-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cafe736
commit f24a759
Showing
3 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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") | ||
} |