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: add deterministic, multi-layer deployment script #1303

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
febc8a7
feat: add deterministic, multi-layer deployment script
Thegaram Apr 25, 2024
5c42eb3
disable bytecode_hash
Thegaram Apr 25, 2024
6eb58c1
rename param
Thegaram Apr 25, 2024
491aa91
use toml config file
Thegaram Apr 26, 2024
7b22288
add GenerateGenesisAlloc script
Thegaram Apr 26, 2024
e56d9a9
fmt
Thegaram Apr 26, 2024
9f7841a
add GenerateGenesis
Thegaram Apr 26, 2024
3c6c86e
move configurations
Thegaram Apr 26, 2024
31a636a
simplify contract address prediction
Thegaram Apr 26, 2024
421cd7e
clean up
Thegaram Apr 26, 2024
03fdd8e
move files
Thegaram Apr 26, 2024
ad5c475
docker
Thegaram Apr 26, 2024
623cf34
improve dockerfiles, better error messages
Thegaram Apr 27, 2024
dfab731
predeploy DeterministicDeploymentProxy
Thegaram Apr 27, 2024
7ac34b3
fmt
Thegaram Apr 27, 2024
d4bbb25
enable cache
Thegaram Apr 28, 2024
98d2c33
move files
Thegaram Apr 28, 2024
1d85682
small improvements
Thegaram Apr 28, 2024
5e59373
add simple build script
Thegaram Apr 28, 2024
180f3c6
ensure l1ChainId is serialized as string
Thegaram Apr 29, 2024
53b14bc
fix genesis extradata
Thegaram Apr 29, 2024
5b3a65b
use legacy txs on L2
Thegaram Apr 29, 2024
2d14457
make envs more configurable
Thegaram May 3, 2024
39db563
wip: generate other config files
Thegaram May 7, 2024
5497777
update dockerfile
Thegaram May 13, 2024
bc1cb1f
add missing files to container
Thegaram May 13, 2024
cbd3f54
update scripts
Thegaram May 13, 2024
0e28f28
Merge branch 'develop' into feat-deterministic-deployment
Thegaram May 21, 2024
f27d27c
add coordinator-config.json
Thegaram May 21, 2024
4ab7103
update redis config values
Thegaram May 22, 2024
e2b8787
add chain-monitor and balance-checker config gen
Thegaram May 22, 2024
2b5b82d
init frontend config
Thegaram May 31, 2024
fc0cb97
set mock finalization params
Thegaram Jun 4, 2024
15969d3
update frontend URLs
Thegaram Jun 10, 2024
53d0389
update base image to arm-friendly one
Thegaram Jun 13, 2024
977f570
fix REACT_APP_EXTERNAL_RPC_URI_L1
Thegaram Jun 18, 2024
29a3447
Merge branch 'develop' into feat-deterministic-deployment
Thegaram Jul 5, 2024
0680c0d
set Curie in genesis
Thegaram Jul 5, 2024
6e90535
bump foundry version
Thegaram Jul 5, 2024
f69fc7b
enable isCurie on deployment
Thegaram Jul 9, 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
47 changes: 47 additions & 0 deletions contracts/docker/Dockerfile.deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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

# 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 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"]
53 changes: 53 additions & 0 deletions contracts/docker/Dockerfile.gen-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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

# 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 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/scripts/gen-configs.sh /contracts/docker/scripts/gen-configs.sh

