Skip to content

Commit 3c7288e

Browse files
Le-Caignecgithub-actions[bot]zguesmi
authored
feat: add deploy workflow for contract deployment (#79)
Co-authored-by: GitHub Actions Bot <github-actions[bot]@users.noreply.github.com> Co-authored-by: Zied <[email protected]>
1 parent 8ccc0e4 commit 3c7288e

File tree

13 files changed

+1613
-388
lines changed

13 files changed

+1613
-388
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
CI=false # Set to true if you want to run the make file commands in CI mode (will use --private-key instead of --account option)
2+
13
SEPOLIA_RPC_URL="https://gateway.tenderly.co/public/sepolia"
24
ARBITRUM_SEPOLIA_RPC_URL="https://arbitrum-sepolia.gateway.tenderly.co"
35

.github/workflows/deploy.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Deploy contracts
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
inputs:
6+
network:
7+
description: 'Network'
8+
required: true
9+
type: choice
10+
options:
11+
- anvil
12+
- sepolia
13+
- ethereum
14+
- arbitrum_sepolia
15+
- arbitrum
16+
default: 'anvil'
17+
18+
jobs:
19+
20+
# Build and test before deploying.
21+
build-and-test:
22+
uses: ./.github/workflows/main.yml
23+
with:
24+
SEPOLIA_RPC_URL: ${{ vars.SEPOLIA_RPC_URL }}
25+
ARBITRUM_SEPOLIA_RPC_URL: ${{ vars.ARBITRUM_SEPOLIA_RPC_URL }}
26+
27+
# Deploy and verify contract.
28+
deploy:
29+
needs: build-and-test
30+
runs-on: ubuntu-latest
31+
env:
32+
CI: true
33+
permissions:
34+
contents: write # Required to commit deployment files.
35+
environment: ${{ inputs.network }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
submodules: recursive
40+
41+
- name: Install Foundry
42+
uses: foundry-rs/foundry-toolchain@v1
43+
with:
44+
version: stable
45+
cache: true
46+
47+
- name: Deploy contracts on Anvil (All networks)
48+
if: inputs.network == 'anvil'
49+
env:
50+
DEPLOYER_PRIVATE_KEY: ${{ vars.ANVIL_PRIVATE_KEY }}
51+
SEPOLIA_RPC_URL: ${{ vars.SEPOLIA_RPC_URL }}
52+
ARBITRUM_SEPOLIA_RPC_URL: ${{ vars.ARBITRUM_SEPOLIA_RPC_URL }}
53+
ANVIL_SEPOLIA_RPC_URL: ${{ vars.ANVIL_SEPOLIA_RPC_URL }}
54+
ANVIL_ARBITRUM_SEPOLIA_RPC_URL: ${{ vars.ANVIL_ARBITRUM_SEPOLIA_RPC_URL }}
55+
run: |
56+
make fork-sepolia & make fork-arbitrum-sepolia & sleep 10 && make deploy-on-anvil
57+
58+
- name: Deploy contracts on Sepolia/EthereumMainnet
59+
if: inputs.network == 'sepolia' || inputs.network == 'ethereum'
60+
env:
61+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
62+
CHAIN: ${{ inputs.network }}
63+
RPC_URL: ${{ secrets.RPC_URL }}
64+
run: |
65+
make deploy-liquidity-unifier-and-bridge
66+
67+
- name: Deploy contracts on ChainX
68+
if: inputs.network != 'sepolia' && inputs.network != 'ethereum' && inputs.network != 'anvil'
69+
env:
70+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
71+
CHAIN: ${{ inputs.network }}
72+
RPC_URL: ${{ secrets.RPC_URL }}
73+
run: |
74+
make deploy-crosschain-token-and-bridge
75+
76+
- name: Save deployment artifacts
77+
if: inputs.network != 'anvil'
78+
uses: stefanzweifel/git-auto-commit-action@v5
79+
with:
80+
commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (Github run_id: ${{ github.run_id }})'
81+
file_pattern: 'config/config.json broadcast/'
82+
commit_user_name: 'GitHub Actions Bot'
83+
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
84+
commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
85+
86+
- name: Verify contracts
87+
if: inputs.network != 'anvil'
88+
run: |
89+
echo "TODO: Implement contract verification for ${{ inputs.network }}."

.github/workflows/main.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ name: Default
22

33
on:
44
pull_request:
5+
workflow_call:
6+
inputs:
7+
SEPOLIA_RPC_URL:
8+
required: true
9+
type: string
10+
ARBITRUM_SEPOLIA_RPC_URL:
11+
required: true
12+
type: string
513

614
concurrency:
715
group: ${{ github.ref }}-ci
816
cancel-in-progress: true
917

1018
env:
1119
FOUNDRY_PROFILE: ci
12-
SEPOLIA_RPC_URL: secrets.SEPOLIA_RPC_URL
13-
ARBITRUM_SEPOLIA_RPC_URL: secrets.ARBITRUM_SEPOLIA_RPC_URL
1420

1521
jobs:
1622
build-and-test:
@@ -23,6 +29,9 @@ jobs:
2329

2430
- name: Install Foundry
2531
uses: foundry-rs/foundry-toolchain@v1
32+
with:
33+
version: stable
34+
cache: true
2635

2736
- name: Show Forge version
2837
run: forge --version
@@ -31,12 +40,14 @@ jobs:
3140
run: forge fmt --check
3241

3342
- name: Run Forge build
34-
run: forge build && forge build './src' --sizes && cp .env.template .env
43+
run: forge build && forge build './src' --sizes
3544

3645
- name: Run Foundry coverage
37-
run: make generate-coverage
3846
env:
3947
CI: true
48+
SEPOLIA_RPC_URL: ${{ inputs.SEPOLIA_RPC_URL || vars.SEPOLIA_RPC_URL }}
49+
ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.ARBITRUM_SEPOLIA_RPC_URL || vars.ARBITRUM_SEPOLIA_RPC_URL }}
50+
run: make generate-coverage
4051

