Commit 994f6347 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-e2e: Separate actions tests into different packages (#11921)

* op-e2e: Move most action tests into a package based on what they test

* op-e2e: Move batch_queue_test.go to derivation package

* op-e2e: Move eip4844_test.go to batcher package

* op-e2e: Move actions helper code to helpers package

* update makefile

* op-e2e: Fix typo

---------
Co-authored-by: default avatarclabby <ben@clab.by>
parent 66bfe678
...@@ -21,7 +21,7 @@ test-ws: pre-test ...@@ -21,7 +21,7 @@ test-ws: pre-test
.PHONY: test-ws .PHONY: test-ws
test-actions: pre-test test-actions: pre-test
$(go_test) $(go_test_flags) ./actions $(go_test) $(go_test_flags) ./actions/...
.PHONY: test-actions .PHONY: test-actions
test-http: pre-test test-http: pre-test
......
package actions package altda
import ( import (
"math/big" "math/big"
"math/rand" "math/rand"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
...@@ -32,21 +33,21 @@ type L2AltDA struct { ...@@ -32,21 +33,21 @@ type L2AltDA struct {
daMgr *altda.DA daMgr *altda.DA
altDACfg altda.Config altDACfg altda.Config
contract *bindings.DataAvailabilityChallenge contract *bindings.DataAvailabilityChallenge
batcher *L2Batcher batcher *helpers.L2Batcher
sequencer *L2Sequencer sequencer *helpers.L2Sequencer
engine *L2Engine engine *helpers.L2Engine
engCl *sources.EngineClient engCl *sources.EngineClient
sd *e2eutils.SetupData sd *e2eutils.SetupData
dp *e2eutils.DeployParams dp *e2eutils.DeployParams
miner *L1Miner miner *helpers.L1Miner
alice *CrossLayerUser alice *helpers.CrossLayerUser
lastComm []byte lastComm []byte
lastCommBn uint64 lastCommBn uint64
} }
type AltDAParam func(p *e2eutils.TestParams) type AltDAParam func(p *e2eutils.TestParams)
func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { func NewL2AltDA(t helpers.Testing, params ...AltDAParam) *L2AltDA {
p := &e2eutils.TestParams{ p := &e2eutils.TestParams{
MaxSequencerDrift: 40, MaxSequencerDrift: 40,
SequencerWindowSize: 12, SequencerWindowSize: 12,
...@@ -60,15 +61,15 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { ...@@ -60,15 +61,15 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA {
log := testlog.Logger(t, log.LvlDebug) log := testlog.Logger(t, log.LvlDebug)
dp := e2eutils.MakeDeployParams(t, p) dp := e2eutils.MakeDeployParams(t, p)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
require.True(t, sd.RollupCfg.AltDAEnabled()) require.True(t, sd.RollupCfg.AltDAEnabled())
miner := NewL1Miner(t, log, sd.L1Cfg) miner := helpers.NewL1Miner(t, log, sd.L1Cfg)
l1Client := miner.EthClient() l1Client := miner.EthClient()
jwtPath := e2eutils.WriteDefaultJWT(t) 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) engCl := engine.EngineClient(t, sd.RollupCfg)
storage := &altda.DAErrFaker{Client: altda.NewMockDAClient(log)} storage := &altda.DAErrFaker{Client: altda.NewMockDAClient(log)}
...@@ -81,21 +82,21 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA { ...@@ -81,21 +82,21 @@ func NewL2AltDA(t Testing, params ...AltDAParam) *L2AltDA {
daMgr := altda.NewAltDAWithStorage(log, altDACfg, storage, &altda.NoopMetrics{}) 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'}) miner.ActL1SetFeeRecipient(common.Address{'A'})
sequencer.ActL2PipelineFull(t) 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) addresses := e2eutils.CollectAddresses(sd, dp)
cl := engine.EthClient() cl := engine.EthClient()
l2UserEnv := &BasicUserEnv[*L2Bindings]{ l2UserEnv := &helpers.BasicUserEnv[*helpers.L2Bindings]{
EthCl: cl, EthCl: cl,
Signer: types.LatestSigner(sd.L2Cfg.Config), Signer: types.LatestSigner(sd.L2Cfg.Config),
AddressCorpora: addresses, 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) alice.L2.SetUserEnv(l2UserEnv)
contract, err := bindings.NewDataAvailabilityChallenge(sd.RollupCfg.AltDAConfig.DAChallengeAddress, l1Client) contract, err := bindings.NewDataAvailabilityChallenge(sd.RollupCfg.AltDAConfig.DAChallengeAddress, l1Client)
...@@ -130,21 +131,21 @@ func (a *L2AltDA) StorageClient() *altda.DAErrFaker { ...@@ -130,21 +131,21 @@ func (a *L2AltDA) StorageClient() *altda.DAErrFaker {
return a.storage return a.storage
} }
func (a *L2AltDA) NewVerifier(t Testing) *L2Verifier { func (a *L2AltDA) NewVerifier(t helpers.Testing) *helpers.L2Verifier {
jwtPath := e2eutils.WriteDefaultJWT(t) 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) 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)) l1F, err := sources.NewL1Client(a.miner.RPCClient(), a.log, nil, sources.L1ClientDefaultConfig(a.sd.RollupCfg, false, sources.RPCKindBasic))
require.NoError(t, err) require.NoError(t, err)
daMgr := altda.NewAltDAWithStorage(a.log, a.altDACfg, a.storage, &altda.NoopMetrics{}) 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 return verifier
} }
func (a *L2AltDA) ActSequencerIncludeTx(t Testing) { func (a *L2AltDA) ActSequencerIncludeTx(t helpers.Testing) {
a.alice.L2.ActResetTxOpts(t) a.alice.L2.ActResetTxOpts(t)
a.alice.L2.ActSetTxToAddr(&a.dp.Addresses.Bob)(t) a.alice.L2.ActSetTxToAddr(&a.dp.Addresses.Bob)(t)
a.alice.L2.ActMakeTx(t) a.alice.L2.ActMakeTx(t)
...@@ -156,7 +157,7 @@ func (a *L2AltDA) ActSequencerIncludeTx(t Testing) { ...@@ -156,7 +157,7 @@ func (a *L2AltDA) ActSequencerIncludeTx(t Testing) {
a.sequencer.ActL2EndBlock(t) a.sequencer.ActL2EndBlock(t)
} }
func (a *L2AltDA) ActNewL2Tx(t Testing) { func (a *L2AltDA) ActNewL2Tx(t helpers.Testing) {
a.ActSequencerIncludeTx(t) a.ActSequencerIncludeTx(t)
a.batcher.ActL2BatchBuffer(t) a.batcher.ActL2BatchBuffer(t)
...@@ -170,20 +171,20 @@ func (a *L2AltDA) ActNewL2Tx(t Testing) { ...@@ -170,20 +171,20 @@ func (a *L2AltDA) ActNewL2Tx(t Testing) {
a.miner.ActL1IncludeTx(a.dp.Addresses.Batcher)(t) a.miner.ActL1IncludeTx(a.dp.Addresses.Batcher)(t)
a.miner.ActL1EndBlock(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)) 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.ActChallengeInput(t, a.lastComm, a.lastCommBn)
a.log.Info("challenged last input", "block", 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{}) bondValue, err := a.contract.BondSize(&bind.CallOpts{})
require.NoError(t, err) require.NoError(t, err)
...@@ -209,15 +210,15 @@ func (a *L2AltDA) ActChallengeInput(t Testing, comm []byte, bn uint64) { ...@@ -209,15 +210,15 @@ func (a *L2AltDA) ActChallengeInput(t Testing, comm []byte, bn uint64) {
a.miner.ActL1EndBlock(t) a.miner.ActL1EndBlock(t)
} }
func (a *L2AltDA) ActExpireLastInput(t Testing) { func (a *L2AltDA) ActExpireLastInput(t helpers.Testing) {
reorgWindow := a.altDACfg.ResolveWindow + a.altDACfg.ChallengeWindow 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.ActL1StartBlock(12)(t)
a.miner.ActL1EndBlock(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) txOpts, err := bind.NewKeyedTransactorWithChainID(a.dp.Secrets.Alice, a.sd.L1Cfg.Config.ChainID)
require.NoError(t, err) require.NoError(t, err)
...@@ -229,7 +230,7 @@ func (a *L2AltDA) ActResolveInput(t Testing, comm []byte, input []byte, bn uint6 ...@@ -229,7 +230,7 @@ func (a *L2AltDA) ActResolveInput(t Testing, comm []byte, input []byte, bn uint6
a.miner.ActL1EndBlock(t) a.miner.ActL1EndBlock(t)
} }
func (a *L2AltDA) ActResolveLastChallenge(t Testing) { func (a *L2AltDA) ActResolveLastChallenge(t helpers.Testing) {
// remove derivation byte prefix // remove derivation byte prefix
input, err := a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(a.lastComm[1:])) input, err := a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(a.lastComm[1:]))
require.NoError(t, err) require.NoError(t, err)
...@@ -237,23 +238,22 @@ func (a *L2AltDA) ActResolveLastChallenge(t Testing) { ...@@ -237,23 +238,22 @@ func (a *L2AltDA) ActResolveLastChallenge(t Testing) {
a.ActResolveInput(t, a.lastComm, input, a.lastCommBn) 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++ { for i := uint64(0); i < n; i++ {
a.miner.ActL1StartBlock(12)(t) a.miner.ActL1StartBlock(12)(t)
a.miner.ActL1EndBlock(t) a.miner.ActL1EndBlock(t)
} }
} }
func (a *L2AltDA) GetLastTxBlock(t Testing) *types.Block { func (a *L2AltDA) GetLastTxBlock(t helpers.Testing) *types.Block {
rcpt, err := a.engine.EthClient().TransactionReceipt(t.Ctx(), a.alice.L2.lastTxHash) rcpt := a.alice.L2.LastTxReceipt(t)
require.NoError(t, err)
blk, err := a.engine.EthClient().BlockByHash(t.Ctx(), rcpt.BlockHash) blk, err := a.engine.EthClient().BlockByHash(t.Ctx(), rcpt.BlockHash)
require.NoError(t, err) require.NoError(t, err)
return blk return blk
} }
func (a *L2AltDA) ActL1Finalized(t Testing) { func (a *L2AltDA) ActL1Finalized(t helpers.Testing) {
latest := a.miner.l1Chain.CurrentBlock().Number.Uint64() latest := a.miner.L1Chain().CurrentBlock().Number.Uint64()
a.miner.ActL1Safe(t, latest) a.miner.ActL1Safe(t, latest)
a.miner.ActL1Finalize(t, latest) a.miner.ActL1Finalize(t, latest)
a.sequencer.ActL1FinalizedSignal(t) a.sequencer.ActL1FinalizedSignal(t)
...@@ -265,7 +265,7 @@ func TestAltDA_ChallengeExpired(gt *testing.T) { ...@@ -265,7 +265,7 @@ func TestAltDA_ChallengeExpired(gt *testing.T) {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
harness := NewL2AltDA(t) harness := NewL2AltDA(t)
// generate enough initial l1 blocks to have a finalized head. // generate enough initial l1 blocks to have a finalized head.
...@@ -325,7 +325,7 @@ func TestAltDA_ChallengeResolved(gt *testing.T) { ...@@ -325,7 +325,7 @@ func TestAltDA_ChallengeResolved(gt *testing.T) {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
harness := NewL2AltDA(t) harness := NewL2AltDA(t)
// include a new l2 transaction, submitting an input commitment to the l1. // include a new l2 transaction, submitting an input commitment to the l1.
...@@ -373,7 +373,7 @@ func TestAltDA_StorageError(gt *testing.T) { ...@@ -373,7 +373,7 @@ func TestAltDA_StorageError(gt *testing.T) {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
harness := NewL2AltDA(t) harness := NewL2AltDA(t)
// include a new l2 transaction, submitting an input commitment to the l1. // include a new l2 transaction, submitting an input commitment to the l1.
...@@ -402,7 +402,7 @@ func TestAltDA_ChallengeReorg(gt *testing.T) { ...@@ -402,7 +402,7 @@ func TestAltDA_ChallengeReorg(gt *testing.T) {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
harness := NewL2AltDA(t) harness := NewL2AltDA(t)
// New L2 tx added to a batch and committed to L1 // New L2 tx added to a batch and committed to L1
...@@ -450,7 +450,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) { ...@@ -450,7 +450,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
a := NewL2AltDA(t) a := NewL2AltDA(t)
// create a new tx on l2 and commit it to l1 // create a new tx on l2 and commit it to l1
...@@ -509,7 +509,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) { ...@@ -509,7 +509,7 @@ func TestAltDA_SequencerStalledMultiChallenges(gt *testing.T) {
comm2 := a.lastComm comm2 := a.lastComm
_, err = a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(comm2[1:])) _, err = a.storage.GetInput(t.Ctx(), altda.Keccak256Commitment(comm2[1:]))
require.NoError(t, err) 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 // ensure the second commitment is distinct from the first
require.NotEqual(t, comm1, comm2) require.NotEqual(t, comm1, comm2)
...@@ -545,7 +545,7 @@ func TestAltDA_Finalization(gt *testing.T) { ...@@ -545,7 +545,7 @@ func TestAltDA_Finalization(gt *testing.T) {
if !e2eutils.UseAltDA() { if !e2eutils.UseAltDA() {
gt.Skip("AltDA is not enabled") gt.Skip("AltDA is not enabled")
} }
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
a := NewL2AltDA(t) a := NewL2AltDA(t)
// build L1 block #1 // build L1 block #1
......
package actions package batcher
import ( import (
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -16,26 +17,26 @@ import ( ...@@ -16,26 +17,26 @@ import (
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
) )
func setupEIP4844Test(t Testing, log log.Logger) (*e2eutils.SetupData, *e2eutils.DeployParams, *L1Miner, *L2Sequencer, *L2Engine, *L2Verifier, *L2Engine) { 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, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
genesisActivation := hexutil.Uint64(0) genesisActivation := hexutil.Uint64(0)
dp.DeployConfig.L1CancunTimeOffset = &genesisActivation dp.DeployConfig.L1CancunTimeOffset = &genesisActivation
dp.DeployConfig.L2GenesisCanyonTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisCanyonTimeOffset = &genesisActivation
dp.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation
dp.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation dp.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) miner, seqEngine, sequencer := helpers.SetupSequencerTest(t, sd, log)
miner.ActL1SetFeeRecipient(common.Address{'A'}) miner.ActL1SetFeeRecipient(common.Address{'A'})
sequencer.ActL2PipelineFull(t) 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 return sd, dp, miner, sequencer, seqEngine, verifier, verifEngine
} }
func setupBatcher(t Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutils.DeployParams, miner *L1Miner, func setupBatcher(t helpers.Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutils.DeployParams, miner *helpers.L1Miner,
sequencer *L2Sequencer, engine *L2Engine, daType batcherFlags.DataAvailabilityType, sequencer *helpers.L2Sequencer, engine *helpers.L2Engine, daType batcherFlags.DataAvailabilityType,
) *L2Batcher { ) *helpers.L2Batcher {
return NewL2Batcher(log, sd.RollupCfg, &BatcherCfg{ return helpers.NewL2Batcher(log, sd.RollupCfg, &helpers.BatcherCfg{
MinL1TxSize: 0, MinL1TxSize: 0,
MaxL1TxSize: 128_000, MaxL1TxSize: 128_000,
BatcherKey: dp.Secrets.Batcher, BatcherKey: dp.Secrets.Batcher,
...@@ -44,7 +45,7 @@ func setupBatcher(t Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutil ...@@ -44,7 +45,7 @@ func setupBatcher(t Testing, log log.Logger, sd *e2eutils.SetupData, dp *e2eutil
} }
func TestEIP4844DataAvailability(gt *testing.T) { func TestEIP4844DataAvailability(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log)
...@@ -82,7 +83,7 @@ func TestEIP4844DataAvailability(gt *testing.T) { ...@@ -82,7 +83,7 @@ func TestEIP4844DataAvailability(gt *testing.T) {
} }
func TestEIP4844MultiBlobs(gt *testing.T) { func TestEIP4844MultiBlobs(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log)
...@@ -121,7 +122,7 @@ func TestEIP4844MultiBlobs(gt *testing.T) { ...@@ -121,7 +122,7 @@ func TestEIP4844MultiBlobs(gt *testing.T) {
} }
func TestEIP4844DataAvailabilitySwitch(gt *testing.T) { func TestEIP4844DataAvailabilitySwitch(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log) sd, dp, miner, sequencer, seqEngine, verifier, _ := setupEIP4844Test(t, log)
......
package actions package derivation
import ( import (
"testing" "testing"
altda "github.com/ethereum-optimism/optimism/op-alt-da" altda "github.com/ethereum-optimism/optimism/op-alt-da"
batcherFlags "github.com/ethereum-optimism/optimism/op-batcher/flags" 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-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/node/safedb" "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/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/sources"
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -20,7 +23,7 @@ import ( ...@@ -20,7 +23,7 @@ import (
// This is a regression test, previously the pipeline encountered got stuck in a reset loop with the error: // 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 // buffered L1 chain epoch %s in batch queue does not match safe head origin %s
func TestDeriveChainFromNearL1Genesis(gt *testing.T) { func TestDeriveChainFromNearL1Genesis(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
p := &e2eutils.TestParams{ p := &e2eutils.TestParams{
MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12)
SequencerWindowSize: 24, SequencerWindowSize: 24,
...@@ -29,22 +32,22 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { ...@@ -29,22 +32,22 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) {
} }
dp := e2eutils.MakeDeployParams(t, p) dp := e2eutils.MakeDeployParams(t, p)
// do not activate Delta hardfork for verifier // do not activate Delta hardfork for verifier
applyDeltaTimeOffset(dp, nil) upgradesHelpers.ApplyDeltaTimeOffset(dp, nil)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
logger := testlog.Logger(t, log.LevelInfo) logger := testlog.Logger(t, log.LevelInfo)
miner, seqEngine, sequencer := setupSequencerTest(t, sd, logger) miner, seqEngine, sequencer := helpers.SetupSequencerTest(t, sd, logger)
miner.ActEmptyBlock(t) 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.NoError(gt, err)
require.EqualValues(gt, 0, ref.L1Origin.Number) require.EqualValues(gt, 0, ref.L1Origin.Number)
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
l2BlockNum := seqEngine.l2Chain.CurrentBlock().Number.Uint64() l2BlockNum := seqEngine.L2Chain().CurrentBlock().Number.Uint64()
ref, err = derive.L2BlockToBlockRef(sequencer.rollupCfg, seqEngine.l2Chain.GetBlockByNumber(l2BlockNum)) ref, err = derive.L2BlockToBlockRef(sequencer.RollupCfg, seqEngine.L2Chain().GetBlockByNumber(l2BlockNum))
require.NoError(gt, err) require.NoError(gt, err)
require.EqualValues(gt, 1, ref.L1Origin.Number) require.EqualValues(gt, 1, ref.L1Origin.Number)
...@@ -52,7 +55,7 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { ...@@ -52,7 +55,7 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) {
rollupSeqCl := sequencer.RollupClient() rollupSeqCl := sequencer.RollupClient()
// Force batcher to submit SingularBatches to L1. // Force batcher to submit SingularBatches to L1.
batcher := NewL2Batcher(logger, sd.RollupCfg, &BatcherCfg{ batcher := helpers.NewL2Batcher(logger, sd.RollupCfg, &helpers.BatcherCfg{
MinL1TxSize: 0, MinL1TxSize: 0,
MaxL1TxSize: 128_000, MaxL1TxSize: 128_000,
BatcherKey: dp.Secrets.Batcher, BatcherKey: dp.Secrets.Batcher,
...@@ -60,40 +63,40 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) { ...@@ -60,40 +63,40 @@ func TestDeriveChainFromNearL1Genesis(gt *testing.T) {
}, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) }, rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
batcher.ActSubmitAll(t) batcher.ActSubmitAll(t)
require.EqualValues(gt, l2BlockNum, batcher.l2BufferedBlock.Number) require.EqualValues(gt, l2BlockNum, batcher.L2BufferedBlock.Number)
// confirm batch on L1 // confirm batch on L1
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
bl := miner.l1Chain.CurrentBlock() bl := miner.L1Chain().CurrentBlock()
logger.Info("Produced L1 block with batch", logger.Info("Produced L1 block with batch",
"num", miner.l1Chain.CurrentBlock().Number.Uint64(), "num", miner.L1Chain().CurrentBlock().Number.Uint64(),
"txs", len(miner.l1Chain.GetBlockByHash(bl.Hash()).Transactions())) "txs", len(miner.L1Chain().GetBlockByHash(bl.Hash()).Transactions()))
// Process batches so safe head updates // Process batches so safe head updates
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActL2PipelineFull(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 // Finalize L1 and process so L2 finalized updates
miner.ActL1Safe(t, miner.l1Chain.CurrentBlock().Number.Uint64()) miner.ActL1Safe(t, miner.L1Chain().CurrentBlock().Number.Uint64())
miner.ActL1Finalize(t, miner.l1Chain.CurrentBlock().Number.Uint64()) miner.ActL1Finalize(t, miner.L1Chain().CurrentBlock().Number.Uint64())
sequencer.ActL1SafeSignal(t) sequencer.ActL1SafeSignal(t)
sequencer.ActL1FinalizedSignal(t) sequencer.ActL1FinalizedSignal(t)
sequencer.ActL2PipelineFull(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. // 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. // 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)) l2Cl, err := sources.NewEngineClient(seqEngine.RPCClient(), logger, nil, sources.EngineClientDefaultConfig(sd.RollupCfg))
require.NoError(gt, err) require.NoError(gt, err)
verifier := NewL2Verifier(t, logger, sequencer.l1, miner.BlobStore(), altda.Disabled, verifier := helpers.NewL2Verifier(t, logger, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), altda.Disabled,
l2Cl, sequencer.rollupCfg, sequencer.syncCfg, safedb.Disabled, nil) l2Cl, sequencer.RollupCfg, &sync.Config{}, safedb.Disabled, nil)
verifier.ActL2PipelineFull(t) // Should not get stuck in a reset loop forever 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().CurrentSafeBlock().Number.Uint64())
require.EqualValues(gt, l2BlockNum, seqEngine.l2Chain.CurrentFinalBlock().Number.Uint64()) require.EqualValues(gt, l2BlockNum, seqEngine.L2Chain().CurrentFinalBlock().Number.Uint64())
syncStatus := verifier.syncStatus.SyncStatus() syncStatus := verifier.SyncStatus()
require.EqualValues(gt, l2BlockNum, syncStatus.SafeL2.Number) require.EqualValues(gt, l2BlockNum, syncStatus.SafeL2.Number)
require.EqualValues(gt, l2BlockNum, syncStatus.FinalizedL2.Number) require.EqualValues(gt, l2BlockNum, syncStatus.FinalizedL2.Number)
} }
package actions package derivation
import ( import (
"math/big" "math/big"
"testing" "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-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
...@@ -44,16 +46,16 @@ func TestBlockTimeBatchType(t *testing.T) { ...@@ -44,16 +46,16 @@ func TestBlockTimeBatchType(t *testing.T) {
// window. // window.
// This is a regression test against the bug fixed in PR #4566 // This is a regression test against the bug fixed in PR #4566
func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
t := NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams)
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
dp.DeployConfig.SequencerWindowSize = 4 dp.DeployConfig.SequencerWindowSize = 4
dp.DeployConfig.L2BlockTime = 2 dp.DeployConfig.L2BlockTime = 2
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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) signer := types.LatestSigner(sd.L2Cfg.Config)
cl := sequencerEngine.EthClient() cl := sequencerEngine.EthClient()
...@@ -63,7 +65,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -63,7 +65,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
ChainID: sd.L2Cfg.Config.ChainID, ChainID: sd.L2Cfg.Config.ChainID,
Nonce: aliceNonce, Nonce: aliceNonce,
GasTipCap: big.NewInt(2 * params.GWei), 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, Gas: params.TxGas,
To: &dp.Addresses.Bob, To: &dp.Addresses.Bob,
Value: e2eutils.Ether(2), Value: e2eutils.Ether(2),
...@@ -78,7 +80,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -78,7 +80,7 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
} }
verifyChainStateOnSequencer := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin 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, unsafeHead, sequencer.L2Unsafe().Number)
require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number) require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number)
require.Equal(t, safeHead, sequencer.L2Safe().Number) require.Equal(t, safeHead, sequencer.L2Safe().Number)
...@@ -155,8 +157,8 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -155,8 +157,8 @@ func BatchInLastPossibleBlocks(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
// At this point it can verify that the batches where properly generated. // At this point it can verify that the batches where properly generated.
// Note: It batches submits when possible. // Note: It batches submits when possible.
func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { func LargeL1Gaps(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.L1BlockTime = 4 dp.DeployConfig.L1BlockTime = 4
dp.DeployConfig.L2BlockTime = 2 dp.DeployConfig.L2BlockTime = 2
dp.DeployConfig.SequencerWindowSize = 4 dp.DeployConfig.SequencerWindowSize = 4
...@@ -165,11 +167,11 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -165,11 +167,11 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
dp.DeployConfig.L2GenesisFjordTimeOffset = nil dp.DeployConfig.L2GenesisFjordTimeOffset = nil
// TODO(client-pod#831): The Ecotone (and Fjord) activation blocks don't include user txs, // TODO(client-pod#831): The Ecotone (and Fjord) activation blocks don't include user txs,
// so disabling these forks for now. // so disabling these forks for now.
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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) signer := types.LatestSigner(sd.L2Cfg.Config)
cl := sequencerEngine.EthClient() cl := sequencerEngine.EthClient()
...@@ -180,7 +182,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -180,7 +182,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
ChainID: sd.L2Cfg.Config.ChainID, ChainID: sd.L2Cfg.Config.ChainID,
Nonce: aliceNonce, Nonce: aliceNonce,
GasTipCap: big.NewInt(2 * params.GWei), 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, Gas: params.TxGas,
To: &dp.Addresses.Bob, To: &dp.Addresses.Bob,
Value: e2eutils.Ether(2), Value: e2eutils.Ether(2),
...@@ -196,7 +198,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -196,7 +198,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
} }
verifyChainStateOnSequencer := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin 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, unsafeHead, sequencer.L2Unsafe().Number)
require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number) require.Equal(t, unsafeHeadOrigin, sequencer.L2Unsafe().L1Origin.Number)
require.Equal(t, safeHead, sequencer.L2Safe().Number) require.Equal(t, safeHead, sequencer.L2Safe().Number)
...@@ -204,7 +206,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -204,7 +206,7 @@ func LargeL1Gaps(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
} }
verifyChainStateOnVerifier := func(l1Number, unsafeHead, unsafeHeadOrigin, safeHead, safeHeadOrigin 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, unsafeHead, verifier.L2Unsafe().Number)
require.Equal(t, unsafeHeadOrigin, verifier.L2Unsafe().L1Origin.Number) require.Equal(t, unsafeHeadOrigin, verifier.L2Unsafe().L1Origin.Number)
require.Equal(t, safeHead, verifier.L2Safe().Number) require.Equal(t, safeHead, verifier.L2Safe().Number)
......
package actions package derivation
import ( import (
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require" "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-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" "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) { func TestL2Verifier_SequenceWindow(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
p := &e2eutils.TestParams{ p := &e2eutils.TestParams{
MaxSequencerDrift: 10, MaxSequencerDrift: 10,
SequencerWindowSize: 24, SequencerWindowSize: 24,
...@@ -43,26 +21,26 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { ...@@ -43,26 +21,26 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) {
L1BlockTime: 15, L1BlockTime: 15,
} }
dp := e2eutils.MakeDeployParams(t, p) dp := e2eutils.MakeDeployParams(t, p)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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'}) 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 // 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.ActL1StartBlock(10)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
verifier.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t)
l1Head := miner.l1Chain.CurrentBlock().Number.Uint64() l1Head := miner.L1Chain().CurrentBlock().Number.Uint64()
expectedL1Origin := uint64(0) expectedL1Origin := uint64(0)
// as soon as we complete the sequence window, we force-adopt the L1 origin // as soon as we complete the sequence window, we force-adopt the L1 origin
if l1Head >= sd.RollupCfg.SeqWindowSize { if l1Head >= sd.RollupCfg.SeqWindowSize {
expectedL1Origin = 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.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() tip2N := verifier.SyncStatus()
...@@ -77,13 +55,13 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { ...@@ -77,13 +55,13 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'B'}) miner.ActL1SetFeeRecipient(common.Address{'B'})
miner.ActL1StartBlock(10)(t) miner.ActL1StartBlock(10)(t)
miner.ActL1EndBlock(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 // Still no reorg, we need more L1 blocks first, before the reorged L1 block is forced in by sequence window
verifier.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t)
require.Equal(t, tip2N.SafeL2, verifier.SyncStatus().SafeL2) 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.ActL1StartBlock(10)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
} }
...@@ -95,6 +73,6 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { ...@@ -95,6 +73,6 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) {
// Now it will reorg // Now it will reorg
verifier.ActL2PipelineFull(t) 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") require.Equal(t, reorgL1Block.Hash(), got.Hash(), "must have reorged L2 chain to the new L1 chain")
} }
package actions package derivation
import ( import (
"math/big" "math/big"
"math/rand" "math/rand"
"testing" "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/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
...@@ -49,27 +51,27 @@ func TestSystemConfigBatchType(t *testing.T) { ...@@ -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, // 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. // and that the change to batcher B is reverted properly upon reorg of L1.
func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { 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 dp.DeployConfig.L2BlockTime = 2
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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'}) miner.ActL1SetFeeRecipient(common.Address{'A'})
sequencer.ActL2PipelineFull(t) 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() rollupSeqCl := sequencer.RollupClient()
// the default batcher // 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)) rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
// a batcher with a new key // a batcher with a new key
altCfg := *DefaultBatcherCfg(dp) altCfg := *actionsHelpers.DefaultBatcherCfg(dp)
altCfg.BatcherKey = dp.Secrets.Bob 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)) rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
...@@ -114,7 +116,7 @@ func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -114,7 +116,7 @@ func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
receipt, err := miner.EthClient().TransactionReceipt(t.Ctx(), tx.Hash()) receipt, err := miner.EthClient().TransactionReceipt(t.Ctx(), tx.Hash())
require.NoError(t, err) require.NoError(t, err)
cfgChangeL1BlockNum := miner.l1Chain.CurrentBlock().Number.Uint64() cfgChangeL1BlockNum := miner.L1Chain().CurrentBlock().Number.Uint64()
require.Equal(t, cfgChangeL1BlockNum, receipt.BlockNumber.Uint64()) require.Equal(t, cfgChangeL1BlockNum, receipt.BlockNumber.Uint64())
// sequence L2 blocks, and submit with new batcher // sequence L2 blocks, and submit with new batcher
...@@ -225,9 +227,9 @@ func BatcherKeyRotation(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -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, // 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. // 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) { func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
t := NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams)
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
// activating Delta only, not Ecotone and further: // activating Delta only, not Ecotone and further:
// the GPO change assertions here all apply only for the Delta transition. // the GPO change assertions here all apply only for the Delta transition.
...@@ -236,14 +238,14 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -236,14 +238,14 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
dp.DeployConfig.L2GenesisFjordTimeOffset = nil dp.DeployConfig.L2GenesisFjordTimeOffset = nil
dp.DeployConfig.L2GenesisGraniteTimeOffset = nil dp.DeployConfig.L2GenesisGraniteTimeOffset = nil
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log)
batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp),
sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
alice := NewBasicUser[any](log, dp.Secrets.Alice, rand.New(rand.NewSource(1234))) alice := actionsHelpers.NewBasicUser[any](log, dp.Secrets.Alice, rand.New(rand.NewSource(1234)))
alice.SetUserEnv(&BasicUserEnv[any]{ alice.SetUserEnv(&actionsHelpers.BasicUserEnv[any]{
EthCl: seqEngine.EthClient(), EthCl: seqEngine.EthClient(),
Signer: types.LatestSigner(sd.L2Cfg.Config), Signer: types.LatestSigner(sd.L2Cfg.Config),
}) })
...@@ -254,7 +256,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -254,7 +256,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
miner.ActEmptyBlock(t) miner.ActEmptyBlock(t)
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
basefee := miner.l1Chain.CurrentBlock().BaseFee basefee := miner.L1Chain().CurrentBlock().BaseFee
// alice makes a L2 tx, sequencer includes it // alice makes a L2 tx, sequencer includes it
alice.ActResetTxOpts(t) alice.ActResetTxOpts(t)
...@@ -299,7 +301,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -299,7 +301,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
miner.ActL1IncludeTx(dp.Addresses.SysCfgOwner)(t) miner.ActL1IncludeTx(dp.Addresses.SysCfgOwner)(t)
miner.ActL1EndBlock(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 // build empty L2 chain, up to but excluding the L2 block with the L1 origin that processes the GPO change
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
...@@ -336,7 +338,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -336,7 +338,7 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
// build more L2 blocks, with new L1 origin // build more L2 blocks, with new L1 origin
miner.ActEmptyBlock(t) miner.ActEmptyBlock(t)
basefee = miner.l1Chain.CurrentBlock().BaseFee basefee = miner.L1Chain().CurrentBlock().BaseFee
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
// and Alice makes a tx again // and Alice makes a tx again
...@@ -360,13 +362,13 @@ func GPOParamsChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -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 // 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. // 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) { func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
t := NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams)
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log)
batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp), batcher := actionsHelpers.NewL2Batcher(log, sd.RollupCfg, actionsHelpers.DefaultBatcherCfg(dp),
sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) sequencer.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
...@@ -374,7 +376,7 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -374,7 +376,7 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
oldGasLimit := seqEngine.l2Chain.CurrentBlock().GasLimit oldGasLimit := seqEngine.L2Chain().CurrentBlock().GasLimit
require.Equal(t, oldGasLimit, uint64(dp.DeployConfig.L2GenesisBlockGasLimit)) require.Equal(t, oldGasLimit, uint64(dp.DeployConfig.L2GenesisBlockGasLimit))
// change gas limit on L1 to triple what it was // change gas limit on L1 to triple what it was
...@@ -396,12 +398,12 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -396,12 +398,12 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1HeadExcl(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) 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 // now include the L1 block with the gaslimit change, and see if it changes as expected
sequencer.ActBuildToL1Head(t) 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) 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 // 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) { ...@@ -410,7 +412,7 @@ func GasLimitChange(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
miner.ActL1IncludeTx(dp.Addresses.Batcher)(t) miner.ActL1IncludeTx(dp.Addresses.Batcher)(t)
miner.ActL1EndBlock(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) verifier.ActL2PipelineFull(t)
require.Equal(t, sequencer.L2Unsafe(), verifier.L2Safe(), "verifier stays in sync, even with gaslimit changes") require.Equal(t, sequencer.L2Unsafe(), verifier.L2Safe(), "verifier stays in sync, even with gaslimit changes")
......
package actions package helpers
import ( import (
"context" "context"
......
package actions package helpers
import ( import (
"math/big" "math/big"
...@@ -33,9 +33,9 @@ type L1Miner struct { ...@@ -33,9 +33,9 @@ type L1Miner struct {
// L1 block building data // L1 block building data
l1BuildingHeader *types.Header // block header that we add txs to for block building l1BuildingHeader *types.Header // block header that we add txs to for block building
l1BuildingState *state.StateDB // state used 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. 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 l1Receipts []*types.Receipt // collect receipts of ongoing building
l1Building bool l1Building bool
l1TxFailed []*types.Transaction // log of failed transactions which could not be included l1TxFailed []*types.Transaction // log of failed transactions which could not be included
...@@ -120,11 +120,11 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action { ...@@ -120,11 +120,11 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
s.l1BuildingHeader = header s.l1BuildingHeader = header
s.l1BuildingState = statedb s.l1BuildingState = statedb
s.l1Receipts = make([]*types.Receipt, 0) 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.pendingIndices = make(map[common.Address]uint64)
s.l1BuildingBlobSidecars = make([]*types.BlobTxSidecar, 0) 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 { ...@@ -138,7 +138,7 @@ func (s *L1Miner) ActL1IncludeTx(from common.Address) Action {
getPendingIndex := func(from common.Address) uint64 { getPendingIndex := func(from common.Address) uint64 {
return s.pendingIndices[from] 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.IncludeTx(t, tx)
s.pendingIndices[from] = s.pendingIndices[from] + 1 // won't retry the 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 { ...@@ -151,7 +151,7 @@ func (s *L1Miner) ActL1IncludeTxByHash(txHash common.Hash) Action {
t.InvalidAction("no tx inclusion when not building l1 block") t.InvalidAction("no tx inclusion when not building l1 block")
return return
} }
tx := s.eth.TxPool().Get(txHash) tx := s.Eth.TxPool().Get(txHash)
require.NotNil(t, tx, "cannot find tx %s", txHash) require.NotNil(t, tx, "cannot find tx %s", txHash)
s.IncludeTx(t, tx) s.IncludeTx(t, tx)
from, err := s.l1Signer.Sender(tx) from, err := s.l1Signer.Sender(tx)
...@@ -167,19 +167,19 @@ func (s *L1Miner) IncludeTx(t Testing, tx *types.Transaction) { ...@@ -167,19 +167,19 @@ func (s *L1Miner) IncludeTx(t Testing, tx *types.Transaction) {
if tx.Gas() > s.l1BuildingHeader.GasLimit { if tx.Gas() > s.l1BuildingHeader.GasLimit {
t.Fatalf("tx consumes %d gas, more than available in L1 block %d", 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) { if tx.Gas() > uint64(*s.L1GasPool) {
t.InvalidAction("action takes too much gas: %d, only have %d", tx.Gas(), uint64(*s.l1GasPool)) t.InvalidAction("action takes too much gas: %d, only have %d", tx.Gas(), uint64(*s.L1GasPool))
return 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, 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 { if err != nil {
s.l1TxFailed = append(s.l1TxFailed, tx) 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.l1Receipts = append(s.l1Receipts, receipt)
s.l1Transactions = append(s.l1Transactions, tx.WithoutBlobTxSidecar()) s.L1Transactions = append(s.L1Transactions, tx.WithoutBlobTxSidecar())
if tx.Type() == types.BlobTxType { 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") require.True(t, s.l1Cfg.Config.IsCancun(s.l1BuildingHeader.Number, s.l1BuildingHeader.Time), "L1 must be cancun to process blob tx")
sidecar := tx.BlobTxSidecar() sidecar := tx.BlobTxSidecar()
...@@ -205,7 +205,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) { ...@@ -205,7 +205,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
} }
s.l1Building = false 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)) s.l1BuildingHeader.Root = s.l1BuildingState.IntermediateRoot(s.l1Cfg.Config.IsEIP158(s.l1BuildingHeader.Number))
var withdrawals []*types.Withdrawal var withdrawals []*types.Withdrawal
...@@ -213,7 +213,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) { ...@@ -213,7 +213,7 @@ func (s *L1Miner) ActL1EndBlock(t Testing) {
withdrawals = make([]*types.Withdrawal, 0) 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) { if s.l1Cfg.Config.IsCancun(s.l1BuildingHeader.Number, s.l1BuildingHeader.Time) {
parent := s.l1Chain.GetHeaderByHash(s.l1BuildingHeader.ParentHash) parent := s.l1Chain.GetHeaderByHash(s.l1BuildingHeader.ParentHash)
var ( var (
......
package actions package helpers
import ( import (
"math/big" "math/big"
......
package actions package helpers
import ( import (
"errors" "errors"
...@@ -38,7 +38,7 @@ type L1Replica struct { ...@@ -38,7 +38,7 @@ type L1Replica struct {
log log.Logger log log.Logger
node *node.Node node *node.Node
eth *eth.Ethereum Eth *eth.Ethereum
// L1 evm / chain // L1 evm / chain
l1Chain *core.BlockChain l1Chain *core.BlockChain
...@@ -90,7 +90,7 @@ func NewL1Replica(t Testing, log log.Logger, genesis *core.Genesis) *L1Replica { ...@@ -90,7 +90,7 @@ func NewL1Replica(t Testing, log log.Logger, genesis *core.Genesis) *L1Replica {
return &L1Replica{ return &L1Replica{
log: log, log: log,
node: n, node: n,
eth: backend, Eth: backend,
l1Chain: backend.BlockChain(), l1Chain: backend.BlockChain(),
l1Database: backend.ChainDb(), l1Database: backend.ChainDb(),
l1Cfg: genesis, l1Cfg: genesis,
......
package actions package helpers
import ( import (
"encoding/binary" "encoding/binary"
......
package actions package helpers
import ( import (
"bytes" "bytes"
...@@ -106,12 +106,12 @@ type L2Batcher struct { ...@@ -106,12 +106,12 @@ type L2Batcher struct {
l1Signer types.Signer l1Signer types.Signer
l2ChannelOut ChannelOutIface L2ChannelOut ChannelOutIface
l2Submitting bool // when the channel out is being submitted, and not safe to write to without resetting 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 l2SubmittedBlock eth.L2BlockRef
l2BatcherCfg *BatcherCfg l2BatcherCfg *BatcherCfg
batcherAddr common.Address BatcherAddr common.Address
LastSubmitted *types.Transaction LastSubmitted *types.Transaction
} }
...@@ -126,7 +126,7 @@ func NewL2Batcher(log log.Logger, rollupCfg *rollup.Config, batcherCfg *BatcherC ...@@ -126,7 +126,7 @@ func NewL2Batcher(log log.Logger, rollupCfg *rollup.Config, batcherCfg *BatcherC
engCl: engCl, engCl: engCl,
l2BatcherCfg: batcherCfg, l2BatcherCfg: batcherCfg,
l1Signer: types.LatestSignerForChainID(rollupCfg.L1ChainID), 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) { ...@@ -144,7 +144,7 @@ func (s *L2Batcher) ActL2BatchBuffer(t Testing) {
func (s *L2Batcher) Buffer(t Testing) error { func (s *L2Batcher) Buffer(t Testing) error {
if s.l2Submitting { // break ongoing submitting work if necessary if s.l2Submitting { // break ongoing submitting work if necessary
s.l2ChannelOut = nil s.L2ChannelOut = nil
s.l2Submitting = false s.l2Submitting = false
} }
syncStatus, err := s.syncStatusAPI.SyncStatus(t.Ctx()) syncStatus, err := s.syncStatusAPI.SyncStatus(t.Ctx())
...@@ -153,38 +153,38 @@ func (s *L2Batcher) Buffer(t Testing) error { ...@@ -153,38 +153,38 @@ func (s *L2Batcher) Buffer(t Testing) error {
if s.l2SubmittedBlock == (eth.L2BlockRef{}) { if s.l2SubmittedBlock == (eth.L2BlockRef{}) {
s.log.Info("Starting batch-submitter work at safe-head", "safe", syncStatus.SafeL2) s.log.Info("Starting batch-submitter work at safe-head", "safe", syncStatus.SafeL2)
s.l2SubmittedBlock = syncStatus.SafeL2 s.l2SubmittedBlock = syncStatus.SafeL2
s.l2BufferedBlock = syncStatus.SafeL2 s.L2BufferedBlock = syncStatus.SafeL2
s.l2ChannelOut = nil s.L2ChannelOut = nil
} }
// If it's lagging behind, catch it up. // If it's lagging behind, catch it up.
if s.l2SubmittedBlock.Number < syncStatus.SafeL2.Number { 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.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.l2SubmittedBlock = syncStatus.SafeL2
s.l2BufferedBlock = syncStatus.SafeL2 s.L2BufferedBlock = syncStatus.SafeL2
s.l2ChannelOut = nil s.L2ChannelOut = nil
} }
// Add the next unsafe block to the channel // Add the next unsafe block to the channel
if s.l2BufferedBlock.Number >= syncStatus.UnsafeL2.Number { 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 || 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.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.l2SubmittedBlock = syncStatus.SafeL2
s.l2BufferedBlock = syncStatus.SafeL2 s.L2BufferedBlock = syncStatus.SafeL2
s.l2ChannelOut = nil s.L2ChannelOut = nil
} else { } else {
s.log.Info("nothing left to submit") s.log.Info("nothing left to submit")
return nil 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) 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.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.l2SubmittedBlock = syncStatus.SafeL2
s.l2BufferedBlock = syncStatus.SafeL2 s.L2BufferedBlock = syncStatus.SafeL2
s.l2ChannelOut = nil s.L2ChannelOut = nil
} }
// Create channel if we don't have one yet // Create channel if we don't have one yet
if s.l2ChannelOut == nil { if s.L2ChannelOut == nil {
var ch ChannelOutIface var ch ChannelOutIface
if s.l2BatcherCfg.GarbageCfg != nil { if s.l2BatcherCfg.GarbageCfg != nil {
ch, err = NewGarbageChannelOut(s.l2BatcherCfg.GarbageCfg) ch, err = NewGarbageChannelOut(s.l2BatcherCfg.GarbageCfg)
...@@ -210,29 +210,29 @@ func (s *L2Batcher) Buffer(t Testing) error { ...@@ -210,29 +210,29 @@ func (s *L2Batcher) Buffer(t Testing) error {
} }
} }
require.NoError(t, err, "failed to create channel") 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 return err
} }
ref, err := s.engCl.L2BlockRefByHash(t.Ctx(), block.Hash()) ref, err := s.engCl.L2BlockRefByHash(t.Ctx(), block.Hash())
require.NoError(t, err, "failed to get L2BlockRef") require.NoError(t, err, "failed to get L2BlockRef")
s.l2BufferedBlock = ref s.L2BufferedBlock = ref
return nil return nil
} }
func (s *L2Batcher) ActL2ChannelClose(t Testing) { func (s *L2Batcher) ActL2ChannelClose(t Testing) {
// Don't run this action if there's no data to submit // 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") t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer")
return 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 { func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte {
// Don't run this action if there's no data to submit // 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") t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer")
return nil return nil
} }
...@@ -240,8 +240,8 @@ func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte { ...@@ -240,8 +240,8 @@ func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte {
data := new(bytes.Buffer) data := new(bytes.Buffer)
data.WriteByte(derive.DerivationVersion0) data.WriteByte(derive.DerivationVersion0)
// subtract one, to account for the version byte // subtract one, to account for the version byte
if _, err := s.l2ChannelOut.OutputFrame(data, s.l2BatcherCfg.MaxL1TxSize-1); err == io.EOF { if _, err := s.L2ChannelOut.OutputFrame(data, s.l2BatcherCfg.MaxL1TxSize-1); err == io.EOF {
s.l2ChannelOut = nil s.L2ChannelOut = nil
s.l2Submitting = false s.l2Submitting = false
} else if err != nil { } else if err != nil {
s.l2Submitting = false s.l2Submitting = false
...@@ -263,7 +263,7 @@ func (s *L2Batcher) ActL2BatchSubmitRaw(t Testing, payload []byte, txOpts ...fun ...@@ -263,7 +263,7 @@ func (s *L2Batcher) ActL2BatchSubmitRaw(t Testing, payload []byte, txOpts ...fun
payload = comm.TxData() 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") require.NoError(t, err, "need batcher nonce")
gasTipCap := big.NewInt(2 * params.GWei) gasTipCap := big.NewInt(2 * params.GWei)
...@@ -334,7 +334,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { ...@@ -334,7 +334,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) {
} }
// Don't run this action if there's no data to submit // 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") t.InvalidAction("need to buffer data first, cannot batch submit with empty buffer")
return return
} }
...@@ -351,12 +351,12 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { ...@@ -351,12 +351,12 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) {
// subtract one, to account for the version byte // subtract one, to account for the version byte
l = s.l2BatcherCfg.MaxL1TxSize - 1 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 s.l2Submitting = false
if i < numBlobs-1 { if i < numBlobs-1 {
t.Fatalf("failed to fill up %d blobs, only filled %d", numBlobs, i+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 { } else if err != nil {
s.l2Submitting = false s.l2Submitting = false
t.Fatalf("failed to output channel data to frame: %v", err) t.Fatalf("failed to output channel data to frame: %v", err)
...@@ -366,7 +366,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) { ...@@ -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") 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") require.NoError(t, err, "need batcher nonce")
gasTipCap := big.NewInt(2 * params.GWei) gasTipCap := big.NewInt(2 * params.GWei)
...@@ -453,7 +453,7 @@ func (s *L2Batcher) ActL2BatchSubmitGarbageRaw(t Testing, outputFrame []byte, ki ...@@ -453,7 +453,7 @@ func (s *L2Batcher) ActL2BatchSubmitGarbageRaw(t Testing, outputFrame []byte, ki
func (s *L2Batcher) ActBufferAll(t Testing) { func (s *L2Batcher) ActBufferAll(t Testing) {
stat, err := s.syncStatusAPI.SyncStatus(t.Ctx()) stat, err := s.syncStatusAPI.SyncStatus(t.Ctx())
require.NoError(t, err) require.NoError(t, err)
for s.l2BufferedBlock.Number < stat.UnsafeL2.Number { for s.L2BufferedBlock.Number < stat.UnsafeL2.Number {
s.ActL2BatchBuffer(t) s.ActL2BatchBuffer(t)
} }
} }
......
package actions package helpers
import ( import (
"errors" "errors"
...@@ -35,7 +35,7 @@ type L2Engine struct { ...@@ -35,7 +35,7 @@ type L2Engine struct {
log log.Logger log log.Logger
node *node.Node node *node.Node
eth *geth.Ethereum Eth *geth.Ethereum
rollupGenesis *rollup.Genesis rollupGenesis *rollup.Genesis
...@@ -43,9 +43,9 @@ type L2Engine struct { ...@@ -43,9 +43,9 @@ type L2Engine struct {
l2Chain *core.BlockChain l2Chain *core.BlockChain
l2Signer types.Signer 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 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 ...@@ -58,7 +58,7 @@ func NewL2Engine(t Testing, log log.Logger, genesis *core.Genesis, rollupGenesis
eng := &L2Engine{ eng := &L2Engine{
log: log, log: log,
node: n, node: n,
eth: ethBackend, Eth: ethBackend,
rollupGenesis: &rollup.Genesis{ rollupGenesis: &rollup.Genesis{
L1: rollupGenesisL1, L1: rollupGenesisL1,
L2: eth.BlockID{Hash: genesisBlock.Hash(), Number: genesisBlock.NumberU64()}, L2: eth.BlockID{Hash: genesisBlock.Hash(), Number: genesisBlock.NumberU64()},
...@@ -66,14 +66,14 @@ func NewL2Engine(t Testing, log log.Logger, genesis *core.Genesis, rollupGenesis ...@@ -66,14 +66,14 @@ func NewL2Engine(t Testing, log log.Logger, genesis *core.Genesis, rollupGenesis
}, },
l2Chain: chain, l2Chain: chain,
l2Signer: types.LatestSigner(genesis.Config), l2Signer: types.LatestSigner(genesis.Config),
engineApi: engineApi, EngineApi: engineApi,
} }
// register the custom engine API, so we can serve engine requests while having more control // register the custom engine API, so we can serve engine requests while having more control
// over sequencing of individual txs. // over sequencing of individual txs.
n.RegisterAPIs([]rpc.API{ n.RegisterAPIs([]rpc.API{
{ {
Namespace: "engine", Namespace: "engine",
Service: eng.engineApi, Service: eng.EngineApi,
Authenticated: true, Authenticated: true,
}, },
}) })
...@@ -172,10 +172,10 @@ func (e *L2Engine) RPCClient() client.RPC { ...@@ -172,10 +172,10 @@ func (e *L2Engine) RPCClient() client.RPC {
return testutils.RPCErrFaker{ return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl), RPC: client.NewBaseRPCClient(cl),
ErrFn: func(call []rpc.BatchElem) error { ErrFn: func(call []rpc.BatchElem) error {
if e.failL2RPC == nil { if e.FailL2RPC == nil {
return 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 ...@@ -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 // ActL2RPCFail makes the next L2 RPC request fail with given error
func (e *L2Engine) ActL2RPCFail(t Testing, err 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") t.InvalidAction("already set a mock L2 rpc error")
return return
} }
e.failL2RPC = func(call []rpc.BatchElem) error { e.FailL2RPC = func(call []rpc.BatchElem) error {
e.failL2RPC = nil e.FailL2RPC = nil
return err return err
} }
} }
...@@ -201,13 +201,13 @@ func (e *L2Engine) ActL2RPCFail(t Testing, err error) { ...@@ -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 // ActL2IncludeTx includes the next transaction from the given address in the block that is being built
func (e *L2Engine) ActL2IncludeTx(from common.Address) Action { func (e *L2Engine) ActL2IncludeTx(from common.Address) Action {
return func(t Testing) { return func(t Testing) {
if e.engineApi.ForcedEmpty() { if e.EngineApi.ForcedEmpty() {
e.log.Info("Skipping including a transaction because e.L2ForceEmpty is true") e.log.Info("Skipping including a transaction because e.L2ForceEmpty is true")
return return
} }
tx := firstValidTx(t, from, e.engineApi.PendingIndices, e.eth.TxPool().ContentFrom, e.EthClient().NonceAt) tx := firstValidTx(t, from, e.EngineApi.PendingIndices, e.Eth.TxPool().ContentFrom, e.EthClient().NonceAt)
err := e.engineApi.IncludeTx(tx, from) err := e.EngineApi.IncludeTx(tx, from)
if errors.Is(err, engineapi.ErrNotBuildingBlock) { if errors.Is(err, engineapi.ErrNotBuildingBlock) {
t.InvalidAction(err.Error()) t.InvalidAction(err.Error())
} else if errors.Is(err, engineapi.ErrUsesTooMuchGas) { } else if errors.Is(err, engineapi.ErrUsesTooMuchGas) {
......
package actions package helpers
import ( import (
"encoding/binary" "encoding/binary"
......
package actions package helpers
import ( import (
"context" "context"
......
package actions package helpers
import ( import (
"context" "context"
...@@ -89,7 +89,7 @@ func NewL2Sequencer(t Testing, log log.Logger, l1 derive.L1Fetcher, blobSrc deri ...@@ -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 // ActL2StartBlock starts building of a new L2 block on top of the head
func (s *L2Sequencer) ActL2StartBlock(t Testing) { func (s *L2Sequencer) ActL2StartBlock(t Testing) {
if !s.l2PipelineIdle { if !s.L2PipelineIdle {
t.InvalidAction("cannot start L2 build when derivation is not idle") t.InvalidAction("cannot start L2 build when derivation is not idle")
return return
} }
...@@ -191,22 +191,22 @@ func (s *L2Sequencer) ActBuildL2ToTime(t Testing, target uint64) { ...@@ -191,22 +191,22 @@ func (s *L2Sequencer) ActBuildL2ToTime(t Testing, target uint64) {
} }
func (s *L2Sequencer) ActBuildL2ToEcotone(t Testing) { func (s *L2Sequencer) ActBuildL2ToEcotone(t Testing) {
require.NotNil(t, s.rollupCfg.EcotoneTime, "cannot activate Ecotone when it is not scheduled") require.NotNil(t, s.RollupCfg.EcotoneTime, "cannot activate Ecotone when it is not scheduled")
for s.L2Unsafe().Time < *s.rollupCfg.EcotoneTime { for s.L2Unsafe().Time < *s.RollupCfg.EcotoneTime {
s.ActL2StartBlock(t) s.ActL2StartBlock(t)
s.ActL2EndBlock(t) s.ActL2EndBlock(t)
} }
} }
func (s *L2Sequencer) ActBuildL2ToFjord(t Testing) { func (s *L2Sequencer) ActBuildL2ToFjord(t Testing) {
require.NotNil(t, s.rollupCfg.FjordTime, "cannot activate FjordTime when it is not scheduled") require.NotNil(t, s.RollupCfg.FjordTime, "cannot activate FjordTime when it is not scheduled")
for s.L2Unsafe().Time < *s.rollupCfg.FjordTime { for s.L2Unsafe().Time < *s.RollupCfg.FjordTime {
s.ActL2StartBlock(t) s.ActL2StartBlock(t)
s.ActL2EndBlock(t) s.ActL2EndBlock(t)
} }
} }
func (s *L2Sequencer) ActBuildL2ToGranite(t Testing) { func (s *L2Sequencer) ActBuildL2ToGranite(t Testing) {
require.NotNil(t, s.rollupCfg.GraniteTime, "cannot activate GraniteTime when it is not scheduled") require.NotNil(t, s.RollupCfg.GraniteTime, "cannot activate GraniteTime when it is not scheduled")
for s.L2Unsafe().Time < *s.rollupCfg.GraniteTime { for s.L2Unsafe().Time < *s.RollupCfg.GraniteTime {
s.ActL2StartBlock(t) s.ActL2StartBlock(t)
s.ActL2EndBlock(t) s.ActL2EndBlock(t)
} }
......
package actions package helpers
import ( import (
"context" "context"
...@@ -40,7 +40,7 @@ type L2Verifier struct { ...@@ -40,7 +40,7 @@ type L2Verifier struct {
log log.Logger log log.Logger
eng L2API Eng L2API
syncStatus driver.SyncStatusTracker syncStatus driver.SyncStatusTracker
...@@ -57,10 +57,10 @@ type L2Verifier struct { ...@@ -57,10 +57,10 @@ type L2Verifier struct {
l1 derive.L1Fetcher l1 derive.L1Fetcher
l2PipelineIdle bool L2PipelineIdle bool
l2Building bool l2Building bool
rollupCfg *rollup.Config RollupCfg *rollup.Config
rpc *rpc.Server rpc *rpc.Server
...@@ -160,7 +160,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, ...@@ -160,7 +160,7 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
rollupNode := &L2Verifier{ rollupNode := &L2Verifier{
eventSys: sys, eventSys: sys,
log: log, log: log,
eng: eng, Eng: eng,
engine: ec, engine: ec,
derivation: pipeline, derivation: pipeline,
safeHeadListener: safeHeadListener, safeHeadListener: safeHeadListener,
...@@ -168,9 +168,9 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, ...@@ -168,9 +168,9 @@ func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher,
drainer: executor, drainer: executor,
l1: l1, l1: l1,
syncStatus: syncStatusTracker, syncStatus: syncStatusTracker,
l2PipelineIdle: true, L2PipelineIdle: true,
l2Building: false, l2Building: false,
rollupCfg: cfg, RollupCfg: cfg,
rpc: rpc.NewServer(), rpc: rpc.NewServer(),
synchronousEvents: testActionEmitter, synchronousEvents: testActionEmitter,
} }
...@@ -205,7 +205,7 @@ type l2VerifierBackend struct { ...@@ -205,7 +205,7 @@ type l2VerifierBackend struct {
} }
func (s *l2VerifierBackend) BlockRefWithStatus(ctx context.Context, num uint64) (eth.L2BlockRef, *eth.SyncStatus, error) { 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 return ref, s.verifier.SyncStatus(), err
} }
...@@ -345,9 +345,9 @@ func (s *L2Verifier) OnEvent(ev event.Event) bool { ...@@ -345,9 +345,9 @@ func (s *L2Verifier) OnEvent(ev event.Event) bool {
case rollup.CriticalErrorEvent: case rollup.CriticalErrorEvent:
panic(fmt.Errorf("derivation failed critically: %w", x.Err)) panic(fmt.Errorf("derivation failed critically: %w", x.Err))
case derive.DeriverIdleEvent: case derive.DeriverIdleEvent:
s.l2PipelineIdle = true s.L2PipelineIdle = true
case derive.PipelineStepEvent: case derive.PipelineStepEvent:
s.l2PipelineIdle = false s.L2PipelineIdle = false
case driver.StepReqEvent: case driver.StepReqEvent:
s.synchronousEvents.Emit(driver.StepEvent{}) s.synchronousEvents.Emit(driver.StepEvent{})
default: default:
...@@ -396,7 +396,7 @@ func (s *L2Verifier) ActL2UnsafeGossipReceive(payload *eth.ExecutionPayloadEnvel ...@@ -396,7 +396,7 @@ func (s *L2Verifier) ActL2UnsafeGossipReceive(payload *eth.ExecutionPayloadEnvel
// ActL2InsertUnsafePayload creates an action that can insert an unsafe execution payload // ActL2InsertUnsafePayload creates an action that can insert an unsafe execution payload
func (s *L2Verifier) ActL2InsertUnsafePayload(payload *eth.ExecutionPayloadEnvelope) Action { func (s *L2Verifier) ActL2InsertUnsafePayload(payload *eth.ExecutionPayloadEnvelope) Action {
return func(t Testing) { return func(t Testing) {
ref, err := derive.PayloadToBlockRef(s.rollupCfg, payload.ExecutionPayload) ref, err := derive.PayloadToBlockRef(s.RollupCfg, payload.ExecutionPayload)
require.NoError(t, err) require.NoError(t, err)
err = s.engine.InsertUnsafePayload(t.Ctx(), payload, ref) err = s.engine.InsertUnsafePayload(t.Ctx(), payload, ref)
require.NoError(t, err) require.NoError(t, err)
......
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
}
package actions package helpers
import ( import (
"context" "context"
......
package actions package helpers
import ( import (
"context" "context"
......
package actions package helpers
import ( import (
"fmt" "fmt"
...@@ -131,7 +131,7 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { ...@@ -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().Batcher, dp.DeployConfig.BatchSenderAddress)
require.Equal(t, dp.Secrets.Addresses().Proposer, dp.DeployConfig.L2OutputOracleProposer) 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), batcher := NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp),
seq.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg)) seq.RollupClient(), miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
...@@ -199,7 +199,7 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { ...@@ -199,7 +199,7 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, infoTx.IsDepositTx()) require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled // 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 // regular L2 tx, in new L2 block
alice.L2.ActResetTxOpts(t) alice.L2.ActResetTxOpts(t)
...@@ -320,5 +320,5 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { ...@@ -320,5 +320,5 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, infoTx.IsDepositTx()) require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled // 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())
} }
package actions package helpers
import ( import (
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
......
package actions package interop
import ( import (
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
...@@ -18,24 +19,24 @@ import ( ...@@ -18,24 +19,24 @@ import (
var _ interop.InteropBackend = (*testutils.MockInteropBackend)(nil) var _ interop.InteropBackend = (*testutils.MockInteropBackend)(nil)
func TestInteropVerifier(gt *testing.T) { func TestInteropVerifier(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
// Temporary work-around: interop needs to be active, for cross-safety to not be instant. // 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. // The state genesis in this test is pre-interop however.
sd.RollupCfg.InteropTime = new(uint64) sd.RollupCfg.InteropTime = new(uint64)
logger := testlog.Logger(t, log.LevelDebug) logger := testlog.Logger(t, log.LevelDebug)
seqMockBackend := &testutils.MockInteropBackend{} seqMockBackend := &testutils.MockInteropBackend{}
l1Miner, seqEng, seq := setupSequencerTest(t, sd, logger, l1Miner, seqEng, seq := helpers.SetupSequencerTest(t, sd, logger,
WithVerifierOpts(WithInteropBackend(seqMockBackend))) 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)) seq.RollupClient(), l1Miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg))
verMockBackend := &testutils.MockInteropBackend{} verMockBackend := &testutils.MockInteropBackend{}
_, ver := setupVerifier(t, sd, logger, _, ver := helpers.SetupVerifier(t, sd, logger,
l1Miner.L1Client(t, sd.RollupCfg), l1Miner.BlobStore(), &sync.Config{}, l1Miner.L1Client(t, sd.RollupCfg), l1Miner.BlobStore(), &sync.Config{},
WithInteropBackend(verMockBackend)) helpers.WithInteropBackend(verMockBackend))
seq.ActL2PipelineFull(t) seq.ActL2PipelineFull(t)
ver.ActL2PipelineFull(t) ver.ActL2PipelineFull(t)
......
...@@ -3,7 +3,7 @@ package proofs ...@@ -3,7 +3,7 @@ package proofs
import ( import (
"testing" "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/actions/proofs/helpers"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-program/client/claim" "github.com/ethereum-optimism/optimism/op-program/client/claim"
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
// 5. Instruct the sequencer to derive the L2 chain. // 5. Instruct the sequencer to derive the L2 chain.
// 6. Run the FPP on the safe head. // 6. Run the FPP on the safe head.
func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { func runChannelTimeoutTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
t := actions.NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) { tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) {
// Set the channel timeout to 10 blocks, 12x lower than the sequencing window. // Set the channel timeout to 10 blocks, 12x lower than the sequencing window.
tp.ChannelTimeout = 10 tp.ChannelTimeout = 10
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"testing" "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/actions/proofs/helpers"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-program/client/claim" "github.com/ethereum-optimism/optimism/op-program/client/claim"
...@@ -15,19 +15,19 @@ import ( ...@@ -15,19 +15,19 @@ import (
// garbageKinds is a list of garbage kinds to test. We don't use `INVALID_COMPRESSION` and `MALFORM_RLP` because // 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 // they submit malformed frames always, and this test models a valid channel with a single invalid frame in the
// middle. // middle.
var garbageKinds = []actions.GarbageKind{ var garbageKinds = []actionsHelpers.GarbageKind{
actions.STRIP_VERSION, actionsHelpers.STRIP_VERSION,
actions.RANDOM, actionsHelpers.RANDOM,
actions.TRUNCATE_END, actionsHelpers.TRUNCATE_END,
actions.DIRTY_APPEND, actionsHelpers.DIRTY_APPEND,
} }
// Run a test that submits garbage channel data in the middle of a channel. // Run a test that submits garbage channel data in the middle of a channel.
// //
// channel format ([]Frame): // channel format ([]Frame):
// [f[0 - correct] f_x[1 - bad frame] f[1 - correct]] // [f[0 - correct] f_x[1 - bad frame] f[1 - correct]]
func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actions.GarbageKind]) { func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actionsHelpers.GarbageKind]) {
t := actions.NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) { tp := helpers.NewTestParams(func(tp *e2eutils.TestParams) {
// Set the channel timeout to 10 blocks, 12x lower than the sequencing window. // Set the channel timeout to 10 blocks, 12x lower than the sequencing window.
tp.ChannelTimeout = 10 tp.ChannelTimeout = 10
...@@ -100,7 +100,7 @@ func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actions.Garba ...@@ -100,7 +100,7 @@ func runGarbageChannelTest(gt *testing.T, testCfg *helpers.TestCfg[actions.Garba
} }
func Test_ProgramAction_GarbageChannel(gt *testing.T) { func Test_ProgramAction_GarbageChannel(gt *testing.T) {
matrix := helpers.NewMatrix[actions.GarbageKind]() matrix := helpers.NewMatrix[actionsHelpers.GarbageKind]()
defer matrix.Run(gt) defer matrix.Run(gt)
for _, garbageKind := range garbageKinds { for _, garbageKind := range garbageKinds {
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
altda "github.com/ethereum-optimism/optimism/op-alt-da" altda "github.com/ethereum-optimism/optimism/op-alt-da"
batcherFlags "github.com/ethereum-optimism/optimism/op-batcher/flags" 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-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-program/host" "github.com/ethereum-optimism/optimism/op-program/host"
"github.com/ethereum-optimism/optimism/op-program/host/config" "github.com/ethereum-optimism/optimism/op-program/host/config"
...@@ -25,17 +25,17 @@ import ( ...@@ -25,17 +25,17 @@ import (
// L2FaultProofEnv is a test harness for a fault provable L2 chain. // L2FaultProofEnv is a test harness for a fault provable L2 chain.
type L2FaultProofEnv struct { type L2FaultProofEnv struct {
log log.Logger log log.Logger
Batcher *actions.L2Batcher Batcher *helpers.L2Batcher
Sequencer *actions.L2Sequencer Sequencer *helpers.L2Sequencer
Engine *actions.L2Engine Engine *helpers.L2Engine
engCl *sources.EngineClient engCl *sources.EngineClient
sd *e2eutils.SetupData sd *e2eutils.SetupData
dp *e2eutils.DeployParams dp *e2eutils.DeployParams
Miner *actions.L1Miner Miner *helpers.L1Miner
Alice *actions.CrossLayerUser 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) log := testlog.Logger(t, log.LvlDebug)
dp := NewDeployParams(t, func(dp *e2eutils.DeployParams) { dp := NewDeployParams(t, func(dp *e2eutils.DeployParams) {
genesisBlock := hexutil.Uint64(0) genesisBlock := hexutil.Uint64(0)
...@@ -59,44 +59,44 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut ...@@ -59,44 +59,44 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut
dp.DeployConfig.L2GenesisGraniteTimeOffset = &genesisBlock dp.DeployConfig.L2GenesisGraniteTimeOffset = &genesisBlock
} }
}) })
sd := e2eutils.Setup(t, dp, actions.DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
jwtPath := e2eutils.WriteDefaultJWT(t) 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)) l1Cl, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard))
require.NoError(t, err) 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)) l2EngineCl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg))
require.NoError(t, err) 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}) miner.ActL1SetFeeRecipient(common.Address{0xCA, 0xFE, 0xBA, 0xBE})
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
engCl := engine.EngineClient(t, sd.RollupCfg) engCl := engine.EngineClient(t, sd.RollupCfg)
// Set the batcher key to the secret key of the batcher // Set the batcher key to the secret key of the batcher
batcherCfg.BatcherKey = dp.Secrets.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) addresses := e2eutils.CollectAddresses(sd, dp)
l1EthCl := miner.EthClient() l1EthCl := miner.EthClient()
l2EthCl := engine.EthClient() l2EthCl := engine.EthClient()
l1UserEnv := &actions.BasicUserEnv[*actions.L1Bindings]{ l1UserEnv := &helpers.BasicUserEnv[*helpers.L1Bindings]{
EthCl: l1EthCl, EthCl: l1EthCl,
Signer: types.LatestSigner(sd.L1Cfg.Config), Signer: types.LatestSigner(sd.L1Cfg.Config),
AddressCorpora: addresses, AddressCorpora: addresses,
Bindings: actions.NewL1Bindings(t, l1EthCl), Bindings: helpers.NewL1Bindings(t, l1EthCl),
} }
l2UserEnv := &actions.BasicUserEnv[*actions.L2Bindings]{ l2UserEnv := &helpers.BasicUserEnv[*helpers.L2Bindings]{
EthCl: l2EthCl, EthCl: l2EthCl,
Signer: types.LatestSigner(sd.L2Cfg.Config), Signer: types.LatestSigner(sd.L2Cfg.Config),
AddressCorpora: addresses, 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.L1.SetUserEnv(l1UserEnv)
alice.L2.SetUserEnv(l2UserEnv) alice.L2.SetUserEnv(l2UserEnv)
...@@ -115,16 +115,16 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut ...@@ -115,16 +115,16 @@ func NewL2FaultProofEnv[c any](t actions.Testing, testCfg *TestCfg[c], tp *e2eut
type FixtureInputParam func(f *FixtureInputs) type FixtureInputParam func(f *FixtureInputs)
type CheckResult func(actions.Testing, error) type CheckResult func(helpers.Testing, error)
func ExpectNoError() CheckResult { 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") require.NoError(t, err, "fault proof program should have succeeded")
} }
} }
func ExpectError(expectedErr error) CheckResult { 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") require.ErrorIs(t, err, expectedErr, "fault proof program should have failed with expected error")
} }
} }
...@@ -135,7 +135,7 @@ func WithL2Claim(claim common.Hash) FixtureInputParam { ...@@ -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. // Fetch the pre and post output roots for the fault proof.
preRoot, err := env.Sequencer.RollupClient().OutputAtBlock(t.Ctx(), l2ClaimBlockNum-1) preRoot, err := env.Sequencer.RollupClient().OutputAtBlock(t.Ctx(), l2ClaimBlockNum-1)
require.NoError(t, err) require.NoError(t, err)
...@@ -182,7 +182,7 @@ func (env *L2FaultProofEnv) RunFaultProofProgram(t actions.Testing, l2ClaimBlock ...@@ -182,7 +182,7 @@ func (env *L2FaultProofEnv) RunFaultProofProgram(t actions.Testing, l2ClaimBlock
type TestParam func(p *e2eutils.TestParams) type TestParam func(p *e2eutils.TestParams)
func NewTestParams(params ...TestParam) *e2eutils.TestParams { func NewTestParams(params ...TestParam) *e2eutils.TestParams {
dfault := actions.DefaultRollupTestParams dfault := helpers.DefaultRollupTestParams
for _, apply := range params { for _, apply := range params {
apply(dfault) apply(dfault)
} }
...@@ -191,7 +191,7 @@ func NewTestParams(params ...TestParam) *e2eutils.TestParams { ...@@ -191,7 +191,7 @@ func NewTestParams(params ...TestParam) *e2eutils.TestParams {
type DeployParam func(p *e2eutils.DeployParams) 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()) dfault := e2eutils.MakeDeployParams(t, NewTestParams())
for _, apply := range params { for _, apply := range params {
apply(dfault) apply(dfault)
...@@ -199,10 +199,10 @@ func NewDeployParams(t actions.Testing, params ...DeployParam) *e2eutils.DeployP ...@@ -199,10 +199,10 @@ func NewDeployParams(t actions.Testing, params ...DeployParam) *e2eutils.DeployP
return dfault return dfault
} }
type BatcherCfgParam func(c *actions.BatcherCfg) type BatcherCfgParam func(c *helpers.BatcherCfg)
func NewBatcherCfg(params ...BatcherCfgParam) *actions.BatcherCfg { func NewBatcherCfg(params ...BatcherCfgParam) *helpers.BatcherCfg {
dfault := &actions.BatcherCfg{ dfault := &helpers.BatcherCfg{
MinL1TxSize: 0, MinL1TxSize: 0,
MaxL1TxSize: 128_000, MaxL1TxSize: 128_000,
DataAvailabilityType: batcherFlags.BlobsType, DataAvailabilityType: batcherFlags.BlobsType,
...@@ -216,7 +216,7 @@ func NewBatcherCfg(params ...BatcherCfgParam) *actions.BatcherCfg { ...@@ -216,7 +216,7 @@ func NewBatcherCfg(params ...BatcherCfgParam) *actions.BatcherCfg {
type OpProgramCfgParam func(p *config.Config) type OpProgramCfgParam func(p *config.Config)
func NewOpProgramCfg( func NewOpProgramCfg(
t actions.Testing, t helpers.Testing,
env *L2FaultProofEnv, env *L2FaultProofEnv,
fi *FixtureInputs, fi *FixtureInputs,
params ...OpProgramCfgParam, params ...OpProgramCfgParam,
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"regexp" "regexp"
"strings" "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/client/claim"
"github.com/ethereum-optimism/optimism/op-program/host/config" "github.com/ethereum-optimism/optimism/op-program/host/config"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -48,7 +48,7 @@ type FixtureInputs struct { ...@@ -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. // 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 // [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 { if !dumpFixtures {
return return
} }
......
...@@ -3,7 +3,7 @@ package proofs ...@@ -3,7 +3,7 @@ package proofs
import ( import (
"testing" "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/actions/proofs/helpers"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
// Run a test that proves a deposit-only block generated due to sequence window expiry. // Run a test that proves a deposit-only block generated due to sequence window expiry.
func runSequenceWindowExpireTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { func runSequenceWindowExpireTest(gt *testing.T, testCfg *helpers.TestCfg[any]) {
t := actions.NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
tp := helpers.NewTestParams() tp := helpers.NewTestParams()
env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg()) env := helpers.NewL2FaultProofEnv(t, testCfg, tp, helpers.NewBatcherCfg())
......
...@@ -3,7 +3,7 @@ package proofs ...@@ -3,7 +3,7 @@ package proofs
import ( import (
"testing" "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/actions/proofs/helpers"
"github.com/ethereum-optimism/optimism/op-program/client/claim" "github.com/ethereum-optimism/optimism/op-program/client/claim"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
func runSimpleProgramTest(gt *testing.T, testCfg *helpers.TestCfg[any]) { 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()) env := helpers.NewL2FaultProofEnv(t, testCfg, helpers.NewTestParams(), helpers.NewBatcherCfg())
// Build an empty block on L2 // Build an empty block on L2
......
package actions package proposer
import ( import (
"math/big" "math/big"
"testing" "testing"
"time" "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/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
...@@ -44,24 +46,24 @@ func TestProposerBatchType(t *testing.T) { ...@@ -44,24 +46,24 @@ func TestProposerBatchType(t *testing.T) {
} }
func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
t := NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, actionsHelpers.DefaultRollupTestParams)
applyDeltaTimeOffset(dp, deltaTimeOffset) upgradesHelpers.ApplyDeltaTimeOffset(dp, deltaTimeOffset)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, actionsHelpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
miner, seqEngine, sequencer := setupSequencerTest(t, sd, log) miner, seqEngine, sequencer := actionsHelpers.SetupSequencerTest(t, sd, log)
rollupSeqCl := sequencer.RollupClient() 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)) rollupSeqCl, miner.EthClient(), seqEngine.EthClient(), seqEngine.EngineClient(t, sd.RollupCfg))
var proposer *L2Proposer var proposer *actionsHelpers.L2Proposer
if e2eutils.UseFaultProofs() { if e2eutils.UseFaultProofs() {
optimismPortal2Contract, err := bindingspreview.NewOptimismPortal2(sd.DeploymentsL1.OptimismPortalProxy, miner.EthClient()) optimismPortal2Contract, err := bindingspreview.NewOptimismPortal2(sd.DeploymentsL1.OptimismPortalProxy, miner.EthClient())
require.NoError(t, err) require.NoError(t, err)
respectedGameType, err := optimismPortal2Contract.RespectedGameType(&bind.CallOpts{}) respectedGameType, err := optimismPortal2Contract.RespectedGameType(&bind.CallOpts{})
require.NoError(t, err) require.NoError(t, err)
proposer = NewL2Proposer(t, log, &ProposerCfg{ proposer = actionsHelpers.NewL2Proposer(t, log, &actionsHelpers.ProposerCfg{
DisputeGameFactoryAddr: &sd.DeploymentsL1.DisputeGameFactoryProxy, DisputeGameFactoryAddr: &sd.DeploymentsL1.DisputeGameFactoryProxy,
ProposalInterval: 6 * time.Second, ProposalInterval: 6 * time.Second,
ProposalRetryInterval: 3 * time.Second, ProposalRetryInterval: 3 * time.Second,
...@@ -70,7 +72,7 @@ func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) { ...@@ -70,7 +72,7 @@ func RunProposerTest(gt *testing.T, deltaTimeOffset *hexutil.Uint64) {
AllowNonFinalized: true, AllowNonFinalized: true,
}, miner.EthClient(), rollupSeqCl) }, miner.EthClient(), rollupSeqCl)
} else { } else {
proposer = NewL2Proposer(t, log, &ProposerCfg{ proposer = actionsHelpers.NewL2Proposer(t, log, &actionsHelpers.ProposerCfg{
OutputOracleAddr: &sd.DeploymentsL1.L2OutputOracleProxy, OutputOracleAddr: &sd.DeploymentsL1.L2OutputOracleProxy,
ProposerKey: dp.Secrets.Proposer, ProposerKey: dp.Secrets.Proposer,
ProposalRetryInterval: 3 * time.Second, ProposalRetryInterval: 3 * time.Second,
......
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
}
package actions package safedb
import ( import (
"context" "context"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/ethereum-optimism/optimism/op-node/node/safedb" "github.com/ethereum-optimism/optimism/op-e2e/actions/safedb/helpers"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
"github.com/ethereum-optimism/optimism/op-service/eth" "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/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestRecordSafeHeadUpdates(gt *testing.T) { func TestRecordSafeHeadUpdates(gt *testing.T) {
t := NewDefaultTesting(gt) t := actionsHelpers.NewDefaultTesting(gt)
sd, miner, sequencer, verifier, verifierEng, batcher := setupSafeDBTest(t, DefaultRollupTestParams) sd, miner, sequencer, verifier, verifierEng, batcher := helpers.SetupSafeDBTest(t, actionsHelpers.DefaultRollupTestParams)
verifEngClient := verifierEng.EngineClient(t, sd.RollupCfg) verifEngClient := verifierEng.EngineClient(t, sd.RollupCfg)
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
...@@ -36,7 +33,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { ...@@ -36,7 +33,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) {
// new L1 block with L2 batch // new L1 block with L2 batch
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
batchTx := miner.l1Transactions[0] batchTx := miner.L1Transactions[0]
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
// verifier picks up the L2 chain that was submitted // verifier picks up the L2 chain that was submitted
...@@ -46,7 +43,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { ...@@ -46,7 +43,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) {
require.NotEqual(t, sequencer.L2Safe(), sequencer.L2Unsafe(), "sequencer has not processed L1 yet") require.NotEqual(t, sequencer.L2Safe(), sequencer.L2Unsafe(), "sequencer has not processed L1 yet")
// Verify the safe head is recorded // Verify the safe head is recorded
l1Head := miner.l1Chain.CurrentBlock() l1Head := miner.L1Chain().CurrentBlock()
firstSafeHeadUpdateL1Block := l1Head.Number.Uint64() firstSafeHeadUpdateL1Block := l1Head.Number.Uint64()
response, err := verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block) response, err := verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block)
require.NoError(t, err) require.NoError(t, err)
...@@ -62,7 +59,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { ...@@ -62,7 +59,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) {
// Only genesis is safe at this point // Only genesis is safe at this point
response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block-1) response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block-1)
require.NoError(t, err) 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) 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 // 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) { ...@@ -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 // 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) response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block)
require.NoError(t, err) 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) require.Equal(t, sd.RollupCfg.Genesis.L2, response.SafeHead)
// Now replay the batch tx in a new L1 block // Now replay the batch tx in a new L1 block
...@@ -91,7 +88,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { ...@@ -91,7 +88,7 @@ func TestRecordSafeHeadUpdates(gt *testing.T) {
miner.ActL1SetFeeRecipient(common.Address{'C'}) miner.ActL1SetFeeRecipient(common.Address{'C'})
// note: the geth tx pool reorgLoop is too slow (responds to chain head events, but async), // 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. // 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 // need to re-insert previously included tx into the block
miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
...@@ -105,36 +102,10 @@ func TestRecordSafeHeadUpdates(gt *testing.T) { ...@@ -105,36 +102,10 @@ func TestRecordSafeHeadUpdates(gt *testing.T) {
require.Equal(t, verifier.L2Safe(), ref, "verifier engine matches rollup client") require.Equal(t, verifier.L2Safe(), ref, "verifier engine matches rollup client")
// Verify the safe head is recorded again // Verify the safe head is recorded again
l1Head = miner.l1Chain.CurrentBlock() l1Head = miner.L1Chain().CurrentBlock()
firstSafeHeadUpdateL1Block = l1Head.Number.Uint64() firstSafeHeadUpdateL1Block = l1Head.Number.Uint64()
response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block) response, err = verifier.RollupClient().SafeHeadAtL1Block(context.Background(), firstSafeHeadUpdateL1Block)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, eth.HeaderBlockID(l1Head), response.L1Block) require.Equal(t, eth.HeaderBlockID(l1Head), response.L1Block)
require.Equal(t, verifier.L2Unsafe().ID(), response.SafeHead) 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
}
package actions package sequencer
import ( import (
"math/big" "math/big"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
...@@ -11,33 +12,12 @@ import ( ...@@ -11,33 +12,12 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require" "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-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum-optimism/optimism/op-service/testlog" "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) { func TestL2Sequencer_SequencerDrift(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
p := &e2eutils.TestParams{ p := &e2eutils.TestParams{
MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12) MaxSequencerDrift: 20, // larger than L1 block time we simulate in this test (12)
SequencerWindowSize: 24, SequencerWindowSize: 24,
...@@ -45,9 +25,9 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ...@@ -45,9 +25,9 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) {
L1BlockTime: 12, L1BlockTime: 12,
} }
dp := e2eutils.MakeDeployParams(t, p) dp := e2eutils.MakeDeployParams(t, p)
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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'}) miner.ActL1SetFeeRecipient(common.Address{'A'})
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
...@@ -61,7 +41,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ...@@ -61,7 +41,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) {
ChainID: sd.L2Cfg.Config.ChainID, ChainID: sd.L2Cfg.Config.ChainID,
Nonce: n, Nonce: n,
GasTipCap: big.NewInt(2 * params.GWei), 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, Gas: params.TxGas,
To: &dp.Addresses.Bob, To: &dp.Addresses.Bob,
Value: e2eutils.Ether(2), Value: e2eutils.Ether(2),
...@@ -79,7 +59,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ...@@ -79,7 +59,7 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) {
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
sequencer.ActL1HeadSignal(t) sequencer.ActL1HeadSignal(t)
origin := miner.l1Chain.CurrentBlock() origin := miner.L1Chain().CurrentBlock()
// L2 makes blocks to catch up // L2 makes blocks to catch up
for sequencer.SyncStatus().UnsafeL2.Time+sd.RollupCfg.BlockTime < origin.Time { for sequencer.SyncStatus().UnsafeL2.Time+sd.RollupCfg.BlockTime < origin.Time {
...@@ -104,18 +84,18 @@ func TestL2Sequencer_SequencerDrift(gt *testing.T) { ...@@ -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 // We passed the sequencer drift: we can still keep the old origin, but can't include any txs
sequencer.ActL2KeepL1Origin(t) sequencer.ActL2KeepL1Origin(t)
sequencer.ActL2StartBlock(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 // 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, // 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. // while the verifier-codepath only ever sees the valid post-reorg L1 chain.
func TestL2Sequencer_SequencerOnlyReorg(gt *testing.T) { func TestL2Sequencer_SequencerOnlyReorg(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) 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) 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. // 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. // The rest of the L1 chain will be incorporated as L1 origins into unsafe L2 blocks.
......
package actions package upgrades
import ( import (
"context" "context"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -17,15 +18,15 @@ import ( ...@@ -17,15 +18,15 @@ import (
) )
func TestDencunL1ForkAfterGenesis(gt *testing.T) { func TestDencunL1ForkAfterGenesis(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
offset := hexutil.Uint64(24) offset := hexutil.Uint64(24)
dp.DeployConfig.L1CancunTimeOffset = &offset dp.DeployConfig.L1CancunTimeOffset = &offset
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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.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") require.Nil(t, l1Head.ExcessBlobGas, "Cancun blob gas not in header")
...@@ -39,7 +40,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { ...@@ -39,7 +40,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) {
miner.ActEmptyBlock(t) // Cancun activates here miner.ActEmptyBlock(t) // Cancun activates here
miner.ActEmptyBlock(t) miner.ActEmptyBlock(t)
// verify Cancun is active // 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.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active")
require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header")
...@@ -48,7 +49,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { ...@@ -48,7 +49,7 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) {
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
batcher.ActSubmitAll(t) batcher.ActSubmitAll(t)
miner.ActL1IncludeTx(batcher.batcherAddr)(t) miner.ActL1IncludeTx(batcher.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
// sync verifier // sync verifier
...@@ -60,14 +61,14 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) { ...@@ -60,14 +61,14 @@ func TestDencunL1ForkAfterGenesis(gt *testing.T) {
} }
func TestDencunL1ForkAtGenesis(gt *testing.T) { func TestDencunL1ForkAtGenesis(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
require.Zero(t, *dp.DeployConfig.L1CancunTimeOffset) 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) 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.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active at genesis")
require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header")
...@@ -81,7 +82,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) { ...@@ -81,7 +82,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) {
miner.ActEmptyBlock(t) miner.ActEmptyBlock(t)
// verify Cancun is still active // 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.True(t, sd.L1Cfg.Config.IsCancun(l1Head.Number, l1Head.Time), "Cancun active")
require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header") require.NotNil(t, l1Head.ExcessBlobGas, "Cancun blob gas in header")
...@@ -90,7 +91,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) { ...@@ -90,7 +91,7 @@ func TestDencunL1ForkAtGenesis(gt *testing.T) {
sequencer.ActBuildToL1Head(t) sequencer.ActBuildToL1Head(t)
miner.ActL1StartBlock(12)(t) miner.ActL1StartBlock(12)(t)
batcher.ActSubmitAll(t) batcher.ActSubmitAll(t)
miner.ActL1IncludeTx(batcher.batcherAddr)(t) miner.ActL1IncludeTx(batcher.BatcherAddr)(t)
miner.ActL1EndBlock(t) miner.ActL1EndBlock(t)
// sync verifier // sync verifier
...@@ -117,8 +118,8 @@ func verifyEcotoneBlock(gt *testing.T, header *types.Header) { ...@@ -117,8 +118,8 @@ func verifyEcotoneBlock(gt *testing.T, header *types.Header) {
} }
func TestDencunL2ForkAfterGenesis(gt *testing.T) { func TestDencunL2ForkAfterGenesis(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
require.Zero(t, *dp.DeployConfig.L1CancunTimeOffset) require.Zero(t, *dp.DeployConfig.L1CancunTimeOffset)
// This test wil fork on the second block // This test wil fork on the second block
offset := hexutil.Uint64(dp.DeployConfig.L2BlockTime * 2) offset := hexutil.Uint64(dp.DeployConfig.L2BlockTime * 2)
...@@ -127,56 +128,56 @@ func TestDencunL2ForkAfterGenesis(gt *testing.T) { ...@@ -127,56 +128,56 @@ func TestDencunL2ForkAfterGenesis(gt *testing.T) {
dp.DeployConfig.L2GenesisGraniteTimeOffset = nil dp.DeployConfig.L2GenesisGraniteTimeOffset = nil
// New forks have to be added here, after changing the default deploy config! // 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) 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 // start op-nodes
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
verifier.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t)
// Genesis block is pre-ecotone // Genesis block is pre-ecotone
verifyPreEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyPreEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
// Block before fork block // Block before fork block
sequencer.ActL2StartBlock(t) sequencer.ActL2StartBlock(t)
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
verifyPreEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyPreEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
// Fork block is ecotone // Fork block is ecotone
sequencer.ActL2StartBlock(t) sequencer.ActL2StartBlock(t)
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
// Blocks post fork have Ecotone properties // Blocks post fork have Ecotone properties
sequencer.ActL2StartBlock(t) sequencer.ActL2StartBlock(t)
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
} }
func TestDencunL2ForkAtGenesis(gt *testing.T) { func TestDencunL2ForkAtGenesis(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
require.Zero(t, *dp.DeployConfig.L2GenesisEcotoneTimeOffset) 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) 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 // start op-nodes
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
verifier.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t)
// Genesis block has ecotone properties // Genesis block has ecotone properties
verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
// Blocks post fork have Ecotone properties // Blocks post fork have Ecotone properties
sequencer.ActL2StartBlock(t) sequencer.ActL2StartBlock(t)
sequencer.ActL2EndBlock(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) txData := transactions.CreateEmptyBlobTx(true, dp.DeployConfig.L2ChainID)
// Manual signer creation, so we can sign a blob tx on the chain, // Manual signer creation, so we can sign a blob tx on the chain,
// even though we have disabled cancun signer support in Ecotone. // even though we have disabled cancun signer support in Ecotone.
...@@ -186,17 +187,17 @@ func aliceSimpleBlobTx(t Testing, dp *e2eutils.DeployParams) *types.Transaction ...@@ -186,17 +187,17 @@ func aliceSimpleBlobTx(t Testing, dp *e2eutils.DeployParams) *types.Transaction
return tx 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) 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. // TestDencunBlobTxRPC tries to send a Blob tx to the L2 engine via RPC, it should not be accepted.
func TestDencunBlobTxRPC(gt *testing.T) { func TestDencunBlobTxRPC(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) 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) log := testlog.Logger(t, log.LevelDebug)
engine := newEngine(t, sd, log) engine := newEngine(t, sd, log)
cl := engine.EthClient() cl := engine.EthClient()
...@@ -207,31 +208,31 @@ func TestDencunBlobTxRPC(gt *testing.T) { ...@@ -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. // TestDencunBlobTxInTxPool tries to insert a blob tx directly into the tx pool, it should not be accepted.
func TestDencunBlobTxInTxPool(gt *testing.T) { func TestDencunBlobTxInTxPool(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) 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) log := testlog.Logger(t, log.LevelDebug)
engine := newEngine(t, sd, log) engine := newEngine(t, sd, log)
tx := aliceSimpleBlobTx(t, dp) 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") 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. // TestDencunBlobTxInclusion tries to send a Blob tx to the L2 engine, it should not be accepted.
func TestDencunBlobTxInclusion(gt *testing.T) { func TestDencunBlobTxInclusion(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) 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) log := testlog.Logger(t, log.LevelDebug)
_, engine, sequencer := setupSequencerTest(t, sd, log) _, engine, sequencer := helpers.SetupSequencerTest(t, sd, log)
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
tx := aliceSimpleBlobTx(t, dp) tx := aliceSimpleBlobTx(t, dp)
sequencer.ActL2StartBlock(t) 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") require.ErrorContains(t, err, "invalid L2 block (tx 1): failed to apply transaction to L2 block (tx 1): transaction type not supported")
} }
package actions package upgrades
import ( import (
"context" "context"
"math/big" "math/big"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -30,7 +31,7 @@ var ( ...@@ -30,7 +31,7 @@ var (
// verifyCodeHashMatches checks that the has of the code at the given address matches the expected code-hash. // 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. // It also sanity-checks that the code is not empty: we should never deploy empty contract codes.
// Returns the contract code // 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) code, err := client.CodeAt(context.Background(), address, nil)
require.NoError(t, err) require.NoError(t, err)
require.NotEmpty(t, code) require.NotEmpty(t, code)
...@@ -40,8 +41,8 @@ func verifyCodeHashMatches(t Testing, client *ethclient.Client, address common.A ...@@ -40,8 +41,8 @@ func verifyCodeHashMatches(t Testing, client *ethclient.Client, address common.A
} }
func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) { func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
ecotoneOffset := hexutil.Uint64(4) ecotoneOffset := hexutil.Uint64(4)
log := testlog.Logger(t, log.LevelDebug) log := testlog.Logger(t, log.LevelDebug)
...@@ -54,8 +55,8 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) { ...@@ -54,8 +55,8 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) {
// New forks have to be added here... // New forks have to be added here...
require.NoError(t, dp.DeployConfig.Check(log), "must have valid config") require.NoError(t, dp.DeployConfig.Check(log), "must have valid config")
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
_, _, miner, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) _, _, miner, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log)
ethCl := engine.EthClient() ethCl := engine.EthClient()
// build a single block to move away from the genesis with 0-values in L1Block contract // 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) { ...@@ -238,8 +239,8 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) {
// TestEcotoneBeforeL1 tests that the L2 Ecotone fork can activate before L1 Dencun does // TestEcotoneBeforeL1 tests that the L2 Ecotone fork can activate before L1 Dencun does
func TestEcotoneBeforeL1(gt *testing.T) { func TestEcotoneBeforeL1(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
offset := hexutil.Uint64(0) offset := hexutil.Uint64(0)
farOffset := hexutil.Uint64(10000) farOffset := hexutil.Uint64(10000)
dp.DeployConfig.L2GenesisRegolithTimeOffset = &offset dp.DeployConfig.L2GenesisRegolithTimeOffset = &offset
...@@ -248,19 +249,19 @@ func TestEcotoneBeforeL1(gt *testing.T) { ...@@ -248,19 +249,19 @@ func TestEcotoneBeforeL1(gt *testing.T) {
dp.DeployConfig.L2GenesisDeltaTimeOffset = &offset dp.DeployConfig.L2GenesisDeltaTimeOffset = &offset
dp.DeployConfig.L2GenesisEcotoneTimeOffset = &offset dp.DeployConfig.L2GenesisEcotoneTimeOffset = &offset
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
log := testlog.Logger(t, log.LevelDebug) 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 // start op-nodes
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
verifier.ActL2PipelineFull(t) verifier.ActL2PipelineFull(t)
// Genesis block has ecotone properties // Genesis block has ecotone properties
verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
// Blocks post fork have Ecotone properties // Blocks post fork have Ecotone properties
sequencer.ActL2StartBlock(t) sequencer.ActL2StartBlock(t)
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
verifyEcotoneBlock(gt, engine.l2Chain.CurrentBlock()) verifyEcotoneBlock(gt, engine.L2Chain().CurrentBlock())
} }
package actions package upgrades
import ( import (
"context" "context"
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/ethereum-optimism/optimism/op-service/predeploys" "github.com/ethereum-optimism/optimism/op-service/predeploys"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -29,8 +30,8 @@ var ( ...@@ -29,8 +30,8 @@ var (
) )
func TestFjordNetworkUpgradeTransactions(gt *testing.T) { func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
t := NewDefaultTesting(gt) t := helpers.NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, helpers.DefaultRollupTestParams)
genesisBlock := hexutil.Uint64(0) genesisBlock := hexutil.Uint64(0)
fjordOffset := hexutil.Uint64(2) fjordOffset := hexutil.Uint64(2)
...@@ -46,8 +47,8 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) { ...@@ -46,8 +47,8 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
dp.DeployConfig.L2GenesisFjordTimeOffset = &fjordOffset dp.DeployConfig.L2GenesisFjordTimeOffset = &fjordOffset
require.NoError(t, dp.DeployConfig.Check(log), "must have valid config") require.NoError(t, dp.DeployConfig.Check(log), "must have valid config")
sd := e2eutils.Setup(t, dp, DefaultAlloc) sd := e2eutils.Setup(t, dp, helpers.DefaultAlloc)
_, _, _, sequencer, engine, verifier, _, _ := setupReorgTestActors(t, dp, sd, log) _, _, _, sequencer, engine, verifier, _, _ := helpers.SetupReorgTestActors(t, dp, sd, log)
ethCl := engine.EthClient() ethCl := engine.EthClient()
// start op-nodes // start op-nodes
......
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
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment