fix(runtime): support view/staticCall on native ethers contracts + prime genesis on reachable TRE - #30
Merged
Merged
Conversation
…ime genesis on reachable TRE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes surfaced while running the OZ tron-contracts suite against TRE.
1.
stubProvider.call(tx)— view/staticCallsupport for native ethers contractsA native
new ethers.Contract(addr, abi, runner)— e.g. the tron-contracts test helperforceDeployCodelayered oversetCode— routesview/puremethods and any explicit.staticCallthroughrunner.call(tx). The bridge'sstubProviderimplementedgetCode/getBalance/estimateGas/… but not.call, so ethers threwUNSUPPORTED_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 existingestimateGas— POST the raw calldata to/wallet/triggerconstantcontractand return'0x' + constant_result[0]; ethers performs the ABI decode, so no ABI/registry is needed in the stub. Revert handling mirrorsstaticCallWithRevertData: detect a revert viaresult.code || result.messageand throw aCALL_EXCEPTIONcarrying the revert bytes, sorevertedWith/revertedWithCustomErrordecode the error instead of ethers mis-decoding the 4-byte selector as return data.2.
primeGenesisonensureUp's "already reachable" branchWhen an external/parallel runner spawns its own TRE and points the plugin at it via
TRE_URL,ensureUptakes 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 blocknumber, so the firstCreateSmartContractdeploy crashes ingetCurrentRefBlockParams("Cannot read properties of undefined"). Fix: callprimeGenesison 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— addstubProvider.call(tx)(+44)src/tre/lifecycle.js—primeGenesison the reachable branch (+7)