4152
- name: Upload coverage reports to Codecov
4253
uses: codecov/codecov-action@v5

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,25 @@ deploy-on-testnets:
6666
TARGET_CHAIN=arbitrum_sepolia TARGET_RPC=$(ARBITRUM_SEPOLIA_RPC_URL) \
6767
OPTIONS="--verify --verifier etherscan --verifier-api-key $(ETHERSCAN_API_KEY) --verifier-url $(ETHERSCAN_API_URL)"
6868

69+
deploy-liquidity-unifier-and-bridge:
70+
$(MAKE) deploy-contract CONTRACT=RLCLiquidityUnifier CHAIN=$(CHAIN) RPC_URL=$(RPC_URL) OPTIONS="$(OPTIONS)"
71+
$(MAKE) deploy-contract CONTRACT=bridges/layerZero/IexecLayerZeroBridge CHAIN=$(CHAIN) RPC_URL=$(RPC_URL) OPTIONS="$(OPTIONS)"
72+
73+
deploy-crosschain-token-and-bridge:
74+
$(MAKE) deploy-contract CONTRACT=RLCCrosschainToken CHAIN=$(CHAIN) RPC_URL=$(RPC_URL) OPTIONS="$(OPTIONS)"
75+
$(MAKE) deploy-contract CONTRACT=bridges/layerZero/IexecLayerZeroBridge CHAIN=$(CHAIN) RPC_URL=$(RPC_URL) OPTIONS="$(OPTIONS)"
76+
6977
deploy-all: # SOURCE_CHAIN, SOURCE_RPC, TARGET_CHAIN, TARGET_RPC, OPTIONS
70-
$(MAKE) deploy-contract CONTRACT=RLCLiquidityUnifier CHAIN=$(SOURCE_CHAIN) RPC_URL=$(SOURCE_RPC) OPTIONS="$(OPTIONS)"
71-
$(MAKE) deploy-contract CONTRACT=bridges/layerZero/IexecLayerZeroBridge CHAIN=$(SOURCE_CHAIN) RPC_URL=$(SOURCE_RPC) OPTIONS="$(OPTIONS)"
72-
$(MAKE) deploy-contract CONTRACT=RLCCrosschainToken CHAIN=$(TARGET_CHAIN) RPC_URL=$(TARGET_RPC) OPTIONS="$(OPTIONS)"
73-
$(MAKE) deploy-contract CONTRACT=bridges/layerZero/IexecLayerZeroBridge CHAIN=$(TARGET_CHAIN) RPC_URL=$(TARGET_RPC) OPTIONS="$(OPTIONS)"
78+
$(MAKE) deploy-liquidity-unifier-and-bridge CHAIN=$(SOURCE_CHAIN) RPC_URL=$(SOURCE_RPC) OPTIONS=$(OPTIONS)
79+
$(MAKE) deploy-crosschain-token-and-bridge CHAIN=$(TARGET_CHAIN) RPC_URL=$(TARGET_RPC) OPTIONS=$(OPTIONS)
80+
@echo "Contracts deployment completed."
81+
@echo "⚠️ Run 'make configure-all' to configure bridges."
82+
@echo "⚠️ Please configure the bridges. Do not forget to authorize the RLCLiquidityUnifier and RLCCrosschainToken contracts on the bridges."
83+
84+
configure-all: # SOURCE_CHAIN, TARGET_CHAIN, SOURCE_RPC, TARGET_RPC
7485
$(MAKE) configure-bridge SOURCE_CHAIN=$(SOURCE_CHAIN) TARGET_CHAIN=$(TARGET_CHAIN) RPC_URL=$(SOURCE_RPC)
7586
$(MAKE) configure-bridge SOURCE_CHAIN=$(TARGET_CHAIN) TARGET_CHAIN=$(SOURCE_CHAIN) RPC_URL=$(TARGET_RPC)
76-
@echo "Deployment completed."
77-
@echo "⚠️ Please authorize bridges on RLCLiquidityUnifier and RLCCrosschainToken contracts."
78-
# TODO verify contracts after deployment.
87+
@echo "Bridge configuration completed."
7988

