forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Add fallback mechanism test #305
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
Merged
philippecamacho
merged 5 commits into
celo-integration-rebase-14.1
from
ag/switch-batchers
Dec 19, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package environment_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| env "github.com/ethereum-optimism/optimism/espresso/environment" | ||
| "github.com/ethereum-optimism/optimism/op-batcher/bindings" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/system/e2esys" | ||
| "github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestBatcherSwitching(t *testing.T) { | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| defer cancel() | ||
|
|
||
| launcher := new(env.EspressoDevNodeLauncherDocker) | ||
|
|
||
| system, espressoDevNode, err := launcher.StartE2eDevnet(ctx, t) | ||
| require.NoError(t, err) | ||
|
|
||
| l1Client := system.NodeClient(e2esys.RoleL1) | ||
|
|
||
| defer env.Stop(t, system) | ||
| defer env.Stop(t, espressoDevNode) | ||
|
|
||
| // Send Transaction on L1, and wait for verification on the L2 Verifier | ||
| env.RunSimpleL1TransferAndVerifier(ctx, t, system) | ||
|
|
||
| // Verify everything works | ||
| env.RunSimpleL2Burn(ctx, t, system) | ||
|
|
||
| // Stop the "TEE" batcher | ||
| err = system.BatchSubmitter.TestDriver().StopBatchSubmitting(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| // Switch active batcher | ||
| options, err := bind.NewKeyedTransactorWithChainID(system.Config().Secrets.Deployer, system.Cfg.L1ChainIDBig()) | ||
| require.NoError(t, err) | ||
|
|
||
| batchAuthenticator, err := bindings.NewBatchAuthenticator(system.RollupConfig.BatchAuthenticatorAddress, l1Client) | ||
| require.NoError(t, err) | ||
|
|
||
| tx, err := batchAuthenticator.SwitchBatcher(options) | ||
| require.NoError(t, err) | ||
| _, err = wait.ForReceiptOK(ctx, l1Client, tx.Hash()) | ||
| require.NoError(t, err) | ||
|
|
||
| // Start the fallback batcher | ||
| err = system.FallbackBatchSubmitter.TestDriver().StartBatchSubmitting() | ||
| require.NoError(t, err) | ||
|
|
||
| // Everything should still work | ||
| env.RunSimpleL2Burn(ctx, t, system) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ import ( | |
| "github.com/ethereum-optimism/optimism/op-node/rollup" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/crypto" | ||
| "github.com/ethereum/go-ethereum/params" | ||
| "github.com/holiman/uint256" | ||
| "golang.org/x/exp/maps" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-e2e/config/secrets" | ||
|
|
@@ -37,6 +39,9 @@ import ( | |
| ) | ||
|
|
||
| const ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY = "5fede428b9506dee864b0d85aefb2409f4728313eb41da4121409299c487f816" | ||
| const ESPRESSO_TESTING_BATCHER_EPHEMERAL_KEY = "404520dcd0335deccd7d4a01f29136dfd651b89ec3969d53a06c3cc5aae5f515" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this key computed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a random one. |
||
|
|
||
| var ESPRESSO_NON_TEE_BATCHER_ADDRESS = common.HexToAddress("0x78A424C38759DDA4A4F349e661Aa3523CFf3BacB") | ||
|
|
||
| // legacy geth log levels - the geth command line --verbosity flag wasn't | ||
| // migrated to use slog's numerical levels. | ||
|
|
@@ -58,7 +63,6 @@ const ( | |
| AllocTypeL2OO AllocType = "l2oo" | ||
| AllocTypeMTCannon AllocType = "mt-cannon" | ||
| AllocTypeMTCannonNext AllocType = "mt-cannon-next" | ||
| AllocTypeEspresso AllocType = "espresso" | ||
| AllocTypeEspressoWithoutEnclave AllocType = "espresso-no-enclave" | ||
| AllocTypeEspressoWithEnclave AllocType = "espresso-enclave" | ||
|
|
||
|
|
@@ -74,14 +78,18 @@ func (a AllocType) Check() error { | |
|
|
||
| func (a AllocType) UsesProofs() bool { | ||
| switch a { | ||
| case AllocTypeStandard, AllocTypeMTCannon, AllocTypeMTCannonNext, AllocTypeAltDA, AllocTypeAltDAGeneric, AllocTypeEspresso, AllocTypeEspressoWithEnclave, AllocTypeEspressoWithoutEnclave: | ||
| case AllocTypeStandard, AllocTypeMTCannon, AllocTypeMTCannonNext, AllocTypeAltDA, AllocTypeAltDAGeneric, AllocTypeEspressoWithEnclave, AllocTypeEspressoWithoutEnclave: | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| var allocTypes = []AllocType{AllocTypeStandard, AllocTypeAltDA, AllocTypeAltDAGeneric, AllocTypeL2OO, AllocTypeMTCannon, AllocTypeEspresso, AllocTypeMTCannonNext, AllocTypeEspressoWithEnclave, AllocTypeEspressoWithoutEnclave} | ||
| func (a AllocType) IsEspresso() bool { | ||
| return a == AllocTypeEspressoWithEnclave || a == AllocTypeEspressoWithoutEnclave | ||
| } | ||
|
|
||
| var allocTypes = []AllocType{AllocTypeStandard, AllocTypeAltDA, AllocTypeAltDAGeneric, AllocTypeL2OO, AllocTypeMTCannon, AllocTypeMTCannonNext, AllocTypeEspressoWithEnclave, AllocTypeEspressoWithoutEnclave} | ||
|
|
||
| var ( | ||
| // All of the following variables are set in the init function | ||
|
|
@@ -288,14 +296,34 @@ func initAllocType(root string, allocType AllocType) { | |
| } | ||
|
|
||
| // Configure Espresso allocation types | ||
| if allocType == AllocTypeEspressoWithoutEnclave || allocType == AllocTypeEspressoWithEnclave { | ||
| batcherPk, err := crypto.HexToECDSA(ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) | ||
| if allocType.IsEspresso() { | ||
| intent.Chains[0].EspressoEnabled = true | ||
| intent.Chains[0].TeeBatcher = intent.Chains[0].Roles.Batcher | ||
|
|
||
| nonTeeBatcherPk, err := crypto.HexToECDSA(ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) | ||
| if err != nil { | ||
| panic(fmt.Errorf("failed to parse batcher private key: %w", err)) | ||
| } | ||
| intent.Chains[0].EspressoEnabled = true | ||
| intent.Chains[0].NonTeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey) | ||
| intent.Chains[0].TeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey) | ||
| nonTeeBatcherAddr := crypto.PubkeyToAddress(nonTeeBatcherPk.PublicKey) | ||
| intent.Chains[0].NonTeeBatcher = nonTeeBatcherAddr | ||
|
|
||
| // Fund the fallback batcher | ||
| if intent.L1DevGenesisParams == nil { | ||
| intent.L1DevGenesisParams = &state.L1DevGenesisParams{} | ||
| } | ||
| if intent.L1DevGenesisParams.Prefund == nil { | ||
| intent.L1DevGenesisParams.Prefund = make(map[common.Address]*hexutil.U256) | ||
| } | ||
| millionEth := (*hexutil.U256)(new(uint256.Int).Mul(uint256.NewInt(1_000_000), uint256.NewInt(params.Ether))) | ||
| intent.L1DevGenesisParams.Prefund[nonTeeBatcherAddr] = millionEth | ||
| } | ||
|
|
||
| if allocType == AllocTypeEspressoWithoutEnclave { | ||
| ephemeralPk, err := crypto.HexToECDSA(ESPRESSO_TESTING_BATCHER_EPHEMERAL_KEY) | ||
| if err != nil { | ||
| panic(fmt.Errorf("failed to parse batcher private key: %w", err)) | ||
| } | ||
| intent.Chains[0].PreRegisteredBatcher = crypto.PubkeyToAddress(ephemeralPk.PublicKey) | ||
| } | ||
|
|
||
| baseUpgradeSchedule := map[string]any{ | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.