From 50d6e5b7fc29420e1a67bcba2970ee02295c2ee1 Mon Sep 17 00:00:00 2001 From: Sebastian Stammler Date: Tue, 10 Dec 2024 19:50:30 +0100 Subject: [PATCH] Pass empty ChainConfig to all types.NewBlock calls This uses pre-Isthmus blocks in all tests for now. --- op-batcher/batcher/channel_builder_test.go | 4 +-- op-batcher/batcher/channel_manager_test.go | 26 +++++++++---------- op-e2e/actions/helpers/l1_miner.go | 3 ++- op-node/rollup/derive/test/random.go | 5 ++-- op-program/client/l2/engine_test.go | 3 ++- .../client/l2/engineapi/l2_engine_api.go | 2 +- op-service/testutils/random.go | 3 ++- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/op-batcher/batcher/channel_builder_test.go b/op-batcher/batcher/channel_builder_test.go index a6cb9371f9c08..f6e6a99c4b607 100644 --- a/op-batcher/batcher/channel_builder_test.go +++ b/op-batcher/batcher/channel_builder_test.go @@ -75,7 +75,7 @@ func newMiniL2BlockWithNumberParentAndL1Information(numTx int, l2Number *big.Int Difficulty: common.Big0, Number: big.NewInt(l1Number), Time: blockTime, - }, nil, nil, trie.NewStackTrie(nil)) + }, nil, nil, trie.NewStackTrie(nil), emptyChainCfg) l1InfoTx, err := derive.L1InfoDeposit(defaultTestRollupConfig, eth.SystemConfig{}, 0, eth.BlockToInfo(l1Block), blockTime) if err != nil { panic(err) @@ -90,7 +90,7 @@ func newMiniL2BlockWithNumberParentAndL1Information(numTx int, l2Number *big.Int return types.NewBlock(&types.Header{ Number: l2Number, ParentHash: parent, - }, &types.Body{Transactions: txs}, nil, trie.NewStackTrie(nil)) + }, &types.Body{Transactions: txs}, nil, trie.NewStackTrie(nil), emptyChainCfg) } // addTooManyBlocks adds blocks to the channel until it hits an error, diff --git a/op-batcher/batcher/channel_manager_test.go b/op-batcher/batcher/channel_manager_test.go index d1a0037a5d0d4..ff5998329d1d3 100644 --- a/op-batcher/batcher/channel_manager_test.go +++ b/op-batcher/batcher/channel_manager_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/require" ) @@ -56,6 +57,8 @@ func TestChannelManagerBatchType(t *testing.T) { } } +var emptyChainCfg = ¶ms.ChainConfig{} // no Isthmus + // ChannelManagerReturnsErrReorg ensures that the channel manager // detects a reorg when it has cached L1 blocks. func ChannelManagerReturnsErrReorg(t *testing.T, batchType uint) { @@ -65,19 +68,19 @@ func ChannelManagerReturnsErrReorg(t *testing.T, batchType uint) { a := types.NewBlock(&types.Header{ Number: big.NewInt(0), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) b := types.NewBlock(&types.Header{ Number: big.NewInt(1), ParentHash: a.Hash(), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) c := types.NewBlock(&types.Header{ Number: big.NewInt(2), ParentHash: b.Hash(), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) x := types.NewBlock(&types.Header{ Number: big.NewInt(2), ParentHash: common.Hash{0xff}, - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) require.NoError(t, m.AddL2Block(a)) require.NoError(t, m.AddL2Block(b)) @@ -166,7 +169,7 @@ func ChannelManager_Clear(t *testing.T, batchType uint) { b := types.NewBlock(&types.Header{ Number: big.NewInt(1), ParentHash: a.Hash(), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) require.NoError(m.AddL2Block(b)) require.Equal(m.blockCursor, len(m.blocks)-1) require.Equal(b.Hash(), m.tip) @@ -285,8 +288,8 @@ func (f *FakeDynamicEthChannelConfig) ChannelConfig() ChannelConfig { } func newFakeDynamicEthChannelConfig(lgr log.Logger, - reqTimeout time.Duration) *FakeDynamicEthChannelConfig { - + reqTimeout time.Duration, +) *FakeDynamicEthChannelConfig { calldataCfg := ChannelConfig{ MaxFrameSize: 120_000 - 1, TargetNumFrames: 1, @@ -316,7 +319,6 @@ func newFakeDynamicEthChannelConfig(lgr log.Logger, // set of market conditions. The test asserts that the DA type is changed at channel // submission time. func TestChannelManager_TxData(t *testing.T) { - type TestCase struct { name string chooseBlobsWhenChannelCreated bool @@ -389,7 +391,6 @@ func TestChannelManager_TxData(t *testing.T) { require.Equal(t, tc.chooseBlobsWhenChannelSubmitted, m.defaultCfg.UseBlobs) }) } - } // TestChannelManager_handleChannelInvalidated seeds the channel manager with blocks, @@ -467,15 +468,15 @@ func TestChannelManager_PruneBlocks(t *testing.T) { cfg.InitNoneCompressor() a := types.NewBlock(&types.Header{ Number: big.NewInt(0), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) b := types.NewBlock(&types.Header{ Number: big.NewInt(1), ParentHash: a.Hash(), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) c := types.NewBlock(&types.Header{ Number: big.NewInt(2), ParentHash: b.Hash(), - }, nil, nil, nil) + }, nil, nil, nil, emptyChainCfg) type testCase struct { name string @@ -557,7 +558,6 @@ func TestChannelManager_PruneBlocks(t *testing.T) { } }) } - } func TestChannelManager_PruneChannels(t *testing.T) { diff --git a/op-e2e/actions/helpers/l1_miner.go b/op-e2e/actions/helpers/l1_miner.go index 108c11d3e1667..9324dc6299e6e 100644 --- a/op-e2e/actions/helpers/l1_miner.go +++ b/op-e2e/actions/helpers/l1_miner.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/triedb" @@ -218,7 +219,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) *types.Block { withdrawals = make([]*types.Withdrawal, 0) } - block := types.NewBlock(s.l1BuildingHeader, &types.Body{Transactions: s.L1Transactions, Withdrawals: withdrawals}, s.l1Receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(s.l1BuildingHeader, &types.Body{Transactions: s.L1Transactions, Withdrawals: withdrawals}, s.l1Receipts, trie.NewStackTrie(nil), ¶ms.ChainConfig{}) if s.l1Cfg.Config.IsCancun(s.l1BuildingHeader.Number, s.l1BuildingHeader.Time) { parent := s.l1Chain.GetHeaderByHash(s.l1BuildingHeader.ParentHash) var ( diff --git a/op-node/rollup/derive/test/random.go b/op-node/rollup/derive/test/random.go index ba9600da8c822..b0691347616b4 100644 --- a/op-node/rollup/derive/test/random.go +++ b/op-node/rollup/derive/test/random.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/testutils" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" ) @@ -17,7 +18,8 @@ import ( // L1 Info Deposit transaction. func RandomL2Block(rng *rand.Rand, txCount int, t time.Time) (*types.Block, []*types.Receipt) { body := types.Body{} - l1Block := types.NewBlock(testutils.RandomHeader(rng), &body, nil, trie.NewStackTrie(nil)) + emptyChainCfg := ¶ms.ChainConfig{} // no Isthmus + l1Block := types.NewBlock(testutils.RandomHeader(rng), &body, nil, trie.NewStackTrie(nil), emptyChainCfg) rollupCfg := rollup.Config{} if testutils.RandomBool(rng) { t := uint64(0) @@ -32,7 +34,6 @@ func RandomL2Block(rng *rand.Rand, txCount int, t time.Time) (*types.Block, []*t } else { return testutils.RandomBlockPrependTxsWithTime(rng, txCount, uint64(t.Unix()), types.NewTx(l1InfoTx)) } - } func RandomL2BlockWithChainId(rng *rand.Rand, txCount int, chainId *big.Int) *types.Block { diff --git a/op-program/client/l2/engine_test.go b/op-program/client/l2/engine_test.go index 4b84b2db3cd64..9177ebb7815e3 100644 --- a/op-program/client/l2/engine_test.go +++ b/op-program/client/l2/engine_test.go @@ -187,7 +187,8 @@ func createL2Block(t *testing.T, number int) *types.Block { body := &types.Body{ Transactions: []*types.Transaction{types.NewTx(tx)}, } - return types.NewBlock(header, body, nil, trie.NewStackTrie(nil)) + emptyChainCfg := ¶ms.ChainConfig{} // no Isthmus + return types.NewBlock(header, body, nil, trie.NewStackTrie(nil), emptyChainCfg) } type stubEngineBackend struct { diff --git a/op-program/client/l2/engineapi/l2_engine_api.go b/op-program/client/l2/engineapi/l2_engine_api.go index 273483893b375..c7bd918c090fa 100644 --- a/op-program/client/l2/engineapi/l2_engine_api.go +++ b/op-program/client/l2/engineapi/l2_engine_api.go @@ -503,7 +503,7 @@ func (ea *L2EngineAPI) newPayload(_ context.Context, payload *eth.ExecutionPaylo Withdrawals: toGethWithdrawals(payload), ExcessBlobGas: (*uint64)(payload.ExcessBlobGas), BlobGasUsed: (*uint64)(payload.BlobGasUsed), - }, hashes, root) + }, hashes, root, ea.config()) if err != nil { log.Debug("Invalid NewPayload params", "params", payload, "error", err) return ð.PayloadStatusV1{Status: eth.ExecutionInvalidBlockHash}, nil diff --git a/op-service/testutils/random.go b/op-service/testutils/random.go index a3021ad463b65..697b9df92f726 100644 --- a/op-service/testutils/random.go +++ b/op-service/testutils/random.go @@ -282,6 +282,7 @@ func RandomBlock(rng *rand.Rand, txCount uint64) (*types.Block, []*types.Receipt return RandomBlockPrependTxs(rng, int(txCount)) } +// RandomBlockPrependTxsWithTime will generate a random pre-Isthmus block. func RandomBlockPrependTxsWithTime(rng *rand.Rand, txCount int, t uint64, ptxs ...*types.Transaction) (*types.Block, []*types.Receipt) { header := RandomHeaderWithTime(rng, t) signer := types.NewLondonSigner(big.NewInt(rng.Int63n(1000))) @@ -302,7 +303,7 @@ func RandomBlockPrependTxsWithTime(rng *rand.Rand, txCount int, t uint64, ptxs . body := types.Body{ Transactions: txs, } - block := types.NewBlock(header, &body, receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(header, &body, receipts, trie.NewStackTrie(nil), ¶ms.ChainConfig{}) logIndex := uint(0) for i, r := range receipts { r.BlockHash = block.Hash()