-
Notifications
You must be signed in to change notification settings - Fork 15
225 lines (185 loc) · 8.08 KB
/
test-stellar.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Test Stellar
on: pull_request
jobs:
check-relevant-changes:
name: Check for Relevant Changes
runs-on: blacksmith-2vcpu-ubuntu-2204
outputs:
run_tests: ${{ steps.filter.outputs.stellar == 'true' || steps.filter.outputs.common == 'true' || steps.filter.outputs.github == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
stellar:
- 'stellar/**'
common:
- 'common/**'
github:
- '.github/workflows/test-stellar.yaml'
- name: Summarize Changes
run: |
echo "Changes in stellar: ${{ steps.filter.outputs.stellar }}"
echo "Changes in common: ${{ steps.filter.outputs.common }}"
echo "Changes in github: ${{ steps.filter.outputs.github }}"
test-stellar:
name: Test Stellar
needs: check-relevant-changes
if: ${{ needs.check-relevant-changes.outputs.run_tests == 'true' }}
runs-on: blacksmith-2vcpu-ubuntu-2204
steps:
# this sets up nested repos: https://github.com/actions/checkout?tab=readme-ov-file#checkout-multiple-repos-nested
#
# axelar-contract-deployments
# - axelar-cgp-soroban
#
# future steps depend on this directory structure
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout axelar-cgp-soroban repo
uses: actions/checkout@v4
with:
repository: axelarnetwork/axelar-cgp-soroban
path: axelar-cgp-soroban
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18' # Hardcoded to ensure consistency.
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
shell: bash
run: npm ci
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.81.0
targets: wasm32-unknown-unknown
# install binary to avoid lengthy compilation process
- name: Install Stellar CLI
shell: bash
run: |
# Query latest release from official Stellar repo
URL=$(curl -s https://api.github.com/repos/stellar/stellar-cli/releases/latest | jq -r .assets[].browser_download_url | grep 'stellar.*x86_64-unknown-linux')
# download + extract binary
wget -q $URL
tar -xzf $(basename $URL)
# setup bin/ directory
mkdir bin
mv soroban bin/
# the cargo install defines these as aliases, so mimic that behaviour
ln -s $PWD/bin/soroban bin/stellar
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Setup Stellar local network
run: |
docker pull stellar/quickstart
docker run -d --rm -it \
-p 8000:8000 \
--name stellar \
stellar/quickstart:testing \
--local \
--enable-soroban-rpc \
--protocol-version 22
RPC_URL="http://localhost:8000/soroban/rpc"
NETWORK_PASSPHRASE="Standalone Network ; February 2017"
echo "RPC_URL=${RPC_URL}" >> $GITHUB_ENV
echo "NETWORK_PASSPHRASE=${NETWORK_PASSPHRASE}" >> $GITHUB_ENV
- name: Add as configured network
shell: bash
run: |
stellar network add local \
--rpc-url "$RPC_URL" \
--network-passphrase "$NETWORK_PASSPHRASE"
- name: Prepare local.json
run: |
echo '{
"chains": {
"stellar": {
"name": "Stellar",
"axelarId": "stellar",
"networkType": "local",
"chainType": "stellar",
"tokenSymbol": "XLM",
"rpc": "http://127.0.0.1:8000/soroban/rpc",
"horizonRpc": "http://127.0.0.1:8000",
"contracts": {}
}
}
}' > ./axelar-chains-config/info/local.json
- name: Display local.json
run: cat ./axelar-chains-config/info/local.json
###### Compile Wasm Contracts ######
- name: Compile WASM contracts
run: |
stellar contract build --manifest-path=axelar-cgp-soroban/Cargo.toml
cd axelar-cgp-soroban
./optimize.sh
cd ..
WASM_DIR=axelar-cgp-soroban/target/wasm32-unknown-unknown/release
echo "WASM_DIR=${WASM_DIR}" >> $GITHUB_ENV
- name: Setup Stellar wallet
run: |
stellar keys generate test \
--rpc-url "$RPC_URL" \
--network-passphrase "$NETWORK_PASSPHRASE"
STELLAR_PRIVATE_KEY=$(stellar keys show test)
STELLAR_ADDRESS=$(stellar keys address test)
echo "STELLAR_PRIVATE_KEY=${STELLAR_PRIVATE_KEY}" >> $GITHUB_ENV
echo "STELLAR_ADDRESS=${STELLAR_ADDRESS}" >> $GITHUB_ENV
- name: Fund Stellar wallet
run: node stellar/faucet --recipient $STELLAR_ADDRESS
- name: Prepare .env
run: |
echo "PRIVATE_KEY = '$STELLAR_PRIVATE_KEY'" >> .env
echo "ENV = 'local'" >> .env
echo "YES = 'true'" >> .env
###### Command: Deploy Contract ######
- name: Deploy axelar_gateway
run: |
CONTRACT=axelar_gateway
node stellar/deploy-contract deploy $CONTRACT --wasm-path $WASM_DIR/$CONTRACT.optimized.wasm --initialize
- name: Deploy axelar_operators
run: |
CONTRACT=axelar_operators
node stellar/deploy-contract deploy $CONTRACT --wasm-path $WASM_DIR/$CONTRACT.optimized.wasm --initialize
###### Command: Gateway ######
# FIXME:
# - name: Gateway Approve
# run: |
# node stellar/gateway approve avalanche 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 wallet 0x1234
- name: Gateway Call Contract
run: node stellar/gateway.js call-contract avalanche 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234
- name: Gateway Rotate Signers
run: |
node stellar/gateway rotate --new-nonce test --signers wallet
node stellar/gateway rotate --new-nonce test2 --current-nonce test --signers wallet
- name: Upgrade gateway contract
run: |
CONTRACT=axelar_gateway
node stellar/deploy-contract.js upgrade $CONTRACT --wasm-path $WASM_DIR/$CONTRACT.optimized.wasm
###### Command: Operators ######
- name: Execute is_operator action
run: node stellar/operators.js --action is_operator --args $STELLAR_ADDRESS
- name: Execute add_operator action
run: node stellar/operators.js --action add_operator --args $STELLAR_ADDRESS
- name: Execute remove_operator action
run: node stellar/operators.js --action remove_operator --args $STELLAR_ADDRESS
# TODO: needs gas-service contract
# - name: Execute refund action
# run: node stellar/operators.js --action refund
# FIXME: find proper way to execute this
# - name: Execute execute action
# run: node stellar/operators.js --action execute --target $STELLAR_ADDRESS --method "is_operator"
# TODO: currently fails
# - name: is_operator with estimate_cost
# run: node stellar/operators.js --action is_operator --args $STELLAR_ADDRESS --estimate-cost
###### Command: Generate Bindings #####
- name: generate operators bindings
run: |
CONTRACT=axelar_operators
node stellar/generate-bindings.js --wasm-path $WASM_DIR/$CONTRACT.optimized.wasm --contract-id $(jq .chains.stellar.contracts.$CONTRACT.address axelar-chains-config/info/local.json) --output-dir ./stellar/bindings/$CONTRACT
- name: generate gateway bindings
run: |
CONTRACT=axelar_gateway
node stellar/generate-bindings.js --wasm-path $WASM_DIR/$CONTRACT.optimized.wasm --contract-id $(jq .chains.stellar.contracts.$CONTRACT.address axelar-chains-config/info/local.json) --output-dir ./stellar/bindings/$CONTRACT