-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-node/rollup/derive: implement SetCodeTx span batches #14197
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
sebastianst
merged 15 commits into
ethereum-optimism:develop
from
meyer9:meyer9/implement-isthmus-7702-span-batch-tests
Mar 14, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aa29436
feat: implement EIP-7702 span batch tests
meyer9 e272604
Don't overwrite alloc
meyer9 57249bd
Check error
meyer9 af432ff
Fix lint
meyer9 0efe4e9
Add SetCode txs to tests and switch signer
meyer9 cbf5784
Use old signer
meyer9 d93c341
Implement as FP action test
meyer9 d08207b
Remove old test
meyer9 4601c18
Clean up code
meyer9 2a3e364
Cover set code auth in unit tests
meyer9 bae06a7
Remove extra file
meyer9 71846d2
Update channel out sizes since random tx changed
meyer9 c69363d
Use test matrix
meyer9 747db5c
Simplify RunFPP call
meyer9 cfc1145
add back bob address sanity check
sebastianst 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
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 |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| package proofs_test | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "testing" | ||
|
|
||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
| "github.com/ethereum/go-ethereum/core/vm/program" | ||
| "github.com/holiman/uint256" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" | ||
| ) | ||
|
|
||
| var ( | ||
| aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") | ||
| bb = common.HexToAddress("0x000000000000000000000000000000000000bbbb") | ||
| ) | ||
|
|
||
| func runSetCodeTxTypeTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { | ||
| t := actionsHelpers.NewDefaultTesting(gt) | ||
|
|
||
| // hardcoded because it's not available until after we need it | ||
| bobAddr := common.HexToAddress("0x14dC79964da2C08b23698B3D3cc7Ca32193d9955") | ||
|
|
||
| // Create 2 contracts, (1) writes 42 to slot 42, (2) calls (1) | ||
| store42Program := program.New().Sstore(0x42, 0x42) | ||
| callBobProgram := program.New().Call(nil, bobAddr, 1, 0, 0, 0, 0) | ||
|
|
||
| alloc := *actionsHelpers.DefaultAlloc | ||
| alloc.L2Alloc = make(map[common.Address]types.Account) | ||
| alloc.L2Alloc[aa] = types.Account{ | ||
| Code: store42Program.Bytes(), | ||
| } | ||
| alloc.L2Alloc[bb] = types.Account{ | ||
| Code: callBobProgram.Bytes(), | ||
| } | ||
|
|
||
| testCfg.Allocs = &alloc | ||
|
|
||
| tp := helpers.NewTestParams() | ||
| env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg()) | ||
| require.Equal(gt, env.Bob.Address(), bobAddr) | ||
|
|
||
| cl := env.Engine.EthClient() | ||
|
|
||
| env.Sequencer.ActL2PipelineFull(t) | ||
| env.Miner.ActEmptyBlock(t) | ||
| env.Sequencer.ActL2StartBlock(t) | ||
|
|
||
| aliceSecret := env.Alice.L2.Secret() | ||
| bobSecret := env.Bob.L2.Secret() | ||
|
|
||
| chainID := env.Sequencer.RollupCfg.L2ChainID | ||
|
|
||
| // Sign authorization tuples. | ||
| // The way the auths are combined, it becomes | ||
| // 1. tx -> addr1 which is delegated to 0xaaaa | ||
| // 2. addr1:0xaaaa calls into addr2:0xbbbb | ||
| // 3. addr2:0xbbbb writes to storage | ||
| auth1, err := types.SignSetCode(aliceSecret, types.SetCodeAuthorization{ | ||
| ChainID: *uint256.MustFromBig(chainID), | ||
| Address: bb, | ||
| Nonce: 1, | ||
| }) | ||
| require.NoError(gt, err, "failed to sign auth1") | ||
| auth2, err := types.SignSetCode(bobSecret, types.SetCodeAuthorization{ | ||
| Address: aa, | ||
| Nonce: 0, | ||
| }) | ||
| require.NoError(gt, err, "failed to sign auth2") | ||
|
|
||
| txdata := &types.SetCodeTx{ | ||
| ChainID: uint256.MustFromBig(chainID), | ||
| Nonce: 0, | ||
| To: env.Alice.Address(), | ||
| Gas: 500000, | ||
| GasFeeCap: uint256.NewInt(5000000000), | ||
| GasTipCap: uint256.NewInt(2), | ||
| AuthList: []types.SetCodeAuthorization{auth1, auth2}, | ||
| } | ||
| signer := types.NewIsthmusSigner(chainID) | ||
| tx := types.MustSignNewTx(aliceSecret, signer, txdata) | ||
|
|
||
| err = cl.SendTransaction(t.Ctx(), tx) | ||
| require.NoError(gt, err, "failed to send set code tx") | ||
|
|
||
| _, err = env.Engine.EngineApi.IncludeTx(tx, env.Alice.Address()) | ||
| require.NoError(t, err, "failed to include set code tx") | ||
|
|
||
| env.Sequencer.ActL2EndBlock(t) | ||
|
|
||
| // Verify delegation designations were deployed. | ||
| bobCode, err := cl.PendingCodeAt(t.Ctx(), env.Bob.Address()) | ||
| require.NoError(gt, err, "failed to get bob code") | ||
| want := types.AddressToDelegation(auth2.Address) | ||
| if !bytes.Equal(bobCode, want) { | ||
| t.Fatalf("addr1 code incorrect: got %s, want %s", common.Bytes2Hex(bobCode), common.Bytes2Hex(want)) | ||
| } | ||
| aliceCode, err := cl.PendingCodeAt(t.Ctx(), env.Alice.Address()) | ||
| require.NoError(gt, err, "failed to get alice code") | ||
| want = types.AddressToDelegation(auth1.Address) | ||
| if !bytes.Equal(aliceCode, want) { | ||
| t.Fatalf("addr2 code incorrect: got %s, want %s", common.Bytes2Hex(aliceCode), common.Bytes2Hex(want)) | ||
| } | ||
|
|
||
| // Verify delegation executed the correct code. | ||
| fortyTwo := common.BytesToHash([]byte{0x42}) | ||
| actual, err := cl.PendingStorageAt(t.Ctx(), env.Bob.Address(), fortyTwo) | ||
| require.NoError(gt, err, "failed to get addr1 storage") | ||
|
|
||
| if !bytes.Equal(actual, fortyTwo[:]) { | ||
| t.Fatalf("addr2 storage wrong: expected %d, got %d", fortyTwo, actual) | ||
| } | ||
|
|
||
| // batch submit to L1. batcher should submit span batches. | ||
| env.BatchAndMine(t) | ||
|
|
||
| env.Sequencer.ActL1HeadSignal(t) | ||
| env.Sequencer.ActL2PipelineFull(t) | ||
|
|
||
| latestBlock, err := cl.BlockByNumber(t.Ctx(), nil) | ||
| require.NoError(t, err, "error fetching latest block") | ||
|
|
||
| env.RunFaultProofProgram(t, latestBlock.NumberU64(), testCfg.CheckResult, testCfg.InputParams...) | ||
| } | ||
|
|
||
| func TestSetCodeTx(gt *testing.T) { | ||
| matrix := helpers.NewMatrix[any]() | ||
| defer matrix.Run(gt) | ||
|
|
||
| matrix.AddDefaultTestCases( | ||
| nil, | ||
| helpers.LatestForkOnly, | ||
| runSetCodeTxTypeTest, | ||
| ) | ||
| } | ||
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
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.