-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace instruction table by lookup argument #171
Conversation
289e247
to
90978a2
Compare
90978a2
to
323ba14
Compare
126c196
to
4b7ab0d
Compare
4b7ab0d
to
d8eb58a
Compare
fn default() -> Self { | ||
impl AlgebraicExecutionTrace { | ||
pub fn new(program: Program) -> Self { | ||
let instruction_multiplicities = vec![0_u32; program.len()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I made .len()
on Program
, but in retrospect, this is ambiguous to me:
A program's length could either be the number of instructions, or the number of b-words.
It is actually the number of b-words here, but perhaps .len()
could be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have a method
/// The total number of instructions in the program. Double-word instructions are counted as one
/// instruction. See also `.len()`.
pub fn number_of_instructions(&self) -> usize {
self.clone().into_iter().count()
}
as addition to .len()
. I decided against that since it would not be used anywhere. I tried to clarify the behavior of .len()
by introducing the doc-string. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to have a function that never gets called.
I suppose what I'm suggesting is to rename .len()
into something unambiguous, like .len_bwords()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense and is in line with the naming scheme in triton-opcodes
. I'll refactor accordingly. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a context where we need the number of instructions without counting the arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm a little confused about what ambiguity this renaming is supposed to eliminate. What other thing could program length refer to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisely the one you were asking about. Method .len()
could return either
- the number of instructions in the program, or
- the number of base field elements used to encode the program.
The former interpretation is never used in Triton VM. However, that knowledge is highly domain specific – not even I was certain about that. In fact, I spent a non-negligible amount of time debugging and writing unnecessary code for this current PR because the method .len()
did not behave as I had expected it to, given both its name and code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fn default() -> Self { | ||
impl AlgebraicExecutionTrace { | ||
pub fn new(program: Program) -> Self { | ||
let instruction_multiplicities = vec![0_u32; program.len()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a context where we need the number of instructions without counting the arguments?
Co-authored-by: sshine <[email protected]>
A `VMState` records the condition “halting“ explicitly. Initialized as `false`, only executing instruction `halt` sets it to `true`. This allows de-duplication of logic in the virtual machine's methods `.run()` and `.simulate()` and correctly throws an error whenever the instruction pointer is out of bounds.
Co-authored-by: Alan <[email protected]>
43f16e0
to
576404b
Compare
- change instructions `read_mem` and `write_mem` (#179) (022245b) - `read_mem` now pushes to stack instead of overwriting - `write_mem` now pops the written element from stack - move to Tip5 hash function (#161) (#182) (d40f0b6) - this greatly boosts overall prover performance - replace Instruction Table by Lookup Argument (#171) (543327a) - rework U32 Table (#181) (09a4c27) - link to processor using Lookup Argument (2719030) - improve clock jump differences check (#177) (04bb5c4 and 9c2f3c0) - improve parsing of Triton assembly - remove old parser (bbe4aa8) - introduce `ParsedInstruction`, simplifying parsing (8602892) - fix bug in property test (9e4fcb7) - improve on constant folding in multicircuits (#183) (c1be5bb) - update to twenty-first v0.18 (#184) (ff972ff) - improve specification and documentation - explain the various cross-table arguments (567efc0) - more and better links (a66b20d and 9386878) - various simplifications and readability improvements
Replace the Instruction Table with a Lookup Argument, as described here. This decreases the total number of columns by 5, the total number of constraints by 9, and is expected to decrease the number of rows. The last property depends on the concrete program and its input. However, in the worst case, the number of rows remains unchanged.