|
|
|
@ -9,9 +9,6 @@ CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
|
|
|
|
|
|
|
|
|
|
CERC_L1_ACCOUNTS_CSV_URL="${CERC_L1_ACCOUNTS_CSV_URL:-${DEFAULT_CERC_L1_ACCOUNTS_CSV_URL}}"
|
|
|
|
|
|
|
|
|
|
CERC_PROPOSER_AMOUNT="${CERC_PROPOSER_AMOUNT:-${DEFAULT_CERC_PROPOSER_AMOUNT}}"
|
|
|
|
|
CERC_BATCHER_AMOUNT="${CERC_BATCHER_AMOUNT:-${DEFAULT_CERC_BATCHER_AMOUNT}}"
|
|
|
|
|
|
|
|
|
|
export DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID"
|
|
|
|
|
# Optional create2 salt for deterministic deployment of contract implementations
|
|
|
|
|
export IMPL_SALT=$(openssl rand -hex 32)
|
|
|
|
@ -19,7 +16,7 @@ export IMPL_SALT=$(openssl rand -hex 32)
|
|
|
|
|
echo "Using L1 RPC endpoint ${CERC_L1_RPC}"
|
|
|
|
|
|
|
|
|
|
# Exit if a deployment already exists (on restarts)
|
|
|
|
|
if [ -f "/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" ]; then
|
|
|
|
|
if [ -d "/l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" ]; then
|
|
|
|
|
echo "Deployment directory /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json, checking OptimismPortal deployment"
|
|
|
|
|
|
|
|
|
|
OPTIMISM_PORTAL_ADDRESS=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json | jq -r .OptimismPortal)
|
|
|
|
@ -50,78 +47,59 @@ wait_for_block() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# We need four accounts and their private keys for the deployment: Admin, Proposer, Batcher, and Sequencer
|
|
|
|
|
# Check if accounts file already exists
|
|
|
|
|
l2_accounts_file="/l2-accounts/accounts.json"
|
|
|
|
|
if [ -f $l2_accounts_file ]; then
|
|
|
|
|
echo "Using existing accounts from $l2_accounts_file."
|
|
|
|
|
|
|
|
|
|
ADMIN=$(jq -r .Admin $l2_accounts_file)
|
|
|
|
|
ADMIN_KEY=$(jq -r .AdminKey $l2_accounts_file)
|
|
|
|
|
# If $CERC_L1_ADDRESS and $CERC_L1_PRIV_KEY have been set, we'll assign it to Admin and generate/fund the remaining three accounts from it
|
|
|
|
|
# If not, we'll assume the L1 is the stack's own fixturenet-eth and use the pre-funded accounts/keys from $CERC_L1_ACCOUNTS_CSV_URL
|
|
|
|
|
if [ -n "$CERC_L1_ADDRESS" ] && [ -n "$CERC_L1_PRIV_KEY" ]; then
|
|
|
|
|
wallet1=$(cast wallet new)
|
|
|
|
|
wallet2=$(cast wallet new)
|
|
|
|
|
wallet3=$(cast wallet new)
|
|
|
|
|
# Admin
|
|
|
|
|
ADMIN=$CERC_L1_ADDRESS
|
|
|
|
|
ADMIN_KEY=$CERC_L1_PRIV_KEY
|
|
|
|
|
# Proposer
|
|
|
|
|
PROPOSER=$(jq -r .Proposer $l2_accounts_file)
|
|
|
|
|
PROPOSER_KEY=$(jq -r .ProposerKey $l2_accounts_file)
|
|
|
|
|
PROPOSER=$(echo "$wallet1" | awk '/Address:/{print $2}')
|
|
|
|
|
PROPOSER_KEY=$(echo "$wallet1" | awk '/Private key:/{print $3}')
|
|
|
|
|
# Batcher
|
|
|
|
|
BATCHER=$(jq -r .Batcher $l2_accounts_file)
|
|
|
|
|
BATCHER_KEY=$(jq -r .BatcherKey $l2_accounts_file)
|
|
|
|
|
BATCHER=$(echo "$wallet2" | awk '/Address:/{print $2}')
|
|
|
|
|
BATCHER_KEY=$(echo "$wallet2" | awk '/Private key:/{print $3}')
|
|
|
|
|
# Sequencer
|
|
|
|
|
SEQ=$(jq -r .Seq $l2_accounts_file)
|
|
|
|
|
SEQ_KEY=$(jq -r .SeqKey $l2_accounts_file)
|
|
|
|
|
SEQ=$(echo "$wallet3" | awk '/Address:/{print $2}')
|
|
|
|
|
SEQ_KEY=$(echo "$wallet3" | awk '/Private key:/{print $3}')
|
|
|
|
|
|
|
|
|
|
echo "Funding accounts."
|
|
|
|
|
wait_for_block 1 300
|
|
|
|
|
cast send --from $ADMIN --rpc-url $CERC_L1_RPC --value 5ether $PROPOSER --private-key $ADMIN_KEY
|
|
|
|
|
cast send --from $ADMIN --rpc-url $CERC_L1_RPC --value 10ether $BATCHER --private-key $ADMIN_KEY
|
|
|
|
|
cast send --from $ADMIN --rpc-url $CERC_L1_RPC --value 2ether $SEQ --private-key $ADMIN_KEY
|
|
|
|
|
else
|
|
|
|
|
# If $CERC_L1_ADDRESS and $CERC_L1_PRIV_KEY have been set, we'll assign it to Admin and generate/fund the remaining three accounts from it
|
|
|
|
|
# If not, we'll assume the L1 is the stack's own fixturenet-eth and use the pre-funded accounts/keys from $CERC_L1_ACCOUNTS_CSV_URL
|
|
|
|
|
|
|
|
|
|
if [ -n "$CERC_L1_ADDRESS" ] && [ -n "$CERC_L1_PRIV_KEY" ]; then
|
|
|
|
|
echo "Creating new accounts for Optimism deployment."
|
|
|
|
|
wallet1=$(cast wallet new)
|
|
|
|
|
wallet2=$(cast wallet new)
|
|
|
|
|
wallet3=$(cast wallet new)
|
|
|
|
|
# Admin
|
|
|
|
|
ADMIN=$CERC_L1_ADDRESS
|
|
|
|
|
ADMIN_KEY=$CERC_L1_PRIV_KEY
|
|
|
|
|
# Proposer
|
|
|
|
|
PROPOSER=$(echo "$wallet1" | awk '/Address:/{print $2}')
|
|
|
|
|
PROPOSER_KEY=$(echo "$wallet1" | awk '/Private key:/{print $3}')
|
|
|
|
|
# Batcher
|
|
|
|
|
BATCHER=$(echo "$wallet2" | awk '/Address:/{print $2}')
|
|
|
|
|
BATCHER_KEY=$(echo "$wallet2" | awk '/Private key:/{print $3}')
|
|
|
|
|
# Sequencer
|
|
|
|
|
SEQ=$(echo "$wallet3" | awk '/Address:/{print $2}')
|
|
|
|
|
SEQ_KEY=$(echo "$wallet3" | awk '/Private key:/{print $3}')
|
|
|
|
|
|
|
|
|
|
echo "Funding accounts..."
|
|
|
|
|
wait_for_block 1 300
|
|
|
|
|
cast send --from $ADMIN --rpc-url $CERC_L1_RPC --value $CERC_PROPOSER_AMOUNT $PROPOSER --private-key $ADMIN_KEY
|
|
|
|
|
cast send --from $ADMIN --rpc-url $CERC_L1_RPC --value $CERC_BATCHER_AMOUNT $BATCHER --private-key $ADMIN_KEY
|
|
|
|
|
else
|
|
|
|
|
curl -o accounts.csv $CERC_L1_ACCOUNTS_CSV_URL
|
|
|
|
|
# Admin
|
|
|
|
|
ADMIN=$(awk -F ',' 'NR == 1 {print $2}' accounts.csv)
|
|
|
|
|
ADMIN_KEY=$(awk -F ',' 'NR == 1 {print $3}' accounts.csv)
|
|
|
|
|
# Proposer
|
|
|
|
|
PROPOSER=$(awk -F ',' 'NR == 2 {print $2}' accounts.csv)
|
|
|
|
|
PROPOSER_KEY=$(awk -F ',' 'NR == 2 {print $3}' accounts.csv)
|
|
|
|
|
# Batcher
|
|
|
|
|
BATCHER=$(awk -F ',' 'NR == 3 {print $2}' accounts.csv)
|
|
|
|
|
BATCHER_KEY=$(awk -F ',' 'NR == 3 {print $3}' accounts.csv)
|
|
|
|
|
# Sequencer
|
|
|
|
|
SEQ=$(awk -F ',' 'NR == 4 {print $2}' accounts.csv)
|
|
|
|
|
SEQ_KEY=$(awk -F ',' 'NR == 4 {print $3}' accounts.csv)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# These accounts will be needed by other containers, so write them to a shared volume
|
|
|
|
|
echo "Writing accounts/private keys to volume l2_accounts."
|
|
|
|
|
accounts_json=$(jq -n \
|
|
|
|
|
--arg Admin "$ADMIN" --arg AdminKey "$ADMIN_KEY" \
|
|
|
|
|
--arg Proposer "$PROPOSER" --arg ProposerKey "$PROPOSER_KEY" \
|
|
|
|
|
--arg Batcher "$BATCHER" --arg BatcherKey "$BATCHER_KEY" \
|
|
|
|
|
--arg Seq "$SEQ" --arg SeqKey "$SEQ_KEY" \
|
|
|
|
|
'{Admin: $Admin, AdminKey: $AdminKey, Proposer: $Proposer, ProposerKey: $ProposerKey, Batcher: $Batcher, BatcherKey: $BatcherKey, Seq: $Seq, SeqKey: $SeqKey}')
|
|
|
|
|
echo "$accounts_json" > $l2_accounts_file
|
|
|
|
|
curl -o accounts.csv $CERC_L1_ACCOUNTS_CSV_URL
|
|
|
|
|
# Admin
|
|
|
|
|
ADMIN=$(awk -F ',' 'NR == 1 {print $2}' accounts.csv)
|
|
|
|
|
ADMIN_KEY=$(awk -F ',' 'NR == 1 {print $3}' accounts.csv)
|
|
|
|
|
# Proposer
|
|
|
|
|
PROPOSER=$(awk -F ',' 'NR == 2 {print $2}' accounts.csv)
|
|
|
|
|
PROPOSER_KEY=$(awk -F ',' 'NR == 2 {print $3}' accounts.csv)
|
|
|
|
|
# Batcher
|
|
|
|
|
BATCHER=$(awk -F ',' 'NR == 3 {print $2}' accounts.csv)
|
|
|
|
|
BATCHER_KEY=$(awk -F ',' 'NR == 3 {print $3}' accounts.csv)
|
|
|
|
|
# Sequencer
|
|
|
|
|
SEQ=$(awk -F ',' 'NR == 4 {print $2}' accounts.csv)
|
|
|
|
|
SEQ_KEY=$(awk -F ',' 'NR == 4 {print $3}' accounts.csv)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Using accounts:"
|
|
|
|
|
echo -e "Admin: $ADMIN\nProposer: $PROPOSER\nBatcher: $BATCHER\nSequencer: $SEQ"
|
|
|
|
|
|
|
|
|
|
# These accounts will be needed by other containers, so write them to a shared volume
|
|
|
|
|
echo "Writing accounts/private keys to volume l2_accounts."
|
|
|
|
|
accounts_json=$(jq -n \
|
|
|
|
|
--arg Admin "$ADMIN" --arg AdminKey "$ADMIN_KEY" \
|
|
|
|
|
--arg Proposer "$PROPOSER" --arg ProposerKey "$PROPOSER_KEY" \
|
|
|
|
|
--arg Batcher "$BATCHER" --arg BatcherKey "$BATCHER_KEY" \
|
|
|
|
|
--arg Seq "$SEQ" --arg SeqKey "$SEQ_KEY" \
|
|
|
|
|
'{Admin: $Admin, AdminKey: $AdminKey, Proposer: $Proposer, ProposerKey: $ProposerKey, Batcher: $Batcher, BatcherKey: $BatcherKey, Seq: $Seq, SeqKey: $SeqKey}')
|
|
|
|
|
echo "$accounts_json" > "/l2-accounts/accounts.json"
|
|
|
|
|
|
|
|
|
|
# Get a finalized L1 block to set as the starting point for the L2 deployment
|
|
|
|
|
# If the chain is a freshly created fixturenet-eth, a finalized block won't be available for many minutes; rather than wait, we can use block 1
|
|
|
|
|
echo "Checking L1 for finalized block..."
|
|
|
|
@ -185,7 +163,7 @@ echo "Done deploying contracts."
|
|
|
|
|
echo "Generating L2 genesis allocs..."
|
|
|
|
|
L2_CHAIN_ID=$(jq ".l2ChainID" $deploy_config_file)
|
|
|
|
|
DEPLOY_CONFIG_PATH=$deploy_config_file \
|
|
|
|
|
CONTRACT_ADDRESSES_PATH="deployments/$DEPLOYMENT_CONTEXT-deploy.json" \
|
|
|
|
|
CONTRACT_ADDRESSES_PATH=deployments/$DEPLOYMENT_CONTEXT-deploy.json \
|
|
|
|
|
forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithAllUpgrades()' --private-key $ADMIN_KEY
|
|
|
|
|
|
|
|
|
|
cp /app/packages/contracts-bedrock/state-dump-$L2_CHAIN_ID.json allocs-l2.json
|
|
|
|
@ -193,9 +171,10 @@ echo "Done."
|
|
|
|
|
echo "*************************************"
|
|
|
|
|
|
|
|
|
|
# Copy files needed by other containers to the appropriate shared volumes
|
|
|
|
|
echo "Copying deployment artifacts to volume l1_deployment and deploy-config to volume l2_config"
|
|
|
|
|
echo "Copying deployment artifacts volume l1_deployment and deploy-config to volume l2_config"
|
|
|
|
|
cp /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json /l1-deployment
|
|
|
|
|
cp /app/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config
|
|
|
|
|
cp allocs-l2.json /l2-config
|
|
|
|
|
openssl rand -hex 32 > /l2-config/l2-jwt.txt
|
|
|
|
|
|
|
|
|
|
echo "Deployment successful. Exiting"
|
|
|
|
|