Skip to content

Commit

Permalink
merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy committed Jul 3, 2024
1 parent 56c52f9 commit b26dd72
Show file tree
Hide file tree
Showing 69 changed files with 1,494 additions and 3,644 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,9 @@ jobs:
run: |
terraform init -input=false -backend-config="key=${{ env.DEPLOY_TAG }}/prover"
terraform apply -input=false -auto-approve
- name: Deploy Provers
working-directory: ./yarn-project/aztec/terraform/prover
run: |
terraform init -input=false -backend-config="key=devnet/prover"
terraform apply -input=false -auto-approve
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7b77bbfc19c51829814149e623257a3424d8e8c2
32029f91f6aae4d2f6b08b4ea40481f5837e50bc
2,131 changes: 212 additions & 1,919 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp

Large diffs are not rendered by default.

761 changes: 5 additions & 756 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp

Large diffs are not rendered by default.

534 changes: 3 additions & 531 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp

Large diffs are not rendered by default.

128 changes: 97 additions & 31 deletions bb-pilcom/bb-pil-backend/src/flavor_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub trait FlavorBuilder {
lookups: &[String],
fixed: &[String],
witness: &[String],
witness_without_inverses: &[String],
all_cols: &[String],
to_be_shifted: &[String],
shifted: &[String],
Expand All @@ -28,6 +29,7 @@ impl FlavorBuilder for BBFiles {
lookups: &[String],
fixed: &[String],
witness: &[String],
witness_without_inverses: &[String],
all_cols: &[String],
to_be_shifted: &[String],
shifted: &[String],
Expand All @@ -47,9 +49,9 @@ impl FlavorBuilder for BBFiles {

// Entities classes
let precomputed_entities = create_precomputed_entities(fixed);
let witness_entities = create_witness_entities(witness);
let all_entities =
create_all_entities(all_cols, to_be_shifted, shifted, all_cols_and_shifts);
let witness_entities =
create_witness_entities(witness_without_inverses, lookups, shifted, to_be_shifted);
let all_entities = create_all_entities();

let proving_and_verification_key =
create_proving_and_verification_key(name, lookups, to_be_shifted);
Expand Down Expand Up @@ -197,16 +199,12 @@ fn create_relation_definitions(
let comma_sep_lookups: Option<String> = create_lookups_tuple(lookups);

// We only include the grand product relations if we are given lookups
let mut grand_product_relations = String::new();
let mut all_relations = comma_sep_relations.to_string();
if let Some(lookups) = comma_sep_lookups {
all_relations = all_relations + &format!(", {lookups}");
grand_product_relations = format!("using GrandProductRelations = std::tuple<{lookups}>;");
}

format!("
{grand_product_relations}
using Relations = std::tuple<{all_relations}>;
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
Expand Down Expand Up @@ -286,52 +284,120 @@ fn create_precomputed_entities(fixed: &[String]) -> String {
)
}

fn create_witness_entities(witness: &[String]) -> String {
let pointer_view = create_flavor_members(witness);

let wires = return_ref_vector("get_wires", witness);
// Note(md): this is witnesses WITHOUT inverses or shifts
fn create_wire_entities(witness: &[String]) -> String {
let flavor_members = create_flavor_members(witness);

format!(
"
template <typename DataType>
class WitnessEntities {{
class WireEntities {{
public:
{flavor_members}
}};
"
)
}

{pointer_view}
// Note(md): this is witnesses and in future grand products
fn create_derived_witnesses(inverses: &[String]) -> String {
let flavor_members = create_flavor_members(inverses);

{wires}
format!(
"
template <typename DataType>
struct DerivedWitnessEntities {{
{flavor_members}
}};
"
)
}

/// Creates container of all witness entities and shifts
fn create_all_entities(
all_cols: &[String],
to_be_shifted: &[String],
fn create_shifted_entities(shifted: &[String]) -> String {
let flavor_members = create_flavor_members(shifted);

format!(
"
template <typename DataType>
class ShiftedEntities {{
public:
{flavor_members}
}};
"
)
}

fn create_to_be_shifted(to_be_shifted: &[String]) -> String {
let entities_transformation = |name: &String| format!("entities.{name},");
let entities_list = map_with_newline(to_be_shifted, entities_transformation);

format!(
"
template <typename DataType, typename PrecomputedAndWitnessEntitiesSuperset>
static auto get_to_be_shifted(PrecomputedAndWitnessEntitiesSuperset& entities) {{
return RefArray{{
{entities_list}
}};
}}
"
)
}

fn create_witness_entities(
witness: &[String],
inverses: &[String],
shifted: &[String],
all_cols_and_shifts: &[String],
to_be_shifted: &[String],
) -> String {
let all_entities_flavor_members = create_flavor_members(all_cols_and_shifts);

let wires = return_ref_vector("get_wires", all_cols_and_shifts);
let get_unshifted = return_ref_vector("get_unshifted", all_cols);
let get_to_be_shifted = return_ref_vector("get_to_be_shifted", to_be_shifted);
let get_shifted = return_ref_vector("get_shifted", shifted);
let wire_entities = create_wire_entities(witness);
let derived_witnesses = create_derived_witnesses(inverses);
let shifted_entities = create_shifted_entities(shifted);
let to_be_shifted = create_to_be_shifted(to_be_shifted);

format!(
"
{wire_entities}
{derived_witnesses}
{shifted_entities}
{to_be_shifted}
template <typename DataType>
class AllEntities {{
class WitnessEntities: public WireEntities<DataType>, public DerivedWitnessEntities<DataType> {{
public:
DEFINE_COMPOUND_GET_ALL(WireEntities<DataType>, DerivedWitnessEntities<DataType>)
auto get_wires() {{ return WireEntities<DataType>::get_all(); }};
}};
"
)
}

{all_entities_flavor_members}
/// Creates container of all witness entities and shifts
fn create_all_entities() -> String {
format!(
"
template <typename DataType>
class AllEntities: public PrecomputedEntities<DataType>,
public WitnessEntities<DataType>,
public ShiftedEntities<DataType> {{
public:
AllEntities()
: PrecomputedEntities<DataType>{{}}
, WitnessEntities<DataType>{{}}
, ShiftedEntities<DataType>{{}}
{{}}
DEFINE_COMPOUND_GET_ALL(PrecomputedEntities<DataType>, WitnessEntities<DataType>, ShiftedEntities<DataType>)
{wires}
{get_unshifted}
{get_to_be_shifted}
{get_shifted}
auto get_unshifted(){{
return concatenate(PrecomputedEntities<DataType>::get_all(), WitnessEntities<DataType>::get_all());
}}
auto get_to_be_shifted(){{ return AvmFlavor::get_to_be_shifted<DataType>(*this); }}
auto get_shifted() {{ return ShiftedEntities<DataType>::get_all(); }}
auto get_precomputed() {{ return PrecomputedEntities<DataType>::get_all(); }}
}};
"
)
Expand Down
31 changes: 9 additions & 22 deletions bb-pilcom/bb-pil-backend/src/prover_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ use crate::utils::{map_with_newline, snake_case};
pub trait ProverBuilder {
fn create_prover_hpp(&mut self, name: &str);

fn create_prover_cpp(
&mut self,
name: &str,
commitment_polys: &[String],
lookup_names: &[String],
);
fn create_prover_cpp(&mut self, name: &str, lookup_names: &[String]);
}

impl ProverBuilder for BBFiles {
Expand Down Expand Up @@ -83,15 +78,10 @@ impl ProverBuilder for BBFiles {
/// Create the prover cpp file
///
/// Committed polys are included as we manually unroll all commitments, as we do not commit to everything
fn create_prover_cpp(
&mut self,
name: &str,
commitment_polys: &[String],
lookup_names: &[String],
) {
fn create_prover_cpp(&mut self, name: &str, lookup_names: &[String]) {
let include_str = includes_cpp(&snake_case(name));

let polynomial_commitment_phase = create_commitments_phase(commitment_polys);
let polynomial_commitment_phase = create_commitments_phase();

let (call_log_derivative_phase, log_derivative_inverse_phase): (String, String) =
if lookup_names.is_empty() {
Expand Down Expand Up @@ -292,18 +282,15 @@ fn send_to_verifier_transform(name: &String) -> String {
format!("transcript->send_to_verifier(commitment_labels.{name}, witness_commitments.{name});")
}

fn create_commitments_phase(polys_to_commit_to: &[String]) -> String {
let all_commit_operations = map_with_newline(polys_to_commit_to, commitment_transform);
let send_to_verifier_operations =
map_with_newline(polys_to_commit_to, send_to_verifier_transform);

fn create_commitments_phase() -> String {
format!(
"
// Commit to all polynomials (apart from logderivative inverse polynomials, which are committed to in the later logderivative phase)
{all_commit_operations}
// Send all commitments to the verifier
{send_to_verifier_operations}
auto wire_polys = prover_polynomials.get_wires();
auto labels = commitment_labels.get_wires();
for (size_t idx = 0; idx < wire_polys.size(); ++idx) {{
transcript->send_to_verifier(labels[idx], commitment_key->commit(wire_polys[idx]));
}}
"
)
}
Expand Down
8 changes: 3 additions & 5 deletions bb-pilcom/bb-pil-backend/src/verifier_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub trait VerifierBuilder {
fn create_verifier_cpp(
&mut self,
name: &str,
witness: &[String],
inverses: &[String],
public_cols: &[(String, usize)],
);
Expand All @@ -19,7 +18,6 @@ impl VerifierBuilder for BBFiles {
fn create_verifier_cpp(
&mut self,
name: &str,
witness: &[String],
inverses: &[String],
public_cols: &[(String, usize)],
) {
Expand All @@ -30,8 +28,6 @@ impl VerifierBuilder for BBFiles {
"commitments.{n} = transcript->template receive_from_prover<Commitment>(commitment_labels.{n});"
)
};
let wire_commitments = map_with_newline(witness, wire_transformation);

let has_public_input_columns = !public_cols.is_empty();
let has_inverses = !inverses.is_empty();

Expand Down Expand Up @@ -151,7 +147,9 @@ impl VerifierBuilder for BBFiles {
}}
// Get commitments to VM wires
{wire_commitments}
for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) {{
comm = transcript->template receive_from_prover<Commitment>(label);
}}
{get_inverse_challenges}
Expand Down
10 changes: 3 additions & 7 deletions bb-pilcom/bb-pil-backend/src/vm_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn analyzed_to_cpp<F: FieldElement>(
&inverses,
&fixed,
&witness,
&witnesses_without_inverses,
&all_cols,
&to_be_shifted,
&shifted,
Expand All @@ -147,16 +148,11 @@ pub fn analyzed_to_cpp<F: FieldElement>(
bb_files.create_composer_hpp(file_name);

// ----------------------- Create the Verifier files -----------------------
bb_files.create_verifier_cpp(
file_name,
&witnesses_without_inverses,
&inverses,
&public_inputs,
);
bb_files.create_verifier_cpp(file_name, &inverses, &public_inputs);
bb_files.create_verifier_hpp(file_name, &public_inputs);

// ----------------------- Create the Prover files -----------------------
bb_files.create_prover_cpp(file_name, &witnesses_without_inverses, &inverses);
bb_files.create_prover_cpp(file_name, &inverses);
bb_files.create_prover_hpp(file_name);
}

Expand Down
2 changes: 1 addition & 1 deletion noir/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ bench-publish-acir-bb:
RUN mkdir -p ./log
RUN docker run -v "$(pwd)/log":/log -e LOG_FILE=/log/bench-acir.jsonl --rm aztecprotocol/barretenberg-acir-benches:$AZTEC_DOCKER_TAG ./bench_acir_tests.sh

DO ../+UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH
DO ../+UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH
7 changes: 7 additions & 0 deletions noir/noir-repo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions noir/noir-repo/compiler/noirc_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ regex = "1.9.1"
cfg-if = "1.0.0"
tracing.workspace = true
petgraph = "0.6"
rangemap = "1.4.0"
lalrpop-util = { version = "0.20.2", features = ["lexer"] }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<'context> Elaborator<'context> {
trait_id: trait_id.trait_id,
trait_generics: Vec::new(),
};
self.trait_constraints.push((constraint, expr_id));
self.push_trait_constraint(constraint, expr_id);
self.type_check_operator_method(expr_id, trait_id, &lhs_type, span);
}
typ
Expand Down Expand Up @@ -663,7 +663,14 @@ impl<'context> Elaborator<'context> {
}

fn elaborate_comptime_block(&mut self, block: BlockExpression, span: Span) -> (ExprId, Type) {
// We have to push a new FunctionContext so that we can resolve any constraints
// in this comptime block early before the function as a whole finishes elaborating.
// Otherwise the interpreter below may find expressions for which the underlying trait
// call is not yet solved for.
self.function_context.push(Default::default());
let (block, _typ) = self.elaborate_block_expression(block);
self.check_and_pop_function_context();

let mut interpreter =
Interpreter::new(self.interner, &mut self.comptime_scopes, self.crate_id);
let value = interpreter.evaluate_block(block);
Expand Down
Loading

0 comments on commit b26dd72

Please sign in to comment.