8089
#
8190
# High-level upgrade targets
@@ -111,7 +120,7 @@ deploy-contract: # CONTRACT, CHAIN, RPC_URL, OPTIONS
111120
@echo "Deploying $(CONTRACT) on $(CHAIN) with options: $(OPTIONS)"
112121
CHAIN=$(CHAIN) forge script script/$(CONTRACT).s.sol:Deploy \
113122
--rpc-url $(RPC_URL) \
114-
--account $(ACCOUNT) \
123+
$$(if [ "$(CI)" = "true" ]; then echo "--private-key $(DEPLOYER_PRIVATE_KEY)"; else echo "--account $(ACCOUNT)"; fi) \
115124
$(OPTIONS) \
116125
--broadcast \
117126
-vvv

broadcast/IexecLayerZeroBridge.s.sol/11155111/run-1753085151.json

Lines changed: 257 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/IexecLayerZeroBridge.s.sol/11155111/run-latest.json

Lines changed: 188 additions & 104 deletions
Large diffs are not rendered by default.

broadcast/IexecLayerZeroBridge.s.sol/421614/run-1753085188.json

Lines changed: 261 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/IexecLayerZeroBridge.s.sol/421614/run-latest.json

Lines changed: 188 additions & 106 deletions
Large diffs are not rendered by default.

broadcast/RLCCrosschainToken.s.sol/421614/run-1753085175.json

Lines changed: 217 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/RLCCrosschainToken.s.sol/421614/run-latest.json

Lines changed: 80 additions & 80 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)