-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add DA Footprint Limit Acceptance Test #17034
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
Closed
Closed
Changes from all commits
Commits
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
102 changes: 102 additions & 0 deletions
102
op-acceptance-tests/tests/jovian/calldata_footprint_test.go
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,102 @@ | ||
| package jovian | ||
|
|
||
| import ( | ||
| "crypto/rand" | ||
| "fmt" | ||
| "math/big" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/dsl" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| "github.com/ethereum-optimism/optimism/op-node/rollup" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| "github.com/ethereum-optimism/optimism/op-service/txplan" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/params" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func sendTx(t devtest.T, eoa *dsl.EOA, to common.Address, calldataSize int) { | ||
| data := make([]byte, calldataSize) | ||
| _, err := rand.Read(data) | ||
| t.Require().NoError(err) | ||
| eoa.Transact( | ||
| eoa.Plan(), | ||
| txplan.WithTo(&to), | ||
| txplan.WithData(data), | ||
| ) | ||
| fmt.Println("sent tx", eoa.Address()) | ||
| } | ||
|
|
||
| // TestCalldataFootprint generates a large volume of transactions with configurable calldata size. | ||
| // It is used to test the calldata footprint response of the L2 under Jovian HF. | ||
| func TestCalldataFootprint(gt *testing.T) { | ||
| t := devtest.SerialT(gt) | ||
| sys := presets.NewMinimal(t) | ||
|
|
||
| // check that the chain is running on Jovian fork | ||
| err := dsl.RequiresL2Fork(t.Ctx(), sys, 0, rollup.Jovian) | ||
| require.NoError(t, err, "Jovian fork must be active for this test") | ||
|
|
||
| calldataSize := 120_000 | ||
| eoaGroupSize := 50 | ||
|
|
||
| // create eoas | ||
| eoaGroup := make([]*dsl.EOA, eoaGroupSize) | ||
| for i := range eoaGroup { | ||
| eoaGroup[i] = sys.FunderL2.NewFundedEOA(eth.HundredEther) | ||
| } | ||
|
|
||
| // all eoas send tx to the same recipient simultaneously | ||
| to := eoaGroup[0].Address() | ||
| wg := sync.WaitGroup{} | ||
| for i := range eoaGroup { | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| sendTx(t, eoaGroup[i], to, calldataSize) | ||
| }() | ||
| } | ||
| wg.Wait() | ||
| fmt.Println("all txs sent") | ||
|
|
||
| // get blocks of the L2 and check for the txs | ||
| ethClient := sys.L2Chain.Escape().L2ELNodes()[0].EthClient() | ||
| lastBlock, err := ethClient.BlockRefByLabel(t.Ctx(), eth.BlockLabel(eth.Unsafe)) | ||
| t.Require().NoError(err) | ||
|
|
||
| daLimitedSeen := false | ||
| // check for the txs in the block | ||
| for i := range lastBlock.Number { | ||
| info, txs, err := ethClient.InfoAndTxsByNumber(t.Ctx(), uint64(i)) | ||
| t.Require().NoError(err) | ||
| fmt.Println("txs", txs.Len()) | ||
| fmt.Println("info", info) | ||
| blockGasUsed := info.GasUsed() | ||
| gasUsedAccumulated := uint64(0) | ||
| daFootprintAccumulated := big.NewInt(0) | ||
| for _, tx := range txs { | ||
| receipt, err := ethClient.TransactionReceipt(t.Ctx(), tx.Hash()) | ||
| t.Require().NoError(err) | ||
| gasUsedAccumulated += receipt.GasUsed | ||
| daFootprintAccumulated.Add(daFootprintAccumulated, tx.RollupCostData().EstimatedDASize()) | ||
| } | ||
| fmt.Println("blockGasUsed", blockGasUsed) | ||
| fmt.Println("gasUsedAccumulated", gasUsedAccumulated) | ||
| fmt.Println("daFootprintAccumulated", daFootprintAccumulated) | ||
|
|
||
| // if the blockGasUsed is based on actual gasUsed, nothing to validate | ||
| if blockGasUsed == gasUsedAccumulated { | ||
| continue | ||
| } | ||
|
|
||
| // else, the blockGasUsed is based on da footprint, | ||
| // so we need to validate that the calldata footprint rules were followed | ||
| daFootprintAccumulated.Mul(daFootprintAccumulated, big.NewInt(params.DAFootprintGasScalar)) | ||
| require.Equal(t, daFootprintAccumulated, big.NewInt(int64(blockGasUsed)), "blockGasUsed is not gas or da based") | ||
| daLimitedSeen = true | ||
| } | ||
| require.True(t, daLimitedSeen, "no da limited blocks seen") | ||
| } | ||
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,34 @@ | ||
| package jovian | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-chain-ops/devkeys" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/stack" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/sysgo" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/intentbuilder" | ||
| "github.com/ethereum-optimism/optimism/op-node/rollup" | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| presets.DoMain(m, | ||
| presets.WithMinimal(), | ||
| WithJovianEnabled(), | ||
| ) | ||
| } | ||
|
|
||
| // WithJovianEnabled creates a preset option that enables Jovian hardfork at genesis | ||
| func WithJovianEnabled() stack.CommonOption { | ||
| return stack.MakeCommon(sysgo.WithDeployerOptions(WithJovianAtGenesis())) | ||
| } | ||
|
|
||
| // Helper function to activate Jovian at genesis | ||
| func WithJovianAtGenesis() sysgo.DeployerOption { | ||
| return func(p devtest.P, keys devkeys.Keys, builder intentbuilder.Builder) { | ||
| for _, l2Cfg := range builder.L2s() { | ||
| l2Cfg.WithForkAtGenesis(rollup.Jovian) | ||
| } | ||
| } | ||
| } |
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.
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.
Right now the mere presence of transactions, even with negligible calldata, is causing bad blocks and failure to include the tx. Not sure why, investigating this, but I assume it's an issue with the feature.