Skip to content

Commit c511fee

Browse files
authored
ci(autobahn): run the EVM-only upgrade test with seid instead of cast (#4846)
## Summary `integration_test/autobahn/evmonly_upgrade.sh` now drives the chain with seid's `--evm-rpc` commands from #4845 instead of Foundry's `cast`. The "Autobahn Upgrade Module" CI row no longer installs Foundry. Stacked on #4845; merge that first. This is the second of three PRs for CON-576. ## Changes - **`evmonly_upgrade.sh`:** - Every chain interaction is a seid command run in a node with `docker exec sei-node-N seid … --evm-rpc http://127.0.0.1:8545`: submit, vote, cancel, `q gov proposal`, `q upgrade plan|applied`, `q gov params`, `q block` (for height and block hash), and `tx evm send` for the block ticks. The runner needs only `docker` and `jq`. - It imports anvil accounts 0–3 (the validators' `evm_voter` keys) and 9 (block ticks) into a throwaway keyring in `sei-node-0`, using `seid keys add --recover --hd-path`. - A startup transfer moves the chain past genesis before the script reads any block, since Autobahn makes no empty blocks. - The checks are unchanged, with one exception: a cancel naming another plan is now refused during seid's gas estimation, so the check expects "refused" instead of a failed receipt. - **`integration-test.yml`:** removes the "Install Foundry" step, and the comment line documenting the `foundry` matrix field. - **`integration-test-matrix.json`:** removes `"foundry": true` from the Autobahn Upgrade Module row and updates its `_comment`. - **`integration_test/autobahn/README.md`:** the upgrade section now lists `docker` and `jq` as the only requirements. ## Testing On the local four-validator Autobahn cluster, with the CI row's env (`AUTOBAHN`, `GIGA_EXECUTOR`, `GIGA_STORAGE`, `GIGA_OCC`, `EVM_GOVERNANCE_VOTING_PERIOD=30s`), the script passed 85/0. It ran under `env -i` with `cast`, `forge` and `anvil` absent from `PATH`.
1 parent 2ca5a77 commit c511fee

4 files changed

Lines changed: 149 additions & 86 deletions

File tree

‎.github/workflows/integration-test-matrix.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@
149149
]
150150
},
151151
{
152-
"_comment": "Destructive: halts, restarts and upgrades every validator. Schedules major and minor upgrades through the gov and upgrade precompiles with cast.",
152+
"_comment": "Destructive: halts, restarts and upgrades every validator. Schedules major and minor upgrades through the gov and upgrade precompiles with seid.",
153153
"name": "Autobahn Upgrade Module",
154-
"foundry": true,
155154
"env": "AUTOBAHN=true GIGA_EXECUTOR=true GIGA_STORAGE=true GIGA_OCC=true EVM_GOVERNANCE_VOTING_PERIOD=30s",
156155
"scripts": [
157156
"timeout \"$JOB_TIMEOUT\" ./integration_test/autobahn/evmonly_upgrade.sh"

‎.github/workflows/integration-test.yml‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ jobs:
5858
# not a matrix row.
5959
# - A row with "disabled": true stays in the file but does not run. Its
6060
# `_comment` says why and carries the TODO to re-enable it.
61-
# - A row with "foundry": true gets Foundry's cast on the runner.
6261
set-matrix:
6362
name: Resolve integration test matrix
6463
runs-on: ubuntu-latest
@@ -275,23 +274,6 @@ jobs:
275274
- name: Install jq
276275
run: command -v jq >/dev/null || sudo apt-get install -y jq
277276

278-
- name: Install Foundry
279-
if: ${{ matrix.test.foundry }}
280-
env:
281-
FOUNDRY_VERSION: v1.8.6
282-
# sha256 of foundry_v1.8.6_linux_amd64.tar.gz, from the release asset digest.
283-
FOUNDRY_SHA256: 58850106984038f3a7200f38a4182c8cb423d3a4f4c7848eacbc2453e6bc35fc
284-
run: |
285-
set -euo pipefail
286-
tarball="foundry_${FOUNDRY_VERSION}_linux_amd64.tar.gz"
287-
curl -sSfL -o "${RUNNER_TEMP}/${tarball}" \
288-
"https://github.com/foundry-rs/foundry/releases/download/${FOUNDRY_VERSION}/${tarball}"
289-
echo "${FOUNDRY_SHA256} ${RUNNER_TEMP}/${tarball}" | sha256sum -c -
290-
mkdir -p "${RUNNER_TEMP}/foundry/bin"
291-
tar -xzf "${RUNNER_TEMP}/${tarball}" -C "${RUNNER_TEMP}/foundry/bin" cast
292-
echo "${RUNNER_TEMP}/foundry/bin" >> "$GITHUB_PATH"
293-
"${RUNNER_TEMP}/foundry/bin/cast" --version
294-
295277
- name: Set up Go
296278
uses: actions/setup-go@v7
297279
with:

‎integration_test/autobahn/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,9 @@ that depend on a method listed above as not supported cannot operate normally.
803803
## Run a software upgrade
804804

805805
`evmonly_upgrade.sh` drives a software upgrade through EVM-only gov on the
806-
local Docker cluster. It needs `cast` and `jq`. Start the cluster with EVM
807-
governance, then run the script from the repository root:
806+
local Docker cluster, with each node's own `seid` and its `--evm-rpc` flag. It
807+
needs only `docker` and `jq`. Start the cluster with EVM governance, then run
808+
the script from the repository root:
808809

809810
```sh
810811
AUTOBAHN=true EVM_GOVERNANCE_VOTING_PERIOD=30s DOCKER_DETACH=true make docker-cluster-start

‎integration_test/autobahn/evmonly_upgrade.sh‎

Lines changed: 145 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,23 @@
1919
#
2020
# AUTOBAHN=true EVM_GOVERNANCE_VOTING_PERIOD=30s DOCKER_DETACH=true make docker-cluster-start
2121
#
22-
# then run this script from the repository root. It needs cast and jq.
22+
# then run this script from the repository root. It drives the chain with each
23+
# node's own seid over its EVM JSON-RPC, and needs only docker and jq.
2324
set -euo pipefail
2425

25-
GAS_PRICE=${GAS_PRICE:-1gwei}
2626
NODES=4
27-
PORTS=(8545 8547 8549 8551)
28-
# The validators' evm_voter keys: anvil accounts 0 to 3 of the test mnemonic.
29-
VOTER_KEYS=(
30-
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
31-
0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
32-
0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
33-
0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
34-
)
35-
# Anvil account 9 sends the transfers that produce blocks; Autobahn makes no
36-
# empty blocks.
37-
TICK_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
38-
GOV=0x0000000000000000000000000000000000001006
39-
PARAMS=0x0000000000000000000000000000000000001013
40-
UPGRADE=0x0000000000000000000000000000000000001015
41-
# gov.DefaultParams' minimum expedited deposit: 20,000,000 usei.
42-
EXPEDITED_DEPOSIT=20ether
27+
# The test mnemonic. Anvil accounts 0 to 3 are the validators' evm_voter keys;
28+
# account 9 sends the transfers that produce blocks, as Autobahn makes no empty
29+
# blocks.
30+
MNEMONIC="test test test test test test test test test test test junk"
31+
KEY_INDEXES="0 1 2 3 9"
32+
# The keyring, in sei-node-0, that signs every transaction.
33+
KEY_HOME=/tmp/evmonly-upgrade-keys
34+
EVM_RPC=http://127.0.0.1:8545
35+
# gov.DefaultParams' minimum expedited deposit.
36+
EXPEDITED_DEPOSIT=20000000usei
4337
TEST_UPGRADE=vX.Y-test
4438
TEST_MINOR_UPGRADE=vX.Y-minor-test
45-
SUBMIT_PROPOSAL_TOPIC=$(cast keccak "SubmitProposal(uint64,address,uint8,bool)")
4639
# The 72h max deposit period, in nanoseconds, the test upgrade's handler sets.
4740
DEPOSIT_PERIOD_AFTER=259200000000000
4841
TEST_BINARY=build/seid-test-upgrade
@@ -58,40 +51,89 @@ check() {
5851
if [ "$got" = "$want" ]; then pass "$what"; else fail "$what: got '$got', want '$want'"; fi
5952
}
6053

61-
rpc() { echo "http://127.0.0.1:${PORTS[$1]}"; }
62-
height() { cast block-number --rpc-url "$(rpc "$1")" 2>/dev/null || echo unreachable; }
54+
node_sh() { docker exec "sei-node-$1" sh -c "$2"; }
6355

64-
# tick sends one transfer, which seals a block, and waits up to 20s for it.
65-
tick() {
66-
cast send --rpc-url "$(rpc 0)" --private-key "$TICK_KEY" --legacy --gas-price "$GAS_PRICE" \
67-
--timeout 20 0x0000000000000000000000000000000000000001 --value 1 >/dev/null 2>&1
56+
# seid_q runs a seid query in node $1 against that node's EVM JSON-RPC.
57+
seid_q() {
58+
local n=$1
59+
shift
60+
docker exec "sei-node-$n" seid "$@" --evm-rpc "$EVM_RPC"
6861
}
6962

70-
# gov_send sends a gov call from voter key $1 and prints its receipt as JSON.
71-
gov_send() {
63+
# seid_q_or_none runs a seid query in node $1 and prints its output. A query
64+
# failing with message $2 prints nothing and succeeds; any other failure
65+
# prints its error to stderr and fails.
66+
seid_q_or_none() {
67+
local n=$1 none=$2 err
68+
shift 2
69+
{ err=$(seid_q "$n" "$@" 2>&1 >&3 3>&-); } 3>&1 && return 0
70+
case "$err" in *"$none"*) return 0 ;; esac
71+
echo "$err" | head -1 >&2
72+
return 1
73+
}
74+
75+
# seid_tx runs a seid transaction in node 0, signed by key $1 of KEY_HOME.
76+
seid_tx() {
7277
local key=$1
7378
shift
74-
cast send --json --rpc-url "$(rpc 0)" --private-key "$key" --legacy --gas-price "$GAS_PRICE" \
75-
--gas-limit 2000000 "$GOV" "$@"
79+
docker exec sei-node-0 seid "$@" --from "$key" --keyring-backend test --home "$KEY_HOME" --evm-rpc "$EVM_RPC"
80+
}
81+
82+
# gov_tx sends a seid tx gov command from key $1 and prints its result as JSON.
83+
gov_tx() {
84+
local key=$1
85+
shift
86+
seid_tx "$key" tx gov "$@" -y -o json
87+
}
88+
89+
height() {
90+
local h
91+
h=$(seid_q "$1" q block 2>/dev/null | jq -r .number 2>/dev/null) || h=
92+
case "$h" in 0x*) echo $((h)) ;; *) echo unreachable ;; esac
93+
}
94+
95+
# tick sends one transfer, which seals a block, and waits up to 20s for it.
96+
tick() {
97+
local before i
98+
before=$(height 0)
99+
[ "$before" != unreachable ] || return 1
100+
seid_tx key9 tx evm send 0x0000000000000000000000000000000000000001 1 >/dev/null 2>&1 || return 1
101+
for i in $(seq 1 20); do
102+
[ "$(height 0)" != unreachable ] && [ "$(height 0)" -gt "$before" ] && return 0
103+
sleep 1
104+
done
105+
return 1
76106
}
77107

78-
# proposal_id prints the id a submit receipt's SubmitProposal event carries.
108+
# proposal_id prints the id in a submit-proposal result.
79109
proposal_id() {
80-
jq -r --arg topic "$SUBMIT_PROPOSAL_TOPIC" '.logs[] | select(.topics[0] == $topic) | .topics[1]' | cast to-dec
110+
jq -r '.logs[0].events[] | select(.type == "submit_proposal") | .attributes[] | select(.key == "proposal_id") | .value'
111+
}
112+
113+
# submit_upgrade submits an expedited software upgrade of plan $1 at height $2
114+
# with info $3, and prints its proposal id.
115+
submit_upgrade() {
116+
gov_tx key0 submit-proposal software-upgrade "$1" --upgrade-height "$2" --upgrade-info "$3" \
117+
--title upgrade --description "schedules $1" --is-expedited --deposit "$EXPEDITED_DEPOSIT" | proposal_id
118+
}
119+
120+
# submit_cancel submits an expedited cancel of plan $1 and prints its result.
121+
submit_cancel() {
122+
gov_tx key0 submit-proposal cancel-software-upgrade --name "$1" \
123+
--title cancel --description "cancels $1" --is-expedited --deposit "$EXPEDITED_DEPOSIT"
81124
}
82125

83126
# pass_proposal has every voter vote yes on proposal $1 and ticks until it
84-
# leaves the voting period.
127+
# leaves the voting period, printing its final status.
85128
pass_proposal() {
86129
local id=$1 i status
87130
for i in 0 1 2 3; do
88-
gov_send "${VOTER_KEYS[$i]}" "vote(uint64,int32)" "$id" 1 >/dev/null
131+
gov_tx "key$i" vote "$id" yes >/dev/null
89132
done
90133
for i in $(seq 1 60); do
91134
tick || true
92-
status=$(cast call --rpc-url "$(rpc 0)" "$GOV" "proposal(uint64)((uint64,int32,(uint256,uint256,uint256,uint256),uint64,uint64,uint256,uint64,uint64,bool,uint8,bytes))" "$id" |
93-
sed -n 's/^(\([0-9]*\), \([0-9]*\),.*/\2/p')
94-
if [ "$status" != 2 ]; then
135+
status=$(seid_q 0 q gov proposal "$id" -o json | jq -r .status)
136+
if [ "$status" != PROPOSAL_STATUS_VOTING_PERIOD ]; then
95137
echo "$status"
96138
return
97139
fi
@@ -100,14 +142,40 @@ pass_proposal() {
100142
echo timeout
101143
}
102144

103-
plan_name() { cast call --rpc-url "$(rpc "$1")" "$UPGRADE" "currentPlan()((string,uint64,string))" | sed -n 's/^("\([^"]*\)", .*/\1/p'; }
104-
applied() { cast call --rpc-url "$(rpc "$1")" "$UPGRADE" "appliedPlan(string)(uint64)" "$2"; }
105-
max_deposit_period() {
106-
cast call --rpc-url "$(rpc "$1")" "$PARAMS" "param(string,string)(bytes)" gov depositparams.max_deposit_period | cast to-dec
145+
# plan_name prints the name of the plan node $1 has scheduled, nothing when it
146+
# has none, and "query failed" when the query fails.
147+
plan_name() {
148+
local out
149+
out=$(seid_q_or_none "$1" "no upgrade scheduled" q upgrade plan -o json) || { echo "query failed"; return; }
150+
[ -z "$out" ] || echo "$out" | jq -r .name
107151
}
108-
block_hash() { cast block "$2" --field hash --rpc-url "$(rpc "$1")"; }
109152

110-
node_sh() { docker exec "sei-node-$1" sh -c "$2"; }
153+
# applied prints the height node $1 applied plan $2 at, 0 when it never applied
154+
# it, and "query failed" when the query fails.
155+
applied() {
156+
local out h
157+
out=$(seid_q_or_none "$1" "no upgrade found" q upgrade applied "$2") || { echo "query failed"; return; }
158+
[ -n "$out" ] || { echo 0; return; }
159+
h=$(echo "$out" | jq -r .number 2>/dev/null)
160+
case "$h" in 0x*) echo $((h)) ;; *) echo "unparsed: $h" ;; esac
161+
}
162+
163+
# cancel_outcome submits a cancel of plan $1 and prints refused when the gov
164+
# precompile refuses it during gas estimation, sent when it is sent, and the
165+
# error otherwise.
166+
cancel_outcome() {
167+
local err
168+
if err=$(submit_cancel "$1" 2>&1 >/dev/null); then
169+
echo sent
170+
return
171+
fi
172+
case "$err" in
173+
*"estimate gas: upgrade is not scheduled"*) echo refused ;;
174+
*) echo "$err" | head -1 ;;
175+
esac
176+
}
177+
max_deposit_period() { seid_q "$1" q gov params -o json | jq -r .deposit_params.max_deposit_period; }
178+
block_hash() { seid_q "$1" q block "$2" | jq -r .hash; }
111179

112180
# restart_node stops seid on node $1, waiting up to 30s for it to exit, then
113181
# starts it from binary $2 as step5_start_sei.sh does.
@@ -142,12 +210,16 @@ tick_past() {
142210
done
143211
}
144212

213+
# serving reports whether node $1 answers over its EVM JSON-RPC, which it does
214+
# from genesis, before it has a block.
215+
serving() { seid_q_or_none "$1" "no upgrade scheduled" q upgrade plan >/dev/null 2>&1; }
216+
145217
# wait_ready waits for node $1 to serve RPC, polling every 2s up to $2 times
146218
# (default 60).
147219
wait_ready() {
148220
local i
149221
for i in $(seq 1 "${2:-60}"); do
150-
if cast chain-id --rpc-url "$(rpc "$1")" >/dev/null 2>&1; then return 0; fi
222+
if serving "$1"; then return 0; fi
151223
sleep 2
152224
done
153225
return 1
@@ -165,21 +237,34 @@ for n in $(seq 0 $((NODES - 1))); do
165237
fi
166238
done
167239

240+
log "Importing the test keys into $KEY_HOME in sei-node-0"
241+
node_sh 0 "rm -rf $KEY_HOME"
242+
for i in $KEY_INDEXES; do
243+
echo "$MNEMONIC" | docker exec -i sei-node-0 seid keys add "key$i" --recover \
244+
--hd-path "m/44'/60'/0'/0/$i" --keyring-backend test --home "$KEY_HOME" >/dev/null
245+
done
246+
247+
log "Sending a teaser transfer so the chain leaves genesis"
248+
# Autobahn makes no empty blocks, and a node reports no latest block before
249+
# the first one, so a transfer produces block 1 before anything reads a block.
250+
seid_tx key9 tx evm send 0x0000000000000000000000000000000000000001 1 >/dev/null
251+
for i in $(seq 1 20); do
252+
[ "$(height 0)" != unreachable ] && break
253+
sleep 1
254+
done
255+
[ "$(height 0)" != unreachable ] || { echo "the chain produced no first block" >&2; exit 1; }
256+
168257
log "Building the giga_test_upgrade binary in sei-node-0"
169258
node_sh 0 "cd /sei-protocol/sei-chain && export PATH=\$PATH:/usr/local/go/bin && \
170259
LEDGER_ENABLED=false go build -tags 'netgo giga_test_upgrade' -o $TEST_BINARY ./cmd/seid"
171260
node_sh 0 "cp \$HOME/go/bin/seid /sei-protocol/sei-chain/build/seid-old"
172261

173262
log "Scheduling $TEST_UPGRADE"
174-
# Gov writes its genesis state at the chain's first block and refuses calls
175-
# until then, so a transaction must produce that block first.
176-
tick || fail "the chain produced no first block"
177263
start=$(height 0)
178264
target=$((start + 40))
179-
id=$(gov_send "${VOTER_KEYS[0]}" "submitSoftwareUpgradeProposal(string,string,bool,(string,uint64,string))" \
180-
"upgrade" "schedules $TEST_UPGRADE" true "($TEST_UPGRADE,$target,docker-run)" --value "$EXPEDITED_DEPOSIT" | proposal_id)
265+
id=$(submit_upgrade "$TEST_UPGRADE" "$target" docker-run)
181266
echo "proposal $id plans $TEST_UPGRADE at block $target"
182-
check "upgrade proposal passes" "$(pass_proposal "$id")" 3
267+
check "upgrade proposal passes" "$(pass_proposal "$id")" PROPOSAL_STATUS_PASSED
183268
deposit_period_before=$(max_deposit_period 0)
184269
check "the max deposit period is not yet the handler's" "$([ "$deposit_period_before" != "$DEPOSIT_PERIOD_AFTER" ] && echo yes || echo no)" yes
185270
for n in 0 1 2 3; do
@@ -239,17 +324,15 @@ wait_ready 3 || fail "node 3 did not come back"
239324

240325
log "Cancelling a plan before its height"
241326
tick || fail "no block before the cancel"
242-
cancelled=$(( $(height 0) + 40 ))
243-
id=$(gov_send "${VOTER_KEYS[0]}" "submitSoftwareUpgradeProposal(string,string,bool,(string,uint64,string))" \
244-
"upgrade" "schedules never-applied" true "(never-applied,$cancelled,none)" --value "$EXPEDITED_DEPOSIT" | proposal_id)
245-
check "second upgrade proposal passes" "$(pass_proposal "$id")" 3
327+
cancelled=$(($(height 0) + 40))
328+
id=$(submit_upgrade never-applied "$cancelled" none)
329+
check "second upgrade proposal passes" "$(pass_proposal "$id")" PROPOSAL_STATUS_PASSED
246330
check "the second plan is scheduled" "$(plan_name 0)" never-applied
247-
status=$(gov_send "${VOTER_KEYS[0]}" "submitCancelSoftwareUpgradeProposal(string,string,bool,string)" \
248-
"cancel" "cancels another plan" true not-scheduled --value "$EXPEDITED_DEPOSIT" 2>/dev/null | jq -r '.status // empty' 2>/dev/null || true)
249-
check "a cancel naming another plan fails" "$status" 0x0
250-
id=$(gov_send "${VOTER_KEYS[0]}" "submitCancelSoftwareUpgradeProposal(string,string,bool,string)" \
251-
"cancel" "cancels never-applied" true never-applied --value "$EXPEDITED_DEPOSIT" | proposal_id)
252-
check "cancel proposal passes" "$(pass_proposal "$id")" 3
331+
# seid estimates gas before sending, so the gov precompile's refusal stops the
332+
# cancel before any transaction is sent.
333+
check "a cancel naming another plan is refused" "$(cancel_outcome not-scheduled)" refused
334+
id=$(submit_cancel never-applied | proposal_id)
335+
check "cancel proposal passes" "$(pass_proposal "$id")" PROPOSAL_STATUS_PASSED
253336
for n in 0 1 2 3; do check "node $n has no plan after the cancel" "$(plan_name "$n")" ""; done
254337
tick_past $((cancelled + 1))
255338
for n in 0 1 2 3; do
@@ -259,11 +342,9 @@ done
259342

260343
log "Applying minor upgrade $TEST_MINOR_UPGRADE"
261344
tick || fail "no block before the minor upgrade"
262-
minor=$(( $(height 0) + 40 ))
263-
id=$(gov_send "${VOTER_KEYS[0]}" "submitSoftwareUpgradeProposal(string,string,bool,(string,uint64,string))" \
264-
"upgrade" "schedules $TEST_MINOR_UPGRADE" true "($TEST_MINOR_UPGRADE,$minor,{\"upgradeType\":\"minor\"})" \
265-
--value "$EXPEDITED_DEPOSIT" | proposal_id)
266-
check "minor upgrade proposal passes" "$(pass_proposal "$id")" 3
345+
minor=$(($(height 0) + 40))
346+
id=$(submit_upgrade "$TEST_MINOR_UPGRADE" "$minor" '{"upgradeType":"minor"}')
347+
check "minor upgrade proposal passes" "$(pass_proposal "$id")" PROPOSAL_STATUS_PASSED
267348
tick || true
268349
sleep 5
269350
for n in 0 1 2 3; do

0 commit comments

Comments
 (0)