From 2bbb7c3ca893c220dc8a4568519e5f461ae2fbfa Mon Sep 17 00:00:00 2001 From: Paul Lange Date: Tue, 1 Oct 2024 16:40:22 +0200 Subject: [PATCH 1/2] migration: Use deterministic default for migration block timestamp --- op-chain-ops/cmd/celo-migrate/state.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/op-chain-ops/cmd/celo-migrate/state.go b/op-chain-ops/cmd/celo-migrate/state.go index 1fbf26e025ae..80eb21618143 100644 --- a/op-chain-ops/cmd/celo-migrate/state.go +++ b/op-chain-ops/cmd/celo-migrate/state.go @@ -6,7 +6,6 @@ import ( "fmt" "math/big" "os" - "time" "github.com/ethereum-optimism/optimism/op-chain-ops/genesis" "github.com/ethereum-optimism/optimism/op-service/jsonutil" @@ -157,7 +156,9 @@ func applyStateMigrationChanges(config *genesis.DeployConfig, l2Allocs types.Gen } if migrationBlockTime == 0 { - migrationBlockTime = uint64(time.Now().Unix()) + // If the migration block time is not set, use the time of the last block incremented by one. + // This makes sure the migration is deterministic. + migrationBlockTime = header.Time + config.L2BlockTime } // Set the standard options. From 34ba0ba52c71838425ccb5ef9e4e8d4663912ff4 Mon Sep 17 00:00:00 2001 From: alecps Date: Thu, 3 Oct 2024 15:28:00 -0400 Subject: [PATCH 2/2] make migration-block-time a required flag --- op-chain-ops/cmd/celo-migrate/main.go | 5 +++-- op-chain-ops/cmd/celo-migrate/state.go | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/op-chain-ops/cmd/celo-migrate/main.go b/op-chain-ops/cmd/celo-migrate/main.go index e8d1b87c7a8b..b23f2461adc5 100644 --- a/op-chain-ops/cmd/celo-migrate/main.go +++ b/op-chain-ops/cmd/celo-migrate/main.go @@ -66,8 +66,9 @@ var ( Required: true, } migrationBlockTimeFlag = &cli.Uint64Flag{ - Name: "migration-block-time", - Usage: "Specifies a unix timestamp to use for the migration block. If not provided, the current time will be used.", + Name: "migration-block-time", + Usage: "Specifies a unix timestamp to use for the migration block. This should be set to the same timestamp as was used for the sequencer migration. If performing the sequencer migration, this should set to a time in the future around when the migration script is expected to complete.", + Required: true, } oldDBPathFlag = &cli.PathFlag{ Name: "old-db", diff --git a/op-chain-ops/cmd/celo-migrate/state.go b/op-chain-ops/cmd/celo-migrate/state.go index 80eb21618143..6bf998db22a3 100644 --- a/op-chain-ops/cmd/celo-migrate/state.go +++ b/op-chain-ops/cmd/celo-migrate/state.go @@ -155,12 +155,6 @@ func applyStateMigrationChanges(config *genesis.DeployConfig, l2Allocs types.Gen return nil, err } - if migrationBlockTime == 0 { - // If the migration block time is not set, use the time of the last block incremented by one. - // This makes sure the migration is deterministic. - migrationBlockTime = header.Time + config.L2BlockTime - } - // Set the standard options. cfg.LondonBlock = migrationBlockNumber cfg.BerlinBlock = migrationBlockNumber