Skip to content

Creating Geth and ARB init state for v1.1.2-usdt-3-node #63

Creating Geth and ARB init state for v1.1.2-usdt-3-node

Creating Geth and ARB init state for v1.1.2-usdt-3-node #63

name: Create Geth and ARB Initial State
run-name: Creating Geth and ARB init state for ${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
on:
workflow_dispatch:
inputs:
tag:
description: Which tag should we deploy against?
required: true
genesis_validators:
description: The aggregate key generated from generate-genesis-keys
type: choice
options:
- "1"
- "3"
chainflip_backend_ref:
description: The branch, tag or commit of chainflip-backend to use
required: true
default: "main"
nitro_testnodes_ref:
description: The branch, tag or commit of nitro-testnodes to use
required: true
default: "feat/setup-from-scratch"
docker_image_tag_suffix:
description: A suffix to append to the image tag
required: false
default: ""
permissions:
contents: read
packages: write
env:
SEED: test test test test test test test test test test test junk
NUM_GENESIS_VALIDATORS: ${{ inputs.genesis_validators }}
GOV_KEY: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
COMM_KEY: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
REDEMPTION_DELAY: "120"
GENESIS_STAKE: "1000000000000000000000"
DEPLOYER_ACCOUNT_INDEX: "0"
DEPLOY_ARTEFACT_ID: "docker"
DEPLOY_RAW_TX_ID: "arbRawDeploymentTxs"
IMAGE_TAG: ${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
jobs:
build-geth-base:
runs-on: [self-hosted, linux, x64, ephemeral]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
- name: Docker meta
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ghcr.io/${{ github.repository }}/geth-base
flavor: |
latest=true
tags: |
type=semver,pattern={{raw}}
type=raw,value=latest
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: ci/docker/arb-geth/
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-geth-state:
runs-on: [self-hosted, linux, x64, ephemeral]
outputs:
image-tag: ${{ env.IMAGE_TAG }}
needs:
- build-geth-base
services:
geth:
image: ghcr.io/${{ github.repository }}/geth-base:latest
ports:
- 8545:8545
- 8546:8546
- 8551:8551
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ inputs.tag }}
- name: Checkout chainflip-backend @ ${{ inputs.chainflip_backend_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/chainflip-backend
path: chainflip-backend
ref: ${{ inputs.chainflip_backend_ref }}
- name: Fetch agg_key
run: |
echo "AGG_KEY=$(jq -r .eth_agg_key chainflip-backend/localnet/init/keyshare/${{ inputs.genesis_validators }}-node/agg_keys.json)" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
- run: npm install --global ganache-cli
- run: npm install --global yarn
- run: yarn
- run: poetry install
- name: Add the network
run: poetry run brownie networks add Ethereum docker host=http://localhost:8545 chainid=10997
- name: Deploy contracts
run: poetry run brownie run deploy_contracts --network docker
- name: Commit and push new geth image
run: |
CONTAINER=$(docker ps --format '{{.Names}}' | grep geth)
echo "geth_container=$CONTAINER" >> $GITHUB_ENV
docker commit $CONTAINER ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}
docker push ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}
- name: Copy initial Geth state
run: |
docker cp ${{ env.geth_container }}:/datadir ${{ github.workspace }}/datadir
- name: Summary
run: |
CONTRACTS=$(jq . ./scripts/.artefacts/docker.json)
echo "## Deployed Contracts for \`${{ inputs.genesis_validators }}-node\`" >> $GITHUB_STEP_SUMMARY
echo "\`agg_key\` = \`${{ env.AGG_KEY }}\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo "$CONTRACTS" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "## Docker Image" >> $GITHUB_STEP_SUMMARY
echo "\`ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
- name: Save agg key to file
run: echo ${{ env.AGG_KEY }} > agg_key
- name: Save artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: ${{ env.IMAGE_TAG }}
path: |
agg_key
./scripts/.artefacts/docker.json
${{ github.workspace }}/datadir
build-arb-state:
runs-on: [self-hosted, linux, x64, ephemeral]
env:
GETH_INITIAL_STATE_DIR: ci-geth-initial-state
GETH_BASE_IMAGE: ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ inputs.tag }}-${{ inputs.genesis_validators }}-node${{ inputs.docker_image_tag_suffix }}
needs:
- build-geth-state
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Checkout chainflip-io/nitro-testnode @ ${{ inputs.nitro_testnodes_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/nitro-testnode
path: nitro-testnode
ref: ${{ inputs.nitro_testnodes_ref }}
submodules: true
- name: Checkout chainflip-backend @ ${{ inputs.chainflip_backend_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
token: ${{ secrets.CF_GITHUB_BOT_READONLY_BACKEND_REPO }}
repository: chainflip-io/chainflip-backend
path: chainflip-backend
ref: ${{ inputs.chainflip_backend_ref }}
- name: Fetch agg_key
run: |
echo "AGG_KEY=$(jq -r .eth_agg_key chainflip-backend/localnet/init/keyshare/${{ inputs.genesis_validators }}-node/agg_keys.json)" >> $GITHUB_ENV
- name: Download Geth Initial State
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
with:
name: ${{ env.IMAGE_TAG }}
path: ./nitro-testnode/${{ env.GETH_INITIAL_STATE_DIR }}
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update directory permissions
working-directory: nitro-testnode
run: |
chmod -R 777 ./${{ env.GETH_INITIAL_STATE_DIR }}
- name: Update Docker user
run: |
sudo usermod -aG docker $USER
newgrp docker
- name: Build Arbitrum Network
working-directory: nitro-testnode
run: |
mkdir -p ./data
chmod -R 777 ./data
./test-node.bash --init --detach
./test-node.bash script send-l2 --to address_0x076d3803349fd5FB48863c5Fc33483cB2243C0Df --ethamount 10000
./test-node.bash script send-l2 --to address_0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --ethamount 10000
./test-node.bash script send-l2 --to address_0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --ethamount 10000
# Spamming Arbitrum so the final state contains all the previous funding transactions
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
- run: npm install --global ganache-cli
- run: npm install --global yarn
- run: yarn
- run: poetry install
- name: Add the network
run: poetry run brownie networks add Ethereum arb-l2 host=http://localhost:8547 chainid=412346
- name: Spam txs
run: poetry run brownie run spam_txs --network arb-l2
- name: Stop Containers
run: |
# Stop ARB containers in order to preserve a clean state
docker stop nitro-testnode-poster-1
docker stop nitro-testnode-staker-unsafe-1
docker stop nitro-testnode-sequencer-1
docker stop nitro-testnode-redis-1
docker stop nitro-testnode-geth-1
# Stop any other containers that may be running
docker stop $(docker ps -a -q)
- name: Update permissions
run: |
sudo chown -R $USER:$USER ./nitro-testnode/data
sudo chmod -R 777 ./nitro-testnode/data
- name: Save Initial State Artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: ${{ env.IMAGE_TAG }}-localnet-initial-state
path: |
${{ github.workspace }}/nitro-testnode/data
- name: Clean Up docker containers 🧹
if: always()
working-directory: ./nitro-testnode
continue-on-error: true
run: |
ls -laR ./data
docker ps -a
docker compose logs
docker compose down --rmi all --volumes --remove-orphans
build-initial-state-container:
needs:
- build-arb-state
runs-on: [self-hosted, linux, x64, ephemeral]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU βš™οΈ
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx πŸ‘·
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Docker meta πŸ”–
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ghcr.io/${{ github.repository }}/localnet-initial-state
tags: ${{ env.IMAGE_TAG }}
- name: Login to GitHub Container Registry βž‘οΈπŸ¦‘
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download Initial State from previous job
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
with:
name: ${{ env.IMAGE_TAG }}-localnet-initial-state
path: ./localnet-initial-state
- name: List files
run: ls -laR ./localnet-initial-state
- name: Get Current Time ⌚️
id: get_time
run: echo "current_datetime=$(date -u +"%b %d, %Y at %R UTC")" >> $GITHUB_OUTPUT
- name: Build Initial State Image πŸ«™
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
file: ci/docker/localnet-initial-state.Dockerfile
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATETIME="${{ steps.get_time.outputs.current_datetime }}"
VCS_REF="${{ github.sha }}"
BACKEND_REF="${{ inputs.chainflip_backend_ref }}"
get-l2-contracts-raw-tx:
env:
AGG_KEY: "346529871269487315764593845752985329862751012"
needs:
- build-initial-state-container
runs-on: [self-hosted, linux, x64, ephemeral]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up QEMU βš™οΈ
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Set up Docker Buildx πŸ‘·
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Docker meta πŸ”–
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ghcr.io/${{ github.repository }}/arbitrum-gizmo-shop
tags: ${{ env.IMAGE_TAG }}
- name: Login to GitHub Container Registry βž‘οΈπŸ¦‘
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update Docker user 🐳
run: |
sudo usermod -aG docker $USER
newgrp docker
- name: Start Arb Network πŸš€
run: |
docker compose pull > /dev/null 2>&1
docker compose up init -d
docker compose up -d
- name: Install Python virtualenv
run: pip install virtualenv
- name: Setup Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
with:
node-version: "16"
- name: Install Poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b
- run: npm install --global ganache-cli
- run: npm install --global yarn
- run: yarn
- run: poetry install
- name: Add the network
run: poetry run brownie networks add Ethereum arb-l2 host=http://localhost:8547 chainid=412346
- name: Deploy contracts
run: poetry run brownie run deploy_contracts --network arb-l2
- name: Get raw deployment transactions
run: poetry run brownie run store_raw_deployment_txs --network arb-l2
- name: Summary
run: |
CONTRACTS=$(jq . ./scripts/.artefacts/docker.json)
echo "## Deployed L2 Contracts for \`${{ inputs.genesis_validators }}-node\`" >> $GITHUB_STEP_SUMMARY
echo "\`agg_key\` = \`${{ env.AGG_KEY }}\`" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo "$CONTRACTS" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "## Docker Image" >> $GITHUB_STEP_SUMMARY
echo "\`ghcr.io/chainflip-io/chainflip-eth-contracts/geth:${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
- name: Save agg key to file
run: echo ${{ env.AGG_KEY }} > agg_key
- name: Save ARB Raw Deployment Txs Artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
with:
name: Arbitrum raw deployment transactions
path: |
./scripts/.artefacts/arbRawDeploymentTxs.json
- name: Get Current Time ⌚️
id: get_time
run: echo "current_datetime=$(date -u +"%b %d, %Y at %R UTC")" >> $GITHUB_OUTPUT
- name: Build Arbitrum Gizmo Shop Image πŸͺ€
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
file: ci/docker/arbitrum-gizmo-shop.Dockerfile
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATETIME="${{ steps.get_time.outputs.current_datetime }}"
VCS_REF="${{ github.sha }}"
BACKEND_REF="${{ inputs.chainflip_backend_ref }}"
- name: Clean Up docker containers 🧹
if: always()
continue-on-error: true
run: |
docker ps -a
docker compose logs
docker compose down --rmi all --volumes --remove-orphans