Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard L2 Genesis #12057

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
03251e0
wip: holocene contracts
tynes Sep 23, 2024
f41a1d0
progress
tynes Sep 28, 2024
c6fb79a
l1xdm
tynes Sep 28, 2024
e4be05a
standard bridge
tynes Sep 29, 2024
67a7544
erc721bridge
tynes Sep 29, 2024
50d5004
fee vaults
tynes Sep 29, 2024
3cdb688
cleanup
tynes Sep 29, 2024
faec331
portal interop: cleanup
tynes Sep 29, 2024
3714c5c
cleanup
tynes Sep 29, 2024
e8fe9e8
contracts: fix erc721 factory tests
tynes Sep 30, 2024
3bc0e3d
contracts: more cleanup
tynes Sep 30, 2024
9849bc1
contracts: L2xdm tests passing
tynes Sep 30, 2024
8c7e3ab
contracts: l2 standard bridge tests
tynes Sep 30, 2024
a5cfa46
tests: sequencer fee vault passes
tynes Sep 30, 2024
34dbe19
tests: sequencer fee vault passes
tynes Sep 30, 2024
6b4154c
tests: more passing
tynes Sep 30, 2024
be6c5ad
contracts: portal tests pass
tynes Sep 30, 2024
edd9ddf
fix build
tynes Oct 10, 2024
dd7dc5c
messenger: fixup
tynes Oct 13, 2024
c8a2696
messenger fixup
tynes Oct 13, 2024
8a6130a
standard bridge: fixup
tynes Oct 13, 2024
86da2d7
fixes
tynes Oct 13, 2024
227807e
progress
tynes Oct 13, 2024
e1251f3
more tests passing
tynes Oct 13, 2024
fb1e667
fixups
tynes Oct 13, 2024
681c7e3
tests: cleanup
tynes Oct 13, 2024
eab6a20
more fixes
tynes Oct 13, 2024
84ad5d3
more fixup
tynes Oct 13, 2024
c060567
more fixes
tynes Oct 13, 2024
cb1a9c7
more fixes
tynes Oct 13, 2024
72477cb
tests: all passing
tynes Oct 13, 2024
a4c146b
tests
tynes Oct 13, 2024
f220efc
fix: ERC721Bridge spacer offset
maurelian Oct 21, 2024
1cf87c5
fix: lint
maurelian Oct 21, 2024
2a1b15f
fix: Place comment above @custom:semver
maurelian Oct 21, 2024
f008055
chore: Update semver-lock
maurelian Oct 21, 2024
df82df4
add some todos
maurelian Oct 22, 2024
5251780
test: Add fuzz test for OptimismPortal2 setConfig
maurelian Oct 23, 2024
22584e6
test: OptimismPortalInterop - test all auth failures in one fuzz test
maurelian Oct 23, 2024
3b39914
fix: Portal2 iface
maurelian Oct 23, 2024
d6e03cb
wip: Adding OptimismPortal2.upgrade() tests
maurelian Oct 23, 2024
059cfad
feat: Set upgrader to superchainProxyAdminOwner in DeploySuperchain.s…
maurelian Oct 23, 2024
498bdf6
fix some ifaces
maurelian Oct 23, 2024
3b98344
Some iface fixes
maurelian Oct 24, 2024
c5f9b5a
More iface fixes
maurelian Oct 24, 2024
dfc3a48
fix solc warning
maurelian Oct 24, 2024
293fe3e
feat: Add setFeeVaultConfig
maurelian Oct 24, 2024
2577bd2
wip adding Roles struct with feeadmin
maurelian Oct 24, 2024
6c448bf
Merge branch 'develop' into feat/holocene-contracts
maurelian Oct 24, 2024
d5a4d5d
update forge-std
maurelian Oct 25, 2024
0115bac
feat: Add feeAdmin to new SystemConfig.Roles struct
maurelian Oct 25, 2024
7039c8e
feat: Fix DeployOPChain init assertions
maurelian Oct 25, 2024
96f397d
feat: Update name to L1OptimismMintableERC20Factory
maurelian Oct 25, 2024
fd9f281
fix: testFuzz_upgrade
maurelian Oct 25, 2024
ffab4b9
rename to L1OpMintableErc20Factory
maurelian Oct 25, 2024
2dc6e27
fix: interace fixes
maurelian Oct 25, 2024
2db3193
Merge branch 'develop' into feat/holocene-contracts
maurelian Oct 25, 2024
ee8b8f1
fix: delete unused functions
maurelian Oct 25, 2024
dd2805f
fix: spacer naming
maurelian Oct 25, 2024
eda3318
fix some semvers
maurelian Oct 25, 2024
af21912
fix semvers
maurelian Oct 25, 2024
bd909bc
chore: gas benchmarks
maurelian Oct 25, 2024
e695518
fix spacer
maurelian Oct 25, 2024
358995e
fix: interfaces
maurelian Oct 25, 2024
0bffa48
Remove outdated comment
maurelian Oct 25, 2024
252937a
fix: interfaces
maurelian Oct 25, 2024
b953c94
fix: IL1Block
maurelian Oct 25, 2024
925ea52
snapshots and semver-lock
maurelian Oct 25, 2024
62a0c06
fix: unused imports
maurelian Oct 25, 2024
0e6556d
fix: spacer and semver
maurelian Oct 25, 2024
df46145
fix: L120factory name
maurelian Oct 25, 2024
2b22127
op-deployer: Add FeeAdmin
maurelian Oct 25, 2024
d4080ca
semgrep: More flexible string.concat usage
maurelian Oct 25, 2024
753e044
update todo notes
maurelian Oct 28, 2024
156b1f9
fix: Semgrep rules and source formatting
maurelian Oct 28, 2024
c44edb5
Remove unused storage and immutable checks from TestApplyGenesisStrategy
maurelian Oct 28, 2024
7ed2ac3
fix: test_upgrade_correctEvent_succeeds bug
maurelian Oct 28, 2024
c604a6d
remove unused console import
maurelian Oct 28, 2024
989dd48
fix: Specs for SystemConfigInterop abi
maurelian Oct 29, 2024
62d765f
fix: semver diffs on required contracts
maurelian Oct 29, 2024
ce7923b
remove unused getEIP1967ImplementationAddress func
maurelian Oct 29, 2024
8f1b1c5
fix: layout in StandardBridge
maurelian Oct 29, 2024
0bfec69
fix: go lint
maurelian Oct 29, 2024
834e089
fix: layout in standard bridge
maurelian Oct 30, 2024
83f6ee5
feat: use _disableInitializers on L1StandardBridge and SuperchainConfig
maurelian Oct 30, 2024
3bb3690
fix: L1xDM spacers
maurelian Oct 30, 2024
7c507b4
feat: Add missing natspec
maurelian Oct 30, 2024
296fdc8
feat: Add missing natspec
maurelian Oct 30, 2024
f1b34db
fix: Spacer to pad out L1StandardBridge _initialized slot
maurelian Oct 30, 2024
02314dc
feat: Make base CDM abstract, remove its snapshots
maurelian Oct 30, 2024
806411c
fix: spacer sizing on L1CDM
maurelian Oct 30, 2024
461fde3
fix: L1StandardBridge init check
maurelian Oct 30, 2024
0f0f840
fix: spacer validations
maurelian Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions op-deployer/pkg/deployer/opcm/opchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type DeployOPChainInput struct {
UnsafeBlockSigner common.Address
Proposer common.Address
Challenger common.Address
FeeAdmin common.Address

BasefeeScalar uint32
BlobBaseFeeScalar uint32
Expand Down Expand Up @@ -122,6 +123,7 @@ type opcmRoles struct {
UnsafeBlockSigner common.Address
Proposer common.Address
Challenger common.Address
FeeAdmin common.Address
}

// opcmDeployInput is the input struct for the deploy method of the OPStackManager contract. We
Expand Down Expand Up @@ -253,6 +255,7 @@ func DeployOPChainRaw(
UnsafeBlockSigner: input.UnsafeBlockSigner,
Proposer: input.Proposer,
Challenger: input.Challenger,
FeeAdmin: input.FeeAdmin,
},
BasefeeScalar: input.BasefeeScalar,
BlobBasefeeScalar: input.BlobBaseFeeScalar,
Expand Down
26 changes: 13 additions & 13 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7567)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5567)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175677)
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7545)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5545)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175655)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369280)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967420)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564398)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076613)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467098)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512802)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72664)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 367195)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2965335)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 560201)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4072416)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 462680)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3508556)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 70470)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68422)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68986)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155610)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68344)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68908)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155647)
28 changes: 13 additions & 15 deletions packages/contracts-bedrock/scripts/DeployImplementations.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol";
import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol";
import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";
import { IL1OptimismMintableERC20Factory as IOptimismMintableERC20Factory } from
"src/L1/interfaces/IL1OptimismMintableERC20Factory.sol";

