Skip to content

docs: clarify precompile table and limit hot-path comments#320

Open
mark0-cn wants to merge 1 commit into
megaeth-labs:mainfrom
mark0-cn:mark0/docs/clarify-precompile-limit-comments
Open

docs: clarify precompile table and limit hot-path comments#320
mark0-cn wants to merge 1 commit into
megaeth-labs:mainfrom
mark0-cn:mark0/docs/clarify-precompile-limit-comments

Conversation

@mark0-cn

Copy link
Copy Markdown

Summary

Documentation/comment-only cleanup of three spots in the precompile provider and the EVM hot path.
No behavior change: no spec semantics, gas accounting, or control flow is touched.

Changes

  • MegaPrecompiles::precompiles() (evm/precompiles.rs): the doc claimed it "returns precompiles with custom gas cost overrides for MINI_REX spec" while the body just returned the inner table under a // For now note.
    Rewrote it to state accurately that the precompile gas-cost overrides (fixed-cost KZG point evaluation, Osaka ModExp schedule) are baked into the table by mini_rex() / rex(), while the per-spec compute-gas accounting and the REX5 forwarded-gas cap are applied separately in run().
  • AdditionalLimit::after_frame_init (limit/limit.rs): added a comment explaining why this site records the child frame's init growth without calling check_limit() itself.
    before_frame_run latches any exceed before the first metered opcode, so the deferral is sound under the fixed frame lifecycle order (per the Resource-Limit Check Protocol).
    This is the one frame-lifecycle hook that defers its latch, so the reasoning is now written down.
  • compute_gas_ext module (evm/instructions.rs): replaced the TODO: add more doc placeholder with a real module doc describing the per-opcode compute-gas wrappers and the default / @frame / SELFDESTRUCT variants.

Testing

  • cargo fmt --all --check: clean.
  • Doc/comment-only change with no compilation or runtime impact; existing tests are unaffected.

- precompiles(): document that the gas-cost overrides are baked into the
  table and the compute-gas accounting / REX5 forwarded-gas cap happen in
  run(), replacing the stale "for now" note.
- after_frame_init: explain why it defers its latch to before_frame_run,
  per the resource-limit check protocol.
- compute_gas_ext: replace "TODO: add more doc" with a real module doc.
@mark0-cn

Copy link
Copy Markdown
Author

@Troublor

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.

1 participant