feat: 2^32 memory address #2850
Open
GunaDD wants to merge 16 commits into
Open
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
52efe21 to
4c9cea5
Compare
e5623d6 to
50cec8e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
814c620 to
0e6d6a6
Compare
…eferral chip changes and fixing the gen_pointer test function to use 2^31 max_memory
…er of cells in the register AS since now we have a separate gen_distinct_register_pointers
90b629c to
395639e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
efee83a to
f338acf
Compare
Note: cells_used metrics omitted because CUDA tracegen does not expose unpadded trace heights. Commit: f338acf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: support 2^32 byte memory addresses
Raises the RV64 memory address space to the full 2^32 bytes. Since
RV64_MEMORY_ASstores u16 cells, that means cell pointers are now up to 31 bits wide
(
POINTER_MAX_BITS: 28 → 31).Why pointers become two limbs
A 31-bit pointer no longer fits safely in a single BabyBear field element, so every
pointer on the memory bus is now sent as two little-endian 16-bit limbs.
MemoryAddress.pointerbecomespointer_limbs: [T; 2], and the bus payload is[address_space, ptr_lo, ptr_hi, data..., timestamp].Main changes
MemoryAddress, memory bus, and offline checker switched totwo-limb pointers. The persistent boundary AIR decomposes the merkle leaf label
into range-checked limbs so the leaf pointer can be emitted without composing the
full 31-bit value.
extensions/riscv/circuit/src/adapters/mod.rs):shared AIR + tracegen helpers that convert RV64 byte pointers (read from
registers) into cell-pointer limbs using a carry witness plus range checks, and
add per-block offsets with carries. Register-AS pointers always fit in the low
limb, so register accesses skip the extra columns and range checks.
pointer into a single field element; each now carries new witness columns and
uses the shared helpers instead:
hintstore, vec_heap family, keccak256 xorin, sha2);
base + block_offsetaddition inchips that do multi-block accesses (vec_heap family, keccak256, sha2);
limb is constant zero and needs no carry or range check.
(column/record layouts kept identical).
gen_pointernow draws from the full 2^31 cell range. Thisalso resolves jpw's TODO in the test config: tests used to call the general
gen_pointeron the register address space, which forced the testMemoryConfigto artificially widen the register AS. Tests now use the new
gen_register_pointer/gen_distinct_register_pointers, which draw from thereal 32-slot register file (the distinct variant avoids collisions when a test
writes several register operands), so the register-AS resizing workaround is
removed.
extensions/sha2/circuit/src/sha2_chips/config.rs):the incremental hasher cast the record's state byte slice in place to
&mut [u64; 8]. The state lives inside the trace-generation record buffer, whichis only guaranteed 4-byte alignment (
align_of::<Sha2RecordHeader>() = 4, sincethe header is all u32 fields), while
[u64; 8]requires 8-byte alignment — so thecast was undefined behavior on host memory. Fixed by copying through an aligned
local
[u64; 8]buffer instead of reinterpreting in place.Closes INT-8080