Skip to content

Commit

Permalink
Merge pull request ethereum-optimism#8365 from ethereum-optimism/ctb/…
Browse files Browse the repository at this point in the history
…erc721-pause

contracts-bedrock: ERC721Bridge pausable
  • Loading branch information
maurelian authored Dec 6, 2023
2 parents 18d5273 + e521392 commit 52ef1b6
Show file tree
Hide file tree
Showing 22 changed files with 722 additions and 74 deletions.
225 changes: 221 additions & 4 deletions op-bindings/bindings/l1erc721bridge.go

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

194 changes: 190 additions & 4 deletions op-bindings/bindings/l2erc721bridge.go

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,11 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block) (*immutables
GovernanceToken: struct{}{},
LegacyMessagePasser: struct{}{},
L2ERC721Bridge: struct {
Messenger common.Address
OtherBridge common.Address
Messenger common.Address
}{
Messenger: predeploys.L2CrossDomainMessengerAddr,
OtherBridge: config.L1ERC721BridgeProxy,
Messenger: predeploys.L2CrossDomainMessengerAddr,
},
OptimismMintableERC721Factory: struct {
Bridge common.Address
Expand Down Expand Up @@ -834,6 +834,10 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.Storage
"_initialized": 1,
"_initializing": false,
}
storage["L2ERC721Bridge"] = state.StorageValues{
"_initialized": 1,
"_initializing": false,
}
storage["L1Block"] = state.StorageValues{
"number": block.Number(),
"timestamp": block.Time(),
Expand Down
10 changes: 3 additions & 7 deletions op-chain-ops/immutables/immutables.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type PredeploysImmutableConfig struct {
GovernanceToken struct{}
LegacyMessagePasser struct{}
L2ERC721Bridge struct {
Messenger common.Address
OtherBridge common.Address
Messenger common.Address
}
OptimismMintableERC721Factory struct {
Bridge common.Address
Expand Down Expand Up @@ -230,15 +230,11 @@ func l2ImmutableDeployer(backend *backends.SimulatedBackend, opts *bind.Transact
}
_, tx, _, err = bindings.DeployOptimismMintableERC20Factory(opts, backend, bridge)
case "L2ERC721Bridge":
messenger, ok := deployment.Args[0].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid type for messenger")
}
otherBridge, ok := deployment.Args[1].(common.Address)
otherBridge, ok := deployment.Args[0].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid type for otherBridge")
}
_, tx, _, err = bindings.DeployL2ERC721Bridge(opts, backend, messenger, otherBridge)
_, tx, _, err = bindings.DeployL2ERC721Bridge(opts, backend, otherBridge)
case "OptimismMintableERC721Factory":
bridge, ok := deployment.Args[0].(common.Address)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions op-chain-ops/immutables/immutables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func TestBuildOptimism(t *testing.T) {
GovernanceToken: struct{}{},
LegacyMessagePasser: struct{}{},
L2ERC721Bridge: struct {
Messenger common.Address
OtherBridge common.Address
Messenger common.Address
}{
Messenger: common.HexToAddress("0x1234567890123456789012345678901234567890"),
OtherBridge: common.HexToAddress("0x1234567890123456789012345678901234567890"),
Messenger: predeploys.L2CrossDomainMessengerAddr,
},
OptimismMintableERC721Factory: struct {
Bridge common.Address
Expand Down
9 changes: 7 additions & 2 deletions packages/contracts-bedrock/scripts/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library ChainAssertions {
checkL1StandardBridge({ _contracts: _prox, _isProxy: true });
checkL2OutputOracle(_prox, _cfg, _l2OutputOracleStartingTimestamp, _l2OutputOracleStartingBlockNumber);
checkOptimismMintableERC20Factory(_prox);
checkL1ERC721Bridge(_prox);
checkL1ERC721Bridge({ _contracts: _prox, _isProxy: true });
checkOptimismPortal({ _contracts: _prox, _cfg: _cfg, _isProxy: true });
checkProtocolVersions({ _contracts: _prox, _cfg: _cfg, _isProxy: true });
}
Expand Down Expand Up @@ -137,12 +137,17 @@ library ChainAssertions {
}

/// @notice Asserts that the L1ERC721Bridge is setup correctly
function checkL1ERC721Bridge(Types.ContractSet memory _contracts) internal view {
function checkL1ERC721Bridge(Types.ContractSet memory _contracts, bool _isProxy) internal view {
L1ERC721Bridge bridge = L1ERC721Bridge(_contracts.L1ERC721Bridge);
require(address(bridge.MESSENGER()) == _contracts.L1CrossDomainMessenger);
require(address(bridge.messenger()) == _contracts.L1CrossDomainMessenger);
require(bridge.OTHER_BRIDGE() == Predeploys.L2_ERC721_BRIDGE);
require(bridge.otherBridge() == Predeploys.L2_ERC721_BRIDGE);
if (_isProxy) {
require(address(bridge.superchainConfig()) == _contracts.SuperchainConfig);
} else {
require(address(bridge.superchainConfig()) == address(0));
}
}

/// @notice Asserts the OptimismPortal is setup correctly
Expand Down
16 changes: 9 additions & 7 deletions packages/contracts-bedrock/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,7 @@ contract Deploy is Deployer {
console.log("Deploying L1ERC721Bridge implementation");
address l1CrossDomainMessengerProxy = mustGetAddress("L1CrossDomainMessengerProxy");
L1ERC721Bridge bridge = new L1ERC721Bridge{ salt: _implSalt() }({
_messenger: l1CrossDomainMessengerProxy,
_otherBridge: Predeploys.L2_ERC721_BRIDGE
_messenger: l1CrossDomainMessengerProxy
});

save("L1ERC721Bridge", address(bridge));
Expand All @@ -690,7 +689,8 @@ contract Deploy is Deployer {
// are always proxies.
Types.ContractSet memory contracts = _proxiesUnstrict();
contracts.L1ERC721Bridge = address(bridge);
ChainAssertions.checkL1ERC721Bridge(contracts);

ChainAssertions.checkL1ERC721Bridge({ _contracts: contracts, _isProxy: false });

addr_ = address(bridge);
}
Expand Down Expand Up @@ -811,17 +811,19 @@ contract Deploy is Deployer {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address l1ERC721BridgeProxy = mustGetAddress("L1ERC721BridgeProxy");
address l1ERC721Bridge = mustGetAddress("L1ERC721Bridge");
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");

_callViaSafe({
_target: address(proxyAdmin),
_data: abi.encodeCall(ProxyAdmin.upgrade, (payable(l1ERC721BridgeProxy), l1ERC721Bridge))
_upgradeAndCallViaSafe({
_proxy: payable(l1ERC721BridgeProxy),
_implementation: l1ERC721Bridge,
_innerCallData: abi.encodeCall(L1ERC721Bridge.initialize, (SuperchainConfig(superchainConfigProxy)))
});

L1ERC721Bridge bridge = L1ERC721Bridge(l1ERC721BridgeProxy);
string memory version = bridge.version();
console.log("L1ERC721Bridge version: %s", version);

ChainAssertions.checkL1ERC721Bridge(_proxies());
ChainAssertions.checkL1ERC721Bridge({ _contracts: _proxies(), _isProxy: true });
}

/// @notice Ininitialize the OptimismMintableERC20Factory
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"sourceCodeHash": "0x508ac7c5628d226f5e3ec6593f6c28aab969f70223c678eb0e870155d24b1da4"
},
"src/L1/L1ERC721Bridge.sol": {
"initCodeHash": "0xb9d7955f46b634725a57269f7004ee638850a4d3ecd20ae2d6fdcd4694430a75",
"sourceCodeHash": "0x76ab62d44cf4efdc1db7042e75738b6d187682b0bdfb4160f5d0dc09eab55b4f"
"initCodeHash": "0xca27bfb4742b3b44e9adb6018b0917ae3392e67e5f8242ab24828dd37245af16",
"sourceCodeHash": "0x60f2d99be1211f6d64fb0ae4d0ac4819bdbaefd2ebf4a49e95cbad27cf691fac"
},
"src/L1/L1StandardBridge.sol": {
"initCodeHash": "0x56a7fbc6807e1c4fa818a9706a12545f86499ca4269b0dc84c328ec632933eaf",
Expand Down Expand Up @@ -64,8 +64,8 @@
"sourceCodeHash": "0x167f90f8b75e6ae2d5326d5245384d1ec9dd28222e78388b9e9b11aea8da7348"
},
"src/L2/L2ERC721Bridge.sol": {
"initCodeHash": "0x8c7dc436d8150514bca8a322e3e45e53fb98a6c1f0f22d6a9ba6cf1f479e0e56",
"sourceCodeHash": "0x448b01aa8e9e79782766134290d54a3557135c9d39357bfbbf1d2672687518ac"
"initCodeHash": "0x3b7357a0972db8cde39f6583d87291fc64ef424737498cf6927f8fcb3d7e368d",
"sourceCodeHash": "0x2b9b106a924ac21d6e8f57219e7f7c72f6581ea1cfd5cff77d79a7f144f0ebd2"
},
"src/L2/L2StandardBridge.sol": {
"initCodeHash": "0x2d6b3e6fee86b9edbfe56bc4e201d1fe0cd70db424121f0059772cd9a46cdb16",
Expand Down
57 changes: 52 additions & 5 deletions packages/contracts-bedrock/snapshots/abi/L1ERC721Bridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"internalType": "address",
"name": "_messenger",
"type": "address"
},
{
"internalType": "address",
"name": "_otherBridge",
"type": "address"
}
],
"stateMutability": "nonpayable",
Expand Down Expand Up @@ -101,6 +96,19 @@
"name": "ERC721BridgeInitiated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"inputs": [],
"name": "MESSENGER",
Expand Down Expand Up @@ -265,6 +273,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract SuperchainConfig",
"name": "_superchainConfig",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "messenger",
Expand All @@ -291,6 +312,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paused",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "superchainConfig",
"outputs": [
{
"internalType": "contract SuperchainConfig",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "version",
Expand Down
38 changes: 33 additions & 5 deletions packages/contracts-bedrock/snapshots/abi/L2ERC721Bridge.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_messenger",
"type": "address"
},
{
"internalType": "address",
"name": "_otherBridge",
Expand Down Expand Up @@ -101,6 +96,19 @@
"name": "ERC721BridgeInitiated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"inputs": [],
"name": "MESSENGER",
Expand Down Expand Up @@ -236,6 +244,13 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "messenger",
Expand All @@ -262,6 +277,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paused",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "version",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
[
{
"bytes": "1568",
"label": "__gap",
"bytes": "1",
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "uint256[49]"
"type": "uint8"
},
{
"bytes": "1",
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "bool"
},
{
"bytes": "1536",
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "uint256[48]"
},
{
"bytes": "32",
"label": "deposits",
"offset": 0,
"slot": "49",
"type": "mapping(address => mapping(address => mapping(uint256 => bool)))"
},
{
"bytes": "20",
"label": "superchainConfig",
"offset": 0,
"slot": "50",
"type": "contract SuperchainConfig"
}
]
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
[
{
"bytes": "1568",
"label": "__gap",
"bytes": "1",
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "uint256[49]"
"type": "uint8"
},
{
"bytes": "1",
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "bool"
},
{
"bytes": "1536",
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "uint256[48]"
}
]
Loading

0 comments on commit 52ef1b6

Please sign in to comment.