-
Notifications
You must be signed in to change notification settings - Fork 73
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
Witgen: Handle machine calls with side effects #1388
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// This tests whether side effects are counted as "progress" when processing identities. | ||
// The MemoryProxy writes values to memory. Processing the link to memory does not result | ||
// in any updates to the MemoryProxy witness, but it does have a side effect (adding an | ||
// entry to the memory machine). Because of this, processing the link should not be skipped. | ||
|
||
use std::machines::memory::Memory; | ||
|
||
machine MemoryProxy with | ||
latch: latch, | ||
operation_id: operation_id, | ||
call_selectors: sel, | ||
{ | ||
operation mstore<0> addr, step, value ->; | ||
|
||
col witness operation_id; | ||
col fixed latch = [1]*; | ||
|
||
Memory mem; | ||
|
||
col witness addr, step, value; | ||
|
||
col witness used; | ||
used = std::array::sum(sel); | ||
std::utils::force_bool(used); | ||
|
||
link used ~> mem.mstore addr, step, value ->; | ||
} | ||
|
||
machine Main with degree: 1024 { | ||
reg pc[@pc]; | ||
reg X[<=]; | ||
reg Y[<=]; | ||
reg Z[<=]; | ||
|
||
col fixed STEP(i) { i }; | ||
MemoryProxy mem; | ||
instr mstore X, Y -> ~ mem.mstore X, STEP, Y ->; | ||
|
||
function main { | ||
|
||
mstore 1, 1; | ||
mstore 2, 2; | ||
mstore 3, 3; | ||
mstore 4, 4; | ||
|
||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add some assertions so we know the memory proxy is working> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, not sure how to do this actually, because we don't have a shared memory yet (which requires #1356) ^^ So we can't access the memory from the main machine here. If witgen didn't insert the right memory accesses into the memory machine, the permutation would fail, which is tested by the current test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right |
||
} | ||
} |
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.
test_data/asm/book/operations_and_links.asm
fails, because there is a machine that calls the same sub-machine with multiple arguments. Because of #1385, this keeps adding new blocks. Not reporting the side effect makes this works, because then the identity is not processed again.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 it gonna be fixed here or later?
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.
Later, this requires fixing #1385, which is not the scope of this PR. The fix in this PR is disabled for block machines because of #1385, but IMO it makes sense to merge like this because it adds all the infrastructure to handle side effects, and it already works for other machines (crucially: memory).