-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Witgen: Handle machine calls with side effects (#1388)
Cherry-picked ef6a72f from #1380. With this PR, we track whether a call to a machine led to some side effect (e.g. added a block). In that case, the processed identity should count has having led to some progress, even if no values were returned to the calling machine. An example would be writing values to memory, which does not return any values and hence does not change the state of the caller.
- Loading branch information
1 parent
cbc5dd1
commit a3087ea
Showing
9 changed files
with
118 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |