Skip to content

Commit 3630f77

Browse files
authored
feat: add CI for integration test suite for contract upgrades (#381)
- 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
1 parent c5ad558 commit 3630f77

35 files changed

+1796
-45
lines changed

.changeset/thin-ways-dress.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@fuel-bridge/solidity-contracts': minor
3+
'@fuel-bridge/test-utils': minor
4+
---
5+
6+
ci for contract upgrade test suite
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Upgrade Test Suite
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main # Target branch for the PR
10+
release:
11+
types: [published]
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
upgrade-test-suite:
19+
runs-on: ubuntu-latest
20+
if: github.event_name == 'pull_request'
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: FuelLabs/github-actions/setups/node@master
24+
with:
25+
node-version: 20.16.0
26+
pnpm-version: 9.0.6
27+
- uses: FuelLabs/github-actions/setups/docker@master
28+
with:
29+
username: ${{ github.repository_owner }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
- uses: ./.github/actions/setup-rust
32+
- name: Build project
33+
run: pnpm build
34+
- name: Sets the tenderly rpc endpoint in the L1 docker container env and sets forking variable for fuel core setup
35+
run: |
36+
cat << EOF > l1_chain.env
37+
TENDERLY_RPC_URL=${{ secrets.TENDERLY_RPC_URL }}
38+
EOF
39+
40+
cat << EOF > fuel_core.env
41+
FORKING=true
42+
EOF
43+
working-directory: docker/envs
44+
- name: Run integration tests on a L1 fork after upgrading contracts
45+
run: |
46+
pnpm run test:fork

docker/envs/fuel_core.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
RUST_BACKTRACE=1
2-
CONSENSUS_KEY_SECRET="0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
32
# Uncommend to use the variables by removing #
43
# FUEL_IP=
54
# FUEL_PORT=
5+
# set true when running integration tests over forked environment
6+
FORKING=false

docker/envs/l1_chain.env

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
# L1_PORT=
66
# SERVE_PORT=
77
DEPLOYER_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
8+
# set tenderly rpc for spinning up forked network
9+
TENDERLY_RPC_URL=

docker/fuel-core/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ FROM ghcr.io/fuellabs/fuel-core:v0.40.0
77

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

1213
# dependencies
1314
ENV DEBIAN_FRONTEND=noninteractive

docker/fuel-core/fuel_core.sh

+36-15
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,40 @@ export FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS=$(cat "./addresses.json" | jq -r .Fu
4949
echo "FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS: $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS"
5050
echo "L1_CHAIN_HTTP: $L1_CHAIN_HTTP"
5151

52+
export FORKING=${FORKING}
53+
5254
# start the Fuel client
53-
echo "Starting fuel node."
54-
exec /root/fuel-core run \
55-
--ip $FUEL_IP \
56-
--port $FUEL_PORT \
57-
--utxo-validation \
58-
--vm-backtrace \
59-
--enable-relayer \
60-
--relayer $L1_CHAIN_HTTP \
61-
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
62-
--poa-interval-period 1sec \
63-
--debug \
64-
--da-compression $DA_COMPRESSION \
65-
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
66-
--min-gas-price 0 \
67-
--snapshot ./
55+
if [ "$FORKING" = "true" ]; then
56+
echo "FORKING is enabled. Running with da deploy height"
57+
exec /root/fuel-core run \
58+
--ip $FUEL_IP \
59+
--port $FUEL_PORT \
60+
--utxo-validation \
61+
--vm-backtrace \
62+
--enable-relayer \
63+
--relayer $L1_CHAIN_HTTP \
64+
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
65+
--poa-interval-period 1sec \
66+
--relayer-da-deploy-height=21371952 \
67+
--debug \
68+
--da-compression $DA_COMPRESSION \
69+
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
70+
--min-gas-price 0 \
71+
--snapshot ./
72+
else
73+
echo "FORKING is disabled. Running without da deploy height"
74+
exec /root/fuel-core run \
75+
--ip $FUEL_IP \
76+
--port $FUEL_PORT \
77+
--utxo-validation \
78+
--vm-backtrace \
79+
--enable-relayer \
80+
--relayer $L1_CHAIN_HTTP \
81+
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
82+
--poa-interval-period 1sec \
83+
--debug \
84+
--da-compression $DA_COMPRESSION \
85+
--graphql-max-complexity $GRAPHQL_COMPLEXITY \
86+
--min-gas-price 0 \
87+
--snapshot ./
88+
fi

docker/l1-chain/Dockerfile

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN npm i -g pnpm
1111

1212
# clone the contracts repo
1313
ADD ./packages/solidity-contracts/package.json /l1chain/fuel-v2-contracts/
14+
1415
# copy over the fuel chain and replace consts values
1516
WORKDIR /l1chain/fuel-v2-contracts
1617

@@ -27,16 +28,11 @@ RUN pnpm compile
2728
ADD ./docker/l1-chain/.fuelChainConsts.env /l1chain/fuel-v2-contracts/.fuelChainConsts.env
2829
ADD ./packages/solidity-contracts/contracts /l1chain/fuel-v2-contracts/contracts
2930
ADD ./packages/solidity-contracts/deploy /l1chain/fuel-v2-contracts/deploy
31+
ADD ./packages/solidity-contracts/deployments/ /l1chain/fuel-v2-contracts/deployments/
3032
ADD ./packages/solidity-contracts/protocol /l1chain/fuel-v2-contracts/protocol
3133

32-
33-
# remove build dependencies
34-
# RUN pnpm prune --prod
3534
RUN pnpm compile
3635

37-
# Create deployments dir
38-
RUN mkdir deployments
39-
4036
# expose node and server port
4137
ENV L1_IP="${L1_IP}"
4238
ENV L1_PORT="${L1_PORT}"

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"node:clean": "make -C ./docker clean",
1919
"node:logs": "make -C ./docker logs",
2020
"test": "sh ./scripts/test.sh",
21+
"test:fork": "sh ./scripts/test-fork.sh",
2122
"test:integration": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test",
23+
"test:integration:fork": "DEBUG=true pnpm --filter @fuel-bridge/integration-tests test-fork",
2224
"lint:check": "eslint . --ext .ts,.js",
2325
"lint:fix": "pnpm lint:check --fix",
2426
"prettier:check": "prettier --check .",

packages/fungible-token/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
},
1111
"devDependencies": {
1212
"fuels": "0.96.1",
13-
"@fuel-bridge/esbuild-bin-loader": "workspace:../esbuild-bin-loader",
14-
"@fuel-bridge/solidity-contracts": "workspace:*"
13+
"@fuel-bridge/esbuild-bin-loader": "workspace:../esbuild-bin-loader"
1514
}
1615
}

0 commit comments

Comments
 (0)