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: Extract types to a types crate #3203

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 0 deletions yarn-project/noir-protocol-circuits/src/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"crates/types",
"crates/private-kernel-lib",
"crates/private-kernel-init",
"crates/private-kernel-init-simulated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{ PrivateKernelInputsInit, KernelCircuitPublicInputs };
use dep::private_kernel_lib::PrivateKernelInputsInit;
use dep::types::KernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInputsInit) -> distinct pub KernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{ PrivateKernelInputsInit, KernelCircuitPublicInputs };
use dep::private_kernel_lib::PrivateKernelInputsInit;
use dep::types::KernelCircuitPublicInputs;

fn main(input: PrivateKernelInputsInit) -> distinct pub KernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
aztec = { path = "../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{PrivateKernelInputsInner, KernelCircuitPublicInputs};
use dep::private_kernel_lib::PrivateKernelInputsInner;
use dep::types::KernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInputsInner) -> distinct pub KernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
aztec = { path="../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{PrivateKernelInputsInner, KernelCircuitPublicInputs};
use dep::private_kernel_lib::PrivateKernelInputsInner;
use dep::types::KernelCircuitPublicInputs;

fn main(input: PrivateKernelInputsInner) -> distinct pub KernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ authors = [""]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { path="../../../../aztec-nr/aztec" }
aztec = { path = "../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use crate::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs;
use crate::abis::kernel_circuit_public_inputs::KernelCircuitPublicInputsBuilder;
use crate::utils::arrays;
use crate::abis::previous_kernel_data::PreviousKernelData;
use crate::abis::private_kernel::private_call_data::PrivateCallData;
use crate::abis::combined_accumulated_data::{CombinedAccumulatedData, CombinedAccumulatedDataBuilder};
use crate::abis::private_kernel::private_call_data::ReadRequestMembershipWitnessPrivateData;
use crate::hash::{read_request_root_from_siblings, function_tree_root_from_siblings, contract_tree_root_from_siblings, silo_commitment, silo_nullifier,stdlib_recursion_verification_key_compress_native_vk, compute_new_contract_address_hash, compute_l2_to_l1_hash,compute_constructor_hash, compute_logs_hash};
use crate::address::{EthAddress, Address};
use crate::abis::function_data::FunctionData;
use crate::contrakt::deployment_data::ContractDeploymentData;
use crate::point::Point;
use crate::abis::new_contract_data::NewContractData;
use crate::abis::complete_address::CompleteAddress;
use crate::utils::bounded_vec::BoundedVec;
use dep::types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs;
use dep::types::abis::kernel_circuit_public_inputs::KernelCircuitPublicInputsBuilder;
use dep::types::utils::arrays;
use dep::types::abis::previous_kernel_data::PreviousKernelData;
use dep::types::abis::private_kernel::private_call_data::PrivateCallData;
use dep::types::abis::combined_accumulated_data::{CombinedAccumulatedData, CombinedAccumulatedDataBuilder};
use dep::types::abis::private_kernel::private_call_data::ReadRequestMembershipWitnessPrivateData;
use dep::types::hash::{read_request_root_from_siblings, function_tree_root_from_siblings, contract_tree_root_from_siblings, silo_commitment, silo_nullifier,stdlib_recursion_verification_key_compress_native_vk, compute_new_contract_address_hash, compute_l2_to_l1_hash,compute_constructor_hash, compute_logs_hash};
use dep::types::address::{EthAddress, Address};
use dep::types::abis::function_data::FunctionData;
use dep::types::contrakt::deployment_data::ContractDeploymentData;
use dep::types::point::Point;
use dep::types::abis::new_contract_data::NewContractData;
use dep::types::abis::complete_address::CompleteAddress;
use dep::types::utils::bounded_vec::BoundedVec;

use dep::aztec::constants_gen::{
MAX_READ_REQUESTS_PER_CALL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
mod utils;
mod address;
mod point;
// This is intentionally spelled like this
// since contract is a reserved keyword, so it cannot
// be used as an ident.
mod contrakt;
mod transaction;
mod abis;
mod block;
// TODO: rename to be precise as to what its common to.
mod common;

mod mocked;
mod hash;

mod interop_testing;

mod private_kernel_init;
mod private_kernel_inner;
mod private_kernel_ordering;

mod tests;

use abis::kernel_circuit_public_inputs::{ KernelCircuitPublicInputs, KernelCircuitPublicInputsFinal };
use private_kernel_init::PrivateKernelInputsInit;
use private_kernel_inner::PrivateKernelInputsInner;
use private_kernel_ordering::PrivateKernelInputsOrdering;

// TODO: rename to be precise as to what its common to.
mod common;
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use dep::aztec::constants_gen;
use crate::common;
use crate::mocked::{Proof, AggregationObject,verify_previous_kernel_state};
use crate::transaction::request::TxRequest;
use crate::abis::{
use dep::types::mocked::{Proof, AggregationObject,verify_previous_kernel_state};
use dep::types::transaction::request::TxRequest;
use dep::types::abis::{
combined_constant_data::CombinedConstantData,
private_kernel::private_call_data::PrivateCallData,
kernel_circuit_public_inputs::{KernelCircuitPublicInputs, KernelCircuitPublicInputsBuilder}
};
use crate::utils::arrays;
use dep::types::utils::arrays;
use dep::std::unsafe;

// Initialization struct for private inputs to the private kernel
Expand Down Expand Up @@ -152,12 +152,12 @@ impl PrivateKernelInputsInit {

mod tests {
use crate::private_kernel_init::PrivateKernelInputsInit;
use crate::abis::{
use dep::types::abis::{
kernel_circuit_public_inputs::{KernelCircuitPublicInputs, KernelCircuitPublicInputsBuilder},
private_circuit_public_inputs::PrivateCircuitPublicInputs,
read_request_membership_witness::ReadRequestMembershipWitness,
};
use crate::tests::{
use dep::types::tests::{
testing_harness::{
create_private_call_data,
generate_read_requests,
Expand All @@ -176,9 +176,9 @@ mod tests {
ConstructorParams,
}
};
use crate::address::Address;
use crate::hash::{accumulate_sha256};
use crate::utils::uint128::U128;
use dep::types::address::Address;
use dep::types::hash::{accumulate_sha256};
use dep::types::utils::uint128::U128;
use dep::aztec::constants_gen::{
MAX_READ_REQUESTS_PER_CALL,
MAX_NEW_COMMITMENTS_PER_CALL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use dep::aztec::constants_gen::{MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX};
use crate::common;
use crate::mocked::{Proof, AggregationObject, verify_previous_kernel_state};
use crate::transaction::request::TxRequest;
use crate::abis::{
use dep::types::mocked::{Proof, AggregationObject, verify_previous_kernel_state};
use dep::types::transaction::request::TxRequest;
use dep::types::abis::{
previous_kernel_data::PreviousKernelData,
private_kernel::private_call_data::PrivateCallData,
new_contract_data::NewContractData,
kernel_circuit_public_inputs::{KernelCircuitPublicInputs, KernelCircuitPublicInputsBuilder}
};
use crate::utils::{
use dep::types::utils::{
arrays,
bounded_vec::BoundedVec,
};
Expand Down Expand Up @@ -95,11 +95,11 @@ impl PrivateKernelInputsInner {

mod tests {
use crate::private_kernel_inner::PrivateKernelInputsInner;
use crate::abis::{
use dep::types::abis::{
private_circuit_public_inputs::PrivateCircuitPublicInputs,
read_request_membership_witness::ReadRequestMembershipWitness,
};
use crate::tests::{
use dep::types::tests::{
testing_harness::{
create_previous_kernel_data,
create_private_call_data,
Expand All @@ -112,8 +112,8 @@ mod tests {
deposit::deposit_app,
},
};
use crate::address::Address;
use crate::hash::compute_logs_hash;
use dep::types::address::Address;
use dep::types::hash::compute_logs_hash;
use dep::aztec::constants_gen::{
MAX_READ_REQUESTS_PER_CALL,
MAX_READ_REQUESTS_PER_TX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use dep::aztec::constants_gen::{
MAX_READ_REQUESTS_PER_TX,
};
use crate::common;
use crate::mocked::{Proof, AggregationObject, verify_previous_kernel_state};
use crate::transaction::request::TxRequest;
use crate::abis::{
use dep::types::mocked::{Proof, AggregationObject, verify_previous_kernel_state};
use dep::types::transaction::request::TxRequest;
use dep::types::abis::{
combined_constant_data::CombinedConstantData,
previous_kernel_data::PreviousKernelData,
private_kernel::private_call_data::PrivateCallData,
Expand All @@ -18,11 +18,11 @@ use crate::abis::{
KernelCircuitPublicInputsFinal,
},
};
use crate::utils::{
use dep::types::utils::{
arrays,
bounded_vec::BoundedVec,
};
use crate::hash::{
use dep::types::hash::{
compute_commitment_nonce,
compute_unique_commitment,
};
Expand Down Expand Up @@ -156,17 +156,17 @@ impl PrivateKernelInputsOrdering {
}

mod tests {
use crate::abis::{
use dep::types::abis::{
private_circuit_public_inputs::PrivateCircuitPublicInputs,
read_request_membership_witness::ReadRequestMembershipWitness,
};
use crate::address::Address;
use crate::hash::{
use dep::types::address::Address;
use dep::types::hash::{
compute_commitment_nonce,
compute_unique_commitment,
};
use crate::private_kernel_ordering::PrivateKernelInputsOrdering;
use crate::tests::{
use dep::types::tests::{
apps::constructor::constructor_app,
testing_harness::{
create_previous_kernel_data,
Expand All @@ -183,7 +183,7 @@ mod tests {
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
MAX_NEW_L2_TO_L1_MSGS_PER_TX,
};
use crate::utils::{
use dep::types::utils::{
bounded_vec::BoundedVec,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
aztec = { path = "../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{PrivateKernelInputsOrdering, KernelCircuitPublicInputsFinal};
use dep::private_kernel_lib::PrivateKernelInputsOrdering;
use dep::types::KernelCircuitPublicInputsFinal;

unconstrained fn main(input : PrivateKernelInputsOrdering) -> distinct pub KernelCircuitPublicInputsFinal {
input.native_private_kernel_circuit_ordering()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
private_kernel_lib = { path = "../private-kernel-lib" }
aztec = { path="../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use dep::private_kernel_lib::{PrivateKernelInputsOrdering, KernelCircuitPublicInputsFinal};
use dep::private_kernel_lib::PrivateKernelInputsOrdering;
use dep::types::KernelCircuitPublicInputsFinal;

fn main(input : PrivateKernelInputsOrdering) -> distinct pub KernelCircuitPublicInputsFinal {
input.native_private_kernel_circuit_ordering()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ compiler_version = ">=0.18.0"

[dependencies]
rollup_lib = { path = "../rollup-lib" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ authors = [""]
compiler_version = ">=0.18.0"

[dependencies]
aztec = { path="../../../../aztec-nr/aztec" }
private_kernel_lib = {path = "../private-kernel-lib"}
aztec = { path = "../../../../aztec-nr/aztec" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
use dep::aztec::constants_gen::NUM_FIELDS_PER_SHA256;
use crate::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot;
use crate::abis::constant_rollup_data::ConstantRollupData;

// Re-export bug 3384
// use dep::private_kernel_lib::mocked::AggregationObject;
struct AggregationObject;
use dep::types::mocked::AggregationObject;

global BASE_ROLLUP_TYPE = 0;
global MERGE_ROLLUP_TYPE = 1;
Expand Down Expand Up @@ -34,6 +31,7 @@ struct BaseOrMergeRollupPublicInputs {

// We hash public inputs to make them constant-sized (to then be unpacked on-chain)
// TODO(Kev): Want to make this a U128, but Re-export bug 3384
// TODO(Alvaro): Do we? U128 isn't safe if it's an input to the circuit (it won't automatically constrain the witness)

// We hash public inputs to make them constant-sized (to then be unpacked on-chain)
calldata_hash : [Field; 2],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs;

// Reexport bug (3384)
// use dep::private_kernel_lib::abis::membership_witness::VKMembershipWitness;
use dep::types::abis::membership_witness::VKMembershipWitness;
use dep::aztec::constants_gen::ROLLUP_VK_TREE_HEIGHT;
struct VKMembershipWitness{
leaf_index : Field,
sibling_path : [Field; ROLLUP_VK_TREE_HEIGHT]
}

// Reexport bug (3384)
// use dep::private_kernel_lib::mocked::{Proof, VerificationKey};
struct Proof;
struct VerificationKey;
use dep::types::mocked::{Proof, VerificationKey};

struct PreviousRollupData{
base_or_merge_rollup_public_inputs : BaseOrMergeRollupPublicInputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,9 @@ use dep::aztec::constants_gen::{
PUBLIC_DATA_TREE_HEIGHT,
KERNELS_PER_BASE_ROLLUP,
};

// Reexport bug (3384)
// use dep::private_kernel_lib::abis::previous_kernel_data::PreviousKernelData;
// Note: I have not implemented the fields for this, it would be a mess to do so.
struct PreviousKernelData;

// Reexport bug (3384)
// use dep::private_kernel_lib::abis::membership_witness::NullifierMembershipWitness;
struct NullifierMembershipWitness{
leaf_index : Field,
sibling_path : [Field; MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP]
}

// Reexport bug (3384)
// use dep::private_kernel_lib::abis::membership_witness::HistoricBlocksTreeRootMembershipWitness;
struct HistoricBlocksTreeRootMembershipWitness{
leaf_index : Field,
sibling_path : [Field; KERNELS_PER_BASE_ROLLUP]
}
use dep::types::abis::previous_kernel_data::PreviousKernelData;
use dep::types::abis::membership_witness::NullifierMembershipWitness;
use dep::types::abis::membership_witness::HistoricBlocksTreeRootMembershipWitness;

struct BaseRollupInputs {
kernel_data: [PreviousKernelData; KERNELS_PER_BASE_ROLLUP],
Expand Down
Loading