Skip to content

fix(explorer): use known ABI for precompiles instead of external signature DBs#682

Open
decofe wants to merge 3 commits intomainfrom
omar/fix-precompile-abi-lookup
Open

fix(explorer): use known ABI for precompiles instead of external signature DBs#682
decofe wants to merge 3 commits intomainfrom
omar/fix-precompile-abi-lookup

Conversation

@decofe
Copy link
Member

@decofe decofe commented Mar 10, 2026

Summary

Short-circuits ABI resolution for known Tempo contracts (TIP-20 tokens, Fee Manager, Stablecoin DEX, etc.) so we never hit external signature databases (OpenChain, 4byte, Samczun) or whatsabi bytecode extraction for them.

Motivation

Investigated whether setPrice on the PathUSD address page was a false positive — it's not, it's a real function on a LayerZero oracle contract (0xca3bb...). But while auditing the code, found that we're making unnecessary external API calls for contracts where we already have the ABI locally.

Verified via Snowflake: every selector used on-chain against known Tempo precompiles currently resolves correctly in external DBs (no active false positives). But this is fragile — any new collision in external DBs would surface bogus names. This PR removes that dependency.

Changes

  1. autoloadAbi() returns the known ABI immediately from getContractAbi() for registered contracts, skipping whatsabi + network calls
  2. lookupSignature() checks a pre-computed selector map from all viem/tempo ABIs before hitting external databases
  3. TxDecodedCalldata always trusts autoloadAbi over external signature results (previously preferred external results if they had more inputs)

Testing

  • pnpm check:types — passes
  • pnpm check:biome — passes
  • Verified all on-chain selectors for PathUSD, AlphaUSD, BetaUSD, ThetaUSD, and FeeManager against OpenChain — no active false positives exist today
  • Verified the only OpenChain mismatch across all Tempo ABIs is a harmless formatting difference on accountKeychain.authorizeKey

Prompted by: omar

@github-actions
Copy link

github-actions bot commented Mar 10, 2026

Bundle Size Report

Metric Size Δ Change
Total 5.1 MB +280.3 KB (+5.7%)
Gzip 1.4 MB +139.7 KB (+10.5%)
Brotli 1.2 MB +116.5 KB (+10.1%)
Chunk changes (>1KB)
Chunk Change
assets/KeyManager.js (removed) -477.4 KB
assets/QueryBuilder.js (removed) -423.4 KB
assets/Intro.js (removed) -66.0 KB
assets/createSsrRpc.js (removed) -43.8 KB
assets/Hash.js (removed) -31.0 KB
assets/_layout.js -29.3 KB
assets/react.js -19.8 KB
assets/stringify.js (removed) -19.7 KB
assets/isAddressEqual.js -18.4 KB
assets/address.js -14.1 KB
assets/Address.js -13.1 KB
assets/base.js (removed) -12.8 KB
assets/token.server.js (removed) -9.8 KB
assets/tx.js -9.7 KB
assets/utils.js -7.6 KB
assets/validators.js (removed) -5.9 KB
assets/sha3.js (removed) -5.5 KB
assets/TxEventDescription.js -3.1 KB
assets/useWatchBlockNumber.js (removed) -2.1 KB
assets/tty.js (removed) -1.8 KB
...and 28 more

Compared against main branch (baseline from 2/4/2026, 5:13:51 PM)

@github-actions
Copy link

github-actions bot commented Mar 10, 2026

Cloudflare Deployments

App Environment Status Preview
explorer devnet [OK] Deployed View Preview
explorer mainnet [OK] Deployed View Preview
explorer testnet [OK] Deployed View Preview
fee-payer devnet [>>] Skipped No changes
fee-payer moderato [>>] Skipped No changes
fee-payer privy [>>] Skipped No changes
og - [>>] Skipped No changes
tokenlist - [>>] Skipped No changes

decofe and others added 3 commits March 11, 2026 00:44
…ature DBs

Skip whatsabi/OpenChain lookup for addresses with known ABIs (TIP-20 tokens,
system contracts). External signature databases return false positives like
"setPrice" for precompile selectors.

Co-authored-by: o-az <23618431+o-az@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019cd8d6-2eab-716f-8b32-d5f273bb7675
…ases

Two fixes:

1. lookupSignature() now checks a pre-computed selector map from all
   viem/tempo ABIs before hitting OpenChain/4byte/Samczun. Prevents
   false positives like "setPrice" for TIP-20 selectors.

2. TxDecodedCalldata no longer prefers external signature results over
   autoloadAbi results based on input count. When autoloadAbi returns
   a match (known ABI), it is always trusted.

Co-authored-by: o-az <23618431+o-az@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019cd8d6-2eab-716f-8b32-d5f273bb7675
@o-az o-az force-pushed the omar/fix-precompile-abi-lookup branch from fc25991 to ad8318d Compare March 11, 2026 07:45
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