diff --git a/op-e2e/Makefile b/op-e2e/Makefile index 6bf5d616640b..e33f83e9b6c1 100644 --- a/op-e2e/Makefile +++ b/op-e2e/Makefile @@ -21,7 +21,7 @@ test-ws: pre-test .PHONY: test-ws test-actions: pre-test - $(go_test) $(go_test_flags) ./actions + $(go_test) $(go_test_flags) ./actions/... .PHONY: test-actions test-http: pre-test diff --git a/op-e2e/actions/altda_test.go b/op-e2e/actions/altda/altda_test.go similarity index 87% rename from op-e2e/actions/altda_test.go rename to op-e2e/actions/altda/altda_test.go index ed6068c141ae..ac122d9d999a 100644 --- a/op-e2e/actions/altda_test.go +++ b/op-e2e/actions/altda/altda_test.go @@ -1,10 +1,11 @@ -package actions +package altda import ( "math/big" "math/rand" "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -32,21 +33,21 @@ type L2AltDA struct { daMgr *altda.DA altDACfg altda.Config contract *bindings.DataAvailabilityChallenge - batcher *L2Batcher - sequencer *L2Sequencer - engine *L2Engine + batcher *helpers.L2Batcher + sequencer *helpers.L2Sequencer + engine *helpers.L2Engine engCl *sources.EngineClient sd *e2eutils.SetupData dp *e2eutils.DeployParams - miner *L1Miner - alice *CrossLayerUser + miner *helpers.L1Miner + alice *helpers.CrossLayerUser lastComm []byte lastCommBn uint64 } type AltDAParam func(p *e2eutils.TestParams) -func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { +func NewL2AltDA(t helpers.Testing, params ...AltDAParam) *L2AltDA { p := &e2eutils.TestParams{ MaxSequencerDrift: 40, SequencerWindowSize: 12, @@ -60,15 +61,15 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { log := testlog.Logger(t, log.LvlDebug) dp := e2eutils.MakeDeployParams(t, p) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) require.True(t, sd.RollupCfg.AltDAEnabled()) - miner := NewL1Miner(t, log, sd.L1Cfg) + miner := helpers.NewL1Miner(t, log, sd.L1Cfg) l1Client := miner.EthClient() jwtPath := e2eutils.WriteDefaultJWT(t) - engine := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) + engine := helpers.NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) engCl := engine.EngineClient(t, sd.RollupCfg) storage := &altda.DAErrFaker{Client: altda.NewMockDAClient(log)} @@ -81,21 +82,21 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { daMgr := altda.NewAltDAWithStorage(log, altDACfg, storage, &altda.NoopMetrics{}) - sequencer := NewL2Sequencer(t, log, l1F, miner.BlobStore(), daMgr, engCl, sd.RollupCfg, 0, nil) + sequencer := helpers.NewL2Sequencer(t, log, l1F, miner.BlobStore(), daMgr, engCl, sd.RollupCfg, 0, nil) miner.ActL1SetFeeRecipient(common.Address{'A'}) sequencer.ActL2PipelineFull(t) - batcher := NewL2Batcher(log, sd.RollupCfg, AltDABatcherCfg(dp, storage), sequencer.RollupClient(), l1Client, engine.EthClient(), engCl) + batcher := helpers.NewL2Batcher(log, sd.RollupCfg, helpers.AltDABatcherCfg(dp, storage), sequencer.RollupClient(), l1Client, engine.EthClient(), engCl) addresses := e2eutils.CollectAddresses(sd, dp) cl := engine.EthClient() - l2UserEnv := &BasicUserEnv[*L2Bindings]{ + l2UserEnv := &helpers.BasicUserEnv[*helpers.L2Bindings]{ EthCl: cl, Signer: types.LatestSigner(sd.L2Cfg.Config), AddressCorpora: addresses, - Bindings: NewL2Bindings(t, cl, engine.GethClient()), + Bindings: helpers.NewL2Bindings(t, cl, engine.GethClient()), } - alice := NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) + alice := helpers.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) alice.L2.SetUserEnv(l2UserEnv) contract, err := bindings.NewDataAvailabilityChallenge(sd.RollupCfg.AltDAConfig.DAChallengeAddress, l1Client) @@ -130,21 +131,21 @@ func (a *L2AltDA) StorageClient() *altda.DAErrFaker { return a.storage } -func (a *L2AltDA) NewVerifier(t Testing) *L2Verifier { +func (a *L2AltDA) NewVerifier(t helpers.Testing) *helpers.L2Verifier { jwtPath := e2eutils.WriteDefaultJWT(t) - engine := NewL2Engine(t, a.log, a.sd.L2Cfg, a.sd.RollupCfg.Genesis.L1, jwtPath) + engine := helpers.NewL2Engine(t, a.log, a.sd.L2Cfg, a.sd.RollupCfg.Genesis.L1, jwtPath) engCl := engine.EngineClient(t, a.sd.RollupCfg) l1F, err := sources.NewL1Client(a.miner.RPCClient(), a.log, nil, sources.L1ClientDefaultConfig(a.sd.RollupCfg, false, sources.RPCKindBasic)) require.NoError(t, err) daMgr := altda.NewAltDAWithStorage(a.log, a.altDACfg, a.storage, &altda.NoopMetrics{}) - verifier := NewL2Verifier(t, a.log, l1F, a.miner.BlobStore(), daMgr, engCl, a.sd.RollupCfg, &sync.Config{}, safedb.Disabled, nil) + verifier := helpers.NewL2Verifier(t, a.log, l1F, a.miner.BlobStore(), daMgr, engCl, a.sd.RollupCfg, &sync.Config{}, safedb.Disabled, nil) return verifier } -func (a *L2AltDA) ActSequencerIncludeTx(t Testing) { +func (a *L2AltDA) ActSequencerIncludeTx(t helpers.Testing) { a.alice.L2.ActResetTxOpts(t) a.alice.L2.ActSetTxToAddr(&a.dp.Addresses.Bob)(t) a.alice.L2.ActMakeTx(t) @@ -156,7 +157,7 @@ func (a *L2AltDA) ActSequencerIncludeTx(t Testing) { a.sequencer.ActL2EndBlock(t) } -func (a *L2AltDA) ActNewL2Tx(t Testing) { +func (a *L2AltDA) ActNewL2Tx(t helpers.Testing) { a.ActSequencerIncludeTx(t) a.batcher.ActL2BatchBuffer(t) @@ -170,20 +171,20 @@ func (a *L2AltDA) ActNewL2Tx(t Testing) { a.miner.ActL1IncludeTx(a.dp.Addresses.Batcher)(t) a.miner.ActL1EndBlock(t) - a.lastCommBn = a.miner.l1Chain.CurrentBlock().Number.Uint64() + a.lastCommBn = a.miner.L1Chain().CurrentBlock().Number.Uint64() } -func (a *L2AltDA) ActDeleteLastInput(t Testing) { +func (a *L2AltDA) ActDeleteLastInput(t helpers.Testing) { require.NoError(t, a.storage.Client.DeleteData(a.lastComm)) } -func (a *L2AltDA) ActChallengeLastInput(t Testing) { +func (a *L2AltDA) ActChallengeLastInput(t helpers.Testing) { a.ActChallengeInput(t, a.lastComm, a.lastCommBn) a.log.Info("challenged last input", "block", a.lastCommBn) } -func (a *L2AltDA) ActChallengeInput(t Testing, comm []byte, bn uint64) { +func (a *L2AltDA) ActChallengeInput(t helpers.Testing, comm []byte, bn uint64) { bondValue, err := a.contract.BondSize(&bind.CallOpts{}) require.NoError(t, err) @@ -209,15 +210,15 @@ func (a *L2AltDA) ActChallengeInput(t Testing, comm []byte, bn uint64) { a.miner.ActL1EndBlock(t) } -func (a *L2AltDA) ActExpireLastInput(t Testing) { +func (a *L2AltDA) ActExpireLastInput(t helpers.Testing) { reorgWindow := a.altDACfg.ResolveWindow + a.altDACfg.ChallengeWindow - for a.miner.l1Chain.CurrentBlock().Number.Uint64() <= a.lastCommBn+reorgWindow { + for a.miner.L1Chain().CurrentBlock().Number.Uint64() <= a.lastCommBn+reorgWindow { a.miner.ActL1StartBlock(12)(t) a.miner.ActL1EndBlock(t) } } -func (a *L2AltDA) ActResolveInput(t Testing, comm []byte, input []byte, bn uint64) { +func (a *L2AltDA) ActResolveInput(t helpers.Testing, comm []byte, input []byte, bn uint64) { txOpts, err := bind.NewKeyedTransactorWithChainID(a.dp.Secrets.Alice, a.sd.L1Cfg.Config.ChainID) require.NoError(t, err) @@ -229,7 +230,7 @@ func (a *L2AltDA) ActResolveInput(t Testing, comm []byte, input []byte, bn uint6 a.miner.ActL1EndBlock(t) } -func (a *L2AltDA) ActResolveLastChallenge(t Testing) { +func (a *L2AltDA) ActResolveLastChallenge(t helpers.Testing) { // remove derivation byte prefix input, err := a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(a.lastComm[1:])) require.NoError(t, err) @@ -237,23 +238,22 @@ func (a *L2AltDA) ActResolveLastChallenge(t Testing) { a.ActResolveInput(t, a.lastComm, input, a.lastCommBn) } -func (a *L2AltDA) ActL1Blocks(t Testing, n uint64) { +func (a *L2AltDA) ActL1Blocks(t helpers.Testing, n uint64) { for i := uint64(0); i < n; i++ { a.miner.ActL1StartBlock(12)(t) a.miner.ActL1EndBlock(t) } } -func (a *L2AltDA) GetLastTxBlock(t Testing) *types.Block { - rcpt, err := a.engine.EthClient().TransactionReceipt(t.Ctx(), a.alice.L2.lastTxHash) - require.NoError(t, err) +func (a *L2AltDA) GetLastTxBlock(t helpers.Testing) *types.Block { + rcpt := a.alice.L2.LastTxReceipt(t) blk, err := a.engine.EthClient().BlockByHash(t.Ctx(), rcpt.BlockHash) require.NoError(t, err) return blk } -func (a *L2AltDA) ActL1Finalized(t Testing) { - latest := a.miner.l1Chain.CurrentBlock().Number.Uint64() +func (a *L2AltDA) ActL1Finalized(t helpers.Testing) { + latest := a.miner.L1Chain().CurrentBlock().Number.Uint64() a.miner.ActL1Safe(t, latest) a.miner.ActL1Finalize(t, latest) a.sequencer.ActL1FinalizedSignal(t) @@ -265,7 +265,7 @@ func TestAltDA_ChallengeExpired(gt *testing.T) { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) harness := NewL2AltDA(t) // generate enough initial l1 blocks to have a finalized head. @@ -325,7 +325,7 @@ func TestAltDA_ChallengeResolved(gt *testing.T) { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) harness := NewL2AltDA(t) // include a new l2 transaction, submitting an input commitment to the l1. @@ -373,7 +373,7 @@ func TestAltDA_StorageError(gt *testing.T) { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) harness := NewL2AltDA(t) // include a new l2 transaction, submitting an input commitment to the l1. @@ -402,7 +402,7 @@ func TestAltDA_ChallengeReorg(gt *testing.T) { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) harness := NewL2AltDA(t) // New L2 tx added to a batch and committed to L1 @@ -450,7 +450,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) a := NewL2AltDA(t) // create a new tx on l2 and commit it to l1 @@ -509,7 +509,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) { comm2 := a.lastComm _, err = a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(comm2[1:])) require.NoError(t, err) - a.lastCommBn = a.miner.l1Chain.CurrentBlock().Number.Uint64() + a.lastCommBn = a.miner.L1Chain().CurrentBlock().Number.Uint64() // ensure the second commitment is distinct from the first require.NotEqual(t, comm1, comm2) @@ -545,7 +545,7 @@ func TestAltDA_Finalization(gt *testing.T) { if !e2eutils.UseAltDA() { gt.Skip("AltDA is not enabled") } - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) a := NewL2AltDA(t) // build L1 block #1 diff --git a/op-e2e/actions/eip4844_test.go b/op-e2e/actions/batcher/eip4844_test.go similarity index 85% rename from op-e2e/actions/eip4844_test.go rename to op-e2e/actions/batcher/eip4844_test.go index 8b287250bb0e..6d77a3961788 100644 --- a/op-e2e/actions/eip4844_test.go +++ b/op-e2e/actions/batcher/eip4844_test.go @@ -1,8 +1,9 @@ -package actions +package batcher import ( "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" @@ -16,26 +17,26 @@ import ( "github.com/ethereum-optimism/optimism/op-service/testlog" ) -func setupEIP4844Test(t Testing, log log.Logger) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine) { - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) +func setupEIP4844Test(t helpers.Testing, log log.Logger) (*e2eutils.SetupData, *e2eutils.DeployParams, *helpers.L1Miner, *helpers.L2Sequencer, *helpers.L2Engine, *helpers.L2Verifier, *helpers.L2Engine) { + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) genesisActivation := hexutil.Uint64(0) dp.DeployConfig.L1CancunTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisCanyonTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation - sd := e2eutils.Setup(t, dp, DefaultAlloc) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) + miner, seqEngine, sequencer := helpers.SetupSequencerTest(t, sd, log) miner.ActL1SetFeeRecipient(common.Address{'A'}) sequencer.ActL2PipelineFull(t) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + verifEngine, verifier := helpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) return sd, dp, miner, sequencer, seqEngine, verifier, verifEngine } -func setupBatcher(t Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutils.DeployParams, miner *L1Miner, - sequencer *L2Sequencer, engine *L2Engine, daType batcherFlags.DataAvailabilityType, -) *L2Batcher { - return NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ +func setupBatcher(t helpers.Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutils.DeployParams, miner *helpers.L1Miner, + sequencer *helpers.L2Sequencer, engine *helpers.L2Engine, daType batcherFlags.DataAvailabilityType, +) *helpers.L2Batcher { + return helpers.NewL2Batcher(log, sd.RollupCfg, &helpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -44,7 +45,7 @@ func setupBatcher(t Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutil } func TestEIP4844DataAvailability(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) log := testlog.Logger(t, log.LevelDebug) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) @@ -82,7 +83,7 @@ func TestEIP4844DataAvailability(gt *testing.T) { } func TestEIP4844MultiBlobs(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) log := testlog.Logger(t, log.LevelDebug) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) @@ -121,7 +122,7 @@ func TestEIP4844MultiBlobs(gt *testing.T) { } func TestEIP4844DataAvailabilitySwitch(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) log := testlog.Logger(t, log.LevelDebug) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) diff --git a/op-e2e/actions/l2_batcher_test.go b/op-e2e/actions/batcher/l2_batcher_test.go similarity index 80% rename from op-e2e/actions/l2_batcher_test.go rename to op-e2e/actions/batcher/l2_batcher_test.go index 0b9140020b0b..e0605f3fb121 100644 --- a/op-e2e/actions/l2_batcher_test.go +++ b/op-e2e/actions/batcher/l2_batcher_test.go @@ -1,4 +1,4 @@ -package actions +package batcher import ( "errors" @@ -6,6 +6,8 @@ import ( "math/rand" "testing" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -50,29 +52,8 @@ func TestL2BatcherBatchType(t *testing.T) { } } -// applyDeltaTimeOffset adjusts fork configuration to not conflict with the delta overrides -func applyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Uint64) { - dp.DeployConfig.L2GenesisDeltaTimeOffset = deltaTimeOffset - // configure Ecotone to not be before Delta accidentally - if dp.DeployConfig.L2GenesisEcotoneTimeOffset != nil { - if deltaTimeOffset == nil { - dp.DeployConfig.L2GenesisEcotoneTimeOffset = nil - } else if *dp.DeployConfig.L2GenesisEcotoneTimeOffset < *deltaTimeOffset { - dp.DeployConfig.L2GenesisEcotoneTimeOffset = deltaTimeOffset - } - } - // configure Fjord to not be before Delta accidentally - if dp.DeployConfig.L2GenesisFjordTimeOffset != nil { - if deltaTimeOffset == nil { - dp.DeployConfig.L2GenesisFjordTimeOffset = nil - } else if *dp.DeployConfig.L2GenesisFjordTimeOffset < *deltaTimeOffset { - dp.DeployConfig.L2GenesisFjordTimeOffset = deltaTimeOffset - } - } -} - func NormalBatcher(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -80,14 +61,14 @@ func NormalBatcher(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { L1BlockTime: 12, } dp := e2eutils.MakeDeployParams(t, p) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + verifEngine, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) // Alice makes a L2 tx @@ -99,7 +80,7 @@ func NormalBatcher(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -123,8 +104,8 @@ func NormalBatcher(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - bl := miner.l1Chain.CurrentBlock() - log.Info("bl", "txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) + bl := miner.L1Chain().CurrentBlock() + log.Info("bl", "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions())) // Now make enough L1 blocks that the verifier will have to derive a L2 block // It will also eagerly derive the block from the batcher @@ -147,12 +128,12 @@ func NormalBatcher(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } func L2Finalization(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) sequencer.ActL2PipelineFull(t) @@ -184,7 +165,7 @@ func L2Finalization(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { require.Equal(t, uint64(1), sequencer.SyncStatus().FinalizedL1.Number) require.Equal(t, uint64(0), sequencer.SyncStatus().FinalizedL2.Number, "L2 block has to be included on L1 before it can be finalized") - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engine.EngineClient(t, sd.RollupCfg)) heightToSubmit := sequencer.SyncStatus().UnsafeL2.Number @@ -244,12 +225,12 @@ func L2Finalization(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // L2FinalizationWithSparseL1 tests that safe L2 blocks can be finalized even if we do not regularly get a L1 finalization signal func L2FinalizationWithSparseL1(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) sequencer.ActL2PipelineFull(t) @@ -260,7 +241,7 @@ func L2FinalizationWithSparseL1(gt *testing.T, deltaTimeOffset *hexutil.Uint64) startStatus := sequencer.SyncStatus() require.Less(t, startStatus.SafeL2.Number, startStatus.UnsafeL2.Number, "sequencer has unsafe L2 block") - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engine.EngineClient(t, sd.RollupCfg)) batcher.ActSubmitAll(t) @@ -300,29 +281,29 @@ func L2FinalizationWithSparseL1(gt *testing.T, deltaTimeOffset *hexutil.Uint64) // valid batches being submitted to the batch inbox. These batches should always be rejected // and the safe L2 head should remain unaltered. func GarbageBatch(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - p := DefaultRollupTestParams + t := actionsHelpers.NewDefaultTesting(gt) + p := actionsHelpers.DefaultRollupTestParams dp := e2eutils.MakeDeployParams(t, p) - applyDeltaTimeOffset(dp, deltaTimeOffset) - for _, garbageKind := range GarbageKinds { - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + for _, garbageKind := range actionsHelpers.GarbageKinds { + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) - batcherCfg := DefaultBatcherCfg(dp) + batcherCfg := actionsHelpers.DefaultBatcherCfg(dp) - if garbageKind == MALFORM_RLP || garbageKind == INVALID_COMPRESSION { + if garbageKind == actionsHelpers.MALFORM_RLP || garbageKind == actionsHelpers.INVALID_COMPRESSION { // If the garbage kind is `INVALID_COMPRESSION` or `MALFORM_RLP`, use the `actions` packages // modified `ChannelOut`. - batcherCfg.GarbageCfg = &GarbageChannelCfg{ - UseInvalidCompression: garbageKind == INVALID_COMPRESSION, - MalformRLP: garbageKind == MALFORM_RLP, + batcherCfg.GarbageCfg = &actionsHelpers.GarbageChannelCfg{ + UseInvalidCompression: garbageKind == actionsHelpers.INVALID_COMPRESSION, + MalformRLP: garbageKind == actionsHelpers.MALFORM_RLP, } } - batcher := NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engine.EngineClient(t, sd.RollupCfg)) + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engine.EngineClient(t, sd.RollupCfg)) sequencer.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t) @@ -376,7 +357,7 @@ func GarbageBatch(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } func ExtendedTimeWithoutL1Batches(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -384,14 +365,14 @@ func ExtendedTimeWithoutL1Batches(gt *testing.T, deltaTimeOffset *hexutil.Uint64 L1BlockTime: 12, } dp := e2eutils.MakeDeployParams(t, p) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engine.EngineClient(t, sd.RollupCfg)) sequencer.ActL2PipelineFull(t) @@ -432,7 +413,7 @@ func ExtendedTimeWithoutL1Batches(gt *testing.T, deltaTimeOffset *hexutil.Uint64 // This does not test the batcher code, but is really focused at testing the batcher utils // and channel-decoding verifier code in the derive package. func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 100, SequencerWindowSize: 1000, @@ -440,14 +421,14 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { L1BlockTime: 12, } dp := e2eutils.MakeDeployParams(t, p) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) - batcher := NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 40_000, // try a small batch size, to force the data to be split between more frames BatcherKey: dp.Secrets.Batcher, @@ -478,7 +459,7 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } sequencer.ActL1HeadSignal(t) sequencer.ActL2StartBlock(t) - baseFee := engine.l2Chain.CurrentBlock().BaseFee // this will go quite high, since so many consecutive blocks are filled at capacity. + baseFee := engine.L2Chain().CurrentBlock().BaseFee // this will go quite high, since so many consecutive blocks are filled at capacity. // fill the block with large L2 txs from alice for n := aliceNonce; ; n++ { require.NoError(t, err) @@ -488,7 +469,7 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { require.NoError(t, err) gas, err := core.IntrinsicGas(data, nil, false, true, true, false) require.NoError(t, err) - if gas > engine.engineApi.RemainingBlockGas() { + if gas > engine.EngineApi.RemainingBlockGas() { break } tx := types.MustSignNewTx(dp.Secrets.Alice, signer, &types.DynamicFeeTx{ @@ -505,12 +486,12 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { engine.ActL2IncludeTx(dp.Addresses.Alice)(t) } sequencer.ActL2EndBlock(t) - for batcher.l2BufferedBlock.Number < sequencer.SyncStatus().UnsafeL2.Number { + for batcher.L2BufferedBlock.Number < sequencer.SyncStatus().UnsafeL2.Number { // if we run out of space, close the channel and submit all the txs if err := batcher.Buffer(t); errors.Is(err, derive.ErrTooManyRLPBytes) || errors.Is(err, derive.ErrCompressorFull) { - log.Info("flushing filled channel to batch txs", "id", batcher.l2ChannelOut.ID()) + log.Info("flushing filled channel to batch txs", "id", batcher.L2ChannelOut.ID()) batcher.ActL2ChannelClose(t) - for batcher.l2ChannelOut != nil { + for batcher.L2ChannelOut != nil { batcher.ActL2BatchSubmit(t, batcherTxOpts) } } @@ -518,16 +499,16 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } // if anything is left in the channel, submit it - if batcher.l2ChannelOut != nil { - log.Info("flushing trailing channel to batch txs", "id", batcher.l2ChannelOut.ID()) + if batcher.L2ChannelOut != nil { + log.Info("flushing trailing channel to batch txs", "id", batcher.L2ChannelOut.ID()) batcher.ActL2ChannelClose(t) - for batcher.l2ChannelOut != nil { + for batcher.L2ChannelOut != nil { batcher.ActL2BatchSubmit(t, batcherTxOpts) } } // build L1 blocks until we're out of txs - txs, _ := miner.eth.TxPool().ContentFrom(dp.Addresses.Batcher) + txs, _ := miner.Eth.TxPool().ContentFrom(dp.Addresses.Batcher) for { if len(txs) == 0 { break @@ -538,7 +519,7 @@ func BigL2Txs(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { break } tx := txs[0] - if miner.l1GasPool.Gas() < tx.Gas() { // fill the L1 block with batcher txs until we run out of gas + if miner.L1GasPool.Gas() < tx.Gas() { // fill the L1 block with batcher txs until we run out of gas break } log.Info("including batcher tx", "nonce", tx.Nonce()) diff --git a/op-e2e/actions/batch_queue_test.go b/op-e2e/actions/derivation/batch_queue_test.go similarity index 62% rename from op-e2e/actions/batch_queue_test.go rename to op-e2e/actions/derivation/batch_queue_test.go index e5132a85ac94..af5b7231b884 100644 --- a/op-e2e/actions/batch_queue_test.go +++ b/op-e2e/actions/derivation/batch_queue_test.go @@ -1,13 +1,16 @@ -package actions +package derivation import ( "testing" altda "github.com/ethereum-optimism/optimism/op-alt-da" batcherFlags "github.com/ethereum-optimism/optimism/op-batcher/flags" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-node/node/safedb" "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/ethereum-optimism/optimism/op-node/rollup/sync" "github.com/ethereum-optimism/optimism/op-service/sources" "github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum/go-ethereum/log" @@ -20,7 +23,7 @@ import ( // This is a regression test, previously the pipeline encountered got stuck in a reset loop with the error: // buffered L1 chain epoch %s in batch queue does not match safe head origin %s func TestDeriveChainFromNearL1Genesis(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -29,22 +32,22 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { } dp := e2eutils.MakeDeployParams(t, p) // do not activate Delta hardfork for verifier - applyDeltaTimeOffset(dp, nil) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, nil) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) logger := testlog.Logger(t, log.LevelInfo) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, logger) + miner, seqEngine, sequencer := helpers.SetupSequencerTest(t, sd, logger) miner.ActEmptyBlock(t) - require.EqualValues(gt, 1, miner.l1Chain.CurrentBlock().Number.Uint64()) + require.EqualValues(gt, 1, miner.L1Chain().CurrentBlock().Number.Uint64()) - ref, err := derive.L2BlockToBlockRef(sequencer.rollupCfg, seqEngine.l2Chain.Genesis()) + ref, err := derive.L2BlockToBlockRef(sequencer.RollupCfg, seqEngine.L2Chain().Genesis()) require.NoError(gt, err) require.EqualValues(gt, 0, ref.L1Origin.Number) sequencer.ActL1HeadSignal(t) sequencer.ActBuildToL1Head(t) - l2BlockNum := seqEngine.l2Chain.CurrentBlock().Number.Uint64() - ref, err = derive.L2BlockToBlockRef(sequencer.rollupCfg, seqEngine.l2Chain.GetBlockByNumber(l2BlockNum)) + l2BlockNum := seqEngine.L2Chain().CurrentBlock().Number.Uint64() + ref, err = derive.L2BlockToBlockRef(sequencer.RollupCfg, seqEngine.L2Chain().GetBlockByNumber(l2BlockNum)) require.NoError(gt, err) require.EqualValues(gt, 1, ref.L1Origin.Number) @@ -52,7 +55,7 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { rollupSeqCl := sequencer.RollupClient() // Force batcher to submit SingularBatches to L1. - batcher := NewL2Batcher(logger, sd.RollupCfg, &BatcherCfg{ + batcher := helpers.NewL2Batcher(logger, sd.RollupCfg, &helpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -60,40 +63,40 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { }, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) batcher.ActSubmitAll(t) - require.EqualValues(gt, l2BlockNum, batcher.l2BufferedBlock.Number) + require.EqualValues(gt, l2BlockNum, batcher.L2BufferedBlock.Number) // confirm batch on L1 miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - bl := miner.l1Chain.CurrentBlock() + bl := miner.L1Chain().CurrentBlock() logger.Info("Produced L1 block with batch", - "num", miner.l1Chain.CurrentBlock().Number.Uint64(), - "txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) + "num", miner.L1Chain().CurrentBlock().Number.Uint64(), + "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions())) // Process batches so safe head updates sequencer.ActL1HeadSignal(t) sequencer.ActL2PipelineFull(t) - require.EqualValues(gt, l2BlockNum, seqEngine.l2Chain.CurrentSafeBlock().Number.Uint64()) + require.EqualValues(gt, l2BlockNum, seqEngine.L2Chain().CurrentSafeBlock().Number.Uint64()) // Finalize L1 and process so L2 finalized updates - miner.ActL1Safe(t, miner.l1Chain.CurrentBlock().Number.Uint64()) - miner.ActL1Finalize(t, miner.l1Chain.CurrentBlock().Number.Uint64()) + miner.ActL1Safe(t, miner.L1Chain().CurrentBlock().Number.Uint64()) + miner.ActL1Finalize(t, miner.L1Chain().CurrentBlock().Number.Uint64()) sequencer.ActL1SafeSignal(t) sequencer.ActL1FinalizedSignal(t) sequencer.ActL2PipelineFull(t) - require.EqualValues(gt, l2BlockNum, seqEngine.l2Chain.CurrentFinalBlock().Number.Uint64()) + require.EqualValues(gt, l2BlockNum, seqEngine.L2Chain().CurrentFinalBlock().Number.Uint64()) // Create a new verifier using the existing engine so it already has the safe and finalized heads set. // This is the same situation as if op-node restarted at this point. l2Cl, err := sources.NewEngineClient(seqEngine.RPCClient(), logger, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(gt, err) - verifier := NewL2Verifier(t, logger, sequencer.l1, miner.BlobStore(), altda.Disabled, - l2Cl, sequencer.rollupCfg, sequencer.syncCfg, safedb.Disabled, nil) + verifier := helpers.NewL2Verifier(t, logger, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled, + l2Cl, sequencer.RollupCfg, &sync.Config{}, safedb.Disabled, nil) verifier.ActL2PipelineFull(t) // Should not get stuck in a reset loop forever - require.EqualValues(gt, l2BlockNum, seqEngine.l2Chain.CurrentSafeBlock().Number.Uint64()) - require.EqualValues(gt, l2BlockNum, seqEngine.l2Chain.CurrentFinalBlock().Number.Uint64()) - syncStatus := verifier.syncStatus.SyncStatus() + require.EqualValues(gt, l2BlockNum, seqEngine.L2Chain().CurrentSafeBlock().Number.Uint64()) + require.EqualValues(gt, l2BlockNum, seqEngine.L2Chain().CurrentFinalBlock().Number.Uint64()) + syncStatus := verifier.SyncStatus() require.EqualValues(gt, l2BlockNum, syncStatus.SafeL2.Number) require.EqualValues(gt, l2BlockNum, syncStatus.FinalizedL2.Number) } diff --git a/op-e2e/actions/blocktime_test.go b/op-e2e/actions/derivation/blocktime_test.go similarity index 89% rename from op-e2e/actions/blocktime_test.go rename to op-e2e/actions/derivation/blocktime_test.go index 20f644887697..ec192d08ad78 100644 --- a/op-e2e/actions/blocktime_test.go +++ b/op-e2e/actions/derivation/blocktime_test.go @@ -1,9 +1,11 @@ -package actions +package derivation import ( "math/big" "testing" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum/go-ethereum/common/hexutil" @@ -44,16 +46,16 @@ func TestBlockTimeBatchType(t *testing.T) { // window. // This is a regression test against the bug fixed in PR #4566 func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) dp.DeployConfig.SequencerWindowSize = 4 dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - sd, _, miner, sequencer, sequencerEngine, _, _, batcher := setupReorgTestActors(t, dp, sd, log) + sd, _, miner, sequencer, sequencerEngine, _, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) signer := types.LatestSigner(sd.L2Cfg.Config) cl := sequencerEngine.EthClient() @@ -63,7 +65,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: aliceNonce, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -78,7 +80,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { sequencer.ActL2EndBlock(t) } verifyChainStateOnSequencer := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin uint64) { - require.Equal(t, l1Number, miner.l1Chain.CurrentHeader().Number.Uint64()) + require.Equal(t, l1Number, miner.L1Chain().CurrentHeader().Number.Uint64()) require.Equal(t, unsafeHead, sequencer.L2Unsafe().Number) require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number) require.Equal(t, safeHead, sequencer.L2Safe().Number) @@ -155,8 +157,8 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // At this point it can verify that the batches where properly generated. // Note: It batches submits when possible. func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) dp.DeployConfig.L1BlockTime = 4 dp.DeployConfig.L2BlockTime = 2 dp.DeployConfig.SequencerWindowSize = 4 @@ -165,11 +167,11 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { dp.DeployConfig.L2GenesisFjordTimeOffset = nil // TODO(client-pod#831): The Ecotone (and Fjord) activation blocks don't include user txs, // so disabling these forks for now. - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - sd, _, miner, sequencer, sequencerEngine, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + sd, _, miner, sequencer, sequencerEngine, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) signer := types.LatestSigner(sd.L2Cfg.Config) cl := sequencerEngine.EthClient() @@ -180,7 +182,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: aliceNonce, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -196,7 +198,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } verifyChainStateOnSequencer := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin uint64) { - require.Equal(t, l1Number, miner.l1Chain.CurrentHeader().Number.Uint64()) + require.Equal(t, l1Number, miner.L1Chain().CurrentHeader().Number.Uint64()) require.Equal(t, unsafeHead, sequencer.L2Unsafe().Number) require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number) require.Equal(t, safeHead, sequencer.L2Safe().Number) @@ -204,7 +206,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } verifyChainStateOnVerifier := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin uint64) { - require.Equal(t, l1Number, miner.l1Chain.CurrentHeader().Number.Uint64()) + require.Equal(t, l1Number, miner.L1Chain().CurrentHeader().Number.Uint64()) require.Equal(t, unsafeHead, verifier.L2Unsafe().Number) require.Equal(t, unsafeHeadOrigin, verifier.L2Unsafe().L1Origin.Number) require.Equal(t, safeHead, verifier.L2Safe().Number) diff --git a/op-e2e/actions/l2_verifier_test.go b/op-e2e/actions/derivation/l2_verifier_test.go similarity index 55% rename from op-e2e/actions/l2_verifier_test.go rename to op-e2e/actions/derivation/l2_verifier_test.go index 75c1efbc176c..2f4fce628d53 100644 --- a/op-e2e/actions/l2_verifier_test.go +++ b/op-e2e/actions/derivation/l2_verifier_test.go @@ -1,41 +1,19 @@ -package actions +package derivation import ( "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/stretchr/testify/require" - altda "github.com/ethereum-optimism/optimism/op-alt-da" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" - "github.com/ethereum-optimism/optimism/op-node/rollup/derive" - "github.com/ethereum-optimism/optimism/op-node/rollup/sync" "github.com/ethereum-optimism/optimism/op-service/testlog" ) -func setupVerifier(t Testing, sd *e2eutils.SetupData, log log.Logger, - l1F derive.L1Fetcher, blobSrc derive.L1BlobsFetcher, syncCfg *sync.Config, opts ...VerifierOpt) (*L2Engine, *L2Verifier) { - cfg := DefaultVerifierCfg() - for _, opt := range opts { - opt(cfg) - } - jwtPath := e2eutils.WriteDefaultJWT(t) - engine := NewL2Engine(t, log.New("role", "verifier-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, EngineWithP2P()) - engCl := engine.EngineClient(t, sd.RollupCfg) - verifier := NewL2Verifier(t, log.New("role", "verifier"), l1F, blobSrc, altda.Disabled, engCl, sd.RollupCfg, syncCfg, cfg.SafeHeadListener, cfg.InteropBackend) - return engine, verifier -} - -func setupVerifierOnlyTest(t Testing, sd *e2eutils.SetupData, log log.Logger) (*L1Miner, *L2Engine, *L2Verifier) { - miner := NewL1Miner(t, log, sd.L1Cfg) - l1Cl := miner.L1Client(t, sd.RollupCfg) - engine, verifier := setupVerifier(t, sd, log, l1Cl, miner.BlobStore(), &sync.Config{}) - return miner, engine, verifier -} - func TestL2Verifier_SequenceWindow(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 10, SequencerWindowSize: 24, @@ -43,26 +21,26 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { L1BlockTime: 15, } dp := e2eutils.MakeDeployParams(t, p) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, engine, verifier := setupVerifierOnlyTest(t, sd, log) + miner, engine, verifier := helpers.SetupVerifierOnlyTest(t, sd, log) miner.ActL1SetFeeRecipient(common.Address{'A'}) // Make two sequence windows worth of empty L1 blocks. After we pass the first sequence window, the L2 chain should get blocks - for miner.l1Chain.CurrentBlock().Number.Uint64() < sd.RollupCfg.SeqWindowSize*2 { + for miner.L1Chain().CurrentBlock().Number.Uint64() < sd.RollupCfg.SeqWindowSize*2 { miner.ActL1StartBlock(10)(t) miner.ActL1EndBlock(t) verifier.ActL2PipelineFull(t) - l1Head := miner.l1Chain.CurrentBlock().Number.Uint64() + l1Head := miner.L1Chain().CurrentBlock().Number.Uint64() expectedL1Origin := uint64(0) // as soon as we complete the sequence window, we force-adopt the L1 origin if l1Head >= sd.RollupCfg.SeqWindowSize { expectedL1Origin = l1Head - sd.RollupCfg.SeqWindowSize } require.Equal(t, expectedL1Origin, verifier.SyncStatus().SafeL2.L1Origin.Number, "L1 origin is forced in, given enough L1 blocks pass by") - require.LessOrEqual(t, miner.l1Chain.GetBlockByNumber(expectedL1Origin).Time(), engine.l2Chain.CurrentBlock().Time, "L2 time higher than L1 origin time") + require.LessOrEqual(t, miner.L1Chain().GetBlockByNumber(expectedL1Origin).Time(), engine.L2Chain().CurrentBlock().Time, "L2 time higher than L1 origin time") } tip2N := verifier.SyncStatus() @@ -77,13 +55,13 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { miner.ActL1SetFeeRecipient(common.Address{'B'}) miner.ActL1StartBlock(10)(t) miner.ActL1EndBlock(t) - reorgL1Block := miner.l1Chain.CurrentBlock() + reorgL1Block := miner.L1Chain().CurrentBlock() // Still no reorg, we need more L1 blocks first, before the reorged L1 block is forced in by sequence window verifier.ActL2PipelineFull(t) require.Equal(t, tip2N.SafeL2, verifier.SyncStatus().SafeL2) - for miner.l1Chain.CurrentBlock().Number.Uint64() < sd.RollupCfg.SeqWindowSize*2 { + for miner.L1Chain().CurrentBlock().Number.Uint64() < sd.RollupCfg.SeqWindowSize*2 { miner.ActL1StartBlock(10)(t) miner.ActL1EndBlock(t) } @@ -95,6 +73,6 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { // Now it will reorg verifier.ActL2PipelineFull(t) - got := miner.l1Chain.GetBlockByHash(miner.l1Chain.GetBlockByHash(verifier.SyncStatus().SafeL2.L1Origin.Hash).Hash()) + got := miner.L1Chain().GetBlockByHash(miner.L1Chain().GetBlockByHash(verifier.SyncStatus().SafeL2.L1Origin.Hash).Hash()) require.Equal(t, reorgL1Block.Hash(), got.Hash(), "must have reorged L2 chain to the new L1 chain") } diff --git a/op-e2e/actions/reorg_test.go b/op-e2e/actions/derivation/reorg_test.go similarity index 89% rename from op-e2e/actions/reorg_test.go rename to op-e2e/actions/derivation/reorg_test.go index 1ffd512d328f..6551b314c1ea 100644 --- a/op-e2e/actions/reorg_test.go +++ b/op-e2e/actions/derivation/reorg_test.go @@ -1,4 +1,4 @@ -package actions +package derivation import ( "math/big" @@ -6,6 +6,8 @@ import ( "path" "testing" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" @@ -16,34 +18,12 @@ import ( altda "github.com/ethereum-optimism/optimism/op-alt-da" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" - "github.com/ethereum-optimism/optimism/op-node/rollup/sync" "github.com/ethereum-optimism/optimism/op-service/client" "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/sources" "github.com/ethereum-optimism/optimism/op-service/testlog" ) -func setupReorgTest(t Testing, config *e2eutils.TestParams, deltaTimeOffset *hexutil.Uint64) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine, *L2Batcher) { - dp := e2eutils.MakeDeployParams(t, config) - applyDeltaTimeOffset(dp, deltaTimeOffset) - - sd := e2eutils.Setup(t, dp, DefaultAlloc) - log := testlog.Logger(t, log.LevelDebug) - - return setupReorgTestActors(t, dp, sd, log) -} - -func setupReorgTestActors(t Testing, dp *e2eutils.DeployParams, sd *e2eutils.SetupData, log log.Logger) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine, *L2Batcher) { - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - miner.ActL1SetFeeRecipient(common.Address{'A'}) - sequencer.ActL2PipelineFull(t) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) - rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), - rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) - return sd, dp, miner, sequencer, seqEngine, verifier, verifEngine, batcher -} - // TestReorgBatchType run each reorg-related test case in singular batch mode and span batch mode. func TestReorgBatchType(t *testing.T) { tests := []struct { @@ -74,8 +54,8 @@ func TestReorgBatchType(t *testing.T) { } func ReorgOrphanBlock(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - sd, _, miner, sequencer, _, verifier, verifierEng, batcher := setupReorgTest(t, DefaultRollupTestParams, deltaTimeOffset) + t := actionsHelpers.NewDefaultTesting(gt) + sd, _, miner, sequencer, _, verifier, verifierEng, batcher := actionsHelpers.SetupReorgTest(t, actionsHelpers.DefaultRollupTestParams, deltaTimeOffset) verifEngClient := verifierEng.EngineClient(t, sd.RollupCfg) sequencer.ActL2PipelineFull(t) @@ -94,7 +74,7 @@ func ReorgOrphanBlock(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // new L1 block with L2 batch miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) - batchTx := miner.l1Transactions[0] + batchTx := miner.L1Transactions[0] miner.ActL1EndBlock(t) // verifier picks up the L2 chain that was submitted @@ -123,7 +103,7 @@ func ReorgOrphanBlock(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1SetFeeRecipient(common.Address{'C'}) // note: the geth tx pool reorgLoop is too slow (responds to chain head events, but async), // and there's no way to manually trigger runReorg, so we re-insert it ourselves. - require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{batchTx}, true, true)[0]) + require.NoError(t, miner.Eth.TxPool().Add([]*types.Transaction{batchTx}, true, true)[0]) // need to re-insert previously included tx into the block miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1EndBlock(t) @@ -142,8 +122,8 @@ func ReorgOrphanBlock(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - sd, _, miner, sequencer, _, verifier, verifierEng, batcher := setupReorgTest(t, DefaultRollupTestParams, deltaTimeOffset) + t := actionsHelpers.NewDefaultTesting(gt) + sd, _, miner, sequencer, _, verifier, verifierEng, batcher := actionsHelpers.SetupReorgTest(t, actionsHelpers.DefaultRollupTestParams, deltaTimeOffset) minerCl := miner.L1Client(t, sd.RollupCfg) verifEngClient := verifierEng.EngineClient(t, sd.RollupCfg) checkVerifEngine := func() { @@ -172,7 +152,7 @@ func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1SetFeeRecipient(common.Address{'A', 1}) miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) - batchTxA := miner.l1Transactions[0] + batchTxA := miner.L1Transactions[0] miner.ActL1EndBlock(t) // verifier picks up the L2 chain that was submitted @@ -195,7 +175,7 @@ func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // re-include the batch tx that submitted L2 chain data that pointed to A0, in the new block B1 miner.ActL1SetFeeRecipient(common.Address{'B', 1}) miner.ActL1StartBlock(12)(t) - require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{batchTxA}, true, true)[0]) + require.NoError(t, miner.Eth.TxPool().Add([]*types.Transaction{batchTxA}, true, true)[0]) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1EndBlock(t) @@ -219,7 +199,7 @@ func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // after delta hard fork require.Zero(t, verifier.L2Safe().Number, "safe head is at genesis block because span batch referenced reorged L1 chain is not accepted") require.Equal(t, verifier.L2Unsafe().ID(), sequencer.L2Unsafe().ParentID(), "head is at the highest unsafe block that references canonical L1 chain(genesis block)") - batcher.l2BufferedBlock = eth.L2BlockRef{} // must reset batcher to resubmit blocks included in the last batch + batcher.L2BufferedBlock = eth.L2BlockRef{} // must reset batcher to resubmit blocks included in the last batch } checkVerifEngine() @@ -260,7 +240,7 @@ func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1SetFeeRecipient(common.Address{'A', 2}) miner.ActL1StartBlock(12)(t) - require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{batchTxA}, true, true)[0]) // replay chain A batches, but now in A2 instead of A1 + require.NoError(t, miner.Eth.TxPool().Add([]*types.Transaction{batchTxA}, true, true)[0]) // replay chain A batches, but now in A2 instead of A1 miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1EndBlock(t) @@ -356,10 +336,10 @@ func ReorgFlipFlop(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // - Unsafe head is 62 // - Safe head is 42 func DeepReorg(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) // Create actor and verification engine client - sd, dp, miner, sequencer, seqEngine, verifier, verifierEng, batcher := setupReorgTest(t, &e2eutils.TestParams{ + sd, dp, miner, sequencer, seqEngine, verifier, verifierEng, batcher := actionsHelpers.SetupReorgTest(t, &e2eutils.TestParams{ MaxSequencerDrift: 40, SequencerWindowSize: 20, ChannelTimeout: 120, @@ -377,13 +357,13 @@ func DeepReorg(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // Set up alice log := testlog.Logger(t, log.LevelDebug) addresses := e2eutils.CollectAddresses(sd, dp) - l2UserEnv := &BasicUserEnv[*L2Bindings]{ + l2UserEnv := &actionsHelpers.BasicUserEnv[*actionsHelpers.L2Bindings]{ EthCl: l2Client, Signer: types.LatestSigner(sd.L2Cfg.Config), AddressCorpora: addresses, - Bindings: NewL2Bindings(t, l2Client, seqEngine.GethClient()), + Bindings: actionsHelpers.NewL2Bindings(t, l2Client, seqEngine.GethClient()), } - alice := NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) + alice := actionsHelpers.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) alice.L2.SetUserEnv(l2UserEnv) // Run one iteration of the L2 derivation pipeline @@ -593,29 +573,29 @@ type rpcWrapper struct { // RestartOpGeth tests that the sequencer can restart its execution engine without rollup-node restart, // including recovering the finalized/safe state of L2 chain without reorging. func RestartOpGeth(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) dbPath := path.Join(t.TempDir(), "testdb") dbOption := func(_ *ethconfig.Config, nodeCfg *node.Config) error { nodeCfg.DataDir = dbPath return nil } - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) jwtPath := e2eutils.WriteDefaultJWT(t) // L1 - miner := NewL1Miner(t, log, sd.L1Cfg) + miner := actionsHelpers.NewL1Miner(t, log, sd.L1Cfg) l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) require.NoError(t, err) // Sequencer - seqEng := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, dbOption) + seqEng := actionsHelpers.NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, dbOption) engRpc := &rpcWrapper{seqEng.RPCClient()} l2Cl, err := sources.NewEngineClient(engRpc, log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) - sequencer := NewL2Sequencer(t, log, l1F, miner.BlobStore(), altda.Disabled, l2Cl, sd.RollupCfg, 0, nil) + sequencer := actionsHelpers.NewL2Sequencer(t, log, l1F, miner.BlobStore(), altda.Disabled, l2Cl, sd.RollupCfg, 0, nil) - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) // start @@ -664,7 +644,7 @@ func RestartOpGeth(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // close the sequencer engine require.NoError(t, seqEng.Close()) // and start a new one with same db path - seqEngNew := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, dbOption) + seqEngNew := actionsHelpers.NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, dbOption) // swap in the new rpc. This is as close as we can get to reconnecting to a new in-memory rpc connection engRpc.RPC = seqEngNew.RPCClient() @@ -686,35 +666,35 @@ func RestartOpGeth(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // L2 block (compared to something already secured by the first sequencer): // the alt block is not synced by the verifier, in unsafe and safe sync modes. func ConflictingL2Blocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - sd, _, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + sd, _, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) // Extra setup: a full alternative sequencer, sequencer engine, and batcher jwtPath := e2eutils.WriteDefaultJWT(t) - altSeqEng := NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) + altSeqEng := actionsHelpers.NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) altSeqEngCl, err := sources.NewEngineClient(altSeqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) require.NoError(t, err) - altSequencer := NewL2Sequencer(t, log, l1F, miner.BlobStore(), altda.Disabled, altSeqEngCl, sd.RollupCfg, 0, nil) - altBatcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + altSequencer := actionsHelpers.NewL2Sequencer(t, log, l1F, miner.BlobStore(), altda.Disabled, altSeqEngCl, sd.RollupCfg, 0, nil) + altBatcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), altSequencer.RollupClient(), miner.EthClient(), altSeqEng.EthClient(), altSeqEng.EngineClient(t, sd.RollupCfg)) // And set up user Alice, using the alternative sequencer endpoint l2Cl := altSeqEng.EthClient() addresses := e2eutils.CollectAddresses(sd, dp) - l2UserEnv := &BasicUserEnv[*L2Bindings]{ + l2UserEnv := &actionsHelpers.BasicUserEnv[*actionsHelpers.L2Bindings]{ EthCl: l2Cl, Signer: types.LatestSigner(sd.L2Cfg.Config), AddressCorpora: addresses, - Bindings: NewL2Bindings(t, l2Cl, altSeqEng.GethClient()), + Bindings: actionsHelpers.NewL2Bindings(t, l2Cl, altSeqEng.GethClient()), } - alice := NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(1234))) + alice := actionsHelpers.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(1234))) alice.L2.SetUserEnv(l2UserEnv) sequencer.ActL2PipelineFull(t) @@ -756,7 +736,7 @@ func ConflictingL2Blocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { altSeqEng.ActL2IncludeTx(alice.Address())(t) altSequencer.ActL2EndBlock(t) - conflictBlock := seqEng.l2Chain.GetBlockByNumber(altSequencer.L2Unsafe().Number) + conflictBlock := seqEng.L2Chain().GetBlockByNumber(altSequencer.L2Unsafe().Number) require.NotEqual(t, conflictBlock.Hash(), altSequencer.L2Unsafe().Hash, "alt sequencer has built a conflicting block") // give the unsafe block to the verifier, and see if it reorgs because of any unsafe inputs @@ -776,7 +756,7 @@ func ConflictingL2Blocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1EndBlock(t) - l1Number := miner.l1Chain.CurrentHeader().Number.Uint64() + l1Number := miner.L1Chain().CurrentHeader().Number.Uint64() // show latest L1 block with new batch data to verifier, and make it sync. verifier.ActL1HeadSignal(t) @@ -793,24 +773,24 @@ func ConflictingL2Blocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } func SyncAfterReorg(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) testingParams := e2eutils.TestParams{ MaxSequencerDrift: 60, SequencerWindowSize: 4, ChannelTimeout: 2, L1BlockTime: 12, } - sd, dp, miner, sequencer, seqEngine, verifier, _, batcher := setupReorgTest(t, &testingParams, deltaTimeOffset) + sd, dp, miner, sequencer, seqEngine, verifier, _, batcher := actionsHelpers.SetupReorgTest(t, &testingParams, deltaTimeOffset) l2Client := seqEngine.EthClient() log := testlog.Logger(t, log.LevelDebug) addresses := e2eutils.CollectAddresses(sd, dp) - l2UserEnv := &BasicUserEnv[*L2Bindings]{ + l2UserEnv := &actionsHelpers.BasicUserEnv[*actionsHelpers.L2Bindings]{ EthCl: l2Client, Signer: types.LatestSigner(sd.L2Cfg.Config), AddressCorpora: addresses, - Bindings: NewL2Bindings(t, l2Client, seqEngine.GethClient()), + Bindings: actionsHelpers.NewL2Bindings(t, l2Client, seqEngine.GethClient()), } - alice := NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) + alice := actionsHelpers.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) alice.L2.SetUserEnv(l2UserEnv) sequencer.ActL2PipelineFull(t) @@ -820,11 +800,11 @@ func SyncAfterReorg(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1SetFeeRecipient(common.Address{'A', 0}) miner.ActEmptyBlock(t) sequencer.ActL1HeadSignal(t) - for sequencer.engine.UnsafeL2Head().L1Origin.Number < sequencer.syncStatus.L1Head().Number { + for sequencer.L2Unsafe().L1Origin.Number < sequencer.SyncStatus().HeadL1.Number { // build L2 blocks until the L1 origin is the current L1 head(A0) sequencer.ActL2PipelineFull(t) sequencer.ActL2StartBlock(t) - if sequencer.engine.UnsafeL2Head().Number == 11 { + if sequencer.L2Unsafe().Number == 11 { // include a user tx at L2 block #12 to make a state transition alice.L2.ActResetTxOpts(t) alice.L2.ActSetTxToAddr(&dp.Addresses.Bob)(t) diff --git a/op-e2e/actions/system_config_test.go b/op-e2e/actions/derivation/system_config_test.go similarity index 87% rename from op-e2e/actions/system_config_test.go rename to op-e2e/actions/derivation/system_config_test.go index 406ca0a16983..bb62001de4a2 100644 --- a/op-e2e/actions/system_config_test.go +++ b/op-e2e/actions/derivation/system_config_test.go @@ -1,10 +1,12 @@ -package actions +package derivation import ( "math/big" "math/rand" "testing" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -49,27 +51,27 @@ func TestSystemConfigBatchType(t *testing.T) { // BatcherKeyRotation tests that batcher A can operate, then be replaced with batcher B, then ignore old batcher A, // and that the change to batcher B is reverted properly upon reorg of L1. func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) dp.DeployConfig.L2BlockTime = 2 - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) miner.ActL1SetFeeRecipient(common.Address{'A'}) sequencer.ActL2PipelineFull(t) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() // the default batcher - batcherA := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcherA := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) // a batcher with a new key - altCfg := *DefaultBatcherCfg(dp) + altCfg := *actionsHelpers.DefaultBatcherCfg(dp) altCfg.BatcherKey = dp.Secrets.Bob - batcherB := NewL2Batcher(log, sd.RollupCfg, &altCfg, + batcherB := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &altCfg, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) sequencer.ActL2PipelineFull(t) @@ -114,7 +116,7 @@ func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { receipt, err := miner.EthClient().TransactionReceipt(t.Ctx(), tx.Hash()) require.NoError(t, err) - cfgChangeL1BlockNum := miner.l1Chain.CurrentBlock().Number.Uint64() + cfgChangeL1BlockNum := miner.L1Chain().CurrentBlock().Number.Uint64() require.Equal(t, cfgChangeL1BlockNum, receipt.BlockNumber.Uint64()) // sequence L2 blocks, and submit with new batcher @@ -225,9 +227,9 @@ func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // GPOParamsChange tests that the GPO params can be updated to adjust fees of L2 transactions, // and that the L1 data fees to the L2 transaction are applied correctly before, during and after the GPO update in L2. func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) // activating Delta only, not Ecotone and further: // the GPO change assertions here all apply only for the Delta transition. @@ -236,14 +238,14 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { dp.DeployConfig.L2GenesisFjordTimeOffset = nil dp.DeployConfig.L2GenesisGraniteTimeOffset = nil - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) - alice := NewBasicUser[any](log, dp.Secrets.Alice, rand.New(rand.NewSource(1234))) - alice.SetUserEnv(&BasicUserEnv[any]{ + alice := actionsHelpers.NewBasicUser[any](log, dp.Secrets.Alice, rand.New(rand.NewSource(1234))) + alice.SetUserEnv(&actionsHelpers.BasicUserEnv[any]{ EthCl: seqEngine.EthClient(), Signer: types.LatestSigner(sd.L2Cfg.Config), }) @@ -254,7 +256,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActEmptyBlock(t) sequencer.ActL1HeadSignal(t) sequencer.ActBuildToL1Head(t) - basefee := miner.l1Chain.CurrentBlock().BaseFee + basefee := miner.L1Chain().CurrentBlock().BaseFee // alice makes a L2 tx, sequencer includes it alice.ActResetTxOpts(t) @@ -299,7 +301,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.SysCfgOwner)(t) miner.ActL1EndBlock(t) - basefeeGPOUpdate := miner.l1Chain.CurrentBlock().BaseFee + basefeeGPOUpdate := miner.L1Chain().CurrentBlock().BaseFee // build empty L2 chain, up to but excluding the L2 block with the L1 origin that processes the GPO change sequencer.ActL1HeadSignal(t) @@ -336,7 +338,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // build more L2 blocks, with new L1 origin miner.ActEmptyBlock(t) - basefee = miner.l1Chain.CurrentBlock().BaseFee + basefee = miner.L1Chain().CurrentBlock().BaseFee sequencer.ActL1HeadSignal(t) sequencer.ActBuildToL1Head(t) // and Alice makes a tx again @@ -360,13 +362,13 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // and that the L2 changes the gas limit instantly at the exact block that adopts the L1 origin with // the gas limit change event. And checks if a verifier node can reproduce the same gas limit change. func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) sequencer.ActL2PipelineFull(t) @@ -374,7 +376,7 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { sequencer.ActL1HeadSignal(t) sequencer.ActBuildToL1Head(t) - oldGasLimit := seqEngine.l2Chain.CurrentBlock().GasLimit + oldGasLimit := seqEngine.L2Chain().CurrentBlock().GasLimit require.Equal(t, oldGasLimit, uint64(dp.DeployConfig.L2GenesisBlockGasLimit)) // change gas limit on L1 to triple what it was @@ -396,12 +398,12 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { sequencer.ActL1HeadSignal(t) sequencer.ActBuildToL1HeadExcl(t) - require.Equal(t, oldGasLimit, seqEngine.l2Chain.CurrentBlock().GasLimit) + require.Equal(t, oldGasLimit, seqEngine.L2Chain().CurrentBlock().GasLimit) require.Equal(t, uint64(1), sequencer.SyncStatus().UnsafeL2.L1Origin.Number) // now include the L1 block with the gaslimit change, and see if it changes as expected sequencer.ActBuildToL1Head(t) - require.Equal(t, oldGasLimit*3, seqEngine.l2Chain.CurrentBlock().GasLimit) + require.Equal(t, oldGasLimit*3, seqEngine.L2Chain().CurrentBlock().GasLimit) require.Equal(t, uint64(2), sequencer.SyncStatus().UnsafeL2.L1Origin.Number) // now submit all this to L1, and see if a verifier can sync and reproduce it @@ -410,7 +412,7 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) verifier.ActL2PipelineFull(t) require.Equal(t, sequencer.L2Unsafe(), verifier.L2Safe(), "verifier stays in sync, even with gaslimit changes") diff --git a/op-e2e/actions/action.go b/op-e2e/actions/helpers/action.go similarity index 99% rename from op-e2e/actions/action.go rename to op-e2e/actions/helpers/action.go index 551ab58d9632..3f8bba669242 100644 --- a/op-e2e/actions/action.go +++ b/op-e2e/actions/helpers/action.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" diff --git a/op-e2e/actions/garbage_channel_out.go b/op-e2e/actions/helpers/garbage_channel_out.go similarity index 99% rename from op-e2e/actions/garbage_channel_out.go rename to op-e2e/actions/helpers/garbage_channel_out.go index d5373755f8fe..6d813520a10a 100644 --- a/op-e2e/actions/garbage_channel_out.go +++ b/op-e2e/actions/helpers/garbage_channel_out.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "bytes" diff --git a/op-e2e/actions/l1_miner.go b/op-e2e/actions/helpers/l1_miner.go similarity index 92% rename from op-e2e/actions/l1_miner.go rename to op-e2e/actions/helpers/l1_miner.go index c35e38ae63c5..c310f234abc8 100644 --- a/op-e2e/actions/l1_miner.go +++ b/op-e2e/actions/helpers/l1_miner.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "math/big" @@ -33,9 +33,9 @@ type L1Miner struct { // L1 block building data l1BuildingHeader *types.Header // block header that we add txs to for block building l1BuildingState *state.StateDB // state used for block building - l1GasPool *core.GasPool // track gas used of ongoing building + L1GasPool *core.GasPool // track gas used of ongoing building pendingIndices map[common.Address]uint64 // per account, how many txs from the pool were already included in the block, since the pool is lagging behind block mining. - l1Transactions []*types.Transaction // collects txs that were successfully included into current block build + L1Transactions []*types.Transaction // collects txs that were successfully included into current block build l1Receipts []*types.Receipt // collect receipts of ongoing building l1Building bool l1TxFailed []*types.Transaction // log of failed transactions which could not be included @@ -120,11 +120,11 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action { s.l1BuildingHeader = header s.l1BuildingState = statedb s.l1Receipts = make([]*types.Receipt, 0) - s.l1Transactions = make([]*types.Transaction, 0) + s.L1Transactions = make([]*types.Transaction, 0) s.pendingIndices = make(map[common.Address]uint64) s.l1BuildingBlobSidecars = make([]*types.BlobTxSidecar, 0) - s.l1GasPool = new(core.GasPool).AddGas(header.GasLimit) + s.L1GasPool = new(core.GasPool).AddGas(header.GasLimit) } } @@ -138,7 +138,7 @@ func (s *L1Miner) ActL1IncludeTx(from common.Address) Action { getPendingIndex := func(from common.Address) uint64 { return s.pendingIndices[from] } - tx := firstValidTx(t, from, getPendingIndex, s.eth.TxPool().ContentFrom, s.EthClient().NonceAt) + tx := firstValidTx(t, from, getPendingIndex, s.Eth.TxPool().ContentFrom, s.EthClient().NonceAt) s.IncludeTx(t, tx) s.pendingIndices[from] = s.pendingIndices[from] + 1 // won't retry the tx } @@ -151,7 +151,7 @@ func (s *L1Miner) ActL1IncludeTxByHash(txHash common.Hash) Action { t.InvalidAction("no tx inclusion when not building l1 block") return } - tx := s.eth.TxPool().Get(txHash) + tx := s.Eth.TxPool().Get(txHash) require.NotNil(t, tx, "cannot find tx %s", txHash) s.IncludeTx(t, tx) from, err := s.l1Signer.Sender(tx) @@ -167,19 +167,19 @@ func (s *L1Miner) IncludeTx(t Testing, tx *types.Transaction) { if tx.Gas() > s.l1BuildingHeader.GasLimit { t.Fatalf("tx consumes %d gas, more than available in L1 block %d", tx.Gas(), s.l1BuildingHeader.GasLimit) } - if tx.Gas() > uint64(*s.l1GasPool) { - t.InvalidAction("action takes too much gas: %d, only have %d", tx.Gas(), uint64(*s.l1GasPool)) + if tx.Gas() > uint64(*s.L1GasPool) { + t.InvalidAction("action takes too much gas: %d, only have %d", tx.Gas(), uint64(*s.L1GasPool)) return } - s.l1BuildingState.SetTxContext(tx.Hash(), len(s.l1Transactions)) + s.l1BuildingState.SetTxContext(tx.Hash(), len(s.L1Transactions)) receipt, err := core.ApplyTransaction(s.l1Cfg.Config, s.l1Chain, &s.l1BuildingHeader.Coinbase, - s.l1GasPool, s.l1BuildingState, s.l1BuildingHeader, tx.WithoutBlobTxSidecar(), &s.l1BuildingHeader.GasUsed, *s.l1Chain.GetVMConfig()) + s.L1GasPool, s.l1BuildingState, s.l1BuildingHeader, tx.WithoutBlobTxSidecar(), &s.l1BuildingHeader.GasUsed, *s.l1Chain.GetVMConfig()) if err != nil { s.l1TxFailed = append(s.l1TxFailed, tx) - t.Fatalf("failed to apply transaction to L1 block (tx %d): %v", len(s.l1Transactions), err) + t.Fatalf("failed to apply transaction to L1 block (tx %d): %v", len(s.L1Transactions), err) } s.l1Receipts = append(s.l1Receipts, receipt) - s.l1Transactions = append(s.l1Transactions, tx.WithoutBlobTxSidecar()) + s.L1Transactions = append(s.L1Transactions, tx.WithoutBlobTxSidecar()) if tx.Type() == types.BlobTxType { require.True(t, s.l1Cfg.Config.IsCancun(s.l1BuildingHeader.Number, s.l1BuildingHeader.Time), "L1 must be cancun to process blob tx") sidecar := tx.BlobTxSidecar() @@ -205,7 +205,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) { } s.l1Building = false - s.l1BuildingHeader.GasUsed = s.l1BuildingHeader.GasLimit - uint64(*s.l1GasPool) + s.l1BuildingHeader.GasUsed = s.l1BuildingHeader.GasLimit - uint64(*s.L1GasPool) s.l1BuildingHeader.Root = s.l1BuildingState.IntermediateRoot(s.l1Cfg.Config.IsEIP158(s.l1BuildingHeader.Number)) var withdrawals []*types.Withdrawal @@ -213,7 +213,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) { 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)) if s.l1Cfg.Config.IsCancun(s.l1BuildingHeader.Number, s.l1BuildingHeader.Time) { parent := s.l1Chain.GetHeaderByHash(s.l1BuildingHeader.ParentHash) var ( diff --git a/op-e2e/actions/l1_miner_test.go b/op-e2e/actions/helpers/l1_miner_test.go similarity index 99% rename from op-e2e/actions/l1_miner_test.go rename to op-e2e/actions/helpers/l1_miner_test.go index a56fc06c235b..b102dcaf84f0 100644 --- a/op-e2e/actions/l1_miner_test.go +++ b/op-e2e/actions/helpers/l1_miner_test.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "math/big" diff --git a/op-e2e/actions/l1_replica.go b/op-e2e/actions/helpers/l1_replica.go similarity index 99% rename from op-e2e/actions/l1_replica.go rename to op-e2e/actions/helpers/l1_replica.go index 3f6a27ed541f..7d5b50d39ccc 100644 --- a/op-e2e/actions/l1_replica.go +++ b/op-e2e/actions/helpers/l1_replica.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "errors" @@ -38,7 +38,7 @@ type L1Replica struct { log log.Logger node *node.Node - eth *eth.Ethereum + Eth *eth.Ethereum // L1 evm / chain l1Chain *core.BlockChain @@ -90,7 +90,7 @@ func NewL1Replica(t Testing, log log.Logger, genesis *core.Genesis) *L1Replica { return &L1Replica{ log: log, node: n, - eth: backend, + Eth: backend, l1Chain: backend.BlockChain(), l1Database: backend.ChainDb(), l1Cfg: genesis, diff --git a/op-e2e/actions/l1_replica_test.go b/op-e2e/actions/helpers/l1_replica_test.go similarity index 99% rename from op-e2e/actions/l1_replica_test.go rename to op-e2e/actions/helpers/l1_replica_test.go index 1d342a86e81f..5bfe2212f59e 100644 --- a/op-e2e/actions/l1_replica_test.go +++ b/op-e2e/actions/helpers/l1_replica_test.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "encoding/binary" diff --git a/op-e2e/actions/l2_batcher.go b/op-e2e/actions/helpers/l2_batcher.go similarity index 91% rename from op-e2e/actions/l2_batcher.go rename to op-e2e/actions/helpers/l2_batcher.go index 75d46f3418ca..d39c324ef9f0 100644 --- a/op-e2e/actions/l2_batcher.go +++ b/op-e2e/actions/helpers/l2_batcher.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "bytes" @@ -106,12 +106,12 @@ type L2Batcher struct { l1Signer types.Signer - l2ChannelOut ChannelOutIface + L2ChannelOut ChannelOutIface l2Submitting bool // when the channel out is being submitted, and not safe to write to without resetting - l2BufferedBlock eth.L2BlockRef + L2BufferedBlock eth.L2BlockRef l2SubmittedBlock eth.L2BlockRef l2BatcherCfg *BatcherCfg - batcherAddr common.Address + BatcherAddr common.Address LastSubmitted *types.Transaction } @@ -126,7 +126,7 @@ func NewL2Batcher(log log.Logger, rollupCfg *rollup.Config, batcherCfg *BatcherC engCl: engCl, l2BatcherCfg: batcherCfg, l1Signer: types.LatestSignerForChainID(rollupCfg.L1ChainID), - batcherAddr: crypto.PubkeyToAddress(batcherCfg.BatcherKey.PublicKey), + BatcherAddr: crypto.PubkeyToAddress(batcherCfg.BatcherKey.PublicKey), } } @@ -144,7 +144,7 @@ func (s *L2Batcher) ActL2BatchBuffer(t Testing) { func (s *L2Batcher) Buffer(t Testing) error { if s.l2Submitting { // break ongoing submitting work if necessary - s.l2ChannelOut = nil + s.L2ChannelOut = nil s.l2Submitting = false } syncStatus, err := s.syncStatusAPI.SyncStatus(t.Ctx()) @@ -153,38 +153,38 @@ func (s *L2Batcher) Buffer(t Testing) error { if s.l2SubmittedBlock == (eth.L2BlockRef{}) { s.log.Info("Starting batch-submitter work at safe-head", "safe", syncStatus.SafeL2) s.l2SubmittedBlock = syncStatus.SafeL2 - s.l2BufferedBlock = syncStatus.SafeL2 - s.l2ChannelOut = nil + s.L2BufferedBlock = syncStatus.SafeL2 + s.L2ChannelOut = nil } // If it's lagging behind, catch it up. if s.l2SubmittedBlock.Number < syncStatus.SafeL2.Number { s.log.Warn("last submitted block lagged behind L2 safe head: batch submission will continue from the safe head now", "last", s.l2SubmittedBlock, "safe", syncStatus.SafeL2) s.l2SubmittedBlock = syncStatus.SafeL2 - s.l2BufferedBlock = syncStatus.SafeL2 - s.l2ChannelOut = nil + s.L2BufferedBlock = syncStatus.SafeL2 + s.L2ChannelOut = nil } // Add the next unsafe block to the channel - if s.l2BufferedBlock.Number >= syncStatus.UnsafeL2.Number { - if s.l2BufferedBlock.Number > syncStatus.UnsafeL2.Number || s.l2BufferedBlock.Hash != syncStatus.UnsafeL2.Hash { + if s.L2BufferedBlock.Number >= syncStatus.UnsafeL2.Number { + if s.L2BufferedBlock.Number > syncStatus.UnsafeL2.Number || s.L2BufferedBlock.Hash != syncStatus.UnsafeL2.Hash { s.log.Error("detected a reorg in L2 chain vs previous buffered information, resetting to safe head now", "safe_head", syncStatus.SafeL2) s.l2SubmittedBlock = syncStatus.SafeL2 - s.l2BufferedBlock = syncStatus.SafeL2 - s.l2ChannelOut = nil + s.L2BufferedBlock = syncStatus.SafeL2 + s.L2ChannelOut = nil } else { s.log.Info("nothing left to submit") return nil } } - block, err := s.l2.BlockByNumber(t.Ctx(), big.NewInt(int64(s.l2BufferedBlock.Number+1))) + block, err := s.l2.BlockByNumber(t.Ctx(), big.NewInt(int64(s.L2BufferedBlock.Number+1))) require.NoError(t, err, "need l2 block %d from sync status", s.l2SubmittedBlock.Number+1) - if block.ParentHash() != s.l2BufferedBlock.Hash { + if block.ParentHash() != s.L2BufferedBlock.Hash { s.log.Error("detected a reorg in L2 chain vs previous submitted information, resetting to safe head now", "safe_head", syncStatus.SafeL2) s.l2SubmittedBlock = syncStatus.SafeL2 - s.l2BufferedBlock = syncStatus.SafeL2 - s.l2ChannelOut = nil + s.L2BufferedBlock = syncStatus.SafeL2 + s.L2ChannelOut = nil } // Create channel if we don't have one yet - if s.l2ChannelOut == nil { + if s.L2ChannelOut == nil { var ch ChannelOutIface if s.l2BatcherCfg.GarbageCfg != nil { ch, err = NewGarbageChannelOut(s.l2BatcherCfg.GarbageCfg) @@ -210,29 +210,29 @@ func (s *L2Batcher) Buffer(t Testing) error { } } require.NoError(t, err, "failed to create channel") - s.l2ChannelOut = ch + s.L2ChannelOut = ch } - if err := s.l2ChannelOut.AddBlock(s.rollupCfg, block); err != nil { + if err := s.L2ChannelOut.AddBlock(s.rollupCfg, block); err != nil { return err } ref, err := s.engCl.L2BlockRefByHash(t.Ctx(), block.Hash()) require.NoError(t, err, "failed to get L2BlockRef") - s.l2BufferedBlock = ref + s.L2BufferedBlock = ref return nil } func (s *L2Batcher) ActL2ChannelClose(t Testing) { // Don't run this action if there's no data to submit - if s.l2ChannelOut == nil { + if s.L2ChannelOut == nil { t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer") return } - require.NoError(t, s.l2ChannelOut.Close(), "must close channel before submitting it") + require.NoError(t, s.L2ChannelOut.Close(), "must close channel before submitting it") } func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte { // Don't run this action if there's no data to submit - if s.l2ChannelOut == nil { + if s.L2ChannelOut == nil { t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer") return nil } @@ -240,8 +240,8 @@ func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte { data := new(bytes.Buffer) data.WriteByte(derive.DerivationVersion0) // subtract one, to account for the version byte - if _, err := s.l2ChannelOut.OutputFrame(data, s.l2BatcherCfg.MaxL1TxSize-1); err == io.EOF { - s.l2ChannelOut = nil + if _, err := s.L2ChannelOut.OutputFrame(data, s.l2BatcherCfg.MaxL1TxSize-1); err == io.EOF { + s.L2ChannelOut = nil s.l2Submitting = false } else if err != nil { s.l2Submitting = false @@ -263,7 +263,7 @@ func (s *L2Batcher) ActL2BatchSubmitRaw(t Testing, payload []byte, txOpts ...fun payload = comm.TxData() } - nonce, err := s.l1.PendingNonceAt(t.Ctx(), s.batcherAddr) + nonce, err := s.l1.PendingNonceAt(t.Ctx(), s.BatcherAddr) require.NoError(t, err, "need batcher nonce") gasTipCap := big.NewInt(2 * params.GWei) @@ -334,7 +334,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { } // Don't run this action if there's no data to submit - if s.l2ChannelOut == nil { + if s.L2ChannelOut == nil { t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer") return } @@ -351,12 +351,12 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { // subtract one, to account for the version byte l = s.l2BatcherCfg.MaxL1TxSize - 1 } - if _, err := s.l2ChannelOut.OutputFrame(data, l); err == io.EOF { + if _, err := s.L2ChannelOut.OutputFrame(data, l); err == io.EOF { s.l2Submitting = false if i < numBlobs-1 { t.Fatalf("failed to fill up %d blobs, only filled %d", numBlobs, i+1) } - s.l2ChannelOut = nil + s.L2ChannelOut = nil } else if err != nil { s.l2Submitting = false t.Fatalf("failed to output channel data to frame: %v", err) @@ -366,7 +366,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { require.NoError(t, blobs[i].FromData(data.Bytes()), "must turn data into blob") } - nonce, err := s.l1.PendingNonceAt(t.Ctx(), s.batcherAddr) + nonce, err := s.l1.PendingNonceAt(t.Ctx(), s.BatcherAddr) require.NoError(t, err, "need batcher nonce") gasTipCap := big.NewInt(2 * params.GWei) @@ -453,7 +453,7 @@ func (s *L2Batcher) ActL2BatchSubmitGarbageRaw(t Testing, outputFrame []byte, ki func (s *L2Batcher) ActBufferAll(t Testing) { stat, err := s.syncStatusAPI.SyncStatus(t.Ctx()) require.NoError(t, err) - for s.l2BufferedBlock.Number < stat.UnsafeL2.Number { + for s.L2BufferedBlock.Number < stat.UnsafeL2.Number { s.ActL2BatchBuffer(t) } } diff --git a/op-e2e/actions/l2_engine.go b/op-e2e/actions/helpers/l2_engine.go similarity index 91% rename from op-e2e/actions/l2_engine.go rename to op-e2e/actions/helpers/l2_engine.go index 80d705d854e5..4bd8fe118d61 100644 --- a/op-e2e/actions/l2_engine.go +++ b/op-e2e/actions/helpers/l2_engine.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "errors" @@ -35,7 +35,7 @@ type L2Engine struct { log log.Logger node *node.Node - eth *geth.Ethereum + Eth *geth.Ethereum rollupGenesis *rollup.Genesis @@ -43,9 +43,9 @@ type L2Engine struct { l2Chain *core.BlockChain l2Signer types.Signer - engineApi *engineapi.L2EngineAPI + EngineApi *engineapi.L2EngineAPI - failL2RPC func(call []rpc.BatchElem) error // mock error + FailL2RPC func(call []rpc.BatchElem) error // mock error } type EngineOption func(ethCfg *ethconfig.Config, nodeCfg *node.Config) error @@ -58,7 +58,7 @@ func NewL2Engine(t Testing, log log.Logger, genesis *core.Genesis, rollupGenesis eng := &L2Engine{ log: log, node: n, - eth: ethBackend, + Eth: ethBackend, rollupGenesis: &rollup.Genesis{ L1: rollupGenesisL1, L2: eth.BlockID{Hash: genesisBlock.Hash(), Number: genesisBlock.NumberU64()}, @@ -66,14 +66,14 @@ func NewL2Engine(t Testing, log log.Logger, genesis *core.Genesis, rollupGenesis }, l2Chain: chain, l2Signer: types.LatestSigner(genesis.Config), - engineApi: engineApi, + EngineApi: engineApi, } // register the custom engine API, so we can serve engine requests while having more control // over sequencing of individual txs. n.RegisterAPIs([]rpc.API{ { Namespace: "engine", - Service: eng.engineApi, + Service: eng.EngineApi, Authenticated: true, }, }) @@ -172,10 +172,10 @@ func (e *L2Engine) RPCClient() client.RPC { return testutils.RPCErrFaker{ RPC: client.NewBaseRPCClient(cl), ErrFn: func(call []rpc.BatchElem) error { - if e.failL2RPC == nil { + if e.FailL2RPC == nil { return nil } - return e.failL2RPC(call) + return e.FailL2RPC(call) }, } } @@ -188,12 +188,12 @@ func (e *L2Engine) EngineClient(t Testing, cfg *rollup.Config) *sources.EngineCl // ActL2RPCFail makes the next L2 RPC request fail with given error func (e *L2Engine) ActL2RPCFail(t Testing, err error) { - if e.failL2RPC != nil { // already set to fail? + if e.FailL2RPC != nil { // already set to fail? t.InvalidAction("already set a mock L2 rpc error") return } - e.failL2RPC = func(call []rpc.BatchElem) error { - e.failL2RPC = nil + e.FailL2RPC = func(call []rpc.BatchElem) error { + e.FailL2RPC = nil return err } } @@ -201,13 +201,13 @@ func (e *L2Engine) ActL2RPCFail(t Testing, err error) { // ActL2IncludeTx includes the next transaction from the given address in the block that is being built func (e *L2Engine) ActL2IncludeTx(from common.Address) Action { return func(t Testing) { - if e.engineApi.ForcedEmpty() { + if e.EngineApi.ForcedEmpty() { e.log.Info("Skipping including a transaction because e.L2ForceEmpty is true") return } - tx := firstValidTx(t, from, e.engineApi.PendingIndices, e.eth.TxPool().ContentFrom, e.EthClient().NonceAt) - err := e.engineApi.IncludeTx(tx, from) + tx := firstValidTx(t, from, e.EngineApi.PendingIndices, e.Eth.TxPool().ContentFrom, e.EthClient().NonceAt) + err := e.EngineApi.IncludeTx(tx, from) if errors.Is(err, engineapi.ErrNotBuildingBlock) { t.InvalidAction(err.Error()) } else if errors.Is(err, engineapi.ErrUsesTooMuchGas) { diff --git a/op-e2e/actions/l2_engine_test.go b/op-e2e/actions/helpers/l2_engine_test.go similarity index 99% rename from op-e2e/actions/l2_engine_test.go rename to op-e2e/actions/helpers/l2_engine_test.go index 2ea335ec855e..d74595d31621 100644 --- a/op-e2e/actions/l2_engine_test.go +++ b/op-e2e/actions/helpers/l2_engine_test.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "encoding/binary" diff --git a/op-e2e/actions/l2_proposer.go b/op-e2e/actions/helpers/l2_proposer.go similarity index 99% rename from op-e2e/actions/l2_proposer.go rename to op-e2e/actions/helpers/l2_proposer.go index 6f7edd0e5057..e97a66a1f5bc 100644 --- a/op-e2e/actions/l2_proposer.go +++ b/op-e2e/actions/helpers/l2_proposer.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" diff --git a/op-e2e/actions/l2_sequencer.go b/op-e2e/actions/helpers/l2_sequencer.go similarity index 95% rename from op-e2e/actions/l2_sequencer.go rename to op-e2e/actions/helpers/l2_sequencer.go index a4626749b18a..98becdcc87a4 100644 --- a/op-e2e/actions/l2_sequencer.go +++ b/op-e2e/actions/helpers/l2_sequencer.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" @@ -89,7 +89,7 @@ func NewL2Sequencer(t Testing, log log.Logger, l1 derive.L1Fetcher, blobSrc deri // ActL2StartBlock starts building of a new L2 block on top of the head func (s *L2Sequencer) ActL2StartBlock(t Testing) { - if !s.l2PipelineIdle { + if !s.L2PipelineIdle { t.InvalidAction("cannot start L2 build when derivation is not idle") return } @@ -191,22 +191,22 @@ func (s *L2Sequencer) ActBuildL2ToTime(t Testing, target uint64) { } func (s *L2Sequencer) ActBuildL2ToEcotone(t Testing) { - require.NotNil(t, s.rollupCfg.EcotoneTime, "cannot activate Ecotone when it is not scheduled") - for s.L2Unsafe().Time < *s.rollupCfg.EcotoneTime { + require.NotNil(t, s.RollupCfg.EcotoneTime, "cannot activate Ecotone when it is not scheduled") + for s.L2Unsafe().Time < *s.RollupCfg.EcotoneTime { s.ActL2StartBlock(t) s.ActL2EndBlock(t) } } func (s *L2Sequencer) ActBuildL2ToFjord(t Testing) { - require.NotNil(t, s.rollupCfg.FjordTime, "cannot activate FjordTime when it is not scheduled") - for s.L2Unsafe().Time < *s.rollupCfg.FjordTime { + require.NotNil(t, s.RollupCfg.FjordTime, "cannot activate FjordTime when it is not scheduled") + for s.L2Unsafe().Time < *s.RollupCfg.FjordTime { s.ActL2StartBlock(t) s.ActL2EndBlock(t) } } func (s *L2Sequencer) ActBuildL2ToGranite(t Testing) { - require.NotNil(t, s.rollupCfg.GraniteTime, "cannot activate GraniteTime when it is not scheduled") - for s.L2Unsafe().Time < *s.rollupCfg.GraniteTime { + require.NotNil(t, s.RollupCfg.GraniteTime, "cannot activate GraniteTime when it is not scheduled") + for s.L2Unsafe().Time < *s.RollupCfg.GraniteTime { s.ActL2StartBlock(t) s.ActL2EndBlock(t) } diff --git a/op-e2e/actions/l2_verifier.go b/op-e2e/actions/helpers/l2_verifier.go similarity index 97% rename from op-e2e/actions/l2_verifier.go rename to op-e2e/actions/helpers/l2_verifier.go index 03de1a674f1c..4d201a88fb0c 100644 --- a/op-e2e/actions/l2_verifier.go +++ b/op-e2e/actions/helpers/l2_verifier.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" @@ -40,7 +40,7 @@ type L2Verifier struct { log log.Logger - eng L2API + Eng L2API syncStatus driver.SyncStatusTracker @@ -57,10 +57,10 @@ type L2Verifier struct { l1 derive.L1Fetcher - l2PipelineIdle bool + L2PipelineIdle bool l2Building bool - rollupCfg *rollup.Config + RollupCfg *rollup.Config rpc *rpc.Server @@ -160,7 +160,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, rollupNode := &L2Verifier{ eventSys: sys, log: log, - eng: eng, + Eng: eng, engine: ec, derivation: pipeline, safeHeadListener: safeHeadListener, @@ -168,9 +168,9 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, drainer: executor, l1: l1, syncStatus: syncStatusTracker, - l2PipelineIdle: true, + L2PipelineIdle: true, l2Building: false, - rollupCfg: cfg, + RollupCfg: cfg, rpc: rpc.NewServer(), synchronousEvents: testActionEmitter, } @@ -205,7 +205,7 @@ type l2VerifierBackend struct { } func (s *l2VerifierBackend) BlockRefWithStatus(ctx context.Context, num uint64) (eth.L2BlockRef, *eth.SyncStatus, error) { - ref, err := s.verifier.eng.L2BlockRefByNumber(ctx, num) + ref, err := s.verifier.Eng.L2BlockRefByNumber(ctx, num) return ref, s.verifier.SyncStatus(), err } @@ -345,9 +345,9 @@ func (s *L2Verifier) OnEvent(ev event.Event) bool { case rollup.CriticalErrorEvent: panic(fmt.Errorf("derivation failed critically: %w", x.Err)) case derive.DeriverIdleEvent: - s.l2PipelineIdle = true + s.L2PipelineIdle = true case derive.PipelineStepEvent: - s.l2PipelineIdle = false + s.L2PipelineIdle = false case driver.StepReqEvent: s.synchronousEvents.Emit(driver.StepEvent{}) default: @@ -396,7 +396,7 @@ func (s *L2Verifier) ActL2UnsafeGossipReceive(payload *eth.ExecutionPayloadEnvel // ActL2InsertUnsafePayload creates an action that can insert an unsafe execution payload func (s *L2Verifier) ActL2InsertUnsafePayload(payload *eth.ExecutionPayloadEnvelope) Action { return func(t Testing) { - ref, err := derive.PayloadToBlockRef(s.rollupCfg, payload.ExecutionPayload) + ref, err := derive.PayloadToBlockRef(s.RollupCfg, payload.ExecutionPayload) require.NoError(t, err) err = s.engine.InsertUnsafePayload(t.Ctx(), payload, ref) require.NoError(t, err) diff --git a/op-e2e/actions/helpers/setups.go b/op-e2e/actions/helpers/setups.go new file mode 100644 index 000000000000..26e19eae82a0 --- /dev/null +++ b/op-e2e/actions/helpers/setups.go @@ -0,0 +1,75 @@ +package helpers + +import ( + altda "github.com/ethereum-optimism/optimism/op-alt-da" + "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" + "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/ethereum-optimism/optimism/op-node/rollup/sync" + "github.com/ethereum-optimism/optimism/op-service/sources" + "github.com/ethereum-optimism/optimism/op-service/testlog" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/log" + "github.com/stretchr/testify/require" +) + +func SetupSequencerTest(t Testing, sd *e2eutils.SetupData, log log.Logger, opts ...SequencerOpt) (*L1Miner, *L2Engine, *L2Sequencer) { + jwtPath := e2eutils.WriteDefaultJWT(t) + cfg := DefaultSequencerConfig() + for _, opt := range opts { + opt(cfg) + } + + miner := NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg) + + l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) + require.NoError(t, err) + engine := NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, EngineWithP2P()) + l2Cl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) + require.NoError(t, err) + + sequencer := NewL2Sequencer(t, log.New("role", "sequencer"), l1F, miner.BlobStore(), altda.Disabled, l2Cl, sd.RollupCfg, 0, cfg.InteropBackend) + return miner, engine, sequencer +} + +func SetupVerifier(t Testing, sd *e2eutils.SetupData, log log.Logger, + l1F derive.L1Fetcher, blobSrc derive.L1BlobsFetcher, syncCfg *sync.Config, opts ...VerifierOpt) (*L2Engine, *L2Verifier) { + cfg := DefaultVerifierCfg() + for _, opt := range opts { + opt(cfg) + } + jwtPath := e2eutils.WriteDefaultJWT(t) + engine := NewL2Engine(t, log.New("role", "verifier-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, EngineWithP2P()) + engCl := engine.EngineClient(t, sd.RollupCfg) + verifier := NewL2Verifier(t, log.New("role", "verifier"), l1F, blobSrc, altda.Disabled, engCl, sd.RollupCfg, syncCfg, cfg.SafeHeadListener, cfg.InteropBackend) + return engine, verifier +} + +func SetupVerifierOnlyTest(t Testing, sd *e2eutils.SetupData, log log.Logger) (*L1Miner, *L2Engine, *L2Verifier) { + miner := NewL1Miner(t, log, sd.L1Cfg) + l1Cl := miner.L1Client(t, sd.RollupCfg) + engine, verifier := SetupVerifier(t, sd, log, l1Cl, miner.BlobStore(), &sync.Config{}) + return miner, engine, verifier +} + +func SetupReorgTest(t Testing, config *e2eutils.TestParams, deltaTimeOffset *hexutil.Uint64) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine, *L2Batcher) { + dp := e2eutils.MakeDeployParams(t, config) + helpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + + sd := e2eutils.Setup(t, dp, DefaultAlloc) + log := testlog.Logger(t, log.LevelDebug) + + return SetupReorgTestActors(t, dp, sd, log) +} + +func SetupReorgTestActors(t Testing, dp *e2eutils.DeployParams, sd *e2eutils.SetupData, log log.Logger) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine, *L2Batcher) { + miner, seqEngine, sequencer := SetupSequencerTest(t, sd, log) + miner.ActL1SetFeeRecipient(common.Address{'A'}) + sequencer.ActL2PipelineFull(t) + verifEngine, verifier := SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + rollupSeqCl := sequencer.RollupClient() + batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) + return sd, dp, miner, sequencer, seqEngine, verifier, verifEngine, batcher +} diff --git a/op-e2e/actions/tx_helper.go b/op-e2e/actions/helpers/tx_helper.go similarity index 99% rename from op-e2e/actions/tx_helper.go rename to op-e2e/actions/helpers/tx_helper.go index e63c1a224822..8174563102c8 100644 --- a/op-e2e/actions/tx_helper.go +++ b/op-e2e/actions/helpers/tx_helper.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" diff --git a/op-e2e/actions/user.go b/op-e2e/actions/helpers/user.go similarity index 99% rename from op-e2e/actions/user.go rename to op-e2e/actions/helpers/user.go index dabc9c1d8980..401237c0fad3 100644 --- a/op-e2e/actions/user.go +++ b/op-e2e/actions/helpers/user.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "context" diff --git a/op-e2e/actions/user_test.go b/op-e2e/actions/helpers/user_test.go similarity index 98% rename from op-e2e/actions/user_test.go rename to op-e2e/actions/helpers/user_test.go index 8bb1b042c9a3..8ee60aa680e3 100644 --- a/op-e2e/actions/user_test.go +++ b/op-e2e/actions/helpers/user_test.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "fmt" @@ -131,7 +131,7 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { require.Equal(t, dp.Secrets.Addresses().Batcher, dp.DeployConfig.BatchSenderAddress) require.Equal(t, dp.Secrets.Addresses().Proposer, dp.DeployConfig.L2OutputOracleProposer) - miner, seqEngine, seq := setupSequencerTest(t, sd, log) + miner, seqEngine, seq := SetupSequencerTest(t, sd, log) batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), seq.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) @@ -199,7 +199,7 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { require.NoError(t, err) require.True(t, infoTx.IsDepositTx()) // Should only be a system tx if regolith is not enabled - require.Equal(t, !seq.rollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx()) + require.Equal(t, !seq.RollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx()) // regular L2 tx, in new L2 block alice.L2.ActResetTxOpts(t) @@ -320,5 +320,5 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { require.NoError(t, err) require.True(t, infoTx.IsDepositTx()) // Should only be a system tx if regolith is not enabled - require.Equal(t, !seq.rollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx()) + require.Equal(t, !seq.RollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx()) } diff --git a/op-e2e/actions/utils.go b/op-e2e/actions/helpers/utils.go similarity index 99% rename from op-e2e/actions/utils.go rename to op-e2e/actions/helpers/utils.go index aa03db3e29b5..f4f1b812cbaa 100644 --- a/op-e2e/actions/utils.go +++ b/op-e2e/actions/helpers/utils.go @@ -1,4 +1,4 @@ -package actions +package helpers import ( "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" diff --git a/op-e2e/actions/interop_test.go b/op-e2e/actions/interop/interop_test.go similarity index 89% rename from op-e2e/actions/interop_test.go rename to op-e2e/actions/interop/interop_test.go index 614ab05f65a7..4015ffa29ce9 100644 --- a/op-e2e/actions/interop_test.go +++ b/op-e2e/actions/interop/interop_test.go @@ -1,8 +1,9 @@ -package actions +package interop import ( "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/log" @@ -18,24 +19,24 @@ import ( var _ interop.InteropBackend = (*testutils.MockInteropBackend)(nil) func TestInteropVerifier(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) // Temporary work-around: interop needs to be active, for cross-safety to not be instant. // The state genesis in this test is pre-interop however. sd.RollupCfg.InteropTime = new(uint64) logger := testlog.Logger(t, log.LevelDebug) seqMockBackend := &testutils.MockInteropBackend{} - l1Miner, seqEng, seq := setupSequencerTest(t, sd, logger, - WithVerifierOpts(WithInteropBackend(seqMockBackend))) + l1Miner, seqEng, seq := helpers.SetupSequencerTest(t, sd, logger, + helpers.WithVerifierOpts(helpers.WithInteropBackend(seqMockBackend))) - batcher := NewL2Batcher(logger, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := helpers.NewL2Batcher(logger, sd.RollupCfg, helpers.DefaultBatcherCfg(dp), seq.RollupClient(), l1Miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) verMockBackend := &testutils.MockInteropBackend{} - _, ver := setupVerifier(t, sd, logger, + _, ver := helpers.SetupVerifier(t, sd, logger, l1Miner.L1Client(t, sd.RollupCfg), l1Miner.BlobStore(), &sync.Config{}, - WithInteropBackend(verMockBackend)) + helpers.WithInteropBackend(verMockBackend)) seq.ActL2PipelineFull(t) ver.ActL2PipelineFull(t) diff --git a/op-e2e/actions/proofs/channel_timeout_test.go b/op-e2e/actions/proofs/channel_timeout_test.go index 9bee473f188b..f4ab00a86538 100644 --- a/op-e2e/actions/proofs/channel_timeout_test.go +++ b/op-e2e/actions/proofs/channel_timeout_test.go @@ -3,7 +3,7 @@ package proofs import ( "testing" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-program/client/claim" @@ -21,7 +21,7 @@ import ( // 5. Instruct the sequencer to derive the L2 chain. // 6. Run the FPP on the safe head. func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { - t := actions.NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) { // Set the channel timeout to 10 blocks, 12x lower than the sequencing window. tp.ChannelTimeout = 10 diff --git a/op-e2e/actions/proofs/garbage_channel_test.go b/op-e2e/actions/proofs/garbage_channel_test.go index 06c888582a05..f112a1a71bda 100644 --- a/op-e2e/actions/proofs/garbage_channel_test.go +++ b/op-e2e/actions/proofs/garbage_channel_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-program/client/claim" @@ -15,19 +15,19 @@ import ( // garbageKinds is a list of garbage kinds to test. We don't use `INVALID_COMPRESSION` and `MALFORM_RLP` because // they submit malformed frames always, and this test models a valid channel with a single invalid frame in the // middle. -var garbageKinds = []actions.GarbageKind{ - actions.STRIP_VERSION, - actions.RANDOM, - actions.TRUNCATE_END, - actions.DIRTY_APPEND, +var garbageKinds = []actionsHelpers.GarbageKind{ + actionsHelpers.STRIP_VERSION, + actionsHelpers.RANDOM, + actionsHelpers.TRUNCATE_END, + actionsHelpers.DIRTY_APPEND, } // Run a test that submits garbage channel data in the middle of a channel. // // channel format ([]Frame): // [f[0 - correct] f_x[1 - bad frame] f[1 - correct]] -func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actions.GarbageKind]) { - t := actions.NewDefaultTesting(gt) +func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actionsHelpers.GarbageKind]) { + t := actionsHelpers.NewDefaultTesting(gt) tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) { // Set the channel timeout to 10 blocks, 12x lower than the sequencing window. tp.ChannelTimeout = 10 @@ -100,7 +100,7 @@ func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actions.Garba } func Test_ProgramAction_GarbageChannel(gt *testing.T) { - matrix := helpers.NewMatrix[actions.GarbageKind]() + matrix := helpers.NewMatrix[actionsHelpers.GarbageKind]() defer matrix.Run(gt) for _, garbageKind := range garbageKinds { diff --git a/op-e2e/actions/proofs/helpers/env.go b/op-e2e/actions/proofs/helpers/env.go index 50fecbb94fb2..1ec23eb472f6 100644 --- a/op-e2e/actions/proofs/helpers/env.go +++ b/op-e2e/actions/proofs/helpers/env.go @@ -6,7 +6,7 @@ import ( altda "github.com/ethereum-optimism/optimism/op-alt-da" batcherFlags "github.com/ethereum-optimism/optimism/op-batcher/flags" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-program/host" "github.com/ethereum-optimism/optimism/op-program/host/config" @@ -25,17 +25,17 @@ import ( // L2FaultProofEnv is a test harness for a fault provable L2 chain. type L2FaultProofEnv struct { log log.Logger - Batcher *actions.L2Batcher - Sequencer *actions.L2Sequencer - Engine *actions.L2Engine + Batcher *helpers.L2Batcher + Sequencer *helpers.L2Sequencer + Engine *helpers.L2Engine engCl *sources.EngineClient sd *e2eutils.SetupData dp *e2eutils.DeployParams - Miner *actions.L1Miner - Alice *actions.CrossLayerUser + Miner *helpers.L1Miner + Alice *helpers.CrossLayerUser } -func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eutils.TestParams, batcherCfg *actions.BatcherCfg) *L2FaultProofEnv { +func NewL2FaultProofEnv[c any](t helpers.Testing, testCfg *TestCfg[c], tp *e2eutils.TestParams, batcherCfg *helpers.BatcherCfg) *L2FaultProofEnv { log := testlog.Logger(t, log.LvlDebug) dp := NewDeployParams(t, func(dp *e2eutils.DeployParams) { genesisBlock := hexutil.Uint64(0) @@ -59,44 +59,44 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut dp.DeployConfig.L2GenesisGraniteTimeOffset = &genesisBlock } }) - sd := e2eutils.Setup(t, dp, actions.DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) jwtPath := e2eutils.WriteDefaultJWT(t) - cfg := &actions.SequencerCfg{VerifierCfg: *actions.DefaultVerifierCfg()} + cfg := &helpers.SequencerCfg{VerifierCfg: *helpers.DefaultVerifierCfg()} - miner := actions.NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg) + miner := helpers.NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg) l1Cl, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) require.NoError(t, err) - engine := actions.NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, actions.EngineWithP2P()) + engine := helpers.NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, helpers.EngineWithP2P()) l2EngineCl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) - sequencer := actions.NewL2Sequencer(t, log.New("role", "sequencer"), l1Cl, miner.BlobStore(), altda.Disabled, l2EngineCl, sd.RollupCfg, 0, cfg.InteropBackend) + sequencer := helpers.NewL2Sequencer(t, log.New("role", "sequencer"), l1Cl, miner.BlobStore(), altda.Disabled, l2EngineCl, sd.RollupCfg, 0, cfg.InteropBackend) miner.ActL1SetFeeRecipient(common.Address{0xCA, 0xFE, 0xBA, 0xBE}) sequencer.ActL2PipelineFull(t) engCl := engine.EngineClient(t, sd.RollupCfg) // Set the batcher key to the secret key of the batcher batcherCfg.BatcherKey = dp.Secrets.Batcher - batcher := actions.NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engCl) + batcher := helpers.NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engCl) addresses := e2eutils.CollectAddresses(sd, dp) l1EthCl := miner.EthClient() l2EthCl := engine.EthClient() - l1UserEnv := &actions.BasicUserEnv[*actions.L1Bindings]{ + l1UserEnv := &helpers.BasicUserEnv[*helpers.L1Bindings]{ EthCl: l1EthCl, Signer: types.LatestSigner(sd.L1Cfg.Config), AddressCorpora: addresses, - Bindings: actions.NewL1Bindings(t, l1EthCl), + Bindings: helpers.NewL1Bindings(t, l1EthCl), } - l2UserEnv := &actions.BasicUserEnv[*actions.L2Bindings]{ + l2UserEnv := &helpers.BasicUserEnv[*helpers.L2Bindings]{ EthCl: l2EthCl, Signer: types.LatestSigner(sd.L2Cfg.Config), AddressCorpora: addresses, - Bindings: actions.NewL2Bindings(t, l2EthCl, engine.GethClient()), + Bindings: helpers.NewL2Bindings(t, l2EthCl, engine.GethClient()), } - alice := actions.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) + alice := helpers.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) alice.L1.SetUserEnv(l1UserEnv) alice.L2.SetUserEnv(l2UserEnv) @@ -115,16 +115,16 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut type FixtureInputParam func(f *FixtureInputs) -type CheckResult func(actions.Testing, error) +type CheckResult func(helpers.Testing, error) func ExpectNoError() CheckResult { - return func(t actions.Testing, err error) { + return func(t helpers.Testing, err error) { require.NoError(t, err, "fault proof program should have succeeded") } } func ExpectError(expectedErr error) CheckResult { - return func(t actions.Testing, err error) { + return func(t helpers.Testing, err error) { require.ErrorIs(t, err, expectedErr, "fault proof program should have failed with expected error") } } @@ -135,7 +135,7 @@ func WithL2Claim(claim common.Hash) FixtureInputParam { } } -func (env *L2FaultProofEnv) RunFaultProofProgram(t actions.Testing, l2ClaimBlockNum uint64, checkResult CheckResult, fixtureInputParams ...FixtureInputParam) { +func (env *L2FaultProofEnv) RunFaultProofProgram(t helpers.Testing, l2ClaimBlockNum uint64, checkResult CheckResult, fixtureInputParams ...FixtureInputParam) { // Fetch the pre and post output roots for the fault proof. preRoot, err := env.Sequencer.RollupClient().OutputAtBlock(t.Ctx(), l2ClaimBlockNum-1) require.NoError(t, err) @@ -182,7 +182,7 @@ func (env *L2FaultProofEnv) RunFaultProofProgram(t actions.Testing, l2ClaimBlock type TestParam func(p *e2eutils.TestParams) func NewTestParams(params ...TestParam) *e2eutils.TestParams { - dfault := actions.DefaultRollupTestParams + dfault := helpers.DefaultRollupTestParams for _, apply := range params { apply(dfault) } @@ -191,7 +191,7 @@ func NewTestParams(params ...TestParam) *e2eutils.TestParams { type DeployParam func(p *e2eutils.DeployParams) -func NewDeployParams(t actions.Testing, params ...DeployParam) *e2eutils.DeployParams { +func NewDeployParams(t helpers.Testing, params ...DeployParam) *e2eutils.DeployParams { dfault := e2eutils.MakeDeployParams(t, NewTestParams()) for _, apply := range params { apply(dfault) @@ -199,10 +199,10 @@ func NewDeployParams(t actions.Testing, params ...DeployParam) *e2eutils.DeployP return dfault } -type BatcherCfgParam func(c *actions.BatcherCfg) +type BatcherCfgParam func(c *helpers.BatcherCfg) -func NewBatcherCfg(params ...BatcherCfgParam) *actions.BatcherCfg { - dfault := &actions.BatcherCfg{ +func NewBatcherCfg(params ...BatcherCfgParam) *helpers.BatcherCfg { + dfault := &helpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, DataAvailabilityType: batcherFlags.BlobsType, @@ -216,7 +216,7 @@ func NewBatcherCfg(params ...BatcherCfgParam) *actions.BatcherCfg { type OpProgramCfgParam func(p *config.Config) func NewOpProgramCfg( - t actions.Testing, + t helpers.Testing, env *L2FaultProofEnv, fi *FixtureInputs, params ...OpProgramCfgParam, diff --git a/op-e2e/actions/proofs/helpers/fixture.go b/op-e2e/actions/proofs/helpers/fixture.go index 22c5590b9955..26c97de0a0cf 100644 --- a/op-e2e/actions/proofs/helpers/fixture.go +++ b/op-e2e/actions/proofs/helpers/fixture.go @@ -10,7 +10,7 @@ import ( "regexp" "strings" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-program/client/claim" "github.com/ethereum-optimism/optimism/op-program/host/config" "github.com/ethereum/go-ethereum/common" @@ -48,7 +48,7 @@ type FixtureInputs struct { // Dumps a `fp-tests` test fixture to disk if the `OP_E2E_DUMP_FIXTURES` environment variable is set. // // [fp-tests]: https://github.com/ethereum-optimism/fp-tests -func tryDumpTestFixture(t actions.Testing, result error, name string, env *L2FaultProofEnv, programCfg *config.Config) { +func tryDumpTestFixture(t helpers.Testing, result error, name string, env *L2FaultProofEnv, programCfg *config.Config) { if !dumpFixtures { return } diff --git a/op-e2e/actions/proofs/sequence_window_expiry_test.go b/op-e2e/actions/proofs/sequence_window_expiry_test.go index 68a949a10b3f..44f58895faac 100644 --- a/op-e2e/actions/proofs/sequence_window_expiry_test.go +++ b/op-e2e/actions/proofs/sequence_window_expiry_test.go @@ -3,7 +3,7 @@ package proofs import ( "testing" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" @@ -11,7 +11,7 @@ import ( // Run a test that proves a deposit-only block generated due to sequence window expiry. func runSequenceWindowExpireTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { - t := actions.NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) tp := helpers.NewTestParams() env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg()) diff --git a/op-e2e/actions/proofs/simple_program_test.go b/op-e2e/actions/proofs/simple_program_test.go index 2d7360bb94af..ab3218caf1e4 100644 --- a/op-e2e/actions/proofs/simple_program_test.go +++ b/op-e2e/actions/proofs/simple_program_test.go @@ -3,7 +3,7 @@ package proofs import ( "testing" - "github.com/ethereum-optimism/optimism/op-e2e/actions" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" "github.com/ethereum-optimism/optimism/op-program/client/claim" "github.com/ethereum/go-ethereum/common" @@ -11,7 +11,7 @@ import ( ) func runSimpleProgramTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { - t := actions.NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) env := helpers.NewL2FaultProofEnv(t, testCfg, helpers.NewTestParams(), helpers.NewBatcherCfg()) // Build an empty block on L2 diff --git a/op-e2e/actions/l2_proposer_test.go b/op-e2e/actions/proposer/l2_proposer_test.go similarity index 88% rename from op-e2e/actions/l2_proposer_test.go rename to op-e2e/actions/proposer/l2_proposer_test.go index a8fe25816a0c..a75ece69b080 100644 --- a/op-e2e/actions/l2_proposer_test.go +++ b/op-e2e/actions/proposer/l2_proposer_test.go @@ -1,10 +1,12 @@ -package actions +package proposer import ( "math/big" "testing" "time" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -44,24 +46,24 @@ func TestProposerBatchType(t *testing.T) { } func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) - var proposer *L2Proposer + var proposer *actionsHelpers.L2Proposer if e2eutils.UseFaultProofs() { optimismPortal2Contract, err := bindingspreview.NewOptimismPortal2(sd.DeploymentsL1.OptimismPortalProxy, miner.EthClient()) require.NoError(t, err) respectedGameType, err := optimismPortal2Contract.RespectedGameType(&bind.CallOpts{}) require.NoError(t, err) - proposer = NewL2Proposer(t, log, &ProposerCfg{ + proposer = actionsHelpers.NewL2Proposer(t, log, &actionsHelpers.ProposerCfg{ DisputeGameFactoryAddr: &sd.DeploymentsL1.DisputeGameFactoryProxy, ProposalInterval: 6 * time.Second, ProposalRetryInterval: 3 * time.Second, @@ -70,7 +72,7 @@ func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { AllowNonFinalized: true, }, miner.EthClient(), rollupSeqCl) } else { - proposer = NewL2Proposer(t, log, &ProposerCfg{ + proposer = actionsHelpers.NewL2Proposer(t, log, &actionsHelpers.ProposerCfg{ OutputOracleAddr: &sd.DeploymentsL1.L2OutputOracleProxy, ProposerKey: dp.Secrets.Proposer, ProposalRetryInterval: 3 * time.Second, diff --git a/op-e2e/actions/safedb/helpers/setups.go b/op-e2e/actions/safedb/helpers/setups.go new file mode 100644 index 000000000000..fcc70f494a74 --- /dev/null +++ b/op-e2e/actions/safedb/helpers/setups.go @@ -0,0 +1,38 @@ +package helpers + +import ( + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" + "github.com/ethereum-optimism/optimism/op-node/node/safedb" + "github.com/ethereum-optimism/optimism/op-node/rollup/sync" + "github.com/ethereum-optimism/optimism/op-service/testlog" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" + "github.com/stretchr/testify/require" +) + +func SetupSafeDBTest(t helpers.Testing, config *e2eutils.TestParams) (*e2eutils.SetupData, *helpers.L1Miner, *helpers.L2Sequencer, *helpers.L2Verifier, *helpers.L2Engine, *helpers.L2Batcher) { + dp := e2eutils.MakeDeployParams(t, config) + + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) + logger := testlog.Logger(t, log.LevelDebug) + + return SetupSafeDBTestActors(t, dp, sd, logger) +} + +func SetupSafeDBTestActors(t helpers.Testing, dp *e2eutils.DeployParams, sd *e2eutils.SetupData, log log.Logger) (*e2eutils.SetupData, *helpers.L1Miner, *helpers.L2Sequencer, *helpers.L2Verifier, *helpers.L2Engine, *helpers.L2Batcher) { + dir := t.TempDir() + db, err := safedb.NewSafeDB(log, dir) + require.NoError(t, err) + t.Cleanup(func() { + _ = db.Close() + }) + miner, seqEngine, sequencer := helpers.SetupSequencerTest(t, sd, log) + miner.ActL1SetFeeRecipient(common.Address{'A'}) + sequencer.ActL2PipelineFull(t) + verifEngine, verifier := helpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}, helpers.WithSafeHeadListener(db)) + rollupSeqCl := sequencer.RollupClient() + batcher := helpers.NewL2Batcher(log, sd.RollupCfg, helpers.DefaultBatcherCfg(dp), + rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) + return sd, miner, sequencer, verifier, verifEngine, batcher +} diff --git a/op-e2e/actions/safedb_test.go b/op-e2e/actions/safedb/safedb_test.go similarity index 68% rename from op-e2e/actions/safedb_test.go rename to op-e2e/actions/safedb/safedb_test.go index d7baeeb3715c..369825e46263 100644 --- a/op-e2e/actions/safedb_test.go +++ b/op-e2e/actions/safedb/safedb_test.go @@ -1,23 +1,20 @@ -package actions +package safedb import ( "context" "testing" - "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" - "github.com/ethereum-optimism/optimism/op-node/node/safedb" - "github.com/ethereum-optimism/optimism/op-node/rollup/sync" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + "github.com/ethereum-optimism/optimism/op-e2e/actions/safedb/helpers" "github.com/ethereum-optimism/optimism/op-service/eth" - "github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/log" "github.com/stretchr/testify/require" ) func TestRecordSafeHeadUpdates(gt *testing.T) { - t := NewDefaultTesting(gt) - sd, miner, sequencer, verifier, verifierEng, batcher := setupSafeDBTest(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + sd, miner, sequencer, verifier, verifierEng, batcher := helpers.SetupSafeDBTest(t, actionsHelpers.DefaultRollupTestParams) verifEngClient := verifierEng.EngineClient(t, sd.RollupCfg) sequencer.ActL2PipelineFull(t) @@ -36,7 +33,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { // new L1 block with L2 batch miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) - batchTx := miner.l1Transactions[0] + batchTx := miner.L1Transactions[0] miner.ActL1EndBlock(t) // verifier picks up the L2 chain that was submitted @@ -46,7 +43,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { require.NotEqual(t, sequencer.L2Safe(), sequencer.L2Unsafe(), "sequencer has not processed L1 yet") // Verify the safe head is recorded - l1Head := miner.l1Chain.CurrentBlock() + l1Head := miner.L1Chain().CurrentBlock() firstSafeHeadUpdateL1Block := l1Head.Number.Uint64() response, err := verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block) require.NoError(t, err) @@ -62,7 +59,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { // Only genesis is safe at this point response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block-1) require.NoError(t, err) - require.Equal(t, eth.HeaderBlockID(miner.l1Chain.Genesis().Header()), response.L1Block) + require.Equal(t, eth.HeaderBlockID(miner.L1Chain().Genesis().Header()), response.L1Block) require.Equal(t, sd.RollupCfg.Genesis.L2, response.SafeHead) // orphan the L1 block that included the batch tx, and build a new different L1 block @@ -83,7 +80,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { // The safe head has been reorged so the record should have been deleted, leaving us back with just genesis safe response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block) require.NoError(t, err) - require.Equal(t, eth.HeaderBlockID(miner.l1Chain.Genesis().Header()), response.L1Block) + require.Equal(t, eth.HeaderBlockID(miner.L1Chain().Genesis().Header()), response.L1Block) require.Equal(t, sd.RollupCfg.Genesis.L2, response.SafeHead) // Now replay the batch tx in a new L1 block @@ -91,7 +88,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { miner.ActL1SetFeeRecipient(common.Address{'C'}) // note: the geth tx pool reorgLoop is too slow (responds to chain head events, but async), // and there's no way to manually trigger runReorg, so we re-insert it ourselves. - require.NoError(t, miner.eth.TxPool().Add([]*types.Transaction{batchTx}, true, true)[0]) + require.NoError(t, miner.Eth.TxPool().Add([]*types.Transaction{batchTx}, true, true)[0]) // need to re-insert previously included tx into the block miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1EndBlock(t) @@ -105,36 +102,10 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { require.Equal(t, verifier.L2Safe(), ref, "verifier engine matches rollup client") // Verify the safe head is recorded again - l1Head = miner.l1Chain.CurrentBlock() + l1Head = miner.L1Chain().CurrentBlock() firstSafeHeadUpdateL1Block = l1Head.Number.Uint64() response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block) require.NoError(t, err) require.Equal(t, eth.HeaderBlockID(l1Head), response.L1Block) require.Equal(t, verifier.L2Unsafe().ID(), response.SafeHead) } - -func setupSafeDBTest(t Testing, config *e2eutils.TestParams) (*e2eutils.SetupData, *L1Miner, *L2Sequencer, *L2Verifier, *L2Engine, *L2Batcher) { - dp := e2eutils.MakeDeployParams(t, config) - - sd := e2eutils.Setup(t, dp, DefaultAlloc) - logger := testlog.Logger(t, log.LevelDebug) - - return setupSafeDBTestActors(t, dp, sd, logger) -} - -func setupSafeDBTestActors(t Testing, dp *e2eutils.DeployParams, sd *e2eutils.SetupData, log log.Logger) (*e2eutils.SetupData, *L1Miner, *L2Sequencer, *L2Verifier, *L2Engine, *L2Batcher) { - dir := t.TempDir() - db, err := safedb.NewSafeDB(log, dir) - require.NoError(t, err) - t.Cleanup(func() { - _ = db.Close() - }) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - miner.ActL1SetFeeRecipient(common.Address{'A'}) - sequencer.ActL2PipelineFull(t) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}, WithSafeHeadListener(db)) - rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), - rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) - return sd, miner, sequencer, verifier, verifEngine, batcher -} diff --git a/op-e2e/actions/l2_sequencer_test.go b/op-e2e/actions/sequencer/l2_sequencer_test.go similarity index 79% rename from op-e2e/actions/l2_sequencer_test.go rename to op-e2e/actions/sequencer/l2_sequencer_test.go index 8872da6481d1..5192c25d7afd 100644 --- a/op-e2e/actions/l2_sequencer_test.go +++ b/op-e2e/actions/sequencer/l2_sequencer_test.go @@ -1,9 +1,10 @@ -package actions +package sequencer import ( "math/big" "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" @@ -11,33 +12,12 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/stretchr/testify/require" - altda "github.com/ethereum-optimism/optimism/op-alt-da" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" - "github.com/ethereum-optimism/optimism/op-service/sources" "github.com/ethereum-optimism/optimism/op-service/testlog" ) -func setupSequencerTest(t Testing, sd *e2eutils.SetupData, log log.Logger, opts ...SequencerOpt) (*L1Miner, *L2Engine, *L2Sequencer) { - jwtPath := e2eutils.WriteDefaultJWT(t) - cfg := DefaultSequencerConfig() - for _, opt := range opts { - opt(cfg) - } - - miner := NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg) - - l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) - require.NoError(t, err) - engine := NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, EngineWithP2P()) - l2Cl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) - require.NoError(t, err) - - sequencer := NewL2Sequencer(t, log.New("role", "sequencer"), l1F, miner.BlobStore(), altda.Disabled, l2Cl, sd.RollupCfg, 0, cfg.InteropBackend) - return miner, engine, sequencer -} - func TestL2Sequencer_SequencerDrift(gt *testing.T) { - t := NewDefaultTesting(gt) + t := helpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -45,9 +25,9 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { L1BlockTime: 12, } dp := e2eutils.MakeDeployParams(t, p) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, engine, sequencer := setupSequencerTest(t, sd, log) + miner, engine, sequencer := helpers.SetupSequencerTest(t, sd, log) miner.ActL1SetFeeRecipient(common.Address{'A'}) sequencer.ActL2PipelineFull(t) @@ -61,7 +41,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -79,7 +59,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { miner.ActL1StartBlock(12)(t) miner.ActL1EndBlock(t) sequencer.ActL1HeadSignal(t) - origin := miner.l1Chain.CurrentBlock() + origin := miner.L1Chain().CurrentBlock() // L2 makes blocks to catch up for sequencer.SyncStatus().UnsafeL2.Time+sd.RollupCfg.BlockTime < origin.Time { @@ -104,18 +84,18 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { // We passed the sequencer drift: we can still keep the old origin, but can't include any txs sequencer.ActL2KeepL1Origin(t) sequencer.ActL2StartBlock(t) - require.True(t, engine.engineApi.ForcedEmpty(), "engine should not be allowed to include anything after sequencer drift is surpassed") + require.True(t, engine.EngineApi.ForcedEmpty(), "engine should not be allowed to include anything after sequencer drift is surpassed") } // TestL2Sequencer_SequencerOnlyReorg regression-tests a Goerli halt where the sequencer // would build an unsafe L2 block with a L1 origin that then gets reorged out, // while the verifier-codepath only ever sees the valid post-reorg L1 chain. func TestL2Sequencer_SequencerOnlyReorg(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - miner, _, sequencer := setupSequencerTest(t, sd, log) + miner, _, sequencer := helpers.SetupSequencerTest(t, sd, log) // Sequencer at first only recognizes the genesis as safe. // The rest of the L1 chain will be incorporated as L1 origins into unsafe L2 blocks. diff --git a/op-e2e/actions/sync_test.go b/op-e2e/actions/sync/sync_test.go similarity index 82% rename from op-e2e/actions/sync_test.go rename to op-e2e/actions/sync/sync_test.go index d2b34b1f06fa..cd6bf4b29b9d 100644 --- a/op-e2e/actions/sync_test.go +++ b/op-e2e/actions/sync/sync_test.go @@ -1,4 +1,4 @@ -package actions +package sync import ( "errors" @@ -8,6 +8,8 @@ import ( "testing" "time" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum" @@ -32,7 +34,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/testutils" ) -func newSpanChannelOut(t StatefulTesting, e e2eutils.SetupData) derive.ChannelOut { +func newSpanChannelOut(t actionsHelpers.StatefulTesting, e e2eutils.SetupData) derive.ChannelOut { channelOut, err := derive.NewSpanChannelOut(e.RollupCfg.Genesis.L2Time, e.RollupCfg.L2ChainID, 128_000, derive.Zlib, rollup.NewChainSpec(e.RollupCfg)) require.NoError(t, err) return channelOut @@ -64,12 +66,12 @@ func TestSyncBatchType(t *testing.T) { } func DerivationWithFlakyL1RPC(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) // mute all the temporary derivation errors that we forcefully create - _, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, _, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) rng := rand.New(rand.NewSource(1234)) sequencer.ActL2PipelineFull(t) @@ -83,7 +85,7 @@ func DerivationWithFlakyL1RPC(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { sequencer.ActBuildToL1Head(t) batcher.ActSubmitAll(t) miner.ActL1StartBlock(12)(t) - miner.ActL1IncludeTx(batcher.batcherAddr)(t) + miner.ActL1IncludeTx(batcher.BatcherAddr)(t) miner.ActL1EndBlock(t) } // Make verifier aware of head @@ -104,12 +106,12 @@ func DerivationWithFlakyL1RPC(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { } func FinalizeWhileSyncing(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - applyDeltaTimeOffset(dp, deltaTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) // mute all the temporary derivation errors that we forcefully create - _, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, _, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) sequencer.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t) @@ -126,10 +128,10 @@ func FinalizeWhileSyncing(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { sequencer.ActBuildToL1Head(t) batcher.ActSubmitAll(t) miner.ActL1StartBlock(12)(t) - miner.ActL1IncludeTx(batcher.batcherAddr)(t) + miner.ActL1IncludeTx(batcher.BatcherAddr)(t) miner.ActL1EndBlock(t) } - l1Head := miner.l1Chain.CurrentHeader() + l1Head := miner.L1Chain().CurrentHeader() // finalize all of L1 miner.ActL1Safe(t, l1Head.Number.Uint64()) miner.ActL1Finalize(t, l1Head.Number.Uint64()) @@ -150,12 +152,12 @@ func FinalizeWhileSyncing(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { // TestUnsafeSync tests that a verifier properly imports unsafe blocks via gossip. func TestUnsafeSync(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - sd, _, _, sequencer, seqEng, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + sd, _, _, sequencer, seqEng, verifier, _, _ := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -178,15 +180,15 @@ func TestUnsafeSync(gt *testing.T) { } func TestBackupUnsafe(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LvlInfo) - _, dp, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, dp, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) l2Cl := seqEng.EthClient() seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -238,7 +240,7 @@ func TestBackupUnsafe(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -256,7 +258,7 @@ func TestBackupUnsafe(gt *testing.T) { } // Submit span batch(A1, B2, invalid B3, B4, B5) - batcher.l2ChannelOut = channelOut + batcher.L2ChannelOut = channelOut batcher.ActL2ChannelClose(t) batcher.ActL2BatchSubmit(t) @@ -339,15 +341,15 @@ func TestBackupUnsafe(gt *testing.T) { } func TestBackupUnsafeReorgForkChoiceInputError(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LvlInfo) - _, dp, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, dp, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) l2Cl := seqEng.EthClient() seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -399,7 +401,7 @@ func TestBackupUnsafeReorgForkChoiceInputError(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -417,7 +419,7 @@ func TestBackupUnsafeReorgForkChoiceInputError(gt *testing.T) { } // Submit span batch(A1, B2, invalid B3, B4, B5) - batcher.l2ChannelOut = channelOut + batcher.L2ChannelOut = channelOut batcher.ActL2ChannelClose(t) batcher.ActL2BatchSubmit(t) @@ -472,15 +474,15 @@ func TestBackupUnsafeReorgForkChoiceInputError(gt *testing.T) { } func TestBackupUnsafeReorgForkChoiceNotInputError(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LvlInfo) - _, dp, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, dp, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) l2Cl := seqEng.EthClient() seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -532,7 +534,7 @@ func TestBackupUnsafeReorgForkChoiceNotInputError(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -550,7 +552,7 @@ func TestBackupUnsafeReorgForkChoiceNotInputError(gt *testing.T) { } // Submit span batch(A1, B2, invalid B3, B4, B5) - batcher.l2ChannelOut = channelOut + batcher.L2ChannelOut = channelOut batcher.ActL2ChannelClose(t) batcher.ActL2BatchSubmit(t) @@ -587,7 +589,7 @@ func TestBackupUnsafeReorgForkChoiceNotInputError(gt *testing.T) { serverErrCnt := 2 // mock forkChoiceUpdate failure while restoring previous unsafe chain using backupUnsafe. - seqEng.failL2RPC = func(call []rpc.BatchElem) error { + seqEng.FailL2RPC = func(call []rpc.BatchElem) error { for _, e := range call { // There may be other calls, like payload-processing-cancellation // based on previous invalid block, and processing of block attributes. @@ -625,7 +627,7 @@ func TestBackupUnsafeReorgForkChoiceNotInputError(gt *testing.T) { // builds l2 blocks within the specified range `from` - `to` // and performs an EL sync between the sequencer and the verifier, // then checks the validity of the payloads within a specified block range. -func PerformELSyncAndCheckPayloads(t Testing, miner *L1Miner, seqEng *L2Engine, sequencer *L2Sequencer, verEng *L2Engine, verifier *L2Verifier, seqEngCl *sources.EngineClient, from, to uint64) { +func PerformELSyncAndCheckPayloads(t actionsHelpers.Testing, miner *actionsHelpers.L1Miner, seqEng *actionsHelpers.L2Engine, sequencer *actionsHelpers.L2Sequencer, verEng *actionsHelpers.L2Engine, verifier *actionsHelpers.L2Verifier, seqEngCl *sources.EngineClient, from, to uint64) { miner.ActEmptyBlock(t) sequencer.ActL2PipelineFull(t) @@ -658,7 +660,7 @@ func PerformELSyncAndCheckPayloads(t Testing, miner *L1Miner, seqEng *L2Engine, // Verify this by checking that the verifier has the correct value for block 1 require.Eventually(t, func() bool { - block, err := verifier.eng.L2BlockRefByNumber(t.Ctx(), from) + block, err := verifier.Eng.L2BlockRefByNumber(t.Ctx(), from) if err != nil { return false } @@ -670,14 +672,14 @@ func PerformELSyncAndCheckPayloads(t Testing, miner *L1Miner, seqEng *L2Engine, } // verifies that a specific block number on the L2 engine has the expected label. -func VerifyBlock(t Testing, engine L2API, number uint64, label eth.BlockLabel) { +func VerifyBlock(t actionsHelpers.Testing, engine actionsHelpers.L2API, number uint64, label eth.BlockLabel) { id, err := engine.L2BlockRefByLabel(t.Ctx(), label) require.NoError(t, err) require.Equal(t, number, id.Number) } // submits batch at a specified block number -func BatchSubmitBlock(t Testing, miner *L1Miner, sequencer *L2Sequencer, verifier *L2Verifier, batcher *L2Batcher, dp *e2eutils.DeployParams, number uint64) { +func BatchSubmitBlock(t actionsHelpers.Testing, miner *actionsHelpers.L1Miner, sequencer *actionsHelpers.L2Sequencer, verifier *actionsHelpers.L2Verifier, batcher *actionsHelpers.L2Batcher, dp *e2eutils.DeployParams, number uint64) { sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) batcher.ActSubmitAll(t) @@ -691,14 +693,14 @@ func BatchSubmitBlock(t Testing, miner *L1Miner, sequencer *L2Sequencer, verifie // TestELSync tests that a verifier will have the EL import the full chain from the sequencer // when passed a single unsafe block. op-geth can either snap sync or full sync here. func TestELSync(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - miner, seqEng, sequencer := setupSequencerTest(t, sd, log) + miner, seqEng, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) // Enable engine P2P sync - verEng, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) + verEng, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -706,11 +708,11 @@ func TestELSync(gt *testing.T) { PerformELSyncAndCheckPayloads(t, miner, seqEng, sequencer, verEng, verifier, seqEngCl, 0, 10) } -func PrepareELSyncedNode(t Testing, miner *L1Miner, sequencer *L2Sequencer, seqEng *L2Engine, verifier *L2Verifier, verEng *L2Engine, seqEngCl *sources.EngineClient, batcher *L2Batcher, dp *e2eutils.DeployParams) { +func PrepareELSyncedNode(t actionsHelpers.Testing, miner *actionsHelpers.L1Miner, sequencer *actionsHelpers.L2Sequencer, seqEng *actionsHelpers.L2Engine, verifier *actionsHelpers.L2Verifier, verEng *actionsHelpers.L2Engine, seqEngCl *sources.EngineClient, batcher *actionsHelpers.L2Batcher, dp *e2eutils.DeployParams) { PerformELSyncAndCheckPayloads(t, miner, seqEng, sequencer, verEng, verifier, seqEngCl, 0, 10) // Despite downloading the blocks, it has not finished finalizing - _, err := verifier.eng.L2BlockRefByLabel(t.Ctx(), "safe") + _, err := verifier.Eng.L2BlockRefByLabel(t.Ctx(), "safe") require.ErrorIs(t, err, ethereum.NotFound) // Insert a block on the verifier to end snap sync @@ -721,15 +723,15 @@ func PrepareELSyncedNode(t Testing, miner *L1Miner, sequencer *L2Sequencer, seqE verifier.ActL2InsertUnsafePayload(seqHead)(t) // Check that safe + finalized are there - VerifyBlock(t, verifier.eng, 11, eth.Safe) - VerifyBlock(t, verifier.eng, 11, eth.Finalized) + VerifyBlock(t, verifier.Eng, 11, eth.Safe) + VerifyBlock(t, verifier.Eng, 11, eth.Finalized) // Batch submit everything BatchSubmitBlock(t, miner, sequencer, verifier, batcher, dp, 12) // Verify that the batch submitted blocks are there now - VerifyBlock(t, sequencer.eng, 12, eth.Safe) - VerifyBlock(t, verifier.eng, 12, eth.Safe) + VerifyBlock(t, sequencer.Eng, 12, eth.Safe) + VerifyBlock(t, verifier.Eng, 12, eth.Safe) } // TestELSyncTransitionstoCL tests that a verifier which starts with EL sync can switch back to a proper CL sync. @@ -744,17 +746,17 @@ func PrepareELSyncedNode(t Testing, miner *L1Miner, sequencer *L2Sequencer, seqE // Prior to this PR, the test would fail at this point. // 8. Create 1 more block & batch submit everything & assert that the verifier picked up those blocks func TestELSyncTransitionstoCL(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) logger := testlog.Logger(t, log.LevelInfo) captureLog, captureLogHandler := testlog.CaptureLogger(t, log.LevelInfo) - miner, seqEng, sequencer := setupSequencerTest(t, sd, logger) - batcher := NewL2Batcher(logger, sd.RollupCfg, DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) + miner, seqEng, sequencer := actionsHelpers.SetupSequencerTest(t, sd, logger) + batcher := actionsHelpers.NewL2Batcher(logger, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) // Enable engine P2P sync - verEng, verifier := setupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) + verEng, verifier := actionsHelpers.SetupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), logger, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -790,28 +792,28 @@ func TestELSyncTransitionstoCL(gt *testing.T) { // This was failing prior to PR 9661 because op-node would attempt to immediately insert blocks into the EL inside the engine queue. op-geth // would not be able to fetch the second range of blocks & it would wipe out the unsafe payloads queue because op-node thought that it had a // higher unsafe block but op-geth did not. - VerifyBlock(t, verifier.eng, 22, eth.Unsafe) + VerifyBlock(t, verifier.Eng, 22, eth.Unsafe) // Create 1 more block & batch submit everything BatchSubmitBlock(t, miner, sequencer, verifier, batcher, dp, 12) // Verify that the batch submitted blocks are there now - VerifyBlock(t, sequencer.eng, 23, eth.Safe) - VerifyBlock(t, verifier.eng, 23, eth.Safe) + VerifyBlock(t, sequencer.Eng, 23, eth.Safe) + VerifyBlock(t, verifier.Eng, 23, eth.Safe) } func TestELSyncTransitionsToCLSyncAfterNodeRestart(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) logger := testlog.Logger(t, log.LevelInfo) captureLog, captureLogHandler := testlog.CaptureLogger(t, log.LevelInfo) - miner, seqEng, sequencer := setupSequencerTest(t, sd, logger) - batcher := NewL2Batcher(logger, sd.RollupCfg, DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) + miner, seqEng, sequencer := actionsHelpers.SetupSequencerTest(t, sd, logger) + batcher := actionsHelpers.NewL2Batcher(logger, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) // Enable engine P2P sync - verEng, verifier := setupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) + verEng, verifier := actionsHelpers.SetupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), logger, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -819,7 +821,7 @@ func TestELSyncTransitionsToCLSyncAfterNodeRestart(gt *testing.T) { PrepareELSyncedNode(t, miner, sequencer, seqEng, verifier, verEng, seqEngCl, batcher, dp) // Create a new verifier which is essentially a new op-node with the sync mode of ELSync and default geth engine kind. - verifier = NewL2Verifier(t, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled, verifier.eng, sd.RollupCfg, &sync.Config{SyncMode: sync.ELSync}, DefaultVerifierCfg().SafeHeadListener, nil) + verifier = actionsHelpers.NewL2Verifier(t, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled, verifier.Eng, sd.RollupCfg, &sync.Config{SyncMode: sync.ELSync}, actionsHelpers.DefaultVerifierCfg().SafeHeadListener, nil) // Build another 10 L1 blocks on the sequencer for i := 0; i < 10; i++ { @@ -843,17 +845,17 @@ func TestELSyncTransitionsToCLSyncAfterNodeRestart(gt *testing.T) { } func TestForcedELSyncCLAfterNodeRestart(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) logger := testlog.Logger(t, log.LevelInfo) captureLog, captureLogHandler := testlog.CaptureLogger(t, log.LevelInfo) - miner, seqEng, sequencer := setupSequencerTest(t, sd, logger) - batcher := NewL2Batcher(logger, sd.RollupCfg, DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) + miner, seqEng, sequencer := actionsHelpers.SetupSequencerTest(t, sd, logger) + batcher := actionsHelpers.NewL2Batcher(logger, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), sequencer.RollupClient(), miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) // Enable engine P2P sync - verEng, verifier := setupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) + verEng, verifier := actionsHelpers.SetupVerifier(t, sd, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), logger, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -861,7 +863,7 @@ func TestForcedELSyncCLAfterNodeRestart(gt *testing.T) { PrepareELSyncedNode(t, miner, sequencer, seqEng, verifier, verEng, seqEngCl, batcher, dp) // Create a new verifier which is essentially a new op-node with the sync mode of ELSync and erigon engine kind. - verifier2 := NewL2Verifier(t, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled, verifier.eng, sd.RollupCfg, &sync.Config{SyncMode: sync.ELSync, SupportsPostFinalizationELSync: true}, DefaultVerifierCfg().SafeHeadListener, nil) + verifier2 := actionsHelpers.NewL2Verifier(t, captureLog, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled, verifier.Eng, sd.RollupCfg, &sync.Config{SyncMode: sync.ELSync, SupportsPostFinalizationELSync: true}, actionsHelpers.DefaultVerifierCfg().SafeHeadListener, nil) // Build another 10 L1 blocks on the sequencer for i := 0; i < 10; i++ { @@ -889,15 +891,15 @@ func TestForcedELSyncCLAfterNodeRestart(gt *testing.T) { } func TestInvalidPayloadInSpanBatch(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - _, _, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) l2Cl := seqEng.EthClient() rng := rand.New(rand.NewSource(1234)) signer := types.LatestSigner(sd.L2Cfg.Config) @@ -927,7 +929,7 @@ func TestInvalidPayloadInSpanBatch(gt *testing.T) { } // Submit span batch(A1, ..., A7, invalid A8, A9, ..., A12) - batcher.l2ChannelOut = channelOut + batcher.L2ChannelOut = channelOut batcher.ActL2ChannelClose(t) batcher.ActL2BatchSubmit(t) @@ -956,7 +958,7 @@ func TestInvalidPayloadInSpanBatch(gt *testing.T) { data := make([]byte, rand.Intn(100)) gas, err := core.IntrinsicGas(data, nil, false, true, true, false) require.NoError(t, err) - baseFee := seqEng.l2Chain.CurrentBlock().BaseFee + baseFee := seqEng.L2Chain().CurrentBlock().BaseFee tx := types.MustSignNewTx(dp.Secrets.Alice, signer, &types.DynamicFeeTx{ ChainID: sd.L2Cfg.Config.ChainID, Nonce: aliceNonce, @@ -975,7 +977,7 @@ func TestInvalidPayloadInSpanBatch(gt *testing.T) { require.NoError(t, err) } // Submit span batch(B1, A2, ... A12) - batcher.l2ChannelOut = channelOut + batcher.L2ChannelOut = channelOut batcher.ActL2ChannelClose(t) batcher.ActL2BatchSubmit(t) @@ -994,15 +996,15 @@ func TestInvalidPayloadInSpanBatch(gt *testing.T) { } func TestSpanBatchAtomicity_Consolidation(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - _, _, miner, sequencer, seqEng, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, seqEng, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) require.NoError(t, err) @@ -1036,8 +1038,8 @@ func TestSpanBatchAtomicity_Consolidation(gt *testing.T) { // Start verifier safe sync verifier.ActL1HeadSignal(t) - verifier.l2PipelineIdle = false - for !verifier.l2PipelineIdle { + verifier.L2PipelineIdle = false + for !verifier.L2PipelineIdle { // wait for next pending block verifier.ActL2EventsUntil(t, func(ev event.Event) bool { if event.Is[engine2.SafeDerivedEvent](ev) { // safe updates should only happen once the pending-safe reaches the target. @@ -1062,15 +1064,15 @@ func TestSpanBatchAtomicity_Consolidation(gt *testing.T) { } func TestSpanBatchAtomicity_ForceAdvance(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := actionsHelpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) dp.DeployConfig.L2BlockTime = 2 - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelInfo) - _, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, _, verifier, _, batcher := actionsHelpers.SetupReorgTestActors(t, dp, sd, log) targetHeadNumber := uint64(6) // L1 block time / L2 block time @@ -1092,8 +1094,8 @@ func TestSpanBatchAtomicity_ForceAdvance(gt *testing.T) { // Start verifier safe sync verifier.ActL1HeadSignal(t) - verifier.l2PipelineIdle = false - for !verifier.l2PipelineIdle { + verifier.L2PipelineIdle = false + for !verifier.L2PipelineIdle { // wait for next pending block verifier.ActL2EventsUntil(t, func(ev event.Event) bool { if event.Is[engine2.SafeDerivedEvent](ev) { // safe updates should only happen once the pending-safe reaches the target. diff --git a/op-e2e/actions/dencun_fork_test.go b/op-e2e/actions/upgrades/dencun_fork_test.go similarity index 71% rename from op-e2e/actions/dencun_fork_test.go rename to op-e2e/actions/upgrades/dencun_fork_test.go index ac0484c800b0..a9e3eb2cc256 100644 --- a/op-e2e/actions/dencun_fork_test.go +++ b/op-e2e/actions/upgrades/dencun_fork_test.go @@ -1,9 +1,10 @@ -package actions +package upgrades import ( "context" "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" @@ -17,15 +18,15 @@ import ( ) func TestDencunL1ForkAfterGenesis(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) offset := hexutil.Uint64(24) dp.DeployConfig.L1CancunTimeOffset = &offset - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, _, verifier, _, batcher := helpers.SetupReorgTestActors(t, dp, sd, log) - l1Head := miner.l1Chain.CurrentBlock() + l1Head := miner.L1Chain().CurrentBlock() require.False(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun not active yet") require.Nil(t, l1Head.ExcessBlobGas, "Cancun blob gas not in header") @@ -39,7 +40,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { miner.ActEmptyBlock(t) // Cancun activates here miner.ActEmptyBlock(t) // verify Cancun is active - l1Head = miner.l1Chain.CurrentBlock() + l1Head = miner.L1Chain().CurrentBlock() require.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") @@ -48,7 +49,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { sequencer.ActBuildToL1Head(t) miner.ActL1StartBlock(12)(t) batcher.ActSubmitAll(t) - miner.ActL1IncludeTx(batcher.batcherAddr)(t) + miner.ActL1IncludeTx(batcher.BatcherAddr)(t) miner.ActL1EndBlock(t) // sync verifier @@ -60,14 +61,14 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { } func TestDencunL1ForkAtGenesis(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) require.Zero(t, *dp.DeployConfig.L1CancunTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log) + _, _, miner, sequencer, _, verifier, _, batcher := helpers.SetupReorgTestActors(t, dp, sd, log) - l1Head := miner.l1Chain.CurrentBlock() + l1Head := miner.L1Chain().CurrentBlock() require.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active at genesis") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") @@ -81,7 +82,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) { miner.ActEmptyBlock(t) // verify Cancun is still active - l1Head = miner.l1Chain.CurrentBlock() + l1Head = miner.L1Chain().CurrentBlock() require.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") @@ -90,7 +91,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) { sequencer.ActBuildToL1Head(t) miner.ActL1StartBlock(12)(t) batcher.ActSubmitAll(t) - miner.ActL1IncludeTx(batcher.batcherAddr)(t) + miner.ActL1IncludeTx(batcher.BatcherAddr)(t) miner.ActL1EndBlock(t) // sync verifier @@ -117,8 +118,8 @@ func verifyEcotoneBlock(gt *testing.T, header *types.Header) { } func TestDencunL2ForkAfterGenesis(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) require.Zero(t, *dp.DeployConfig.L1CancunTimeOffset) // This test wil fork on the second block offset := hexutil.Uint64(dp.DeployConfig.L2BlockTime * 2) @@ -127,56 +128,56 @@ func TestDencunL2ForkAfterGenesis(gt *testing.T) { dp.DeployConfig.L2GenesisGraniteTimeOffset = nil // New forks have to be added here, after changing the default deploy config! - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, _, _, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + _, _, _, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log) // start op-nodes sequencer.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t) // Genesis block is pre-ecotone - verifyPreEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyPreEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) // Block before fork block sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) - verifyPreEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyPreEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) // Fork block is ecotone sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) // Blocks post fork have Ecotone properties sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) } func TestDencunL2ForkAtGenesis(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) require.Zero(t, *dp.DeployConfig.L2GenesisEcotoneTimeOffset) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, _, _, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + _, _, _, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log) // start op-nodes sequencer.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t) // Genesis block has ecotone properties - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) // Blocks post fork have Ecotone properties sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) } -func aliceSimpleBlobTx(t Testing, dp *e2eutils.DeployParams) *types.Transaction { +func aliceSimpleBlobTx(t helpers.Testing, dp *e2eutils.DeployParams) *types.Transaction { txData := transactions.CreateEmptyBlobTx(true, dp.DeployConfig.L2ChainID) // Manual signer creation, so we can sign a blob tx on the chain, // even though we have disabled cancun signer support in Ecotone. @@ -186,17 +187,17 @@ func aliceSimpleBlobTx(t Testing, dp *e2eutils.DeployParams) *types.Transaction return tx } -func newEngine(t Testing, sd *e2eutils.SetupData, log log.Logger) *L2Engine { +func newEngine(t helpers.Testing, sd *e2eutils.SetupData, log log.Logger) *helpers.L2Engine { jwtPath := e2eutils.WriteDefaultJWT(t) - return NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) + return helpers.NewL2Engine(t, log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) } // TestDencunBlobTxRPC tries to send a Blob tx to the L2 engine via RPC, it should not be accepted. func TestDencunBlobTxRPC(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) engine := newEngine(t, sd, log) cl := engine.EthClient() @@ -207,31 +208,31 @@ func TestDencunBlobTxRPC(gt *testing.T) { // TestDencunBlobTxInTxPool tries to insert a blob tx directly into the tx pool, it should not be accepted. func TestDencunBlobTxInTxPool(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) engine := newEngine(t, sd, log) tx := aliceSimpleBlobTx(t, dp) - errs := engine.eth.TxPool().Add([]*types.Transaction{tx}, true, true) + errs := engine.Eth.TxPool().Add([]*types.Transaction{tx}, true, true) require.ErrorContains(t, errs[0], "transaction type not supported") } // TestDencunBlobTxInclusion tries to send a Blob tx to the L2 engine, it should not be accepted. func TestDencunBlobTxInclusion(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, engine, sequencer := setupSequencerTest(t, sd, log) + _, engine, sequencer := helpers.SetupSequencerTest(t, sd, log) sequencer.ActL2PipelineFull(t) tx := aliceSimpleBlobTx(t, dp) sequencer.ActL2StartBlock(t) - err := engine.engineApi.IncludeTx(tx, dp.Addresses.Alice) + err := engine.EngineApi.IncludeTx(tx, dp.Addresses.Alice) require.ErrorContains(t, err, "invalid L2 block (tx 1): failed to apply transaction to L2 block (tx 1): transaction type not supported") } diff --git a/op-e2e/actions/ecotone_fork_test.go b/op-e2e/actions/upgrades/ecotone_fork_test.go similarity index 93% rename from op-e2e/actions/ecotone_fork_test.go rename to op-e2e/actions/upgrades/ecotone_fork_test.go index 3237915d6e00..c4135266e162 100644 --- a/op-e2e/actions/ecotone_fork_test.go +++ b/op-e2e/actions/upgrades/ecotone_fork_test.go @@ -1,10 +1,11 @@ -package actions +package upgrades import ( "context" "math/big" "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" @@ -30,7 +31,7 @@ var ( // verifyCodeHashMatches checks that the has of the code at the given address matches the expected code-hash. // It also sanity-checks that the code is not empty: we should never deploy empty contract codes. // Returns the contract code -func verifyCodeHashMatches(t Testing, client *ethclient.Client, address common.Address, expectedCodeHash common.Hash) []byte { +func verifyCodeHashMatches(t helpers.Testing, client *ethclient.Client, address common.Address, expectedCodeHash common.Hash) []byte { code, err := client.CodeAt(context.Background(), address, nil) require.NoError(t, err) require.NotEmpty(t, code) @@ -40,8 +41,8 @@ func verifyCodeHashMatches(t Testing, client *ethclient.Client, address common.A } func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) ecotoneOffset := hexutil.Uint64(4) log := testlog.Logger(t, log.LevelDebug) @@ -54,8 +55,8 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) { // New forks have to be added here... require.NoError(t, dp.DeployConfig.Check(log), "must have valid config") - sd := e2eutils.Setup(t, dp, DefaultAlloc) - _, _, miner, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) + _, _, miner, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log) ethCl := engine.EthClient() // build a single block to move away from the genesis with 0-values in L1Block contract @@ -238,8 +239,8 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) { // TestEcotoneBeforeL1 tests that the L2 Ecotone fork can activate before L1 Dencun does func TestEcotoneBeforeL1(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) offset := hexutil.Uint64(0) farOffset := hexutil.Uint64(10000) dp.DeployConfig.L2GenesisRegolithTimeOffset = &offset @@ -248,19 +249,19 @@ func TestEcotoneBeforeL1(gt *testing.T) { dp.DeployConfig.L2GenesisDeltaTimeOffset = &offset dp.DeployConfig.L2GenesisEcotoneTimeOffset = &offset - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) log := testlog.Logger(t, log.LevelDebug) - _, _, _, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + _, _, _, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log) // start op-nodes sequencer.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t) // Genesis block has ecotone properties - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) // Blocks post fork have Ecotone properties sequencer.ActL2StartBlock(t) sequencer.ActL2EndBlock(t) - verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) + verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock()) } diff --git a/op-e2e/actions/fjord_fork_test.go b/op-e2e/actions/upgrades/fjord_fork_test.go similarity index 94% rename from op-e2e/actions/fjord_fork_test.go rename to op-e2e/actions/upgrades/fjord_fork_test.go index d003c69af394..9444fcfcb7ae 100644 --- a/op-e2e/actions/fjord_fork_test.go +++ b/op-e2e/actions/upgrades/fjord_fork_test.go @@ -1,4 +1,4 @@ -package actions +package upgrades import ( "context" @@ -6,6 +6,7 @@ import ( "math/big" "testing" + "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" "github.com/ethereum-optimism/optimism/op-service/predeploys" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -29,8 +30,8 @@ var ( ) func TestFjordNetworkUpgradeTransactions(gt *testing.T) { - t := NewDefaultTesting(gt) - dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) + t := helpers.NewDefaultTesting(gt) + dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams) genesisBlock := hexutil.Uint64(0) fjordOffset := hexutil.Uint64(2) @@ -46,8 +47,8 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) { dp.DeployConfig.L2GenesisFjordTimeOffset = &fjordOffset require.NoError(t, dp.DeployConfig.Check(log), "must have valid config") - sd := e2eutils.Setup(t, dp, DefaultAlloc) - _, _, _, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) + sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc) + _, _, _, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log) ethCl := engine.EthClient() // start op-nodes diff --git a/op-e2e/actions/upgrades/helpers/config.go b/op-e2e/actions/upgrades/helpers/config.go new file mode 100644 index 000000000000..a936d86250a0 --- /dev/null +++ b/op-e2e/actions/upgrades/helpers/config.go @@ -0,0 +1,27 @@ +package helpers + +import ( + "github.com/ethereum-optimism/optimism/op-e2e/e2eutils" + "github.com/ethereum/go-ethereum/common/hexutil" +) + +// ApplyDeltaTimeOffset adjusts fork configuration to not conflict with the delta overrides +func ApplyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Uint64) { + dp.DeployConfig.L2GenesisDeltaTimeOffset = deltaTimeOffset + // configure Ecotone to not be before Delta accidentally + if dp.DeployConfig.L2GenesisEcotoneTimeOffset != nil { + if deltaTimeOffset == nil { + dp.DeployConfig.L2GenesisEcotoneTimeOffset = nil + } else if *dp.DeployConfig.L2GenesisEcotoneTimeOffset < *deltaTimeOffset { + dp.DeployConfig.L2GenesisEcotoneTimeOffset = deltaTimeOffset + } + } + // configure Fjord to not be before Delta accidentally + if dp.DeployConfig.L2GenesisFjordTimeOffset != nil { + if deltaTimeOffset == nil { + dp.DeployConfig.L2GenesisFjordTimeOffset = nil + } else if *dp.DeployConfig.L2GenesisFjordTimeOffset < *deltaTimeOffset { + dp.DeployConfig.L2GenesisFjordTimeOffset = deltaTimeOffset + } + } +} diff --git a/op-e2e/actions/span_batch_test.go b/op-e2e/actions/upgrades/span_batch_test.go similarity index 82% rename from op-e2e/actions/span_batch_test.go rename to op-e2e/actions/upgrades/span_batch_test.go index 7eb551c521c7..fc1707b158a0 100644 --- a/op-e2e/actions/span_batch_test.go +++ b/op-e2e/actions/upgrades/span_batch_test.go @@ -1,4 +1,4 @@ -package actions +package upgrades import ( "context" @@ -10,6 +10,8 @@ import ( "math/rand" "testing" + actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" + upgradesHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/upgrades/helpers" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum" @@ -31,7 +33,7 @@ import ( // TestDropSpanBatchBeforeHardfork tests behavior of op-node before Delta hardfork. // op-node must drop SpanBatch before Delta hardfork. func TestDropSpanBatchBeforeHardfork(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -40,15 +42,15 @@ func TestDropSpanBatchBeforeHardfork(gt *testing.T) { } dp := e2eutils.MakeDeployParams(t, p) // do not activate Delta hardfork for verifier - applyDeltaTimeOffset(dp, nil) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, nil) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + verifEngine, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() // Force batcher to submit SpanBatches to L1. - batcher := NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -65,7 +67,7 @@ func TestDropSpanBatchBeforeHardfork(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -89,8 +91,8 @@ func TestDropSpanBatchBeforeHardfork(gt *testing.T) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - bl := miner.l1Chain.CurrentBlock() - log.Info("bl", "txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) + bl := miner.L1Chain().CurrentBlock() + log.Info("bl", "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions())) // Now make enough L1 blocks that the verifier will have to derive a L2 block // It will also eagerly derive the block from the batcher @@ -120,7 +122,7 @@ func TestDropSpanBatchBeforeHardfork(gt *testing.T) { // TestHardforkMiddleOfSpanBatch tests behavior of op-node Delta hardfork. // If Delta activation time is in the middle of time range of a SpanBatch, op-node must drop the batch. func TestHardforkMiddleOfSpanBatch(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -131,21 +133,21 @@ func TestHardforkMiddleOfSpanBatch(gt *testing.T) { // Activate HF in the middle of the first epoch deltaOffset := hexutil.Uint64(6) - applyDeltaTimeOffset(dp, &deltaOffset) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &deltaOffset) // Applies to HF that goes into Delta. Otherwise we end up with more upgrade txs and things during this case. dp.DeployConfig.L2GenesisEcotoneTimeOffset = nil dp.DeployConfig.L2GenesisFjordTimeOffset = nil dp.DeployConfig.L2GenesisGraniteTimeOffset = nil - sd := e2eutils.Setup(t, dp, DefaultAlloc) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + verifEngine, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) minerCl := miner.EthClient() rollupSeqCl := sequencer.RollupClient() // Force batcher to submit SpanBatches to L1. - batcher := NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -162,7 +164,7 @@ func TestHardforkMiddleOfSpanBatch(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -202,8 +204,8 @@ func TestHardforkMiddleOfSpanBatch(gt *testing.T) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - bl := miner.l1Chain.CurrentBlock() - log.Info("bl", "txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) + bl := miner.L1Chain().CurrentBlock() + log.Info("bl", "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions())) // Now make enough L1 blocks that the verifier will have to derive a L2 block // It will also eagerly derive the block from the batcher @@ -233,7 +235,7 @@ func TestHardforkMiddleOfSpanBatch(gt *testing.T) { // TestAcceptSingularBatchAfterHardfork tests behavior of op-node after Delta hardfork. // op-node must accept SingularBatch after Delta hardfork. func TestAcceptSingularBatchAfterHardfork(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -244,15 +246,15 @@ func TestAcceptSingularBatchAfterHardfork(gt *testing.T) { dp := e2eutils.MakeDeployParams(t, p) // activate Delta hardfork for verifier. - applyDeltaTimeOffset(dp, &minTs) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + verifEngine, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() // Force batcher to submit SingularBatches to L1. - batcher := NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -269,7 +271,7 @@ func TestAcceptSingularBatchAfterHardfork(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -293,8 +295,8 @@ func TestAcceptSingularBatchAfterHardfork(gt *testing.T) { miner.ActL1StartBlock(12)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1EndBlock(t) - bl := miner.l1Chain.CurrentBlock() - log.Info("bl", "txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) + bl := miner.L1Chain().CurrentBlock() + log.Info("bl", "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions())) // Now make enough L1 blocks that the verifier will have to derive a L2 block // It will also eagerly derive the block from the batcher @@ -319,7 +321,7 @@ func TestAcceptSingularBatchAfterHardfork(gt *testing.T) { // TestMixOfBatchesAfterHardfork tests behavior of op-node after Delta hardfork. // op-node must accept SingularBatch and SpanBatch in sequence. func TestMixOfBatchesAfterHardfork(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) SequencerWindowSize: 24, @@ -330,11 +332,11 @@ func TestMixOfBatchesAfterHardfork(gt *testing.T) { dp := e2eutils.MakeDeployParams(t, p) // Activate Delta hardfork for verifier. - applyDeltaTimeOffset(dp, &minTs) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - verifEngine, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + verifEngine, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() seqEngCl := seqEngine.EthClient() @@ -352,7 +354,7 @@ func TestMixOfBatchesAfterHardfork(gt *testing.T) { ChainID: sd.L2Cfg.Config.ChainID, Nonce: n, GasTipCap: big.NewInt(2 * params.GWei), - GasFeeCap: new(big.Int).Add(miner.l1Chain.CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), + GasFeeCap: new(big.Int).Add(miner.L1Chain().CurrentBlock().BaseFee, big.NewInt(2*params.GWei)), Gas: params.TxGas, To: &dp.Addresses.Bob, Value: e2eutils.Ether(2), @@ -368,7 +370,7 @@ func TestMixOfBatchesAfterHardfork(gt *testing.T) { sequencer.ActBuildToL1Head(t) // Select batcher mode - batcherCfg := BatcherCfg{ + batcherCfg := actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -376,7 +378,7 @@ func TestMixOfBatchesAfterHardfork(gt *testing.T) { ForceSubmitSingularBatch: i%2 == 1, // Submit SingularBatch for even numbered batches DataAvailabilityType: batcherFlags.CalldataType, } - batcher := NewL2Batcher(log, sd.RollupCfg, &batcherCfg, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, &batcherCfg, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) // Submit all new blocks batcher.ActSubmitAll(t) @@ -410,7 +412,7 @@ func TestMixOfBatchesAfterHardfork(gt *testing.T) { // TestSpanBatchEmptyChain tests derivation of empty chain using SpanBatch. func TestSpanBatchEmptyChain(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, SequencerWindowSize: 24, @@ -420,14 +422,14 @@ func TestSpanBatchEmptyChain(gt *testing.T) { dp := e2eutils.MakeDeployParams(t, p) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) sequencer.ActL2PipelineFull(t) @@ -473,7 +475,7 @@ func TestSpanBatchEmptyChain(gt *testing.T) { // TestSpanBatchLowThroughputChain tests derivation of low-throughput chain using SpanBatch. func TestSpanBatchLowThroughputChain(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) p := &e2eutils.TestParams{ MaxSequencerDrift: 20, SequencerWindowSize: 24, @@ -483,14 +485,14 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) { dp := e2eutils.MakeDeployParams(t, p) minTs := hexutil.Uint64(0) // Activate Delta hardfork - applyDeltaTimeOffset(dp, &minTs) - sd := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) + sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) log := testlog.Logger(t, log.LevelError) - miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) - _, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log) + _, verifier := actionsHelpers.SetupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{}) rollupSeqCl := sequencer.RollupClient() - batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), + batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp), rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) cl := seqEngine.EthClient() @@ -521,7 +523,7 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) { totalTxCount := 0 // Make 600 L2 blocks (L1BlockTime / L2BlockTime * 50) including 1~3 txs for i := 0; i < 50; i++ { - for sequencer.engine.UnsafeL2Head().L1Origin.Number < sequencer.syncStatus.L1Head().Number { + for sequencer.L2Unsafe().L1Origin.Number < sequencer.SyncStatus().HeadL1.Number { sequencer.ActL2StartBlock(t) // fill the block with random number of L2 txs for j := 0; j < rand.Intn(3); j++ { @@ -532,7 +534,7 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) { require.NoError(t, err) gas, err := core.IntrinsicGas(data, nil, false, true, true, false) require.NoError(t, err) - baseFee := seqEngine.l2Chain.CurrentBlock().BaseFee + baseFee := seqEngine.L2Chain().CurrentBlock().BaseFee nonce, err := cl.PendingNonceAt(t.Ctx(), addrs[userIdx]) require.NoError(t, err) tx := types.MustSignNewTx(privKeys[userIdx], signer, &types.DynamicFeeTx{ @@ -585,7 +587,7 @@ func TestSpanBatchLowThroughputChain(gt *testing.T) { } func TestBatchEquivalence(gt *testing.T) { - t := NewDefaultTesting(gt) + t := actionsHelpers.NewDefaultTesting(gt) log := testlog.Logger(t, log.LevelError) p := &e2eutils.TestParams{ @@ -597,8 +599,8 @@ func TestBatchEquivalence(gt *testing.T) { // Delta activated deploy config dp := e2eutils.MakeDeployParams(t, p) minTs := hexutil.Uint64(0) - applyDeltaTimeOffset(dp, &minTs) - sdDeltaActivated := e2eutils.Setup(t, dp, DefaultAlloc) + upgradesHelpers.ApplyDeltaTimeOffset(dp, &minTs) + sdDeltaActivated := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc) // Delta deactivated deploy config rcfg := *sdDeltaActivated.RollupCfg @@ -611,18 +613,18 @@ func TestBatchEquivalence(gt *testing.T) { } // Setup sequencer - miner, seqEngine, sequencer := setupSequencerTest(t, sdDeltaActivated, log) + miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sdDeltaActivated, log) rollupSeqCl := sequencer.RollupClient() seqEngCl := seqEngine.EthClient() // Setup Delta activated spanVerifier - _, spanVerifier := setupVerifier(t, sdDeltaActivated, log, miner.L1Client(t, sdDeltaActivated.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, spanVerifier := actionsHelpers.SetupVerifier(t, sdDeltaActivated, log, miner.L1Client(t, sdDeltaActivated.RollupCfg), miner.BlobStore(), &sync.Config{}) // Setup Delta deactivated spanVerifier - _, singularVerifier := setupVerifier(t, sdDeltaDeactivated, log, miner.L1Client(t, sdDeltaDeactivated.RollupCfg), miner.BlobStore(), &sync.Config{}) + _, singularVerifier := actionsHelpers.SetupVerifier(t, sdDeltaDeactivated, log, miner.L1Client(t, sdDeltaDeactivated.RollupCfg), miner.BlobStore(), &sync.Config{}) // Setup SpanBatcher - spanBatcher := NewL2Batcher(log, sdDeltaActivated.RollupCfg, &BatcherCfg{ + spanBatcher := actionsHelpers.NewL2Batcher(log, sdDeltaActivated.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -631,7 +633,7 @@ func TestBatchEquivalence(gt *testing.T) { }, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sdDeltaActivated.RollupCfg)) // Setup SingularBatcher - singularBatcher := NewL2Batcher(log, sdDeltaDeactivated.RollupCfg, &BatcherCfg{ + singularBatcher := actionsHelpers.NewL2Batcher(log, sdDeltaDeactivated.RollupCfg, &actionsHelpers.BatcherCfg{ MinL1TxSize: 0, MaxL1TxSize: 128_000, BatcherKey: dp.Secrets.Batcher, @@ -660,7 +662,7 @@ func TestBatchEquivalence(gt *testing.T) { sequencer.ActL2PipelineFull(t) totalTxCount := 0 // Build random blocks - for sequencer.engine.UnsafeL2Head().L1Origin.Number < sequencer.syncStatus.L1Head().Number { + for sequencer.L2Unsafe().L1Origin.Number < sequencer.SyncStatus().HeadL1.Number { sequencer.ActL2StartBlock(t) // fill the block with random number of L2 txs for j := 0; j < rand.Intn(3); j++ { @@ -671,7 +673,7 @@ func TestBatchEquivalence(gt *testing.T) { require.NoError(t, err) gas, err := core.IntrinsicGas(data, nil, false, true, true, false) require.NoError(t, err) - baseFee := seqEngine.l2Chain.CurrentBlock().BaseFee + baseFee := seqEngine.L2Chain().CurrentBlock().BaseFee nonce, err := seqEngCl.PendingNonceAt(t.Ctx(), addrs[userIdx]) require.NoError(t, err) tx := types.MustSignNewTx(privKeys[userIdx], signer, &types.DynamicFeeTx{