Skip to content

Comments

Sovereign SDK Changes + Lookup Refactor#2

Open
guillevalin wants to merge 16 commits intomainfrom
guillevalin/test-lookup-refactor
Open

Sovereign SDK Changes + Lookup Refactor#2
guillevalin wants to merge 16 commits intomainfrom
guillevalin/test-lookup-refactor

Conversation

@guillevalin
Copy link

No description provided.

- Added `serde::Serialize` and `serde::Deserialize` derives to various structs including `Commitment`, `ShoutAddrPreProof`, and `BatchedTimeProof` for improved serialization capabilities.
- Introduced `serde_helpers` module with custom serialization functions for handling non-trivially-serializable fields, specifically for `Vec<&'static [u8]>`.
- Implemented verification methods in `FoldingSession` to allow proof verification using externally supplied step instance bundles without executing the program.

This update enhances the flexibility and usability of proof serialization across the codebase.
- Introduced Poseidon2 compute and read ECALLs for hashing Goldilocks field elements.
- Implemented guest-side API for computing Poseidon2 hashes, allowing for efficient input handling and digest retrieval.
- Enhanced RISC-V CPU to manage Poseidon2 ECALLs, including internal state for pending digest words.
- Updated CCS layout and constraints to accommodate new ECALLs and ensure proper integration with existing functionality.
- Introduced new timing fields in `ProveTimings` to track durations for VM trace collection and CPU witness building.
- Updated `ShardWitnessAux` to include wall-clock time for VM trace and CPU witness phases.
- Enhanced `R1csCpu` to log detailed timing for witness building, bus filling, matrix decomposition, and commitment processes.
- Added methods in `Session` for preloading CCS preprocessing with matrix digests to optimize performance during proving and verification.
- Updated proof retrieval in RISC-V tests to use `proof_bundle()` instead of `proof()`, ensuring consistency across test cases.
- Modified memory sidecar functions to utilize `rv32_trace_lookup_addr_group_for_table_shape` for address group lookups, enhancing shape awareness in shared-bus scenarios.
- Introduced new helper functions for checking memory ID instances and shout specifications in the context of RV32 trace, improving clarity and maintainability of the code.
Copy link

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

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: cca6616a27

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 652 to 656
let call_id = self.get_reg(10) as u32;
if call_id == POSEIDON2_ECALL_NUM {
self.handle_poseidon2_ecall(twist);
} else if call_id == POSEIDON2_READ_ECALL_NUM {
self.handle_poseidon2_read_ecall();

Choose a reason for hiding this comment

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

P1 Badge Handle Poseidon2 ECALL in the decoded SYSTEM path

This branch is unreachable for normal ROM bytecode execution because decode_instruction maps 0x00000073 to RiscvInstruction::Halt, not RiscvInstruction::Ecall, so programs produced from bytes never hit this Poseidon2 logic and simply halt on ECALL. In practice that means the new Poseidon2 precompile is not invoked in the default decode_program flow (including guest ecall emitted by the SDK).

Useful? React with 👍 / 👎.

Comment on lines 1502 to 1506
self.session
.verify_with_external_steps_and_output_binding(&self.ccs, steps_public, proof, ob_cfg)
} else {
self.session
.verify_with_external_steps(&self.ccs, steps_public, proof)

Choose a reason for hiding this comment

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

P1 Badge Verify RV32 sidecar proofs in standalone verifier

Rv32B1Verifier::verify only checks the main ShardProof, but RV32 proofs also require decode-plumbing/semantics/(optional) RV32M sidecar verification; Rv32B1Run::verify_bundle_inner explicitly calls verify_sidecars_inner before accepting a proof. This new verify-only API can therefore accept proof packages without enforcing sidecar constraints, creating a soundness gap for consumers that rely on build_verifier().

Useful? React with 👍 / 👎.

}

// Compute ECALL: host reads inputs via untraced loads and stores digest in CPU state.
poseidon2_ecall_compute(input.len() as u32, input_buf.as_ptr() as u32);

Choose a reason for hiding this comment

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

P2 Badge Preserve pointer width for Poseidon2 ECALL inputs

The function is compiled for both riscv32 and riscv64, but it truncates the input buffer pointer to u32 before placing it in a2; on riscv64, addresses above 4 GiB lose their high bits and the host will read the wrong memory region. This should use pointer-width (usize/u64) ABI handling or be limited to riscv32 targets.

Useful? React with 👍 / 👎.

guillevalin and others added 6 commits February 18, 2026 15:42
…l fields

- Added `ram_d` and `width_lookup_addr_d` fields to `Rv32TraceWiringRun` for improved trace handling.
- Introduced `Rv32TraceWiringVerifier` struct to facilitate proof verification without re-executing the program.
- Implemented methods for accessing RAM address width and width-lookup address bits during proving runs.
- Updated `build_verifier` method to utilize new sizing values for verification context construction.
- Added `pc_carry` field to `Rv32TraceLayout` and updated relevant functions to incorporate it.
- Modified control residual calculations to account for `pc_carry` in branch and jump operations.
- Updated trace width assertions in tests to reflect the addition of the new field.
- Adjusted various functions to ensure compatibility with the new `pc_carry` logic.
- Added support for Goldilocks field operations (addition, subtraction, multiplication, and reading results) via ECALLs in the RiscvCpu struct.
- Introduced new ECALL identifiers for Goldilocks operations in the mod.rs file.
- Updated the Goldilocks arithmetic implementation to utilize ECALLs on RISC-V targets, while maintaining software fallbacks for other architectures.
- Enhanced the handling of poseidon2 ECALLs to accommodate the new Goldilocks operations.
@guillevalin guillevalin changed the base branch from nico/lookup_refactor to main February 19, 2026 16:44
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