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

feat: introduce SuperchainWETH and ETHLiquidity #11042

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/invariant-docs/ETHLiquidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `ETHLiquidity` Invariants

## Calls to mint/burn repeatedly should never cause the actor's balance to increase beyond the starting balance.
**Test:** [`ETHLiquidity.t.sol#L83`](../test/invariants/ETHLiquidity.t.sol#L83)

2 changes: 2 additions & 0 deletions packages/contracts-bedrock/invariant-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This directory contains documentation for all defined invariant tests within `co
- [Burn.Eth](./Burn.Eth.md)
- [Burn.Gas](./Burn.Gas.md)
- [CrossDomainMessenger](./CrossDomainMessenger.md)
- [ETHLiquidity](./ETHLiquidity.md)
- [Encoding](./Encoding.md)
- [FaultDisputeGame](./FaultDisputeGame.md)
- [Hashing](./Hashing.md)
Expand All @@ -19,6 +20,7 @@ This directory contains documentation for all defined invariant tests within `co
- [OptimismPortal2](./OptimismPortal2.md)
- [ResourceMetering](./ResourceMetering.md)
- [SafeCall](./SafeCall.md)
- [SuperchainWETH](./SuperchainWETH.md)
- [SystemConfig](./SystemConfig.md)
<!-- END autoTOC -->

Expand Down
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/invariant-docs/SuperchainWETH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `SuperchainWETH` Invariants

## Calls to sendERC20 should always succeed as long as the actor has less than uint248 wei which is much greater than the total ETH supply. Actor's balance should also not increase out of nowhere.
mds1 marked this conversation as resolved.
Show resolved Hide resolved
**Test:** [`SuperchainWETH.t.sol#L171`](../test/invariants/SuperchainWETH.t.sol#L171)

4 changes: 2 additions & 2 deletions packages/contracts-bedrock/scripts/ForgeArtifacts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ library ForgeArtifacts {
string[] memory cmd = new string[](3);
cmd[0] = Executables.bash;
cmd[1] = "-c";
cmd[2] = string.concat(Executables.jq, " '.methodIdentifiers | keys' < ", _getForgeArtifactPath(_name));
bytes memory res = Process.run(cmd);
cmd[2] = string.concat(Executables.jq, " '.methodIdentifiers // {} | keys ' < ", _getForgeArtifactPath(_name));
bytes memory res = Process.run(cmd, true);
ids_ = stdJson.readStringArray(string(res), "");
}

Expand Down
19 changes: 17 additions & 2 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ contract L2Genesis is Deployer {
if (cfg.useInterop()) {
setCrossL2Inbox(); // 22
setL2ToL2CrossDomainMessenger(); // 23
setSuperchainWETH(); // 24
setETHLiquidity(); // 25
}
}

Expand Down Expand Up @@ -463,18 +465,31 @@ contract L2Genesis is Deployer {
vm.resetNonce(address(eas));
}

/// @notice This predeploy is following the saftey invariant #2.
/// @notice This predeploy is following the safety invariant #2.
/// This contract has no initializer.
function setCrossL2Inbox() internal {
_setImplementationCode(Predeploys.CROSS_L2_INBOX);
}

/// @notice This predeploy is following the saftey invariant #2.
/// @notice This predeploy is following the safety invariant #2.
/// This contract has no initializer.
function setL2ToL2CrossDomainMessenger() internal {
_setImplementationCode(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER);
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setETHLiquidity() internal {
_setImplementationCode(Predeploys.ETH_LIQUIDITY);
vm.deal(Predeploys.ETH_LIQUIDITY, type(uint248).max);
smartcontracts marked this conversation as resolved.
Show resolved Hide resolved
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setSuperchainWETH() internal {
_setImplementationCode(Predeploys.SUPERCHAIN_WETH);
}

/// @notice Sets all the preinstalls.
/// Warning: the creator-accounts of the preinstall contracts have 0 nonce values.
/// When performing a regular user-initiated contract-creation of a preinstall,
Expand Down
8 changes: 8 additions & 0 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"initCodeHash": "0x074af4b17cfdd1d1dafaaccb79d68ab4ceef50d35dc205aeeedc265e11ae2a92",
"sourceCodeHash": "0x5b4355b060e8e5ab81047e5f3d093869c2be7bae14a48a0e5ddf6872a219faf2"
},
"src/L2/ETHLiquidity.sol": {
"initCodeHash": "0x98177562fca0de0dfea5313c9acefe2fdbd73dee5ce6c1232055601f208f0177",
"sourceCodeHash": "0x6dc23ceeed5a63fdc98ba8e5099df1822f3eeaa8c82afb1fa3235ff68a37b274"
},
"src/L2/GasPriceOracle.sol": {
"initCodeHash": "0xb16f1e370e58c7693fd113a21a1b1e7ccebc03d4f1e5a76786fc27847ef51ead",
"sourceCodeHash": "0x5529ee28aae94904a1c08a8b188f51a39a0f51fbd3b43f1abd4fee7bba57998c"
Expand Down Expand Up @@ -107,6 +111,10 @@
"initCodeHash": "0xb94145f571e92ee615c6fe903b6568e8aac5fe760b6b65148ffc45d2fb0f5433",
"sourceCodeHash": "0x8f2a54104e5e7105ba03ba37e3ef9b6684a447245f0e0b787ba4cca12957b97c"
},
"src/L2/SuperchainWETH.sol": {
"initCodeHash": "0x52e302ac749e6a519829e0fb01075638e481e7f010a6438088486a7a4be4601b",
"sourceCodeHash": "0x7c93752288f4414777e01c2962aee929a28aef2c1fccdfeba456f22df0f9aa39"
},
"src/L2/WETH.sol": {
"initCodeHash": "0xde72ae96910e95249623c2d695749847e4c4adeaf96a7a35033afd77318a528a",
"sourceCodeHash": "0xbe200a6cb297a3ca1a7d174a9c886e3f17eb8edf617ad014a2ac4f6c2e2ac7f1"
Expand Down
83 changes: 83 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/ETHLiquidity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[
{
"inputs": [],
"name": "burn",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "caller",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "LiquidityBurned",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "caller",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "LiquidityMinted",
"type": "event"
},
{
"inputs": [],
"name": "NotCustomGasToken",
"type": "error"
},
{
"inputs": [],
"name": "Unauthorized",
"type": "error"
}
]
Loading