Skip to content

fix(rpc): register mint precompile for trace replay - #432

Open
nekomoto911 wants to merge 3 commits into
Galxe:mainfrom
nekomoto911:fix/mint-precompile-rpc-register
Open

fix(rpc): register mint precompile for trace replay#432
nekomoto911 wants to merge 3 commits into
Galxe:mainfrom
nekomoto911:fix/mint-precompile-rpc-register

Conversation

@nekomoto911

@nekomoto911 nekomoto911 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #372

Aligns RPC register_custom_precompiles with pipe's two precompile sets so debug_trace* / trace_* / eth_call replay matches canonical execution:

Set Pipe RPC (for_system_tx)
system (SYSTEM_CALLER) BLS + mint true → BLS + mint
user pre-Alpha BLS false → BLS
user post-Alpha BLS + randomness false + Alpha → BLS + randomness

Also:

  • moves mint into gravity-precompiles (same hygiene as BLS/fix(rpc): register BLS pop-verify precompile unconditionally (split from #367) #370) and re-exports the address from pipe onchain_config
  • mirrors Alpha SYSTEM_CALLER balance zeroing on the activation block for RPC replay
  • rebuilds the EVM on SYSTEM_CALLER↔user even pre-Alpha so mint/randomness drop correctly at the boundary
  • wires gravity_system_tx_post_alpha_trace_test into CI; adds invariant 10 (pipe system_precompiles addr idents must appear in RPC call.rs)
  • injects a user EOA CALL to the mint address on SAMPLE_BLOCK and asserts canonical/RPC status (+ gas) parity (empty-account semantics — proves mint is not over-registered on the user path)
  • parity trace_* roots: shape-only; debug/callTracer carries gas≡receipt for successful system txs; roots use with_transaction_gas_used(tx_gas_used)

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).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread crates/rpc/rpc/src/eth/helpers/call.rs Outdated
Comment on lines +131 to +133
let mint_precompile = create_mint_token_precompile();
evm.precompiles_mut()
.apply_precompile(&NATIVE_MINT_PRECOMPILE_ADDR, move |_| Some(mint_precompile));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed — pushed in 413c5df.

  • register_custom_precompiles now takes for_system_tx; mint is installed only when replaying a SYSTEM_CALLER tx (mirrors pipe system_precompiles vs custom_precompiles_for_ordered_block).
  • Block/replay loops rebuild on SYSTEM_CALLER↔user even pre-Alpha so mint drops on the user boundary.
  • post_alpha_trace now asserts canonical/RPC status (+ gas) parity for the injected user mint CALL (empty-account semantics), not unauthorized halt.
  • Clippy doc_markdown on mint_token fixed (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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 {

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.

P1 Badge 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 Lchangliang 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. 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.

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.

fix(rpc): mint precompile RPC registration gap + post-Alpha trace test design gap (same class as BLS §3.5.0)

2 participants