Skip to content

Allow Reading from Hint Space for MULTI_OBSERVE#41

Open
darth-cy wants to merge 2 commits intofeat/hint_bridgefrom
feat/hint_multi_observe
Open

Allow Reading from Hint Space for MULTI_OBSERVE#41
darth-cy wants to merge 2 commits intofeat/hint_bridgefrom
feat/hint_multi_observe

Conversation

@darth-cy
Copy link

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the MULTI_OBSERVE Poseidon2 instruction to optionally read input data from hint space instead of memory. Previously, MULTI_OBSERVE always read input elements from a memory array pointer. Now, a context array is used to pass parameters (init_pos, len, is_hint, reserved), and when is_hint=1, data is read from hint space via the hint bus instead of memory.

Changes:

  • Replaced separate init_pos and len register parameters with a context array (ctx_ptr) and added a hint_id register parameter across the entire instruction pipeline (compiler IR, ASM, conversion, execution, AIR, columns).
  • Added conditional hint space lookup in the AIR constraints and trace generation: in hint mode, memory reads are skipped and hint bus lookups are used instead, with adjusted timestamp increments (1 per element instead of 2).
  • Wired HintSpaceProviderChip into NativePoseidon2Filler to register hint bus interactions during trace filling.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
extensions/native/recursion/src/challenger/duplex.rs Pass None for new hint_id parameter
extensions/native/compiler/src/ir/poseidon.rs Allocate context array, pack params, read back result
extensions/native/compiler/src/ir/instructions.rs Update Poseidon2MultiObserve variant to use ctx_ptr and hint_id
extensions/native/compiler/src/conversion/mod.rs Update instruction field mapping for conversion
extensions/native/compiler/src/asm/instruction.rs Update ASM instruction docs and display
extensions/native/compiler/src/asm/compiler.rs Update DslIr→AsmInstruction mapping
extensions/native/circuit/src/poseidon2/execution.rs Read ctx array and hint data in execution path
extensions/native/circuit/src/poseidon2/columns.rs Add ctx array, read_ctx, register columns; remove old fields
extensions/native/circuit/src/poseidon2/chip.rs Add hint_space_provider, conditional hint reads in trace gen
extensions/native/circuit/src/poseidon2/air.rs Add hint bus lookups, conditional memory reads, timestamp adjustments
extensions/native/circuit/src/extension/mod.rs Reorder chip creation to pass hint_space_provider to poseidon2
extensions/native/circuit/cuda/src/poseidon2.cu Update CUDA trace fill for hint mode timestamps and reads

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +384 to +403
// is_hint = ctx[2]
uint32_t is_hint =
specific[COL_INDEX(MultiObserveCols, ctx[2])].asUInt32();
uint32_t ts_per_element = 2 - is_hint;
for (uint32_t j = chunk_start; j < chunk_end; ++j) {
if (!is_hint) {
// Non-hint mode: fill read_data aux
mem_fill_base(
mem_helper,
start_timestamp,
specific.slice_from(COL_INDEX(MultiObserveCols, read_data[j].base))
);
}
// Write timestamp: start_timestamp + (1 - is_hint) for non-hint, start_timestamp for hint
mem_fill_base(
mem_helper,
start_timestamp,
specific.slice_from(COL_INDEX(MultiObserveCols, read_data[j].base))
);
mem_fill_base(
mem_helper,
start_timestamp + 1,
start_timestamp + (1 - is_hint),
specific.slice_from(COL_INDEX(MultiObserveCols, write_data[j].base))
);
start_timestamp += 2;
start_timestamp += ts_per_element;
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