Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
2fd67e4
tasks: create postCheck.s.sol for eth/006-MCP-L1
0xfuturistic Mar 30, 2024
2763e15
Create DeployConfigMainnet.json
0xfuturistic Mar 30, 2024
32f3cb1
tasks: update MCP L1 postCheck
0xfuturistic Mar 30, 2024
dfdd4c5
add virtual to postCheck function in SignFromJson.s.sol
0xfuturistic Mar 30, 2024
a131c38
tasks: fix stack too deep issue with postCheck in MCP script
0xfuturistic Mar 30, 2024
154711a
tasks: move postCheck script to MCP subdir from scripts
0xfuturistic Mar 30, 2024
e09cb0d
tasks: remove redundant lines in postCheck script for MCP
0xfuturistic Mar 30, 2024
31a9504
tasks: remove unnecessary imports in postCheck script for MCP
0xfuturistic Mar 30, 2024
9ee86fb
tasks: inherit from env var for DeployConfig in postCheck.s.sol
0xfuturistic Apr 1, 2024
888400d
tasks: demodularize ResourceMetering.ResourceConfig in postCheck for …
0xfuturistic Apr 1, 2024
c95f8f3
tasks: drop unnecessary check in postCheck.s.sol for MCP mainnet
0xfuturistic Apr 1, 2024
3471fd0
tasks: drop unnecessary check in postCheck.s.sol for MCP mainnet
0xfuturistic Apr 1, 2024
61774bc
forge install: superchain-registry
0xfuturistic Apr 1, 2024
650f0cc
Update foundry.toml to add superchain-registry to mappings
0xfuturistic Apr 1, 2024
651c818
tasks: read ContractSet from json in postCheck for MCP mainnet
0xfuturistic Apr 1, 2024
c401b88
tasks: read l2OutputOracleStartingTimestamp from cfg in postCheck for…
0xfuturistic Apr 1, 2024
8edfda2
tasks: rename postCheck in MCP mainnet to SignFromJsonWithAssertions
0xfuturistic Apr 1, 2024
72bdfb5
tasks: add assertions that any address referenced has code for SignFr…
0xfuturistic Apr 1, 2024
7077a29
tasks: use incrementing numbers of 100 for error logs in SignFromJson…
0xfuturistic Apr 2, 2024
63e65e4
tasks: define xdmSenderSlotNumber in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
14beb5a
tasks: read values from read these values from tasks/eth/005-protocol…
0xfuturistic Apr 2, 2024
a47bca7
tasks: fix code length check in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
63c95f9
tasks: fix deploy config path in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
e71720d
tasks: insert postDeployAssertions in _postCheck in SignFromJsonWithA…
0xfuturistic Apr 2, 2024
7279dbd
tasks: fix _getContractSet() in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
2edc67e
tasks: drop DeployConfig.json in MCP mainnet
0xfuturistic Apr 2, 2024
e6bffdc
tasks: read superchain.yaml in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
28d8c95
tasks: improve variable names in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
f27e17a
tasks: inherit Deployer in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
9b4df80
tasks: update contract name in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
42fb99d
Update lib/optimism
0xfuturistic Apr 2, 2024
aebdde2
Fix script/DeployRehearsalContracts.s.sol
0xfuturistic Apr 2, 2024
cbf2104
tasks: define setUp function in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
7ade1f3
tasks: read xdmSenderSlotNumber from snapshot in SignFromJsonWithAsse…
0xfuturistic Apr 2, 2024
53fcdfc
task: fix import path in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
091add1
tasks: fix superchain.yaml read in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
44c4b0a
tasks: use hash in check for resourceConfig in SignFromJsonWithAssert…
0xfuturistic Apr 2, 2024
97677b0
tasks: remove redundant check in SignFromJsonWithAssertions.s.sol
0xfuturistic Apr 2, 2024
e1f9a38
tasks: drop unnecessary ternary in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
df5a836
Add yq installation to README
0xfuturistic Apr 2, 2024
8780b5a
tasks: fix superchain.yaml read in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
dfe33fa
tasks: use DeployConfig for recommendedProtocolVersion in SignFromJso…
0xfuturistic Apr 2, 2024
b3051f2
tasks: add additional assertions checking any address referenced has …
0xfuturistic Apr 2, 2024
05ad40b
tasks: improve naming of vars in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
a4b6d61
task: clean json read in SignFromJsonWithAssertions
0xfuturistic Apr 2, 2024
3cdc5eb
Update single.just to use script tasks/eth/006-MCP-L1/SignFromJsonWit…
0xfuturistic Apr 2, 2024
b1bf8a1
tasks: introduce local vars for deploy config in SignFromJsonWithAsse…
0xfuturistic Apr 2, 2024
99fd3e2
tasks: enforce slot number validity for xdmSender in SignFromJsonWith…
0xfuturistic Apr 2, 2024
2047aa3
Add yq installation to CI
0xfuturistic Apr 2, 2024
23d9bca
tasks: rename SignFromJsonWithAssertions to SignFromJson
0xfuturistic Apr 3, 2024
1fc1630
tasks: drop get go path in SignFromJson
0xfuturistic Apr 3, 2024
e91ad3b
Drop yq install from CI config
0xfuturistic Apr 3, 2024
82098a8
Add CI test for 006-MCP-L1
0xfuturistic Apr 3, 2024
3a3bd3b
tasks: hardcode xdmSenderSlotNumber value in SignFromJson.s.sol for MCP
0xfuturistic Apr 4, 2024
e74827c
scripts: add _postCheck() to public functions in SignFromJson.s.sol
0xfuturistic Apr 4, 2024
bc6ad6a
tasks: drop extra assignment for guardian in SignFromJson for MCP
0xfuturistic Apr 4, 2024
f9ce185
Drop redundant just_simulate_006-MCP-L1 in CI
0xfuturistic Apr 5, 2024
7f16670
tasks: use relative path for import in SignFromJson for MCP
0xfuturistic Apr 5, 2024
4272cd4
Add local NestedSignFromJson usage to nested.just
0xfuturistic Apr 5, 2024
c3cdf35
scripts: add postCheck to public functions in NestedSignFromJson
0xfuturistic Apr 5, 2024
f48ad4b
tasks: create eth/006-MCP-L1/NestedSignFromJson.s.sol
0xfuturistic Apr 5, 2024
a962474
tasks: delete eth/006-MCP-L1/NestedSignFromJson.s.sol
0xfuturistic Apr 5, 2024
94c2bb6
Update superchain-registry
0xfuturistic Apr 5, 2024
af1fbcb
tasks: check implementation code length for NestedSignFromJson in MCP
0xfuturistic Apr 5, 2024
02a3bb8
tasks: add source for constants in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
ca72231
script: drop _postCheck(); from signJson method
0xfuturistic Apr 5, 2024
058e65d
tasks: minor fixes in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
7361d0c
Update lib/optimism
0xfuturistic Apr 5, 2024
64dbb3f
Add yq installation to CI
0xfuturistic Apr 5, 2024
b57d87f
Replace 'manipulate' by 'parse' for yq in README
0xfuturistic Apr 5, 2024
cbb314c
Set ffi = true in foundry.toml
0xfuturistic Apr 5, 2024
a22a62d
script: Reintroduce console logs in DeployRehearsalContracts.s.sol
0xfuturistic Apr 5, 2024
9336989
tasks: improve verify comments in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
ff52d26
tasks: improve verify comments in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
a24f71d
tasks: improve verify comments in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
89105f3
tasks: use permalinks for verify links in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
978bbc6
tasks: replace almost all etherscan links in NestedSignFromJson for MCP
0xfuturistic Apr 5, 2024
72050a6
Improve comment for FFI in foundry.toml
0xfuturistic Apr 5, 2024
c83628b
script: add specific import for Config in DeployRehearsalContracts.s.sol
0xfuturistic Apr 5, 2024
75ee38b
fix scalar check
mds1 Apr 5, 2024
432704c
script: fix console.log in DeployRehearsalContracts.s.sol
0xfuturistic Apr 5, 2024
a0624f9
tasks: update verify link for finalSystemOwner in NestedSignFromJson …
0xfuturistic Apr 5, 2024
2979e21
Improve comment for FFI in foundry.toml
0xfuturistic Apr 5, 2024
e543ae3
Add echo for running script with assertions in nested.just
0xfuturistic Apr 5, 2024
c3dfb14
script: add postCheck to signJson methods
0xfuturistic Apr 5, 2024
e954e2b
Drop semicolon in echo in nested.just, single.just
0xfuturistic Apr 5, 2024
815a5c4
feat: run simulation of tx in foundry
mds1 Apr 5, 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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
- run:
name: just simulate 006-MCP-L1
command: |
go install github.com/mikefarah/yq/v4@latest
just install
forge clean
forge build
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
[submodule "lib/superchain-registry"]
path = lib/superchain-registry
url = https://github.com/ethereum-optimism/superchain-registry
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ We’ll use the [eip712sign](https://github.com/base-org/eip712sign) utility dev
You should see a message something like this:
` One (and only one) of --private-key, --ledger, --mnemonic must be set`

### Installing `mikefarah/yq`

We’ll use `mikefarah/yq` to parse `.yaml` files:

1. From the command prompt run:
`go install github.com/mikefarah/yq/v4@latest`
2. Verify the installation by typing `$(go env GOPATH)/bin/yq --version`
3. You should see the version number printed. This repo has been tested with version `4.43.1`.

### Installing foundry

We’ll use foundry to simulate the transaction we’re approving:
Expand Down
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ optimizer_runs = 999999
solc_version = "0.8.15"
via_ir = true
broadcast = 'records'
fs_permissions = [ {access = "read-write", path = "./"} ]
fs_permissions = [{ access = "read-write", path = "./" }]
# Enable FFI for reading lib/superchain-registry files in scripts SignFromJson.s.sol, NestedSignFromJson.s.sol within tasks
ffi = true

remappings = [
'@openzeppelin/contracts-upgradeable/=lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable/contracts/',
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',
'@base-contracts/=lib/base-contracts/',
'@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/',
'@rari-capital/solmate/=lib/solmate',
'@eth-optimism-superchain-registry/=lib/superchain-registry/',
'forge-std/=lib/forge-std/src/',
]

Expand Down
2 changes: 1 addition & 1 deletion lib/optimism
Submodule optimism updated 731 files
1 change: 1 addition & 0 deletions lib/superchain-registry
Submodule superchain-registry added at 4c005f
40 changes: 35 additions & 5 deletions nested.just
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export randomPersonEoa := "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
simulate whichSafe hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=NestedSignFromJson
if [ -f "${taskPath}/NestedSignFromJson.s.sol" ]; then
script="${taskPath}/NestedSignFromJson.s.sol"
echo "Running script with assertions"
fi
echo "Using script ${script}"
echo "getting signer address for {{whichSafe}}..."

if [ "{{whichSafe}}" == "foundation" ]; then
Expand All @@ -38,7 +44,7 @@ simulate whichSafe hdPath='0':
echo "Simulating without ledger using the first owner account: ${signer}"
fi
echo ""
forge script NestedSignFromJson \
forge script ${script} \
--rpc-url ${rpcUrl} \
--sender ${signer} \
--sig "signJson(string,address)" \
Expand All @@ -48,6 +54,12 @@ simulate whichSafe hdPath='0':
sign whichSafe hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=NestedSignFromJson
if [ -f "${taskPath}/NestedSignFromJson.s.sol" ]; then
Comment thread
0xfuturistic marked this conversation as resolved.
script="${taskPath}/NestedSignFromJson.s.sol"
echo "Running script with assertions"
fi
echo "Using script ${script}"
if [ "{{whichSafe}}" == "foundation" ]; then
safe="{{foundationSafe}}"
echo "Using foundation safe at ${safe}"
Expand All @@ -61,7 +73,7 @@ sign whichSafe hdPath='0':
echo "Signing with: ${signer}"
echo ""
$(git rev-parse --show-toplevel)/bin/eip712sign --ledger --hd-paths "m/44'/60'/{{hdPath}}'/0/0" -- \
forge script NestedSignFromJson \
forge script ${script} \
--rpc-url ${rpcUrl} \
--sig "signJson(string,address)" \
${bundlePath} \
Expand All @@ -70,6 +82,12 @@ sign whichSafe hdPath='0':
approve whichSafe hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=NestedSignFromJson
if [ -f "${taskPath}/NestedSignFromJson.s.sol" ]; then
script="${taskPath}/NestedSignFromJson.s.sol"
echo "Running script with assertions"
fi
echo "Using script ${script}"
if [ "{{whichSafe}}" == "foundation" ]; then
safe="{{foundationSafe}}"
echo "Using foundation safe at ${safe}"
Expand All @@ -79,7 +97,7 @@ approve whichSafe hdPath='0':
echo "Using council safe at ${safe}"
fi
sender=$(cast wallet address --ledger --mnemonic-derivation-path "m/44'/60'/{{hdPath}}'/0/0")
forge script NestedSignFromJson \
forge script ${script} \
--fork-url ${rpcUrl} \
--ledger --hd-paths "m/44'/60'/{{hdPath}}'/0/0" \
--broadcast \
Expand All @@ -92,8 +110,14 @@ approve whichSafe hdPath='0':
execute hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=NestedSignFromJson
if [ -f "${taskPath}/NestedSignFromJson.s.sol" ]; then
script="${taskPath}/NestedSignFromJson.s.sol"
echo "Running script with assertions"
fi
echo "Using script ${script}"
sender=$(cast wallet address --ledger --mnemonic-derivation-path "m/44'/60'/{{hdPath}}'/0/0")
forge script NestedSignFromJson \
forge script ${script} \
--fork-url ${rpcUrl} \
--ledger --hd-paths "m/44'/60'/{{hdPath}}'/0/0" \
--broadcast \
Expand All @@ -104,7 +128,13 @@ execute hdPath='0':
simulated-run hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
forge script NestedSignFromJson \
script=NestedSignFromJson
if [ -f "${taskPath}/NestedSignFromJson.s.sol" ]; then
script="${taskPath}/NestedSignFromJson.s.sol"
echo "Running script with assertions"
fi
echo "Using script ${script}"
forge script ${script} \
--fork-url ${rpcUrl} \
--sender ${randomPersonEoa} \
--sig "runJson(string)" \
Expand Down
5 changes: 3 additions & 2 deletions script/DeployRehearsalContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import {Deployer} from "@eth-optimism-bedrock/scripts/Deployer.sol";
import {Config} from "@eth-optimism-bedrock/scripts/Config.sol";
import {GnosisSafe} from "safe-contracts/GnosisSafe.sol";
import {ProxyAdmin} from "@eth-optimism-bedrock/src/universal/ProxyAdmin.sol";
import {Proxy} from "@eth-optimism-bedrock/src/universal/Proxy.sol";
Expand Down Expand Up @@ -31,8 +32,8 @@ contract DeployRehearsalContracts is Deployer {

require(owner_safe.isOwner(address(council_safe)));

console.log("Deploying from %s", deployScript);
console.log("Deployment context: %s", deploymentContext);
Comment thread
0xfuturistic marked this conversation as resolved.
console.log("Deploying from %s", name());
console.log("Deployment context: %s", Config.deploymentContext());
}

function run() public {
Expand Down
15 changes: 14 additions & 1 deletion script/NestedSignFromJson.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@ import {stdJson} from "forge-std/StdJson.sol";
import {console} from "forge-std/console.sol";

contract NestedSignFromJson is NestedMultisigBuilder, JsonTxBuilderBase {
address globalSignerSafe; // Hack to avoid passing signerSafe as an input to many functions.

/// @dev Signs the approveHash transaction from the Nested Safe to the System Owner Safe.
function signJson(string memory _path, address _signerSafe) public {
_loadJson(_path);
sign(_signerSafe);
globalSignerSafe = _signerSafe;
_postCheckWithSim();
}

/// @dev Submits signatures to call approveHash on the System Owner Safe.
function approveJson(string memory _path, address _signerSafe, bytes memory _signatures) public {
_loadJson(_path);
approve(_signerSafe, _signatures);
globalSignerSafe = _signerSafe;
_postCheckWithSim();
}

/// @dev Executes the transaction from the System Owner Safe.
function runJson(string memory _path) public {
_loadJson(_path);
run();
// globalSignerSafe = _signerSafe; // TODO how to handle this one?
Comment thread
mds1 marked this conversation as resolved.
// _postCheckWithSim();
}

function _buildCalls() internal view override returns (IMulticall3.Call3[] memory) {
Expand All @@ -34,5 +42,10 @@ contract NestedSignFromJson is NestedMultisigBuilder, JsonTxBuilderBase {
return vm.envAddress("OWNER_SAFE");
}

function _postCheck() internal view override {}
function _postCheck() internal view virtual override {}

// A thorough postCheck would apply the needed state overrides and run the simulation, then
// execute those assertions against the resulting state. Using `vm.store` changes state therefore
// the postCheck methods cannot be `view`, which is why we have this alternate version.
function _postCheckWithSim() internal virtual {}
}
4 changes: 3 additions & 1 deletion script/SignFromJson.s.sol
Comment thread
0xfuturistic marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ contract SignFromJson is MultisigBuilder, JsonTxBuilderBase {
function signJson(string memory _path) public {
_loadJson(_path);
sign();
_postCheck();
}

function runJson(string memory _path, bytes memory _signatures) public {
_loadJson(_path);
run(_signatures);
_postCheck();
}

function _buildCalls() internal view override returns (IMulticall3.Call3[] memory) {
Expand All @@ -27,5 +29,5 @@ contract SignFromJson is MultisigBuilder, JsonTxBuilderBase {
return vm.envAddress("OWNER_SAFE");
}

function _postCheck() internal view override {}
function _postCheck() internal view virtual override {}
Comment thread
0xfuturistic marked this conversation as resolved.
}
21 changes: 18 additions & 3 deletions single.just
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export foundationOwner0 := "0x42d27eEA1AD6e22Af6284F609847CB3Cd56B9c64"
simulate hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=SignFromJson
if [ -f "${taskPath}/SignFromJson.s.sol" ]; then
script="${taskPath}/SignFromJson.s.sol"
fi
echo "Using script ${script}"
echo "getting signer address..."
if [ ! -z "$SIMULATE_WITHOUT_LEDGER" ]
then
Expand All @@ -22,31 +27,41 @@ simulate hdPath='0':
echo "Simulating with: ${signer}"
echo ""
forge build
forge script SignFromJson \
forge script ${script} \
--rpc-url ${rpcUrl} \
--sig "signJson(string)" ${bundlePath} \
--sender ${signer}

sign hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=SignFromJson
if [ -f "${taskPath}/SignFromJson.s.sol" ]; then
script="${taskPath}/SignFromJson.s.sol"
fi
echo "Using script ${script}"
echo "getting signer address..."
signer=$(cast wallet address --ledger --mnemonic-derivation-path "m/44'/60'/{{hdPath}}'/0/0")
echo "Signing with: ${signer}"
echo ""
forge build
$(git rev-parse --show-toplevel)/bin/eip712sign --ledger --hd-paths "m/44'/60'/{{hdPath}}'/0/0" -- \
forge script SignFromJson \
forge script ${script} \
--rpc-url ${rpcUrl} \
--sig "signJson(string)" \
${bundlePath}

execute hdPath='0':
#!/usr/bin/env bash
bundlePath=${taskPath}/${bundleName}.json
script=SignFromJson
if [ -f "${taskPath}/SignFromJson.s.sol" ]; then
script="${taskPath}/SignFromJson.s.sol"
fi
echo "Using script ${script}"
sender=$(cast wallet address --ledger --mnemonic-derivation-path "m/44'/60'/{{hdPath}}'/0/0")
forge build
forge script --fork-url ${ETH_RPC_URL} SignFromJson \
forge script --fork-url ${ETH_RPC_URL} ${script} \
--sig "runJson(string,bytes)" ${bundlePath} ${SIGNATURES} \
--ledger --hd-paths "m/44'/60'/{{hdPath}}'/0/0" --broadcast \
--sender ${sender}
Loading