Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuperSystem: Add Emitter Contract - Basic Message Passing #11956

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

axelKingsley
Copy link
Contributor

@axelKingsley axelKingsley commented Sep 17, 2024

This PR has two components

Emitter Contract in op-e2e/interop/contracts

Now there is a directory where custom contracts can be used for message passing or other test behaviors. At the moment there is only one: emit.go. The Emitter contract simply takes the caller's data and emits it as a log event. This allows us to generate content on the Supervisor, and we can also use this contract to test the receiving side.
To update the binding, generate.sh does a forge build, extracts the bin and abi, and abigen creates a go binding.

Custom Contracts for L2s are currently stored in a map[string]interface{} to store arbitrary contract bindings in the future. This one is keyed as "emitter".

The Emitter Contract adds two functions to the SuperSystem interface. I'd like to avoid scope-creeping the interface, but for now this provides good abstraction for tests to use this contract:

  • DeployEmitterContract - puts the emitter contract on the specified L2 by the specified user
  • EmitData - uses the Emitter contract keyed as "emitter" for the given L2, and calls it on behalf of the specified user
  • Contracts - does a map lookup and returns the contract item

AddL2RPC without Restarting Supervisor

As soon as the log emissions started, I found another bug in the Supervisor. This one is related to file closing -- in AddL2RPC, we Stop the backend before adding the L2 and then we Start it back up. However, in underlying calls, a file object is closed which never gets opened again.

As a symptom, log emissions for any chain except the most recently added would fail because the underlying file was closed to writing!

I could have tired to make the logDB re-openable, but the real solution was just to make it possible to add new L2s without stopping the existing monitors. It was easier than I expected, the main change required was that the code used to add L2s needed to know whether or not to start the chain-monitor too.

Testing

As soon as log emission worked, the closed-file issue started. By implementing these changes, I see each Chain Monitor start exactly once, and I see them process (or attempt to process) chain updates.

fixes: #11959

Copy link
Contributor

semgrep-app bot commented Sep 17, 2024

Semgrep found 14 sol-style-input-arg-fmt findings:

Inputs to functions must be prepended with an underscore (_)

Ignore this finding from sol-style-input-arg-fmt.

@protolambda protolambda added this pull request to the merge queue Sep 20, 2024
Merged via the queue into develop with commit 2fcbe4b Sep 20, 2024
61 checks passed
@protolambda protolambda deleted the supervisor/SuperSystemContracts branch September 20, 2024 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

interop: decouple op-supervisor endpoints availability
2 participants