Skip to content

Commit

Permalink
Merge ca887e0 into 795b832
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Aug 6, 2024
2 parents 795b832 + ca887e0 commit 3d57175
Show file tree
Hide file tree
Showing 35 changed files with 323 additions and 281 deletions.
20 changes: 10 additions & 10 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x10107c16f4b8ac81aa0127268a7c467fd07717e1a6ae8ad0d068c9454b0e976d",
"archive": "0x15e53fc73037ad67a12a7af9a828218445cd4252d356f854d2a44b3e64d2262c",
"body": "0x00000000",
"txsEffectsHash": "0x00d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf2",
"decodedHeader": {
Expand All @@ -24,40 +24,40 @@
"chainId": 31337,
"timestamp": 0,
"version": 1,
"coinbase": "0x7fea02760c190713b363c9030a22b14846464e1f",
"feeRecipient": "0x085fdb7b311018f9d15e25348b849902dd8041515bc78248220ca712a6c6afef",
"coinbase": "0x56496111355717b87a7e9ecde62b1fc8741933d7",
"feeRecipient": "0x30312153fedef883087dc5281903c6d005a7c0e98a4f604b0ab93953c162e50e",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 1,
"root": "0x0a50781a9ce38c219f4fb0c320c441b30c9d3009dfb36d995a8035e68e67e27d"
"root": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e"
},
"stateReference": {
"l1ToL2MessageTree": {
"nextAvailableLeafIndex": 16,
"root": "0x1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80"
"root": "0x14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3"
},
"partialStateReference": {
"noteHashTree": {
"nextAvailableLeafIndex": 128,
"root": "0x16642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb"
"root": "0x0b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d"
},
"nullifierTree": {
"nextAvailableLeafIndex": 256,
"root": "0x0bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278"
"root": "0x19a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc"
},
"publicDataTree": {
"nextAvailableLeafIndex": 256,
"root": "0x021a6cc64c830b4914600d0296c3968c5d28c1b00c5c4b0b33d1f39d948edbd4"
"root": "0x23c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9"
}
}
}
},
"header": "0x0a50781a9ce38c219f4fb0c320c441b30c9d3009dfb36d995a8035e68e67e27d00000001000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000001016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000000800bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f27800000100021a6cc64c830b4914600d0296c3968c5d28c1b00c5c4b0b33d1f39d948edbd4000001000000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000007fea02760c190713b363c9030a22b14846464e1f085fdb7b311018f9d15e25348b849902dd8041515bc78248220ca712a6c6afef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00d30a4f529fd4f14f9667bc062d5fbf3c7b0dd3e9833a7253732f83aa60986e",
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a69000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000056496111355717b87a7e9ecde62b1fc8741933d730312153fedef883087dc5281903c6d005a7c0e98a4f604b0ab93953c162e50e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00010682db7186e580231f059cb12d74d3e8d1ab7428fcf0fb893af85b297ea5",
"numTxs": 0
}
}
22 changes: 11 additions & 11 deletions l1-contracts/test/fixtures/empty_block_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x2602de27d40577b24692fc0696b1225a4725e6b7a8a105c658b261d55ee83660",
"archive": "0x1900f7c4305f805f10fd6940dc654405720621d2a40b3b076969c5bc51ba6475",
"body": "0x00000000",
"txsEffectsHash": "0x00d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf2",
"decodedHeader": {
Expand All @@ -22,42 +22,42 @@
"blockNumber": 2,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000002",
"chainId": 31337,
"timestamp": 1722338614,
"timestamp": 1722938948,
"version": 1,
"coinbase": "0x7fea02760c190713b363c9030a22b14846464e1f",
"feeRecipient": "0x085fdb7b311018f9d15e25348b849902dd8041515bc78248220ca712a6c6afef",
"coinbase": "0x56496111355717b87a7e9ecde62b1fc8741933d7",
"feeRecipient": "0x30312153fedef883087dc5281903c6d005a7c0e98a4f604b0ab93953c162e50e",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x10107c16f4b8ac81aa0127268a7c467fd07717e1a6ae8ad0d068c9454b0e976d"
"root": "0x15e53fc73037ad67a12a7af9a828218445cd4252d356f854d2a44b3e64d2262c"
},
"stateReference": {
"l1ToL2MessageTree": {
"nextAvailableLeafIndex": 32,
"root": "0x1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80"
"root": "0x14f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3"
},
"partialStateReference": {
"noteHashTree": {
"nextAvailableLeafIndex": 256,
"root": "0x16642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb"
"root": "0x0b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d"
},
"nullifierTree": {
"nextAvailableLeafIndex": 384,
"root": "0x0bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278"
"root": "0x19a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc"
},
"publicDataTree": {
"nextAvailableLeafIndex": 384,
"root": "0x021a6cc64c830b4914600d0296c3968c5d28c1b00c5c4b0b33d1f39d948edbd4"
"root": "0x23c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9"
}
}
}
},
"header": "0x10107c16f4b8ac81aa0127268a7c467fd07717e1a6ae8ad0d068c9454b0e976d00000002000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c31864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f800000002016642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb000001000bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f27800000180021a6cc64c830b4914600d0296c3968c5d28c1b00c5c4b0b33d1f39d948edbd4000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000066a8cd367fea02760c190713b363c9030a22b14846464e1f085fdb7b311018f9d15e25348b849902dd8041515bc78248220ca712a6c6afef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x009d843e9fb93a6cf18eb3784737e8fdf2ee10b75aa4843433d10001864f32f6",
"header": "0x15e53fc73037ad67a12a7af9a828218445cd4252d356f854d2a44b3e64d2262c00000002000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000066b1f64456496111355717b87a7e9ecde62b1fc8741933d730312153fedef883087dc5281903c6d005a7c0e98a4f604b0ab93953c162e50e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00dc15ea88fb4abf65ab3e6de30cdf91c104afb5cb14296a138c28d768b34aa5",
"numTxs": 0
}
}
92 changes: 46 additions & 46 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions l1-contracts/test/fixtures/mixed_block_2.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use dep::types::{
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_TX,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL
},
hash::{silo_encrypted_log_hash, silo_l2_to_l1_message, silo_note_hash, silo_nullifier},
traits::is_empty, transaction::tx_request::TxRequest,
hash::{silo_encrypted_log_hash, silo_note_hash, silo_nullifier}, traits::is_empty,
transaction::tx_request::TxRequest,
utils::arrays::{array_length, array_to_bounded_vec, sort_by_counters_asc, sort_by_counters_desc}
};

Expand Down Expand Up @@ -276,7 +276,6 @@ impl PrivateKernelCircuitPublicInputsComposer {
fn silo_scoped_values(&mut self) {
self.silo_note_hashes();
self.silo_nullifiers();
self.silo_l2_to_l1_messages();
self.silo_encrypted_logs();
}

Expand All @@ -299,18 +298,6 @@ impl PrivateKernelCircuitPublicInputsComposer {
}
}

fn silo_l2_to_l1_messages(&mut self) {
let l2_to_l1_msgs = self.public_inputs.end.l2_to_l1_msgs.storage;
let tx_context = self.public_inputs.constants.tx_context;
for i in 0..l2_to_l1_msgs.len() {
self.public_inputs.end.l2_to_l1_msgs.storage[i].message.content = silo_l2_to_l1_message(
l2_to_l1_msgs[i],
tx_context.version,
tx_context.chain_id,
);
}
}

fn silo_encrypted_logs(&mut self) {
let logs = self.public_inputs.end.encrypted_logs_hashes.storage;
for i in 0..logs.len() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl TailOutputComposer {
let mut data = CombinedAccumulatedData::empty();
data.note_hashes = source.note_hashes.storage.map(|n: ScopedNoteHash| n.note_hash.value);
data.nullifiers = source.nullifiers.storage.map(|n: ScopedNullifier| n.nullifier.value);
data.l2_to_l1_msgs = source.l2_to_l1_msgs.storage.map(|m: ScopedL2ToL1Message| m.message.content);
data.l2_to_l1_msgs = source.l2_to_l1_msgs.storage.map(|m: ScopedL2ToL1Message| m.expose_to_public());
data.note_encrypted_logs_hash = compute_tx_note_logs_hash(source.note_encrypted_logs_hashes.storage.map(|l: NoteLogHash| l.expose_to_public()));
data.encrypted_logs_hash = compute_tx_logs_hash(source.encrypted_logs_hashes.storage.map(|l: ScopedEncryptedLogHash| l.expose_to_public()));
data.unencrypted_logs_hashes = source.unencrypted_logs_hashes.storage.map(|l: ScopedLogHash| l.expose_to_public());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ use dep::types::{
kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PrivateKernelCircuitPublicInputs},
log_hash::{LogHash, NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}
},
hash::{
compute_tx_logs_hash, compute_tx_note_logs_hash, silo_encrypted_log_hash, silo_l2_to_l1_message,
silo_note_hash, silo_nullifier
},
messaging::l2_to_l1_message::ScopedL2ToL1Message,
hash::{compute_tx_logs_hash, compute_tx_note_logs_hash, silo_encrypted_log_hash, silo_note_hash, silo_nullifier},
traits::is_empty,
utils::arrays::{assert_sorted_transformed_value_array, assert_sorted_array_with_order_hints}
};
Expand Down Expand Up @@ -99,16 +97,9 @@ impl TailOutputValidator {
);

// l2_to_l1_msgs
let tx_context = self.previous_kernel.constants.tx_context;
validate_transformed_values(
self.previous_kernel.end.l2_to_l1_msgs,
self.hints.siloed_l2_to_l1_msgs,
|msg| silo_l2_to_l1_message(msg, tx_context.version, tx_context.chain_id)
);

assert_sorted_transformed_value_array(
self.previous_kernel.end.l2_to_l1_msgs,
self.hints.siloed_l2_to_l1_msgs,
self.previous_kernel.end.l2_to_l1_msgs.map(|log: ScopedL2ToL1Message| log.expose_to_public()),
self.output.end.l2_to_l1_msgs,
self.hints.sorted_l2_to_l1_msg_hints
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dep::types::{
MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX,
MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX
},
hash::{silo_encrypted_log_hash, silo_l2_to_l1_message, silo_note_hash, silo_nullifier},
hash::{silo_encrypted_log_hash, silo_note_hash, silo_nullifier},
messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::{Empty, is_empty},
utils::arrays::{OrderHint, sort_by_counters_asc, sort_get_order_hints_asc}
};
Expand All @@ -20,7 +20,6 @@ struct TailOutputHints {
siloed_nullifiers: [Field; MAX_NULLIFIERS_PER_TX],
// L2 to l1 msgs.
sorted_l2_to_l1_msg_hints: [OrderHint; MAX_L2_TO_L1_MSGS_PER_TX],
siloed_l2_to_l1_msgs: [Field; MAX_L2_TO_L1_MSGS_PER_TX],
// Note encrypted log hashes.
note_encrypted_log_hashes: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX],
sorted_note_encrypted_log_hashes: [LogHash; MAX_NOTE_ENCRYPTED_LOGS_PER_TX],
Expand All @@ -45,15 +44,6 @@ unconstrained pub fn generate_tail_output_hints(previous_kernel: PrivateKernelCi
// l2_to_l1_msgs
let sorted_l2_to_l1_msg_hints = sort_get_order_hints_asc(previous_kernel.end.l2_to_l1_msgs);

let tx_context = previous_kernel.constants.tx_context;
let siloed_l2_to_l1_msgs = previous_kernel.end.l2_to_l1_msgs.map(
|m: ScopedL2ToL1Message| silo_l2_to_l1_message(
m,
tx_context.version,
tx_context.chain_id,
)
);

// note_encrypted_logs
let note_encrypted_log_hashes = previous_kernel.end.note_encrypted_logs_hashes.map(|h: NoteLogHash| h.expose_to_public());
let sorted_note_encrypted_log_hashes = sort_by_counters_asc(previous_kernel.end.note_encrypted_logs_hashes).map(|h: NoteLogHash| h.expose_to_public());
Expand All @@ -77,7 +67,6 @@ unconstrained pub fn generate_tail_output_hints(previous_kernel: PrivateKernelCi
sorted_nullifier_hints,
siloed_nullifiers,
sorted_l2_to_l1_msg_hints,
siloed_l2_to_l1_msgs,
note_encrypted_log_hashes,
sorted_note_encrypted_log_hashes,
sorted_siloed_encrypted_log_hashes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pub fn split_to_public(
if i < l2_to_l1_msgs.len() {
let msg = l2_to_l1_msgs.get_unchecked(i);
if msg.counter() < min_revertible_side_effect_counter {
non_revertible_builder.l2_to_l1_msgs.push(msg.message.content);
non_revertible_builder.l2_to_l1_msgs.push(msg.expose_to_public());
} else {
revertible_builder.l2_to_l1_msgs.push(msg.message.content);
revertible_builder.l2_to_l1_msgs.push(msg.expose_to_public());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use dep::types::{
log_hash::{LogHash, ScopedEncryptedLogHash, NoteLogHash, ScopedLogHash}, note_hash::NoteHash,
nullifier::Nullifier, public_call_request::PublicCallRequest
},
address::AztecAddress,
hash::{silo_encrypted_log_hash, silo_l2_to_l1_message, silo_note_hash, silo_nullifier},
messaging::l2_to_l1_message::ScopedL2ToL1Message, address::AztecAddress,
hash::{silo_encrypted_log_hash, silo_note_hash, silo_nullifier},
traits::{Empty, is_empty, is_empty_array},
utils::arrays::{
array_length, assert_split_sorted_transformed_value_arrays_asc,
Expand Down Expand Up @@ -128,16 +128,10 @@ impl TailToPublicOutputValidator {
);

// l2_to_l1_msgs
let tx_context = self.previous_kernel.constants.tx_context;
validate_transformed_values(
prev_data.l2_to_l1_msgs,
hints.siloed_l2_to_l1_msgs,
|msg| silo_l2_to_l1_message(msg, tx_context.version, tx_context.chain_id)
);

assert_split_sorted_transformed_value_arrays_asc(
prev_data.l2_to_l1_msgs,
hints.siloed_l2_to_l1_msgs,
prev_data.l2_to_l1_msgs.map(|log: ScopedL2ToL1Message| log.expose_to_public()),
split_counter,
output_non_revertible.l2_to_l1_msgs,
output_revertible.l2_to_l1_msgs,
Expand Down
Loading

0 comments on commit 3d57175

Please sign in to comment.