Skip to content
59 changes: 45 additions & 14 deletions op-bindings/bindings/l2tol1messagepasser.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions op-bindings/bindings/l2tol1messagepasser_more.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 41 additions & 15 deletions op-chain-ops/ether/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
}
)

func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances []*migration.Allowance, chainID int, commit bool) (common.Hash, error) {
func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances []*migration.Allowance, chainID int, commit, noCheck bool) (common.Hash, error) {
// Set of addresses that we will be migrating.
addressesToMigrate := make(map[common.Address]bool)
// Set of storage slots that we expect to see in the OVM ETH contract.
Expand Down Expand Up @@ -125,7 +125,11 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
default:
// Check if this slot is a variable. If it isn't, abort.
if !ignoredSlots[k] {
log.Crit("missed storage key", "k", k.String(), "v", v.String())
if noCheck {
log.Error("missed storage key", "k", k.String(), "v", v.String())
} else {
log.Crit("missed storage key", "k", k.String(), "v", v.String())
}
}
}

Expand All @@ -137,13 +141,23 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// had supply bugs.
delta := new(big.Int).Sub(totalSupply, totalFound)
if delta.Cmp(params.ExpectedSupplyDelta) != 0 {
log.Crit(
"supply mismatch",
"migrated", totalFound.String(),
"supply", totalSupply.String(),
"delta", delta.String(),
"exp_delta", params.ExpectedSupplyDelta.String(),
)
if noCheck {
log.Error(
"supply mismatch",
"migrated", totalFound.String(),
"supply", totalSupply.String(),
"delta", delta.String(),
"exp_delta", params.ExpectedSupplyDelta.String(),
)
} else {
log.Crit(
"supply mismatch",
"migrated", totalFound.String(),
"supply", totalSupply.String(),
"delta", delta.String(),
"exp_delta", params.ExpectedSupplyDelta.String(),
)
}
}

log.Info(
Expand Down Expand Up @@ -181,7 +195,11 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances

// No accounts should have a balance in state. If they do, bail.
if data.Balance.Sign() > 0 {
log.Crit("account has non-zero balance in state - should never happen", "addr", addr)
if noCheck {
log.Error("account has non-zero balance in state - should never happen", "addr", addr)
} else {
log.Crit("account has non-zero balance in state - should never happen", "addr", addr)
}
}

// Actually perform the migration by setting the appropriate values in state.
Expand Down Expand Up @@ -214,11 +232,19 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// Make sure that the amount we migrated matches the amount in
// our original state.
if totalMigrated.Cmp(totalFound) != 0 {
log.Crit(
"total migrated does not equal total OVM eth found",
"migrated", totalMigrated,
"found", totalFound,
)
if noCheck {
log.Debug(
"total migrated does not equal total OVM eth found",
"migrated", totalMigrated,
"found", totalFound,
)
} else {
log.Crit(
"total migrated does not equal total OVM eth found",
"migrated", totalMigrated,
"found", totalFound,
)
}
}

// Set the total supply to 0
Expand Down
6 changes: 1 addition & 5 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"math/big"
"os"
"path/filepath"
Expand Down Expand Up @@ -333,11 +332,8 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.Storage
return storage, errors.New("block base fee not set")
}

// Set the initial L2ToL1MessagePasser nonce to
// `type(uint32).max` to prevent nonce collisions
// with historical withdrawals.
storage["L2ToL1MessagePasser"] = state.StorageValues{
"nonce": math.MaxUint32,
"msgNonce": 0,
}
storage["L2CrossDomainMessenger"] = state.StorageValues{
"_initialized": 1,
Expand Down
2 changes: 1 addition & 1 deletion op-chain-ops/genesis/db_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m

log.Info("Starting to migrate ERC20 ETH")
addrs := migrationData.Addresses()
newRoot, err := ether.MigrateLegacyETH(ldb, addrs, migrationData.OvmAllowances, int(config.L1ChainID), commit)
newRoot, err := ether.MigrateLegacyETH(ldb, addrs, migrationData.OvmAllowances, int(config.L1ChainID), commit, noCheck)
if err != nil {
return nil, fmt.Errorf("cannot migrate legacy eth: %w", err)
}
Expand Down
18 changes: 9 additions & 9 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageSucceeds() (gas: 53204)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageToSystemContract() (gas: 36172)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageV0Fails() (gas: 18870)
L2CrossDomainMessenger_Test:test_L2MessengerRelayShouldRevertIfPaused() (gas: 41596)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 122423)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 134632)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 122533)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 134716)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 10568)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 52615)
L2OutputOracleTest:testCannot_ProposeWithUnmatchedBlockhash() (gas: 29434)
Expand Down Expand Up @@ -118,13 +118,13 @@ L2StandardBridge_Test:test_finalizeBridgeETH_sendToMessengerReverts() (gas: 2396
L2StandardBridge_Test:test_finalizeBridgeETH_sendToSelfReverts() (gas: 23793)
L2StandardBridge_Test:test_finalizeDeposit() (gas: 89363)
L2StandardBridge_Test:test_initialize() (gas: 10536)
L2StandardBridge_Test:test_receive() (gas: 131820)
L2StandardBridge_Test:test_withdraw() (gas: 343951)
L2StandardBridge_Test:test_withdrawTo() (gas: 344680)
L2StandardBridge_Test:test_receive() (gas: 131862)
L2StandardBridge_Test:test_withdraw() (gas: 343984)
L2StandardBridge_Test:test_withdrawTo() (gas: 344713)
L2StandardBridge_Test:test_withdraw_onlyEOA() (gas: 251816)
L2ToL1MessagePasserTest:test_burn() (gas: 112530)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromContract() (gas: 70246)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromEOA() (gas: 75764)
L2ToL1MessagePasserTest:test_burn() (gas: 112594)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromContract() (gas: 70356)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromEOA() (gas: 75874)
LegacyERC20ETH_Test:test_approve() (gas: 10723)
LegacyERC20ETH_Test:test_burn() (gas: 10615)
LegacyERC20ETH_Test:test_crossDomain() (gas: 6339)
Expand Down Expand Up @@ -293,4 +293,4 @@ SequencerFeeVault_Test:test_constructor() (gas: 5459)
SequencerFeeVault_Test:test_minWithdrawalAmount() (gas: 5418)
SequencerFeeVault_Test:test_receive() (gas: 17316)
SequencerFeeVault_Test:test_revertWithdraw() (gas: 9343)
SequencerFeeVault_Test:test_withdraw() (gas: 135837)
SequencerFeeVault_Test:test_withdraw() (gas: 135879)
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/.storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
+============================================================================================================================+
| sentMessages | mapping(bytes32 => bool) | 0 | 0 | 32 | contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser |
|--------------+--------------------------+------+--------+-------+----------------------------------------------------------|
| nonce | uint256 | 1 | 0 | 32 | contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser |
| msgNonce | uint240 | 1 | 0 | 30 | contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser |
+--------------+--------------------------+------+--------+-------+----------------------------------------------------------+

=======================
Expand Down
Loading