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 23 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
69 changes: 69 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and publish scroll-alpine image

on:
push:
tags:
- 'v*.*.*'
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:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
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.ref_name }}
${{ env.REPOSITORY }}:latest

- name: Build gen image
id: build_gen_image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
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.ref_name }}
${{ env.REPOSITORY }}:latest
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"]
55 changes: 55 additions & 0 deletions docker/Dockerfile.gen-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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/scripts/gen-configs.sh /contracts/docker/scripts/gen-configs.sh

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

L1_RPC_ENDPOINT = "http://l1geth:8545"
L2_RPC_ENDPOINT = "http://l2geth:8545"

CHAIN_ID_L1 = 111111
CHAIN_ID_L2 = 222222

MAX_TX_IN_CHUNK = 100
MAX_BLOCK_IN_CHUNK = 100
MAX_CHUNK_IN_BATCH = 15
MAX_BATCH_IN_BUNDLE = 30
MAX_L1_MESSAGE_GAS_LIMIT = 10000000

L1_CONTRACT_DEPLOYMENT_BLOCK = 0

ALTERNATIVE_GAS_TOKEN_ENABLED = true
# EXAMPLE_GAS_TOKEN_DECIMAL = 6

TEST_ENV_MOCK_FINALIZE_ENABLED = true
TEST_ENV_MOCK_FINALIZE_TIMEOUT_SEC = 3600


[accounts]

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

DEPLOYER_PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
OWNER_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"

L2GETH_SIGNER_0_ADDRESS = "0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6"

[db]

SCROLL_DB_CONNECTION_STRING = "postgres://postgres:scroll2022@db:5432/scroll?sslmode=disable"
CHAIN_MONITOR_DB_CONNECTION_STRING = "postgres://postgres:scroll2022@db:5432/chain_monitor?sslmode=disable"
BRIDGE_HISTORY_DB_CONNECTION_STRING = "postgres://postgres:scroll2022@db:5432/bridge_history?sslmode=disable"
ROLLUP_EXPLORER_DB_CONNECTION_STRING = "postgres://postgres:scroll2022@db:5432/rollup_explorer?sslmode=disable"


[genesis]

L2_MAX_ETH_SUPPLY = "226156424291633194186662080095093570025917938800079226639565593765455331328"
L2_DEPLOYER_INITIAL_BALANCE = 1000000000000000000


[contracts]

DEPLOYMENT_SALT = ""

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

[contracts.overrides]

# L1_WETH = "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
# L1_GAS_TOKEN = "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"

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


[coordinator]

COORDINATOR_JWT_SECRET_KEY = "e788b62d39254928a821ac1c76b274a8c835aa1e20ecfb6f50eb10e87847de44"

[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 = "https://rollup-explorer-backend.scrollsdk/api"
EXTERNAL_EXPLORER_URI_L1 = "http://l1-explorer.scrollsdk"
EXTERNAL_EXPLORER_URI_L2 = "http://blockscout.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