-
Notifications
You must be signed in to change notification settings - Fork 234
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
feat(avm): kernel output opcodes #6416
Conversation
… md/04-12-feat_example_caller_and_address_opcode
Benchmark resultsMetrics with a significant change:
Detailed resultsAll benchmarks are run on txs on the This benchmark source data is available in JSON format on S3 here. Proof generationEach column represents the number of threads used in proof generation.
L2 block published to L1Each column represents the number of txs on an L2 block published to L1.
L2 chain processingEach column represents the number of blocks on the L2 chain where each block has 16 txs.
Circuits statsStats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.
Stats on running time collected for app circuits
Tree insertion statsThe duration to insert a fixed batch of leaves into each tree type.
MiscellaneousTransaction sizes based on how many contract classes are registered in the tx.
Transaction size based on fee payment method | Metric | | |
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.
Good work! Please look at my feedback before merging.
|
||
// When we encounter a state writing opcode | ||
// We increment the side effect counter by 1 | ||
KERNEL_OUTPUT_SELECTORS * (avm_kernel.side_effect_counter' - (avm_kernel.side_effect_counter + 1)) = 0; |
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 this crucial to start at zero? (Probably, otherwise a malicious prover might choose a huge value and then you get overflow/wraparound. Not sure about what the kernel is expecting.)
If yes, then we should have a constraint to enforce the initial value to be zero. (maybe sthg like: first * avm_kernel.side_effect_counter =0 )
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.
Side effect counter will be required to be constrained to the value of the start_side_effect_counter in the public inputs - this can be done with a copy constraint or via a lookup
// OUTPUTS LOOKUPS | ||
// Constrain the value of kernel_out_sel to be the correct offset for the operation being performed | ||
#[NOTE_HASH_KERNEL_OUTPUT] | ||
sel_op_note_hash_exists * (avm_kernel.kernel_out_sel - (avm_kernel.START_NOTE_HASH_EXISTS_WRITE_OFFSET + avm_kernel.note_hash_exist_write_offset)) = 0; |
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.
avm_kernel.note_hash_exist_write_offset should be constrained to be initialized to zero. (maybe on first line?)
Same holds for all other offsets.
pol commit kernel_sel; | ||
pol commit kernel_out_sel; |
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.
The suffix "sel" makes us think it is a boolean. I think "offset" suffix might be better,
@@ -11,6 +11,17 @@ using Flavor = bb::AvmFlavor; | |||
using FF = Flavor::FF; | |||
using Row = bb::AvmFullRow<bb::fr>; | |||
|
|||
// There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects | |||
using VM_PUBLIC_INPUTS = std::tuple<std::array<FF, KERNEL_INPUTS_LENGTH>, // Input: Kernel context inputs |
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.
The current notation in bb for type alias is camel case. We might need to rename "using VmPublicInputs = ..." to be consistent.
return result; | ||
} | ||
|
||
void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, FF value, FF metadata) |
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.
value and metadata can be made "const &"
Overview
This pr implements:
Currently Not Implemented (TODO)
Negative tests have not been performed in this pr, and will be revisted - chore(avm): negative tests for kernel output opcodes #6468
Further kernel circuit changes will be required to fit this outputs format - chore(avm): refactor the public kernel public inputs to line up with the AVM outputs #6469
Start and end side effects counter must be constrained - feat(avm): constrain start and end side effects counter to line up #6471
The write offfsets for each opcode are not currently constrained to be within a certain range (e.g. max new nullifiers per tx) feat(avm): range constrain kernel output write_offsets to be less than MAX PER TX #6465
The write offsets are not constrained to start at 0 (boundary constraints) feat(avm): constrain start write offsets to be 0 #6467
PIILgen must be updated to create verifier checks for multiple public input columns - pr here feat: codegen for multiple public input columns powdr#61