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: squash transient note logs #6268

Merged
merged 33 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
32634be
feat: log hashes struct, tracking lens inside circuit
MirandaWood May 8, 2024
6b3cf5f
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 8, 2024
d8097d1
chore: merge fixes + snaps
MirandaWood May 8, 2024
e8771dc
feat: stop tracking extra log lens in circuit
MirandaWood May 8, 2024
cb4058d
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 8, 2024
540fd8a
chore: merge fix + snaps
MirandaWood May 8, 2024
f8bc8bb
feat: noteloghash separation and transient removal
MirandaWood May 10, 2024
ff8ece9
chore: update tests, fixtures, fmt
MirandaWood May 13, 2024
ad521f7
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 13, 2024
f4427dc
chore: merge fixes + constants updates
MirandaWood May 13, 2024
5342064
fix: small e2e fixes, priv->pub note log fixes, comments
MirandaWood May 13, 2024
707eaa1
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 13, 2024
c6acc4d
chore: nargo fmt contexts
MirandaWood May 13, 2024
82fc9a2
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 14, 2024
3c1e499
fix: merge fixes, circuits.js test fixes, log len updates
MirandaWood May 14, 2024
a979a71
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 14, 2024
4c01cf7
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 14, 2024
24a5dbd
fix: merge fixes + increase bench test timeout
MirandaWood May 14, 2024
360021e
feat: address comments
MirandaWood May 14, 2024
8ab5d10
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
75f2867
feat: address final comments
MirandaWood May 15, 2024
b9b9425
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
a77a9f3
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
76a2ddb
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
a70b23b
fix: merge fixes
MirandaWood May 15, 2024
ff2efaa
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
18de2b7
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
96bb755
fix: reapply transient log changes to new reset circuit
MirandaWood May 15, 2024
b8f28d2
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
41fdde0
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 15, 2024
4625f9e
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 16, 2024
560f0df
Merge remote-tracking branch 'origin' into mw/note-logs
MirandaWood May 16, 2024
17a8b24
feat: address comments, merge fixes, update fixtures
MirandaWood May 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mod tests {

builder.failed();
}

