Skip to content

Mediums batch 2 - #224

Closed
lordbutterfly-hive wants to merge 1 commit into
developfrom
med/gv-develop
Closed

Mediums batch 2#224
lordbutterfly-hive wants to merge 1 commit into
developfrom
med/gv-develop

Conversation

@lordbutterfly-hive

Copy link
Copy Markdown
Contributor

PR — go-vsc-node: MED fix batch (gateway/wasm/oracle/runtime/dids/keystore) + ecrecover host-import HIGH + EVM-bridge devnet test suite

37 files changed = 21 (5 MED commits) + 16 new devnet test/helper files.

Title

fix(go-vsc): register crypto.ecrecover_strict/canonical host imports (un-brick contract ecrecover, HIGH) + 22 review6 MEDs across gateway/wasm/oracle/runtime/dids/keystore + EVM-bridge devnet test suite


⚠ THE HIGH — DS-RE-1: contract ecrecover host imports were never registered

df295dc1 — The account-mapping + zk contracts import crypto.ecrecover_strict (withdrawals) and crypto.ecrecover_canonical (deposits), but go-vsc never registered these host functions. On a real gc.custom WASM build the contract bricks on every ecrecover path. It was masked locally because the !gc.custom SDK stub delegates strict→plain. FIXED: both host imports registered in modules/wasm/runtime_ipc/wasm.go; strict rejects high-S (malleability), canonical normalizes — both empirically verified against go-ethereum. This is the cross-repo lynchpin: deploy this host BEFORE any contract WASM that imports them (see Deploy Order) or the contract bricks on instantiate.


MED findings closed (22 numbered + round hardening)

gateway/p2p — 7e9ab539

gateway/multisig — 7e9ab539

wasm/sdk + host — 7e9ab539, round3/5

oracle — 7e9ab539, round3

runtime — 7e9ab539, round2/3/4

  • sign uses gossip, one gossip per height #136 / CD-1 IsSupportedAt() version-gates runtime acceptance at create/update AND at the call site (transactions.go, before w.Execute) so a contract record with an invalid runtime inserted directly into Mongo yields a deterministic tx-level failure on all nodes instead of reaching the Execute default-case panic.
  • C-R24 / R2-4 Execute default branch: explicitly-commented unreachable-assertion panic with the determinism rationale (the generic signature can't build result.Err[Result]; zero-value Result[T] has IsOk()==true which would mask a wiring regression — so panic, but documented as provably-unreachable since IsSupportedAt gates create/update).
  • C-RV / R2-5 SimulateContractCalls now adds WithTryCatch gated on TryCatchICCVersion, matching the four options the on-chain path sets (WithPendulumApplier, WithTryCatch, WithSdkErrorDeterminism, WithInitGuard) — Simulate was missing WithTryCatch, diverging from on-chain ICC try-semantics.
  • C-RV / R2-6c assertIntervalDivisibility strengthened to require strict ordering ACTION_INTERVAL < ROTATION_INTERVAL < SYNC_INTERVAL (equal intervals pass divisibility but permanently starve actions — reintroduces MED-56).

dids — 7e9ab539

  • wasm vm ipc runner #9 EthDID.Verify length guard (65 bytes) before indexing sigBytes[64] (panic-on-malformed-sig fix).

keystore — 7e9ab539

  • MED-13 os.Chmod(tssKeysDir, 0700) after flatfs.CreateOrOpen — TSS key dir perms.

CONSENSUS-VERSION GATING — review this carefully (determinism)

The fixes that change on-chain behavior are version-gated so nodes stay in lockstep until activation:


EVM-BRIDGE DEVNET TEST SUITE (16 new files — this is the integration proof for THIS PR and the account-mapping PR)

Real 5-node docker devnet + anvil L1. tests/devnet/: evm_anvil.go (anvil + MPT tx/receipt-trie proofs), evm_l2_sign.go (evm-DID L2 signing), evm_bot.go (bot runner), evm_bridge_setup.go (shared harness: deploy + wire mock verifier + RC bootstrap + deployWithRetry), and the waves:

Wave Proves
W1 evm_bridge_w1 ETH deposit: ecrecover_canonical recovers L1 depositor (proves DS-RE-1 host import), tx-trie verify vs real anvil root, observed-dedup, chainId, gas-tax. FAIL→PASS demonstrates the account-mapping host-"" HIGH fix.
W2 evm_bridge_w2 Withdrawal close-out: PendingSpend JSON (H-F1), confirmSpend flat-10 + intent-bind + tx/receipt-trie (H-F2), all-zero-bloom receiptsRoot (CC-1), ecrecover_strict==vault (DS-F1), single nonce advance.
W3 evm_bridge_w3 Double-spend: Type-B drop-proof can't force-refund a SUCCEEDED withdrawal (H-SM2), Type-A status!=0 (H-SM1), no refund/no double-spend.
ZK evm_bridge_zk zk-verifier reject paths (#85 shape gate, #65, required-fields). Accept path = Milo's SP1 proof (out of scope).
W6Neg evm_bridge_w6neg admin/negative matrix 15/15 (pause, registerToken/setGasReserve bounds, unmapETH/map degenerate).
BotRes evm_bridge_botres bot checkpoint persist/resume + the bot-"h" scan-height fix (see PR3); LastScannedBlock 0→74.
BotH evm_bridge_both proves the bot-"h" contract↔bot mismatch finding.

All green; full regression re-swept (W1/W2/W3/ZK/W6Neg PASS). Status: /mnt/o/MED-FIX-2026-06-19/devnet-results/STATUS-DEVNET.md.


DEPLOY ORDER (mandatory — cross-repo coupling)

  1. THIS host first (med/gv-develop, ecrecover_strict/canonical imports) BEFORE any contract WASM that imports them, or the contract bricks on instantiate.
  2. Then account-mapping (review6) + bot (EVM #154) + zk per the campaign handoff.

Reviewer guide

  1. DS-RE-1 is the headline — verify both host imports registered in runtime_ipc/wasm.go, strict rejects high-S, canonical normalizes.
  2. Consensus gating (section above) — no behavior change ungated; versions correct.
  3. Init-guard (Feat/onchain gossip readiness v2 #130) threads a ctx key through 3 call sites — confirm all three (transactions.go, execution-context.go, GQL simulate).
  4. Devnet suite is the integration proof; it deploys the account-mapping WASM, so this PR + the account-mapping PR verify together.

NOTE — branch base

med/gv-develop is 5 commits ahead of origin/develop. If you want a tests-only or fixes-only split, say so; as-is the branch carries both the 5 MED commits and the devnet suite → one PR to develop.

Hygiene

LF line endings (verified). No .wasm/binaries staged. TODO before merge: 3 devnet test files (evm_bridge_w0/wmock/zk) hardcode a local /home/clauderfly/... WASM path — being parameterized to an env var w/ default (does not affect CI logic, but shouldn't ship a machine path).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant