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

chore(avm): make fixed tables use constant polys #7744

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion barretenberg/cpp/pil/avm/binary.pil
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include "fixed/byte_lookup.pil";

namespace binary(256);

pol commit clk;

// Selector for Binary Operation
Expand Down
16 changes: 7 additions & 9 deletions barretenberg/cpp/pil/avm/fixed/byte_lookup.pil
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
namespace byte_lookup(256);
// These columns are commited for now, but will be migrated to constant/fixed when
// we support more *exotic* code generation options
pol commit table_op_id; // identifies if operation is AND/OR/XOR
pol commit table_input_a; // column of all 8-bit numbers
pol commit table_input_b; // column of all 8-bit numbers
pol commit table_output; // output = a AND/OR/XOR b
pol constant table_op_id; // identifies if operation is AND/OR/XOR
pol constant table_input_a; // column of all 8-bit numbers
pol constant table_input_b; // column of all 8-bit numbers
pol constant table_output; // output = a AND/OR/XOR b
// Selector to indicate when to utilise the lookup table
// TODO: Support for 1-sided lookups may make this redundant.
pol commit sel_bin;
pol constant sel_bin;

// These two columns are a mapping between instruction tags and their byte lengths
// {U8: 1, U16: 2, ... , U128: 16}
pol commit table_in_tags; // Column of U8,U16,...,U128
pol commit table_byte_lengths; // Columns of byte lengths 1,2,...,16;
pol constant table_in_tags; // Column of U8,U16,...,U128
pol constant table_byte_lengths; // Columns of byte lengths 1,2,...,16;
13 changes: 3 additions & 10 deletions barretenberg/cpp/pil/avm/fixed/gas.pil
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
namespace gas(256);
// TODO: WILL BE FIXED - we should be able to have this be a fixed column / the lookup tables are fixed so require no selectors
// TODO: All the columns here will have to be constant (when supported by our powdr fork and proving system)
pol commit sel_gas_cost;
pol constant sel_gas_cost;

// TODO(ISSUE_NUMBER): Constrain variable gas costs
pol commit l2_gas_fixed_table;
pol commit da_gas_fixed_table;

// DUMMY RELATIONS to force creation of hpp.
sel_gas_cost - sel_gas_cost = 0;
l2_gas_fixed_table - l2_gas_fixed_table = 0;
da_gas_fixed_table - da_gas_fixed_table = 0;
pol constant l2_gas_fixed_table;
pol constant da_gas_fixed_table;
5 changes: 1 addition & 4 deletions barretenberg/cpp/pil/avm/fixed/powers.pil
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
// power_of_2 = 1 << clk;
namespace powers(256);
// clk will be the implicit power.
pol commit power_of_2;

// DUMMY RELATION to force creation of hpp.
power_of_2 - power_of_2 = 0;
pol constant power_of_2;
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
}

for (size_t i = 0; i < rows.size(); i++) {
polys.byte_lookup_sel_bin[i] = rows[i].byte_lookup_sel_bin;
polys.byte_lookup_table_byte_lengths[i] = rows[i].byte_lookup_table_byte_lengths;
polys.byte_lookup_table_in_tags[i] = rows[i].byte_lookup_table_in_tags;
polys.byte_lookup_table_input_a[i] = rows[i].byte_lookup_table_input_a;
polys.byte_lookup_table_input_b[i] = rows[i].byte_lookup_table_input_b;
polys.byte_lookup_table_op_id[i] = rows[i].byte_lookup_table_op_id;
polys.byte_lookup_table_output[i] = rows[i].byte_lookup_table_output;
polys.gas_da_gas_fixed_table[i] = rows[i].gas_da_gas_fixed_table;
polys.gas_l2_gas_fixed_table[i] = rows[i].gas_l2_gas_fixed_table;
polys.gas_sel_gas_cost[i] = rows[i].gas_sel_gas_cost;
polys.main_clk[i] = rows[i].main_clk;
polys.main_sel_first[i] = rows[i].main_sel_first;
polys.main_zeroes[i] = rows[i].main_zeroes;
polys.powers_power_of_2[i] = rows[i].powers_power_of_2;
polys.kernel_kernel_inputs[i] = rows[i].kernel_kernel_inputs;
polys.kernel_kernel_value_out[i] = rows[i].kernel_kernel_value_out;
polys.kernel_kernel_side_effect_out[i] = rows[i].kernel_kernel_side_effect_out;
Expand Down Expand Up @@ -129,21 +140,11 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
polys.binary_op_id[i] = rows[i].binary_op_id;
polys.binary_sel_bin[i] = rows[i].binary_sel_bin;
polys.binary_start[i] = rows[i].binary_start;
polys.byte_lookup_sel_bin[i] = rows[i].byte_lookup_sel_bin;
polys.byte_lookup_table_byte_lengths[i] = rows[i].byte_lookup_table_byte_lengths;
polys.byte_lookup_table_in_tags[i] = rows[i].byte_lookup_table_in_tags;
polys.byte_lookup_table_input_a[i] = rows[i].byte_lookup_table_input_a;
polys.byte_lookup_table_input_b[i] = rows[i].byte_lookup_table_input_b;
polys.byte_lookup_table_op_id[i] = rows[i].byte_lookup_table_op_id;
polys.byte_lookup_table_output[i] = rows[i].byte_lookup_table_output;
polys.conversion_clk[i] = rows[i].conversion_clk;
polys.conversion_input[i] = rows[i].conversion_input;
polys.conversion_num_limbs[i] = rows[i].conversion_num_limbs;
polys.conversion_radix[i] = rows[i].conversion_radix;
polys.conversion_sel_to_radix_le[i] = rows[i].conversion_sel_to_radix_le;
polys.gas_da_gas_fixed_table[i] = rows[i].gas_da_gas_fixed_table;
polys.gas_l2_gas_fixed_table[i] = rows[i].gas_l2_gas_fixed_table;
polys.gas_sel_gas_cost[i] = rows[i].gas_sel_gas_cost;
polys.keccakf1600_clk[i] = rows[i].keccakf1600_clk;
polys.keccakf1600_input[i] = rows[i].keccakf1600_input;
polys.keccakf1600_output[i] = rows[i].keccakf1600_output;
Expand Down Expand Up @@ -602,7 +603,6 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
polys.poseidon2_mem_addr_write_d[i] = rows[i].poseidon2_mem_addr_write_d;
polys.poseidon2_output_addr[i] = rows[i].poseidon2_output_addr;
polys.poseidon2_sel_poseidon_perm[i] = rows[i].poseidon2_sel_poseidon_perm;
polys.powers_power_of_2[i] = rows[i].powers_power_of_2;
polys.sha256_clk[i] = rows[i].sha256_clk;
polys.sha256_input[i] = rows[i].sha256_input;
polys.sha256_output[i] = rows[i].sha256_output;
Expand Down
Loading
Loading