Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Jan 3, 2025
1 parent 58bbabc commit 250a23d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ impl TailOutputValidator {
}

fn validate_propagated_values(self) {
assert_eq(self.output.constants, self.previous_kernel.constants, "mismatch constants");
assert_eq(
self.output.constants.historical_header,
self.previous_kernel.constants.historical_header,
"mismatch historical_header",
);
assert_eq(
self.output.constants.tx_context,
self.previous_kernel.constants.tx_context,
"mismatch tx_context",
);
assert_eq(
self.output.constants.vk_tree_root,
self.previous_kernel.constants.vk_tree_root,
"mismatch vk_tree_root",
);
assert_eq(
self.output.constants.protocol_contract_tree_root,
self.previous_kernel.constants.protocol_contract_tree_root,
"mismatch protocol_contract_tree_root",
);

assert_eq(
self.output.rollup_validation_requests,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod validate_empty_values;
mod validate_gas_used;
mod validate_propagated_sorted_values;
mod validate_propagated_values;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ fn validate_propagated_values_protocol_contract_tree_root_mismatch_fails() {
builder.validate();
}

#[test(should_fail_with = "global_variables must be empty")]
fn validate_propagated_values_global_variables_non_empty_fails() {
let mut builder = TailOutputValidatorBuilder::new();

// Tweak the value in the output.
builder.output.global_variables.chain_id = 1;

builder.validate();
}

/**
* max_block_number
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pub(crate) mod base_or_merge_rollup_public_inputs;
pub(crate) mod block_root_or_block_merge_public_inputs;
pub(crate) mod previous_rollup_data;
pub(crate) mod previous_rollup_block_data;
pub(crate) mod tx_effect;
pub(crate) mod tx_effect;
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use types::{traits::Empty, abis::{log_hash::ScopedLogHash, private_log::PrivateLog, public_data_write::PublicDataWrite}, constants::{
MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX
}};
use types::{
abis::{log_hash::ScopedLogHash, private_log::PrivateLog, public_data_write::PublicDataWrite},
constants::{
MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX,
MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX,
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX,
},
traits::Empty,
};

pub(crate) struct TxEffect {
pub(crate) revert_code: u8,
Expand All @@ -24,12 +30,14 @@ impl Empty for TxEffect {
note_hashes: [0; MAX_NOTE_HASHES_PER_TX],
nullifiers: [0; MAX_NULLIFIERS_PER_TX],
l2_to_l1_msgs: [0; MAX_L2_TO_L1_MSGS_PER_TX],
public_data_writes: [PublicDataWrite::empty(); MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX],
public_data_writes: [
PublicDataWrite::empty(); MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
],
private_logs: [PrivateLog::empty(); MAX_PRIVATE_LOGS_PER_TX],
unencrypted_log_preimages_length: 0,
unencrypted_logs_hashes: [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX],
contract_class_log_preimages_length: 0,
contract_class_logs_hashes: [ScopedLogHash::empty(); MAX_CONTRACT_CLASS_LOGS_PER_TX],
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use types::abis::{
tx_constant_data::TxConstantData, combined_constant_data::CombinedConstantData, constant_rollup_data::ConstantRollupData,
combined_constant_data::CombinedConstantData, constant_rollup_data::ConstantRollupData,
tx_constant_data::TxConstantData,
};

pub(crate) fn validate_combined_constant_data(
Expand Down Expand Up @@ -49,5 +50,4 @@ pub(crate) fn validate_tx_constant_data(
constants.protocol_contract_tree_root == rollup_constants.protocol_contract_tree_root,
"kernel protocol_contract_tree_root does not match the rollup protocol_contract_tree_root",
);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::{
abis::tx_effect::TxEffect, abis::base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
abis::{
base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
tx_effect::TxEffect,
},
base::{
components::{
archive::perform_archive_membership_check,
Expand All @@ -12,15 +15,16 @@ use crate::{
},
components::{append_tx_effects_for_blob, compute_kernel_out_hash},
};
use super::components::constants::validate_tx_constant_data;
use dep::types::{
abis::{
log_hash::ScopedLogHash, append_only_tree_snapshot::AppendOnlyTreeSnapshot, constant_rollup_data::ConstantRollupData,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob, tube::PrivateTubeData,
append_only_tree_snapshot::AppendOnlyTreeSnapshot, constant_rollup_data::ConstantRollupData,
log_hash::ScopedLogHash, nullifier_leaf_preimage::NullifierLeafPreimage,
public_data_write::PublicDataWrite, sponge_blob::SpongeBlob, tube::PrivateTubeData,
},
constants::{
ARCHIVE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT,
TUBE_VK_INDEX,MAX_UNENCRYPTED_LOGS_PER_TX
ARCHIVE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX,
NOTE_HASH_SUBTREE_HEIGHT, TUBE_VK_INDEX,
},
data::{hash::compute_public_data_tree_value, public_data_hint::PublicDataHint},
hash::silo_l2_to_l1_message,
Expand All @@ -30,7 +34,6 @@ use dep::types::{
messaging::l2_to_l1_message::ScopedL2ToL1Message,
partial_state_reference::PartialStateReference,
};
use super::components::constants::validate_tx_constant_data;

global ALLOWED_PREVIOUS_CIRCUITS: [u32; 1] = [TUBE_VK_INDEX];

Expand Down Expand Up @@ -123,13 +126,14 @@ impl PrivateBaseRollupInputs {
private_logs: self.tube_data.public_inputs.end.private_logs,
unencrypted_log_preimages_length: 0,
unencrypted_logs_hashes: [ScopedLogHash::empty(); MAX_UNENCRYPTED_LOGS_PER_TX],
contract_class_log_preimages_length: self.tube_data.public_inputs.end.contract_class_log_preimages_length,
contract_class_log_preimages_length: self
.tube_data
.public_inputs
.end
.contract_class_log_preimages_length,
contract_class_logs_hashes: self.tube_data.public_inputs.end.contract_class_logs_hashes,
};
let end_sponge_blob = append_tx_effects_for_blob(
tx_effect,
self.start_sponge_blob,
);
let end_sponge_blob = append_tx_effects_for_blob(tx_effect, self.start_sponge_blob);

// Perform membership checks that the notes provided exist within the historical trees data
perform_archive_membership_check(
Expand Down Expand Up @@ -225,6 +229,7 @@ mod tests {
append_tx_effects_for_blob, encode_blob_prefix, TX_EFFECTS_BLOB_HASH_INPUT_FIELDS,
},
};
use crate::abis::tx_effect::TxEffect;
use dep::types::{
abis::{
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
Expand Down Expand Up @@ -260,7 +265,6 @@ mod tests {
field::{field_from_bytes, full_field_less_than},
},
};
use crate::abis::tx_effect::TxEffect;

struct NullifierInsertion {
existing_index: u32,
Expand Down Expand Up @@ -386,9 +390,7 @@ mod tests {
gas_used.compute_fee(gas_fees)
}

fn build_pre_existing_tx_effects(
self,
) -> TxEffect {
fn build_pre_existing_tx_effects(self) -> TxEffect {
let mut res = TxEffect::empty();
res.note_hashes = self.pre_existing_notes;
res.nullifiers = self.pre_existing_nullifiers.map(|nullifier: NullifierLeafPreimage| {
Expand Down Expand Up @@ -573,9 +575,7 @@ mod tests {
public_data_tree: start_public_data_tree_snapshot,
};

let pre_existing_tx_effects =
self.build_pre_existing_tx_effects();

let pre_existing_tx_effects = self.build_pre_existing_tx_effects();

let start_sponge_blob = append_tx_effects_for_blob(
pre_existing_tx_effects,
Expand Down Expand Up @@ -962,15 +962,7 @@ mod tests {
reconstructed_tx_effects[0] = field_from_bytes(
array_concat(
TX_START_PREFIX.to_be_bytes::<8>(),
[
0,
length_bytes[0],
length_bytes[1],
0,
REVERT_CODE_PREFIX,
0,
0,
],
[0, length_bytes[0], length_bytes[1], 0, REVERT_CODE_PREFIX, 0, 0],
),
true,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::{
abis::tx_effect::TxEffect, abis::base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
abis::{
base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
tx_effect::TxEffect,
},
base::{
components::{
archive::perform_archive_membership_check, constants::validate_combined_constant_data,
Expand Down Expand Up @@ -50,7 +53,11 @@ pub struct PublicBaseRollupInputs {
}

impl PublicBaseRollupInputs {
fn generate_tx_effect(self, reverted: bool, combined_constant_data: CombinedConstantData) -> TxEffect {
fn generate_tx_effect(
self,
reverted: bool,
combined_constant_data: CombinedConstantData,
) -> TxEffect {
let from_private = self.tube_data.public_inputs;
let from_public = self.avm_proof_data.public_inputs;
let revert_code = if reverted { 1 } else { 0 };
Expand Down Expand Up @@ -90,12 +97,12 @@ impl PublicBaseRollupInputs {
transaction_fee: from_public.transaction_fee,
note_hashes: from_public.accumulated_data.note_hashes,
nullifiers: from_public.accumulated_data.nullifiers,
l2_to_l1_msgs:siloed_l2_to_l1_msgs ,
l2_to_l1_msgs: siloed_l2_to_l1_msgs,
public_data_writes: from_public.accumulated_data.public_data_writes,
private_logs,
unencrypted_logs_hashes: from_public.accumulated_data.unencrypted_logs_hashes,
unencrypted_log_preimages_length,
contract_class_log_preimages_length,
unencrypted_log_preimages_length,
contract_class_log_preimages_length,
contract_class_logs_hashes,
}
}
Expand Down Expand Up @@ -140,8 +147,7 @@ impl PublicBaseRollupInputs {

let tx_effect = self.generate_tx_effect(reverted, combined_constant_data);

let commitments_tree_subroot =
calculate_subtree_root(tx_effect.note_hashes);
let commitments_tree_subroot = calculate_subtree_root(tx_effect.note_hashes);

let empty_commitments_subtree_root = calculate_empty_tree_root(NOTE_HASH_SUBTREE_HEIGHT);

Expand All @@ -164,10 +170,7 @@ impl PublicBaseRollupInputs {

let out_hash = compute_kernel_out_hash(tx_effect.l2_to_l1_msgs);

let end_sponge_blob = append_tx_effects_for_blob(
tx_effect,
self.start_sponge_blob,
);
let end_sponge_blob = append_tx_effects_for_blob(tx_effect, self.start_sponge_blob);

// Perform membership checks that the notes provided exist within the historical trees data
perform_archive_membership_check(
Expand Down Expand Up @@ -284,6 +287,7 @@ mod tests {
append_tx_effects_for_blob, encode_blob_prefix, TX_EFFECTS_BLOB_HASH_INPUT_FIELDS,
},
};
use crate::abis::tx_effect::TxEffect;
use dep::types::{
abis::{
accumulated_data::CombinedAccumulatedData,
Expand Down Expand Up @@ -321,7 +325,6 @@ mod tests {
field::{field_from_bytes, full_field_less_than},
},
};
use crate::abis::tx_effect::TxEffect;

struct NullifierInsertion {
existing_index: u32,
Expand Down Expand Up @@ -436,9 +439,7 @@ mod tests {
builder
}

fn build_pre_existing_tx_effects(
self,
) -> TxEffect {
fn build_pre_existing_tx_effects(self) -> TxEffect {
let mut res = TxEffect::empty();
res.note_hashes = self.pre_existing_notes;
res.nullifiers = self.pre_existing_nullifiers.map(|nullifier: NullifierLeafPreimage| {
Expand Down Expand Up @@ -673,8 +674,7 @@ mod tests {
public_data_tree: start_public_data_tree_snapshot,
};

let tx_effect =
self.build_pre_existing_tx_effects();
let tx_effect = self.build_pre_existing_tx_effects();

let start_sponge_blob = append_tx_effects_for_blob(
tx_effect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use crate::abis::{
previous_rollup_block_data::PreviousRollupBlockData,
previous_rollup_data::PreviousRollupData,
};
use super::abis::tx_effect::TxEffect;
use dep::types::{
abis::{
log_hash::ScopedLogHash,
public_data_write::PublicDataWrite, sponge_blob::SpongeBlob,
},
abis::{log_hash::ScopedLogHash, public_data_write::PublicDataWrite, sponge_blob::SpongeBlob},
constants::{
AZTEC_MAX_EPOCH_DURATION, CONTRACT_CLASS_LOGS_PREFIX, L2_L1_MSGS_PREFIX,
MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX,
Expand All @@ -24,7 +22,6 @@ use dep::types::{
utils::{arrays::{array_concat, array_length, array_merge}, field::field_from_bytes},
};
use blob::blob_public_inputs::BlockBlobPublicInputs;
use super::abis::tx_effect::TxEffect;

/**
* Asserts that the tree formed by rollup circuits is filled greedily from L to R
Expand Down Expand Up @@ -302,7 +299,10 @@ pub(crate) fn append_tx_effects_for_blob(
// TX FEE
// Using 29 bytes to encompass all reasonable fee lengths
tx_effects_hash_input[offset] = field_from_bytes(
array_concat([TX_FEE_PREFIX, 0], tx_effect.transaction_fee.to_be_bytes::<29>()),
array_concat(
[TX_FEE_PREFIX, 0],
tx_effect.transaction_fee.to_be_bytes::<29>(),
),
true,
);
offset += 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
abis::tx_constant_data::TxConstantData, abis::{
accumulated_data::CombinedAccumulatedData,
gas::Gas, validation_requests::RollupValidationRequests,
abis::{
accumulated_data::CombinedAccumulatedData, gas::Gas, tx_constant_data::TxConstantData,
validation_requests::RollupValidationRequests,
},
address::AztecAddress,
constants::KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH,
Expand Down

0 comments on commit 250a23d

Please sign in to comment.