Skip to content
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: seperate pil files for sub machines #3454

Merged
merged 30 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
132ef00
feat: add jean avm mini
Maddiaa0 Nov 21, 2023
1bb0d5b
temp
Maddiaa0 Nov 17, 2023
39b6247
fix: update to new
Maddiaa0 Nov 21, 2023
32e0f18
fix: fib
Maddiaa0 Nov 21, 2023
0fbf74b
fix: merge fix
Maddiaa0 Nov 21, 2023
5320089
fix: lil clean
Maddiaa0 Nov 21, 2023
67249ed
clean
Maddiaa0 Nov 21, 2023
04565be
chore: move pil
Maddiaa0 Nov 21, 2023
f9498f8
merge fix
Maddiaa0 Nov 21, 2023
3abbffb
fix: add test - run in vm_tests
Maddiaa0 Nov 21, 2023
70df69c
min-avm - polish CALLDATACOPY and test
jeanmon Nov 22, 2023
e616223
avm-mini: refactoring of basic load/store memory operations
jeanmon Nov 22, 2023
2900ef7
Adapt avm-mini to latest powdr code generation (set_trace in
jeanmon Nov 23, 2023
92e2940
Adapt Fibonacci to latest powdr code generation (set_trace in
jeanmon Nov 23, 2023
636a344
mini-avm - implement return opcode with direct memory
jeanmon Nov 23, 2023
f3551ba
mini avm - refactor avmMini_trace.hpp into a proper class
jeanmon Nov 27, 2023
3c6148e
avm - mini: polishing and helper functions
jeanmon Nov 28, 2023
2218e47
Review feedback: sorting memTrace at the end
jeanmon Nov 28, 2023
3c63ce3
Addressing some review comments
jeanmon Nov 28, 2023
903b93e
Review comments - move non-generated files outside of generated folder
jeanmon Nov 28, 2023
707473a
chore: point acir tests at noir master branch (#3440)
TomAFrench Nov 28, 2023
5bd2fb9
chore(docs): Core concepts page in getting-started (#3401)
catmcgee Nov 28, 2023
9b7f47c
feat: persistent archiver store (#3410)
alexghr Nov 28, 2023
1541283
feat: added poseidon2 hash function to barretenberg/crypto (#3118)
zac-williamson Nov 28, 2023
22aceac
docs: Further updates to the gas and fees whitepaper (#3448)
PhilWindle Nov 28, 2023
5d066ab
feat: split relations for submachines
Maddiaa0 Nov 28, 2023
9447d89
Merge branch 'master' into md/new-codegen
Maddiaa0 Nov 28, 2023
1687902
feat: finalise double traces
Maddiaa0 Nov 28, 2023
ead3280
fix: variable length relations
Maddiaa0 Nov 30, 2023
c2a5c67
Merge branch 'master' into md/new-codegen
Maddiaa0 Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 3 additions & 44 deletions barretenberg/cpp/pil/avm/avm_mini.pil
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
constant %N = 256;

namespace avmMini(%N);
include "mem_trace.pil";

namespace avmMini(256);

//===== CONSTANT POLYNOMIALS ==================================================
pol constant clk(i) { i };
Expand Down Expand Up @@ -52,46 +53,4 @@ namespace avmMini(%N);
// Relation for addition over the finite field
subop * (ia + ib - ic) = 0;

// ========= Table MEM-TR =================
pol commit m_clk;
pol commit m_sub_clk;
pol commit m_addr;
pol commit m_val;
pol commit m_lastAccess; // Boolean (1 when this row is the last of a given address)
pol commit m_rw; // Enum: 0 (read), 1 (write)

// Type constraints
m_lastAccess * (1 - m_lastAccess) = 0;
m_rw * (1 - m_rw) = 0;

// m_lastAccess == 0 ==> m_addr' == m_addr
(1 - first) * (1 - m_lastAccess) * (m_addr' - m_addr) = 0;

// We need: m_lastAccess == 1 ==> m_addr' > m_addr
// The above implies: m_addr' == m_addr ==> m_lastAccess == 0
// This condition does not apply on the last row.
// clk + 1 used as an expression for positive integers
// TODO: Uncomment when lookups are supported
// (1 - first) * (1 - last) * m_lastAccess { (m_addr' - m_addr) } in clk + 1; // Gated inclusion check. Is it supported?

// TODO: following constraint
// m_addr' == m_addr && m_clk == m_clk' ==> m_sub_clk' - m_sub_clk > 0
// Can be enforced with (1 - first) * (1 - last) * (1 - m_lastAccess) { 6 * (m_clk' - m_clk) + m_sub_clk' - m_sub_clk } in clk + 1

// Alternatively to the above, one could require
// that m_addr' - m_addr is 0 or 1 (needs to add placeholders m_addr values):
// (m_addr' - m_addr) * (m_addr' - m_addr) - (m_addr' - m_addr) = 0;
// if m_addr' - m_addr is 0 or 1, the following is equiv. to m_lastAccess
// (m_addr' - m_addr)

// m_lastAccess == 0 && m_rw' == 0 ==> m_val == m_val'
// This condition does not apply on the last row.
// Note: in barretenberg, a shifted polynomial will be 0 on the last row (shift is not cyclic)
// Note2: in barretenberg, if a poynomial is shifted, its non-shifted equivalent must be 0 on the first row

(1 - first) * (1 - last) * (1 - m_lastAccess) * (1 - m_rw') * (m_val' - m_val) = 0;

// TODO: Constraint the first load from a given adress has value 0. (Consistency of memory initialization.)
// TODO: when introducing load/store as sub-operations, we will have to add consistency of intermediate
// register values ia, ib, ic

25 changes: 12 additions & 13 deletions barretenberg/cpp/pil/avm/avm_mini_opt.pil
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
constant %N = 256;
namespace memTrace(256);
col witness m_clk;
col witness m_sub_clk;
col witness m_addr;
col witness m_val;
col witness m_lastAccess;
col witness m_rw;
(memTrace.m_lastAccess * (1 - memTrace.m_lastAccess)) = 0;
(memTrace.m_rw * (1 - memTrace.m_rw)) = 0;
(((1 - avmMini.first) * (1 - memTrace.m_lastAccess)) * (memTrace.m_addr' - memTrace.m_addr)) = 0;
(((((1 - avmMini.first) * (1 - avmMini.last)) * (1 - memTrace.m_lastAccess)) * (1 - memTrace.m_rw')) * (memTrace.m_val' - memTrace.m_val)) = 0;
namespace avmMini(256);
col fixed clk(i) { i };
col fixed positive(i) { (i + 1) };
col fixed first = [1] + [0]*;
col witness subop;
col witness ia;
Expand All @@ -24,14 +33,4 @@ namespace avmMini(256);
(avmMini.rwa * (1 - avmMini.rwa)) = 0;
(avmMini.rwb * (1 - avmMini.rwb)) = 0;
(avmMini.rwc * (1 - avmMini.rwc)) = 0;
(avmMini.subop * ((avmMini.ia + avmMini.ib) - avmMini.ic)) = 0;
col witness m_clk;
col witness m_sub_clk;
col witness m_addr;
col witness m_val;
col witness m_lastAccess;
col witness m_rw;
(avmMini.m_lastAccess * (1 - avmMini.m_lastAccess)) = 0;
(avmMini.m_rw * (1 - avmMini.m_rw)) = 0;
(((1 - avmMini.first) * (1 - avmMini.m_lastAccess)) * (avmMini.m_addr' - avmMini.m_addr)) = 0;
(((((1 - avmMini.first) * (1 - avmMini.last)) * (1 - avmMini.m_lastAccess)) * (1 - avmMini.m_rw')) * (avmMini.m_val' - avmMini.m_val)) = 0;
(avmMini.subop * ((avmMini.ia + avmMini.ib) - avmMini.ic)) = 0;
47 changes: 47 additions & 0 deletions barretenberg/cpp/pil/avm/mem_trace.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@


include "avm_mini.pil";

namespace memTrace(256);
// ========= Table MEM-TR =================
pol commit m_clk;
pol commit m_sub_clk;
pol commit m_addr;
pol commit m_val;
pol commit m_lastAccess; // Boolean (1 when this row is the last of a given address)
pol commit m_rw; // Enum: 0 (read), 1 (write)

// Type constraints
m_lastAccess * (1 - m_lastAccess) = 0;
m_rw * (1 - m_rw) = 0;

// m_lastAccess == 0 ==> m_addr' == m_addr
(1 - avmMini.first) * (1 - m_lastAccess) * (m_addr' - m_addr) = 0;

// We need: m_lastAccess == 1 ==> m_addr' > m_addr
// The above implies: m_addr' == m_addr ==> m_lastAccess == 0
// This condition does not apply on the last row.
// clk + 1 used as an expression for positive integers
// TODO: Uncomment when lookups are supported
// (1 - first) * (1 - last) * m_lastAccess { (m_addr' - m_addr) } in clk + 1; // Gated inclusion check. Is it supported?

// TODO: following constraint
// m_addr' == m_addr && m_clk == m_clk' ==> m_sub_clk' - m_sub_clk > 0
// Can be enforced with (1 - first) * (1 - last) * (1 - m_lastAccess) { 6 * (m_clk' - m_clk) + m_sub_clk' - m_sub_clk } in clk + 1

// Alternatively to the above, one could require
// that m_addr' - m_addr is 0 or 1 (needs to add placeholders m_addr values):
// (m_addr' - m_addr) * (m_addr' - m_addr) - (m_addr' - m_addr) = 0;
// if m_addr' - m_addr is 0 or 1, the following is equiv. to m_lastAccess
// (m_addr' - m_addr)

// m_lastAccess == 0 && m_rw' == 0 ==> m_val == m_val'
// This condition does not apply on the last row.
// Note: in barretenberg, a shifted polynomial will be 0 on the last row (shift is not cyclic)
// Note2: in barretenberg, if a poynomial is shifted, its non-shifted equivalent must be 0 on the first row

(1 - avmMini.first) * (1 - avmMini.last) * (1 - m_lastAccess) * (1 - m_rw') * (m_val' - m_val) = 0;

// TODO: Constraint the first load from a given adress has value 0. (Consistency of memory initialization.)
// TODO: when introducing load/store as sub-operations, we will have to add consistency of intermediate
// register values ia, ib, ic
Loading