Skip to content

fix(runtime): support view/staticCall on native ethers contracts + prime genesis on reachable TRE - #30

Merged
luiz-lvj merged 1 commit into
mainfrom
runtime/view-call-support
Jun 2, 2026
Merged

fix(runtime): support view/staticCall on native ethers contracts + prime genesis on reachable TRE#30
luiz-lvj merged 1 commit into
mainfrom
runtime/view-call-support

Conversation

@luiz-lvj

@luiz-lvj luiz-lvj commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two fixes surfaced while running the OZ tron-contracts suite against TRE.

1. stubProvider.call(tx) — view/staticCall support for native ethers contracts

A native new ethers.Contract(addr, abi, runner) — e.g. the tron-contracts test helper forceDeployCode layered over setCode — routes view/pure methods and any explicit .staticCall through runner.call(tx). The bridge's stubProvider implemented getCode/getBalance/estimateGas/… but not .call, so ethers threw UNSUPPORTED_OPERATION: contract runner does not support calling. (The facade path — deployContract/getContractAt — intercepts calls itself and was unaffected; only the bare-provider path hit this.)

Fix: add stubProvider.call(tx), modeled on the existing estimateGas — POST the raw calldata to /wallet/triggerconstantcontract and return '0x' + constant_result[0]; ethers performs the ABI decode, so no ABI/registry is needed in the stub. Revert handling mirrors staticCallWithRevertData: detect a revert via result.code || result.message and throw a CALL_EXCEPTION carrying the revert bytes, so revertedWith / revertedWithCustomError decode the error instead of ethers mis-decoding the 4-byte selector as return data.

2. primeGenesis on ensureUp's "already reachable" branch

When an external/parallel runner spawns its own TRE and points the plugin at it via TRE_URL, ensureUp takes the "already reachable → skip spawn" branch and therefore skipped the genesis prime, leaving the chain at block 0. java-tron's proto3 encoding omits the zero-valued block number, so the first CreateSmartContract deploy crashes in getCurrentRefBlockParams ("Cannot read properties of undefined"). Fix: call primeGenesis on that branch too. Best-effort + idempotent — on an already-advanced chain it just mines one extra harmless block.

Verification

Files

  • src/runtime/ethers-bridge.js — add stubProvider.call(tx) (+44)
  • src/tre/lifecycle.jsprimeGenesis on the reachable branch (+7)

@luiz-lvj
luiz-lvj requested a review from km631 June 2, 2026 15:28

@km631 km631 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@luiz-lvj
luiz-lvj merged commit 9e1d604 into main Jun 2, 2026
5 checks passed
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.

2 participants