From 901afe89213e7e961170d08404732a029d4d0cf3 Mon Sep 17 00:00:00 2001 From: James Kim Date: Wed, 11 Sep 2024 00:46:15 -0700 Subject: [PATCH] docs: create docs site --- .github/workflows/deploy-docs.yml | 32 +++++ docs/.gitignore | 1 + docs/book.toml | 6 + docs/src/SUMMARY.md | 32 +++++ .../src/chain-environment/contracts/README.md | 44 +++++++ .../network-details/README.md | 8 ++ .../network-details/op-chain-a.md | 84 +++++++++++++ .../network-details/op-chain-b.md | 84 +++++++++++++ docs/src/examples/cross-chain-tictactoe.md | 1 + docs/src/getting-started/first-steps.md | 76 ++++++++++++ docs/src/getting-started/installation.md | 31 +++++ docs/src/guides/deposit-transactions.md | 1 + docs/src/guides/interop/README.md | 1 + .../guides/interop/bridging-superchainweth.md | 1 + .../interop/calling-destination-contract.md | 1 + .../src/guides/interop/interop-identifiers.md | 1 + docs/src/introduction.md | 17 +++ docs/src/reference/supersim-fork.md | 117 ++++++++++++++++++ docs/src/reference/supersim.md | 113 +++++++++++++++++ 19 files changed, 651 insertions(+) create mode 100644 .github/workflows/deploy-docs.yml create mode 100644 docs/.gitignore create mode 100644 docs/book.toml create mode 100644 docs/src/SUMMARY.md create mode 100644 docs/src/chain-environment/contracts/README.md create mode 100644 docs/src/chain-environment/network-details/README.md create mode 100644 docs/src/chain-environment/network-details/op-chain-a.md create mode 100644 docs/src/chain-environment/network-details/op-chain-b.md create mode 100644 docs/src/examples/cross-chain-tictactoe.md create mode 100644 docs/src/getting-started/first-steps.md create mode 100644 docs/src/getting-started/installation.md create mode 100644 docs/src/guides/deposit-transactions.md create mode 100644 docs/src/guides/interop/README.md create mode 100644 docs/src/guides/interop/bridging-superchainweth.md create mode 100644 docs/src/guides/interop/calling-destination-contract.md create mode 100644 docs/src/guides/interop/interop-identifiers.md create mode 100644 docs/src/introduction.md create mode 100644 docs/src/reference/supersim-fork.md create mode 100644 docs/src/reference/supersim.md diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..c099e5aa --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,32 @@ +name: Deploy docs +on: + push: + branches: + - main +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: write + deployments: write + name: Publish to GitHub Pages + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install Rust stable toolchain + uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Setup mdbook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: "latest" + - name: Build book + run: mdbook build + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book \ No newline at end of file diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..3006b271 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book/ diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 00000000..ec08714d --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["optimism-collective"] +language = "en" +multilingual = false +src = "src" +title = "Supersim" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 00000000..c1991a4b --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,32 @@ +# Summary + +[Introduction](./introduction.md) + +# Getting Started + +- [Installation](./getting-started/installation.md) +- [First steps](./getting-started/first-steps.md) + +# CLI Reference + +- [supersim](./reference/supersim.md) +- [supersim fork](./reference/supersim-fork.md) + +# Chain Environment + +- [Included contracts](./chain-environment/contracts/README.md) +- [Network details & contract addresses](./chain-environment/network-details/README.md) + - [OPChainA](./chain-environment/network-details/op-chain-a.md) + - [OPChainB](./chain-environment/network-details/op-chain-b.md) + +# Guides + +- [Sending deposit transactions](./guides/deposit-transactions.md) +- [Interoperability](./guides/interop/README.md) + - [Fetching identifiers for interop messages](./guides/interop/interop-identifiers.md) + - [Calling contract on other chain](./guides/interop/calling-destination-contract.md) + - [Bridging SuperchainWETH](./guides/interop/bridging-superchainweth.md) + +# Examples + +- [Cross-chain tic-tac-toe](./examples/cross-chain-tictactoe.md) diff --git a/docs/src/chain-environment/contracts/README.md b/docs/src/chain-environment/contracts/README.md new file mode 100644 index 00000000..d836ee5d --- /dev/null +++ b/docs/src/chain-environment/contracts/README.md @@ -0,0 +1,44 @@ + +# Included contracts + +The chain environment includes contracts already deployed to help replicate the Superchain environment. You can see an example of contract addresses for a L2 system [here](/docs/src/chain-environment/network-details/op-chain-a.md). + +- [OP Stack system contracts (L1)](#op-stack-system-contracts-l1) +- [OP Stack L2 contracts (L2)](#op-stack-l2-contracts-l2) +- [Periphery contracts (L2)](#periphery-contracts-l2) + - [L2NativeSuperchainERC20](#l2nativesuperchainerc20) + - [Minting new tokens](#minting-new-tokens) + + +## OP Stack system contracts (L1) + +These are the L1 contracts that are required for a rollup as part of the OP Stack protocol. Examples are the [OptimismPortal](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/OptimismPortal.sol), [L1StandardBridge](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/L1StandardBridge.sol), and [L1CrossDomainMessenger](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol). + +View examples of these contracts here the official [OP docs](https://docs.optimism.io/chain/addresses#ethereum-l1) or the source code [here in the Optimism monorepo](https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts-bedrock/src/L1) + +## OP Stack L2 contracts (L2) + +The OP Stack system contracts on the L2 are included at the standard addresses by default. + +- [Standard OP Stack predeploys (L2)](https://specs.optimism.io/protocol/predeploys.html) +- [Interoperability predeploys (*experimental*) (L2)](https://specs.optimism.io/interop/predeploys.html) +- [OP Stack preinstalls (L2)](https://specs.optimism.io/protocol/preinstalls.html) + + +## Periphery contracts (L2) + +L2 chains running on `supersim` also includes some useful contracts for testing purposes that are not part of the OP Stack by default. + +### L2NativeSuperchainERC20 + +A simple ERC20 that adheres to the SuperchainERC20 standard. It includes permissionless minting for easy testing. + +Source: [L2NativeSuperchainERC20.sol](/contracts/src/L2NativeSuperchainERC20.sol) + +Deployed address: `0x61a6eF395d217eD7C79e1B84880167a417796172` + +#### Minting new tokens + +```bash +cast send 0x61a6eF395d217eD7C79e1B84880167a417796172 "mint(address _to, uint256 _amount)" $RECIPIENT_ADDRESS 1ether --rpc-url $L2_RPC_URL +``` diff --git a/docs/src/chain-environment/network-details/README.md b/docs/src/chain-environment/network-details/README.md new file mode 100644 index 00000000..48a85ed1 --- /dev/null +++ b/docs/src/chain-environment/network-details/README.md @@ -0,0 +1,8 @@ +# Network details + +By default, two OP Stack systems will be spun up in vanilla mode + +- OPChainA (chainID 901) +- OPChainB (chainID 902) + +Both "roll up" into a single L1 chain (chainID 900). diff --git a/docs/src/chain-environment/network-details/op-chain-a.md b/docs/src/chain-environment/network-details/op-chain-a.md new file mode 100644 index 00000000..d39ab270 --- /dev/null +++ b/docs/src/chain-environment/network-details/op-chain-a.md @@ -0,0 +1,84 @@ + +# OPChainA + +- [Network details](#network-details) +- [Contract addresses](#contract-addresses) + - [L1 contracts](#l1-contracts) + - [L2 contracts](#l2-contracts) + +## Network details + +| **Parameter** | **Value** | +|---------------|-----------------------| +| **Name** | OPChainA | +| **Chain ID** | 901 | +| **RPC URL** | | + +## Contract addresses + +### L1 contracts + +```json +{ + "AddressManager": "0x78d21C9820A9135215202A9a8D6521483D4b75cD", + "AnchorStateRegistry": "0x21799f09394c50220CCD95E7dAc1cdD774FC871a", + "AnchorStateRegistryProxy": "0xa6F40d5770b3509aB40B2effa5cb544D29743ec7", + "DelayedWETH": "0x49BBFf1629824A1e7993Ab5c17AFa45D24AB28c9", + "DelayedWETHProxy": "0x309DA6B9a8fE16afD7D067528d358E55314bEa6b", + "DisputeGameFactory": "0x20B168142354Cee65a32f6D8cf3033E592299765", + "DisputeGameFactoryProxy": "0x444689B81D485bc58AB81aC02A95a937fAa152D7", + "L1CrossDomainMessenger": "0x094e6508ba9d9bf1ce421fff3dE06aE56e67901b", + "L1CrossDomainMessengerProxy": "0xe5bda89cd85cE0DfB80E053281cA070D65B738e6", + "L1ERC721Bridge": "0x5C4F5e749A61a9503c4AAE8a9393e89609a0e804", + "L1ERC721BridgeProxy": "0x018dC24a6617c47cAa00C3fA25097214B2D4F447", + "L1StandardBridge": "0xb7900B27Be8f0E0fF65d1C3A4671e1220437dd2b", + "L1StandardBridgeProxy": "0xa01ae68902e205B420FD164435F299E07b0C778b", + "L2OutputOracle": "0x19652082F846171168Daf378C4fD3ee85a0D4A60", + "L2OutputOracleProxy": "0x6cE0530E823e23be85D8e151FB023605eB4F6d43", + "Mips": "0xB3A0348310a0ff78E5FbDB7f14BB7d3e02d40773", + "OptimismMintableERC20Factory": "0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567", + "OptimismMintableERC20FactoryProxy": "0x15c855966C196Be3a8ca747E8A8Bf40928d4741f", + "OptimismPortal": "0xb7461Fb347f68f9717e6fD12C8407dEcee063bdc", + "OptimismPortal2": "0xfcbb237388CaF5b08175C9927a37aB6450acd535", + "OptimismPortalProxy": "0xF5fe61a258CeBb54CCe428F76cdeD04Cbc12F53d", + "PreimageOracle": "0x3bd7E801E51d48c5d94Ea68e8B801DFFC275De75", + "ProtocolVersions": "0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F", + "ProtocolVersionsProxy": "0x6dA4f6489039d9f4F3144954DDF5bb2F4986e90b", + "ProxyAdmin": "0xe32a4D31ffD5596542DAc8239a1DE3Fff9d63475", + "SafeProxyFactory": "0x4a05c09875DE2DD5B81Bc01dd46eD4699b181bfA", + "SafeSingleton": "0x99A395CE6d6b37CaaCBad64fB42d556b6CA73a48", + "SuperchainConfig": "0x068E44eB31e111028c41598E4535be7468674D0A", + "SuperchainConfigProxy": "0x7E6c6ebCF109fa23277b86bdA39738035C21BB86", + "SystemConfig": "0x6167B477F8d9138aa509f54b2800443857e28c0f", + "SystemConfigProxy": "0xf32919Ed2490b56EaD65E72749894aE4C9523320", + "SystemOwnerSafe": "0xc052b7316C87390E555aF97D42bCd5FB6d5eEFDa" +} +``` + +### L2 contracts + +```json +{ + // OP Stack predeploys + "L2ToL1MessagePasser": "0x4200000000000000000000000000000000000016", + "L2CrossDomainMessenger": "0x4200000000000000000000000000000000000007", + "L2StandardBridge": "0x4200000000000000000000000000000000000010", + "L2ERC721Bridge": "0x4200000000000000000000000000000000000014", + "SequencerFeeVault": "0x4200000000000000000000000000000000000011", + "OptimismMintableERC20Factory": "0x4200000000000000000000000000000000000012", + "OptimismMintableERC721Factory": "0x4200000000000000000000000000000000000017", + "L1BlockInterop": "0x4200000000000000000000000000000000000015", + "GasPriceOracle": "0x420000000000000000000000000000000000000F", + "ProxyAdmin": "0x4200000000000000000000000000000000000018", + "BaseFeeVault": "0x4200000000000000000000000000000000000019", + "L1FeeVault": "0x420000000000000000000000000000000000001A", + "GovernanceToken": "0x4200000000000000000000000000000000000042", + "SchemaRegistry": "0x4200000000000000000000000000000000000020", + "EAS": "0x4200000000000000000000000000000000000021", + "CrossL2Inbox": "0x4200000000000000000000000000000000000022", + "L2ToL2CrossDomainMessenger": "0x4200000000000000000000000000000000000023", + + // Periphery + "L2NativeSuperchainERC20": "0x61a6eF395d217eD7C79e1B84880167a417796172" +} +``` diff --git a/docs/src/chain-environment/network-details/op-chain-b.md b/docs/src/chain-environment/network-details/op-chain-b.md new file mode 100644 index 00000000..54343619 --- /dev/null +++ b/docs/src/chain-environment/network-details/op-chain-b.md @@ -0,0 +1,84 @@ + +# OPChainB + +- [Network details](#network-details) +- [Contract addresses](#contract-addresses) + - [L1 contracts](#l1-contracts) + - [L2 contracts](#l2-contracts) + +## Network details + +| **Parameter** | **Value** | +|---------------|-----------------------| +| **Name** | OPChainB | +| **Chain ID** | 902 | +| **RPC URL** | | + +## Contract addresses + +### L1 contracts + +```json +{ + "AddressManager": "0xafB51A0f73C8409AeA1207DF7f39885c927BeA46", + "AnchorStateRegistry": "0x05493149c84A71063f7948127bb931f8377F779C", + "AnchorStateRegistryProxy": "0xfd0269a716A59fF125Bd7eb65Cd3427C8555bab7", + "DelayedWETH": "0x49BBFf1629824A1e7993Ab5c17AFa45D24AB28c9", + "DelayedWETHProxy": "0xA63353128502269b4A4A4c2677fE316cd9ad4397", + "DisputeGameFactory": "0x20B168142354Cee65a32f6D8cf3033E592299765", + "DisputeGameFactoryProxy": "0x5F416fEb15c8B382d338FDBDb7D44967ca2b59BC", + "L1CrossDomainMessenger": "0x094e6508ba9d9bf1ce421fff3dE06aE56e67901b", + "L1CrossDomainMessengerProxy": "0xCB9768921831677Ae15cE4B64A10B94F49cD88E2", + "L1ERC721Bridge": "0x5C4F5e749A61a9503c4AAE8a9393e89609a0e804", + "L1ERC721BridgeProxy": "0xDCE41E6C0901586EE27Eac329EBD4b5fe5A7170d", + "L1StandardBridge": "0xb7900B27Be8f0E0fF65d1C3A4671e1220437dd2b", + "L1StandardBridgeProxy": "0x2D8543c236a4d626f54B51Fa8bc229a257C5143E", + "L2OutputOracle": "0x19652082F846171168Daf378C4fD3ee85a0D4A60", + "L2OutputOracleProxy": "0x006Af3fB62c4BE4fB0393995d364BbFe6b0F3CB2", + "Mips": "0xB3A0348310a0ff78E5FbDB7f14BB7d3e02d40773", + "OptimismMintableERC20Factory": "0x39Aea2Dd53f2d01c15877aCc2791af6BDD7aD567", + "OptimismMintableERC20FactoryProxy": "0x1A2A942d891e525D1Ab192578a378980729fD585", + "OptimismPortal": "0xb7461Fb347f68f9717e6fD12C8407dEcee063bdc", + "OptimismPortal2": "0xfcbb237388CaF5b08175C9927a37aB6450acd535", + "OptimismPortalProxy": "0xdfC9DEAbEEbDaa7620C71e2E76AEda32919DE5f2", + "PreimageOracle": "0x3bd7E801E51d48c5d94Ea68e8B801DFFC275De75", + "ProtocolVersions": "0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F", + "ProtocolVersionsProxy": "0xE139cB0CDa5EF722870068ea331d0989776A7aDf", + "ProxyAdmin": "0xff5E6C2Af859f70B875BA59B958BEde60E36bf69", + "SafeProxyFactory": "0xb68f3B057fE3c6CdDF9DB35837Ea769FCc81978a", + "SafeSingleton": "0xeeB44D84d505AbD958d032e90704c56443eB3ED0", + "SuperchainConfig": "0x068E44eB31e111028c41598E4535be7468674D0A", + "SuperchainConfigProxy": "0x2ED4AA34573c36bF3856e597501aEf9d9Dc1687C", + "SystemConfig": "0x6167B477F8d9138aa509f54b2800443857e28c0f", + "SystemConfigProxy": "0x2Db03FE998D7c20E4B65afD1f50f04Ec4BfAb694", + "SystemOwnerSafe": "0xBF3830711B7c559042453B7546dB4736eFB4245e" +} +``` + +### L2 contracts + +```json +{ + // OP Stack predeploys + "L2ToL1MessagePasser": "0x4200000000000000000000000000000000000016", + "L2CrossDomainMessenger": "0x4200000000000000000000000000000000000007", + "L2StandardBridge": "0x4200000000000000000000000000000000000010", + "L2ERC721Bridge": "0x4200000000000000000000000000000000000014", + "SequencerFeeVault": "0x4200000000000000000000000000000000000011", + "OptimismMintableERC20Factory": "0x4200000000000000000000000000000000000012", + "OptimismMintableERC721Factory": "0x4200000000000000000000000000000000000017", + "L1BlockInterop": "0x4200000000000000000000000000000000000015", + "GasPriceOracle": "0x420000000000000000000000000000000000000F", + "ProxyAdmin": "0x4200000000000000000000000000000000000018", + "BaseFeeVault": "0x4200000000000000000000000000000000000019", + "L1FeeVault": "0x420000000000000000000000000000000000001A", + "GovernanceToken": "0x4200000000000000000000000000000000000042", + "SchemaRegistry": "0x4200000000000000000000000000000000000020", + "EAS": "0x4200000000000000000000000000000000000021", + "CrossL2Inbox": "0x4200000000000000000000000000000000000022", + "L2ToL2CrossDomainMessenger": "0x4200000000000000000000000000000000000023", + + // Periphery + "L2NativeSuperchainERC20": "0x61a6eF395d217eD7C79e1B84880167a417796172" +} +``` diff --git a/docs/src/examples/cross-chain-tictactoe.md b/docs/src/examples/cross-chain-tictactoe.md new file mode 100644 index 00000000..e0c7b009 --- /dev/null +++ b/docs/src/examples/cross-chain-tictactoe.md @@ -0,0 +1 @@ +# Cross-chain tic-tac-toe diff --git a/docs/src/getting-started/first-steps.md b/docs/src/getting-started/first-steps.md new file mode 100644 index 00000000..9399a8a0 --- /dev/null +++ b/docs/src/getting-started/first-steps.md @@ -0,0 +1,76 @@ +# First steps + +`supersim` allows testing multichain features **locally**. Previously, testing multichain features required complex docker setups or using a testnet. + +To see it in practice, let's first try sending some ETH from the L1 to the L2. + +## Deposit ETH from the L1 into the L2 (L1 to L2 message passing) + +### 1. Call `bridgeETH` function on the `L1StandardBridgeProxy` contract on the L1 (chain 900) + +Initiate a bridge transaction on the L1: + +```sh +cast send 0xa01ae68902e205B420FD164435F299E07b0C778b "bridgeETH(uint32 _minGasLimit, bytes calldata _extraData)" 50000 0x --value 0.1ether --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +``` + +### 2. Check the balance on the L2 (chain 901) + +Verify that the ETH balance of the sender has increased on the L2: + +```sh +cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://127.0.0.1:9545 +``` + +Now that you know how to pass messages from the L1 to the L2, let's try a sending an L2 to L2 message! + +## Send an interoperable SuperchainERC20 token from chain 901 to 902 (L2 to L2 message passing) + +In a typical L2 to L2 cross-chain transfer, two transactions are required: + +1. Send transaction on the source chain – This initiates the token transfer on Chain 901. +2. Relay message transaction on the destination chain – This relays the transfer details to Chain 902. + +To simplify this process, you can use the `--interop.autorelay` flag. This flag automatically triggers the relay message transaction once the initial send transaction is completed on the source chain, improving the developer experience by removing the need to manually send the relay message. + +### 1. Start `supersim` with the autorelayer enabled + +``` +supersim --interop.autorelay +``` + +### 2. Mint tokens to transfer on chain 901 + +Run the following command to mint 1000 tokens to the recipient address: + +```sh +cast send 0x61a6eF395d217eD7C79e1B84880167a417796172 "mint(address _to, uint256 _amount)" 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 1000 --rpc-url http://127.0.0.1:9545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 + +``` + +### 3. Initiate the send transaction on chain 901 + +Send the tokens from Chain 901 to Chain 902 using the following command: + +```sh +cast send 0x61a6eF395d217eD7C79e1B84880167a417796172 "sendERC20(address _to, uint256 _amount, uint256 _chainId)" 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 1000 902 --rpc-url http://127.0.0.1:9545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +``` + +### 4. Wait for the relayed message to appear on chain 902 + +In a few seconds, you should see the RelayedMessage on chain 902: + +```sh +# example +INFO [08-30|14:30:14.698] L2ToL2CrossChainMessenger#RelayedMessage sourceChainID=901 destinationChainID=902 nonce=0 sender=0x61a6eF395d217eD7C79e1B84880167a417796172 target=0x61a6eF395d217eD7C79e1B84880167a417796172 +``` + +### 5. Check the balance on chain 902 + +Verify that the balance of the L2NativeSuperchainERC20 on chain 902 has increased: + +```sh +cast balance --erc20 0x61a6eF395d217eD7C79e1B84880167a417796172 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://127.0.0.1:9546 +``` + +With the steps above, you've now successfully completed both an L1 to L2 ETH bridge and an L2 to L2 interoperable SuperchainERC20 token transfer, all done locally using `supersim`. This approach simplifies multichain testing, allowing you to focus on development without the need for complex setups or relying on external testnets. diff --git a/docs/src/getting-started/installation.md b/docs/src/getting-started/installation.md new file mode 100644 index 00000000..528fdfa5 --- /dev/null +++ b/docs/src/getting-started/installation.md @@ -0,0 +1,31 @@ +# Installation + +## 1. Prerequisites: `foundry` + +`supersim` requires `anvil` to be installed. + +Follow the guide [here](https://book.getfoundry.sh/getting-started/installation) to install the Foundry toolchain. + +## 2. Install `supersim` + +### Precompiled Binaries + +Download the executable for your platform from the [GitHub releases page](https://github.com/ethereum-optimism/supersim/releases). + +### Homebrew (OS X, Linux) + +*Coming soon* + +## 3. Start `supersim` in vanilla mode + +```sh +supersim +``` + +Vanilla mode will start 3 chains, with the OP Stack contracts already deployed. + +- (1) L1 Chain + - Chain 900 +- (2) L2 Chains + - Chain 901 + - Chain 902 diff --git a/docs/src/guides/deposit-transactions.md b/docs/src/guides/deposit-transactions.md new file mode 100644 index 00000000..33339901 --- /dev/null +++ b/docs/src/guides/deposit-transactions.md @@ -0,0 +1 @@ +# Deposit transactions diff --git a/docs/src/guides/interop/README.md b/docs/src/guides/interop/README.md new file mode 100644 index 00000000..2f83d383 --- /dev/null +++ b/docs/src/guides/interop/README.md @@ -0,0 +1 @@ +# Interoperability diff --git a/docs/src/guides/interop/bridging-superchainweth.md b/docs/src/guides/interop/bridging-superchainweth.md new file mode 100644 index 00000000..f866e429 --- /dev/null +++ b/docs/src/guides/interop/bridging-superchainweth.md @@ -0,0 +1 @@ +# Bridging SuperchainWETH diff --git a/docs/src/guides/interop/calling-destination-contract.md b/docs/src/guides/interop/calling-destination-contract.md new file mode 100644 index 00000000..eb0a4ac8 --- /dev/null +++ b/docs/src/guides/interop/calling-destination-contract.md @@ -0,0 +1 @@ +# Calling contracts on destination chain diff --git a/docs/src/guides/interop/interop-identifiers.md b/docs/src/guides/interop/interop-identifiers.md new file mode 100644 index 00000000..59d93934 --- /dev/null +++ b/docs/src/guides/interop/interop-identifiers.md @@ -0,0 +1 @@ +# Fetching identifiers for interop messages diff --git a/docs/src/introduction.md b/docs/src/introduction.md new file mode 100644 index 00000000..48b5fd2b --- /dev/null +++ b/docs/src/introduction.md @@ -0,0 +1,17 @@ +# Introduction + +Supersim is a lightweight tool to simulate the Superchain (with a single L1 and multiple OP-Stack L2s). + +Run multiple local nodes with one command, and coordinate message passing between these chains. + +It does not require a complicated devnet setup and is run using cli commands with configuration options that fall back to sensible defaults if they are not specified. Each chain is an instance of [anvil](https://book.getfoundry.sh/reference/anvil/), though future versions may support other local testing tools. + +## Features + +- spin up multiple anvil nodes +- predeployed OP Stack contracts and useful mock contracts (ERC20) +- fork multiple remote chains (fork the entire Superchain) +- simulate L1 <> L2 message passing (deposits) +- simulate L2 <> L2 message passing (interoperability) and auto-relayer +- (**Coming soon**) Withdrawals +- (**Coming soon**) ERC-4337 account abstraction services (bundlers / paymasters / wallet implementation) diff --git a/docs/src/reference/supersim-fork.md b/docs/src/reference/supersim-fork.md new file mode 100644 index 00000000..11b7c633 --- /dev/null +++ b/docs/src/reference/supersim-fork.md @@ -0,0 +1,117 @@ + +# supersim fork (forked mode) + +- [Overview](#overview) +- [Configuration](#configuration) +- [Notes](#notes) + - [Fork height](#fork-height) + - [Interoperability contracts](#interoperability-contracts) + +## Overview + +```sh +supersim fork +``` + +The supersim fork command simplifies the process of forking multiple chains in the Superchain ecosystem simultaneously. It determines the appropriate block heights for each chain and launches both the L1 and L2 chains based on these values. + +If you're relying on contracts already deployed on testnet / mainnet chains, you can use fork mode to simulate and interact with the state of the chain without needing to re-deploy or modify the contracts. + +Locally fork any of the available chains in a superchain network of the [superchain registry](https://github.com/ethereum-optimism/superchain-registry), default `mainnet` versions. + +**Example startup logs** + +``` +Available Accounts +----------------------- +(0): 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +--- truncated for brevity --- + +Private Keys +----------------------- +(0): 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +--- truncated for brevity --- + +Orchestrator Config: +L1: + Name: mainnet Chain ID: 1 RPC: http://127.0.0.1:8545 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-1-1521250718 +L2: + Name: op Chain ID: 10 RPC: http://127.0.0.1:9545 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-10 + Name: base Chain ID: 8453 RPC: http://127.0.0.1:9546 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-8453 + Name: zora Chain ID: 7777777 RPC: http://127.0.0.1:9547 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-7777777 +``` + +## Configuration + +``` +NAME: + supersim fork - Locally fork a network in the superchain registry + +USAGE: + supersim fork [command options] + +OPTIONS: + + --l1.fork.height value (default: 0) ($SUPERSIM_L1_FORK_HEIGHT) + L1 height to fork the superchain (bounds L2 time). `0` for latest + + --chains value ($SUPERSIM_CHAINS) + chains to fork in the superchain, mainnet options: [base, lyra, metal, mode, op, + orderly, race, zora]. In order to replace the public rpc endpoint for a chain, + specify the ($SUPERSIM_RPC_URL_) env variable. i.e + SUPERSIM_RPC_URL_OP=http://optimism-mainnet.infura.io/v3/ + + --network value (default: "mainnet") ($SUPERSIM_NETWORK) + superchain network. options: mainnet, sepolia, sepolia-dev-0. In order to + replace the public rpc endpoint for the network, specify the + ($SUPERSIM_RPC_URL_) env variable. i.e + SUPERSIM_RPC_URL_MAINNET=http://mainnet.infura.io/v3/ + + --interop.enabled (default: false) ($SUPERSIM_FORK_WITH_INTEROP) + Enable interop in fork mode + + --l1.port value (default: 8545) ($SUPERSIM_L1_PORT) + Listening port for the L1 instance. `0` binds to any available port + + --l2.starting.port value (default: 9545) ($SUPERSIM_L2_STARTING_PORT) + Starting port to increment from for L2 chains. `0` binds each chain to any + available port + + --interop.autorelay (default: false) ($SUPERSIM_AUTORELAY) + Automatically relay messages sent to the L2ToL2CrossDomainMessenger using + account 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 + + --aa.bundler (default: false) ($SUPERSIM_AA_BUNDLER) + Run a ERC-4337 Bundler which sends transactions using account + 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f + + --log.level value (default: INFO) ($SUPERSIM_LOG_LEVEL) + The lowest log level that will be output + + --log.format value (default: text) ($SUPERSIM_LOG_FORMAT) + Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', + 'json-pretty', + + --log.color (default: false) ($SUPERSIM_LOG_COLOR) + Color the log output if in terminal mode + + --log.pid (default: false) ($SUPERSIM_LOG_PID) + Show pid in the log + + --help, -h (default: false) + show help +``` + +## Notes + +### Fork height + +The fork height is determined by L1 block height (default `latest`). This is then used to derive the corresponding L2 block to start from. + +### Interoperability contracts + +By default, interop contracts are not deployed on forked networks. To include them, run supersim with the `--interop.enabled` flag. + +```sh +supersim fork --chains=op,base,zora --interop.enabled +``` diff --git a/docs/src/reference/supersim.md b/docs/src/reference/supersim.md new file mode 100644 index 00000000..f15ebce4 --- /dev/null +++ b/docs/src/reference/supersim.md @@ -0,0 +1,113 @@ + +# supersim (vanilla mode) + +- [Overview](#overview) +- [Configuration](#configuration) + +## Overview + +Start supersim in vanilla (non-forked) mode + +```sh +supersim +``` + +Vanilla mode will start 3 chains, with the OP Stack contracts & periphery contracts already deployed. + +- (1) L1 Chain + - Chain 900 +- (2) L2 Chains + - Chain 901 + - Chain 902 + +**Example startup logs** + +``` +Available Accounts +----------------------- +(0): 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +(1): 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +(2): 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC +(3): 0x90F79bf6EB2c4f870365E785982E1f101E93b906 +(4): 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 +(5): 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc +(6): 0x976EA74026E726554dB657fA54763abd0C3a0aa9 +(7): 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 +(8): 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f +(9): 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 + +Private Keys +----------------------- +(0): 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +(1): 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d +(2): 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a +(3): 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 +(4): 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a +(5): 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba +(6): 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e +(7): 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 +(8): 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 +(9): 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 + +Orchestrator Config: +L1: + Name: L1 Chain ID: 900 RPC: http://127.0.0.1:8545 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-900 +L2: + Name: OPChainA Chain ID: 901 RPC: http://127.0.0.1:9545 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-901 + Name: OPChainB Chain ID: 902 RPC: http://127.0.0.1:9546 LogPath: /var/folders/0w/ethers-phoenix/T/anvil-chain-902 +``` + +## Configuration + +``` +NAME: + supersim - Superchain Multi-L2 Simulator + +USAGE: + supersim [global options] command [command options] + +VERSION: + untagged + +DESCRIPTION: + Local multichain optimism development environment + +COMMANDS: + fork Locally fork a network in the superchain registry + help, h Shows a list of commands or help for one command + +GLOBAL OPTIONS: + + --interop.autorelay (default: false) ($SUPERSIM_AUTORELAY) + Automatically relay messages sent to the L2ToL2CrossDomainMessenger using + account 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 + + --l1.port value (default: 8545) ($SUPERSIM_L1_PORT) + Listening port for the L1 instance. `0` binds to any available port + + --l2.starting.port value (default: 9545) ($SUPERSIM_L2_STARTING_PORT) + Starting port to increment from for L2 chains. `0` binds each chain to any + available port + + --log.color (default: false) ($SUPERSIM_LOG_COLOR) + Color the log output if in terminal mode + + --log.format value (default: text) ($SUPERSIM_LOG_FORMAT) + Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', + 'json-pretty', + + --log.level value (default: INFO) ($SUPERSIM_LOG_LEVEL) + The lowest log level that will be output + + --log.pid (default: false) ($SUPERSIM_LOG_PID) + Show pid in the log + + MISC + + + --help, -h (default: false) + show help + + --version, -v (default: false) + print the version +```