#[test]
unconstrained fn propagate_fee_payer() {
let mut builder = PrivateKernelInitInputsBuilder::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,33 @@ mod tests {
}

#[test(should_fail_with = "Could not find note hash linked to note log.")]
fn input_validation_note_log_not_linked() {
unconstrained fn input_validation_note_log_not_linked() {
let mut builder = PrivateKernelInnerInputsBuilder::new();

builder.private_call.public_inputs.note_encrypted_logs_hashes.extend_from_array([NoteLogHash { value: 9123, counter: 1, length: 2, note_hash: 1 }]);
builder.private_call.public_inputs.note_encrypted_logs_hashes.push(NoteLogHash { value: 9123, counter: 1, length: 2, note_hash: 1 });
builder.failed();
}

#[test]
unconstrained fn propagate_fee_payer() {
let mut builder = PrivateKernelInnerInputsBuilder::new();
let fee_payer = builder.private_call.public_inputs.call_context.storage_contract_address;
builder.private_call.public_inputs.is_fee_payer = true;
let public_inputs = builder.execute();
assert_eq(public_inputs.fee_payer, fee_payer);
}

#[test]
unconstrained fn propagate_fee_payer_not_set() {
// Check that the fee payer is not set if is_fee_payer is false
let mut builder = PrivateKernelInnerInputsBuilder::new();
assert_eq(builder.private_call.public_inputs.is_fee_payer, false);
let public_inputs = builder.execute();
assert_eq(public_inputs.fee_payer, AztecAddress::empty());
}

#[test]
unconstrained fn propagate_fee_payer_carry_forward() {
LeilaWang marked this conversation as resolved.
Show resolved Hide resolved
// Check that we carry forward if the fee payer is already set
let mut builder = PrivateKernelInnerInputsBuilder::new();
let fee_payer = AztecAddress::from_field(123);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ fn empty_hash() {
let hash = item.hash();

// Value from private_call_stack_item.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x0e3b0eeedc919ca4b40e9cf513eaa76b3b26ff7d99be7ad1f45ea73835e9bccd;
let test_data_empty_hash = 0x09d4e540f9a3aa434960efdecb388dfc8f14d157b4ed205f7ed049e108ca41cc;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@ fn empty_hash() {
let inputs = PrivateCircuitPublicInputs::empty();
let hash = inputs.hash();
// Value from private_circuit_public_inputs.test.ts "computes empty item hash" test
let test_data_empty_hash = 0x04702de5e5815af9c35e4de0a2458edb284509cc975d303ccb346de8f927196b;
let test_data_empty_hash = 0x151a2195c12896a8c8f58f3738f6920e93363d398c5f4a8fe1222b4f3b00dafe;
assert_eq(hash, test_data_empty_hash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ describe('ContractAddress', () => {
expect(address).toMatchSnapshot();
});

it('Public key hash matches Noir', () => {
// This test no longer exists in nr, the new test in 'noir-projects/aztec-nr/aztec/src/keys/public_keys.nr does not match the code here.
// That test is run in keys/index.test.ts -> 'computing public keys hash matches Noir'
it.skip('Public key hash matches Noir', () => {
LeilaWang marked this conversation as resolved.
Show resolved Hide resolved
const secretKey = new Fr(2n);
const hash = deriveKeys(secretKey).publicKeys.hash().toString();
expect(hash).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/keys/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('🔑', () => {

// Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data
updateInlineTestData(
'noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr',
'noir-projects/aztec-nr/aztec/src/keys/public_keys.nr',
'expected_public_keys_hash',
expected.toString(),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x0e3b0eeedc919ca4b40e9cf513eaa76b3b26ff7d99be7ad1f45ea73835e9bccd>`;
exports[`PrivateCallStackItem computes empty item hash 1`] = `Fr<0x09d4e540f9a3aa434960efdecb388dfc8f14d157b4ed205f7ed049e108ca41cc>`;

exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x2984cb74f2fbc6b915c5fb2673296156917c2bde4d72821841f10b8288e9e957>`;
exports[`PrivateCallStackItem computes hash 1`] = `Fr<0x029a9d1f821097cb2036661cdc3f7c5e7de75ac126036f1ce931ec0c675daa0d>`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x04702de5e5815af9c35e4de0a2458edb284509cc975d303ccb346de8f927196b>`;
exports[`PrivateCircuitPublicInputs computes empty inputs hash 1`] = `Fr<0x151a2195c12896a8c8f58f3738f6920e93363d398c5f4a8fe1222b4f3b00dafe>`;

exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x2bd261dcbd3035bcc884242c96fb40cacd498403abbb2306b9116c11735d8619>`;
exports[`PrivateCircuitPublicInputs hash matches snapshot 1`] = `Fr<0x0e7a8afddd8967913ff699f70ed48dcaffeeadaf892b94e70666db8be73b884b>`;
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,28 @@ describe('benchmarks/tx_size_fees', () => {
'native fee',
() => NativeFeePaymentMethod.create(aliceWallet),
// DA:
// non-rev: 1 nullifiers, overhead; rev: 2 note hashes, 1 nullifier, 624 B enc logs, 8 B unenc logs, teardown
// non-rev: 1 nullifiers, overhead; rev: 2 note hashes, 1 nullifier, 616 B enc logs, 0 B unenc logs, teardown
// L2:
// non-rev: 0; rev: 0
200012672n,
200012416n,
],
[
'public fee',
() => Promise.resolve(new PublicFeePaymentMethod(token.address, fpc.address, aliceWallet)),
// DA:
// non-rev: 1 nullifiers, overhead; rev: 2 note hashes, 1 nullifier, 628 B enc logs, 12 B unenc logs, teardown
// non-rev: 1 nullifiers, overhead; rev: 2 note hashes, 1 nullifier, 616 B enc logs, 0 B unenc logs, teardown
// L2:
// non-rev: 0; rev: 0
200012800n,
200012416n,
],
[
'private fee',
() => Promise.resolve(new PrivateFeePaymentMethod(token.address, fpc.address, aliceWallet)),
// DA:
// non-rev: 3 nullifiers, overhead; rev: 2 note hashes, 944 B enc logs, 20 B unenc logs, teardown
// non-rev: 3 nullifiers, overhead; rev: 2 note hashes, 616 B enc logs, 0 B unenc logs, teardown
// L2:
// non-rev: 0; rev: 0
200018496n,
200012928n,
],
] as const)(
'sends a tx with a fee with %s payment method',
Expand Down
17 changes: 10 additions & 7 deletions yarn-project/simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,19 @@ export class ClientExecutionContext extends ViewDataOracle {
public chopNoteEncryptedLogsFromNested() {
// Do not return logs that have been chopped in the cache
const allNoteLogs = this.noteCache.getLogs();
this.nestedExecutions.forEach(result => {
if (!result.noteEncryptedLogs[0]?.isEmpty()) {
// The execution has note logs
result.noteEncryptedLogs = result.noteEncryptedLogs.filter(l => allNoteLogs.includes(l));
}
});
const chop = (thing: any) =>
thing.nestedExecutions.forEach((result: ExecutionResult) => {
if (!result.noteEncryptedLogs[0]?.isEmpty()) {
// The execution has note logs
result.noteEncryptedLogs = result.noteEncryptedLogs.filter(l => allNoteLogs.includes(l));
}
chop(result);
});
chop(this);
}

/**
* Return the note encrypted logs emitted during this execution.
* Return the note encrypted logs emitted during this execution and nested executions.
*/
public getAllNoteEncryptedLogs() {
return this.noteCache.getLogs();
Expand Down
Loading