-
Notifications
You must be signed in to change notification settings - Fork 23
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
design-doc: supersim #34
Conversation
Change formatting Update formatting
## Usage | ||
|
||
```bash | ||
// brings up two vanilla op chains with each other in the dep set with the same L1 chain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides two L2s, does it also include running the L1 chain itself? Or are there existing different preferred tools to test a L1 <> L2 chain combination in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does - supersim's orchestrator spins up an L1 and multiple L2s.
|
||
|
||
|
||
D1[Check Interop Message Invariants] -->|If Pass|D2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear debug messages, so the user understands how/why their interop executing message is invalid, would be really useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! will add this to be an explicit requirement.
* Orchestrator should also run an L1 instance, though L1 withdrawals won’t initially be supported. | ||
* Eventually supersim can be extended to be used with HardHat and other local simulation tools as well. | ||
|
||
3. **Genesis-applier** : The `genesis-applier` takes genesis files output by the monorepo and applies them to anvil instances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The monorepo currently outputs allocs-X.json
files, where X
is a feature-set like a hardfork. E.g. allocs-ecotone.json
. We might just want to output an additional allocs-supersim.json
with any pre-configured things for the supersim, if more internal EVM things have to change.
Also note that some L2 contracts contain references to the L1, which would need to be updated, to make it work e.g. with different L1 deployments, chain-IDs, etc. Any improvements here, to make templating easier, like not using immutable
but storage
(so contract bytecode never has to be touched) would be really helpful, but has not been prioritized yet (even though it's currently affecting the monorepo testing, the superchain-registry, and the supersim).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh the allocs approach is interesting! We have been talking about the best ways to identify what exactly should be used for genesis, and this could be a really helpful option.
We'll look into the L1 references in the L2 contracts. Maybe we can help make the changes if it makes sense. I'd like to be able to use the contracts as is rather than have to edit them on our end, if at all possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to directly use the JSON allocs files to populate anvil
instances in vanilla mode, would be surprised if they don't already support a CLI flag for this, where you can just pass a path to an allocs file and its applied. Then we can avoid the need to write another tool that converts an allocs file into JSON anvil_setCode
/anvil_setStorage
calls. Ideally we reuse as much of our existing tooling as possible here, so the deploy script with --sig runWithStateDump()
so that the same genesis is created as in the production setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tynes makes sense! we're using anvil --init
to pass a pre-made genesis.json
in terms of generating the state dump, definitely alligned on trying to use the deploy script as is. basically copied the logic in the python script in the monorepo and added some functionality to handle for multiple l2s https://github.com/ethereum-optimism/supersim/pull/53/files.
* Can be multi-step: multiple genesis files can be applied idempotently, particularly in forking mode (when you fork a network that has bedrock contracts but not interop contracts, for instance). | ||
* Genesis-applier should work as a standalone tool: if a developer is using Anvil outside the context of the orchestrator, they should be able to use genesis-applier to apply genesis state to their instance. In the context of supersim, the `orchestrator` will use the `genesis-applier` to apply the needed genesis state to the anvil instances it is running. | ||
|
||
4. **Chain-config-loader**: Downloads the latest chain config from the superchain registry to allow the orchestrator to apply needed configs to anvil instances. Should be a standalone tool that works with the orchestrator but could be used directly on local testing nodes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's part of the other tooling, and written in Go or rust, then it should be relatively straight-forward to just import the superchain-registry as library. Like the op-node does.
|
||
### Services | ||
|
||
Given the application flow, the following services will be part of supersim: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this all still be packaged into the same executable? I don't see a user installing and running 6 different tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 100%, the orchestrator spins these up but it is all "supersim."
|
||
Supersim will be a lightweight tool that simulates an interoperable Superchain environment locally. It will not require a complicated devnet setup and will be run using cli commands with configuration options that fall back to sensible defaults if they are not specified. Predefined state can be passed in at startup or the state can be forked based on specified block height. | ||
|
||
From a developer perspective, supersim will offer a command line interface through which to easily start up multiple local testnets that can be used interoperably via the [Optimism Interop Protocol](https://github.com/ethereum-optimism/specs/tree/main/specs/interop). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it orchestrate each instance? Through Docker or something similar?
|
||
1. Orchestrator acquires L1 reference block to get the latest L2 height for forking using l2-fork-state-finder. | ||
2. Orchestrator gets appropriate chain configs from the superchain registry using the chain-config-loader. | ||
3. Orchestrator starts the requested chains at determined L2 block height. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this means that you'd need RPCs for all chains in your forked interop set, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For forking, yes I don't see a way around that. We were planning to default to public RPCs where possible and allow users to override.
|
||
3. **Genesis-applier** : The `genesis-applier` takes genesis files output by the monorepo and applies them to anvil instances. | ||
|
||
* The genesis files needed will differ depending on whether the user is in vanilla or forked mode, and forked mode is unlikely to need anything other than the interop contracts initially. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could create a small script to install the interop contracts in the short term
|
||
6. **Op-simulator**: Proxy server in front of anvil instances that simulates op-stack services without the real derivation pipeline. | ||
|
||
* Simulates deposits by listening to the `optimismPortal` and forwarding deposit txs via `eth_sendRawTransaction`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Design document for supersim, a local multichain development environment for app developers building on the Superchain.