Skip to content

Commit

Permalink
add holocene fork action test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianst committed Oct 17, 2024
1 parent cafe736 commit f24a759
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 1 deletion.
55 changes: 55 additions & 0 deletions op-e2e/actions/helpers/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package helpers

import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
"github.com/ethereum-optimism/optimism/op-service/testlog"
)

type Env struct {
Log log.Logger
Logs *testlog.CapturingHandler

SetupData *e2eutils.SetupData

Miner *L1Miner
Seq *L2Sequencer
SeqEngine *L2Engine
Verifier *L2Verifier
VerifEngine *L2Engine
Batcher *L2Batcher
}

func SetupEnv(t StatefulTesting) (env Env) {
dp := e2eutils.MakeDeployParams(t, DefaultRollupTestParams())
genesisOffset := hexutil.Uint64(0)

log, logs := testlog.CaptureLogger(t, log.LevelDebug)
env.Log, env.Logs = log, logs

// Activate Holocene at genesis
// TODO: make configurabe
dp.DeployConfig.L2GenesisRegolithTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisCanyonTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisDeltaTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisFjordTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisGraniteTimeOffset = &genesisOffset
dp.DeployConfig.L2GenesisHoloceneTimeOffset = &genesisOffset

sd := e2eutils.Setup(t, dp, DefaultAlloc)
env.SetupData = sd
env.Miner, env.SeqEngine, env.Seq = SetupSequencerTest(t, sd, log)
env.Miner.ActL1SetFeeRecipient(common.Address{'A'})
env.Seq.ActL2PipelineFull(t)
env.VerifEngine, env.Verifier = SetupVerifier(t, sd, log, env.Miner.L1Client(t, sd.RollupCfg), env.Miner.BlobStore(), &sync.Config{})
rollupSeqCl := env.Seq.RollupClient()
env.Batcher = NewL2Batcher(log, sd.RollupCfg, DefaultBatcherCfg(dp),
rollupSeqCl, env.Miner.EthClient(), env.SeqEngine.EthClient(), env.SeqEngine.EngineClient(t, sd.RollupCfg))

return
}
20 changes: 19 additions & 1 deletion op-e2e/actions/upgrades/helpers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
// ApplyDeltaTimeOffset adjusts fork configuration to not conflict with the delta overrides
func ApplyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Uint64) {
dp.DeployConfig.L2GenesisDeltaTimeOffset = deltaTimeOffset
dp.DeployConfig.L2GenesisGraniteTimeOffset = nil
// configure Ecotone to not be before Delta accidentally
if dp.DeployConfig.L2GenesisEcotoneTimeOffset != nil {
if deltaTimeOffset == nil {
Expand All @@ -17,6 +16,7 @@ func ApplyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Ui
dp.DeployConfig.L2GenesisEcotoneTimeOffset = deltaTimeOffset
}
}

// configure Fjord to not be before Delta accidentally
if dp.DeployConfig.L2GenesisFjordTimeOffset != nil {
if deltaTimeOffset == nil {
Expand All @@ -25,4 +25,22 @@ func ApplyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Ui
dp.DeployConfig.L2GenesisFjordTimeOffset = deltaTimeOffset
}
}

// configure Granite to not be before Delta accidentally
if dp.DeployConfig.L2GenesisGraniteTimeOffset != nil {
if deltaTimeOffset == nil {
dp.DeployConfig.L2GenesisGraniteTimeOffset = nil
} else if *dp.DeployConfig.L2GenesisGraniteTimeOffset < *deltaTimeOffset {
dp.DeployConfig.L2GenesisGraniteTimeOffset = deltaTimeOffset
}
}

// configure Holocene to not be before Delta accidentally
if dp.DeployConfig.L2GenesisHoloceneTimeOffset != nil {
if deltaTimeOffset == nil {
dp.DeployConfig.L2GenesisHoloceneTimeOffset = nil
} else if *dp.DeployConfig.L2GenesisHoloceneTimeOffset < *deltaTimeOffset {
dp.DeployConfig.L2GenesisHoloceneTimeOffset = deltaTimeOffset
}
}
}
59 changes: 59 additions & 0 deletions op-e2e/actions/upgrades/holocene_fork_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package upgrades

import (
"testing"

"github.com/ethereum-optimism/optimism/op-e2e/actions/helpers"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/stretchr/testify/require"
)

func TestHoloceneActivationAtGenesis(gt *testing.T) {
t := helpers.NewDefaultTesting(gt)
env := helpers.SetupEnv(t)

// Start op-nodes
env.Seq.ActL2PipelineFull(t)
env.Verifier.ActL2PipelineFull(t)

// Verify Holocene is active at genesis
l2Head := env.Seq.L2Unsafe()
require.NotZero(t, l2Head.Hash)
require.True(t, env.SetupData.RollupCfg.IsHolocene(l2Head.Time), "Holocene should be active at genesis")

// Advance the L1 chain
env.Miner.ActEmptyBlock(t)
env.Miner.ActEmptyBlock(t)

// build empty L1 block
env.Miner.ActEmptyBlock(t)
// finalize it, so the L1 geth blob pool doesn't log errors about missing finality
env.Miner.ActL1SafeNext(t)
env.Miner.ActL1FinalizeNext(t)

// Build L2 chain and advance safe head
env.Seq.ActL1HeadSignal(t)
env.Seq.ActBuildToL1Head(t)

// verify in logs that stage transformations happened
recs := env.Logs.FindLogs(testlog.NewMessageContainsFilter("transforming to Holocene"), testlog.NewAttributesFilter("role", e2esys.RoleSeq))
require.Len(t, recs, 3)
recs = env.Logs.FindLogs(testlog.NewMessageContainsFilter("transforming to Holocene"), testlog.NewAttributesFilter("role", e2esys.RoleVerif))
require.Len(t, recs, 3)

// Submit L2
env.Batcher.ActSubmitAll(t)
batchTx := env.Batcher.LastSubmitted

// new L1 block with L2 batch
env.Miner.ActL1StartBlock(12)(t)
env.Miner.ActL1IncludeTxByHash(batchTx.Hash())(t)
env.Miner.ActL1EndBlock(t)

// env.Verifier picks up the L2 chain that was submitted
env.Verifier.ActL1HeadSignal(t)
env.Verifier.ActL2PipelineFull(t)
require.Equal(t, env.Verifier.L2Safe(), env.Seq.L2Unsafe(), "verifier syncs from sequencer via L1")
require.NotEqual(t, env.Seq.L2Safe(), env.Seq.L2Unsafe(), "sequencer has not processed L1 yet")
}

0 comments on commit f24a759

Please sign in to comment.