Fix TVM compile pipeline and align test suite#64
Closed
km631 wants to merge 2 commits into
Closed
Conversation
Compile / runtime - tron-batches batch 05: ERC721/ERC1155 -> TRC721/TRC1155 dirs. When the token tree was renamed, this batch was missed, so the NFT contracts and their $-wrappers never compiled — fixes all "$TRC721/$TRC1155 not found" failures. - hardhat-exposed: gated behind SKIP_EXPOSED, outDir -> contracts/exposed, target -> tron-when-network-tron, add `exposed:regen`; gitignore the generated tree (regenerated, not committed). - .npmrc install-links=true: the file: @openzeppelin/hardhat-tron dep is now COPIED (no nested node_modules) instead of symlinked, so the plugin shares the project's single chai instance. Fixes the suite-wide changeTokenBalance eth_getBlockByHash NPE (the plugin was registering TVM matchers on a second chai). - mocha timeout 600s (TVM deploys are slow), solc metadata (ipfs+literal), warnings default 'warn' (tron-solc `chain` builtin shadow), defaultNetwork tre, load dotenv; pin tronweb/mocha/solc/dotenv. Test helpers (TVM-aware, ported from spike) - account DEFAULT_BALANCE within Java-long bounds; governance sequential delegate(); txpool dual-mode batchInBlock (EVM path for anvil, TVM path via tre_blockTime/tre_mine); eip712-types UserOperation types; erc4337 helper. Skips for TVM/EVM divergences (match spike behaviour) - TrieProof (needs un-bridged anvil ethers + EVM trie roots) - Blockhash future-block (TVM BLOCKHASH returns non-zero for future blocks) - sanity check-snapshot (TVM block number is monotonic through revert) - TRC20Votes one-checkpoint-per-block (TRE can't stage N tx in one block; this test also fails in the spike) Un-skip 4 RelayedCall tests that were over-skipped — they pass on TVM. Also add scripts/mocha-file-timings-reporter.js (parallel bucket weighting) and scripts/compare-bytecode.js. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
luiz-lvj
reviewed
May 29, 2026
Comment on lines
+31
to
+38
| // TVM port: skipped. EVM's BLOCKHASH opcode returns 0 for the current and | ||
| // any future block; the TVM VM instead returns a non-zero hash for a | ||
| // future block number, so `$blockHash(latest + 10)` is non-zero on TRE. | ||
| // This is a VM-level divergence, not a contract bug — Blockhash.sol just | ||
| // passes the opcode result through, and the library's purpose is historical | ||
| // (past) block hashes, where `recent block` and `old block` above already | ||
| // verify correct behavior. The spike (source of truth) has no Blockhash | ||
| // test at all. |
Collaborator
There was a problem hiding this comment.
This is not correct. The TVM and EVM BLOCKHASH opcode work the same way, this is an issue on the runtime.
This was referenced May 29, 2026
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
Brings the test suite to green on TRE: fixes the compile pipeline so the
hardhat-exposed
$-wrappers actually build, fixes a duplicate-chaiinstancethat broke every balance-change assertion, and adapts a handful of tests/helpers
to TVM semantics.
Changes
Compile / runtime
tron-batches.config.cjs— batch 05 now scanscontracts/token/TRC721and
contracts/token/TRC1155(was the staleERC721/ERC1155paths left overfrom the token rename). Without this the NFT contracts and their
hardhat-exposed
$-wrappers never compiled, surfacing asArtifact for contract "$TRC721"/"$TRC1155" not foundacross the suite.hardhat.config.js— gatehardhat-exposedbehindSKIP_EXPOSED, move itsoutDirtocontracts/exposed, set the tron compilertargettotron-when-network-tron, raise the mocha timeout to 600s (TVM deploys areslow), pin solc
metadata, relaxwarnings.defaulttowarn(tron-solc treatschainas a builtin symbol), setdefaultNetwork: tre, and load.env..npmrc—install-links=trueso thefile:@openzeppelin/hardhat-trondependency is copied (no nested
node_modules) instead of symlinked. Thesymlinked copy resolved its own
chai, so the plugin registered its TVM-awarechangeTokenBalance/changeEtherBalancematchers on a different chaiinstance than the tests used — every balance-change assertion then fell through
to upstream's matcher and crashed with
eth_getBlockByHash -> java.lang.NullPointerException.package.json— addexposed:regen; pintronweb,mocha,solc,dotenv..gitignore— ignore the generatedcontracts/exposedtree and theparallel-test cache.
Test helpers (TVM-aware)
accountdefault balance kept within TVM'sLong.MAX_VALUEbound;governancedelegate()awaited sequentially (TRE is single-witness);txpoolbatchInBlockmade dual-mode — EVM path (evm_setAutomine) for theanvil-backed TrieProof test, TVM path (
tre_blockTime/tre_mine) otherwise;add UserOperation EIP-712 types and an
erc4337helper.Test treatment
Skip-and-document the cases that hit TVM/EVM divergences:
anvilnodeplus EVM trie roots (
transactionsRoot/eth_getProof); the global TVMbridge and TVM block shape make this unrunnable on TRE.
future block— TVM'sBLOCKHASHreturns a non-zero hash for afuture block number where the EVM returns zero.
check snapshot— asserts the block number rolls back throughrevert; TVM keeps the block number monotonic through
tre_revertby design.does not add more than one checkpoint in a block— TRE cannotreliably stage N transactions into a single block.
Re-enable 4
RelayedCalltests (automatic relayer deploymentandtarget success (with value), ×2 salts) that were over-skipped — they pass onTVM with the chai fix above.
Also add
scripts/mocha-file-timings-reporter.js(parallel-bucket weighting) andscripts/compare-bytecode.js.Out of scope
contracts/exposed/**wrappers are produced bynpm run exposed:regenand are gitignored, not committed.