Commit 5bc3311c authored by Matthew Slipper's avatar Matthew Slipper Committed by Kelvin Fichter

Add fixes and additional checks

- Don't exit early from iterators
- Check against an explicit mapping between storage slots and their values
- Add explicit checks for values in the L1Block contract
- Set GasUsed to zero in transition
parent 9f6106ae
...@@ -9,6 +9,10 @@ import ( ...@@ -9,6 +9,10 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"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/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
...@@ -195,7 +199,22 @@ func main() { ...@@ -195,7 +199,22 @@ func main() {
return err return err
} }
if err := genesis.PostCheckMigratedDB(postLDB, migrationData, &config.L1CrossDomainMessengerProxy, config.L1ChainID); err != nil { if err := genesis.PostCheckMigratedDB(
postLDB,
migrationData,
&config.L1CrossDomainMessengerProxy,
config.L1ChainID,
config.FinalSystemOwner,
&derive.L1BlockInfo{
Number: block.NumberU64(),
Time: block.Time(),
BaseFee: block.BaseFee(),
BlockHash: block.Hash(),
BatcherAddr: config.BatchSenderAddress,
L1FeeOverhead: eth.Bytes32(common.BigToHash(new(big.Int).SetUint64(config.GasPriceOracleOverhead))),
L1FeeScalar: eth.Bytes32(common.BigToHash(new(big.Int).SetUint64(config.GasPriceOracleScalar))),
},
); err != nil {
return err return err
} }
......
...@@ -32,7 +32,9 @@ func PreCheckWithdrawals(db *state.StateDB, withdrawals []*LegacyWithdrawal) ([] ...@@ -32,7 +32,9 @@ func PreCheckWithdrawals(db *state.StateDB, withdrawals []*LegacyWithdrawal) ([]
// of the ABI encoding of "true". Although there should not be any other storage slots, we // of the ABI encoding of "true". Although there should not be any other storage slots, we
// can safely ignore anything that is not "true". // can safely ignore anything that is not "true".
if value != abiTrue { if value != abiTrue {
return false // Should not happen!
log.Error("found unknown slot in LegacyMessagePasser", "key", key.String(), "val", value.String())
return true
} }
// Slot exists, so add it to the map. // Slot exists, so add it to the map.
......
...@@ -72,7 +72,7 @@ func PreCheckBalances(ldb ethdb.Database, db *state.StateDB, addresses []common. ...@@ -72,7 +72,7 @@ func PreCheckBalances(ldb ethdb.Database, db *state.StateDB, addresses []common.
err = db.ForEachStorage(predeploys.LegacyERC20ETHAddr, func(key, value common.Hash) bool { err = db.ForEachStorage(predeploys.LegacyERC20ETHAddr, func(key, value common.Hash) bool {
// We can safely ignore specific slots (totalSupply, name, symbol). // We can safely ignore specific slots (totalSupply, name, symbol).
if ignoredSlots[key] { if ignoredSlots[key] {
return false return true
} }
// Slot exists, so add it to the map. // Slot exists, so add it to the map.
......
This diff is collapsed.
...@@ -218,7 +218,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m ...@@ -218,7 +218,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
Difficulty: common.Big0, Difficulty: common.Big0,
Number: new(big.Int).Add(header.Number, common.Big1), Number: new(big.Int).Add(header.Number, common.Big1),
GasLimit: (uint64)(config.L2GenesisBlockGasLimit), GasLimit: (uint64)(config.L2GenesisBlockGasLimit),
GasUsed: (uint64)(config.L2GenesisBlockGasLimit) * config.EIP1559Elasticity, GasUsed: 0,
Time: uint64(config.L2OutputOracleStartingTimestamp), Time: uint64(config.L2OutputOracleStartingTimestamp),
Extra: BedrockTransitionBlockExtraData, Extra: BedrockTransitionBlockExtraData,
MixDigest: common.Hash{}, MixDigest: common.Hash{},
......
...@@ -29,6 +29,8 @@ require ( ...@@ -29,6 +29,8 @@ require (
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e // indirect github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
......
This diff is collapsed.
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