ENTRYPOINT ["/bin/bash", "/contracts/docker/scripts/gen-configs.sh"]
75 changes: 75 additions & 0 deletions contracts/docker/config-example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[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_L1_MESSAGE_GAS_LIMIT = 10000

L1_CONTRACT_DEPLOYMENT_BLOCK = 0

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"


[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"

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"
26 changes: 26 additions & 0 deletions contracts/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
46 changes: 46 additions & 0 deletions contracts/docker/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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 [ "${L1_RPC_ENDPOINT}" = "" ]; then
echo "L1_RPC_ENDPOINT is not set"
L1_RPC_ENDPOINT="http://host.docker.internal:8543"
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/foundry/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/foundry/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/foundry/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/foundry/DeployScroll.s.sol:DeployScroll --rpc-url "$L2_RPC_ENDPOINT" --batch-size "$BATCH_SIZE" --sig "run(string,string)" "L2" "verify-config" --broadcast --legacy || exit 1
33 changes: 33 additions & 0 deletions contracts/docker/scripts/gen-configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

echo ""
echo "generating config-contracts.toml"
forge script scripts/foundry/DeployScroll.s.sol:DeployScroll --sig "run(string,string)" "none" "write-config" || exit 1

echo ""
echo "generating genesis.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateGenesis || exit 1

echo ""
echo "generating rollup-config.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateRollupConfig || exit 1

echo ""
echo "generating coordinator-config.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateCoordinatorConfig || exit 1

echo ""
echo "generating chain-monitor-config.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateChainMonitorConfig || exit 1

echo ""
echo "generating bridge-history-config.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateBridgeHistoryConfig || exit 1

echo ""
echo "generating balance-checker-config.json"
forge script scripts/foundry/DeployScroll.s.sol:GenerateBalanceCheckerConfig || exit 1

echo ""
echo "generating .env.frontend"
forge script scripts/foundry/DeployScroll.s.sol:GenerateFrontendConfig || exit 1
24 changes: 24 additions & 0 deletions contracts/docker/scripts/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

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

docker push scrolltech/scroll-stack-contracts:gen-configs-$tag-amd64
docker push scrolltech/scroll-stack-contracts:gen-configs-$tag-arm64

docker manifest create scrolltech/scroll-stack-contracts:gen-configs-$tag \
--amend scrolltech/scroll-stack-contracts:gen-configs-$tag-amd64 \
--amend scrolltech/scroll-stack-contracts:gen-configs-$tag-arm64

docker manifest push scrolltech/scroll-stack-contracts:gen-configs-$tag

docker push scrolltech/scroll-stack-contracts:deploy-$tag-amd64
docker push scrolltech/scroll-stack-contracts:deploy-$tag-arm64

docker manifest create scrolltech/scroll-stack-contracts:deploy-$tag \
--amend scrolltech/scroll-stack-contracts:deploy-$tag-amd64 \
--amend scrolltech/scroll-stack-contracts:deploy-$tag-arm64

docker manifest push scrolltech/scroll-stack-contracts:deploy-$tag
42 changes: 42 additions & 0 deletions contracts/docker/templates/balance-checker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"addresses": [
{
"rpc_url": "${SCROLL_L1_RPC}",
"min_balance_ether": "10",
"address": "${L1_COMMIT_SENDER_ADDRESS}",
"name": "L1_COMMIT_SENDER"
},
{
"rpc_url": "${SCROLL_L1_RPC}",
"min_balance_ether": "10",
"address": "${L1_FINALIZE_SENDER_ADDRESS}",
"name": "L1_FINALIZE_SENDER"
},
{
"rpc_url": "${SCROLL_L1_RPC}",
"min_balance_ether": "1.1",
"address": "${L1_GAS_ORACLE_SENDER_ADDRESS}",
"name": "L1_GAS_ORACLE_SENDER"
},
{
"rpc_url": "${SCROLL_L1_RPC}",
"min_balance_ether": "0",
"address": "${L1_SCROLL_FEE_VAULT_ADDRESS}",
"name": "L1_SCROLL_FEE_VAULT"
},
{
"rpc_url": "${SCROLL_L2_RPC}",
"min_balance_ether": "1.1",
"address": "${L2_GAS_ORACLE_SENDER_ADDRESS}",
"name": "L2_GAS_ORACLE_SENDER"
},
{
"rpc_url": "${SCROLL_L2_RPC}",
"min_balance_ether": "0",
"address": "${L2_TX_FEE_VAULT_ADDR}",
"name": "L2_TX_FEE_VAULT"
}
],
"JOB_INTERVAL_SECS": 60,
"BIND_PORT": 8080
}
Loading