Commit 33be0e65 authored by Mark Tyneway's avatar Mark Tyneway

op-migrate: various sanity checks + cleanup

Adds cleanup to the migration script, ensures that
config is sane.

We cannot allow for non monotonic block time. We also
try to make eip 1159 stable at start and use a hardcoded
initial base fee.

Add additional logging
parent 1a24329e
......@@ -120,6 +120,9 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
}
log.Info("Completed ERC20 ETH migration", "root", newRoot)
// Set the amount of gas used so that EIP 1559 starts off stable
gasUsed := (uint64)(config.L2GenesisBlockGasLimit) * config.EIP1559Elasticity
// Create the bedrock transition block
bedrockHeader := &types.Header{
ParentHash: header.Hash(),
......@@ -132,16 +135,25 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
Difficulty: common.Big0,
Number: new(big.Int).Add(header.Number, common.Big1),
GasLimit: (uint64)(config.L2GenesisBlockGasLimit),
GasUsed: 0,
GasUsed: gasUsed,
Time: uint64(config.L2OutputOracleStartingTimestamp),
Extra: bedrockTransitionBlockExtraData,
MixDigest: common.Hash{},
Nonce: types.BlockNonce{},
BaseFee: (*big.Int)(config.L2GenesisBlockBaseFeePerGas),
BaseFee: big.NewInt(params.InitialBaseFee),
}
bedrockBlock := types.NewBlock(bedrockHeader, nil, nil, nil, trie.NewStackTrie(nil))
log.Info(
"Built Bedrock transition",
"hash", bedrockBlock.Hash(),
"root", bedrockBlock.Root(),
"number", bedrockBlock.NumberU64(),
"gas-used", bedrockBlock.GasUsed(),
"gas-limit", bedrockBlock.GasLimit(),
)
res := &MigrationResult{
TransitionHeight: bedrockBlock.NumberU64(),
TransitionTimestamp: bedrockBlock.Time(),
......@@ -183,6 +195,12 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
}
rawdb.WriteChainConfig(ldb, genesisHash, cfg)
log.Info(
"wrote chain config",
"1559-denominator", config.EIP1559Denominator,
"1559-elasticity", config.EIP1559Elasticity,
)
log.Info(
"wrote Bedrock transition block",
"height", bedrockHeader.Number,
......
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