Commit 722ee120 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into fix/deploy-config-validation-2

parents 2df8ab61 899e3b94
......@@ -63,7 +63,10 @@ func MigrateWithdrawal(withdrawal *LegacyWithdrawal, l1CrossDomainMessenger *com
return nil, err
}
versionedNonce := EncodeVersionedNonce(withdrawal.Nonce, common.Big1)
// Migrated withdrawals are specified as version 0. Both the
// L2ToL1MessagePasser and the CrossDomainMessenger use the same
// versioning scheme. Both should be set to version 0
versionedNonce := EncodeVersionedNonce(withdrawal.Nonce, new(big.Int))
// Encode the call to `relayMessage` on the `CrossDomainMessenger`.
// The minGasLimit can safely be 0 here.
data, err := abi.Pack(
......@@ -83,7 +86,7 @@ func MigrateWithdrawal(withdrawal *LegacyWithdrawal, l1CrossDomainMessenger *com
gasLimit := uint64(len(data)*16 + 200_000)
w := NewWithdrawal(
withdrawal.Nonce,
versionedNonce,
&predeploys.L2CrossDomainMessengerAddr,
l1CrossDomainMessenger,
value,
......
......@@ -62,7 +62,6 @@ type DeployConfig struct {
L2GenesisBlockGasLimit hexutil.Uint64 `json:"l2GenesisBlockGasLimit"`
L2GenesisBlockDifficulty *hexutil.Big `json:"l2GenesisBlockDifficulty"`
L2GenesisBlockMixHash common.Hash `json:"l2GenesisBlockMixHash"`
L2GenesisBlockCoinbase common.Address `json:"l2GenesisBlockCoinbase"`
L2GenesisBlockNumber hexutil.Uint64 `json:"l2GenesisBlockNumber"`
L2GenesisBlockGasUsed hexutil.Uint64 `json:"l2GenesisBlockGasUsed"`
L2GenesisBlockParentHash common.Hash `json:"l2GenesisBlockParentHash"`
......@@ -173,7 +172,7 @@ func (d *DeployConfig) Check() error {
log.Warn("GasPriceOracleOverhead is 0")
}
if d.GasPriceOracleScalar == 0 {
log.Warn("GasPriceOracleScalar is 0")
return fmt.Errorf("%w: GasPriceOracleScalar cannot be 0", ErrInvalidDeployConfig)
}
if d.L1StandardBridgeProxy == (common.Address{}) {
return fmt.Errorf("%w: L1StandardBridgeProxy cannot be address(0)", ErrInvalidDeployConfig)
......
......@@ -147,7 +147,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
bedrockHeader := &types.Header{
ParentHash: header.Hash(),
UncleHash: types.EmptyUncleHash,
Coinbase: config.L2GenesisBlockCoinbase,
Coinbase: predeploys.SequencerFeeVaultAddr,
Root: newRoot,
TxHash: types.EmptyRootHash,
ReceiptHash: types.EmptyRootHash,
......
......@@ -5,6 +5,7 @@ import (
"math/big"
"time"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
......@@ -85,7 +86,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
GasLimit: uint64(gasLimit),
Difficulty: difficulty.ToInt(),
Mixhash: config.L2GenesisBlockMixHash,
Coinbase: config.L2GenesisBlockCoinbase,
Coinbase: predeploys.SequencerFeeVaultAddr,
Number: uint64(config.L2GenesisBlockNumber),
GasUsed: uint64(config.L2GenesisBlockGasUsed),
ParentHash: config.L2GenesisBlockParentHash,
......
......@@ -32,7 +32,6 @@
"l2GenesisBlockGasLimit": "0xe4e1c0",
"l2GenesisBlockDifficulty": "0x1",
"l2GenesisBlockMixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"l2GenesisBlockCoinbase": "0x42000000000000000000000000000000000000f0",
"l2GenesisBlockNumber": "0x0",
"l2GenesisBlockGasUsed": "0x0",
"l2GenesisBlockParentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
......
......@@ -93,7 +93,6 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams {
L2GenesisBlockGasLimit: 15_000_000,
L2GenesisBlockDifficulty: uint64ToBig(0),
L2GenesisBlockMixHash: common.Hash{},
L2GenesisBlockCoinbase: predeploys.SequencerFeeVaultAddr,
L2GenesisBlockNumber: 0,
L2GenesisBlockGasUsed: 0,
L2GenesisBlockParentHash: common.Hash{},
......@@ -264,7 +263,6 @@ func ForkedDeployConfig(t require.TestingT, mnemonicCfg *MnemonicConfig, startBl
L2OutputOracleStartingTimestamp: int(startBlock.Time()),
L2OutputOracleProposer: addrs.Proposer,
L2OutputOracleChallenger: addrs.Deployer,
L2GenesisBlockCoinbase: common.HexToAddress("0x42000000000000000000000000000000000000f0"),
L2GenesisBlockGasLimit: hexutil.Uint64(15_000_000),
// taken from devnet, need to check this
L2GenesisBlockBaseFeePerGas: uint64ToBig(0x3B9ACA00),
......
......@@ -85,7 +85,6 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
L2GenesisBlockGasLimit: 8_000_000,
L2GenesisBlockDifficulty: uint642big(1),
L2GenesisBlockMixHash: common.Hash{},
L2GenesisBlockCoinbase: common.Address{0: 0x12},
L2GenesisBlockNumber: 0,
L2GenesisBlockGasUsed: 0,
L2GenesisBlockParentHash: common.Hash{},
......
......@@ -21,9 +21,9 @@ CrossDomainOwnableThroughPortal_Test:test_depositTransaction_crossDomainOwner_su
CrossDomainOwnable_Test:test_onlyOwner_notOwner_reverts() (gas: 10530)
CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34861)
CrossDomainOwnable2_Test:test_onlyOwner_notMessenger_reverts() (gas: 8416)
CrossDomainOwnable2_Test:test_onlyOwner_notOwner2_reverts() (gas: 61754)
CrossDomainOwnable2_Test:test_onlyOwner_notOwner2_reverts() (gas: 61783)
CrossDomainOwnable2_Test:test_onlyOwner_notOwner_reverts() (gas: 16588)
CrossDomainOwnable2_Test:test_onlyOwner_succeeds() (gas: 77782)
CrossDomainOwnable2_Test:test_onlyOwner_succeeds() (gas: 77811)
DeployerWhitelist_Test:test_owner_succeeds() (gas: 7538)
DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395)
FeeVault_Test:test_constructor_succeeds() (gas: 10647)
......@@ -55,22 +55,27 @@ L1BlockTest:test_updateValues_succeeds() (gas: 60481)
L1BlockNumberTest:test_fallback_succeeds() (gas: 18633)
L1BlockNumberTest:test_getL1BlockNumber_succeeds() (gas: 10603)
L1BlockNumberTest:test_receive_succeeds() (gas: 25340)
L1CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 24716)
L1CrossDomainMessenger_Test:test_pause_callerIsNotOwner_reverts() (gas: 24539)
L1CrossDomainMessenger_Test:test_pause_succeeds() (gas: 52964)
L1CrossDomainMessenger_Test:test_relayMessage_paused_reverts() (gas: 60498)
L1CrossDomainMessenger_Test:test_relayMessage_reentrancy_reverts() (gas: 190902)
L1CrossDomainMessenger_Test:test_relayMessage_retryAfterFailure_succeeds() (gas: 197256)
L1CrossDomainMessenger_Test:test_relayMessage_succeeds() (gas: 73617)
L1CrossDomainMessenger_Test:test_relayMessage_toSystemContract_reverts() (gas: 65858)
L1CrossDomainMessenger_Test:test_relayMessage_v0_reverts() (gas: 33214)
L1CrossDomainMessenger_Test:test_replayMessage_withValue_reverts() (gas: 38214)
L1CrossDomainMessenger_Test:test_sendMessage_succeeds() (gas: 299523)
L1CrossDomainMessenger_Test:test_sendMessage_twice_succeeds() (gas: 1490457)
L1CrossDomainMessenger_Test:test_unpause_callerIsNotOwner_reverts() (gas: 24472)
L1CrossDomainMessenger_Test:test_unpause_succeeds() (gas: 45149)
L1CrossDomainMessenger_Test:test_xDomainMessageSender_reset_succeeds() (gas: 84036)
L1CrossDomainMessenger_Test:test_xDomainSender_notSet_reverts() (gas: 24252)
L1CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 24759)
L1CrossDomainMessenger_Test:test_pause_callerIsNotOwner_reverts() (gas: 24517)
L1CrossDomainMessenger_Test:test_pause_succeeds() (gas: 52942)
L1CrossDomainMessenger_Test:test_relayMessage_legacyOldReplay_reverts() (gas: 56662)
L1CrossDomainMessenger_Test:test_relayMessage_legacyRetryAfterFailureThenSuccess_reverts() (gas: 212695)
L1CrossDomainMessenger_Test:test_relayMessage_legacyRetryAfterFailure_succeeds() (gas: 203380)
L1CrossDomainMessenger_Test:test_relayMessage_legacyRetryAfterSuccess_reverts() (gas: 126553)
L1CrossDomainMessenger_Test:test_relayMessage_legacy_succeeds() (gas: 76688)
L1CrossDomainMessenger_Test:test_relayMessage_paused_reverts() (gas: 60521)
L1CrossDomainMessenger_Test:test_relayMessage_reentrancy_reverts() (gas: 190932)
L1CrossDomainMessenger_Test:test_relayMessage_retryAfterFailure_succeeds() (gas: 197320)
L1CrossDomainMessenger_Test:test_relayMessage_succeeds() (gas: 73646)
L1CrossDomainMessenger_Test:test_relayMessage_toSystemContract_reverts() (gas: 65917)
L1CrossDomainMessenger_Test:test_relayMessage_v2_reverts() (gas: 19545)
L1CrossDomainMessenger_Test:test_replayMessage_withValue_reverts() (gas: 38265)
L1CrossDomainMessenger_Test:test_sendMessage_succeeds() (gas: 299568)
L1CrossDomainMessenger_Test:test_sendMessage_twice_succeeds() (gas: 1490458)
L1CrossDomainMessenger_Test:test_unpause_callerIsNotOwner_reverts() (gas: 24516)
L1CrossDomainMessenger_Test:test_unpause_succeeds() (gas: 45185)
L1CrossDomainMessenger_Test:test_xDomainMessageSender_reset_succeeds() (gas: 84065)
L1CrossDomainMessenger_Test:test_xDomainSender_notSet_reverts() (gas: 24274)
L1ERC721Bridge_Test:test_bridgeERC721To_localTokenZeroAddress_reverts() (gas: 52730)
L1ERC721Bridge_Test:test_bridgeERC721To_remoteTokenZeroAddress_reverts() (gas: 27332)
L1ERC721Bridge_Test:test_bridgeERC721To_succeeds() (gas: 354722)
......@@ -103,17 +108,17 @@ L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 31449)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 22005)
L1StandardBridge_Receive_Test:test_receive_succeeds() (gas: 514475)
L2CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 8367)
L2CrossDomainMessenger_Test:test_pause_notOwner_reverts() (gas: 10859)
L2CrossDomainMessenger_Test:test_pause_notOwner_reverts() (gas: 10837)
L2CrossDomainMessenger_Test:test_pause_succeeds() (gas: 31846)
L2CrossDomainMessenger_Test:test_relayMessage_paused_reverts() (gas: 41596)
L2CrossDomainMessenger_Test:test_relayMessage_reentrancy_reverts() (gas: 167787)
L2CrossDomainMessenger_Test:test_relayMessage_retry_succeeds() (gas: 168313)
L2CrossDomainMessenger_Test:test_relayMessage_succeeds() (gas: 53183)
L2CrossDomainMessenger_Test:test_relayMessage_toSystemContract_reverts() (gas: 36194)
L2CrossDomainMessenger_Test:test_relayMessage_v0_reverts() (gas: 18870)
L2CrossDomainMessenger_Test:test_relayMessage_reentrancy_reverts() (gas: 167794)
L2CrossDomainMessenger_Test:test_relayMessage_retry_succeeds() (gas: 168371)
L2CrossDomainMessenger_Test:test_relayMessage_succeeds() (gas: 53212)
L2CrossDomainMessenger_Test:test_relayMessage_toSystemContract_reverts() (gas: 36246)
L2CrossDomainMessenger_Test:test_relayMessage_v2_reverts() (gas: 18913)
L2CrossDomainMessenger_Test:test_sendMessage_succeeds() (gas: 122533)
L2CrossDomainMessenger_Test:test_sendMessage_twice_succeeds() (gas: 134671)
L2CrossDomainMessenger_Test:test_xDomainMessageSender_reset_succeeds() (gas: 52594)
L2CrossDomainMessenger_Test:test_xDomainMessageSender_reset_succeeds() (gas: 52623)
L2CrossDomainMessenger_Test:test_xDomainSender_senderNotSet_reverts() (gas: 10524)
L2ERC721Bridge_Test:test_bridgeERC721To_localTokenZeroAddress_reverts() (gas: 26432)
L2ERC721Bridge_Test:test_bridgeERC721To_remoteTokenZeroAddress_reverts() (gas: 21748)
......
......@@ -93,18 +93,20 @@ contract L2CrossDomainMessenger_Test is Messenger_Initializer {
L2Messenger.xDomainMessageSender();
}
function test_relayMessage_v0_reverts() external {
function test_relayMessage_v2_reverts() external {
address target = address(0xabcd);
address sender = address(L1Messenger);
address caller = AddressAliasHelper.applyL1ToL2Alias(address(L1Messenger));
vm.prank(caller);
// Expect a revert.
vm.expectRevert(
"CrossDomainMessenger: only version 1 messages are supported after the Bedrock upgrade"
"CrossDomainMessenger: only version 0 or 1 messages are supported at this time"
);
// Try to relay a v2 message.
vm.prank(caller);
L2Messenger.relayMessage(
0, // nonce
Encoding.encodeVersionedNonce(0, 2), // nonce
sender,
target,
0, // value
......
......@@ -263,15 +263,23 @@ abstract contract CrossDomainMessenger is
bytes calldata _message
) external payable nonReentrant whenNotPaused {
(, uint16 version) = Encoding.decodeVersionedNonce(_nonce);
require(
version < 2,
"CrossDomainMessenger: only version 0 or 1 messages are supported at this time"
);
// Block any messages that aren't version 1. All version 0 messages have been guaranteed to
// be relayed OR have been migrated to version 1 messages. Version 0 messages do not commit
// to the value or minGasLimit fields, which can create unexpected issues for end-users.
// If the message is version 0, then it's a migrated legacy withdrawal. We therefore need
// to check that the legacy version of the message has not already been relayed.
if (version == 0) {
bytes32 oldHash = Hashing.hashCrossDomainMessageV0(_target, _sender, _message, _nonce);
require(
version == 1,
"CrossDomainMessenger: only version 1 messages are supported after the Bedrock upgrade"
successfulMessages[oldHash] == false,
"CrossDomainMessenger: legacy withdrawal already relayed"
);
}
// We use the v1 message hash as the unique identifier for the message because it commits
// to the value and minimum gas limit of the message.
bytes32 versionedHash = Hashing.hashCrossDomainMessageV1(
_nonce,
_sender,
......
......@@ -12,7 +12,6 @@
"l2OutputOracleStartingTimestamp": -1,
"l2OutputOracleProposer": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"l2OutputOracleChallenger": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
"l2GenesisBlockCoinbase": "0x42000000000000000000000000000000000000f0",
"l2GenesisBlockGasLimit": "0xE4E1C0",
"l1BlockTime": 15,
"cliqueSignerAddress": "0xca062b0fd91172d89bcd4bb084ac4e21972cc467",
......
{
"finalSystemOwner": "0x62790eFcB3a5f3A5D398F95B47930A9Addd83807",
"controller": "0x2d30335B0b807bBa1682C487BaAFD2Ad6da5D675",
"l1StartingBlockTag": "0x4104895a540d87127ff11eef0d51d8f63ce00a6fc211db751a45a4b3a61a9c83",
"l1ChainID": 5,
"l2ChainID": 420,
"l2BlockTime": 2,
"maxSequencerDrift": 1200,
"sequencerWindowSize": 3600,
"channelTimeout": 120,
"p2pSequencerAddress": "0xCBABF46d40982B4530c0EAc9889f6e44e17f0383",
"batchInboxAddress": "0xff00000000000000000000000000000000000420",
"batchSenderAddress": "0x3a2baA0160275024A50C1be1FC677375E7DB4Bd7",
"l2OutputOracleSubmissionInterval": 20,
"l2OutputOracleStartingTimestamp": 1670625264,
"l2OutputOracleStartingBlockNumber": 3324764,
"l2OutputOracleProposer": "0x88BCa4Af3d950625752867f826E073E337076581",
"l2OutputOracleChallenger": "0x88BCa4Af3d950625752867f826E073E337076581",
"finalizationPeriodSeconds": 2,
"proxyAdminOwner": "0x62790eFcB3a5f3A5D398F95B47930A9Addd83807",
"governanceTokenName": "Optimism",
"governanceTokenSymbol": "OP",
"governanceTokenOwner": "0x038a8825A3C3B0c08d52Cc76E5E361953Cf6Dc76",
"l2GenesisBlockGasLimit": "0x17D7840",
"l2GenesisBlockCoinbase": "0x4200000000000000000000000000000000000011",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"gasPriceOracleOverhead": 2100,
"gasPriceOracleScalar": 1000000,
"eip1559Denominator": 50,
"eip1559Elasticity": 10
}
import { DeployConfig } from '../src/deploy-config'
import config from './final-migration-rehearsal.json'
export default config satisfies DeployConfig
......@@ -28,7 +28,6 @@
"governanceTokenOwner": "0x038a8825A3C3B0c08d52Cc76E5E361953Cf6Dc76",
"l2GenesisBlockGasLimit": "0x17D7840",
"l2GenesisBlockCoinbase": "0x4200000000000000000000000000000000000011",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
......
......@@ -21,7 +21,6 @@
"finalizationPeriodSeconds": 2,
"l2GenesisBlockGasLimit": "0x17D7840",
"l2GenesisBlockCoinbase": "0x4200000000000000000000000000000000000011",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"l2CrossDomainMessengerOwner": "DUMMY",
......
......@@ -69,6 +69,12 @@ const config: HardhatUserConfig = {
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
live: true,
},
'final-migration-rehearsal': {
chainId: 5,
url: process.env.L1_RPC || '',
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
live: true,
},
},
foundry: {
buildInfo: true,
......@@ -104,6 +110,10 @@ const config: HardhatUserConfig = {
'../contracts/deployments/goerli',
'../contracts-periphery/deployments/goerli',
],
'final-migration-rehearsal': [
'../contracts/deployments/goerli',
'../contracts-periphery/deployments/goerli',
],
},
},
solidity: {
......
......@@ -151,7 +151,6 @@ interface OptionalL2DeployConfig {
l2GenesisBlockGasLimit: string
l2GenesisBlockDifficulty: string
l2GenesisBlockMixHash: string
l2GenesisBlockCoinbase: string
l2GenesisBlockNumber: string
l2GenesisBlockGasUsed: string
l2GenesisBlockParentHash: string
......@@ -300,10 +299,6 @@ export const deployConfigSpec: {
type: 'string', // bytes32
default: ethers.constants.HashZero,
},
l2GenesisBlockCoinbase: {
type: 'address',
default: ethers.constants.AddressZero,
},
l2GenesisBlockNumber: {
type: 'string', // uint64
default: '0x0',
......
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