Skip to content

Conversation

@OlivierBBB
Copy link
Collaborator

@OlivierBBB OlivierBBB commented Oct 24, 2025

Note

Implements MODEXP common rows (byte-size extraction, leading-word, pricing) with EIP‑7823 upper-bound checks, updates success flow to use normalized sizes, and refactors OOB lead/xbs logic.

  • Hub/Constraints — MODEXP common processing:
    • New rows in common/:
      • __01__call_data_size_analysis_row.lisp: OOB modexp-cds; exposes extract-{b,e,m}bs.
      • __02__bbs_extraction_row.lisp, __03__ebs_extraction_row.lisp, __04__mbs_extraction_row.lisp:
        • Set MISC/MMU flags; MMU right‑padded word extraction; OOB modexp-xbs.
        • Expose {b,e,m}bs-(hi|lo), within/out‑of‑bounds bits, and normalized sizes; compute max-mbs-bbs and all-byte-sizes-are-in-bounds.
      • __05__exponent_leading_word_extraction_and_analysis_row.lisp:
        • Coordinate EXP/MMU/OOB for leading word; MMU mload; OOB modexp-lead; expose cutoffs and modexp-full-log.
      • __06__pricing_row.lisp: OOB modexp-pricing; expose RAM success/return gas.
      • generalities.lisp: standard precondition; exclude hub-known failure.
      • justifying_hub_predictions.lisp: tie success and return gas to pricing outputs gated by bounds.
    • Constants: rename row offsets to *-extraction-and-analysis.
  • Hub/Success path (success.lisp):
    • Use normalized {b,e,m}bs across base/exponent/modulus extraction.
    • Replace fixed 512 with EIP_7823_MODEXP_UPPER_BYTE_SIZE_BOUND for result copy; adjust offsets and return-data sizes.
  • OOB:
    • modexp/lead.lisp: rename load-leadextract-leading-word; update justification accordingly.
    • modexp/xbs.lisp: refactor comparison helpers and prediction bits; adjust max(xbs,ybs) setting logic and bounds bits.

Written by Cursor Bugbot for commit 6bcb9fc. This will update automatically on new commits. Configure here.

@OlivierBBB OlivierBBB self-assigned this Oct 24, 2025
cursor[bot]

This comment was marked as outdated.


(defun (precompile-processing---MODEXP---call-EXP-to-analyze-leading-word) (shift misc/EXP_FLAG precompile-processing---MODEXP---misc-row-offset---leading-word-analysis))
(defun (precompile-processing---MODEXP---call-MMU-to-extract-leading-word) (shift misc/MMU_FLAG precompile-processing---MODEXP---misc-row-offset---leading-word-analysis))
(defun (precompile-processing---MODEXP---call-OOB-on-leading-word-row) (shift misc/MMU_FLAG precompile-processing---MODEXP---misc-row-offset---leading-word-analysis))
Copy link

Choose a reason for hiding this comment

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

Bug: OOB Flag Check Misplaced in Precompile Step

The function precompile-processing---MODEXP---call-OOB-on-leading-word-row incorrectly checks misc/MMU_FLAG instead of misc/OOB_FLAG. This is a copy-paste error from the line above. The function name indicates it should check if the OOB module is being called, and it's used in a constraint (line 37) that requires it to equal 1, meaning OOB should always be called on this row. However, it's actually checking the MMU flag, which will cause incorrect behavior when the MMU flag and OOB flag have different values.

Fix in Cursor Fix in Web

(:guard (* (assumption---fresh-new-stamp) (prc-modexp-xbs---standard-precondition)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(begin (or! (eq! 0 (prc-modexp-xbs---compute-max)) (eq! 1 (prc-modexp-xbs---compute-max)))
(eq! (prc-modexp-xbs---xbs-is-LEQ-the-MODEXP-upper-bound) 1)))
Copy link

Choose a reason for hiding this comment

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

Bug: Broken bounds check for MODEXP parameters

The constraint forces prc-modexp-xbs---xbs-is-LEQ-the-MODEXP-upper-bound to always equal 1, preventing the system from detecting out-of-bounds byte sizes. This makes xbs-out-of-bounds always 0 and breaks the bounds checking mechanism for MODEXP parameters, allowing invalid calls that exceed EIP_7823_MODEXP_UPPER_BYTE_SIZE_BOUND to pass validation.

Fix in Cursor Fix in Web

@OlivierBBB OlivierBBB merged commit 00e31bc into master Nov 7, 2025
8 checks passed
@OlivierBBB OlivierBBB deleted the EIP-7823-set-upper-bounds-for-MODEXP---HUB-side branch November 7, 2025 14:00
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