Skip to content

Conversation

@DavePearce
Copy link
Collaborator

@DavePearce DavePearce commented Nov 14, 2025

This puts in place an assembly implementation of the euc module, thereby replacing the original.


Note

Replace the EUC module with a zkasm implementation and update all related lookups to remove DONE/IOMF wiring and align targets/fields, plus Makefile update.

  • Core EUC:
    • Add euc/euc.zkasm implementing 64-bit Euclidean division with CEIL; enforces non-zero divisor and REMAINDER < DIVISOR.
    • Remove legacy euc/columns.lisp, euc/constraints.lisp, and euc/lookups/euc_into_wcp.lisp.
    • Update Makefile to set EUC := euc/euc.zkasm.
  • Lookups:
    • blockdata/*/lookups/blockdata_into_euc.lisp: target only euc.DIVIDEND, euc.DIVISOR, euc.QUOTIENT; drop euc.IOMF and constant source.
    • mmu/{london,osaka}/lookups/mmu_into_euc.lisp: map DIVIDEND/DIVISOR/QUOTIENT/REMAINDER/CEIL; remove euc.DONE.
    • mxp/cancun/lookups/mxp_into_euc.lisp: target DIVIDEND/DIVISOR/QUOTIENT/CEIL; remove euc.DONE.
    • txndata/*/lookups/txndata_into_euc.lisp: target DIVIDEND/DIVISOR/QUOTIENT (and REMAINDER where present); remove euc.DONE and constant source.

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

@DavePearce DavePearce linked an issue Nov 14, 2025 that may be closed by this pull request
This puts in place an assembly implementation of the euc module, thereby
replacing the original.
@DavePearce DavePearce force-pushed the 829-feat-add-euc-assembly-implementation branch from 5852023 to 3f64870 Compare November 14, 2025 00:59
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Incomplete Blockdata Causes Euclidean Division Failure

The lookup is missing euc.REMAINDER in the target columns. The new assembly implementation of euc requires REMAINDER as an input parameter (line 5 of euc/euc.zkasm), but blockdata only provides DIVIDEND, DIVISOR, and QUOTIENT. This causes the euclidean division verification to fail or use an undefined value for REMAINDER. The same issue affects blockdata/london and blockdata/paris lookups.

blockdata/cancun/lookups/blockdata_into_euc.lisp#L5-L10

;; target columns
(
euc.DIVIDEND
euc.DIVISOR
euc.QUOTIENT
)

Fix in Cursor Fix in Web


Bug: Missing Remainder Breaks Core Division Verification.

The lookup is missing euc.REMAINDER in the target columns. The new assembly implementation of euc requires REMAINDER as an input parameter, but mxp only provides DIVIDEND, DIVISOR, QUOTIENT, and CEIL. Without REMAINDER, the euclidean division verification in the assembly function cannot correctly validate that DIVIDEND = DIVISOR * QUOTIENT + REMAINDER.

mxp/cancun/lookups/mxp_into_euc.lisp#L8-L14

;; target columns
(
euc.DIVIDEND
euc.DIVISOR
euc.QUOTIENT
euc.CEIL
)

Fix in Cursor Fix in Web


Bug: Missing Input Blocks Core Calculation

The lookup is missing euc.REMAINDER in the target columns. The new assembly implementation of euc requires REMAINDER as an input parameter, but txndata/london only provides DIVIDEND, DIVISOR, and QUOTIENT. This prevents proper euclidean division verification. The same issue affects txndata/shanghai.

txndata/london/lookups/txndata_into_euc.lisp#L3-L8

; target columns
(
euc.DIVIDEND
euc.DIVISOR
euc.QUOTIENT
)

Fix in Cursor Fix in Web


Copy link
Collaborator

@letypequividelespoubelles letypequividelespoubelles left a comment

Choose a reason for hiding this comment

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

LGTM

if val_hi != 0 goto exit_f
if val_lo != DIVIDEND goto exit_f
;; assert remainder < divisor
b, tmp = DIVISOR - REMAINDER - 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

will it be better to call WCP when wcp will be asm ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it will not. Its more expensive in terms of columns to do that.

if b == 1 goto exit_f
;; Compute ceiling
if REMAINDER == 0 goto exit_0
c, CEIL = QUOTIENT + 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need a carry here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically yes. You have a u64 with +1 gives u65 which does not go into a u64. However, we know the true value of QUOTIENT is smaller and, hence, the carry will never be 1. But, the tool cannot figure this out. Potentially I could add a cast feature, but not today ;)

@DavePearce DavePearce merged commit 7f8b4e9 into master Nov 14, 2025
8 checks passed
@DavePearce DavePearce deleted the 829-feat-add-euc-assembly-implementation branch November 14, 2025 04: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.

feat: add EUC assembly implementation

3 participants