Skip to content

test(evm): migrate response-reading lib.js helpers off -b block (CON-256)#3406

Merged
wen-coding merged 5 commits into
mainfrom
wen/migrate_response_reading_lib_helpers_off_b_block
May 20, 2026
Merged

test(evm): migrate response-reading lib.js helpers off -b block (CON-256)#3406
wen-coding merged 5 commits into
mainfrom
wen/migrate_response_reading_lib_helpers_off_b_block

Conversation

@wen-coding
Copy link
Copy Markdown
Contributor

@wen-coding wen-coding commented May 7, 2026

Summary

Picks up where #3363 left off. Migrates the lib.js helpers that read post-execution events from -b block to -b sync + per-helper side-effect waits.

Pattern (introduced in #3363, extended here): submit with -b sync, then poll the actual on-chain side effect rather than seid q tx (which doesn't return under Autobahn). When the side effect is observable, return the post-state value; when it isn't, fall back to admin-sequence-advance + block-walk to recover the inclusion height.

Migrated:

  • storeWasm — side-effect: max wasm code_id grows (new getMaxWasmCodeId)
  • instantiateWasm — side-effect: new contract appears under codeId (new listContractsByCode)
  • registerPointerForERC20/721/1155 — side-effect: seid query evm pointer returns non-empty (factored into shared registerPointerForCw)
  • proposeCW20toERC20Upgrade, proposeParamChange — side-effect: new gov proposal with matching title (factored into findProposalByTitle)
  • executeWasm, associateWasm — fallback path: waitForAdminTxCommit waits on admin sequence advance, then block-walks to recover the actual inclusion height (no easy single-query side effect for arbitrary wasm execute / contract association)

Wait-timeout cases are wrapped with the same error prefixes ("storeWasm failed", "instantiateWasm failed", "contract deployment failed") that callers already match on, so existing assertions in DisableWasmTest and similar continue to work.

Other:

  • Removed associateSigner + hardcoded seilocalSignerPrivateKeyssetupSigners now uniformly funds the EVM address and reads back the sei address. The conditional branch became redundant after test(evm): wipe stale .openzeppelin manifest before upgradeability test #3431.
  • Dropped 3 res.code assertions in CW1155toERC1155PointerTest.jsres.code is now CheckTx (always 0 for mempool admission), not DeliverTx. Outcome verification stays via the existing post-state balance checks.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 19, 2026, 9:27 PM

@wen-coding wen-coding marked this pull request as ready for review May 7, 2026 05:34
@wen-coding wen-coding marked this pull request as draft May 7, 2026 05:37
@wen-coding
Copy link
Copy Markdown
Contributor Author

This doesn't work until we link in block db which supports tx lookup.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.04%. Comparing base (80a4364) to head (9f05f86).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3406      +/-   ##
==========================================
- Coverage   59.05%   59.04%   -0.01%     
==========================================
  Files        2188     2188              
  Lines      182088   182084       -4     
==========================================
- Hits       107530   107520      -10     
  Misses      64925    64925              
- Partials     9633     9639       +6     
Flag Coverage Δ
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wen-coding wen-coding force-pushed the wen/migrate_response_reading_lib_helpers_off_b_block branch 2 times, most recently from 2e0fe83 to 9d86334 Compare May 18, 2026 22:57
wen-coding and others added 4 commits May 19, 2026 14:08
… waits

The remaining -b block helpers in lib.js previously needed their post-
execution events to extract the returned identifier (code_id, contract
address, proposal_id, pointer_address). Under Autobahn -b block hangs,
and the seid tx indexer isn't wired yet, so neither -b block nor a
generic poll-by-txhash works.

Replace each with a per-caller side-effect wait that goes through a
query path that does work under Autobahn:

- storeWasm: poll max code_id in `seid q wasm list-code`
- instantiateWasm: diff `seid q wasm list-contract-by-code` before/after
- proposeCW20toERC20Upgrade: scan gov proposals for matching title
  (extracted findProposalByTitle helper, also used by proposeParamChange)
- registerPointerForERC20/721/1155: factored into registerPointerForCw;
  poll `seid q evm pointer` until non-empty
- executeWasm, associateWasm: new waitForAdminTxCommit helper, waits
  for sender sequence to advance (the natural commit signal when the
  helper itself doesn't have a specific side effect to poll)

The four EVM pointer deploy helpers (deployErc{20,721,1155}PointerFor*,
deployErc20PointerNative) already polled via `provider.getTransactionReceipt`
so only the broadcast mode needs to change.

executeWasm now returns only the CheckTx response (not DeliverTx), so
callers that asserted `res.code` to verify failure have to verify via
state instead. CW1155toERC1155PointerTest already followed each such
check with the state assertion that actually proves the outcome, so the
res.code lines are removed as redundant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…merge

The merge of #3431 (origin/wen/wipe_env_before_contract_upgradeability_test)
silently kept our side of setupSigners because #3363 had touched the same
region. Apply #3431's intent here: drop associateSigner and the
seilocalSignerPrivateKeys lookup, and have setupSigners always use the
fundAddress + self-send-tx flow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… waitForAdminTxCommit

Three cleanups after CI surfaced regressions from the -b sync refactor:

1. storeWasm / instantiateWasm / registerPointerForCw wrap the
   waitForCondition timeout in a `<helper> failed: ...` prefix so
   callers that match on the prefix string (DisableWasmTest's wasm-
   disabled cases, ERC20toCW20PointerTest's pointer-of-a-pointer
   case) keep working. The chain rejects at DeliverTx in these cases
   (CheckTx accepts), so we surface the failure as a timeout on the
   side effect — the prefix preserves the existing error contract.

2. executeWasm / associateWasm now rewrite `response.height` to the
   actual inclusion block. The CheckTx response from -b sync carries
   `height: "0"`, but SeiEndpointsTest reads `res.height` to bound
   its sei_getLogs range. Find the inclusion block by scanning blocks
   between submit and observed commit for the tx hash (hex-uppercase
   SHA-256 of base64-decoded `block.data.txs` entries).

3. Add `getCurrentBlockHeight` and `findInclusionBlock` to support (2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wen-coding wen-coding force-pushed the wen/migrate_response_reading_lib_helpers_off_b_block branch from cddbc2d to 68b8f86 Compare May 19, 2026 21:09
@wen-coding wen-coding changed the title test(evm): introduce submitAndWaitForTx; migrate storeWasm + registerPointerForERC20 (CON-256) test(evm): migrate response-reading lib.js helpers off -b block (CON-256) May 19, 2026
- storeWasm: capture new code_id inside the wait. A second
  getMaxWasmCodeId() after the wait raced with any concurrent store
  landing in the same window. Serial test execution made the race
  dormant; capture-during-wait closes it.

- instantiateWasm: same. The wait used .some() (boolean) and the return
  used .find() (specific entry) — two separate queries, each of which
  could see different state. Now captured inside the wait.

- waitForAdminTxCommit: when sender sequence advanced (tx landed
  somewhere) but findInclusionBlock returned null, response.height was
  silently left at the CheckTx default. Log when this happens so the
  anomaly is visible in test output rather than producing a misleading
  height value.

- CW1155toERC1155PointerTest: drop the unused res from three
  executeWasm calls (the res.code assertions that read it are gone),
  and on the negative-case test, add a comment pointing at the
  unchanged balances as the assertion that the unauthorized transfer
  was rejected at DeliverTx.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread contracts/test/lib.js
const output = await execute(command);
return JSON.parse(output);
const command = `seid tx wasm execute ${contractAddress} "${jsonString}" --amount ${coins} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y -b sync -o json`;
return await waitForAdminTxCommit(command)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment thread contracts/test/lib.js
const seqBefore = await getAccountSequence(senderAddr)
const response = JSON.parse(await execute(command))
if (response.code !== 0) return response // CheckTx rejection — surface immediately
await waitForCondition(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we timeout in case there's some sort of bug here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, waitForCondition has a default 30s timeout, adding a note.

@wen-coding wen-coding marked this pull request as ready for review May 19, 2026 23:43
@cursor
Copy link
Copy Markdown

cursor Bot commented May 19, 2026

PR Summary

Medium Risk
Medium risk because it changes core test harness transaction submission/wait logic (wasm store/instantiate, pointer registration, gov proposals), which can introduce flakiness or false positives/negatives across many E2E tests if the new side-effect detection is incomplete or racy.

Overview
Migrates key contracts/test/lib.js helpers from -b block to -b sync and makes them wait for observable chain side effects before returning (e.g., new wasm code_id, new contract under a codeId, new gov proposal by title, and newly-registered pointer addresses), including shared polling utilities and improved error wrapping.

Adds a fallback waitForAdminTxCommit path for cases without an easy side-effect query (executeWasm, associateWasm) by waiting for the admin account sequence to advance and then scanning blocks to recover the inclusion height.

Simplifies signer setup by removing hardcoded private-key association logic and updates CW1155toERC1155PointerTest to stop asserting res.code (now CheckTx-only), relying on post-state balance checks instead.

Reviewed by Cursor Bugbot for commit 9f05f86. Bugbot is set up for automated code reviews on this repo. Configure here.

wen-coding added a commit that referenced this pull request May 20, 2026
Mirrors the existing "EVM Module" CI job with AUTOBAHN=true plus the
GIGA_EXECUTOR/GIGA_STORAGE/GIGA_OCC flag set used by the "Autobahn
EVM GIGA Module" job. Runs evm_tests.sh under Autobahn:

  - EVMCompatabilityTest.js  (broad EVM semantics: deployment, gas,
                              variable types, assembly, trace, log
                              filtering, edge cases — 78 cases)
  - EVMPrecompileTest.js     (Sei precompiles: bank, addr, gov,
                              distribution, staking, oracle, wasm)
  - SeiEndpointsTest.js      (sei_*ExcludeTraceFail JSON-RPC paths)
  - AssociateTest.js         (account association mechanics)

Complements the narrower "Autobahn EVM GIGA Module" (smoke-tests
EVMGigaTest.js on native+ERC20 transfers only) by adding broader
EVM-compat + Sei-precompile + sei-endpoint + association coverage
that aren't exercised elsewhere under Autobahn.

Deliberately omits the flatkv post-steps from the CometBFT "EVM
Module" job; flatkv-under-Autobahn is its own concern and would
make per-job failure triage harder.

Verified locally on a 4-node Autobahn docker cluster: 101 passing,
1 pending, 0 failing.

Autobahn EVM Interoperability deferred until #3406 (lib.js
response-reading helper migration) lands; without it, the
suite's CW-deploy setup hooks depend on unmigrated -b block
helpers and CI passing would be accidental rather than verified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
wen-coding added a commit that referenced this pull request May 20, 2026
Mirrors the existing "EVM Module" CI job with AUTOBAHN=true plus the
GIGA_EXECUTOR/GIGA_STORAGE/GIGA_OCC flag set used by the "Autobahn
EVM GIGA Module" job. Runs evm_tests.sh under Autobahn:

  - EVMCompatabilityTest.js  (broad EVM semantics: deployment, gas,
                              variable types, assembly, trace, log
                              filtering, edge cases — 78 cases)
  - EVMPrecompileTest.js     (Sei precompiles: bank, addr, gov,
                              distribution, staking, oracle, wasm)
  - SeiEndpointsTest.js      (sei_*ExcludeTraceFail JSON-RPC paths)
  - AssociateTest.js         (account association mechanics)

Complements the narrower "Autobahn EVM GIGA Module" (smoke-tests
EVMGigaTest.js on native+ERC20 transfers only) by adding broader
EVM-compat + Sei-precompile + sei-endpoint + association coverage
that aren't exercised elsewhere under Autobahn.

Deliberately omits the flatkv post-steps from the CometBFT "EVM
Module" job; flatkv-under-Autobahn is its own concern and would
make per-job failure triage harder.

Verified locally on a 4-node Autobahn docker cluster: 101 passing,
1 pending, 0 failing.

Autobahn EVM Interoperability deferred until #3406 (lib.js
response-reading helper migration) lands; without it, the
suite's CW-deploy setup hooks depend on unmigrated -b block
helpers and CI passing would be accidental rather than verified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
wen-coding added a commit that referenced this pull request May 20, 2026
Mirrors the existing "EVM Module" CI job with AUTOBAHN=true plus the
GIGA_EXECUTOR/GIGA_STORAGE/GIGA_OCC flag set used by the "Autobahn
EVM GIGA Module" job. Same 4 steps as the CometBFT job:

  - evm_tests.sh                          (EVMCompatabilityTest,
                                           EVMPrecompileTest,
                                           SeiEndpointsTest,
                                           AssociateTest)
  - deploy_flatkv_evm_fixture.sh          (seeds historical EVM
                                           state: balance, storage,
                                           code)
  - flatkv_evm_test.yaml                  (historical EVM RPC reads
                                           via cast: balance, storage,
                                           code at past block heights)
  - verify_flatkv_evm_store.sh            (seidb dump-flatkv smoke
                                           check on the on-disk
                                           storage bucket)

Complements the narrower "Autobahn EVM GIGA Module" (smoke-tests
EVMGigaTest.js on native+ERC20 transfers only) by adding broader
EVM-compat + Sei-precompile + sei-endpoint + association coverage
plus historical-state correctness, none of which are exercised
elsewhere under Autobahn.

Verified locally on a 4-node Autobahn docker cluster:
  evm_tests.sh:                  101 passing, 1 pending, 0 failing
  deploy_flatkv_evm_fixture.sh:  fixture seeded at heights 17567/17571
  (flatkv yaml + verify steps deferred to CI; the 3 flatkv components
  have zero -b block usages and use only EVM RPC + seid queries, so
  they're Autobahn-clean.)

Autobahn EVM Interoperability deferred until #3406 (lib.js
response-reading helper migration) lands; without it, the
suite's CW-deploy setup hooks depend on unmigrated -b block
helpers and CI passing would be accidental rather than verified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wen-coding wen-coding added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 1dd16d0 May 20, 2026
43 checks passed
@wen-coding wen-coding deleted the wen/migrate_response_reading_lib_helpers_off_b_block branch May 20, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants