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: Migrate the init kernel CPP tests to noir #3091

Merged
merged 3 commits into from
Oct 27, 2023
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
5 changes: 5 additions & 0 deletions yarn-project/noir-private-kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"formatting:fix": "run -T prettier -w ./src",
"noir:build": "cd src && nargo compile --no-backend && rm -rf ./target/debug_*",
"noir:types": "yarn ts-node --esm src/scripts/generate_ts_from_abi.ts",
"noir:test": "cd src && nargo test",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
Expand All @@ -38,11 +39,15 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@aztec/merkle-tree": "workspace:^",
"@aztec/types": "workspace:^",
"@jest/globals": "^29.5.0",
"@rushstack/eslint-patch": "^1.1.4",
"@types/jest": "^29.5.0",
"@types/node": "^18.7.23",
"jest": "^29.5.0",
"levelup": "^5.1.1",
"memdown": "^6.1.1",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
Expand Down
4,399 changes: 4,399 additions & 0 deletions yarn-project/noir-private-kernel/src/__snapshots__/noir_test_gen.test.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ 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;

// Hmm
// PrivateCircuitPublicInputs vs CombinedAccumulatedData (Duplicated fields)
// ?Que es la diferencia entre contract_address y storage_address?

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod testing_harness;
mod apps;
mod read_requests;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod deposit;
mod constructor;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::{
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs,
tests::testing_harness::{PrivateCircuitPublicInputsBuilder, PrivateAppInputs},
utils::uint128::U128,
hash::NUM_FIELDS_PER_SHA256,
};

struct ConstructorParams {}

pub fn constructor_app(inputs: PrivateAppInputs, params: ConstructorParams) -> PrivateCircuitPublicInputs {
PrivateCircuitPublicInputsBuilder::new(inputs).finish()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::{
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs,
tests::testing_harness::{PrivateCircuitPublicInputsBuilder, PrivateAppInputs},
utils::uint128::U128,
hash::NUM_FIELDS_PER_SHA256,
};

global BALANCES_SLOT = 1;

struct DepositParams {
amount: Field,
asset_id: Field,
memo: Field,
encrypted_logs_hash : [U128; NUM_FIELDS_PER_SHA256],
unencrypted_logs_hash : [U128; NUM_FIELDS_PER_SHA256],
encrypted_log_preimages_length : Field,
unencrypted_log_preimages_length : Field,
}

pub fn deposit_app(inputs: PrivateAppInputs, params: DepositParams) -> PrivateCircuitPublicInputs {
let msg_sender = inputs.call_context.msg_sender;

let mut context = PrivateCircuitPublicInputsBuilder::new(inputs);


let user_balance_slot = dep::std::hash::pedersen_hash([BALANCES_SLOT, params.asset_id, msg_sender.to_field()]);

let commitment = dep::std::hash::pedersen_hash([user_balance_slot, params.amount, msg_sender.to_field(), params.memo]);

context.new_commitments.push(commitment);

context.encrypted_logs_hash = params.encrypted_logs_hash.map(|uint: U128| uint.to_field());
context.unencrypted_logs_hash = params.unencrypted_logs_hash.map(|uint: U128| uint.to_field());

context.encrypted_log_preimages_length = params.encrypted_log_preimages_length;
context.unencrypted_log_preimages_length = params.unencrypted_log_preimages_length;

context.finish()
}

Large diffs are not rendered by default.

Loading