import { OPContractsManagerInterop } from "src/L1/OPContractsManagerInterop.sol";
import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol";
Expand Down Expand Up @@ -370,19 +371,19 @@ contract DeployImplementationsOutput is BaseDeployIO {

DeployUtils.assertInitialized({ _contractAddress: address(systemConfig), _slot: 0, _offset: 0 });

require(systemConfig.owner() == address(0xdead), "SYSCON-10");
require(systemConfig.owner() == address(0), "SYSCON-10");
require(systemConfig.overhead() == 0, "SYSCON-20");
require(systemConfig.scalar() == uint256(0x01) << 248, "SYSCON-30");
require(systemConfig.scalar() == 0, "SYSCON-30");
require(systemConfig.basefeeScalar() == 0, "SYSCON-40");
require(systemConfig.blobbasefeeScalar() == 0, "SYSCON-50");
require(systemConfig.batcherHash() == bytes32(0), "SYSCON-60");
require(systemConfig.gasLimit() == 1, "SYSCON-70");
require(systemConfig.gasLimit() == 0, "SYSCON-70");
require(systemConfig.unsafeBlockSigner() == address(0), "SYSCON-80");

IResourceMetering.ResourceConfig memory resourceConfig = systemConfig.resourceConfig();
require(resourceConfig.maxResourceLimit == 1, "SYSCON-90");
require(resourceConfig.elasticityMultiplier == 1, "SYSCON-100");
require(resourceConfig.baseFeeMaxChangeDenominator == 2, "SYSCON-110");
require(resourceConfig.maxResourceLimit == 0, "SYSCON-90");
require(resourceConfig.elasticityMultiplier == 0, "SYSCON-100");
require(resourceConfig.baseFeeMaxChangeDenominator == 0, "SYSCON-110");
require(resourceConfig.systemTxMaxGas == 0, "SYSCON-120");
require(resourceConfig.minimumBaseFee == 0, "SYSCON-130");
require(resourceConfig.maximumBaseFee == 0, "SYSCON-140");
Expand All @@ -400,22 +401,19 @@ contract DeployImplementationsOutput is BaseDeployIO {
function assertValidL1CrossDomainMessengerImpl(DeployImplementationsInput) internal view {
IL1CrossDomainMessenger messenger = l1CrossDomainMessengerImpl();

DeployUtils.assertInitialized({ _contractAddress: address(messenger), _slot: 0, _offset: 20 });
DeployUtils.assertInitialized({ _contractAddress: address(messenger), _slot: 252, _offset: 0 });

require(address(messenger.OTHER_MESSENGER()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-10");
require(address(messenger.otherMessenger()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-20");
require(address(messenger.PORTAL()) == address(0), "L1xDM-30");
require(address(messenger.portal()) == address(0), "L1xDM-40");
require(address(messenger.superchainConfig()) == address(0), "L1xDM-50");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the proxy you do the following check

        vm.expectRevert("CrossDomainMessenger: xDomainMessageSender is not set");
        messenger.xDomainMessageSender();

This could also be useful here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectRevert is not yet supported in Go. I will add a todo and some uncommented code in both cases instead.


bytes32 xdmSenderSlot = vm.load(address(messenger), bytes32(uint256(204)));
require(address(uint160(uint256(xdmSenderSlot))) == Constants.DEFAULT_L2_SENDER, "L1xDM-60");
}

function assertValidL1ERC721BridgeImpl(DeployImplementationsInput) internal view {
IL1ERC721Bridge bridge = l1ERC721BridgeImpl();

DeployUtils.assertInitialized({ _contractAddress: address(bridge), _slot: 0, _offset: 0 });
DeployUtils.assertInitialized({ _contractAddress: address(bridge) });

require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_ERC721_BRIDGE, "L721B-10");
require(address(bridge.otherBridge()) == Predeploys.L2_ERC721_BRIDGE, "L721B-20");
Expand All @@ -439,7 +437,7 @@ contract DeployImplementationsOutput is BaseDeployIO {
function assertValidOptimismMintableERC20FactoryImpl(DeployImplementationsInput) internal view {
IOptimismMintableERC20Factory factory = optimismMintableERC20FactoryImpl();

DeployUtils.assertInitialized({ _contractAddress: address(factory), _slot: 0, _offset: 0 });
DeployUtils.assertInitialized({ _contractAddress: address(factory), _slot: 51, _offset: 0 });

require(address(factory.BRIDGE()) == address(0), "MERC20F-10");
require(address(factory.bridge()) == address(0), "MERC20F-20");
Expand Down Expand Up @@ -788,15 +786,15 @@ contract DeployImplementations is Script {
vm.broadcast(msg.sender);
impl = IOptimismMintableERC20Factory(
DeployUtils.create1({
_name: "OptimismMintableERC20Factory",
_name: "L1OptimismMintableERC20Factory",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IOptimismMintableERC20Factory.__constructor__, ()))
})
);
} else {
revert(string.concat("DeployImplementations: failed to deploy release ", release));
}

vm.label(address(impl), "OptimismMintableERC20FactoryImpl");
vm.label(address(impl), "L1OptimismMintableERC20FactoryImpl");
_dio.set(_dio.optimismMintableERC20FactoryImpl.selector, address(impl));
}

Expand Down
16 changes: 9 additions & 7 deletions packages/contracts-bedrock/scripts/DeployOPChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ contract DeployOPChain is Script {
batcher: _doi.batcher(),
unsafeBlockSigner: _doi.unsafeBlockSigner(),
proposer: _doi.proposer(),
challenger: _doi.challenger()
});
challenger: _doi.challenger(),
feeAdmin: msg.sender // TODO: read from doi
maurelian marked this conversation as resolved.
Show resolved Hide resolved
});
OPContractsManager.DeployInput memory deployInput = OPContractsManager.DeployInput({
roles: roles,
basefeeScalar: _doi.basefeeScalar(),
Expand Down Expand Up @@ -557,7 +558,7 @@ contract DeployOPChain is Script {
function assertValidL1CrossDomainMessenger(DeployOPChainInput _doi, DeployOPChainOutput _doo) internal {
IL1CrossDomainMessenger messenger = _doo.l1CrossDomainMessengerProxy();

DeployUtils.assertInitialized({ _contractAddress: address(messenger), _slot: 0, _offset: 20 });
DeployUtils.assertInitialized({ _contractAddress: address(messenger), _slot: 252, _offset: 0 });

require(address(messenger.OTHER_MESSENGER()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-10");
require(address(messenger.otherMessenger()) == Predeploys.L2_CROSS_DOMAIN_MESSENGER, "L1xDM-20");
Expand All @@ -566,8 +567,9 @@ contract DeployOPChain is Script {
require(address(messenger.portal()) == address(_doo.optimismPortalProxy()), "L1xDM-40");
require(address(messenger.superchainConfig()) == address(_doi.opcmProxy().superchainConfig()), "L1xDM-50");

bytes32 xdmSenderSlot = vm.load(address(messenger), bytes32(uint256(204)));
require(address(uint160(uint256(xdmSenderSlot))) == Constants.DEFAULT_L2_SENDER, "L1xDM-60");
// TODO: vm.expectRevert is not supported by op-chain-ops, so we can't check this yet.
// vm.expectRevert("CrossDomainMessenger: xDomainMessageSender is not set");
// messenger.xDomainMessageSender();
maurelian marked this conversation as resolved.
Show resolved Hide resolved
}

function assertValidL1StandardBridge(DeployOPChainInput _doi, DeployOPChainOutput _doo) internal {
Expand All @@ -586,7 +588,7 @@ contract DeployOPChain is Script {
function assertValidOptimismMintableERC20Factory(DeployOPChainInput, DeployOPChainOutput _doo) internal {
IOptimismMintableERC20Factory factory = _doo.optimismMintableERC20FactoryProxy();

DeployUtils.assertInitialized({ _contractAddress: address(factory), _slot: 0, _offset: 0 });
DeployUtils.assertInitialized({ _contractAddress: address(factory), _slot: 51, _offset: 0 });

require(factory.BRIDGE() == address(_doo.l1StandardBridgeProxy()), "MERC20F-10");
require(factory.bridge() == address(_doo.l1StandardBridgeProxy()), "MERC20F-20");
Expand All @@ -595,7 +597,7 @@ contract DeployOPChain is Script {
function assertValidL1ERC721Bridge(DeployOPChainInput _doi, DeployOPChainOutput _doo) internal {
IL1ERC721Bridge bridge = _doo.l1ERC721BridgeProxy();

DeployUtils.assertInitialized({ _contractAddress: address(bridge), _slot: 0, _offset: 0 });
DeployUtils.assertInitialized({ _contractAddress: address(bridge) });

require(address(bridge.OTHER_BRIDGE()) == Predeploys.L2_ERC721_BRIDGE, "L721B-10");
require(address(bridge.otherBridge()) == Predeploys.L2_ERC721_BRIDGE, "L721B-20");
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/scripts/DeploySuperchain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ contract DeploySuperchain is Script {

function deployAndInitializeSuperchainConfig(DeploySuperchainInput _dsi, DeploySuperchainOutput _dso) public {
address guardian = _dsi.guardian();
address upgrader = _dsi.superchainProxyAdminOwner();
bool paused = _dsi.paused();

IProxyAdmin superchainProxyAdmin = _dso.superchainProxyAdmin();
Expand All @@ -376,7 +377,7 @@ contract DeploySuperchain is Script {
superchainProxyAdmin.upgradeAndCall(
payable(address(superchainConfigProxy)),
address(superchainConfigImpl),
abi.encodeCall(ISuperchainConfig.initialize, (guardian, paused))
abi.encodeCall(ISuperchainConfig.initialize, (guardian, upgrader, paused))
);
vm.stopBroadcast();

Expand Down
Loading