fix(rpc): register mint precompile for trace replay - #432
Conversation
Closes Galxe#372 Move mint into gravity-precompiles and register it unconditionally in RPC register_custom_precompiles (same pattern as BLS/Galxe#370). Mirror Alpha SYSTEM_CALLER balance zeroing on the activation block for RPC replay, wire post_alpha_trace into CI, and pin mint dispatch via callTracer. Parity root gas now uses with_transaction_gas_used(tx_gas_used).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13d264a9c5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let mint_precompile = create_mint_token_precompile(); | ||
| evm.precompiles_mut() | ||
| .apply_precompile(&NATIVE_MINT_PRECOMPILE_ADDR, move |_| Some(mint_precompile)); |
There was a problem hiding this comment.
Align mint registration with canonical user execution
When a normal user transaction calls the otherwise-empty mint address, this unconditional RPC registration dispatches the mint handler and halts as unauthorized, while canonical user execution does not register mint: custom_precompiles_for_ordered_block in crates/pipe-exec-layer-ext-v2/execute/src/lib.rs includes only BLS and randomness before executor.execute(&block). Consequently debug_trace*, trace_*, eth_call, and gas estimation can disagree with the canonical receipt/state for exactly the user-call case added by this commit; either mint must also be available during canonical user execution or RPC registration must be limited to the system-transaction replay path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — this is a real mismatch.
The pipe registers mint only for transact_system_txn, while register_custom_precompiles is shared by every RPC execution. Registering mint unconditionally therefore changes normal user-call semantics: a direct EOA call is a successful empty-account call canonically, but RPC replay dispatches mint and halts as unauthorized.
The new test currently masks that mismatch by treating the RPC halt as proof of registration and not asserting the mint transaction canonical success against the trace result. I will change the implementation so mint is installed only when replaying a SYSTEM_CALLER transaction, unless we intentionally make mint available to canonical user execution as a separate consensus change, and update the test to assert canonical/RPC status parity for the injected user transaction.
There was a problem hiding this comment.
Agreed — pushed in 413c5df.
register_custom_precompilesnow takesfor_system_tx; mint is installed only when replaying aSYSTEM_CALLERtx (mirrors pipesystem_precompilesvscustom_precompiles_for_ordered_block).- Block/replay loops rebuild on SYSTEM_CALLER↔user even pre-Alpha so mint drops on the user boundary.
post_alpha_tracenow asserts canonical/RPC status (+ gas) parity for the injected user mint CALL (empty-account semantics), not unauthorized halt.- Clippy
doc_markdownonmint_tokenfixed (was the lint CI failure).
Address Galxe#432 review: pipe registers mint only in transact_system_txn, not custom_precompiles_for_ordered_block. RPC now takes for_system_tx and installs mint only for SYSTEM_CALLER txs; rebuild on system↔user even pre-Alpha so user paths stay empty-account. post_alpha_trace asserts canonical/RPC parity for the injected user mint CALL. Clippy doc_markdown backticks in mint_token.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 413c5df94a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let traces = ctx | ||
| .take_inspector() | ||
| .into_parity_builder() | ||
| .with_transaction_gas_used(gas_used) |
There was a problem hiding this comment.
Preserve call-frame gas in parity traces
Remove this transaction-level gas override from the parity trace builders. For any ordinary transaction, tx_gas_used() includes intrinsic transaction gas, whereas parity root result.gasUsed represents the inspected call frame; for example, a plain value transfer should report zero call-frame gas rather than the 21,000 receipt total. The same override was added to trace_transaction, trace_filter, and replay_block_transactions, so those APIs now return incompatible root gas values for all traced transactions. This also contradicts the revised integration-test contract, which explicitly says parity gas must not be bound to receipt gas.
Useful? React with 👍 / 👎.
| // `custom_precompiles_for_ordered_block`. Registering it for user txs would make | ||
| // a direct EOA CALL halt as unauthorized on RPC while canonical treats the mint | ||
| // address as an empty account. See #372 / PR review. | ||
| if for_system_tx { |
There was a problem hiding this comment.
Gate randomness out of the system-transaction set
for_system_tx currently gates only mint; execution then falls through and registers randomness for every post-Alpha EVM. This still does not mirror canonical execution: pipe system_precompiles contains only mint + BLS, while randomness is installed only by custom_precompiles_for_ordered_block for the user-transaction executor. A post-Alpha system transaction that reaches 0x…1625f5002 will therefore dispatch the randomness precompile during RPC replay but execute it as an ordinary address canonically, causing the same trace/gas/output divergence class as the mint bug. Please return after registering mint for for_system_tx, or explicitly gate randomness with !for_system_tx; if system transactions are intended to use randomness, add it to the canonical pipe set instead.
There was a problem hiding this comment.
Good catch — fixed in the follow-up commit: for_system_tx now returns after BLS+mint, so randomness stays on the user path only (custom_precompiles_for_ordered_block / !for_system_tx + Alpha).
Pipe system_precompiles is BLS+mint only; randomness belongs to the user executor. Return after mint when for_system_tx so post-Alpha system-tx RPC replay no longer installs randomness.
Lchangliang
left a comment
There was a problem hiding this comment.
LGTM. Re-reviewed at b367c9b: the RPC precompile sets now match canonical pipe execution for both SYSTEM_CALLER and user transactions, and the mint user-path parity regression is covered. The previously reported mint and randomness over-registration issues are resolved.
Closes #372
Aligns RPC
register_custom_precompileswith pipe's two precompile sets sodebug_trace*/trace_*/eth_callreplay matches canonical execution:for_system_tx)SYSTEM_CALLER)true→ BLS + mintfalse→ BLSfalse+ Alpha → BLS + randomnessAlso:
gravity-precompiles(same hygiene as BLS/fix(rpc): register BLS pop-verify precompile unconditionally (split from #367) #370) and re-exports the address from pipeonchain_configSYSTEM_CALLERbalance zeroing on the activation block for RPC replaygravity_system_tx_post_alpha_trace_testinto CI; adds invariant 10 (pipesystem_precompilesaddr idents must appear in RPCcall.rs)SAMPLE_BLOCKand asserts canonical/RPC status (+ gas) parity (empty-account semantics — proves mint is not over-registered on the user path)trace_*roots: shape-only; debug/callTracer carries gas≡receipt for successful system txs; roots usewith_transaction_gas_used(tx_gas_used)