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

Change Folder Structure for Example Tasks #26

Draft
wants to merge 12 commits into
base: chore/remove-constants-file
Choose a base branch
from
129 changes: 98 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2.1

parameters:
ci_builder_image:
default_docker_image:
type: string
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.47.3
default: cimg/base:2024.01
l1_mainnet_rpc_url:
type: string
default: "https://ci-mainnet-l1.optimism.io"
Expand All @@ -21,6 +21,66 @@ parameters:
default: 5

commands:
checkout-with-mise:
steps:
- checkout
- run:
name: Initialize mise environment
command: |
# This is used to create a per-user cache key to preserve permissions across different
# executor types.
user=$(whoami)
echo "$user" > .executor-user
echo "Set executor user to $user."

if [[ "$user" == "root" ]]; then
# Self-hosted runners will persist this cache between runs. Cleaning it up means that we
# preserve the semantics of the cache regardless of executor type. It's also much faster
# to delete the cache and recreate it than it is to overwrite it in place.
rm -rf /data/mise-data
echo "Cleaned up cache data."

mkdir -p /data/mise-data
echo "Created Mise data dir."
mkdir -p ~/.cache
echo "Created Mise cache dir."
else
sudo rm -rf /data/mise-data
echo "Cleaned up cache data."
sudo mkdir -p /data/mise-data
sudo chown -R "$user:$user" /data/mise-data
echo "Created Mise data dir."
sudo mkdir -p ~/.cache
sudo chown -R "$user:$user" ~/.cache
echo "Created Mise cache dir."
fi
- restore_cache:
name: Restore mise cache
keys:
- mise-v5-{{ checksum ".executor-user" }}-{{ checksum "mise.toml" }}
- run:
name: Install mise
command: |
if command -v mise &> /dev/null; then
echo "mise already installed at $(command -v mise)"
else
curl https://mise.run | sh
fi

echo "export PATH=\"$HOME/.local/bin:\$PATH\"" >> "$BASH_ENV"
echo "export MISE_DATA_DIR=/data/mise-data" >> "$BASH_ENV"
echo "export MISE_JOBS=$(nproc)" >> "$BASH_ENV"
echo "eval \"\$($HOME/.local/bin/mise activate --shims)\"" >> "$BASH_ENV"
- run:
name: Install mise deps
command: |
mise install -v -y
- save_cache:
name: Save mise cache
key: mise-v5-{{ checksum ".executor-user" }}-{{ checksum "mise.toml" }}
paths:
- /data/mise-data

simulate:
description: "Runs simulations of a task"
parameters:
Expand Down Expand Up @@ -63,9 +123,9 @@ jobs:
check_sepolia_rpc_endpoints:
circleci_ip_ranges: true
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: Check Sepolia RPC Endpoints
command: |
Expand All @@ -92,9 +152,9 @@ jobs:
check_mainnet_rpc_endpoints:
circleci_ip_ranges: true
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: Check Mainnet RPC Endpoints
command: |
Expand All @@ -120,9 +180,9 @@ jobs:

check_task_statuses:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- attach_workspace:
at: .
- run:
Expand All @@ -131,9 +191,9 @@ jobs:

check_nonce_overrides:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- attach_workspace:
at: .
- run:
Expand All @@ -144,7 +204,7 @@ jobs:
example_mainnet_job:
circleci_ip_ranges: true
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- attach_workspace:
at: .
Expand All @@ -164,9 +224,9 @@ jobs:

just_simulate_sc_rehearsal_1:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: just simulate r1-hello-council
command: |
Expand All @@ -181,9 +241,9 @@ jobs:

just_simulate_sc_rehearsal_2:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: just simulate r2-remove-signer
command: |
Expand All @@ -199,9 +259,9 @@ jobs:

just_simulate_sc_rehearsal_4:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: just simulate r4-jointly-upgrade
command: |
Expand All @@ -213,26 +273,28 @@ jobs:
just simulate-council
just prepare-json
just simulate-council # simulate again to make sure the json is still valid

just_simulate_ink_respected_game_type:
docker:
- image: << pipeline.parameters.ci_builder_image >>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout-with-mise
- simulate:
task: "/eth/ink-002-set-respected-game-type"

just_simulate_eth_029_holocene_system_config_upgrade_and_init_base:
docker:
- image: << pipeline.parameters.ci_builder_image >>
- image: << pipeline.parameters.default_docker_image >>
steps:
- simulate:
- checkout-with-mise
- simulate_nested:
task: "/eth/029-holocene-system-config-upgrade-and-init-base"

forge_build:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: forge build
command: |
Expand All @@ -242,20 +304,21 @@ jobs:

forge_fmt:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: forge fmt
command: |
just install
forge --version
forge fmt --check

forge_test:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: forge test
command: |
Expand All @@ -264,9 +327,9 @@ jobs:

print_versions:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
- image: <<pipeline.parameters.default_docker_image>>
steps:
- checkout
- checkout-with-mise
- run:
name: print versions
command: |
Expand Down Expand Up @@ -298,7 +361,11 @@ workflows:
# expect the ceremony to work continuously), and remove it once
# the ceremony is for historical archive only (e.g. the
# ceremony is done).
- just_simulate_sc_rehearsal_1
#
# We skip rehearsal 1 because we already have completed this rehearsal (https://github.com/ethereum-optimism/superchain-ops/pull/459),
# and now it fails with stack too deep after https://github.com/ethereum-optimism/superchain-ops/pull/528.
# We wll need to rewrite the rehearsals with the new superchain-ops structure anyway, so this is ok.
# - just_simulate_sc_rehearsal_1
- just_simulate_sc_rehearsal_2
- just_simulate_sc_rehearsal_4
- just_simulate_ink_respected_game_type
Expand Down
4 changes: 1 addition & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
src = "src"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 999999
optimizer = false
solc_version = "0.8.15"
evm_version = "cancun"
via_ir = true
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
Expand Down
19 changes: 19 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tools]

# Core dependencies
go = "1.22.7"
just = "1.37.0"
yq = "4.44.5"

# Foundry dependencies
# Foundry is a special case because it supplies multiple binaries at the same
# GitHub release, so we need to use the aliasing trick to get mise to not error
# The git ref here should be on the `stable` branch.
forge = "nightly-5d16800a64e5357fbb2493e4cae061756d145981"
cast = "nightly-5d16800a64e5357fbb2493e4cae061756d145981"
anvil = "nightly-5d16800a64e5357fbb2493e4cae061756d145981"

[alias]
forge = "ubi:foundry-rs/foundry[exe=forge]"
cast = "ubi:foundry-rs/foundry[exe=cast]"
anvil = "ubi:foundry-rs/foundry[exe=anvil]"
8 changes: 7 additions & 1 deletion src/fps/AddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ contract AddressRegistry is IAddressRegistry, Test {
revert(string.concat("Failed to parse network config file path: ", networkConfigFilePath));
}

chains = abi.decode(chainListContent, (ChainInfo[]));
// Cannot assign the abi.decode result to `chains` directly because it's a storage array, so
// compiling without via-ir will fail with:
// Unimplemented feature (/solidity/libsolidity/codegen/ArrayUtils.cpp:228):Copying of type struct AddressRegistry.ChainInfo memory[] memory to storage not yet supported.
ChainInfo[] memory _chains = abi.decode(chainListContent, (ChainInfo[]));
for (uint256 i = 0; i < _chains.length; i++) {
chains.push(_chains[i]);
}

/// should never revert
string memory chainAddressesContent =
Expand Down
8 changes: 4 additions & 4 deletions src/fps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ This toml configuration file allows task developers to set gas limits for the ta
#### Template 00 to set gas configs:

```bash
forge script src/fps/example/template/GasConfigTemplate.sol --sig "run(string)" src/fps/example/task-00/mainnetConfig.toml --rpc-url mainnet -vvv
forge script test/task/mock/example/template/GasConfigTemplate.sol --sig "run(string)" test/task/mock/example/task-00/mainnetConfig.toml --rpc-url mainnet -vvv
```

#### Template 01 to set dispute game upgrade:

```bash
forge script src/fps/example/template/DisputeGameUpgradeTemplate.sol --sig "run(string)" src/fps/example/task-01/mainnetConfig.toml --rpc-url mainnet -vvv
forge script test/task/mock/example/template/DisputeGameUpgradeTemplate.sol --sig "run(string)" test/task/mock/example/task-01/mainnetConfig.toml --rpc-url mainnet -vvv
```

#### Template 02 to set respected game type:

```bash
forge script src/fps/example/template/SetGameTypeTemplate.sol --sig "run(string)" src/fps/example/task-02/mainnetConfig.toml --rpc-url mainnet -vvvvv
forge script test/task/mock/example/template/SetGameTypeTemplate.sol --sig "run(string)" test/task/mock/example/task-02/mainnetConfig.toml --rpc-url mainnet -vvvvv
```

#### Template 03 to set gas config:

```bash
forge script src/fps/example/template/GasConfigTemplate.sol --sig "run(string)" src/fps/example/task-03/mainnetConfig.toml --rpc-url mainnet -vvvvv
forge script test/task/mock/example/template/GasConfigTemplate.sol --sig "run(string)" test/task/mock/example/task-03/mainnetConfig.toml --rpc-url mainnet -vvvvv
```
2 changes: 1 addition & 1 deletion src/fps/doc/CALLDATA_DIFFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data: `0xb40a817c000000000000000000000000000000000000000000000000000000000393870

command:
```bash
forge script src/fps/example/template/GasConfigTemplate.sol --sig "run(string)" src/fps/example/task-03/mainnetConfig.toml --rpc-url mainnet -vvv
forge script test/task/mock/example/template/GasConfigTemplate.sol --sig "run(string)" test/task/mock/example/task-03/mainnetConfig.toml --rpc-url mainnet -vvv
```

Calldata diff can be found here https://www.diffchecker.com/HA7YFSWi/, select character comparison to see the difference.
Loading