From c69870c7fec537148436596164b188c78bdca2cb Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 30 Nov 2022 18:40:56 -0800 Subject: [PATCH 1/2] op-chain-ops: add no check to eth migration --- op-chain-ops/ether/migrate.go | 56 ++++++++++++++++++++-------- op-chain-ops/genesis/db_migration.go | 2 +- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/op-chain-ops/ether/migrate.go b/op-chain-ops/ether/migrate.go index 8785b5320b51c..abbbd66750a72 100644 --- a/op-chain-ops/ether/migrate.go +++ b/op-chain-ops/ether/migrate.go @@ -33,7 +33,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. @@ -120,7 +120,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()) + } } } @@ -132,13 +136,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( @@ -176,7 +190,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. @@ -209,11 +227,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 diff --git a/op-chain-ops/genesis/db_migration.go b/op-chain-ops/genesis/db_migration.go index f9453f169172d..b7becebf7aff0 100644 --- a/op-chain-ops/genesis/db_migration.go +++ b/op-chain-ops/genesis/db_migration.go @@ -107,7 +107,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) } From b6af427985fa8ba889e963e96d7d33e8dbc1fbf7 Mon Sep 17 00:00:00 2001 From: Kelvin Fichter Date: Wed, 30 Nov 2022 20:31:44 -0500 Subject: [PATCH 2/2] feat(ctb): add message versioning to MessagePasser Adds message versioning to the L2ToL1MessagePasser, using the same scheme as in the CrossDomainMessenger. Also renames the "nonce" variable to "messageNonce" in line with the naming within the CrossDomainMessenger contracts. --- op-bindings/bindings/l2tol1messagepasser.go | 59 ++++++++++++++----- .../bindings/l2tol1messagepasser_more.go | 4 +- op-chain-ops/genesis/config.go | 6 +- packages/contracts-bedrock/.gas-snapshot | 18 +++--- packages/contracts-bedrock/.storage-layout | 2 +- .../contracts/L2/L2ToL1MessagePasser.sol | 48 +++++++++++---- .../test/L2CrossDomainMessenger.t.sol | 4 +- .../contracts/test/L2ToL1MessagePasser.t.sol | 10 ++-- .../contracts/test/OptimismPortal.t.sol | 2 +- 9 files changed, 103 insertions(+), 50 deletions(-) diff --git a/op-bindings/bindings/l2tol1messagepasser.go b/op-bindings/bindings/l2tol1messagepasser.go index 3149b2afaa882..db6629a5df7f2 100644 --- a/op-bindings/bindings/l2tol1messagepasser.go +++ b/op-bindings/bindings/l2tol1messagepasser.go @@ -30,8 +30,8 @@ var ( // L2ToL1MessagePasserMetaData contains all meta data concerning the L2ToL1MessagePasser contract. var L2ToL1MessagePasserMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"withdrawalHash\",\"type\":\"bytes32\"}],\"name\":\"MessagePassed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WithdrawerBalanceBurnt\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"initiateWithdrawal\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"sentMessages\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60e060405234801561001057600080fd5b506000608081905260a052600160c05260805160a05160c0516108f261004f60003960006102d5015260006102ac0152600061028301526108f26000f3fe60806040526004361061005e5760003560e01c806382e3702d1161004357806382e3702d146100c7578063affed0e014610107578063c2b3e5ac1461012b57600080fd5b806344df8e701461008757806354fd4d501461009c57600080fd5b366100825761008033620186a060405180602001604052806000815250610139565b005b600080fd5b34801561009357600080fd5b50610080610244565b3480156100a857600080fd5b506100b161027c565b6040516100be919061055e565b60405180910390f35b3480156100d357600080fd5b506100f76100e2366004610578565b60006020819052908152604090205460ff1681565b60405190151581526020016100be565b34801561011357600080fd5b5061011d60015481565b6040519081526020016100be565b6100806101393660046105c0565b600061019e6040518060c0016040528060015481526020013373ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020013481526020018581526020018481525061031f565b6000818152602081905260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915554905191925073ffffffffffffffffffffffffffffffffffffffff8616913391907f02a52367d10742d8032712c1bb8e0144ff1ec5ffda1ed7d70bb05a27449550549061022e9034908990899089906106c4565b60405180910390a4505060018054810190555050565b4761024e8161036c565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60606102a77f000000000000000000000000000000000000000000000000000000000000000061039b565b6102d07f000000000000000000000000000000000000000000000000000000000000000061039b565b6102f97f000000000000000000000000000000000000000000000000000000000000000061039b565b60405160200161030b939291906106f4565b604051602081830303815290604052905090565b80516020808301516040808501516060860151608087015160a0880151935160009761034f97909695910161076a565b604051602081830303815290604052805190602001209050919050565b80604051610379906104d8565b6040518091039082f0905080158015610396573d6000803e3d6000fd5b505050565b6060816000036103de57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561040857806103f2816107f0565b91506104019050600a83610857565b91506103e2565b60008167ffffffffffffffff81111561042357610423610591565b6040519080825280601f01601f19166020018201604052801561044d576020820181803683370190505b5090505b84156104d05761046260018361086b565b915061046f600a86610882565b61047a906030610896565b60f81b81838151811061048f5761048f6108ae565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506104c9600a86610857565b9450610451565b949350505050565b6008806108de83390190565b60005b838110156104ff5781810151838201526020016104e7565b8381111561050e576000848401525b50505050565b6000815180845261052c8160208601602086016104e4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006105716020830184610514565b9392505050565b60006020828403121561058a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156105d557600080fd5b833573ffffffffffffffffffffffffffffffffffffffff811681146105f957600080fd5b925060208401359150604084013567ffffffffffffffff8082111561061d57600080fd5b818601915086601f83011261063157600080fd5b81358181111561064357610643610591565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561068957610689610591565b816040528281528960208487010111156106a257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b8481528360208201526080604082015260006106e36080830185610514565b905082606083015295945050505050565b600084516107068184602089016104e4565b80830190507f2e000000000000000000000000000000000000000000000000000000000000008082528551610742816001850160208a016104e4565b6001920191820152835161075d8160028401602088016104e4565b0160020195945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a08301526107b560c0830184610514565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610821576108216107c1565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261086657610866610828565b500490565b60008282101561087d5761087d6107c1565b500390565b60008261089157610891610828565b500690565b600082198211156108a9576108a96107c1565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405230fffea164736f6c634300080f000a", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"withdrawalHash\",\"type\":\"bytes32\"}],\"name\":\"MessagePassed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WithdrawerBalanceBurnt\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MESSAGE_VERSION\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"initiateWithdrawal\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"sentMessages\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60e060405234801561001057600080fd5b506000608081905260a052600160c05260805160a05160c051610a2061004f6000396000610403015260006103da015260006103b10152610a206000f3fe6080604052600436106100695760003560e01c806382e3702d1161004357806382e3702d146100f6578063c2b3e5ac14610136578063ecc704281461014957600080fd5b80633f827a5a1461009257806344df8e70146100bf57806354fd4d50146100d457600080fd5b3661008d5761008b33620186a0604051806020016040528060008152506101ae565b005b600080fd5b34801561009e57600080fd5b506100a7600181565b60405161ffff90911681526020015b60405180910390f35b3480156100cb57600080fd5b5061008b610372565b3480156100e057600080fd5b506100e96103aa565b6040516100b6919061068c565b34801561010257600080fd5b506101266101113660046106a6565b60006020819052908152604090205460ff1681565b60405190151581526020016100b6565b61008b6101443660046106ee565b6101ae565b34801561015557600080fd5b506101a06001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b6040519081526020016100b6565b60006102446040518060c001604052806102086001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b815233602082015273ffffffffffffffffffffffffffffffffffffffff871660408201523460608201526080810186905260a00184905261044d565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055905073ffffffffffffffffffffffffffffffffffffffff8416336102df6001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b7f02a52367d10742d8032712c1bb8e0144ff1ec5ffda1ed7d70bb05a27449550543487878760405161031494939291906107f2565b60405180910390a45050600180547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8082168301167fffff0000000000000000000000000000000000000000000000000000000000009091161790555050565b4761037c8161049a565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60606103d57f00000000000000000000000000000000000000000000000000000000000000006104c9565b6103fe7f00000000000000000000000000000000000000000000000000000000000000006104c9565b6104277f00000000000000000000000000000000000000000000000000000000000000006104c9565b60405160200161043993929190610822565b604051602081830303815290604052905090565b80516020808301516040808501516060860151608087015160a0880151935160009761047d979096959101610898565b604051602081830303815290604052805190602001209050919050565b806040516104a790610606565b6040518091039082f09050801580156104c4573d6000803e3d6000fd5b505050565b60608160000361050c57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561053657806105208161091e565b915061052f9050600a83610985565b9150610510565b60008167ffffffffffffffff811115610551576105516106bf565b6040519080825280601f01601f19166020018201604052801561057b576020820181803683370190505b5090505b84156105fe57610590600183610999565b915061059d600a866109b0565b6105a89060306109c4565b60f81b8183815181106105bd576105bd6109dc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506105f7600a86610985565b945061057f565b949350505050565b600880610a0c83390190565b60005b8381101561062d578181015183820152602001610615565b8381111561063c576000848401525b50505050565b6000815180845261065a816020860160208601610612565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061069f6020830184610642565b9392505050565b6000602082840312156106b857600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561070357600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461072757600080fd5b925060208401359150604084013567ffffffffffffffff8082111561074b57600080fd5b818601915086601f83011261075f57600080fd5b813581811115610771576107716106bf565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156107b7576107b76106bf565b816040528281528960208487010111156107d057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b8481528360208201526080604082015260006108116080830185610642565b905082606083015295945050505050565b60008451610834818460208901610612565b80830190507f2e000000000000000000000000000000000000000000000000000000000000008082528551610870816001850160208a01610612565b6001920191820152835161088b816002840160208801610612565b0160020195945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a08301526108e360c0830184610642565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361094f5761094f6108ef565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261099457610994610956565b500490565b6000828210156109ab576109ab6108ef565b500390565b6000826109bf576109bf610956565b500690565b600082198211156109d7576109d76108ef565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405230fffea164736f6c634300080f000a", } // L2ToL1MessagePasserABI is the input ABI used to generate the binding from. @@ -201,12 +201,43 @@ func (_L2ToL1MessagePasser *L2ToL1MessagePasserTransactorRaw) Transact(opts *bin return _L2ToL1MessagePasser.Contract.contract.Transact(opts, method, params...) } -// Nonce is a free data retrieval call binding the contract method 0xaffed0e0. +// MESSAGEVERSION is a free data retrieval call binding the contract method 0x3f827a5a. // -// Solidity: function nonce() view returns(uint256) -func (_L2ToL1MessagePasser *L2ToL1MessagePasserCaller) Nonce(opts *bind.CallOpts) (*big.Int, error) { +// Solidity: function MESSAGE_VERSION() view returns(uint16) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserCaller) MESSAGEVERSION(opts *bind.CallOpts) (uint16, error) { var out []interface{} - err := _L2ToL1MessagePasser.contract.Call(opts, &out, "nonce") + err := _L2ToL1MessagePasser.contract.Call(opts, &out, "MESSAGE_VERSION") + + if err != nil { + return *new(uint16), err + } + + out0 := *abi.ConvertType(out[0], new(uint16)).(*uint16) + + return out0, err + +} + +// MESSAGEVERSION is a free data retrieval call binding the contract method 0x3f827a5a. +// +// Solidity: function MESSAGE_VERSION() view returns(uint16) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserSession) MESSAGEVERSION() (uint16, error) { + return _L2ToL1MessagePasser.Contract.MESSAGEVERSION(&_L2ToL1MessagePasser.CallOpts) +} + +// MESSAGEVERSION is a free data retrieval call binding the contract method 0x3f827a5a. +// +// Solidity: function MESSAGE_VERSION() view returns(uint16) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserCallerSession) MESSAGEVERSION() (uint16, error) { + return _L2ToL1MessagePasser.Contract.MESSAGEVERSION(&_L2ToL1MessagePasser.CallOpts) +} + +// MessageNonce is a free data retrieval call binding the contract method 0xecc70428. +// +// Solidity: function messageNonce() view returns(uint256) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserCaller) MessageNonce(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _L2ToL1MessagePasser.contract.Call(opts, &out, "messageNonce") if err != nil { return *new(*big.Int), err @@ -218,18 +249,18 @@ func (_L2ToL1MessagePasser *L2ToL1MessagePasserCaller) Nonce(opts *bind.CallOpts } -// Nonce is a free data retrieval call binding the contract method 0xaffed0e0. +// MessageNonce is a free data retrieval call binding the contract method 0xecc70428. // -// Solidity: function nonce() view returns(uint256) -func (_L2ToL1MessagePasser *L2ToL1MessagePasserSession) Nonce() (*big.Int, error) { - return _L2ToL1MessagePasser.Contract.Nonce(&_L2ToL1MessagePasser.CallOpts) +// Solidity: function messageNonce() view returns(uint256) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserSession) MessageNonce() (*big.Int, error) { + return _L2ToL1MessagePasser.Contract.MessageNonce(&_L2ToL1MessagePasser.CallOpts) } -// Nonce is a free data retrieval call binding the contract method 0xaffed0e0. +// MessageNonce is a free data retrieval call binding the contract method 0xecc70428. // -// Solidity: function nonce() view returns(uint256) -func (_L2ToL1MessagePasser *L2ToL1MessagePasserCallerSession) Nonce() (*big.Int, error) { - return _L2ToL1MessagePasser.Contract.Nonce(&_L2ToL1MessagePasser.CallOpts) +// Solidity: function messageNonce() view returns(uint256) +func (_L2ToL1MessagePasser *L2ToL1MessagePasserCallerSession) MessageNonce() (*big.Int, error) { + return _L2ToL1MessagePasser.Contract.MessageNonce(&_L2ToL1MessagePasser.CallOpts) } // SentMessages is a free data retrieval call binding the contract method 0x82e3702d. diff --git a/op-bindings/bindings/l2tol1messagepasser_more.go b/op-bindings/bindings/l2tol1messagepasser_more.go index c9dcd40f6da63..c9349407e1275 100644 --- a/op-bindings/bindings/l2tol1messagepasser_more.go +++ b/op-bindings/bindings/l2tol1messagepasser_more.go @@ -9,11 +9,11 @@ import ( "github.com/ethereum-optimism/optimism/op-bindings/solc" ) -const L2ToL1MessagePasserStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser\",\"label\":\"sentMessages\",\"offset\":0,\"slot\":\"0\",\"type\":\"t_mapping(t_bytes32,t_bool)\"},{\"astId\":1001,\"contract\":\"contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser\",\"label\":\"nonce\",\"offset\":0,\"slot\":\"1\",\"type\":\"t_uint256\"}],\"types\":{\"t_bool\":{\"encoding\":\"inplace\",\"label\":\"bool\",\"numberOfBytes\":\"1\"},\"t_bytes32\":{\"encoding\":\"inplace\",\"label\":\"bytes32\",\"numberOfBytes\":\"32\"},\"t_mapping(t_bytes32,t_bool)\":{\"encoding\":\"mapping\",\"label\":\"mapping(bytes32 =\u003e bool)\",\"numberOfBytes\":\"32\",\"key\":\"t_bytes32\",\"value\":\"t_bool\"},\"t_uint256\":{\"encoding\":\"inplace\",\"label\":\"uint256\",\"numberOfBytes\":\"32\"}}}" +const L2ToL1MessagePasserStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser\",\"label\":\"sentMessages\",\"offset\":0,\"slot\":\"0\",\"type\":\"t_mapping(t_bytes32,t_bool)\"},{\"astId\":1001,\"contract\":\"contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser\",\"label\":\"msgNonce\",\"offset\":0,\"slot\":\"1\",\"type\":\"t_uint240\"}],\"types\":{\"t_bool\":{\"encoding\":\"inplace\",\"label\":\"bool\",\"numberOfBytes\":\"1\"},\"t_bytes32\":{\"encoding\":\"inplace\",\"label\":\"bytes32\",\"numberOfBytes\":\"32\"},\"t_mapping(t_bytes32,t_bool)\":{\"encoding\":\"mapping\",\"label\":\"mapping(bytes32 =\u003e bool)\",\"numberOfBytes\":\"32\",\"key\":\"t_bytes32\",\"value\":\"t_bool\"},\"t_uint240\":{\"encoding\":\"inplace\",\"label\":\"uint240\",\"numberOfBytes\":\"30\"}}}" var L2ToL1MessagePasserStorageLayout = new(solc.StorageLayout) -var L2ToL1MessagePasserDeployedBin = "0x60806040526004361061005e5760003560e01c806382e3702d1161004357806382e3702d146100c7578063affed0e014610107578063c2b3e5ac1461012b57600080fd5b806344df8e701461008757806354fd4d501461009c57600080fd5b366100825761008033620186a060405180602001604052806000815250610139565b005b600080fd5b34801561009357600080fd5b50610080610244565b3480156100a857600080fd5b506100b161027c565b6040516100be919061055e565b60405180910390f35b3480156100d357600080fd5b506100f76100e2366004610578565b60006020819052908152604090205460ff1681565b60405190151581526020016100be565b34801561011357600080fd5b5061011d60015481565b6040519081526020016100be565b6100806101393660046105c0565b600061019e6040518060c0016040528060015481526020013373ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1681526020013481526020018581526020018481525061031f565b6000818152602081905260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915554905191925073ffffffffffffffffffffffffffffffffffffffff8616913391907f02a52367d10742d8032712c1bb8e0144ff1ec5ffda1ed7d70bb05a27449550549061022e9034908990899089906106c4565b60405180910390a4505060018054810190555050565b4761024e8161036c565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60606102a77f000000000000000000000000000000000000000000000000000000000000000061039b565b6102d07f000000000000000000000000000000000000000000000000000000000000000061039b565b6102f97f000000000000000000000000000000000000000000000000000000000000000061039b565b60405160200161030b939291906106f4565b604051602081830303815290604052905090565b80516020808301516040808501516060860151608087015160a0880151935160009761034f97909695910161076a565b604051602081830303815290604052805190602001209050919050565b80604051610379906104d8565b6040518091039082f0905080158015610396573d6000803e3d6000fd5b505050565b6060816000036103de57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561040857806103f2816107f0565b91506104019050600a83610857565b91506103e2565b60008167ffffffffffffffff81111561042357610423610591565b6040519080825280601f01601f19166020018201604052801561044d576020820181803683370190505b5090505b84156104d05761046260018361086b565b915061046f600a86610882565b61047a906030610896565b60f81b81838151811061048f5761048f6108ae565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506104c9600a86610857565b9450610451565b949350505050565b6008806108de83390190565b60005b838110156104ff5781810151838201526020016104e7565b8381111561050e576000848401525b50505050565b6000815180845261052c8160208601602086016104e4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006105716020830184610514565b9392505050565b60006020828403121561058a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156105d557600080fd5b833573ffffffffffffffffffffffffffffffffffffffff811681146105f957600080fd5b925060208401359150604084013567ffffffffffffffff8082111561061d57600080fd5b818601915086601f83011261063157600080fd5b81358181111561064357610643610591565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561068957610689610591565b816040528281528960208487010111156106a257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b8481528360208201526080604082015260006106e36080830185610514565b905082606083015295945050505050565b600084516107068184602089016104e4565b80830190507f2e000000000000000000000000000000000000000000000000000000000000008082528551610742816001850160208a016104e4565b6001920191820152835161075d8160028401602088016104e4565b0160020195945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a08301526107b560c0830184610514565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610821576108216107c1565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261086657610866610828565b500490565b60008282101561087d5761087d6107c1565b500390565b60008261089157610891610828565b500690565b600082198211156108a9576108a96107c1565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405230fffea164736f6c634300080f000a" +var L2ToL1MessagePasserDeployedBin = "0x6080604052600436106100695760003560e01c806382e3702d1161004357806382e3702d146100f6578063c2b3e5ac14610136578063ecc704281461014957600080fd5b80633f827a5a1461009257806344df8e70146100bf57806354fd4d50146100d457600080fd5b3661008d5761008b33620186a0604051806020016040528060008152506101ae565b005b600080fd5b34801561009e57600080fd5b506100a7600181565b60405161ffff90911681526020015b60405180910390f35b3480156100cb57600080fd5b5061008b610372565b3480156100e057600080fd5b506100e96103aa565b6040516100b6919061068c565b34801561010257600080fd5b506101266101113660046106a6565b60006020819052908152604090205460ff1681565b60405190151581526020016100b6565b61008b6101443660046106ee565b6101ae565b34801561015557600080fd5b506101a06001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b6040519081526020016100b6565b60006102446040518060c001604052806102086001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b815233602082015273ffffffffffffffffffffffffffffffffffffffff871660408201523460608201526080810186905260a00184905261044d565b600081815260208190526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055905073ffffffffffffffffffffffffffffffffffffffff8416336102df6001547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167e010000000000000000000000000000000000000000000000000000000000001790565b7f02a52367d10742d8032712c1bb8e0144ff1ec5ffda1ed7d70bb05a27449550543487878760405161031494939291906107f2565b60405180910390a45050600180547dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8082168301167fffff0000000000000000000000000000000000000000000000000000000000009091161790555050565b4761037c8161049a565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60606103d57f00000000000000000000000000000000000000000000000000000000000000006104c9565b6103fe7f00000000000000000000000000000000000000000000000000000000000000006104c9565b6104277f00000000000000000000000000000000000000000000000000000000000000006104c9565b60405160200161043993929190610822565b604051602081830303815290604052905090565b80516020808301516040808501516060860151608087015160a0880151935160009761047d979096959101610898565b604051602081830303815290604052805190602001209050919050565b806040516104a790610606565b6040518091039082f09050801580156104c4573d6000803e3d6000fd5b505050565b60608160000361050c57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561053657806105208161091e565b915061052f9050600a83610985565b9150610510565b60008167ffffffffffffffff811115610551576105516106bf565b6040519080825280601f01601f19166020018201604052801561057b576020820181803683370190505b5090505b84156105fe57610590600183610999565b915061059d600a866109b0565b6105a89060306109c4565b60f81b8183815181106105bd576105bd6109dc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506105f7600a86610985565b945061057f565b949350505050565b600880610a0c83390190565b60005b8381101561062d578181015183820152602001610615565b8381111561063c576000848401525b50505050565b6000815180845261065a816020860160208601610612565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061069f6020830184610642565b9392505050565b6000602082840312156106b857600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561070357600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461072757600080fd5b925060208401359150604084013567ffffffffffffffff8082111561074b57600080fd5b818601915086601f83011261075f57600080fd5b813581811115610771576107716106bf565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156107b7576107b76106bf565b816040528281528960208487010111156107d057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b8481528360208201526080604082015260006108116080830185610642565b905082606083015295945050505050565b60008451610834818460208901610612565b80830190507f2e000000000000000000000000000000000000000000000000000000000000008082528551610870816001850160208a01610612565b6001920191820152835161088b816002840160208801610612565b0160020195945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a08301526108e360c0830184610642565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361094f5761094f6108ef565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261099457610994610956565b500490565b6000828210156109ab576109ab6108ef565b500390565b6000826109bf576109bf610956565b500690565b600082198211156109d7576109d76108ef565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405230fffea164736f6c634300080f000a" func init() { if err := json.Unmarshal([]byte(L2ToL1MessagePasserStorageLayoutJSON), L2ToL1MessagePasserStorageLayout); err != nil { diff --git a/op-chain-ops/genesis/config.go b/op-chain-ops/genesis/config.go index 2a98e7dae8e15..7d5b645519bd2 100644 --- a/op-chain-ops/genesis/config.go +++ b/op-chain-ops/genesis/config.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "math/big" "os" "path/filepath" @@ -327,11 +326,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, diff --git a/packages/contracts-bedrock/.gas-snapshot b/packages/contracts-bedrock/.gas-snapshot index 9c921054174a2..2275c9b0df703 100644 --- a/packages/contracts-bedrock/.gas-snapshot +++ b/packages/contracts-bedrock/.gas-snapshot @@ -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) @@ -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) @@ -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) diff --git a/packages/contracts-bedrock/.storage-layout b/packages/contracts-bedrock/.storage-layout index 0bf7b5d79d8a2..5ddfc919b2c1e 100644 --- a/packages/contracts-bedrock/.storage-layout +++ b/packages/contracts-bedrock/.storage-layout @@ -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 | +--------------+--------------------------+------+--------+-------+----------------------------------------------------------+ ======================= diff --git a/packages/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol b/packages/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol index 7a1a4402f6d70..42e047b550f63 100644 --- a/packages/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol +++ b/packages/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol @@ -3,6 +3,7 @@ pragma solidity 0.8.15; import { Types } from "../libraries/Types.sol"; import { Hashing } from "../libraries/Hashing.sol"; +import { Encoding } from "../libraries/Encoding.sol"; import { Burn } from "../libraries/Burn.sol"; import { Semver } from "../universal/Semver.sol"; @@ -20,6 +21,11 @@ contract L2ToL1MessagePasser is Semver { */ uint256 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000; + /** + * @notice Current message version identifier. + */ + uint16 public constant MESSAGE_VERSION = 1; + /** * @notice Includes the message hashes for all withdrawals */ @@ -28,18 +34,18 @@ contract L2ToL1MessagePasser is Semver { /** * @notice A unique value hashed with each withdrawal. */ - uint256 public nonce; + uint240 internal msgNonce; /** * @notice Emitted any time a withdrawal is initiated. * - * @param nonce Unique value corresponding to each withdrawal. - * @param sender The L2 account address which initiated the withdrawal. - * @param target The L1 account address the call will be send to. - * @param value The ETH value submitted for withdrawal, to be forwarded to the target. - * @param gasLimit The minimum amount of gas that must be provided when withdrawing on L1. - * @param data The data to be forwarded to the target on L1. - * @param withdrawalHash The hash of the withdrawal. + * @param nonce Unique value corresponding to each withdrawal. + * @param sender The L2 account address which initiated the withdrawal. + * @param target The L1 account address the call will be send to. + * @param value The ETH value submitted for withdrawal, to be forwarded to the target. + * @param gasLimit The minimum amount of gas that must be provided when withdrawing. + * @param data The data to be forwarded to the target on L1. + * @param withdrawalHash The hash of the withdrawal. */ event MessagePassed( uint256 indexed nonce, @@ -96,7 +102,7 @@ contract L2ToL1MessagePasser is Semver { ) public payable { bytes32 withdrawalHash = Hashing.hashWithdrawal( Types.WithdrawalTransaction({ - nonce: nonce, + nonce: messageNonce(), sender: msg.sender, target: _target, value: msg.value, @@ -107,9 +113,29 @@ contract L2ToL1MessagePasser is Semver { sentMessages[withdrawalHash] = true; - emit MessagePassed(nonce, msg.sender, _target, msg.value, _gasLimit, _data, withdrawalHash); + emit MessagePassed( + messageNonce(), + msg.sender, + _target, + msg.value, + _gasLimit, + _data, + withdrawalHash + ); + unchecked { - ++nonce; + ++msgNonce; } } + + /** + * @notice Retrieves the next message nonce. Message version will be added to the upper two + * bytes of the message nonce. Message version allows us to treat messages as having + * different structures. + * + * @return Nonce of the next message to be sent, with added message version. + */ + function messageNonce() public view returns (uint256) { + return Encoding.encodeVersionedNonce(msgNonce, MESSAGE_VERSION); + } } diff --git a/packages/contracts-bedrock/contracts/test/L2CrossDomainMessenger.t.sol b/packages/contracts-bedrock/contracts/test/L2CrossDomainMessenger.t.sol index f89e516ef5f7a..4c144571994e7 100644 --- a/packages/contracts-bedrock/contracts/test/L2CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/contracts/test/L2CrossDomainMessenger.t.sol @@ -58,7 +58,7 @@ contract L2CrossDomainMessenger_Test is Messenger_Initializer { // MessagePassed event vm.expectEmit(true, true, true, true); emit MessagePassed( - messagePasser.nonce(), + messagePasser.messageNonce(), address(L2Messenger), address(L1Messenger), 0, @@ -66,7 +66,7 @@ contract L2CrossDomainMessenger_Test is Messenger_Initializer { xDomainCallData, Hashing.hashWithdrawal( Types.WithdrawalTransaction({ - nonce: messagePasser.nonce(), + nonce: messagePasser.messageNonce(), sender: address(L2Messenger), target: address(L1Messenger), value: 0, diff --git a/packages/contracts-bedrock/contracts/test/L2ToL1MessagePasser.t.sol b/packages/contracts-bedrock/contracts/test/L2ToL1MessagePasser.t.sol index 81d52c1a45073..a8f810c559386 100644 --- a/packages/contracts-bedrock/contracts/test/L2ToL1MessagePasser.t.sol +++ b/packages/contracts-bedrock/contracts/test/L2ToL1MessagePasser.t.sol @@ -32,7 +32,7 @@ contract L2ToL1MessagePasserTest is CommonTest { uint256 _gasLimit, bytes memory _data ) external { - uint256 nonce = messagePasser.nonce(); + uint256 nonce = messagePasser.messageNonce(); bytes32 withdrawalHash = Hashing.hashWithdrawal( Types.WithdrawalTransaction({ @@ -63,7 +63,7 @@ contract L2ToL1MessagePasserTest is CommonTest { function test_initiateWithdrawal_fromContract() external { bytes32 withdrawalHash = Hashing.hashWithdrawal( Types.WithdrawalTransaction( - messagePasser.nonce(), + messagePasser.messageNonce(), address(this), address(4), 100, @@ -74,7 +74,7 @@ contract L2ToL1MessagePasserTest is CommonTest { vm.expectEmit(true, true, true, true); emit MessagePassed( - messagePasser.nonce(), + messagePasser.messageNonce(), address(this), address(4), 100, @@ -93,7 +93,7 @@ contract L2ToL1MessagePasserTest is CommonTest { address target = address(4); uint256 value = 100; bytes memory data = hex"ff"; - uint256 nonce = messagePasser.nonce(); + uint256 nonce = messagePasser.messageNonce(); // EOA emulation vm.prank(alice, alice); @@ -110,7 +110,7 @@ contract L2ToL1MessagePasserTest is CommonTest { // the sent messages mapping is filled assertEq(messagePasser.sentMessages(withdrawalHash), true); // the nonce increments - assertEq(nonce + 1, messagePasser.nonce()); + assertEq(nonce + 1, messagePasser.messageNonce()); } // Test: burn should destroy the ETH held in the contract diff --git a/packages/contracts-bedrock/contracts/test/OptimismPortal.t.sol b/packages/contracts-bedrock/contracts/test/OptimismPortal.t.sol index 06a7f3ab2362d..aa97659fcbae1 100644 --- a/packages/contracts-bedrock/contracts/test/OptimismPortal.t.sol +++ b/packages/contracts-bedrock/contracts/test/OptimismPortal.t.sol @@ -814,7 +814,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer { // Total ETH supply is currently about 120M ETH. uint256 value = bound(_value, 0, 200_000_000 ether); uint256 gasLimit = bound(_gasLimit, 0, 50_000_000); - uint256 nonce = messagePasser.nonce(); + uint256 nonce = messagePasser.messageNonce(); Types.WithdrawalTransaction memory _tx = Types.WithdrawalTransaction({ nonce: nonce, sender: _sender,