Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bfan05
Copy link
Contributor

@bfan05 bfan05 commented Jul 2, 2024

@bfan05 bfan05 requested a review from zlangley July 2, 2024 16:49
@linear
Copy link

linear bot commented Jul 2, 2024

INT-1696 Implement hint opcodes

We need to support the instructions AsmInstruction::Hint and AsmInstruction::HintLen when we convert from AsmInstruction to Instruction.

This involves adding a new opcodes Hint and HintLen. The VirtualMachine should take as input some input encoding, such as Vec<Vec<[F; 4]>>, where each element is the serialization of an input element. (SP1 calls this the witness_stream.) Then the opcodes do the following:

  • hint a: Pop the front element next_input off of witness_stream and write all the elements of next_input consecutively starting at [a]_d (i.e., set up vm state so that this happens in trace generation).
  • hint_len a: Peek the front element next_input of witness_stream and write the length of this element to [a]_d.

Copy link
Contributor

@zlangley zlangley left a comment

Choose a reason for hiding this comment

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

Modify the test_io test to compile and run its program and make sure it passes.

@jonathanpwang jonathanpwang marked this pull request as draft July 9, 2024 04:02
@bfan05 bfan05 marked this pull request as ready for review July 9, 2024 15:30
Copy link
Contributor

@zlangley zlangley left a comment

Choose a reason for hiding this comment

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

Is this generating trace rows to write the hints into the memory trace?

@bfan05
Copy link
Contributor Author

bfan05 commented Jul 9, 2024

Is this generating trace rows to write the hints into the memory trace?

@zlangley no, since the accesses are not being pushed to the accesses array, which is the thing used to generate trace rows

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

For safety, I think all HINTs should be at timestamp 0. If the HINT opcode does not even show up in the program code (so it is ignored by the CpuChip), then it is unsound to allow arbitrary HINTs at any timestamp: that would mean there's no way to tell if memory is properly constrained (how would you know the difference between a program where I inserted a bunch of random hints into memory trace in between every read vs. a normal program?). The fact that tests pass with this current implementation means there's definitely something fishy related to INT-1708.

Separately, the AsmInstruction::Hint needs to be able to allow e = 1 or 2 for compiler purposes. @TlatoaniHJ can you confirm and also see if there's a suggested fix?

Copy link
Contributor

@zlangley zlangley left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

LGTM

@bfan05 bfan05 merged commit 5609fa1 into main Jul 10, 2024
@bfan05 bfan05 deleted the feat/vm-hint branch July 10, 2024 20:50
luffykai pushed a commit that referenced this pull request Dec 13, 2024
* feat: hint opcode implementation

* wip

* wip

* wip

* wip

* wip

* feat: hint

* chore: add comment for to_field change

* chore: use CPU_MAX_ACCESSES_PER_CYCLE

* chore: add max_access_per_instruction for HINT

* chore: address comments

* wip

* feat: integration test for hint

* chore: address comments

* chore: add HINT to Core instruction list

* Modify hint instruction to write length + contents together

* Remove AsmInstruction::HintLen

* add comment for or

* format

* chore: fix lints

* chore: fix test_vm_hint

* chore: uncomment felts

---------

Co-authored-by: Zach Langley <[email protected]>
jonathanpwang pushed a commit that referenced this pull request Aug 14, 2025
* Cuda tracegen + tests for Rv32DivRem

* review comments
jonathanpwang pushed a commit that referenced this pull request Aug 14, 2025
* Cuda tracegen + tests for Rv32DivRem

* review comments
jonathanpwang pushed a commit that referenced this pull request Aug 19, 2025
* Cuda tracegen + tests for Rv32DivRem

* review comments
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.

5 participants