Skip to content

Commit

Permalink
feat: add CI for integration test suite for contract upgrades (#381)
Browse files Browse the repository at this point in the history
- closes #206 
- adds upgrade scripts and integration tests that run on a forked L1
network
- removes unused `solidity-contracts` workspace dependency in
`fungible-token` and `message-predicates` packages to resolve cyclic
dependency
  • Loading branch information
viraj124 authored Jan 15, 2025
1 parent c5ad558 commit 3630f77
Show file tree
Hide file tree
Showing 35 changed files with 1,796 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .changeset/thin-ways-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuel-bridge/solidity-contracts': minor
'@fuel-bridge/test-utils': minor
---

ci for contract upgrade test suite
46 changes: 46 additions & 0 deletions .github/workflows/upgrade-test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Upgrade Test Suite

on:
push:
branches:
- main
pull_request:
branches:
- main # Target branch for the PR
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
upgrade-test-suite:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
with:
node-version: 20.16.0
pnpm-version: 9.0.6
- uses: FuelLabs/github-actions/setups/docker@master
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/setup-rust
- name: Build project
run: pnpm build
- name: Sets the tenderly rpc endpoint in the L1 docker container env and sets forking variable for fuel core setup
run: |
cat << EOF > l1_chain.env
TENDERLY_RPC_URL=${{ secrets.TENDERLY_RPC_URL }}
EOF
cat << EOF > fuel_core.env
FORKING=true
EOF
working-directory: docker/envs
- name: Run integration tests on a L1 fork after upgrading contracts
run: |
pnpm run test:fork
3 changes: 2 additions & 1 deletion docker/envs/fuel_core.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RUST_BACKTRACE=1
CONSENSUS_KEY_SECRET="0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
# Uncommend to use the variables by removing #
# FUEL_IP=
# FUEL_PORT=
# set true when running integration tests over forked environment
FORKING=false
2 changes: 2 additions & 0 deletions docker/envs/l1_chain.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# L1_PORT=
# SERVE_PORT=
DEPLOYER_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
# set tenderly rpc for spinning up forked network
TENDERLY_RPC_URL=
3 changes: 2 additions & 1 deletion docker/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FROM ghcr.io/fuellabs/fuel-core:v0.40.0

ARG FUEL_IP=0.0.0.0
ARG FUEL_PORT=4001
ARG CONSENSUS_KEY_SECRET=""
# since we need to set the FORKING var in the upgrade-test-suite ci so setting it here
ARG CONSENSUS_KEY_SECRET="0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"

# dependencies
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
51 changes: 36 additions & 15 deletions docker/fuel-core/fuel_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,40 @@ export FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS=$(cat "./addresses.json" | jq -r .Fu
echo "FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS: $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS"
echo "L1_CHAIN_HTTP: $L1_CHAIN_HTTP"

export FORKING=${FORKING}

# start the Fuel client
echo "Starting fuel node."
exec /root/fuel-core run \
--ip $FUEL_IP \
--port $FUEL_PORT \
--utxo-validation \
--vm-backtrace \
--enable-relayer \
--relayer $L1_CHAIN_HTTP \
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
--poa-interval-period 1sec \
--debug \
--da-compression $DA_COMPRESSION \
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
--min-gas-price 0 \
--snapshot ./
if [ "$FORKING" = "true" ]; then
echo "FORKING is enabled. Running with da deploy height"
exec /root/fuel-core run \
--ip $FUEL_IP \
--port $FUEL_PORT \
--utxo-validation \
--vm-backtrace \
--enable-relayer \
--relayer $L1_CHAIN_HTTP \
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
--poa-interval-period 1sec \
--relayer-da-deploy-height=21371952 \
--debug \
--da-compression $DA_COMPRESSION \
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
--min-gas-price 0 \
--snapshot ./
else
echo "FORKING is disabled. Running without da deploy height"
exec /root/fuel-core run \
--ip $FUEL_IP \
--port $FUEL_PORT \
--utxo-validation \
--vm-backtrace \
--enable-relayer \
--relayer $L1_CHAIN_HTTP \
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
--poa-interval-period 1sec \
--debug \
--da-compression $DA_COMPRESSION \
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
--min-gas-price 0 \
--snapshot ./
fi
8 changes: 2 additions & 6 deletions docker/l1-chain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN npm i -g pnpm

# clone the contracts repo
ADD ./packages/solidity-contracts/package.json /l1chain/fuel-v2-contracts/

# copy over the fuel chain and replace consts values
WORKDIR /l1chain/fuel-v2-contracts

Expand All @@ -27,16 +28,11 @@ RUN pnpm compile
ADD ./docker/l1-chain/.fuelChainConsts.env /l1chain/fuel-v2-contracts/.fuelChainConsts.env
ADD ./packages/solidity-contracts/contracts /l1chain/fuel-v2-contracts/contracts
ADD ./packages/solidity-contracts/deploy /l1chain/fuel-v2-contracts/deploy
ADD ./packages/solidity-contracts/deployments/ /l1chain/fuel-v2-contracts/deployments/
ADD ./packages/solidity-contracts/protocol /l1chain/fuel-v2-contracts/protocol


# remove build dependencies
# RUN pnpm prune --prod
RUN pnpm compile

# Create deployments dir
RUN mkdir deployments

# expose node and server port
ENV L1_IP="${L1_IP}"
ENV L1_PORT="${L1_PORT}"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"node:clean": "make -C ./docker clean",
"node:logs": "make -C ./docker logs",
"test": "sh ./scripts/test.sh",
"test:fork": "sh ./scripts/test-fork.sh",
"test:integration": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test",
"test:integration:fork": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test-fork",
"lint:check": "eslint . --ext .ts,.js",
"lint:fix": "pnpm lint:check --fix",
"prettier:check": "prettier --check .",
Expand Down
3 changes: 1 addition & 2 deletions packages/fungible-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"devDependencies": {
"fuels": "0.96.1",
"@fuel-bridge/esbuild-bin-loader": "workspace:../esbuild-bin-loader",
"@fuel-bridge/solidity-contracts": "workspace:*"
"@fuel-bridge/esbuild-bin-loader": "workspace:../esbuild-bin-loader"
}
}
Loading

0 comments on commit 3630f77

Please sign in to comment.