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: deterministic deployment scripts #5

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
003c9fe
feat: deterministic deployment scripts
Thegaram Jul 9, 2024
0d9b852
install ca-certificates
Thegaram Jul 10, 2024
0277a66
make isCurie configurable
Thegaram Jul 10, 2024
01f2db0
fix: add rollup config fields (#7)
yiweichi Jul 17, 2024
54d9b75
feat: add workflow to deploy docker images with github action (#8)
sbaizet-ledger Jul 17, 2024
ffa830b
fix: make env.frontend fields generate from config (#9)
yiweichi Jul 18, 2024
7b0b840
fix: log addresses script mode (#15)
yiweichi Jul 24, 2024
cdc9db1
feat: generate rollup explorer backend config (#14)
yiweichi Jul 25, 2024
f18a59a
feat: robust deployment script (#16)
yiweichi Jul 29, 2024
45bcd6c
docs: manual deployment document (#17)
yiweichi Jul 29, 2024
51f9917
fix: generate startHeight for bridge-history config (#18)
yiweichi Jul 29, 2024
cc9b579
fix: rollup config file
yiweichi Jul 30, 2024
1da6067
fix: dockerfile gen-config
yiweichi Jul 31, 2024
2fc37bd
feat: read max_chunks_per_batch from config.toml
yiweichi Aug 1, 2024
1f9cdd7
feat: log broadcast files
yiweichi Aug 1, 2024
244dc4f
feat: change name and placement of env.frontend
yiweichi Aug 7, 2024
b08cdc5
Revert "feat: change name and placement of env.frontend"
yiweichi Aug 14, 2024
4ca3a3c
fix: set l2 deployer balance in genesis
yiweichi Aug 20, 2024
65c5b4e
feat: alternative gas token (#20)
yiweichi Aug 20, 2024
0251956
fix: l2 genesis file owner
yiweichi Aug 20, 2024
9fe3780
fix: change frontend config name
yiweichi Aug 21, 2024
560aad6
feat: enable Darwin for deterministic deployment (#25)
Thegaram Aug 28, 2024
3b5ddcd
Merge branch 'main' into feat-deterministic-deployment
Thegaram Aug 30, 2024
4ad655b
clean up
Thegaram Aug 30, 2024
05e82c6
feat: enable darwinV2 (#29)
Thegaram Aug 30, 2024
187d29a
feat: use v2 zkevm verifier during initial deployment (#28)
Thegaram Aug 30, 2024
9adfdf5
refactor: clean up config.toml file (#32)
yiweichi Sep 2, 2024
3a2ab27
feat: remove dsn strings from configs (#34)
yiweichi Sep 4, 2024
3f9e8e4
fix: script check balance (#33)
yiweichi Sep 4, 2024
3793c18
Update genesis.json
Thegaram Sep 5, 2024
611913c
feat: add test to check deterministic addresses (#35)
Thegaram Sep 6, 2024
574c783
feat: remove private keys from rollup config (#36)
yiweichi Sep 10, 2024
0c993a7
feat: add admin system (#27)
yiweichi Sep 18, 2024
e5dfde6
fix: remove L2GasPriceOracle from deployment (#38)
yiweichi Sep 20, 2024
5b84246
feat: refactor config files to suit helm chart (#39)
yiweichi Sep 20, 2024
0414a23
fix: config file format (#41)
yiweichi Sep 24, 2024
45cdd68
fix: update rollup config confirmation value (#42)
yiweichi Sep 24, 2024
6ea11af
fix: l2 fee vault withdraw when using alt-gas-token (#44)
yiweichi Sep 26, 2024
128cdd0
fix: clean up
yiweichi Sep 26, 2024
e14c751
feat: configurable coordinator collection time sec (#51)
yiweichi Oct 11, 2024
f1454a1
ci: use workflow dispatch (#52)
sbaizet-ledger Oct 11, 2024
aa80925
feat: gas oracle support volatile gas token exchange rate (#49)
yiweichi Oct 14, 2024
0bcc998
fix: update config file for gas token
yiweichi Oct 16, 2024
848f31a
feat: support deploy plonk verifier (#56)
yiweichi Oct 23, 2024
40bd3e7
update chain monitor config (#59)
yiweichi Oct 30, 2024
a507de4
chore: clean up rollup config values (#60)
yiweichi Oct 31, 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
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: forge test --evm-version cancun -vvv

- name: Run foundry coverage
run : forge coverage --evm-version cancun --report lcov
run : forge coverage --evm-version cancun --skip "DeployScroll.t.sol" --report lcov

- name : Prune coverage
run : lcov --rc branch_coverage=1 --remove ./lcov.info -o ./lcov.info.pruned 'src/mocks/*' 'src/test/*' 'scripts/*' 'node_modules/*' 'lib/*'
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and publish scroll-alpine image
# This workflow aims to build images from the feat-deterministic-deployment branch

on:
workflow_dispatch:

jobs:
build:
name: Clone, Build, Publish
runs-on: ubuntu-latest
steps:

- name: Check out repository
uses: actions/checkout@v3
with:
submodules: true

- name: Update submodules recursively
run: git submodule update --init --recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '21'

- name: Install dependencies
run: npm install

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build deploy image
id: build_deploy_image
env:
REPOSITORY: scrolltech/scroll-stack-contracts
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: true
context: .
file: docker/Dockerfile.deploy
tags: |
${{ env.REPOSITORY }}:deploy-${{ github.sha }}

- name: Build gen image
id: build_gen_image
env:
REPOSITORY: scrolltech/scroll-stack-contracts
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: true
context: .
file: docker/Dockerfile.gen-configs
tags: |
${{ env.REPOSITORY }}:gen-configs-${{ github.sha }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ broadcast

# Visual Studio Code
.vscode

volume
.DS_Store
48 changes: 48 additions & 0 deletions docker/Dockerfile.deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Use the latest node Debian slim base image
# This makes installing yarn dep much easier
FROM node:20-bookworm-slim

# Switch to bash shell
SHELL ["/bin/bash", "-c"]

WORKDIR /root

# Install dependencies
RUN apt update
RUN apt install --yes curl bash coreutils git jq ca-certificates

# Download and run the Foundry installation script
RUN curl -L https://foundry.paradigm.xyz | bash

# Set the environment variables to ensure Foundry tools are in the PATH
ENV PATH="/root/.foundry/bin:${PATH}"

# Run foundryup to update Foundry
RUN foundryup -v nightly-56dbd20c7179570c53b6c17ff34daa7273a4ddae

# copy dependencies
COPY ./lib /contracts/lib
COPY ./node_modules/@openzeppelin /contracts/node_modules/@openzeppelin
COPY ./node_modules/hardhat /contracts/node_modules/hardhat

# copy configurations
COPY foundry.toml /contracts/foundry.toml
COPY remappings.txt /contracts/remappings.txt

# copy source code
COPY ./src /contracts/src
COPY ./scripts /contracts/scripts

# compile contracts
ENV FOUNDRY_EVM_VERSION="cancun"
ENV FOUNDRY_BYTECODE_HASH="none"

WORKDIR /contracts
RUN forge build

# copy script configs
COPY ./docker/templates/config-contracts.toml /contracts/docker/templates/config-contracts.toml

COPY ./docker/scripts/deploy.sh /contracts/docker/scripts/deploy.sh

ENTRYPOINT ["/bin/bash", "/contracts/docker/scripts/deploy.sh"]
56 changes: 56 additions & 0 deletions docker/Dockerfile.gen-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Use the latest node Debian slim base image
# This makes installing yarn dep much easier
FROM node:20-bookworm-slim

# Switch to bash shell
SHELL ["/bin/bash", "-c"]

WORKDIR /root

# Install dependencies
RUN apt update
RUN apt install --yes curl bash coreutils git jq ca-certificates

# Download and run the Foundry installation script
RUN curl -L https://foundry.paradigm.xyz | bash

# Set the environment variables to ensure Foundry tools are in the PATH
ENV PATH="/root/.foundry/bin:${PATH}"

# Run foundryup to update Foundry
RUN foundryup -v nightly-56dbd20c7179570c53b6c17ff34daa7273a4ddae

# copy dependencies
COPY ./lib /contracts/lib
COPY ./node_modules/@openzeppelin /contracts/node_modules/@openzeppelin
COPY ./node_modules/hardhat /contracts/node_modules/hardhat

# copy configurations
COPY foundry.toml /contracts/foundry.toml
COPY remappings.txt /contracts/remappings.txt

# copy source code
COPY ./src /contracts/src
COPY ./scripts /contracts/scripts

# compile contracts
ENV FOUNDRY_EVM_VERSION="cancun"
ENV FOUNDRY_BYTECODE_HASH="none"

WORKDIR /contracts
RUN forge build

# copy script configs
COPY ./docker/templates/balance-checker-config.json /contracts/docker/templates/balance-checker-config.json
COPY ./docker/templates/bridge-history-config.json /contracts/docker/templates/bridge-history-config.json
COPY ./docker/templates/chain-monitor-config.json /contracts/docker/templates/chain-monitor-config.json
COPY ./docker/templates/config-contracts.toml /contracts/docker/templates/config-contracts.toml
COPY ./docker/templates/coordinator-config.json /contracts/docker/templates/coordinator-config.json
COPY ./docker/templates/genesis.json /contracts/docker/templates/genesis.json
COPY ./docker/templates/rollup-config.json /contracts/docker/templates/rollup-config.json
COPY ./docker/templates/rollup-explorer-backend-config.json /contracts/docker/templates/rollup-explorer-backend-config.json
COPY ./docker/templates/admin-system-backend-config.json /contracts/docker/templates/admin-system-backend-config.json

COPY ./docker/scripts/gen-configs.sh /contracts/docker/scripts/gen-configs.sh

ENTRYPOINT ["/bin/bash", "/contracts/docker/scripts/gen-configs.sh"]
124 changes: 124 additions & 0 deletions docker/config-example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[general]

L1_RPC_ENDPOINT = "http://l1-devnet:8545"
L1_RPC_ENDPOINT_WEBSOCKET = "ws://l1-devnet:8546"
L2_RPC_ENDPOINT = "http://l2-sequencer:8545"

CHAIN_NAME_L1="Ethereum"
CHAIN_NAME_L2="Scroll SDK"
CHAIN_ID_L1 = 111111
CHAIN_ID_L2 = 221122

L1_CONTRACT_DEPLOYMENT_BLOCK = 0

[accounts]

# note: for now we simply use Anvil's dev accounts

DEPLOYER_PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

L1_COMMIT_SENDER_PRIVATE_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
L1_FINALIZE_SENDER_PRIVATE_KEY = "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
L1_GAS_ORACLE_SENDER_PRIVATE_KEY = "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"
L2_GAS_ORACLE_SENDER_PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

DEPLOYER_ADDR = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
OWNER_ADDR = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"

L1_COMMIT_SENDER_ADDR = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
L1_FINALIZE_SENDER_ADDR = "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
L1_GAS_ORACLE_SENDER_ADDR = "0x90F79bf6EB2c4f870365E785982E1f101E93b906"
L2_GAS_ORACLE_SENDER_ADDR = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"

[db]

ADMIN_SYSTEM_BACKEND_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
BLOCKSCOUT_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/blockscout"
BRIDGE_HISTORY_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
CHAIN_MONITOR_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
GAS_ORACLE_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
COORDINATOR_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
L1_EXPLORER_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/l1-explorer"
ROLLUP_NODE_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"
ROLLUP_EXPLORER_DB_CONNECTION_STRING = "postgres://postgres:qwerty12345@postgresql:5432/scroll?sslmode=disable"

[gas-token]

ALTERNATIVE_GAS_TOKEN_ENABLED = false
# EXAMPLE_GAS_TOKEN_DECIMAL = 6
# L1_GAS_TOKEN = "0x68a041e7c20Afa4784b5d9C63246c89545Ac0E66"
GAS_ORACLE_INCORPORATE_TOKEN_EXCHANGE_RATE_ENANBLED = false
EXCHANGE_RATE_UPDATE_MODE = "Fixed"
FIXED_EXCHANGE_RATE = "0.01"
TOKEN_SYMBOL_PAIR = "UNIETH"

[sequencer]

L2GETH_SIGNER_ADDRESS = "0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6"
L2GETH_KEYSTORE = '{"address":"756ea06bdee36de11f22dcca45a31d8a178ef3c6","crypto":{"cipher":"aes-128-ctr","ciphertext":"8bfb4e48c6b172f1f5794d2874476ca62f8184507c0916dbd45fe77a0056114c","cipherparams":{"iv":"509eb70e7379a776e0779634b6668277"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"ef0f0334e5db7c12d76993e1e9627593fd0d7cd44444b689e792c86bc8a5d75f"},"mac":"d766cac11d0bd563316f5655ebf07550b6fce98ba0ca3c13acdc1b65f5f185ca"},"id":"4459ad67-f2ce-48b2-8940-c0582106a4c6","version":3}'
L2GETH_PASSWORD = "scroll2022"
L2GETH_NODEKEY = "2f59ff2fdee1c42a3d8c8980c313bc8d6c2557463f7bb92b0f0bc89a6d3cbf01"
L2_GETH_STATIC_PEERS = '["enode://848a7d59dd8f60dd1a51160e6bc15c194937855443de9be4b2abd83e11a5c4ac21d61d065448c5c520826fe83f1f29eb5a452daccca27b8113aa897074132507@l2-sequencer:30303"]'
L2GETH_CCC_NUMWORKERS = 5

[rollup]

MAX_TX_IN_CHUNK = 100
MAX_BLOCK_IN_CHUNK = 100
MAX_BATCH_IN_BUNDLE = 30
MAX_L1_MESSAGE_GAS_LIMIT = 10_000_000
TEST_ENV_MOCK_FINALIZE_ENABLED = true
TEST_ENV_MOCK_FINALIZE_TIMEOUT_SEC = 300

[frontend]

EXTERNAL_RPC_URI_L1 = "http://l1-devnet.scrollsdk"
EXTERNAL_RPC_URI_L2 = "http://l2-rpc.scrollsdk"
BRIDGE_API_URI = "http://bridge-history-api.scrollsdk/api"
ROLLUPSCAN_API_URI = "http://rollup-explorer-backend.scrollsdk/api"
EXTERNAL_EXPLORER_URI_L1 = "http://l1-explorer.scrollsdk"
EXTERNAL_EXPLORER_URI_L2 = "http://blockscout.scrollsdk"
ADMIN_SYSTEM_DASHBOARD_URI = "http://admin-system-dashboard.scrollsdk"
GRAFANA_URI = "http://grafana.scrollsdk"

[genesis]

L2_MAX_ETH_SUPPLY = "226156424291633194186662080095093570025917938800079226639565593765455331328"
L2_DEPLOYER_INITIAL_BALANCE = 1000000000000000000

[contracts]

DEPLOYMENT_SALT = "devnetSalt-000"

# contracts deployed outside this script
L1_FEE_VAULT_ADDR = "0x0000000000000000000000000000000000000001"

[contracts.overrides]

# L1_WETH = "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
# L1_PLONK_VERIFIER = "0x0000000000000000000000000000000000000001"

L2_MESSAGE_QUEUE = "0x5300000000000000000000000000000000000000"
L1_GAS_PRICE_ORACLE = "0x5300000000000000000000000000000000000002"
L2_WHITELIST = "0x5300000000000000000000000000000000000003"
L2_WETH = "0x5300000000000000000000000000000000000004"
L2_TX_FEE_VAULT = "0x5300000000000000000000000000000000000005"


[coordinator]

CHUNK_COLLECTION_TIME_SEC = 3600
BATCH_COLLECTION_TIME_SEC = 1800
BUNDLE_COLLECTION_TIME_SEC = 600
COORDINATOR_JWT_SECRET_KEY = "e788b62d39254928a821ac1c76b274a8c835aa1e20ecfb6f50eb10e87847de44"

[ingress]

FRONTEND_HOST = "frontends.scrollsdk"
BRIDGE_HISTORY_API_HOST = "bridge-history-api.scrollsdk"
ROLLUP_EXPLORER_API_HOST = "rollup-explorer-backend.scrollsdk"
COORDINATOR_API_HOST = "coordinator-api.scrollsdk"
RPC_GATEWAY_HOST = "l2-rpc.scrollsdk"
BLOCKSCOUT_HOST = "blockscout.scrollsdk"
ADMIN_SYSTEM_DASHBOARD_HOST= "admin-system-dashboard.scrollsdk"
GRAFANA_HOST = "http://grafana.scrollsdk"
26 changes: 26 additions & 0 deletions docker/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

latest_commit=$(git log -1 --pretty=format:%h)
tag=${latest_commit:0:8}
echo "Using Docker image tag: $tag"
echo ""

docker build -f docker/Dockerfile.gen-configs -t scrolltech/scroll-stack-contracts:gen-configs-$tag-amd64 --platform linux/amd64 .
echo
echo "built scrolltech/scroll-stack-contracts:gen-configs-$tag-amd64"
echo

docker build -f docker/Dockerfile.gen-configs -t scrolltech/scroll-stack-contracts:gen-configs-$tag-arm64 --platform linux/arm64 .
echo
echo "built scrolltech/scroll-stack-contracts:gen-configs-$tag-arm64"
echo

docker build -f docker/Dockerfile.deploy -t scrolltech/scroll-stack-contracts:deploy-$tag-amd64 --platform linux/amd64 .
echo
echo "built scrolltech/scroll-stack-contracts:deploy-$tag-amd64"
echo

docker build -f docker/Dockerfile.deploy -t scrolltech/scroll-stack-contracts:deploy-$tag-arm64 --platform linux/arm64 .
echo
echo "built scrolltech/scroll-stack-contracts:deploy-$tag-arm64"
echo
52 changes: 52 additions & 0 deletions docker/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

export FOUNDRY_EVM_VERSION="cancun"
export FOUNDRY_BYTECODE_HASH="none"

if [ "${L1_RPC_ENDPOINT}" = "" ]; then
echo "L1_RPC_ENDPOINT is not set"
L1_RPC_ENDPOINT="http://host.docker.internal:8543"
fi

if [ "$L2_RPC_ENDPOINT" = "" ]; then
echo "L2_RPC_ENDPOINT is not set"
L2_RPC_ENDPOINT="http://host.docker.internal:8545"
fi

if [ "${BATCH_SIZE}" = "" ]; then
BATCH_SIZE="100"
fi

echo "using L1_RPC_ENDPOINT = $L1_RPC_ENDPOINT"
echo "using L2_RPC_ENDPOINT = $L2_RPC_ENDPOINT"

# simulate L1
echo ""
echo "simulating on L1"
forge script scripts/deterministic/DeployScroll.s.sol:DeployScroll --rpc-url "$L1_RPC_ENDPOINT" --sig "run(string,string)" "L1" "verify-config" || exit 1

# simulate L2
echo ""
echo "simulating on L2"
forge script scripts/deterministic/DeployScroll.s.sol:DeployScroll --rpc-url "$L2_RPC_ENDPOINT" --sig "run(string,string)" "L2" "verify-config" --legacy || exit 1

# deploy L1
echo ""
echo "deploying on L1"
forge script scripts/deterministic/DeployScroll.s.sol:DeployScroll --rpc-url "$L1_RPC_ENDPOINT" --batch-size "$BATCH_SIZE" --sig "run(string,string)" "L1" "verify-config" --broadcast || exit 1

# deploy L2
echo ""
echo "deploying on L2"
forge script scripts/deterministic/DeployScroll.s.sol:DeployScroll --rpc-url "$L2_RPC_ENDPOINT" --batch-size "$BATCH_SIZE" --sig "run(string,string)" "L2" "verify-config" --broadcast --legacy || exit 1

# log broadcast files
echo ""
echo "Broadcast files:"
for file in broadcast/DeployScroll.s.sol/*/*; do
if [ -f "$file" ]; then
echo "$file:"
cat "$file"
echo ""
fi
done
Loading