diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp index 21beafda197..21d2aef29b4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp @@ -2,7 +2,7 @@ #include "tx_context.hpp" -#include "aztec3/circuits/abis/historic_block_data.hpp" +#include "aztec3/circuits/abis/block_header.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -10,7 +10,7 @@ namespace aztec3::circuits::abis { -using aztec3::circuits::abis::HistoricBlockData; +using aztec3::circuits::abis::BlockHeader; using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; using std::is_same; @@ -19,11 +19,11 @@ template struct CombinedConstantData { using fr = typename NCT::fr; using boolean = typename NCT::boolean; - HistoricBlockData block_data{}; + BlockHeader block_header{}; TxContext tx_context{}; // for serialization: update up with new fields - MSGPACK_FIELDS(block_data, tx_context); + MSGPACK_FIELDS(block_header, tx_context); boolean operator==(CombinedConstantData const& other) const { return msgpack_derived_equals(*this, other); @@ -34,7 +34,7 @@ template struct CombinedConstantData { static_assert((std::is_same::value)); CombinedConstantData> constant_data = { - block_data.to_circuit_type(builder), + block_header.to_circuit_type(builder), tx_context.to_circuit_type(builder), }; @@ -48,7 +48,7 @@ template struct CombinedConstantData { auto to_native_type = [](T& e) { return e.template to_native_type(); }; CombinedConstantData constant_data = { - to_native_type(block_data), + to_native_type(block_header), to_native_type(tx_context), }; @@ -59,7 +59,7 @@ template struct CombinedConstantData { { static_assert(!(std::is_same::value)); - block_data.set_public(); + block_header.set_public(); tx_context.set_public(); } }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp index 45161128c06..7d07d16fe0a 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp @@ -17,7 +17,7 @@ using aztec3::utils::types::CircuitTypes; using aztec3::utils::types::NativeTypes; using std::is_same; -template struct HistoricBlockData { +template struct BlockHeader { using fr = typename NCT::fr; using boolean = typename NCT::boolean; @@ -43,12 +43,12 @@ template struct HistoricBlockData { public_data_tree_root, global_variables_hash); - boolean operator==(HistoricBlockData const& other) const + boolean operator==(BlockHeader const& other) const { return note_hash_tree_root == other.note_hash_tree_root && nullifier_tree_root == other.nullifier_tree_root && contract_tree_root == other.contract_tree_root && l1_to_l2_messages_tree_root == other.l1_to_l2_messages_tree_root && - blocks_tree_root == other.historic_block_root && + blocks_tree_root == other.blocks_tree_root && private_kernel_vk_tree_root == other.private_kernel_vk_tree_root && public_data_tree_root == other.public_data_tree_root && global_variables_hash == other.global_variables_hash; @@ -68,14 +68,14 @@ template struct HistoricBlockData { global_variables_hash.assert_is_zero(); } - template HistoricBlockData> to_circuit_type(Builder& builder) const + template BlockHeader> to_circuit_type(Builder& builder) const { static_assert((std::is_same::value)); // Capture the circuit builder: auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - HistoricBlockData> data = { + BlockHeader> data = { to_ct(note_hash_tree_root), to_ct(nullifier_tree_root), to_ct(contract_tree_root), to_ct(l1_to_l2_messages_tree_root), to_ct(blocks_tree_root), to_ct(private_kernel_vk_tree_root), to_ct(public_data_tree_root), to_ct(global_variables_hash), @@ -84,12 +84,12 @@ template struct HistoricBlockData { return data; }; - template HistoricBlockData to_native_type() const + template BlockHeader to_native_type() const { static_assert(std::is_same, NCT>::value); auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - HistoricBlockData data = { + BlockHeader data = { to_nt(note_hash_tree_root), to_nt(nullifier_tree_root), to_nt(contract_tree_root), to_nt(l1_to_l2_messages_tree_root), to_nt(blocks_tree_root), to_nt(private_kernel_vk_tree_root), to_nt(public_data_tree_root), to_nt(global_variables_hash), diff --git a/circuits/cpp/src/aztec3/circuits/abis/packers.hpp b/circuits/cpp/src/aztec3/circuits/abis/packers.hpp index 894481245a6..2ee93840908 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/packers.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/packers.hpp @@ -59,7 +59,7 @@ struct ConstantsPacker { NOTE_HASH_SUBTREE_HEIGHT, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, L1_TO_L2_MSG_SUBTREE_HEIGHT), NVP(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -73,7 +73,7 @@ struct ConstantsPacker { MAX_NOTES_PER_PAGE, VIEW_NOTE_ORACLE_RETURN_LENGTH, CALL_CONTEXT_LENGTH, - HISTORIC_BLOCK_DATA_LENGTH, + BLOCK_HEADER_LENGTH, FUNCTION_DATA_LENGTH, CONTRACT_DEPLOYMENT_DATA_LENGTH, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index 5950c4be70d..e06860ce3c2 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -3,7 +3,7 @@ #include "call_context.hpp" #include "contract_deployment_data.hpp" -#include "aztec3/circuits/abis/historic_block_data.hpp" +#include "aztec3/circuits/abis/block_header.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/convert.hpp" @@ -46,7 +46,7 @@ template class PrivateCircuitPublicInputs { fr encrypted_log_preimages_length = 0; fr unencrypted_log_preimages_length = 0; - HistoricBlockData historic_block_data{}; + BlockHeader block_header{}; ContractDeploymentData contract_deployment_data{}; @@ -69,7 +69,7 @@ template class PrivateCircuitPublicInputs { unencrypted_logs_hash, encrypted_log_preimages_length, unencrypted_log_preimages_length, - historic_block_data, + block_header, contract_deployment_data, chain_id, version); @@ -85,9 +85,8 @@ template class PrivateCircuitPublicInputs { unencrypted_logs_hash == other.unencrypted_logs_hash && encrypted_log_preimages_length == other.encrypted_log_preimages_length && unencrypted_log_preimages_length == other.unencrypted_log_preimages_length && - historic_block_data == other.historic_block_data && - contract_deployment_data == other.contract_deployment_data && chain_id == other.chain_id && - version == other.version; + block_header == other.block_header && contract_deployment_data == other.contract_deployment_data && + chain_id == other.chain_id && version == other.version; }; template @@ -122,7 +121,7 @@ template class PrivateCircuitPublicInputs { to_ct(encrypted_log_preimages_length), to_ct(unencrypted_log_preimages_length), - to_circuit_type(historic_block_data), + to_circuit_type(block_header), to_circuit_type(contract_deployment_data), @@ -162,7 +161,7 @@ template class PrivateCircuitPublicInputs { to_nt(encrypted_log_preimages_length), to_nt(unencrypted_log_preimages_length), - to_native_type(historic_block_data), + to_native_type(block_header), to_native_type(contract_deployment_data), @@ -201,7 +200,7 @@ template class PrivateCircuitPublicInputs { inputs.push_back(encrypted_log_preimages_length); inputs.push_back(unencrypted_log_preimages_length); - spread_arr_into_vec(historic_block_data.to_array(), inputs); + spread_arr_into_vec(block_header.to_array(), inputs); inputs.push_back(contract_deployment_data.hash()); @@ -252,7 +251,7 @@ template class OptionalPrivateCircuitPublicInputs { opt_fr encrypted_log_preimages_length; opt_fr unencrypted_log_preimages_length; - std::optional> historic_block_data; + std::optional> block_header; std::optional> contract_deployment_data; @@ -275,7 +274,7 @@ template class OptionalPrivateCircuitPublicInputs { unencrypted_logs_hash, encrypted_log_preimages_length, unencrypted_log_preimages_length, - historic_block_data, + block_header, contract_deployment_data, chain_id, version); @@ -305,7 +304,7 @@ template class OptionalPrivateCircuitPublicInputs { opt_fr const& encrypted_log_preimages_length, opt_fr const& unencrypted_log_preimages_length, - std::optional> const& historic_block_data, + std::optional> const& block_header, std::optional> const& contract_deployment_data, @@ -326,7 +325,7 @@ template class OptionalPrivateCircuitPublicInputs { , unencrypted_logs_hash(unencrypted_logs_hash) , encrypted_log_preimages_length(encrypted_log_preimages_length) , unencrypted_log_preimages_length(unencrypted_log_preimages_length) - , historic_block_data(historic_block_data) + , block_header(block_header) , contract_deployment_data(contract_deployment_data) , chain_id(chain_id) , version(version){}; @@ -359,7 +358,7 @@ template class OptionalPrivateCircuitPublicInputs { new_inputs.encrypted_log_preimages_length = std::nullopt; new_inputs.unencrypted_log_preimages_length = std::nullopt; - new_inputs.historic_block_data = std::nullopt; + new_inputs.block_header = std::nullopt; new_inputs.contract_deployment_data = std::nullopt; @@ -425,7 +424,7 @@ template class OptionalPrivateCircuitPublicInputs { make_unused_element_zero(builder, encrypted_log_preimages_length); make_unused_element_zero(builder, unencrypted_log_preimages_length); - make_unused_element_zero(builder, historic_block_data); + make_unused_element_zero(builder, block_header); make_unused_element_zero(builder, contract_deployment_data); @@ -465,7 +464,7 @@ template class OptionalPrivateCircuitPublicInputs { (*encrypted_log_preimages_length).set_public(); (*unencrypted_log_preimages_length).set_public(); - (*historic_block_data).set_public(); + (*block_header).set_public(); (*contract_deployment_data).set_public(); @@ -507,7 +506,7 @@ template class OptionalPrivateCircuitPublicInputs { to_ct(encrypted_log_preimages_length), to_ct(unencrypted_log_preimages_length), - to_circuit_type(historic_block_data), + to_circuit_type(block_header), to_circuit_type(contract_deployment_data), @@ -549,7 +548,7 @@ template class OptionalPrivateCircuitPublicInputs { to_nt(encrypted_log_preimages_length), to_nt(unencrypted_log_preimages_length), - to_native_type(historic_block_data), + to_native_type(block_header), to_native_type(contract_deployment_data), @@ -592,7 +591,7 @@ template class OptionalPrivateCircuitPublicInputs { inputs.push_back(*encrypted_log_preimages_length); inputs.push_back(*unencrypted_log_preimages_length); - spread_arr_opt_into_vec((*historic_block_data).to_array(), inputs); + spread_arr_opt_into_vec((*block_header).to_array(), inputs); inputs.push_back((*contract_deployment_data).hash()); @@ -630,7 +629,7 @@ template class OptionalPrivateCircuitPublicInputs { .encrypted_log_preimages_length = encrypted_log_preimages_length.value(), .unencrypted_log_preimages_length = unencrypted_log_preimages_length.value(), - .historic_block_data = historic_block_data.value(), + .block_header = block_header.value(), .contract_deployment_data = contract_deployment_data.value(), diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index 75d2b804020..6548b93a28d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -5,7 +5,7 @@ #include "contract_storage_update_request.hpp" #include "../../constants.hpp" -#include "aztec3/circuits/abis/historic_block_data.hpp" +#include "aztec3/circuits/abis/block_header.hpp" #include "aztec3/utils/types/circuit_types.hpp" #include "aztec3/utils/types/native_types.hpp" @@ -42,7 +42,7 @@ template struct PublicCircuitPublicInputs { // variable-length data. fr unencrypted_log_preimages_length = 0; - HistoricBlockData historic_block_data{}; + BlockHeader block_header{}; address prover_address{}; @@ -58,7 +58,7 @@ template struct PublicCircuitPublicInputs { new_l2_to_l1_msgs, unencrypted_logs_hash, unencrypted_log_preimages_length, - historic_block_data, + block_header, prover_address); boolean operator==(PublicCircuitPublicInputs const& other) const @@ -91,7 +91,7 @@ template struct PublicCircuitPublicInputs { .unencrypted_logs_hash = to_ct(unencrypted_logs_hash), .unencrypted_log_preimages_length = to_ct(unencrypted_log_preimages_length), - .historic_block_data = to_ct(historic_block_data), + .block_header = to_ct(block_header), .prover_address = to_ct(prover_address), }; @@ -121,7 +121,7 @@ template struct PublicCircuitPublicInputs { spread_arr_into_vec(unencrypted_logs_hash, inputs); inputs.push_back(unencrypted_log_preimages_length); - spread_arr_into_vec(historic_block_data.to_array(), inputs); + spread_arr_into_vec(block_header.to_array(), inputs); inputs.push_back(prover_address); if (inputs.size() != PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH) { diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index 5b0d5e2ac94..380b1a2eec4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -21,7 +21,7 @@ template struct BaseRollupInputs { AppendOnlyTreeSnapshot start_nullifier_tree_snapshot{}; AppendOnlyTreeSnapshot start_contract_tree_snapshot{}; fr start_public_data_tree_root{}; - AppendOnlyTreeSnapshot start_historic_blocks_tree_snapshot{}; + AppendOnlyTreeSnapshot start_blocks_tree_snapshot{}; std::array, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP> low_nullifier_leaf_preimages{}; std::array, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP> @@ -37,8 +37,8 @@ template struct BaseRollupInputs { std::array, MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP> new_public_data_reads_sibling_paths{}; - std::array, KERNELS_PER_BASE_ROLLUP> - historic_blocks_tree_root_membership_witnesses{}; + std::array, KERNELS_PER_BASE_ROLLUP> + blocks_tree_root_membership_witnesses{}; ConstantRollupData constants{}; @@ -48,7 +48,7 @@ template struct BaseRollupInputs { start_nullifier_tree_snapshot, start_contract_tree_snapshot, start_public_data_tree_root, - start_historic_blocks_tree_snapshot, + start_blocks_tree_snapshot, low_nullifier_leaf_preimages, low_nullifier_membership_witness, new_commitments_subtree_sibling_path, @@ -56,7 +56,7 @@ template struct BaseRollupInputs { new_contracts_subtree_sibling_path, new_public_data_update_requests_sibling_paths, new_public_data_reads_sibling_paths, - historic_blocks_tree_root_membership_witnesses, + blocks_tree_root_membership_witnesses, constants); boolean operator==(BaseRollupInputs const& other) const diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp index d94788674b4..a1cb37b6a66 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/constant_rollup_data.hpp @@ -11,7 +11,7 @@ template struct ConstantRollupData { using fr = typename NCT::fr; // The very latest roots as at the very beginning of the entire rollup: - AppendOnlyTreeSnapshot start_historic_blocks_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot start_blocks_tree_snapshot{}; // Some members of this struct tbd: fr private_kernel_vk_tree_root = 0; @@ -21,7 +21,7 @@ template struct ConstantRollupData { GlobalVariables global_variables{}; - MSGPACK_FIELDS(start_historic_blocks_tree_roots_snapshot, + MSGPACK_FIELDS(start_blocks_tree_snapshot, private_kernel_vk_tree_root, public_kernel_vk_tree_root, base_rollup_vk_hash, diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp index 372390a8c05..c765c9d09ad 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp @@ -25,16 +25,16 @@ template struct RootRollupInputs { AppendOnlyTreeSnapshot start_l1_to_l2_messages_tree_snapshot{}; // inputs required to add the block hash - AppendOnlyTreeSnapshot start_historic_blocks_tree_snapshot{}; - std::array new_historic_blocks_tree_sibling_path{}; + AppendOnlyTreeSnapshot start_blocks_tree_snapshot{}; + std::array new_blocks_tree_sibling_path{}; // For serialization, update with new fields MSGPACK_FIELDS(previous_rollup_data, new_l1_to_l2_messages, new_l1_to_l2_messages_tree_root_sibling_path, start_l1_to_l2_messages_tree_snapshot, - start_historic_blocks_tree_snapshot, - new_historic_blocks_tree_sibling_path); + start_blocks_tree_snapshot, + new_blocks_tree_sibling_path); bool operator==(RootRollupInputs const&) const = default; }; diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp index 51879fd9566..74aff1ba5e8 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp @@ -31,20 +31,20 @@ template struct RootRollupPublicInputs { fr start_public_data_tree_root{}; fr end_public_data_tree_root{}; - AppendOnlyTreeSnapshot start_tree_of_historic_note_hash_tree_roots_snapshot{}; - AppendOnlyTreeSnapshot end_tree_of_historic_note_hash_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot start_tree_of_historical_note_hash_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot end_tree_of_historical_note_hash_tree_roots_snapshot{}; - AppendOnlyTreeSnapshot start_tree_of_historic_contract_tree_roots_snapshot{}; - AppendOnlyTreeSnapshot end_tree_of_historic_contract_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot start_tree_of_historical_contract_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot end_tree_of_historical_contract_tree_roots_snapshot{}; AppendOnlyTreeSnapshot start_l1_to_l2_messages_tree_snapshot{}; AppendOnlyTreeSnapshot end_l1_to_l2_messages_tree_snapshot{}; - AppendOnlyTreeSnapshot start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot{}; - AppendOnlyTreeSnapshot end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot{}; + AppendOnlyTreeSnapshot end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot{}; - AppendOnlyTreeSnapshot start_historic_blocks_tree_snapshot{}; - AppendOnlyTreeSnapshot end_historic_blocks_tree_snapshot{}; + AppendOnlyTreeSnapshot start_blocks_tree_snapshot{}; + AppendOnlyTreeSnapshot end_blocks_tree_snapshot{}; std::array calldata_hash{}; std::array l1_to_l2_messages_hash{}; @@ -60,16 +60,16 @@ template struct RootRollupPublicInputs { end_contract_tree_snapshot, start_public_data_tree_root, end_public_data_tree_root, - start_tree_of_historic_note_hash_tree_roots_snapshot, - end_tree_of_historic_note_hash_tree_roots_snapshot, - start_tree_of_historic_contract_tree_roots_snapshot, - end_tree_of_historic_contract_tree_roots_snapshot, + start_tree_of_historical_note_hash_tree_roots_snapshot, + end_tree_of_historical_note_hash_tree_roots_snapshot, + start_tree_of_historical_contract_tree_roots_snapshot, + end_tree_of_historical_contract_tree_roots_snapshot, start_l1_to_l2_messages_tree_snapshot, end_l1_to_l2_messages_tree_snapshot, - start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot, - end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot, - start_historic_blocks_tree_snapshot, - end_historic_blocks_tree_snapshot, + start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot, + end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot, + start_blocks_tree_snapshot, + end_blocks_tree_snapshot, calldata_hash, l1_to_l2_messages_hash); @@ -83,21 +83,21 @@ template struct RootRollupPublicInputs { write(buf, start_note_hash_tree_snapshot); write(buf, start_nullifier_tree_snapshot); write(buf, start_contract_tree_snapshot); - write(buf, start_tree_of_historic_note_hash_tree_roots_snapshot); - write(buf, start_tree_of_historic_contract_tree_roots_snapshot); + write(buf, start_tree_of_historical_note_hash_tree_roots_snapshot); + write(buf, start_tree_of_historical_contract_tree_roots_snapshot); write(buf, start_public_data_tree_root); write(buf, start_l1_to_l2_messages_tree_snapshot); - write(buf, start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot); - write(buf, start_historic_blocks_tree_snapshot); + write(buf, start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot); + write(buf, start_blocks_tree_snapshot); write(buf, end_note_hash_tree_snapshot); write(buf, end_nullifier_tree_snapshot); write(buf, end_contract_tree_snapshot); - write(buf, end_tree_of_historic_note_hash_tree_roots_snapshot); - write(buf, end_tree_of_historic_contract_tree_roots_snapshot); + write(buf, end_tree_of_historical_note_hash_tree_roots_snapshot); + write(buf, end_tree_of_historical_contract_tree_roots_snapshot); write(buf, end_public_data_tree_root); write(buf, end_l1_to_l2_messages_tree_snapshot); - write(buf, end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot); - write(buf, end_historic_blocks_tree_snapshot); + write(buf, end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot); + write(buf, end_blocks_tree_snapshot); // Stitching calldata hash together auto high_buffer = calldata_hash[0].to_buffer(); diff --git a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp index 6708e266c7d..25c8c81a860 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp +++ b/circuits/cpp/src/aztec3/circuits/apps/opcodes/opcodes.tpp @@ -54,7 +54,7 @@ Note Opcodes::UTXO_SLOAD(UTXOStateVar* utxo_state_var, // TODO within this function: // - Merkle Membership Check using the contract_address, utxo_datum.{sibling_path, leaf_index, - // historic_note_hash_tree_root} + // historical_note_hash_tree_root} return new_note; }; @@ -95,7 +95,7 @@ std::vector Opcodes::UTXO_SLOAD(UTXOSetStateVar* u // TODO within this function: // - Merkle Membership Check using the contract_address, utxo_datum.{sibling_path, leaf_index, - // historic_note_hash_tree_root} + // historical_note_hash_tree_root} new_notes.push_back(new_note); } diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp index 5b6d5a6afdb..08809a8e4e2 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp @@ -93,7 +93,7 @@ OptionalPrivateCircuitPublicInputs transfer(FunctionExecutionContext& exec_c { amount, to.to_field(), asset_id, memo, CT::fr(reveal_msg_sender_to_recipient), fee }); /// TODO: merkle membership check - // public_inputs.historic_note_hash_tree_root + // public_inputs.historical_note_hash_tree_root exec_ctx.finalize(); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp index 5effa070436..d61fcceed27 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp @@ -86,7 +86,7 @@ OptionalPrivateCircuitPublicInputs withdraw(FunctionExecutionContext& exec_c exec_ctx.finalize(); /// TODO: merkle membership check - // public_inputs.historic_note_hash_tree_root + // public_inputs.historical_note_hash_tree_root // info("public inputs: ", public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp index 360dbeb2ecb..c13bd18527b 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/utxo_datum.hpp @@ -26,7 +26,7 @@ template struct UTXOSLoadDatum { std::vector sibling_path; uint32 leaf_index; - fr historic_note_hash_tree_root = 0; + fr historical_note_hash_tree_root = 0; template auto to_circuit_type(Builder& builder) const { @@ -39,7 +39,7 @@ template struct UTXOSLoadDatum { UTXOSLoadDatum, decltype(preimage_ct)> datum = { to_ct(commitment), to_ct(contract_address), preimage_ct, - to_ct(sibling_path), to_ct(leaf_index), to_ct(historic_note_hash_tree_root), + to_ct(sibling_path), to_ct(leaf_index), to_ct(historical_note_hash_tree_root), }; return datum; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index c5b993a340c..f0e23c9e69d 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -53,8 +53,8 @@ void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const } /** - * @brief Validate all read requests against the historic note hash tree root. - * Use their membership witnesses to do so. If the historic root is not yet + * @brief Validate all read requests against the historical note hash tree root. + * Use their membership witnesses to do so. If the historical root is not yet * initialized, initialize it using the first read request here (if present). * * @details More info here: @@ -62,7 +62,7 @@ void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const * - https://discourse.aztec.network/t/spending-notes-which-havent-yet-been-inserted/180 * * @param builder - * @param historic_note_hash_tree_root This is a reference to the historic root which all + * @param historical_note_hash_tree_root This is a reference to the historical root which all * read requests are checked against here. * @param read_requests the commitments being read by this private call - 'transient note reads' here are * `inner_note_hashes` (not yet siloed, not unique), but 'pre-existing note reads' are `unique_siloed_note_hashes` @@ -70,7 +70,7 @@ void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const * for a given request which is essentially a membership check */ void common_validate_read_requests(DummyBuilder& builder, - NT::fr const& historic_note_hash_tree_root, + NT::fr const& historical_note_hash_tree_root, std::array const& read_requests, std::array, MAX_READ_REQUESTS_PER_CALL> const& read_request_membership_witnesses) @@ -92,12 +92,12 @@ void common_validate_read_requests(DummyBuilder& builder, const auto& root_for_read_request = root_from_sibling_path(read_request, witness.leaf_index, witness.sibling_path); builder.do_assert( - root_for_read_request == historic_note_hash_tree_root, + root_for_read_request == historical_note_hash_tree_root, format("note hash tree root mismatch at read_request[", rr_idx, "]", "\n\texpected root: ", - historic_note_hash_tree_root, + historical_note_hash_tree_root, "\n\tbut got root*: ", root_for_read_request, "\n\tread_request**: ", @@ -429,7 +429,7 @@ void common_contract_logic(DummyBuilder& builder, private_call.contract_leaf_membership_witness.sibling_path); auto const& purported_contract_tree_root = - private_call.call_stack_item.public_inputs.historic_block_data.contract_tree_root; + private_call.call_stack_item.public_inputs.block_header.contract_tree_root; builder.do_assert( computed_contract_tree_root == purported_contract_tree_root, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp index ee0e5c350fb..2e1191a252f 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -31,7 +31,7 @@ using DummyBuilder = aztec3::utils::DummyCircuitBuilder; void common_validate_call_stack(DummyBuilder& builder, PrivateCallData const& private_call); void common_validate_read_requests(DummyBuilder& builder, - NT::fr const& historic_note_hash_tree_root, + NT::fr const& historical_note_hash_tree_root, std::array const& read_requests, std::array, MAX_READ_REQUESTS_PER_CALL> const& read_request_membership_witnesses); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp index e5c70bbd174..1d8fc42f8bc 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp @@ -1,8 +1,8 @@ #include "common.hpp" #include "init.hpp" +#include "aztec3/circuits/abis/block_header.hpp" #include "aztec3/circuits/abis/combined_constant_data.hpp" -#include "aztec3/circuits/abis/historic_block_data.hpp" #include "aztec3/circuits/abis/private_kernel/private_kernel_inputs_init.hpp" #include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" @@ -26,7 +26,7 @@ void initialize_end_values(PrivateKernelInputsInit const& private_inputs, // Define the constants data. auto const& private_call_public_inputs = private_inputs.private_call.call_stack_item.public_inputs; auto const constants = CombinedConstantData{ - .block_data = private_call_public_inputs.historic_block_data, + .block_header = private_call_public_inputs.block_header, .tx_context = private_inputs.tx_request.tx_context, }; @@ -167,7 +167,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyCircuit common_validate_read_requests( builder, - public_inputs.constants.block_data.note_hash_tree_root, + public_inputs.constants.block_header.note_hash_tree_root, private_inputs.private_call.call_stack_item.public_inputs.read_requests, // read requests from private call private_inputs.private_call.read_request_membership_witnesses); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp index f46023cae17..f502436d603 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp @@ -433,7 +433,7 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_request) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak read_request so it gives wrong root when paired with its sibling path read_requests[1] += 1; @@ -467,7 +467,7 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_leaf_index) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak leaf index so it gives wrong root when paired with its request and sibling path read_request_membership_witnesses[1].leaf_index += 1; @@ -500,7 +500,7 @@ TEST_F(native_private_kernel_init_tests, native_read_request_bad_sibling_path) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak sibling path so it gives wrong root when paired with its request read_request_membership_witnesses[1].sibling_path[1] += 1; @@ -534,7 +534,7 @@ TEST_F(native_private_kernel_init_tests, native_read_request_root_mismatch) _transient_read_requests0, _transient_read_request_membership_witnesses0, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; auto [read_requests1, read_request_membership_witnesses1, _transient_read_requests1, @@ -613,7 +613,7 @@ TEST_F(native_private_kernel_init_tests, native_one_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 1); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; @@ -650,7 +650,7 @@ TEST_F(native_private_kernel_init_tests, native_two_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; @@ -687,7 +687,7 @@ TEST_F(native_private_kernel_init_tests, native_max_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; @@ -728,7 +728,7 @@ TEST_F(native_private_kernel_init_tests, native_one_transient_read_requests_work transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 1); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // Make the read request transient read_requests[0] = transient_read_requests[0]; @@ -766,7 +766,7 @@ TEST_F(native_private_kernel_init_tests, native_max_read_requests_one_transient_ transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; // Make the read request at position 1 transient @@ -804,7 +804,7 @@ TEST_F(native_private_kernel_init_tests, native_max_read_requests_all_transient_ transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = transient_read_requests; private_inputs.private_call.read_request_membership_witnesses = transient_read_request_membership_witnesses; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp index 371bcbf81dd..d98423e8322 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp @@ -58,9 +58,9 @@ void pop_and_validate_this_private_call_hash( void validate_contract_tree_root(DummyCircuitBuilder& builder, PrivateKernelInputsInner const& private_inputs) { auto const& purported_contract_tree_root = - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.contract_tree_root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.contract_tree_root; auto const& previous_kernel_contract_tree_root = - private_inputs.previous_kernel.public_inputs.constants.block_data.contract_tree_root; + private_inputs.previous_kernel.public_inputs.constants.block_header.contract_tree_root; builder.do_assert( purported_contract_tree_root == previous_kernel_contract_tree_root, "purported_contract_tree_root doesn't match previous_kernel_contract_tree_root", @@ -114,7 +114,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyCircuitBu common_validate_read_requests( builder, - public_inputs.constants.block_data.note_hash_tree_root, + public_inputs.constants.block_header.note_hash_tree_root, private_inputs.private_call.call_stack_item.public_inputs.read_requests, // read requests from private call private_inputs.private_call.read_request_membership_witnesses); @@ -122,7 +122,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyCircuitBu // TODO(dbanks12): feels like update_end_values should happen later common_update_end_values(builder, private_inputs.private_call, public_inputs); - // ensure that historic/purported contract tree root matches the one in previous kernel + // ensure that historical/purported contract tree root matches the one in previous kernel validate_contract_tree_root(builder, private_inputs); const auto private_call_stack_item = private_inputs.private_call.call_stack_item; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp index 4c1d83856a0..d29c08eb590 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp @@ -93,8 +93,8 @@ TEST_F(native_private_kernel_inner_tests, private_function_incorrect_contract_tr { auto private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); - // Set historic_tree_root to a random scalar. - private_inputs.previous_kernel.public_inputs.constants.block_data.contract_tree_root = NT::fr::random_element(); + // Set historical_tree_root to a random scalar. + private_inputs.previous_kernel.public_inputs.constants.block_header.contract_tree_root = NT::fr::random_element(); // Invoke the native private kernel circuit DummyBuilder builder = DummyBuilder("private_kernel_tests__private_function_incorrect_contract_tree_root_fails"); @@ -477,8 +477,8 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_request) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak read_request so it gives wrong root when paired with its sibling path read_requests[1] += 1; @@ -487,7 +487,7 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_request) private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -516,8 +516,8 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_leaf_index) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak leaf index so it gives wrong root when paired with its request and sibling path read_request_membership_witnesses[1].leaf_index += 1; @@ -525,7 +525,7 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_leaf_index) private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -554,8 +554,8 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_sibling_path) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // tweak sibling path so it gives wrong root when paired with its request read_request_membership_witnesses[1].sibling_path[1] += 1; @@ -563,7 +563,7 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_bad_sibling_path) private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -593,8 +593,8 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_root_mismatch) _transient_read_requests0, _transient_read_request_membership_witnesses0, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; auto [read_requests1, read_request_membership_witnesses1, _transient_read_requests1, @@ -615,7 +615,7 @@ TEST_F(native_private_kernel_inner_tests, native_read_request_root_mismatch) private_inputs.private_call.read_request_membership_witnesses = bad_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -679,8 +679,8 @@ TEST_F(native_private_kernel_inner_tests, native_one_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 1); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; @@ -720,8 +720,8 @@ TEST_F(native_private_kernel_inner_tests, native_two_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 2); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; @@ -761,13 +761,13 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_works) _transient_read_requests, _transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = read_requests; private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -803,7 +803,7 @@ TEST_F(native_private_kernel_inner_tests, native_one_transient_read_requests_wor transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, 1); - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // Make the read request transient read_requests[0] = transient_read_requests[0]; @@ -812,7 +812,7 @@ TEST_F(native_private_kernel_inner_tests, native_one_transient_read_requests_wor private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -847,8 +847,8 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_one_transient transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; // Make the read request at position 1 transient read_requests[1] = transient_read_requests[1]; @@ -857,7 +857,7 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_one_transient private_inputs.private_call.read_request_membership_witnesses = read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); @@ -894,13 +894,13 @@ TEST_F(native_private_kernel_inner_tests, native_max_read_requests_all_transient transient_read_requests, transient_read_request_membership_witnesses, root] = get_random_reads(first_nullifier, contract_address, MAX_READ_REQUESTS_PER_CALL); - private_inputs.previous_kernel.public_inputs.constants.block_data.note_hash_tree_root = root; - private_inputs.private_call.call_stack_item.public_inputs.historic_block_data.note_hash_tree_root = root; + private_inputs.previous_kernel.public_inputs.constants.block_header.note_hash_tree_root = root; + private_inputs.private_call.call_stack_item.public_inputs.block_header.note_hash_tree_root = root; private_inputs.private_call.call_stack_item.public_inputs.read_requests = transient_read_requests; private_inputs.private_call.read_request_membership_witnesses = transient_read_request_membership_witnesses; // We need to update the previous_kernel's private_call_stack because the current_call_stack_item has changed - // i.e. we changed the public_inputs->read_requests and public_inputs->historic_note_hash_tree_root of the + // i.e. we changed the public_inputs->read_requests and public_inputs->historical_note_hash_tree_root of the // current_call_stack_item private_inputs.previous_kernel.public_inputs.end.private_call_stack[0] = private_inputs.private_call.call_stack_item.hash(); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp index 33d0b4cb792..f068662a3e5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -3,6 +3,7 @@ #include "index.hpp" #include "init.hpp" +#include "aztec3/circuits/abis/block_header.hpp" #include "aztec3/circuits/abis/call_context.hpp" #include "aztec3/circuits/abis/call_stack_item.hpp" #include "aztec3/circuits/abis/combined_accumulated_data.hpp" @@ -10,7 +11,6 @@ #include "aztec3/circuits/abis/complete_address.hpp" #include "aztec3/circuits/abis/contract_deployment_data.hpp" #include "aztec3/circuits/abis/function_data.hpp" -#include "aztec3/circuits/abis/historic_block_data.hpp" #include "aztec3/circuits/abis/private_circuit_public_inputs.hpp" #include "aztec3/circuits/abis/private_kernel/private_call_data.hpp" #include "aztec3/circuits/abis/tx_context.hpp" @@ -28,13 +28,13 @@ namespace aztec3::circuits::kernel::private_kernel::testing_harness { +using aztec3::circuits::abis::BlockHeader; using aztec3::circuits::abis::CallContext; using aztec3::circuits::abis::CallStackItem; using aztec3::circuits::abis::CombinedAccumulatedData; using aztec3::circuits::abis::CombinedConstantData; using aztec3::circuits::abis::ContractDeploymentData; using aztec3::circuits::abis::FunctionData; -using aztec3::circuits::abis::HistoricBlockData; using aztec3::circuits::abis::PrivateCircuitPublicInputs; using aztec3::circuits::abis::PrivateTypes; using aztec3::circuits::abis::TxContext; @@ -52,7 +52,7 @@ using aztec3::utils::array_length; * @param first_nullifier used when computing nonce for unique_siloed_commitments (note hash tree leaves) * @param contract_address address to use when siloing read requests * @param num_read_requests if negative, use random num. Must be < MAX_READ_REQUESTS_PER_CALL - * @return std::tuple + * @return std::tuple */ std::tuple, std::array, MAX_READ_REQUESTS_PER_CALL>, @@ -285,7 +285,7 @@ std::pair, ContractDeploymentData> create_private_call_d OptionalPrivateCircuitPublicInputs const opt_private_circuit_public_inputs = func(ctx, args_vec); private_circuit_public_inputs = opt_private_circuit_public_inputs.remove_optionality(); // TODO(suyash): this should likely be handled as part of the DB/Oracle/Context infrastructure - private_circuit_public_inputs.historic_block_data.contract_tree_root = contract_tree_root; + private_circuit_public_inputs.block_header.contract_tree_root = contract_tree_root; private_circuit_public_inputs.encrypted_logs_hash = encrypted_logs_hash; private_circuit_public_inputs.unencrypted_logs_hash = unencrypted_logs_hash; @@ -305,7 +305,7 @@ std::pair, ContractDeploymentData> create_private_call_d .unencrypted_logs_hash = unencrypted_logs_hash, .encrypted_log_preimages_length = encrypted_log_preimages_length, .unencrypted_log_preimages_length = unencrypted_log_preimages_length, - .historic_block_data = HistoricBlockData{ .contract_tree_root = contract_tree_root }, + .block_header = BlockHeader{ .contract_tree_root = contract_tree_root }, .contract_deployment_data = contract_deployment_data, }; } @@ -489,10 +489,10 @@ PrivateKernelInputsInner do_private_call_get_kernel_inputs_inner( // Fill in some important fields in public inputs mock_previous_kernel.public_inputs.end.private_call_stack = initial_kernel_private_call_stack; mock_previous_kernel.public_inputs.constants = CombinedConstantData{ - .block_data = - HistoricBlockData{ - .note_hash_tree_root = private_circuit_public_inputs.historic_block_data.note_hash_tree_root, - .contract_tree_root = private_circuit_public_inputs.historic_block_data.contract_tree_root, + .block_header = + BlockHeader{ + .note_hash_tree_root = private_circuit_public_inputs.block_header.note_hash_tree_root, + .contract_tree_root = private_circuit_public_inputs.block_header.contract_tree_root, }, .tx_context = tx_context, }; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp index 0da5106b240..8ed96456998 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.hpp @@ -89,7 +89,7 @@ inline const auto& get_empty_contract_siblings() * read_request_memberships_witnesses, * transient_read_requests, * transient_read_request_memberships_witnesses, - * historic_note_hash_tree_root> + * historical_note_hash_tree_root> */ std::tuple, std::array, MAX_READ_REQUESTS_PER_CALL>, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index e136a00d265..0e9c5394aa8 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -26,13 +26,13 @@ namespace aztec3::circuits::kernel::public_kernel { using DummyCircuitBuilder = aztec3::utils::DummyCircuitBuilder; using aztec3::circuits::abis::public_kernel::PublicKernelInputs; using NT = aztec3::utils::types::NativeTypes; +using aztec3::circuits::abis::BlockHeader; using aztec3::circuits::abis::CallContext; using aztec3::circuits::abis::CallStackItem; using aztec3::circuits::abis::CombinedAccumulatedData; using aztec3::circuits::abis::CombinedConstantData; using aztec3::circuits::abis::ContractStorageRead; using aztec3::circuits::abis::ContractStorageUpdateRequest; -using aztec3::circuits::abis::HistoricBlockData; using aztec3::circuits::abis::NewContractData; using aztec3::circuits::abis::OptionallyRevealedData; using aztec3::circuits::abis::PreviousKernelData; @@ -328,7 +328,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat std::array const unencrypted_logs_hash = array_of_values(seed, NUM_FIELDS_PER_SHA256); fr const unencrypted_log_preimages_length = ++seed; - HistoricBlockData block_data = { + BlockHeader block_header = { .note_hash_tree_root = ++seed, .nullifier_tree_root = ++seed, .contract_tree_root = ++seed, @@ -352,7 +352,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .new_l2_to_l1_msgs = new_l2_to_l1_msgs, .unencrypted_logs_hash = unencrypted_logs_hash, .unencrypted_log_preimages_length = unencrypted_log_preimages_length, - .historic_block_data = block_data, + .block_header = block_header, }; const PublicCallStackItem call_stack_item{ @@ -369,18 +369,18 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat }; // TODO(914) Should this be unused? - [[maybe_unused]] HistoricBlockData const historic_tree_roots = { + [[maybe_unused]] BlockHeader const historical_tree_roots = { .note_hash_tree_root = 1000, .contract_tree_root = 2000, .l1_to_l2_messages_tree_root = 3000, .private_kernel_vk_tree_root = 4000, }; - CombinedConstantData const end_constants = { .block_data = - HistoricBlockData{ .note_hash_tree_root = ++seed, - .nullifier_tree_root = ++seed, - .contract_tree_root = ++seed, - .private_kernel_vk_tree_root = ++seed }, + CombinedConstantData const end_constants = { .block_header = + BlockHeader{ .note_hash_tree_root = ++seed, + .nullifier_tree_root = ++seed, + .contract_tree_root = ++seed, + .private_kernel_vk_tree_root = ++seed }, .tx_context = TxContext{ .is_fee_payment_tx = false, .is_rebate_payment_tx = false, diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index a5109cabf3b..652e6b0ca52 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -628,26 +628,26 @@ TEST_F(base_rollup_tests, native_calldata_hash) // run_cbind(inputs, outputs); } -TEST_F(base_rollup_tests, native_compute_membership_historic_blocks_tree_negative) +TEST_F(base_rollup_tests, native_compute_membership_blocks_tree_negative) { // WRITE a negative test that will fail the inclusion proof // Test membership works for empty trees DummyCircuitBuilder builder = - DummyCircuitBuilder("base_rollup_tests__native_compute_membership_historic_private_data_negative"); + DummyCircuitBuilder("base_rollup_tests__native_compute_membership_historical_private_data_negative"); std::array, 2> const kernel_data = { get_empty_kernel(), get_empty_kernel() }; BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data); MemoryStore blocks_store; - auto blocks_tree = MerkleTree(blocks_store, HISTORIC_BLOCKS_TREE_HEIGHT); + auto blocks_tree = MerkleTree(blocks_store, BLOCKS_TREE_HEIGHT); - // Create an INCORRECT sibling path for the note hash tree root in the historic tree roots. + // Create an INCORRECT sibling path for the note hash tree root in the historical tree roots. auto hash_path = blocks_tree.get_sibling_path(0); - std::array sibling_path{}; - for (size_t i = 0; i < HISTORIC_BLOCKS_TREE_HEIGHT; ++i) { + std::array sibling_path{}; + for (size_t i = 0; i < BLOCKS_TREE_HEIGHT; ++i) { sibling_path[i] = hash_path[i] + 1; } - inputs.historic_blocks_tree_root_membership_witnesses[0] = { + inputs.blocks_tree_root_membership_witnesses[0] = { .leaf_index = 0, .sibling_path = sibling_path, }; @@ -658,8 +658,7 @@ TEST_F(base_rollup_tests, native_compute_membership_historic_blocks_tree_negativ ASSERT_TRUE(builder.failed()); ASSERT_EQ(builder.get_first_failure().message, "Membership check failed: base_rollup_circuit: historical root is in rollup constants but not in " - "historic block tree roots at kernel input 0 to this " - "base rollup circuit"); + "blocks tree at kernel input 0 to this base rollup circuit"); } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index a75226964e5..1b2fa67ea7d 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -132,42 +132,41 @@ NT::fr calculate_commitments_subtree(DummyBuilder& builder, BaseRollupInputs con * @param constantBaseRollupData * @param baseRollupInputs */ -void perform_historical_blocks_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) +void perform_blocks_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { - // For each of the historic_note_hash_tree_membership_checks, we need to do an inclusion proof + // For each of the historical_note_hash_tree_membership_checks, we need to do an inclusion proof // against the historical root provided in the rollup constants - auto historic_root = baseRollupInputs.constants.start_historic_blocks_tree_roots_snapshot.root; + auto historical_root = baseRollupInputs.constants.start_blocks_tree_snapshot.root; for (size_t i = 0; i < 2; i++) { // Rebuild the block hash - auto historic_block = baseRollupInputs.kernel_data[i].public_inputs.constants.block_data; + auto historical_block = baseRollupInputs.kernel_data[i].public_inputs.constants.block_header; - auto note_hash_tree_root = historic_block.note_hash_tree_root; - auto nullifier_tree_root = historic_block.nullifier_tree_root; - auto contract_tree_root = historic_block.contract_tree_root; - auto l1_to_l2_messages_tree_root = historic_block.l1_to_l2_messages_tree_root; - auto public_data_tree_root = historic_block.public_data_tree_root; + auto note_hash_tree_root = historical_block.note_hash_tree_root; + auto nullifier_tree_root = historical_block.nullifier_tree_root; + auto contract_tree_root = historical_block.contract_tree_root; + auto l1_to_l2_messages_tree_root = historical_block.l1_to_l2_messages_tree_root; + auto public_data_tree_root = historical_block.public_data_tree_root; - auto previous_block_hash = compute_block_hash(historic_block.global_variables_hash, + auto previous_block_hash = compute_block_hash(historical_block.global_variables_hash, note_hash_tree_root, nullifier_tree_root, contract_tree_root, l1_to_l2_messages_tree_root, public_data_tree_root); - abis::MembershipWitness const historic_root_witness = - baseRollupInputs.historic_blocks_tree_root_membership_witnesses[i]; - - check_membership( - builder, - previous_block_hash, - historic_root_witness.leaf_index, - historic_root_witness.sibling_path, - historic_root, - format(BASE_CIRCUIT_ERROR_MESSAGE_BEGINNING, - "historical root is in rollup constants but not in historic block tree roots at kernel input ", - i, - " to this base rollup circuit")); + abis::MembershipWitness const historical_root_witness = + baseRollupInputs.blocks_tree_root_membership_witnesses[i]; + + check_membership(builder, + previous_block_hash, + historical_root_witness.leaf_index, + historical_root_witness.sibling_path, + historical_root, + format(BASE_CIRCUIT_ERROR_MESSAGE_BEGINNING, + "historical root is in rollup constants but not in blocks tree at kernel input ", + i, + " to this base rollup circuit")); } } @@ -524,8 +523,8 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRol std::array const calldata_hash = components::compute_kernels_calldata_hash(baseRollupInputs.kernel_data); - // Perform membership checks that the notes provided exist within the historic trees data - perform_historical_blocks_tree_membership_checks(builder, baseRollupInputs); + // Perform membership checks that the notes provided exist within the historical trees data + perform_blocks_tree_membership_checks(builder, baseRollupInputs); AggregationObject const aggregation_object = aggregate_proofs(baseRollupInputs); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index b9c05fe4bca..ed6f6ca0c25 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -177,7 +177,7 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) auto nullifier_tree = get_initial_nullifier_tree_empty(); MemoryStore blocks_tree_store; - MerkleTree blocks_tree(blocks_tree_store, HISTORIC_BLOCKS_TREE_HEIGHT); + MerkleTree blocks_tree(blocks_tree_store, BLOCKS_TREE_HEIGHT); std::array kernels = { get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel() @@ -292,8 +292,8 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) rootRollupInputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.end_contract_tree_snapshot); ASSERT_EQ(outputs.end_l1_to_l2_messages_tree_snapshot, end_l1_to_l2_messages_tree_snapshot); - ASSERT_EQ(outputs.start_historic_blocks_tree_snapshot, start_blocks_tree_snapshot); - ASSERT_EQ(outputs.end_historic_blocks_tree_snapshot, end_blocks_tree_snapshot); + ASSERT_EQ(outputs.start_blocks_tree_snapshot, start_blocks_tree_snapshot); + ASSERT_EQ(outputs.end_blocks_tree_snapshot, end_blocks_tree_snapshot); // Compute the expected calldata hash for the root rollup (including the l2 -> l1 messages) auto left = components::compute_kernels_calldata_hash({ kernels[0], kernels[1] }); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp index f2c5fd304a4..3c801da601f 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp @@ -107,7 +107,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu "l1 to l2 message tree not empty at location where subtree would be inserted")); // Build the block hash for this iteration from the tree roots and global variables - // Then insert the block into the historic blocks tree + // Then insert the block into the blocks tree auto block_hash = compute_block_hash_with_globals(left.constants.global_variables, right.end_note_hash_tree_snapshot.root, right.end_nullifier_tree_snapshot.root, @@ -115,16 +115,16 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu new_l1_to_l2_messages_tree_snapshot.root, right.end_public_data_tree_root); - // Update the historic blocks tree - auto end_historic_blocks_tree_snapshot = components::insert_subtree_to_snapshot_tree( + // Update the blocks tree + auto end_blocks_tree_snapshot = components::insert_subtree_to_snapshot_tree( builder, - rootRollupInputs.start_historic_blocks_tree_snapshot, - rootRollupInputs.new_historic_blocks_tree_sibling_path, + rootRollupInputs.start_blocks_tree_snapshot, + rootRollupInputs.new_blocks_tree_sibling_path, fr::zero(), block_hash, 0, format(ROOT_CIRCUIT_ERROR_MESSAGE_BEGINNING, - "historic blocks tree roots not empty at location where subtree would be inserted")); + "blocks tree roots not empty at location where subtree would be inserted")); RootRollupPublicInputs public_inputs = { @@ -140,8 +140,8 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu .end_public_data_tree_root = right.end_public_data_tree_root, .start_l1_to_l2_messages_tree_snapshot = rootRollupInputs.start_l1_to_l2_messages_tree_snapshot, .end_l1_to_l2_messages_tree_snapshot = new_l1_to_l2_messages_tree_snapshot, - .start_historic_blocks_tree_snapshot = rootRollupInputs.start_historic_blocks_tree_snapshot, - .end_historic_blocks_tree_snapshot = end_historic_blocks_tree_snapshot, + .start_blocks_tree_snapshot = rootRollupInputs.start_blocks_tree_snapshot, + .end_blocks_tree_snapshot = end_blocks_tree_snapshot, .calldata_hash = components::compute_calldata_hash(rootRollupInputs.previous_rollup_data), .l1_to_l2_messages_hash = compute_messages_hash(rootRollupInputs.new_l1_to_l2_messages) }; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index a872a26497b..72fee73a733 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -86,8 +86,8 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne { // @todo Look at the starting points for all of these. // By supporting as inputs we can make very generic tests, where it is trivial to try new setups. - MemoryStore historic_blocks_tree_store; - MerkleTree historic_blocks_tree = MerkleTree(historic_blocks_tree_store, HISTORIC_BLOCKS_TREE_HEIGHT); + MemoryStore blocks_tree_store; + MerkleTree blocks_tree = MerkleTree(blocks_tree_store, BLOCKS_TREE_HEIGHT); BaseRollupInputs baseRollupInputs = { .kernel_data = kernel_data, @@ -154,31 +154,31 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne baseRollupInputs.start_public_data_tree_root = public_data_tree.root(); - // create the original historic blocks tree leaf + // create the original blocks tree leaf auto block_hash = compute_block_hash(prev_global_variables_hash, note_hash_tree.root(), nullifier_tree.root(), contract_tree.root(), l1_to_l2_msg_tree.root(), public_data_tree.root()); - historic_blocks_tree.update_element(0, block_hash); + blocks_tree.update_element(0, block_hash); - ConstantRollupData const constantRollupData = { .start_historic_blocks_tree_roots_snapshot = { - .root = historic_blocks_tree.root(), + ConstantRollupData const constantRollupData = { .start_blocks_tree_snapshot = { + .root = blocks_tree.root(), .next_available_leaf_index = 1, } }; baseRollupInputs.constants = constantRollupData; - // Set historic tree roots data in the public inputs. + // Set historical tree roots data in the public inputs. for (size_t i = 0; i < 2; i++) { - kernel_data[i].public_inputs.constants.block_data.note_hash_tree_root = note_hash_tree.root(); - kernel_data[i].public_inputs.constants.block_data.nullifier_tree_root = nullifier_tree.root(); - kernel_data[i].public_inputs.constants.block_data.nullifier_tree_root = nullifier_tree.root(); - kernel_data[i].public_inputs.constants.block_data.contract_tree_root = contract_tree.root(); - kernel_data[i].public_inputs.constants.block_data.l1_to_l2_messages_tree_root = l1_to_l2_msg_tree.root(); - kernel_data[i].public_inputs.constants.block_data.blocks_tree_root = historic_blocks_tree.root(); - kernel_data[i].public_inputs.constants.block_data.public_data_tree_root = public_data_tree.root(); - kernel_data[i].public_inputs.constants.block_data.global_variables_hash = prev_global_variables_hash; + kernel_data[i].public_inputs.constants.block_header.note_hash_tree_root = note_hash_tree.root(); + kernel_data[i].public_inputs.constants.block_header.nullifier_tree_root = nullifier_tree.root(); + kernel_data[i].public_inputs.constants.block_header.nullifier_tree_root = nullifier_tree.root(); + kernel_data[i].public_inputs.constants.block_header.contract_tree_root = contract_tree.root(); + kernel_data[i].public_inputs.constants.block_header.l1_to_l2_messages_tree_root = l1_to_l2_msg_tree.root(); + kernel_data[i].public_inputs.constants.block_header.blocks_tree_root = blocks_tree.root(); + kernel_data[i].public_inputs.constants.block_header.public_data_tree_root = public_data_tree.root(); + kernel_data[i].public_inputs.constants.block_header.global_variables_hash = prev_global_variables_hash; } // Then we collect all sibling paths for the reads in the left tx, and then apply the update requests while @@ -207,13 +207,13 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne } } - // Get historic_root sibling paths - baseRollupInputs.historic_blocks_tree_root_membership_witnesses[0] = { + // Get historical_root sibling paths + baseRollupInputs.blocks_tree_root_membership_witnesses[0] = { .leaf_index = 0, - .sibling_path = get_sibling_path(historic_blocks_tree, 0, 0), + .sibling_path = get_sibling_path(blocks_tree, 0, 0), }; - baseRollupInputs.historic_blocks_tree_root_membership_witnesses[1] = - baseRollupInputs.historic_blocks_tree_root_membership_witnesses[0]; + baseRollupInputs.blocks_tree_root_membership_witnesses[1] = + baseRollupInputs.blocks_tree_root_membership_witnesses[0]; baseRollupInputs.kernel_data = kernel_data; @@ -378,8 +378,8 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, MemoryStore public_data_tree_store; MerkleTree public_data_tree(public_data_tree_store, PUBLIC_DATA_TREE_HEIGHT); - MemoryStore historic_blocks_tree_store; - MerkleTree historic_blocks_tree(historic_blocks_tree_store, HISTORIC_BLOCKS_TREE_HEIGHT); + MemoryStore blocks_tree_store; + MerkleTree blocks_tree(blocks_tree_store, BLOCKS_TREE_HEIGHT); // Start blocks tree auto block_hash = compute_block_hash_with_globals(globals, @@ -388,16 +388,16 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, contract_tree.root(), l1_to_l2_msg_tree.root(), public_data_tree.root()); - historic_blocks_tree.update_element(0, block_hash); + blocks_tree.update_element(0, block_hash); // Blocks tree snapshots - AppendOnlyTreeSnapshot const start_historic_blocks_tree_snapshot = { - .root = historic_blocks_tree.root(), + AppendOnlyTreeSnapshot const start_blocks_tree_snapshot = { + .root = blocks_tree.root(), .next_available_leaf_index = 1, }; // Blocks tree - auto blocks_tree_sibling_path = get_sibling_path(historic_blocks_tree, 1, 0); + auto blocks_tree_sibling_path = get_sibling_path(blocks_tree, 1, 0); // l1 to l2 tree auto l1_to_l2_tree_sibling_path = @@ -414,8 +414,8 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, .new_l1_to_l2_messages = l1_to_l2_messages, .new_l1_to_l2_messages_tree_root_sibling_path = l1_to_l2_tree_sibling_path, .start_l1_to_l2_messages_tree_snapshot = start_l1_to_l2_msg_tree_snapshot, - .start_historic_blocks_tree_snapshot = start_historic_blocks_tree_snapshot, - .new_historic_blocks_tree_sibling_path = blocks_tree_sibling_path, + .start_blocks_tree_snapshot = start_blocks_tree_snapshot, + .new_blocks_tree_sibling_path = blocks_tree_sibling_path, }; return rootRollupInputs; } diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index feb162d9a87..39062de3b55 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -104,7 +104,7 @@ constexpr size_t NOTE_HASH_TREE_HEIGHT = 32; constexpr size_t PUBLIC_DATA_TREE_HEIGHT = 254; constexpr size_t NULLIFIER_TREE_HEIGHT = 20; constexpr size_t L1_TO_L2_MSG_TREE_HEIGHT = 16; -constexpr size_t HISTORIC_BLOCKS_TREE_HEIGHT = 16; +constexpr size_t BLOCKS_TREE_HEIGHT = 16; constexpr size_t ROLLUP_VK_TREE_HEIGHT = 8; // TODO: update @@ -315,7 +315,7 @@ constexpr size_t VIEW_NOTE_ORACLE_RETURN_LENGTH = MAX_NOTES_PER_PAGE * (MAX_NOTE constexpr size_t CALL_CONTEXT_LENGTH = 7; // Must be updated if any data is added into the block hash calculation. -constexpr size_t HISTORIC_BLOCK_DATA_LENGTH = 7; +constexpr size_t BLOCK_HEADER_LENGTH = 7; constexpr size_t FUNCTION_DATA_LENGTH = 4; constexpr size_t CONTRACT_DEPLOYMENT_DATA_LENGTH = 6; @@ -327,16 +327,16 @@ constexpr size_t PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = + RETURN_VALUES_LENGTH + MAX_READ_REQUESTS_PER_CALL + MAX_PENDING_READ_REQUESTS_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL + 2 * MAX_NEW_NULLIFIERS_PER_CALL + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + NUM_FIELDS_PER_SHA256 + - NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths - + HISTORIC_BLOCK_DATA_LENGTH + CONTRACT_DEPLOYMENT_DATA_LENGTH + 2; // + 2 for chain_id and version + NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths + + BLOCK_HEADER_LENGTH + CONTRACT_DEPLOYMENT_DATA_LENGTH + 2; // + 2 for chain_id and version constexpr size_t PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 1 + 1 // call_context_hash + args_hash + RETURN_VALUES_LENGTH + MAX_READ_REQUESTS_PER_CALL + MAX_PENDING_READ_REQUESTS_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL + 2 * MAX_NEW_NULLIFIERS_PER_CALL + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + NUM_FIELDS_PER_SHA256 + - NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths - + HISTORIC_BLOCK_DATA_LENGTH + 3; // + 3 for contract_deployment_data.hash(), chain_id, version + NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths + + BLOCK_HEADER_LENGTH + 3; // + 3 for contract_deployment_data.hash(), chain_id, version constexpr size_t CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3; constexpr size_t CONTRACT_STORAGE_READ_LENGTH = 2; @@ -347,15 +347,15 @@ constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL * CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH + MAX_PUBLIC_DATA_READS_PER_CALL * CONTRACT_STORAGE_READ_LENGTH + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + - NUM_FIELDS_PER_SHA256 + 1 + // + 1 for unencrypted logs preimage length - HISTORIC_BLOCK_DATA_LENGTH + 2; // + 2 for chain_id and version + NUM_FIELDS_PER_SHA256 + 1 + // + 1 for unencrypted logs preimage length + BLOCK_HEADER_LENGTH + 2; // + 2 for chain_id and version constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 2 + RETURN_VALUES_LENGTH + // + 1 for args_hash + 1 call_context.hash MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + - NUM_FIELDS_PER_SHA256 + // unencrypted_logs_hash (being represented by NUM_FIELDS_PER_SHA256) - HISTORIC_BLOCK_DATA_LENGTH + 2; // unencrypted_log_preimages_length + prover_address + NUM_FIELDS_PER_SHA256 + // unencrypted_logs_hash (being represented by NUM_FIELDS_PER_SHA256) + BLOCK_HEADER_LENGTH + 2; // unencrypted_log_preimages_length + prover_address // Size of the return value of a private function call, diff --git a/circuits/cpp/src/aztec3/dbs/private_state_db.hpp b/circuits/cpp/src/aztec3/dbs/private_state_db.hpp index 5689dc163ca..60d4ecaedf8 100644 --- a/circuits/cpp/src/aztec3/dbs/private_state_db.hpp +++ b/circuits/cpp/src/aztec3/dbs/private_state_db.hpp @@ -17,7 +17,7 @@ // std::vector active_private_state_preimages; // }; -// // contract->storageSlots->[current->historic] +// // contract->storageSlots->[current->historical] // /** // * Hmmm... There are multiple active leaves for partitioned states. diff --git a/circuits/cpp/src/aztec3/oracle/fake_db.hpp b/circuits/cpp/src/aztec3/oracle/fake_db.hpp index 96ddfd62a21..a14ffa6f57e 100644 --- a/circuits/cpp/src/aztec3/oracle/fake_db.hpp +++ b/circuits/cpp/src/aztec3/oracle/fake_db.hpp @@ -61,7 +61,7 @@ class FakeDB { .sibling_path = sibling_path, .leaf_index = 2, - .historic_note_hash_tree_root = required_utxo_tree_root, + .historical_note_hash_tree_root = required_utxo_tree_root, }; }; @@ -109,7 +109,7 @@ class FakeDB { .sibling_path = sibling_path, .leaf_index = 2, - .historic_note_hash_tree_root = required_utxo_tree_root, + .historical_note_hash_tree_root = required_utxo_tree_root, }); } @@ -153,7 +153,7 @@ class FakeDB { .sibling_path = sibling_path, .leaf_index = 2, - .historic_note_hash_tree_root = required_utxo_tree_root, + .historical_note_hash_tree_root = required_utxo_tree_root, }; }; }; diff --git a/docs/docs/about_aztec/overview.mdx b/docs/docs/about_aztec/overview.mdx index dde9f2c1192..3fceee95c47 100644 --- a/docs/docs/about_aztec/overview.mdx +++ b/docs/docs/about_aztec/overview.mdx @@ -10,7 +10,7 @@ Aztec is an L2 that brings programmable privacy to Ethereum. A smart contract on Aztec is a collection of functions, written as ZK-SNARK circuits. These circuits can have different modes of execution: -1. Secret Functions -- can read and write private state, read historic public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other secret functions in the same contract, or other contracts, and can call public functions. +1. Secret Functions -- can read and write private state, read historical public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other secret functions in the same contract, or other contracts, and can call public functions. 2. Public Functions -- can read and write public state, write private state, consume or send messages to / from Ethereum and read Ethereum state. They can call other public functions on the same or other contracts. 3. Portal Contracts -- these are contracts on Ethereum that can receive messages from Aztec or send messages to Aztec from Ethereum contracts. diff --git a/docs/docs/concepts/advanced/data_structures/trees.md b/docs/docs/concepts/advanced/data_structures/trees.md index 45fc60c51a8..79ee1149d67 100644 --- a/docs/docs/concepts/advanced/data_structures/trees.md +++ b/docs/docs/concepts/advanced/data_structures/trees.md @@ -160,10 +160,10 @@ The contract tree contains information about every function of every contract de > Note: Aztec supports the ability to keep the logic of private functions of a smart contract private. In such cases, no information about the logic of that private function will be broadcast; only a randomized merkle root of that contract's data. -## Trees of historic trees' roots +## Blocks Tree -- `treeOfHistoricNoteHashTreeRoots`: for membership checks against historic roots of the `noteHashTree` -- `treeOfHistoricContractTreeRoots`: for membership checks against historic roots of the `contractTree` +Leaves are hashes of blocks (of block headers). +Can be used to access any of the trees above at some older point in time by doing a membership check of the old root in the block header and of the block header hash in the blocks tree. ## Trees of valid Kernel/Rollup circuit Verification Keys diff --git a/docs/docs/concepts/foundation/communication/public_private_calls.md b/docs/docs/concepts/foundation/communication/public_private_calls.md index 683126a14a3..224574beeb7 100644 --- a/docs/docs/concepts/foundation/communication/public_private_calls.md +++ b/docs/docs/concepts/foundation/communication/public_private_calls.md @@ -34,7 +34,7 @@ To avoid this issue, we permit the use of historical data as long as the data ha In this model, instead of informing the builder of our intentions, we construct the proof $\pi$ and then provide them with the transaction results (new commitments and nullifiers, contract deployments and cross-chain messages) in addition to $\pi$. The builder will then be responsible for inserting these new commitments and nullifiers into the state. They will be aware of the intermediates and can discard transactions that try to produce existing nullifiers (double spend), as doing so would invalidate the rollup proof. -On the left-hand side of the diagram below, we see the fully public world where storage is shared, while on the right-hand side, we see the private world where all reads are historic. +On the left-hand side of the diagram below, we see the fully public world where storage is shared, while on the right-hand side, we see the private world where all reads are historical. @@ -82,15 +82,15 @@ From the above, we should have a decent idea about what private and public funct Many applications rely on some form of access control to function well. USDC have a blacklist, where only parties not on the list should be able to transfer. And other systems such as Aave have limits such that only the pool contract is able to mint debt tokens and transfers held funds. -Access control like this cannot easily be enforced in the private domain, as reading is also nullifying(to ensure data is up to date). However, as it is possible to read historic public state, one can combine private and public functions to get the desired effect. +Access control like this cannot easily be enforced in the private domain, as reading is also nullifying(to ensure data is up to date). However, as it is possible to read historical public state, one can combine private and public functions to get the desired effect. -Say the public state holds a `mapping(address user => bool blacklisted)` and a value with the block number of the last update `last_updated`. The private functions can then use this public blacklist IF it also performs a public function call that reverts if the block number of the historic state is older than the `last_updated`. This means that updating the blacklist would make pending transactions fail, but allow a public blacklist to be used. Similar would work for the Aave example, where it is just a public value with the allowed caller contracts. Example of how this would be written is seen below. Note that because the `onlyFresh` is done in public, the user might not know when he is generating his proof whether it will be valid or not. +Say the public state holds a `mapping(address user => bool blacklisted)` and a value with the block number of the last update `last_updated`. The private functions can then use this public blacklist IF it also performs a public function call that reverts if the block number of the historical state is older than the `last_updated`. This means that updating the blacklist would make pending transactions fail, but allow a public blacklist to be used. Similar would work for the Aave example, where it is just a public value with the allowed caller contracts. Example of how this would be written is seen below. Note that because the `onlyFresh` is done in public, the user might not know when he is generating his proof whether it will be valid or not. ```solidity function transfer( secret address to, secret uint256 amount, - secret HistoricState state + secret HistoricalState state ) secret returns(bool) { if (blacklisted[msg.sender] || blacklisted[to]) revert("Blacklisted"); onlyFresh(state.blockNumber); diff --git a/docs/docs/dev_docs/contracts/resources/common_patterns/main.md b/docs/docs/dev_docs/contracts/resources/common_patterns/main.md index 82afee5c96d..d0c535df871 100644 --- a/docs/docs/dev_docs/contracts/resources/common_patterns/main.md +++ b/docs/docs/dev_docs/contracts/resources/common_patterns/main.md @@ -125,7 +125,7 @@ There are several patterns here: There are several other designs we are discussing through [in this discourse post](https://discourse.aztec.network/t/how-to-handle-private-escrows-between-two-parties/2440) but they need some changes in the protocol or in our demo contract. If you are interested in this discussion, please participate in the discourse post! ### Share Private Notes -If you have private state that needs to be handled by more than a single user (but no more than a handful), you can add the note commitment to the private data tree, and then encrypt the note once for each of the users that need to see it. And if any of those users should be able to consume the note, you can generate a random nullifier on creation and store it in the encrypted note, instead of relying on the user secret. +If you have private state that needs to be handled by more than a single user (but no more than a handful), you can add the note commitment to the note hash tree, and then encrypt the note once for each of the users that need to see it. And if any of those users should be able to consume the note, you can generate a random nullifier on creation and store it in the encrypted note, instead of relying on the user secret. ## Anti Patterns There are mistakes one can make to reduce their privacy set and therefore make it trivial to do analysis and link addresses. Some of them are: diff --git a/docs/docs/dev_docs/contracts/syntax/context.mdx b/docs/docs/dev_docs/contracts/syntax/context.mdx index f73bfbe72ad..1855f59222e 100644 --- a/docs/docs/dev_docs/contracts/syntax/context.mdx +++ b/docs/docs/dev_docs/contracts/syntax/context.mdx @@ -18,7 +18,7 @@ On this page, you'll learn - The details and functionalities of the private context in Aztec.nr - Difference between the private and public contexts and their unified APIs -- Components of the private context, such as inputs, historic block data, and contract deployment data +- Components of the private context, such as inputs, block header, and contract deployment data - Elements like return values, read requests, new commitments, and nullifiers in transaction processing - Differences between the private and public contexts, especially the unique features and variables in the public context @@ -44,7 +44,7 @@ The context inputs includes all of the information that is passed from the kerne #include_code private-context-inputs /yarn-project/aztec-nr/aztec/src/abi.nr rust -As shown in the snippet, the application context is made up of 4 main structures. The call context, the block data, the contract deployment data and the private global variables. +As shown in the snippet, the application context is made up of 4 main structures. The call context, the block header, the contract deployment data and the private global variables. First of all, the call context. @@ -71,11 +71,11 @@ The call context contains information about the current call being made: - is_static_call: This will be set if and only if the current call is a static call. In a static call, state changing altering operations are not allowed. - is_contract_deployment: This will be set if and only if the current call is the contract's constructor. -### Historic Block Data +### Block Header -Another structure that is contained within the context is the Historic Block Data object. This object is a special one as it contains all of the roots of Aztec's data trees. +Another structure that is contained within the context is the Block Header object. This object is a special one as it contains all of the roots of Aztec's data trees. -#include_code historic-block-data /yarn-project/aztec-nr/aztec/src/abi.nr rust +#include_code block-header /yarn-project/aztec-nr/aztec/src/abi.nr rust ### Contract Deployment Data @@ -137,7 +137,7 @@ The Public Context includes all of the information passed from the `Public VM` i ### Public Context Inputs -In the current version of the system, the public context is almost a clone of the private execution context. It contains the same call context data, access to the same historic tree roots, however it does NOT have access to contract deployment data, this is due to traditional contract deployments only currently being possible from private transactions. +In the current version of the system, the public context is almost a clone of the private execution context. It contains the same call context data, access to the same historical tree roots, however it does NOT have access to contract deployment data, this is due to traditional contract deployments only currently being possible from private transactions. #include_code public-context-inputs /yarn-project/aztec-nr/aztec/src/abi.nr rust diff --git a/docs/docs/dev_docs/debugging/sandbox-errors.md b/docs/docs/dev_docs/debugging/sandbox-errors.md index f31752a8d69..fd69c43d831 100644 --- a/docs/docs/dev_docs/debugging/sandbox-errors.md +++ b/docs/docs/dev_docs/debugging/sandbox-errors.md @@ -62,7 +62,7 @@ Confirms that the TxRequest (user's intent) matches the private call being execu #### 2018 - PRIVATE_KERNEL\_\_READ_REQUEST_NOTE_HASH_TREE_ROOT_MISMATCH -Given a read request and provided witness, we check that the merkle root obtained from the witness' sibling path and it's leaf is similar to the historic state root we want to read against. This is a sanity check to ensure we are reading from the right state. +Given a read request and provided witness, we check that the merkle root obtained from the witness' sibling path and it's leaf is similar to the historical state root we want to read against. This is a sanity check to ensure we are reading from the right state. For a non transient read, we fetch the merkle root from the membership witnesses and the leaf index #### 2019 - PRIVATE_KERNEL\_\_TRANSIENT_READ_REQUEST_NO_MATCH @@ -164,11 +164,11 @@ You can have a look at our current constants/limitations in [constants.nr](https #### 7008 - MEMBERSHIP_CHECK_FAILED -Users may create a proof against a historic state in Aztec. The rollup circuits performs a merkle membership check to ensure this state existed at some point. If the historic state doesn't exist, you get this error. Some examples when you may hit this error are: +Users may create a proof against a historical state in Aztec. The rollup circuits performs a merkle membership check to ensure this state existed at some point. If the historical state doesn't exist, you get this error. Some examples when you may hit this error are: -- using invalid historic note hash tree state (aka historic commitments tree) -- using invalid historic contracts data tree state -- using invalid historic L1 to L2 message data tree state +- using invalid historical note hash tree state (aka historical commitments tree) +- using invalid historical contracts data tree state +- using invalid historical L1 to L2 message data tree state - inserting a subtree into the greater tree - we make a smaller merkle tree of all the new commitments/nullifiers etc that were created in a transaction or in a rollup and add it to the bigger state tree. Before inserting, we do a merkle membership check to ensure that the index to insert at is indeed an empty subtree (otherwise we would be overwriting state). This can happen when `next_available_leaf_index` in the state tree's snapshot is wrong (it is fetched by the sequencer from the archiver). The error message should reveal which tree is causing this issue - nullifier tree related errors - The nullifier tree uses an [Indexed Merkle Tree](../../concepts/advanced/data_structures/indexed_merkle_tree.md). It requires additional data from the archiver to know which is the nullifier in the tree that is just below the current nullifier before it can perform batch insertion. If the low nullifier is wrong, or the nullifier is in incorrect range, you may receive this error. diff --git a/docs/docs/dev_docs/getting_started/aztecjs-getting-started.md b/docs/docs/dev_docs/getting_started/aztecjs-getting-started.md index e7be7d00720..185c8bdaf15 100644 --- a/docs/docs/dev_docs/getting_started/aztecjs-getting-started.md +++ b/docs/docs/dev_docs/getting_started/aztecjs-getting-started.md @@ -337,7 +337,7 @@ This function takes: 1. A quantity of tokens to be minted. 2. A secret hash. -This function is public and it inserts a new note into the private data tree and increases the total token supply by the amount minted. +This function is public and it inserts a new note into the note hash tree and increases the total token supply by the amount minted. To make the note spendable the note has to be redeemed. A user can do that by calling the `redeem_shield` function. diff --git a/docs/docs/dev_docs/getting_started/core-concepts.md b/docs/docs/dev_docs/getting_started/core-concepts.md index e22e1d3a04d..e5087c624c1 100644 --- a/docs/docs/dev_docs/getting_started/core-concepts.md +++ b/docs/docs/dev_docs/getting_started/core-concepts.md @@ -31,7 +31,7 @@ You can call a public function from a private function by using `context.call_pu #include_code call_public_function yarn-project/noir-contracts/src/contracts/card_game_contract/src/main.nr rust -You cannot call a private function from a public function, but you can use a slow updates tree to read historic public state and stage writes to public state from a private function. +You cannot call a private function from a public function, but you can use a slow updates tree to read historical public state and stage writes to public state from a private function. ### Data types diff --git a/docs/docs/dev_docs/limitations/main.md b/docs/docs/dev_docs/limitations/main.md index 08a911d29e2..c697898a6f7 100644 --- a/docs/docs/dev_docs/limitations/main.md +++ b/docs/docs/dev_docs/limitations/main.md @@ -130,7 +130,7 @@ A contract can't perform a delegatecall yet (if ever). Delegatecalls are quite a Ethereum has a notion of a 'full node' which keeps-up with the blockchain and stores the full chain state. Many users don't wish to run full nodes, so rely on 3rd-party 'full-node-as-a-service' infrastructure providers, who service blockchain queries from their users. -This pattern is likely to develop in Aztec as well, except there's a problem: privacy. If a privacy-seeking user makes a query to a 3rd-party 'full node', that user might leak data about who they are, or about their historic network activity, or about their future intentions. One solution to this problem is "always run a full node", but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a 3rd-party node without revealing what that data is, nor who is making the request. +This pattern is likely to develop in Aztec as well, except there's a problem: privacy. If a privacy-seeking user makes a query to a 3rd-party 'full node', that user might leak data about who they are, or about their historical network activity, or about their future intentions. One solution to this problem is "always run a full node", but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a 3rd-party node without revealing what that data is, nor who is making the request. ### No private data authentication diff --git a/docs/docs/dev_docs/privacy/main.md b/docs/docs/dev_docs/privacy/main.md index b1818b7f84b..7964a582888 100644 --- a/docs/docs/dev_docs/privacy/main.md +++ b/docs/docs/dev_docs/privacy/main.md @@ -97,7 +97,7 @@ It's not just the broadcasting of transactions to the network that can leak data Ethereum has a notion of a 'full node' which keeps-up with the blockchain and stores the full chain state. Many users don't wish to run full nodes, so rely on 3rd-party 'full-node-as-a-service' infrastructure providers, who service blockchain queries from their users. -This pattern is likely to develop in Aztec as well, except there's a problem: privacy. If a privacy-seeking user makes a query to a 3rd-party 'full node', that user might leak data about who they are; about their historic network activity; or about their future intentions. One solution to this problem is "always run a full node", but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a 3rd-party node without revealing what that data is, nor who is making the request. +This pattern is likely to develop in Aztec as well, except there's a problem: privacy. If a privacy-seeking user makes a query to a 3rd-party 'full node', that user might leak data about who they are; about their historical network activity; or about their future intentions. One solution to this problem is "always run a full node", but pragmatically, not everyone will. To protect less-advanced users' privacy, research is underway to explore how a privacy-seeking user may request and receive data from a 3rd-party node without revealing what that data is, nor who is making the request. App developers should be aware of this avenue for private data leakage. **Whenever an app requests information from a node, the entity running that node is unlikely be your user!** @@ -105,9 +105,9 @@ App developers should be aware of this avenue for private data leakage. **Whenev ##### Querying for up-to-date note sibling paths -To read a private state is to read a note from the note hash tree. To read a note is to prove existence of that note in the note hash tree. And to prove existence is to re-compute the root of the note hash tree using the leaf value, the leaf index, and the sibling path of that leaf. This computed root is then exposed to the world, as a way of saying "This note exists", or more precisely "This note has existed at least since this historic snapshot time". +To read a private state is to read a note from the note hash tree. To read a note is to prove existence of that note in the note hash tree. And to prove existence is to re-compute the root of the note hash tree using the leaf value, the leaf index, and the sibling path of that leaf. This computed root is then exposed to the world, as a way of saying "This note exists", or more precisely "This note has existed at least since this historical snapshot time". -If an old historic snapshot is used, then that old historic root will be exposed, and this leaks some information about the nature of your transaction: it leaks that your note was created before the snapshot date. It shrinks the 'privacy set' of the transaction to a smaller window of time than the entire history of the network. +If an old historical snapshot is used, then that old historical root will be exposed, and this leaks some information about the nature of your transaction: it leaks that your note was created before the snapshot date. It shrinks the 'privacy set' of the transaction to a smaller window of time than the entire history of the network. So for maximal privacy, it's in a user's best interest to read from the very-latest snapshot of the data tree. diff --git a/docs/internal_notes/building_dapps.md b/docs/internal_notes/building_dapps.md index fc807def92b..b6d4f3a1be1 100644 --- a/docs/internal_notes/building_dapps.md +++ b/docs/internal_notes/building_dapps.md @@ -29,7 +29,7 @@ Explain how to write a dapp using [`aztec.js`](https://github.com/AztecProtocol/ - How to query state - How to query whether a tx has been 'mined' - How to subscribe to logs - - How to filter for historic data in the historic block tree? + - How to filter for historical data in the historical block tree? - How to query data from any of the trees (advanced) FOR INSTRUCTIONS FOR BUILDING A WALLET, WE SHOULD WRITE DOCS HERE diff --git a/docs/internal_notes/dev_docs/sandbox/components.md b/docs/internal_notes/dev_docs/sandbox/components.md index 509e851da71..5045e2c18fd 100644 --- a/docs/internal_notes/dev_docs/sandbox/components.md +++ b/docs/internal_notes/dev_docs/sandbox/components.md @@ -246,7 +246,7 @@ Responsibilities: - "Persists" the various merkle trees (configurable). - For this milestone 1.1, we'll need the following trees: - Contract Tree - - Contract Tree Roots Tree (the tree whose leaves are the roots of historic rollups' contract trees) + - Contract Tree Roots Tree (the tree whose leaves are the roots of historical rollups' contract trees) - Nullifier Tree (so that the contract address can never be re-registered in a future deployment) - Note: Suyash has implemented C++ for the 'new' kind of nullifier tree. - Provides methods for updating the trees with commit, rollback semantics. diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 9cb97e57a6b..d63790f5e03 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -56,7 +56,7 @@ library Constants { uint256 internal constant NOTE_HASH_SUBTREE_HEIGHT = 7; uint256 internal constant NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH = 25; uint256 internal constant NULLIFIER_SUBTREE_HEIGHT = 7; - uint256 internal constant HISTORIC_BLOCKS_TREE_HEIGHT = 16; + uint256 internal constant BLOCKS_TREE_HEIGHT = 16; uint256 internal constant NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 13; uint256 internal constant L1_TO_L2_MSG_SUBTREE_HEIGHT = 4; uint256 internal constant L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12; @@ -70,7 +70,7 @@ library Constants { uint256 internal constant MAX_NOTES_PER_PAGE = 10; uint256 internal constant VIEW_NOTE_ORACLE_RETURN_LENGTH = 212; uint256 internal constant CALL_CONTEXT_LENGTH = 7; - uint256 internal constant HISTORIC_BLOCK_DATA_LENGTH = 7; + uint256 internal constant BLOCK_HEADER_LENGTH = 7; uint256 internal constant FUNCTION_DATA_LENGTH = 4; uint256 internal constant CONTRACT_DEPLOYMENT_DATA_LENGTH = 6; uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 155; diff --git a/l1-contracts/src/core/libraries/Decoder.sol b/l1-contracts/src/core/libraries/Decoder.sol index ccc7d0cf677..110522190b1 100644 --- a/l1-contracts/src/core/libraries/Decoder.sol +++ b/l1-contracts/src/core/libraries/Decoder.sol @@ -35,8 +35,8 @@ import {Hash} from "./Hash.sol"; * | 0x00ec | 0x20 | startPublicDataTreeRoot * | 0x010c | 0x20 | startL1ToL2MessageTreeSnapshot.root * | 0x012c | 0x04 | startL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex - * | 0x0130 | 0x20 | startHistoricBlocksTreeSnapshot.root - * | 0x0150 | 0x04 | startHistoricBlocksTreeSnapshot.nextAvailableLeafIndex + * | 0x0130 | 0x20 | startBlocksTreeSnapshot.root + * | 0x0150 | 0x04 | startBlocksTreeSnapshot.nextAvailableLeafIndex * | 0x0154 | 0x20 | endNoteHashTreeSnapshot.root * | 0x0174 | 0x04 | endNoteHashTreeSnapshot.nextAvailableLeafIndex * | 0x0178 | 0x20 | endNullifierTreeSnapshot.root @@ -46,8 +46,8 @@ import {Hash} from "./Hash.sol"; * | 0x01c0 | 0x20 | endPublicDataTreeRoot * | 0x01e0 | 0x20 | endL1ToL2MessageTreeSnapshot.root * | 0x0200 | 0x04 | endL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex - * | 0x0204 | 0x20 | endHistoricBlocksTreeSnapshot.root - * | 0x0224 | 0x04 | endHistoricBlocksTreeSnapshot.nextAvailableLeafIndex + * | 0x0204 | 0x20 | endBlocksTreeSnapshot.root + * | 0x0224 | 0x04 | endBlocksTreeSnapshot.nextAvailableLeafIndex * | 0x0228 | 0x04 | len(newCommitments) (denoted a) * | 0x022c | a * 0x20 | newCommitments * | 0x022c + a * 0x20 | 0x04 | len(newNullifiers) (denoted b) diff --git a/l1-contracts/src/core/messagebridge/Registry.sol b/l1-contracts/src/core/messagebridge/Registry.sol index 15f6ce6b2c8..947597c8b02 100644 --- a/l1-contracts/src/core/messagebridge/Registry.sol +++ b/l1-contracts/src/core/messagebridge/Registry.sol @@ -15,7 +15,7 @@ import {Errors} from "../libraries/Errors.sol"; /** * @title Registry * @author Aztec Labs - * @notice Keeps track of addresses of rollup, inbox and outbox as well as historic addresses. + * @notice Keeps track of addresses of rollup, inbox and outbox as well as historical addresses. * Used as the source of truth for finding the "head" of the rollup chain. Very important information * for L1<->L2 communication. */ diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index d82640a42e9..649ad620cf0 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -1,10 +1,10 @@ import { + BlockHeader, CallContext, ContractDeploymentData, ContractStorageRead, ContractStorageUpdateRequest, FunctionSelector, - HistoricBlockData, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, @@ -163,7 +163,7 @@ export function extractPrivateCircuitPublicInputs( const encryptedLogPreimagesLength = witnessReader.readField(); const unencryptedLogPreimagesLength = witnessReader.readField(); - const historicBlockData = new HistoricBlockData( + const blockHeader = new BlockHeader( witnessReader.readField(), witnessReader.readField(), witnessReader.readField(), @@ -201,7 +201,7 @@ export function extractPrivateCircuitPublicInputs( unencryptedLogsHash, encryptedLogPreimagesLength, unencryptedLogPreimagesLength, - historicBlockData, + blockHeader, contractDeploymentData, chainId, version, @@ -255,7 +255,7 @@ export function extractPublicCircuitPublicInputs(partialWitness: ACVMWitness, ac const unencryptedLogsHash = witnessReader.readFieldArray(NUM_FIELDS_PER_SHA256); const unencryptedLogPreimagesLength = witnessReader.readField(); - const historicBlockData = new HistoricBlockData( + const blockHeader = new BlockHeader( witnessReader.readField(), witnessReader.readField(), witnessReader.readField(), @@ -282,7 +282,7 @@ export function extractPublicCircuitPublicInputs(partialWitness: ACVMWitness, ac newL2ToL1Msgs, unencryptedLogsHash, unencryptedLogPreimagesLength, - historicBlockData, + blockHeader, proverAddress, ); } diff --git a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts index ebc8ca180f1..87a32f072c0 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts @@ -109,14 +109,14 @@ export class Oracle { return witness.toFieldArray().map(toACVMField); } - async getBlockData([blockNumber]: ACVMField[]): Promise { + async getBlockHeader([blockNumber]: ACVMField[]): Promise { const parsedBlockNumber = frToNumber(fromACVMField(blockNumber)); - const blockData = await this.typedOracle.getBlockData(parsedBlockNumber); - if (!blockData) { - throw new Error(`Block data not found for block ${parsedBlockNumber}.`); + const blockHeader = await this.typedOracle.getBlockHeader(parsedBlockNumber); + if (!blockHeader) { + throw new Error(`Block header not found for block ${parsedBlockNumber}.`); } - return blockData.toArray().map(toACVMField); + return blockHeader.toArray().map(toACVMField); } async getAuthWitness([messageHash]: ACVMField[]): Promise { diff --git a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts index 9138009309c..7013689a8ca 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts @@ -1,4 +1,4 @@ -import { HistoricBlockData, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; +import { BlockHeader, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; @@ -102,7 +102,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getBlockData(_blockNumber: number): Promise { + getBlockHeader(_blockNumber: number): Promise { throw new Error('Not available.'); } diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index dff75ab6cb9..abf78f63c1b 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -1,9 +1,9 @@ import { + BlockHeader, CallContext, ContractDeploymentData, FunctionData, GlobalVariables, - HistoricBlockData, PrivateCallStackItem, PrivateCircuitPublicInputs, PublicCallRequest, @@ -101,19 +101,19 @@ export function toACVMContractDeploymentData(contractDeploymentData: ContractDep } /** - * Converts a historic block data into ACVM fields. - * @param historicBlockData - The historic block data object to convert. + * Converts a block header into ACVM fields. + * @param blockHeader - The block header object to convert. * @returns The ACVM fields. */ -export function toACVMHistoricBlockData(historicBlockData: HistoricBlockData): ACVMField[] { +export function toACVMBlockHeader(blockHeader: BlockHeader): ACVMField[] { return [ - toACVMField(historicBlockData.noteHashTreeRoot), - toACVMField(historicBlockData.nullifierTreeRoot), - toACVMField(historicBlockData.contractTreeRoot), - toACVMField(historicBlockData.l1ToL2MessagesTreeRoot), - toACVMField(historicBlockData.blocksTreeRoot), - toACVMField(historicBlockData.publicDataTreeRoot), - toACVMField(historicBlockData.globalVariablesHash), + toACVMField(blockHeader.noteHashTreeRoot), + toACVMField(blockHeader.nullifierTreeRoot), + toACVMField(blockHeader.contractTreeRoot), + toACVMField(blockHeader.l1ToL2MessagesTreeRoot), + toACVMField(blockHeader.blocksTreeRoot), + toACVMField(blockHeader.publicDataTreeRoot), + toACVMField(blockHeader.globalVariablesHash), ]; } @@ -156,7 +156,7 @@ export function toACVMPublicInputs(publicInputs: PrivateCircuitPublicInputs): AC toACVMField(publicInputs.encryptedLogPreimagesLength), toACVMField(publicInputs.unencryptedLogPreimagesLength), - ...toACVMHistoricBlockData(publicInputs.historicBlockData), + ...toACVMBlockHeader(publicInputs.blockHeader), ...toACVMContractDeploymentData(publicInputs.contractDeploymentData), diff --git a/yarn-project/acir-simulator/src/client/client_execution_context.ts b/yarn-project/acir-simulator/src/client/client_execution_context.ts index 5ccbbcc2b99..d113bed04b3 100644 --- a/yarn-project/acir-simulator/src/client/client_execution_context.ts +++ b/yarn-project/acir-simulator/src/client/client_execution_context.ts @@ -1,9 +1,9 @@ import { + BlockHeader, CallContext, ContractDeploymentData, FunctionData, FunctionSelector, - HistoricBlockData, PublicCallRequest, ReadRequestMembershipWitness, TxContext, @@ -18,9 +18,9 @@ import { AuthWitness, FunctionL2Logs, L1NotePayload, Note, UnencryptedL2Log } fr import { NoteData, + toACVMBlockHeader, toACVMCallContext, toACVMContractDeploymentData, - toACVMHistoricBlockData, toACVMWitness, } from '../acvm/index.js'; import { SideEffectCounter } from '../common/index.js'; @@ -64,8 +64,8 @@ export class ClientExecutionContext extends ViewDataOracle { private readonly argsHash: Fr, private readonly txContext: TxContext, private readonly callContext: CallContext, - /** Data required to reconstruct the block hash, it contains historic roots. */ - protected readonly historicBlockData: HistoricBlockData, + /** Data required to reconstruct the block hash, it contains historical roots. */ + protected readonly blockHeader: BlockHeader, /** List of transient auth witnesses to be used during this simulation */ protected readonly authWitnesses: AuthWitness[], private readonly packedArgsCache: PackedArgsCache, @@ -75,7 +75,7 @@ export class ClientExecutionContext extends ViewDataOracle { private readonly curve: Grumpkin, protected log = createDebugLogger('aztec:simulator:client_execution_context'), ) { - super(contractAddress, historicBlockData, authWitnesses, db, undefined, log); + super(contractAddress, blockHeader, authWitnesses, db, undefined, log); } // We still need this function until we can get user-defined ordering of structs for fn arguments @@ -98,7 +98,7 @@ export class ClientExecutionContext extends ViewDataOracle { const fields = [ ...toACVMCallContext(this.callContext), - ...toACVMHistoricBlockData(this.historicBlockData), + ...toACVMBlockHeader(this.blockHeader), ...toACVMContractDeploymentData(contractDeploymentData), this.txContext.chainId, @@ -326,7 +326,7 @@ export class ClientExecutionContext extends ViewDataOracle { argsHash, derivedTxContext, derivedCallContext, - this.historicBlockData, + this.blockHeader, this.authWitnesses, this.packedArgsCache, this.noteCache, diff --git a/yarn-project/acir-simulator/src/client/db_oracle.ts b/yarn-project/acir-simulator/src/client/db_oracle.ts index ad2cb1a19c4..6ed7a6a8e6a 100644 --- a/yarn-project/acir-simulator/src/client/db_oracle.ts +++ b/yarn-project/acir-simulator/src/client/db_oracle.ts @@ -1,4 +1,4 @@ -import { CompleteAddress, GrumpkinPrivateKey, HistoricBlockData, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; import { FunctionArtifact, FunctionDebugMetadata, FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; @@ -109,12 +109,12 @@ export interface DBOracle extends CommitmentsDB { getNullifierIndex(nullifier: Fr): Promise; /** - * Retrieve the databases view of the Historic Block Data object. - * This structure is fed into the circuits simulator and is used to prove against certain historic roots. + * Retrieve the databases view of the Block Header object. + * This structure is fed into the circuits simulator and is used to prove against certain historical roots. * - * @returns A Promise that resolves to a HistoricBlockData object. + * @returns A Promise that resolves to a BlockHeader object. */ - getHistoricBlockData(): Promise; + getBlockHeader(): Promise; /** * Fetch the index of the leaf in the respective tree diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index b96d69dc338..6b0a7816a51 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -1,11 +1,11 @@ import { + BlockHeader, CallContext, CompleteAddress, ContractDeploymentData, EMPTY_NULLIFIED_COMMITMENT, FieldsOf, FunctionData, - HistoricBlockData, L1_TO_L2_MSG_TREE_HEIGHT, MAX_NEW_COMMITMENTS_PER_CALL, NOTE_HASH_TREE_HEIGHT, @@ -58,7 +58,7 @@ describe('Private Execution test suite', () => { let oracle: MockProxy; let acirSimulator: AcirSimulator; - let blockData = HistoricBlockData.empty(); + let blockHeader = BlockHeader.empty(); let logger: DebugLogger; const defaultContractAddress = AztecAddress.random(); @@ -132,10 +132,10 @@ describe('Private Execution test suite', () => { // Update root. const newRoot = trees[name].getRoot(false); - const prevRoots = blockData.toBuffer(); + const prevRoots = blockHeader.toBuffer(); const rootIndex = name === 'noteHash' ? 0 : 32 * 3; const newRoots = Buffer.concat([prevRoots.subarray(0, rootIndex), newRoot, prevRoots.subarray(rootIndex + 32)]); - blockData = HistoricBlockData.fromBuffer(newRoots); + blockHeader = BlockHeader.fromBuffer(newRoots); return trees[name]; }; @@ -163,7 +163,7 @@ describe('Private Execution test suite', () => { } throw new Error(`Unknown address ${pubKey}`); }); - oracle.getHistoricBlockData.mockResolvedValue(blockData); + oracle.getBlockHeader.mockResolvedValue(blockHeader); acirSimulator = new AcirSimulator(oracle); }); diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index cf7222cbe20..520626add64 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -79,7 +79,7 @@ export class AcirSimulator { const curve = new Grumpkin(); - const historicBlockData = await this.db.getHistoricBlockData(); + const blockHeader = await this.db.getBlockHeader(); const callContext = new CallContext( msgSender, contractAddress, @@ -94,7 +94,7 @@ export class AcirSimulator { request.argsHash, request.txContext, callContext, - historicBlockData, + blockHeader, request.authWitnesses, PackedArgsCache.create(request.packedArguments), new ExecutionNoteCache(), @@ -133,8 +133,8 @@ export class AcirSimulator { throw new Error(`Cannot run ${entryPointArtifact.functionType} function as constrained`); } - const historicBlockData = await this.db.getHistoricBlockData(); - const context = new ViewDataOracle(contractAddress, historicBlockData, [], this.db, aztecNode); + const blockHeader = await this.db.getBlockHeader(); + const context = new ViewDataOracle(contractAddress, blockHeader, [], this.db, aztecNode); try { return await executeUnconstrainedFunction( diff --git a/yarn-project/acir-simulator/src/client/unconstrained_execution.test.ts b/yarn-project/acir-simulator/src/client/unconstrained_execution.test.ts index 7e7eb3716d4..3db5f2e9f3d 100644 --- a/yarn-project/acir-simulator/src/client/unconstrained_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/unconstrained_execution.test.ts @@ -1,4 +1,4 @@ -import { CompleteAddress, FunctionData, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, FunctionData } from '@aztec/circuits.js'; import { FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; @@ -46,7 +46,7 @@ describe('Unconstrained Execution test suite', () => { const notes: Note[] = [...Array(5).fill(buildNote(1n, owner)), ...Array(2).fill(buildNote(2n, owner))]; - oracle.getHistoricBlockData.mockResolvedValue(HistoricBlockData.empty()); + oracle.getBlockHeader.mockResolvedValue(BlockHeader.empty()); oracle.getNotes.mockResolvedValue( notes.map((note, index) => ({ contractAddress, diff --git a/yarn-project/acir-simulator/src/client/view_data_oracle.ts b/yarn-project/acir-simulator/src/client/view_data_oracle.ts index fe124f853d2..f744e54dd6c 100644 --- a/yarn-project/acir-simulator/src/client/view_data_oracle.ts +++ b/yarn-project/acir-simulator/src/client/view_data_oracle.ts @@ -1,4 +1,4 @@ -import { HistoricBlockData, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader, PublicKey } from '@aztec/circuits.js'; import { computeGlobalsHash, siloNullifier } from '@aztec/circuits.js/abis'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -16,8 +16,8 @@ import { pickNotes } from './pick_notes.js'; export class ViewDataOracle extends TypedOracle { constructor( protected readonly contractAddress: AztecAddress, - /** Data required to reconstruct the block hash, it contains historic roots. */ - protected readonly historicBlockData: HistoricBlockData, + /** Data required to reconstruct the block hash, it contains historical roots. */ + protected readonly blockHeader: BlockHeader, /** List of transient auth witnesses to be used during this simulation */ protected readonly authWitnesses: AuthWitness[], protected readonly db: DBOracle, @@ -92,21 +92,21 @@ export class ViewDataOracle extends TypedOracle { } /** - * Fetches historic block data for a given block. - * @param blockNumber - The block number at which to get the historic block data. - * @returns Historic block data extracted from a block with block number `blockNumber`. + * Fetches a block header of a given block. + * @param blockNumber - The number of a block of which to get the block header. + * @returns Block extracted from a block with block number `blockNumber`. */ - public async getBlockData(blockNumber: number): Promise { + public async getBlockHeader(blockNumber: number): Promise { const block = await this.db.getBlock(blockNumber); if (!block) { return undefined; } - return new HistoricBlockData( + return new BlockHeader( block.endNoteHashTreeSnapshot.root, block.endNullifierTreeSnapshot.root, block.endContractTreeSnapshot.root, block.endL1ToL2MessagesTreeSnapshot.root, - block.endHistoricBlocksTreeSnapshot.root, + block.endBlocksTreeSnapshot.root, new Fr(0), // TODO(#3441) privateKernelVkTreeRoot is not present in L2Block and it's not yet populated in noir block.endPublicDataTreeRoot, computeGlobalsHash(block.globalVariables), @@ -199,7 +199,7 @@ export class ViewDataOracle extends TypedOracle { */ public async getL1ToL2Message(msgKey: Fr) { const message = await this.db.getL1ToL2Message(msgKey); - return { ...message, root: this.historicBlockData.l1ToL2MessagesTreeRoot }; + return { ...message, root: this.blockHeader.l1ToL2MessagesTreeRoot }; } /** diff --git a/yarn-project/acir-simulator/src/public/executor.ts b/yarn-project/acir-simulator/src/public/executor.ts index fdcb691898d..77d9b1e9baa 100644 --- a/yarn-project/acir-simulator/src/public/executor.ts +++ b/yarn-project/acir-simulator/src/public/executor.ts @@ -1,4 +1,4 @@ -import { GlobalVariables, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, GlobalVariables } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { Oracle, acvm, extractCallStack, extractPublicCircuitPublicInputs } from '../acvm/index.js'; @@ -81,7 +81,7 @@ export class PublicExecutor { private readonly stateDb: PublicStateDB, private readonly contractsDb: PublicContractsDB, private readonly commitmentsDb: CommitmentsDB, - private readonly blockData: HistoricBlockData, + private readonly blockHeader: BlockHeader, ) {} /** @@ -105,7 +105,7 @@ export class PublicExecutor { const context = new PublicExecutionContext( execution, - this.blockData, + this.blockHeader, globalVariables, packedArgs, sideEffectCounter, diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 4d985f476af..1ab7da481be 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,10 +1,4 @@ -import { - CallContext, - FunctionData, - GlobalVariables, - HistoricBlockData, - L1_TO_L2_MSG_TREE_HEIGHT, -} from '@aztec/circuits.js'; +import { BlockHeader, CallContext, FunctionData, GlobalVariables, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; import { FunctionArtifact, FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { pedersenHash } from '@aztec/foundation/crypto'; @@ -34,15 +28,15 @@ describe('ACIR public execution simulator', () => { let publicContracts: MockProxy; let commitmentsDb: MockProxy; let executor: PublicExecutor; - let blockData: HistoricBlockData; + let blockHeader: BlockHeader; beforeEach(() => { publicState = mock(); publicContracts = mock(); commitmentsDb = mock(); - blockData = HistoricBlockData.empty(); - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockData); + blockHeader = BlockHeader.empty(); + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); }, 10000); describe('Token contract', () => { diff --git a/yarn-project/acir-simulator/src/public/public_execution_context.ts b/yarn-project/acir-simulator/src/public/public_execution_context.ts index 6db7acfd3fd..de7ee848009 100644 --- a/yarn-project/acir-simulator/src/public/public_execution_context.ts +++ b/yarn-project/acir-simulator/src/public/public_execution_context.ts @@ -1,4 +1,4 @@ -import { CallContext, FunctionData, FunctionSelector, GlobalVariables, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, CallContext, FunctionData, FunctionSelector, GlobalVariables } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; @@ -7,9 +7,9 @@ import { FunctionL2Logs, UnencryptedL2Log } from '@aztec/types'; import { TypedOracle, + toACVMBlockHeader, toACVMCallContext, toACVMGlobalVariables, - toACVMHistoricBlockData, toACVMWitness, } from '../acvm/index.js'; import { PackedArgsCache, SideEffectCounter } from '../common/index.js'; @@ -31,7 +31,7 @@ export class PublicExecutionContext extends TypedOracle { * Data for this execution. */ public readonly execution: PublicExecution, - private readonly historicBlockData: HistoricBlockData, + private readonly blockHeader: BlockHeader, private readonly globalVariables: GlobalVariables, private readonly packedArgsCache: PackedArgsCache, private readonly sideEffectCounter: SideEffectCounter, @@ -48,7 +48,7 @@ export class PublicExecutionContext extends TypedOracle { * Generates the initial witness for a public function. * @param args - The arguments to the function. * @param callContext - The call context of the function. - * @param historicBlockData - Historic Trees roots and data required to reconstruct block hash. + * @param blockHeader - Contains data required to reconstruct a block hash (historical roots etc.). * @param globalVariables - The global variables. * @param witnessStartIndex - The index where to start inserting the parameters. * @returns The initial witness. @@ -57,7 +57,7 @@ export class PublicExecutionContext extends TypedOracle { const { callContext, args } = this.execution; const fields = [ ...toACVMCallContext(callContext), - ...toACVMHistoricBlockData(this.historicBlockData), + ...toACVMBlockHeader(this.blockHeader), ...toACVMGlobalVariables(this.globalVariables), ...args, @@ -104,7 +104,7 @@ export class PublicExecutionContext extends TypedOracle { public async getL1ToL2Message(msgKey: Fr) { // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 const message = await this.commitmentsDb.getL1ToL2Message(msgKey); - return { ...message, root: this.historicBlockData.l1ToL2MessagesTreeRoot }; + return { ...message, root: this.blockHeader.l1ToL2MessagesTreeRoot }; } /** @@ -210,7 +210,7 @@ export class PublicExecutionContext extends TypedOracle { const context = new PublicExecutionContext( nestedExecution, - this.historicBlockData, + this.blockHeader, this.globalVariables, this.packedArgsCache, this.sideEffectCounter, diff --git a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts index 03f94ab8252..09d316e8670 100644 --- a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts +++ b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts @@ -1,4 +1,4 @@ -import { FunctionSelector, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, FunctionSelector } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; @@ -34,7 +34,7 @@ export function createAztecNodeRpcServer(node: AztecNode) { ContractData, Fr, FunctionSelector, - HistoricBlockData, + BlockHeader, L2Block, L2Tx, LogId, diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 817b1a6b206..d1744c26b14 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -1,10 +1,10 @@ import { Archiver, LMDBArchiverStore } from '@aztec/archiver'; import { + BLOCKS_TREE_HEIGHT, + BlockHeader, CONTRACT_TREE_HEIGHT, Fr, GlobalVariables, - HISTORIC_BLOCKS_TREE_HEIGHT, - HistoricBlockData, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, @@ -364,13 +364,11 @@ export class AztecNodeService implements AztecNode { } /** - * Returns a sibling path for a leaf in the committed historic blocks tree. + * Returns a sibling path for a leaf in the committed blocks tree. * @param leafIndex - Index of the leaf in the tree. * @returns The sibling path. */ - public async getHistoricBlocksTreeSiblingPath( - leafIndex: bigint, - ): Promise> { + public async getBlocksTreeSiblingPath(leafIndex: bigint): Promise> { const committedDb = await this.#getWorldState(); return committedDb.getSiblingPath(MerkleTreeId.BLOCKS_TREE, leafIndex); } @@ -499,14 +497,14 @@ export class AztecNodeService implements AztecNode { } /** - * Returns the currently committed historic block data. - * @returns The current committed block data. + * Returns the currently committed block header. + * @returns The current committed block header. */ - public async getHistoricBlockData(): Promise { + public async getBlockHeader(): Promise { const committedDb = await this.#getWorldState(); const [roots, globalsHash] = await Promise.all([this.getTreeRoots(), committedDb.getLatestGlobalVariablesHash()]); - return new HistoricBlockData( + return new BlockHeader( roots[MerkleTreeId.NOTE_HASH_TREE], roots[MerkleTreeId.NULLIFIER_TREE], roots[MerkleTreeId.CONTRACT_TREE], diff --git a/yarn-project/aztec-nr/aztec/src/abi.nr b/yarn-project/aztec-nr/aztec/src/abi.nr index c84ad8b6d8b..88923767db7 100644 --- a/yarn-project/aztec-nr/aztec/src/abi.nr +++ b/yarn-project/aztec-nr/aztec/src/abi.nr @@ -11,7 +11,7 @@ use crate::constants_gen::{ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, GENERATOR_INDEX__FUNCTION_ARGS, - HISTORIC_BLOCK_DATA_LENGTH, + BLOCK_HEADER_LENGTH, CONTRACT_DEPLOYMENT_DATA_LENGTH, CALL_CONTEXT_LENGTH, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, @@ -94,7 +94,7 @@ impl ContractDeploymentData { // docs:start:private-context-inputs struct PrivateContextInputs { call_context : CallContext, - block_data: HistoricBlockData, + block_header: BlockHeader, contract_deployment_data: ContractDeploymentData, private_global_variables: PrivateGlobalVariables, } @@ -104,7 +104,7 @@ struct PrivateContextInputs { // docs:start:public-context-inputs struct PublicContextInputs { call_context: CallContext, - block_data: HistoricBlockData, + block_header: BlockHeader, public_global_variables: PublicGlobalVariables, } @@ -141,8 +141,8 @@ impl CallContext { } } -// docs:start:historic-block-data -struct HistoricBlockData { +// docs:start:block-header +struct BlockHeader { note_hash_tree_root : Field, nullifier_tree_root : Field, contract_tree_root : Field, @@ -151,11 +151,11 @@ struct HistoricBlockData { public_data_tree_root: Field, global_variables_hash: Field, } -// docs:end:historic-block-data +// docs:end:block-header -impl HistoricBlockData { +impl BlockHeader { // NOTE: this order must match the order in `private_circuit_public_inputs.hpp` - pub fn serialize(self) -> [Field; HISTORIC_BLOCK_DATA_LENGTH] { + pub fn serialize(self) -> [Field; BLOCK_HEADER_LENGTH] { [ self.note_hash_tree_root, self.nullifier_tree_root, @@ -167,8 +167,8 @@ impl HistoricBlockData { ] } - pub fn deserialize(deserialized: [Field; HISTORIC_BLOCK_DATA_LENGTH]) -> Self { - HistoricBlockData { + pub fn deserialize(deserialized: [Field; BLOCK_HEADER_LENGTH]) -> Self { + BlockHeader { note_hash_tree_root: deserialized[0], nullifier_tree_root: deserialized[1], contract_tree_root: deserialized[2], @@ -184,7 +184,7 @@ impl HistoricBlockData { } pub fn block_hash(self) -> Field { - // TODO(#3442): Unify the ordering in `HistoricBlockData::serialize` function and the ordering + // TODO(#3442): Unify the ordering in `BlockHeader::serialize` function and the ordering // in the block hash preimage --> This requires changes in the circuits. let inputs = [ self.global_variables_hash, @@ -234,7 +234,7 @@ struct PrivateCircuitPublicInputs { unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256], encrypted_log_preimages_length: Field, unencrypted_log_preimages_length: Field, - block_data: HistoricBlockData, + block_header: BlockHeader, contract_deployment_data: ContractDeploymentData, chain_id: Field, version: Field, @@ -258,7 +258,7 @@ impl PrivateCircuitPublicInputs { fields.push_array(self.unencrypted_logs_hash); fields.push(self.encrypted_log_preimages_length); fields.push(self.unencrypted_log_preimages_length); - fields.push_array(self.block_data.serialize()); + fields.push_array(self.block_header.serialize()); fields.push(self.contract_deployment_data.hash()); fields.push(self.chain_id); fields.push(self.version); @@ -282,7 +282,7 @@ impl PrivateCircuitPublicInputs { fields.push_array(self.unencrypted_logs_hash); fields.push(self.encrypted_log_preimages_length); fields.push(self.unencrypted_log_preimages_length); - fields.push_array(self.block_data.serialize()); + fields.push_array(self.block_header.serialize()); fields.push_array(self.contract_deployment_data.serialize()); fields.push(self.chain_id); fields.push(self.version); @@ -341,7 +341,7 @@ struct PublicCircuitPublicInputs { new_l2_to_l1_msgs: [Field; crate::abi::MAX_NEW_L2_TO_L1_MSGS_PER_CALL], unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256], unencrypted_log_preimages_length: Field, - block_data: HistoricBlockData, + block_header: BlockHeader, prover_address: Field, } @@ -365,7 +365,7 @@ impl PublicCircuitPublicInputs { inputs.push_array(self.unencrypted_logs_hash); inputs.push(self.unencrypted_log_preimages_length); - inputs.push_array(self.block_data.serialize()); + inputs.push_array(self.block_header.serialize()); inputs.push(self.prover_address); pedersen_hash(inputs.storage, GENERATOR_INDEX__PUBLIC_CIRCUIT_PUBLIC_INPUTS) @@ -388,7 +388,7 @@ impl PublicCircuitPublicInputs { fields.push_array(self.new_l2_to_l1_msgs); fields.push_array(self.unencrypted_logs_hash); fields.push(self.unencrypted_log_preimages_length); - fields.push_array(self.block_data.serialize()); + fields.push_array(self.block_header.serialize()); fields.push(self.prover_address); fields.storage } diff --git a/yarn-project/aztec-nr/aztec/src/constants_gen.nr b/yarn-project/aztec-nr/aztec/src/constants_gen.nr index 368810a0a42..6ac5589e0f8 100644 --- a/yarn-project/aztec-nr/aztec/src/constants_gen.nr +++ b/yarn-project/aztec-nr/aztec/src/constants_gen.nr @@ -73,7 +73,7 @@ global CONTRACT_SUBTREE_SIBLING_PATH_LENGTH: Field = 15; global NOTE_HASH_SUBTREE_HEIGHT: Field = 7; global NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH: Field = 25; global NULLIFIER_SUBTREE_HEIGHT: Field = 7; -global HISTORIC_BLOCKS_TREE_HEIGHT: Field = 16; +global BLOCKS_TREE_HEIGHT: Field = 16; global NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH: Field = 13; global L1_TO_L2_MSG_SUBTREE_HEIGHT: Field = 4; global L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH: Field = 12; @@ -98,7 +98,7 @@ global MAX_NOTES_PER_PAGE: Field = 10; // VIEW_NOTE_ORACLE_RETURN_LENGTH = MAX_NOTES_PER_PAGE * (MAX_NOTE_FIELDS_LENGTH + 1) + 2; global VIEW_NOTE_ORACLE_RETURN_LENGTH: Field = 212; global CALL_CONTEXT_LENGTH: Field = 7; -global HISTORIC_BLOCK_DATA_LENGTH: Field = 7; +global BLOCK_HEADER_LENGTH: Field = 7; global FUNCTION_DATA_LENGTH: Field = 4; global CONTRACT_DEPLOYMENT_DATA_LENGTH: Field = 6; // Change this ONLY if you have changed the PrivateCircuitPublicInputs structure. diff --git a/yarn-project/aztec-nr/aztec/src/context.nr b/yarn-project/aztec-nr/aztec/src/context.nr index 3efe8bda4ac..720ce9981fb 100644 --- a/yarn-project/aztec-nr/aztec/src/context.nr +++ b/yarn-project/aztec-nr/aztec/src/context.nr @@ -19,7 +19,7 @@ use crate::abi::{ hash_args, CallContext, ContractDeploymentData, - HistoricBlockData, + BlockHeader, FunctionData, PrivateCircuitPublicInputs, PublicCircuitPublicInputs, @@ -46,7 +46,7 @@ use crate::oracle::{ public_call::call_public_function_internal, enqueue_public_function_call::enqueue_public_function_call_internal, context::get_portal_address, - get_block_data::get_block_data, + get_block_header::get_block_header, }; use dep::std::option::Option; @@ -71,7 +71,7 @@ struct PrivateContext { new_l2_to_l1_msgs : BoundedVec, // docs:end:private-context - block_data: HistoricBlockData, + block_header: BlockHeader, // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) // encrypted_logs_preimages: Vec, @@ -93,7 +93,7 @@ impl PrivateContext { new_nullifiers: BoundedVec::new(0), nullified_commitments: BoundedVec::new(0), - block_data: inputs.block_data, + block_header: inputs.block_header, private_call_stack: BoundedVec::new(0), public_call_stack: BoundedVec::new(0), @@ -129,8 +129,8 @@ impl PrivateContext { self.inputs.call_context.function_selector } - pub fn get_block_data(self, block_number: Field) -> HistoricBlockData { - get_block_data(block_number, self) + pub fn get_block_header(self, block_number: Field) -> BlockHeader { + get_block_header(block_number, self) } pub fn finish(self) -> abi::PrivateCircuitPublicInputs { @@ -156,7 +156,7 @@ impl PrivateContext { unencrypted_logs_hash: unencrypted_logs_hash, encrypted_log_preimages_length: encrypted_log_preimages_length, unencrypted_log_preimages_length: unencrypted_log_preimages_length, - block_data: self.block_data, + block_header: self.block_header, contract_deployment_data: self.inputs.contract_deployment_data, chain_id: self.inputs.private_global_variables.chain_id, version: self.inputs.private_global_variables.version, @@ -207,7 +207,7 @@ impl PrivateContext { ) // docs:end:context_consume_l1_to_l2_message { - let nullifier = process_l1_to_l2_message(self.block_data.l1_to_l2_messages_tree_root, self.this_address(), self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret); + let nullifier = process_l1_to_l2_message(self.block_header.l1_to_l2_messages_tree_root, self.this_address(), self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret); // Push nullifier (and the "commitment" corresponding to this can be "empty") self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT) @@ -289,7 +289,7 @@ impl PrivateContext { unencrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 141), encrypted_log_preimages_length: fields[143], unencrypted_log_preimages_length: fields[144], - block_data: HistoricBlockData { + block_header: BlockHeader { // Must match order in `private_circuit_public_inputs.hpp` note_hash_tree_root : fields[145], nullifier_tree_root : fields[146], @@ -391,7 +391,7 @@ impl PrivateContext { new_l2_to_l1_msgs:[0; MAX_NEW_L2_TO_L1_MSGS_PER_CALL], unencrypted_logs_hash:[0; NUM_FIELDS_PER_SHA256], unencrypted_log_preimages_length: 0, - block_data: HistoricBlockData::empty(), + block_header: BlockHeader::empty(), prover_address: 0, }, is_execution_request: true, @@ -439,7 +439,7 @@ struct PublicContext { unencrypted_logs_hash: BoundedVec, unencrypted_logs_preimages_length: Field, - block_data: HistoricBlockData, + block_header: BlockHeader, prover_address: Field, } @@ -466,7 +466,7 @@ impl PublicContext { unencrypted_logs_hash: BoundedVec::new(0), unencrypted_logs_preimages_length: 0, - block_data: inputs.block_data, + block_header: inputs.block_header, prover_address: 0, // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) @@ -526,7 +526,7 @@ impl PublicContext { new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage, unencrypted_logs_hash: unencrypted_logs_hash, unencrypted_log_preimages_length: unencrypted_log_preimages_length, - block_data: self.inputs.block_data, + block_header: self.inputs.block_header, prover_address: self.prover_address, }; pub_circuit_pub_inputs @@ -548,7 +548,7 @@ impl PublicContext { // Note this returns self to get around an issue where mutable structs do not maintain mutations unless reassigned pub fn consume_l1_to_l2_message(&mut self, msg_key: Field, content: Field, secret: Field) { let this = (*self).this_address(); - let nullifier = process_l1_to_l2_message(self.block_data.l1_to_l2_messages_tree_root, this, self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret); + let nullifier = process_l1_to_l2_message(self.block_header.l1_to_l2_messages_tree_root, this, self.this_portal_address(), self.chain_id(), self.version(), msg_key, content, secret); // Push nullifier (and the "commitment" corresponding to this can be "empty") self.push_new_nullifier(nullifier, EMPTY_NULLIFIED_COMMITMENT) diff --git a/yarn-project/aztec-nr/aztec/src/oracle.nr b/yarn-project/aztec-nr/aztec/src/oracle.nr index 4bed8383bfa..6a7aac259db 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle.nr @@ -14,7 +14,7 @@ mod get_secret_key; mod get_sibling_path; mod rand; mod enqueue_public_function_call; -mod get_block_data; +mod get_block_header; mod public_call; mod notes; mod storage; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_block_data.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_block_data.nr deleted file mode 100644 index 2b645a62dd9..00000000000 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_block_data.nr +++ /dev/null @@ -1,39 +0,0 @@ -use dep::std::merkle::compute_merkle_root; -use crate::{ - abi::HistoricBlockData, - constants_gen::{ - HISTORIC_BLOCK_DATA_LENGTH, - HISTORIC_BLOCKS_TREE_HEIGHT, - }, - context::PrivateContext, - oracle::get_membership_witness::{ - get_membership_witness, - MembershipWitness, - }, -}; - -#[oracle(getBlockData)] -fn get_block_data_oracle(_block_number: Field) -> [Field; HISTORIC_BLOCK_DATA_LENGTH] {} - -unconstrained pub fn get_block_data_internal(block_number: Field) -> HistoricBlockData { - let block_data = get_block_data_oracle(block_number); - HistoricBlockData::deserialize(block_data) -} - -pub fn get_block_data(block_number: Field, context: PrivateContext) -> HistoricBlockData { - // 1) Get historic block data from oracle at the given block - let block_data = get_block_data_internal(block_number); - - // 2) Compute the block hash from the block data - let block_hash = block_data.block_hash(); - - // 3) Get the membership wintess of the block in the blocks tree - let blocks_tree_id = 5; // TODO(#3443) - let witness: MembershipWitness = get_membership_witness(block_number, blocks_tree_id, block_hash); - - // 4) Check that the block is in the blocks tree (i.e. the witness is valid) - assert(context.block_data.blocks_tree_root == compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in blocks tree failed"); - - // 5) Return the block data - block_data -} diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_block_header.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_block_header.nr new file mode 100644 index 00000000000..5f453221952 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_block_header.nr @@ -0,0 +1,39 @@ +use dep::std::merkle::compute_merkle_root; +use crate::{ + abi::BlockHeader, + constants_gen::{ + BLOCK_HEADER_LENGTH, + BLOCKS_TREE_HEIGHT, + }, + context::PrivateContext, + oracle::get_membership_witness::{ + get_membership_witness, + MembershipWitness, + }, +}; + +#[oracle(getBlockHeader)] +fn get_block_header_oracle(_block_number: Field) -> [Field; BLOCK_HEADER_LENGTH] {} + +unconstrained pub fn get_block_header_internal(block_number: Field) -> BlockHeader { + let block_header = get_block_header_oracle(block_number); + BlockHeader::deserialize(block_header) +} + +pub fn get_block_header(block_number: Field, context: PrivateContext) -> BlockHeader { + // 1) Get block header of a given block from oracle + let block_header = get_block_header_internal(block_number); + + // 2) Compute the block hash from the block header + let block_hash = block_header.block_hash(); + + // 3) Get the membership wintess of the block in the blocks tree + let blocks_tree_id = 5; // TODO(#3443) + let witness: MembershipWitness = get_membership_witness(block_number, blocks_tree_id, block_hash); + + // 4) Check that the block is in the blocks tree (i.e. the witness is valid) + assert(context.block_header.blocks_tree_root == compute_merkle_root(block_hash, witness.index, witness.path), "Proving membership of a block in blocks tree failed"); + + // 5) Return the block header + block_header +} diff --git a/yarn-project/aztec.js/src/artifacts/ecdsa_account_contract.json b/yarn-project/aztec.js/src/artifacts/ecdsa_account_contract.json index 0c4d56e844c..491da2af12c 100644 --- a/yarn-project/aztec.js/src/artifacts/ecdsa_account_contract.json +++ b/yarn-project/aztec.js/src/artifacts/ecdsa_account_contract.json @@ -365,10 +365,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", @@ -632,10 +632,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", diff --git a/yarn-project/aztec.js/src/artifacts/schnorr_account_contract.json b/yarn-project/aztec.js/src/artifacts/schnorr_account_contract.json index 8163729ec65..f05dd9664f7 100644 --- a/yarn-project/aztec.js/src/artifacts/schnorr_account_contract.json +++ b/yarn-project/aztec.js/src/artifacts/schnorr_account_contract.json @@ -353,10 +353,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", @@ -620,10 +620,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", diff --git a/yarn-project/aztec.js/src/artifacts/schnorr_single_key_account_contract.json b/yarn-project/aztec.js/src/artifacts/schnorr_single_key_account_contract.json index cc776fe5d4e..fb155f98ec1 100644 --- a/yarn-project/aztec.js/src/artifacts/schnorr_single_key_account_contract.json +++ b/yarn-project/aztec.js/src/artifacts/schnorr_single_key_account_contract.json @@ -288,10 +288,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", @@ -555,10 +555,10 @@ } }, { - "name": "block_data", + "name": "block_header", "type": { "kind": "struct", - "path": "aztec::abi::HistoricBlockData", + "path": "aztec::abi::BlockHeader", "fields": [ { "name": "note_hash_tree_root", diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index dd249bbb5d6..ecee67a7528 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -531,13 +531,13 @@ function computePrivateInputsHash(input: PrivateCircuitPublicInputs) { ...input.unencryptedLogsHash.map(fr => fr.toBuffer()), input.encryptedLogPreimagesLength.toBuffer(), input.unencryptedLogPreimagesLength.toBuffer(), - input.historicBlockData.noteHashTreeRoot.toBuffer(), - input.historicBlockData.nullifierTreeRoot.toBuffer(), - input.historicBlockData.contractTreeRoot.toBuffer(), - input.historicBlockData.l1ToL2MessagesTreeRoot.toBuffer(), - input.historicBlockData.blocksTreeRoot.toBuffer(), - input.historicBlockData.publicDataTreeRoot.toBuffer(), - input.historicBlockData.globalVariablesHash.toBuffer(), + input.blockHeader.noteHashTreeRoot.toBuffer(), + input.blockHeader.nullifierTreeRoot.toBuffer(), + input.blockHeader.contractTreeRoot.toBuffer(), + input.blockHeader.l1ToL2MessagesTreeRoot.toBuffer(), + input.blockHeader.blocksTreeRoot.toBuffer(), + input.blockHeader.publicDataTreeRoot.toBuffer(), + input.blockHeader.globalVariablesHash.toBuffer(), computeContractDeploymentDataHash(input.contractDeploymentData).toBuffer(), input.chainId.toBuffer(), input.version.toBuffer(), @@ -599,13 +599,13 @@ function computePublicInputsHash(input: PublicCircuitPublicInputs) { ...input.newL2ToL1Msgs.map(fr => fr.toBuffer()), ...input.unencryptedLogsHash.map(fr => fr.toBuffer()), input.unencryptedLogPreimagesLength.toBuffer(), - input.historicBlockData.noteHashTreeRoot.toBuffer(), - input.historicBlockData.nullifierTreeRoot.toBuffer(), - input.historicBlockData.contractTreeRoot.toBuffer(), - input.historicBlockData.l1ToL2MessagesTreeRoot.toBuffer(), - input.historicBlockData.blocksTreeRoot.toBuffer(), - input.historicBlockData.publicDataTreeRoot.toBuffer(), - input.historicBlockData.globalVariablesHash.toBuffer(), + input.blockHeader.noteHashTreeRoot.toBuffer(), + input.blockHeader.nullifierTreeRoot.toBuffer(), + input.blockHeader.contractTreeRoot.toBuffer(), + input.blockHeader.l1ToL2MessagesTreeRoot.toBuffer(), + input.blockHeader.blocksTreeRoot.toBuffer(), + input.blockHeader.publicDataTreeRoot.toBuffer(), + input.blockHeader.globalVariablesHash.toBuffer(), input.proverAddress.toBuffer(), ]; if (toHash.length != PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH) { diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 3cbbab21121..e5fc7359815 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -42,7 +42,7 @@ export const CONTRACT_SUBTREE_SIBLING_PATH_LENGTH = 15; export const NOTE_HASH_SUBTREE_HEIGHT = 7; export const NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH = 25; export const NULLIFIER_SUBTREE_HEIGHT = 7; -export const HISTORIC_BLOCKS_TREE_HEIGHT = 16; +export const BLOCKS_TREE_HEIGHT = 16; export const NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 13; export const L1_TO_L2_MSG_SUBTREE_HEIGHT = 4; export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12; @@ -56,7 +56,7 @@ export const GET_NOTE_ORACLE_RETURN_LENGTH = 23; export const MAX_NOTES_PER_PAGE = 10; export const VIEW_NOTE_ORACLE_RETURN_LENGTH = 212; export const CALL_CONTEXT_LENGTH = 7; -export const HISTORIC_BLOCK_DATA_LENGTH = 7; +export const BLOCK_HEADER_LENGTH = 7; export const FUNCTION_DATA_LENGTH = 4; export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6; export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 155; diff --git a/yarn-project/circuits.js/src/structs/index.ts b/yarn-project/circuits.js/src/structs/index.ts index c8ed1585aea..7ce2c3d0ced 100644 --- a/yarn-project/circuits.js/src/structs/index.ts +++ b/yarn-project/circuits.js/src/structs/index.ts @@ -11,7 +11,7 @@ export * from './kernel/private_kernel.js'; export * from './kernel/public_kernel.js'; export * from './kernel/combined_accumulated_data.js'; export * from './kernel/combined_constant_data.js'; -export * from './kernel/historic_block_data.js'; +export * from './kernel/block_header.js'; export * from './kernel/previous_kernel_data.js'; export * from './kernel/public_inputs.js'; export * from './kernel/public_inputs_final.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/block_header.test.ts b/yarn-project/circuits.js/src/structs/kernel/block_header.test.ts new file mode 100644 index 00000000000..3bb78282c2a --- /dev/null +++ b/yarn-project/circuits.js/src/structs/kernel/block_header.test.ts @@ -0,0 +1,17 @@ +import { BlockHeader } from './block_header.js'; + +describe('BlockHeader', () => { + it('serializes to buffer and back', () => { + const blockHeader = BlockHeader.random(); + const serialized = blockHeader.toBuffer(); + const deserialized = BlockHeader.fromBuffer(serialized); + expect(deserialized).toEqual(blockHeader); + }); + + it('serializes to string and back', () => { + const blockHeader = BlockHeader.random(); + const serialized = blockHeader.toString(); + const deserialized = BlockHeader.fromString(serialized); + expect(deserialized).toEqual(blockHeader); + }); +}); diff --git a/yarn-project/circuits.js/src/structs/kernel/historic_block_data.ts b/yarn-project/circuits.js/src/structs/kernel/block_header.ts similarity index 80% rename from yarn-project/circuits.js/src/structs/kernel/historic_block_data.ts rename to yarn-project/circuits.js/src/structs/kernel/block_header.ts index eda21d334f1..1c83f50351c 100644 --- a/yarn-project/circuits.js/src/structs/kernel/historic_block_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/block_header.ts @@ -5,14 +5,14 @@ import { FieldsOf } from '../../utils/jsUtils.js'; import { serializeToBuffer } from '../../utils/serialize.js'; /** - * The string encoding used for serializing HistoricBlockData objects. + * The string encoding used for serializing BlockHeader objects. */ const STRING_ENCODING: BufferEncoding = 'hex'; /** * Information about the tree roots used for both public and private kernels. */ -export class HistoricBlockData { +export class BlockHeader { constructor( /** * Root of the note hash tree at the time of when this information was assembled. @@ -31,7 +31,7 @@ export class HistoricBlockData { */ public l1ToL2MessagesTreeRoot: Fr, /** - * Root of the historic blocks tree at the time of when this information was assembled. + * Root of the blocks tree at the time of when this information was assembled. */ public blocksTreeRoot: Fr, /** @@ -48,12 +48,12 @@ export class HistoricBlockData { public globalVariablesHash: Fr, ) {} - static from(fields: FieldsOf) { - return new HistoricBlockData(...HistoricBlockData.getFields(fields)); + static from(fields: FieldsOf) { + return new BlockHeader(...BlockHeader.getFields(fields)); } static random() { - return new HistoricBlockData( + return new BlockHeader( Fr.random(), Fr.random(), Fr.random(), @@ -65,7 +65,7 @@ export class HistoricBlockData { ); } - static getFields(fields: FieldsOf) { + static getFields(fields: FieldsOf) { return [ fields.noteHashTreeRoot, fields.nullifierTreeRoot, @@ -79,7 +79,7 @@ export class HistoricBlockData { } toBuffer() { - return serializeToBuffer(...HistoricBlockData.getFields(this)); + return serializeToBuffer(...BlockHeader.getFields(this)); } toString() { @@ -88,7 +88,7 @@ export class HistoricBlockData { } /** - * Return the historic block data as an array of items in the order they are serialized in noir. + * Return the block header as an array of items in the order they are serialized in noir. * @returns Array of items in the order they are stored in the contract */ toArray(): Fr[] { @@ -106,7 +106,7 @@ export class HistoricBlockData { static fromBuffer(buffer: Buffer | BufferReader) { const reader = BufferReader.asReader(buffer); - return new HistoricBlockData( + return new BlockHeader( Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader), @@ -119,7 +119,7 @@ export class HistoricBlockData { } static fromString(str: string) { - return HistoricBlockData.fromBuffer(Buffer.from(str, STRING_ENCODING)); + return BlockHeader.fromBuffer(Buffer.from(str, STRING_ENCODING)); } isEmpty() { @@ -136,6 +136,6 @@ export class HistoricBlockData { } static empty() { - return new HistoricBlockData(Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO); + return new BlockHeader(Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts index 34f10df6761..2410d624191 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_constant_data.ts @@ -2,7 +2,7 @@ import { BufferReader } from '@aztec/foundation/serialize'; import { serializeToBuffer } from '../../utils/serialize.js'; import { TxContext } from '../tx_context.js'; -import { HistoricBlockData } from './historic_block_data.js'; +import { BlockHeader } from './block_header.js'; /** * Data that is constant/not modified by neither of the kernels. @@ -12,7 +12,7 @@ export class CombinedConstantData { /** * Roots of the trees relevant for both kernel circuits. */ - public blockData: HistoricBlockData, + public blockHeader: BlockHeader, /** * Context of the transaction. */ @@ -20,7 +20,7 @@ export class CombinedConstantData { ) {} toBuffer() { - return serializeToBuffer(this.blockData, this.txContext); + return serializeToBuffer(this.blockHeader, this.txContext); } /** @@ -30,10 +30,10 @@ export class CombinedConstantData { */ static fromBuffer(buffer: Buffer | BufferReader): CombinedConstantData { const reader = BufferReader.asReader(buffer); - return new CombinedConstantData(reader.readObject(HistoricBlockData), reader.readObject(TxContext)); + return new CombinedConstantData(reader.readObject(BlockHeader), reader.readObject(TxContext)); } static empty() { - return new CombinedConstantData(HistoricBlockData.empty(), TxContext.empty()); + return new CombinedConstantData(BlockHeader.empty(), TxContext.empty()); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/historic_block_data.test.ts b/yarn-project/circuits.js/src/structs/kernel/historic_block_data.test.ts deleted file mode 100644 index 9179c979ca4..00000000000 --- a/yarn-project/circuits.js/src/structs/kernel/historic_block_data.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { HistoricBlockData } from './historic_block_data.js'; - -describe('HistoricBlockData', () => { - it('serializes to buffer and back', () => { - const historicBlockData = HistoricBlockData.random(); - const serialized = historicBlockData.toBuffer(); - const deserialized = HistoricBlockData.fromBuffer(serialized); - expect(deserialized).toEqual(historicBlockData); - }); - - it('serializes to string and back', () => { - const historicBlockData = HistoricBlockData.random(); - const serialized = historicBlockData.toString(); - const deserialized = HistoricBlockData.fromString(serialized); - expect(deserialized).toEqual(historicBlockData); - }); -}); diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 11dd3c26d39..1b3fe3222fc 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -16,7 +16,7 @@ import { import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; -import { HistoricBlockData } from './index.js'; +import { BlockHeader } from './index.js'; import { ContractDeploymentData } from './tx_context.js'; /** @@ -90,9 +90,9 @@ export class PrivateCircuitPublicInputs { */ public unencryptedLogPreimagesLength: Fr, /** - * Historic roots of the data trees, used to calculate the block hash the user is proving against. + * Historical roots of the data trees, used to calculate the block hash the user is proving against. */ - public historicBlockData: HistoricBlockData, + public blockHeader: BlockHeader, /** * Deployment data of contracts being deployed in this kernel iteration. */ @@ -136,7 +136,7 @@ export class PrivateCircuitPublicInputs { makeTuple(NUM_FIELDS_PER_SHA256, Fr.zero), Fr.ZERO, Fr.ZERO, - HistoricBlockData.empty(), + BlockHeader.empty(), ContractDeploymentData.empty(), Fr.ZERO, Fr.ZERO, @@ -161,7 +161,7 @@ export class PrivateCircuitPublicInputs { isFrArrayEmpty(this.unencryptedLogsHash) && this.encryptedLogPreimagesLength.isZero() && this.unencryptedLogPreimagesLength.isZero() && - this.historicBlockData.isEmpty() && + this.blockHeader.isEmpty() && this.contractDeploymentData.isEmpty() && this.chainId.isZero() && this.version.isZero() @@ -190,7 +190,7 @@ export class PrivateCircuitPublicInputs { fields.unencryptedLogsHash, fields.encryptedLogPreimagesLength, fields.unencryptedLogPreimagesLength, - fields.historicBlockData, + fields.blockHeader, fields.contractDeploymentData, fields.chainId, fields.version, diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index aafd9b454bb..bb160941456 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -15,7 +15,7 @@ import { import { FieldsOf, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; -import { HistoricBlockData } from './index.js'; +import { BlockHeader } from './index.js'; /** * Contract storage read operation on a specific contract. @@ -200,7 +200,7 @@ export class PublicCircuitPublicInputs { /** * Root of the commitment trees when the call started. */ - public historicBlockData: HistoricBlockData, + public blockHeader: BlockHeader, /** * Address of the prover. */ @@ -233,7 +233,7 @@ export class PublicCircuitPublicInputs { makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, Fr.zero), makeTuple(2, Fr.zero), Fr.ZERO, - HistoricBlockData.empty(), + BlockHeader.empty(), AztecAddress.ZERO, ); } @@ -252,7 +252,7 @@ export class PublicCircuitPublicInputs { isFrArrayEmpty(this.newL2ToL1Msgs) && isFrArrayEmpty(this.unencryptedLogsHash) && this.unencryptedLogPreimagesLength.isZero() && - this.historicBlockData.isEmpty() && + this.blockHeader.isEmpty() && this.proverAddress.isZero() ); } @@ -275,7 +275,7 @@ export class PublicCircuitPublicInputs { fields.newL2ToL1Msgs, fields.unencryptedLogsHash, fields.unencryptedLogPreimagesLength, - fields.historicBlockData, + fields.blockHeader, fields.proverAddress, ] as const; } diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 454532ec646..1d6babb0ebe 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -2,8 +2,8 @@ import { Fr } from '@aztec/foundation/fields'; import { BufferReader, Tuple } from '@aztec/foundation/serialize'; import { + BLOCKS_TREE_HEIGHT, CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, - HISTORIC_BLOCKS_TREE_HEIGHT, KERNELS_PER_BASE_ROLLUP, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP, @@ -56,9 +56,9 @@ export class NullifierLeafPreimage { export class ConstantRollupData { constructor( /** - * Snapshot of the historic blocks roots tree at the start of the rollup. + * Snapshot of the blocks tree at the start of the rollup. */ - public startHistoricBlocksTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public startBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** * Root of the private kernel verification key tree. @@ -100,7 +100,7 @@ export class ConstantRollupData { static getFields(fields: FieldsOf) { return [ - fields.startHistoricBlocksTreeRootsSnapshot, + fields.startBlocksTreeSnapshot, fields.privateKernelVkTreeRoot, fields.publicKernelVkTreeRoot, fields.baseRollupVkHash, @@ -140,9 +140,9 @@ export class BaseRollupInputs { */ public startPublicDataTreeRoot: Fr, /** - * Snapshot of the historic blocks tree at the start of the base rollup circuit. + * Snapshot of the blocks tree at the start of the base rollup circuit. */ - public startHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot, + public startBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** * The nullifiers to be inserted in the tree, sorted high to low. @@ -194,10 +194,10 @@ export class BaseRollupInputs { typeof MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP >, /** - * Membership witnesses of historic blocks referred by each of the 2 kernels. + * Membership witnesses of blocks referred by each of the 2 kernels. */ - public historicBlocksTreeRootMembershipWitnesses: Tuple< - MembershipWitness, + public blocksTreeRootMembershipWitnesses: Tuple< + MembershipWitness, typeof KERNELS_PER_BASE_ROLLUP >, /** @@ -217,7 +217,7 @@ export class BaseRollupInputs { fields.startNullifierTreeSnapshot, fields.startContractTreeSnapshot, fields.startPublicDataTreeRoot, - fields.startHistoricBlocksTreeSnapshot, + fields.startBlocksTreeSnapshot, fields.sortedNewNullifiers, fields.sortednewNullifiersIndexes, fields.lowNullifierLeafPreimages, @@ -227,7 +227,7 @@ export class BaseRollupInputs { fields.newContractsSubtreeSiblingPath, fields.newPublicDataUpdateRequestsSiblingPaths, fields.newPublicDataReadsSiblingPaths, - fields.historicBlocksTreeRootMembershipWitnesses, + fields.blocksTreeRootMembershipWitnesses, fields.constants, ] as const; } diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index 5688f5e5f5c..087accf1526 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -2,7 +2,7 @@ import { Fr } from '@aztec/foundation/fields'; import { BufferReader, Tuple } from '@aztec/foundation/serialize'; import { - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '../../constants.gen.js'; @@ -37,13 +37,13 @@ export class RootRollupInputs { */ public startL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic block roots tree at the start of the rollup. + * Snapshot of the historical block roots tree at the start of the rollup. */ - public startHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot, + public startBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** - * Sibling path of the new historic block roots tree root. + * Sibling path of the new block tree root. */ - public newHistoricBlocksTreeSiblingPath: Tuple, + public newBlocksTreeSiblingPath: Tuple, ) {} toBuffer() { @@ -60,8 +60,8 @@ export class RootRollupInputs { fields.newL1ToL2Messages, fields.newL1ToL2MessagesTreeRootSiblingPath, fields.startL1ToL2MessagesTreeSnapshot, - fields.startHistoricBlocksTreeSnapshot, - fields.newHistoricBlocksTreeSiblingPath, + fields.startBlocksTreeSnapshot, + fields.newBlocksTreeSiblingPath, ] as const; } } @@ -120,22 +120,22 @@ export class RootRollupPublicInputs { public endPublicDataTreeRoot: Fr, /** - * Snapshot of the historic note hash tree roots tree at the start of the rollup. + * Snapshot of the historical note hash tree roots tree at the start of the rollup. */ - public startTreeOfHistoricNoteHashTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public startTreeOfHistoricalNoteHashTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic note hash tree roots tree at the end of the rollup. + * Snapshot of the historical note hash tree roots tree at the end of the rollup. */ - public endTreeOfHistoricNoteHashTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public endTreeOfHistoricalNoteHashTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic contract tree roots tree at the start of the rollup. + * Snapshot of the historical contract tree roots tree at the start of the rollup. */ - public startTreeOfHistoricContractTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public startTreeOfHistoricalContractTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic contract tree roots tree at the end of the rollup. + * Snapshot of the historical contract tree roots tree at the end of the rollup. */ - public endTreeOfHistoricContractTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public endTreeOfHistoricalContractTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** * Snapshot of the L1 to L2 message tree at the start of the rollup. @@ -147,22 +147,22 @@ export class RootRollupPublicInputs { public endL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic L1 to L2 message tree roots tree at the start of the rollup. + * Snapshot of the historical L1 to L2 message tree roots tree at the start of the rollup. */ - public startTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public startTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic L1 to L2 message tree roots tree at the end of the rollup. + * Snapshot of the historical L1 to L2 message tree roots tree at the end of the rollup. */ - public endTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot: AppendOnlyTreeSnapshot, + public endTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic blocks tree roots tree at the start of the rollup. + * Snapshot of the blocks tree roots tree at the start of the rollup. */ - public startHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot, + public startBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** - * Snapshot of the historic blocks tree roots tree at the end of the rollup. + * Snapshot of the blocks tree roots tree at the end of the rollup. */ - public endHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot, + public endBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** * Hash of the calldata. @@ -186,16 +186,16 @@ export class RootRollupPublicInputs { fields.endContractTreeSnapshot, fields.startPublicDataTreeRoot, fields.endPublicDataTreeRoot, - fields.startTreeOfHistoricNoteHashTreeRootsSnapshot, - fields.endTreeOfHistoricNoteHashTreeRootsSnapshot, - fields.startTreeOfHistoricContractTreeRootsSnapshot, - fields.endTreeOfHistoricContractTreeRootsSnapshot, + fields.startTreeOfHistoricalNoteHashTreeRootsSnapshot, + fields.endTreeOfHistoricalNoteHashTreeRootsSnapshot, + fields.startTreeOfHistoricalContractTreeRootsSnapshot, + fields.endTreeOfHistoricalContractTreeRootsSnapshot, fields.startL1ToL2MessagesTreeSnapshot, fields.endL1ToL2MessagesTreeSnapshot, - fields.startTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot, - fields.endTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot, - fields.startHistoricBlocksTreeSnapshot, - fields.endHistoricBlocksTreeSnapshot, + fields.startTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot, + fields.endTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot, + fields.startBlocksTreeSnapshot, + fields.endBlocksTreeSnapshot, fields.calldataHash, fields.l1ToL2MessagesHash, ] as const; diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 6c03169795a..2c08c857243 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -7,8 +7,10 @@ import { ARGS_LENGTH, AggregationObject, AppendOnlyTreeSnapshot, + BLOCKS_TREE_HEIGHT, BaseOrMergeRollupPublicInputs, BaseRollupInputs, + BlockHeader, CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, CONTRACT_TREE_HEIGHT, CallContext, @@ -28,8 +30,6 @@ import { FunctionData, FunctionSelector, G1AffineElement, - HISTORIC_BLOCKS_TREE_HEIGHT, - HistoricBlockData, KERNELS_PER_BASE_ROLLUP, KernelCircuitPublicInputs, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -114,13 +114,13 @@ export function makeTxContext(seed: number): TxContext { } /** - * Creates an arbitrary combined historic tree roots object from the given seed. + * Creates an arbitrary combined historical tree roots object from the given seed. * Note: "Combined" indicates that it's the combined output of both private and public circuit flows. - * @param seed - The seed to use for generating the combined historic tree roots. - * @returns A combined historic tree roots object. + * @param seed - The seed to use for generating the combined historical tree roots. + * @returns A combined historical tree roots object. */ -export function makeHistoricBlockData(seed: number): HistoricBlockData { - return new HistoricBlockData( +export function makeBlockHeader(seed: number): BlockHeader { + return new BlockHeader( fr(seed), fr(seed + 1), fr(seed + 2), @@ -138,7 +138,7 @@ export function makeHistoricBlockData(seed: number): HistoricBlockData { * @returns A constant data object. */ export function makeConstantData(seed = 1): CombinedConstantData { - return new CombinedConstantData(makeHistoricBlockData(seed), makeTxContext(seed + 4)); + return new CombinedConstantData(makeBlockHeader(seed), makeTxContext(seed + 4)); } /** @@ -340,7 +340,7 @@ export function makePublicCircuitPublicInputs( tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, fr, seed + 0x900), tupleGenerator(2, fr, seed + 0x901), fr(seed + 0x902), - makeHistoricBlockData(seed + 0xa00), + makeBlockHeader(seed + 0xa00), makeAztecAddress(seed + 0xb01), ); } @@ -679,7 +679,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn unencryptedLogsHash: makeTuple(NUM_FIELDS_PER_SHA256, fr, seed + 0xa00), encryptedLogPreimagesLength: fr(seed + 0xb00), unencryptedLogPreimagesLength: fr(seed + 0xc00), - historicBlockData: makeHistoricBlockData(seed + 0xd00), + blockHeader: makeBlockHeader(seed + 0xd00), contractDeploymentData: makeContractDeploymentData(seed + 0xe00), chainId: fr(seed + 0x1400), version: fr(seed + 0x1500), @@ -726,7 +726,7 @@ export function makeConstantBaseRollupData( globalVariables: GlobalVariables | undefined = undefined, ): ConstantRollupData { return ConstantRollupData.from({ - startHistoricBlocksTreeRootsSnapshot: makeAppendOnlyTreeSnapshot(seed + 0x300), + startBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot(seed + 0x300), privateKernelVkTreeRoot: fr(seed + 0x401), publicKernelVkTreeRoot: fr(seed + 0x402), baseRollupVkHash: fr(seed + 0x403), @@ -840,7 +840,7 @@ export function makeRootRollupInputs(seed = 0, globalVariables?: GlobalVariables makeTuple(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, fr, 0x2100), makeAppendOnlyTreeSnapshot(seed + 0x2200), makeAppendOnlyTreeSnapshot(seed + 0x2200), - makeTuple(HISTORIC_BLOCKS_TREE_HEIGHT, fr, 0x2400), + makeTuple(BLOCKS_TREE_HEIGHT, fr, 0x2400), ); } @@ -866,16 +866,16 @@ export function makeRootRollupPublicInputs( endContractTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), startPublicDataTreeRoot: fr((seed += 0x100)), endPublicDataTreeRoot: fr((seed += 0x100)), - startTreeOfHistoricNoteHashTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - endTreeOfHistoricNoteHashTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - startTreeOfHistoricContractTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - endTreeOfHistoricContractTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + startTreeOfHistoricalNoteHashTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + endTreeOfHistoricalNoteHashTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + startTreeOfHistoricalContractTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + endTreeOfHistoricalContractTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), startL1ToL2MessagesTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), endL1ToL2MessagesTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - startTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - endTreeOfHistoricL1ToL2MessagesTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - startHistoricBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), - endHistoricBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + startTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + endTreeOfHistoricalL1ToL2MessagesTreeRootsSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + startBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), + endBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot((seed += 0x100)), calldataHash: [new Fr(1n), new Fr(2n)], l1ToL2MessagesHash: [new Fr(3n), new Fr(4n)], }); @@ -902,7 +902,7 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { const startNullifierTreeSnapshot = makeAppendOnlyTreeSnapshot(seed + 0x200); const startContractTreeSnapshot = makeAppendOnlyTreeSnapshot(seed + 0x300); const startPublicDataTreeRoot = fr(seed + 0x400); - const startHistoricBlocksTreeSnapshot = makeAppendOnlyTreeSnapshot(seed + 0x500); + const startBlocksTreeSnapshot = makeAppendOnlyTreeSnapshot(seed + 0x500); const lowNullifierLeafPreimages = makeTuple( MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, @@ -935,8 +935,8 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { seed + 0x8000, ); - const historicBlocksTreeRootMembershipWitnesses = makeTuple(KERNELS_PER_BASE_ROLLUP, x => - makeMembershipWitness(HISTORIC_BLOCKS_TREE_HEIGHT, seed + x * 0x1000 + 0x9000), + const blocksTreeRootMembershipWitnesses = makeTuple(KERNELS_PER_BASE_ROLLUP, x => + makeMembershipWitness(BLOCKS_TREE_HEIGHT, seed + x * 0x1000 + 0x9000), ); const constants = makeConstantBaseRollupData(0x100); @@ -948,7 +948,7 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { startNullifierTreeSnapshot, startContractTreeSnapshot, startPublicDataTreeRoot, - startHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot, sortedNewNullifiers, sortednewNullifiersIndexes, lowNullifierLeafPreimages, @@ -957,7 +957,7 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { newContractsSubtreeSiblingPath, newPublicDataUpdateRequestsSiblingPaths, newPublicDataReadsSiblingPaths, - historicBlocksTreeRootMembershipWitnesses, + blocksTreeRootMembershipWitnesses, constants, }); } diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 533bf66783a..6d7805dd4d2 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -28,10 +28,10 @@ import { L1Publisher, RealRollupCircuitSimulator, SoloBlockBuilder, - getHistoricBlockData, + getBlockHeader, getL1Publisher, getVerificationKeys, - makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricTreeRoots, + makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricalTreeRoots, makeProcessedTx, } from '@aztec/sequencer-client'; import { MerkleTreeOperations, MerkleTrees } from '@aztec/world-state'; @@ -152,12 +152,8 @@ describe('L1Publisher integration', () => { }, 100_000); const makeEmptyProcessedTx = async () => { - const historicTreeRoots = await getHistoricBlockData(builderDb, prevGlobals); - const tx = await makeEmptyProcessedTxFromHistoricTreeRoots( - historicTreeRoots, - new Fr(chainId), - new Fr(config.version), - ); + const blockHeader = await getBlockHeader(builderDb, prevGlobals); + const tx = await makeEmptyProcessedTxFromHistoricalTreeRoots(blockHeader, new Fr(chainId), new Fr(config.version)); return tx; }; @@ -166,7 +162,7 @@ describe('L1Publisher integration', () => { const kernelOutput = KernelCircuitPublicInputs.empty(); kernelOutput.constants.txContext.chainId = fr(chainId); kernelOutput.constants.txContext.version = fr(config.version); - kernelOutput.constants.blockData = await getHistoricBlockData(builderDb, prevGlobals); + kernelOutput.constants.blockHeader = await getBlockHeader(builderDb, prevGlobals); kernelOutput.end.publicDataUpdateRequests = makeTuple( MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)), diff --git a/yarn-project/noir-contracts/src/contracts/inclusion_proofs_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/inclusion_proofs_contract/src/main.nr index 7a8871b7218..462f95091be 100644 --- a/yarn-project/noir-contracts/src/contracts/inclusion_proofs_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/inclusion_proofs_contract/src/main.nr @@ -22,13 +22,11 @@ contract InclusionProofs { }, constants_gen::{ NOTE_HASH_TREE_HEIGHT, - NULLIFIER_TREE_HEIGHT, - HISTORIC_BLOCKS_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, GENERATOR_INDEX__PUBLIC_LEAF_INDEX, }, oracle::{ - get_block_data::get_block_data, + get_block_header::get_block_header, get_membership_witness::{ get_membership_witness, MembershipWitness, @@ -103,13 +101,13 @@ contract InclusionProofs { block_number: Field, // The block at which we'll prove that the note exists spare_commitment: Field, // This is only used when the note is not found --> used to test the failure case ) { - // TODO: assert that block number is less than the block number of context.block_data - // --> This will either require a new oracle method that returns block_data.global_variables_hash preimage + // TODO: assert that block number is less than the block number of context.block_header + // --> This will either require a new oracle method that returns block_header.global_variables_hash preimage // or modifying the private context so that we somehow expose it. - // 1) Get historic block data from oracle and ensure that the block hash is included in the current blocks tree + // 1) Get block header from oracle and ensure that the block hash is included in the current blocks tree // root. - let block_data = context.get_block_data(block_number); + let block_header = context.get_block_header(block_number); // 2) Get the note from PXE. let private_values = storage.private_values.at(owner.address); @@ -132,7 +130,7 @@ contract InclusionProofs { // 5) Prove that the commitment is in the note hash tree assert( - block_data.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path), + block_header.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path), "Proving note inclusion failed" ); @@ -146,13 +144,13 @@ contract InclusionProofs { block_number: Field, // The block at which we'll prove that the nullifier does not exists spare_nullifier: Field, // This is only used when the note is not found --> used to test the failure case ) { - // TODO: assert that block number is less than the block number of context.block_data - // --> This will either require a new oracle method that returns block_data.global_variables_hash preimage + // TODO: assert that block number is less than the block number of context.block_header + // --> This will either require a new oracle method that returns block_header.global_variables_hash preimage // or modifying the private context so that we somehow expose it. - // 1) Get historic block data from oracle and ensure that the block hash is included in the current blocks tree + // 1) Get block header from oracle and ensure that the block hash is included in the current blocks tree // root. - let block_data = context.get_block_data(block_number); + let block_header = context.get_block_header(block_number); // 2) Get the note from PXE let private_values = storage.private_values.at(owner.address); @@ -176,7 +174,7 @@ contract InclusionProofs { // 5.a) Compute the low nullifier leaf and prove that it is in the nullifier tree let low_nullifier_leaf = witness.leaf_data.hash(); assert( - block_data.nullifier_tree_root == compute_merkle_root(low_nullifier_leaf, witness.index, witness.path), + block_header.nullifier_tree_root == compute_merkle_root(low_nullifier_leaf, witness.index, witness.path), "Proving nullifier non-inclusion failed: Could not prove low nullifier inclusion" ); @@ -217,13 +215,13 @@ contract InclusionProofs { nullifier: Field, block_number: Field, // The block at which we'll prove that the nullifier not exists in the tree ) { - // TODO: assert that block number is less than the block number of context.block_data - // --> This will either require a new oracle method that returns block_data.global_variables_hash preimage + // TODO: assert that block number is less than the block number of context.block_header + // --> This will either require a new oracle method that returns block_header.global_variables_hash preimage // or modifying the private context so that we somehow expose it. - // 1) Get historic block data from oracle and ensure that the block hash is included in the current blocks tree + // 1) Get block header from oracle and ensure that the block hash is included in the current blocks tree // root. - let block_data = context.get_block_data(block_number); + let block_header = context.get_block_header(block_number); // 2) Get the membership witness of the nullifier let witness = get_nullifier_membership_witness(block_number, nullifier); @@ -236,7 +234,7 @@ contract InclusionProofs { // 5) Prove that the nullifier is in the nullifier tree assert( - block_data.nullifier_tree_root == compute_merkle_root(nullifier_leaf, witness.index, witness.path), + block_header.nullifier_tree_root == compute_merkle_root(nullifier_leaf, witness.index, witness.path), "Proving nullifier inclusion failed" ); @@ -249,13 +247,13 @@ contract InclusionProofs { public_value: Field, block_number: Field, // The block at which we'll prove that the public value exists ) { - // TODO: assert that block number is less than the block number of context.block_data - // --> This will either require a new oracle method that returns block_data.global_variables_hash preimage + // TODO: assert that block number is less than the block number of context.block_header + // --> This will either require a new oracle method that returns block_header.global_variables_hash preimage // or modifying the private context so that we somehow expose it. - // 1) Get historic block data from oracle and ensure that the block hash is included in the current blocks tree + // 1) Get block header from oracle and ensure that the block hash is included in the current blocks tree // root. - let block_data = context.get_block_data(block_number); + let block_header = context.get_block_header(block_number); // 2) Compute the public value leaf index. // We have to compute the leaf index here because unlike in the case of note commitments, public values are @@ -273,7 +271,7 @@ contract InclusionProofs { // 4) Prove that the public value provided on input is in the public data tree assert( - block_data.public_data_tree_root == compute_merkle_root(public_value, public_value_leaf_index, path), + block_header.public_data_tree_root == compute_merkle_root(public_value, public_value_leaf_index, path), "Proving public value inclusion failed" ); @@ -288,4 +286,4 @@ contract InclusionProofs { let note_header = NoteHeader::new(contract_address, nonce, storage_slot); note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note) } -} +} \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr index 65cf52e96b5..1bb62e9f3f6 100644 --- a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr @@ -1,5 +1,5 @@ /* Autogenerated file, do not edit! */ - + use dep::std; use dep::aztec::context::{ PrivateContext, PublicContext }; use dep::aztec::constants_gen::RETURN_VALUES_LENGTH; @@ -26,6 +26,7 @@ struct ManyNotesADeepStructTestCodeGenStruct { secret_hash: Field, } + // Interface for calling Test functions from a private context struct TestPrivateContextInterface { address: Field, @@ -241,6 +242,9 @@ impl TestPrivateContextInterface { } } + + + // Interface for calling Test functions from a public context struct TestPublicContextInterface { @@ -326,4 +330,5 @@ impl TestPublicContextInterface { } } - + + diff --git a/yarn-project/noir-protocol-circuits/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-protocol-circuits/src/__snapshots__/index.test.ts.snap index 0918bd55a07..af2dbd89ecb 100644 --- a/yarn-project/noir-protocol-circuits/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-protocol-circuits/src/__snapshots__/index.test.ts.snap @@ -103,7 +103,7 @@ exports[`Noir compatibility tests (interop_testing.nr) TxRequest Hash matches No exports[`Private kernel Executes private kernel init circuit for a contract deployment 1`] = ` KernelCircuitPublicInputs { "constants": CombinedConstantData { - "blockData": HistoricBlockData { + "blockHeader": BlockHeader { "blocksTreeRoot": Fr { "asBigInt": 10561895175368852737061915973188839857007468377789560793687187642867659280638n, "asBuffer": { @@ -25719,7 +25719,7 @@ KernelCircuitPublicInputs { exports[`Private kernel Executes private kernel inner for a nested call 1`] = ` KernelCircuitPublicInputs { "constants": CombinedConstantData { - "blockData": HistoricBlockData { + "blockHeader": BlockHeader { "blocksTreeRoot": Fr { "asBigInt": 5141115076863619919216387293080007096006645021873634395499188999297490933851n, "asBuffer": { @@ -51335,7 +51335,7 @@ KernelCircuitPublicInputs { exports[`Private kernel Executes private kernel ordering after a deployment 1`] = ` KernelCircuitPublicInputsFinal { "constants": CombinedConstantData { - "blockData": HistoricBlockData { + "blockHeader": BlockHeader { "blocksTreeRoot": Fr { "asBigInt": 10561895175368852737061915973188839857007468377789560793687187642867659280638n, "asBuffer": { diff --git a/yarn-project/noir-protocol-circuits/src/__snapshots__/noir_test_gen.test.ts.snap b/yarn-project/noir-protocol-circuits/src/__snapshots__/noir_test_gen.test.ts.snap index 63015d107db..86437f04b43 100644 --- a/yarn-project/noir-protocol-circuits/src/__snapshots__/noir_test_gen.test.ts.snap +++ b/yarn-project/noir-protocol-circuits/src/__snapshots__/noir_test_gen.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Data generation for noir tests Computes a private data tree 1`] = ` +exports[`Data generation for noir tests Computes a note hash tree 1`] = ` { "root": "0x0d2f152f19e366e9e690e3e551c1aadc0eab0bb27f6d011a9622d8f31bfa6e22", "siblingPaths": [ diff --git a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr index 9e9422608f9..8653d993183 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr @@ -63,15 +63,15 @@ pub fn validate_arrays(app_public_inputs : PrivateCircuitPublicInputs) { // encrypted_logs_hash and unencrypted_logs_hash have their own integrity checks. } -// Validate all read requests against the historic private data root. -// Use their membership witnesses to do so. If the historic root is not yet +// Validate all read requests against the historical private data root. +// Use their membership witnesses to do so. If the historical root is not yet // initialized, initialize it using the first read request here (if present). // // More info here: // - https://discourse.aztec.network/t/to-read-or-not-to-read/178 // - https://discourse.aztec.network/t/spending-notes-which-havent-yet-been-inserted/180 pub fn validate_read_requests( - historic_note_hash_tree_root: Field, + historical_note_hash_tree_root: Field, read_requests: [Field; MAX_READ_REQUESTS_PER_CALL], read_request_membership_witnesses: [ReadRequestMembershipWitness; MAX_READ_REQUESTS_PER_CALL], ) { @@ -81,7 +81,7 @@ pub fn validate_read_requests( let read_request = read_requests[rr_idx]; let witness = read_request_membership_witnesses[rr_idx]; - // A pending commitment is the one that is not yet added to private data tree + // A pending commitment is the one that is not yet added to note hash tree // A "transient read" is when we try to "read" a pending commitment within a transaction // between function calls, as opposed to reading the outputs of a previous transaction // which is a "pending read". @@ -92,7 +92,7 @@ pub fn validate_read_requests( if (read_request != 0) & (witness.is_transient == false) { let root_for_read_request = read_request_root_from_siblings(read_request, witness.leaf_index, witness.sibling_path); - assert(root_for_read_request == historic_note_hash_tree_root, "private data tree root mismatch"); + assert(root_for_read_request == historical_note_hash_tree_root, "note hash tree root mismatch"); // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1354): do we need to enforce // that a non-transient read_request was derived from the proper/current contract address? @@ -347,7 +347,7 @@ pub fn contract_logic(private_call : PrivateCallData, public_inputs : &mut Kerne private_call.contract_leaf_membership_witness.leaf_index, private_call.contract_leaf_membership_witness.sibling_path); - let purported_contract_tree_root = private_call.call_stack_item.public_inputs.historical_block_data.contract_tree_root(); + let purported_contract_tree_root = private_call.call_stack_item.public_inputs.block_header.contract_tree_root(); assert_eq(computed_contract_tree_root, purported_contract_tree_root, "computed_contract_tree_root does not match purported_contract_tree_root"); } } diff --git a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_init.nr b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_init.nr index 7266c691924..88a34b4049c 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_init.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_init.nr @@ -21,7 +21,7 @@ struct PrivateKernelInputsInit { impl PrivateKernelInputsInit { fn initialize_end_values(self, public_inputs: &mut KernelCircuitPublicInputsBuilder) { public_inputs.constants = CombinedConstantData { - block_data: self.private_call.call_stack_item.public_inputs.historical_block_data, + block_header: self.private_call.call_stack_item.public_inputs.block_header, tx_context: self.tx_request.tx_context, }; } @@ -91,7 +91,7 @@ impl PrivateKernelInputsInit { self.validate_this_private_call_against_tx_request(); common::validate_read_requests( - public_inputs.constants.block_data.note_hash_tree_root(), + public_inputs.constants.block_header.note_hash_tree_root(), self.private_call.call_stack_item.public_inputs.read_requests, self.private_call.read_request_membership_witnesses ); @@ -451,7 +451,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_request() { let mut builder = PrivateKernelInitInputsBuilder::new(); @@ -464,7 +464,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_leaf_index() { let mut builder = PrivateKernelInitInputsBuilder::new(); @@ -478,7 +478,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_sibling_path() { let mut builder = PrivateKernelInitInputsBuilder::new(); diff --git a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_inner.nr b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_inner.nr index 23231fdd4a0..cdee6d1b941 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_inner.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/private_kernel_inner.nr @@ -22,8 +22,8 @@ impl PrivateKernelInputsInner { } fn validate_contract_tree_root(self) { - let purported_contract_tree_root = self.private_call.call_stack_item.public_inputs.historical_block_data.contract_tree_root(); - let previous_kernel_contract_tree_root = self.previous_kernel.public_inputs.constants.block_data.contract_tree_root(); + let purported_contract_tree_root = self.private_call.call_stack_item.public_inputs.block_header.contract_tree_root(); + let previous_kernel_contract_tree_root = self.previous_kernel.public_inputs.constants.block_header.contract_tree_root(); assert(purported_contract_tree_root == previous_kernel_contract_tree_root, "purported_contract_tree_root does not match previous_kernel_contract_tree_root"); } @@ -52,14 +52,14 @@ impl PrivateKernelInputsInner { self.pop_and_validate_this_private_call_hash(&mut public_inputs); common::validate_read_requests( - public_inputs.constants.block_data.note_hash_tree_root(), + public_inputs.constants.block_header.note_hash_tree_root(), self.private_call.call_stack_item.public_inputs.read_requests, // read requests from private call self.private_call.read_request_membership_witnesses); //TODO(David): feels like update_end_values should happen later common::update_end_values(self.private_call, &mut public_inputs); - // ensure that historic/purported contract tree root matches the one in previous kernel + // ensure that historical/purported contract tree root matches the one in previous kernel self.validate_contract_tree_root(); let this_call_stack_item = self.private_call.call_stack_item; @@ -171,9 +171,9 @@ mod tests { fn private_function_incorrect_contract_tree_root_fails() { let mut builder = PrivateKernelInnerInputsBuilder::new(); - // Set historic_tree_root to a wrong value (the correct value + 1). - let contract_tree_root = builder.previous_kernel.block_data.block.contract_tree_root; - builder.previous_kernel.block_data.block.contract_tree_root = contract_tree_root + 1; + // Set historical_tree_root to a wrong value (the correct value + 1). + let contract_tree_root = builder.previous_kernel.block_header.block.contract_tree_root; + builder.previous_kernel.block_header.block.contract_tree_root = contract_tree_root + 1; builder.failed(); } @@ -560,7 +560,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_request() { let mut builder = PrivateKernelInnerInputsBuilder::new(); @@ -573,7 +573,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_leaf_index() { let mut builder = PrivateKernelInnerInputsBuilder::new(); @@ -587,7 +587,7 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_bad_sibling_path() { let mut builder = PrivateKernelInnerInputsBuilder::new(); @@ -601,15 +601,15 @@ mod tests { builder.failed(); } - #[test(should_fail_with="private data tree root mismatch")] + #[test(should_fail_with="note hash tree root mismatch")] fn native_read_request_root_mismatch() { let mut builder = PrivateKernelInnerInputsBuilder::new(); builder.private_call.append_read_requests(1); // Set the root to be a different root so the above read request is not under this root. - let old_root = builder.previous_kernel.block_data.block.note_hash_tree_root; - builder.previous_kernel.block_data.block.note_hash_tree_root = old_root + 1; + let old_root = builder.previous_kernel.block_header.block.note_hash_tree_root; + builder.previous_kernel.block_header.block.note_hash_tree_root = old_root + 1; builder.failed(); } diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/constant_rollup_data.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/constant_rollup_data.nr index 675c6d6dcb3..410826c29c3 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/constant_rollup_data.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/constant_rollup_data.nr @@ -3,7 +3,7 @@ use crate::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; struct ConstantRollupData { // The very latest roots as at the very beginning of the entire rollup: - start_historic_blocks_tree_roots_snapshot : AppendOnlyTreeSnapshot, + start_blocks_tree_snapshot : AppendOnlyTreeSnapshot, // TODO(Sean): Some members of this struct tbd private_kernel_vk_tree_root : Field, @@ -16,7 +16,7 @@ struct ConstantRollupData { impl ConstantRollupData { pub fn eq(self, other : ConstantRollupData) -> bool { - self.start_historic_blocks_tree_roots_snapshot.eq(other.start_historic_blocks_tree_roots_snapshot) & + self.start_blocks_tree_snapshot.eq(other.start_blocks_tree_snapshot) & self.global_variables.eq(other.global_variables) & (self.private_kernel_vk_tree_root == other.private_kernel_vk_tree_root) & (self.public_kernel_vk_tree_root == other.public_kernel_vk_tree_root) & diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr index 172701cfb64..a453771ce15 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -33,7 +33,7 @@ use dep::aztec::constants_gen::{ }; use dep::types::abis::previous_kernel_data::PreviousKernelData; use dep::types::abis::membership_witness::{NullifierMembershipWitness, MembershipWitness}; -use dep::types::abis::membership_witness::HistoricBlocksTreeRootMembershipWitness; +use dep::types::abis::membership_witness::BlocksTreeRootMembershipWitness; struct BaseRollupInputs { kernel_data: [PreviousKernelData; KERNELS_PER_BASE_ROLLUP], @@ -41,7 +41,7 @@ struct BaseRollupInputs { start_nullifier_tree_snapshot: AppendOnlyTreeSnapshot, start_contract_tree_snapshot: AppendOnlyTreeSnapshot, start_public_data_tree_root: Field, - start_historic_blocks_tree_snapshot: AppendOnlyTreeSnapshot, + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot, sorted_new_nullifiers: [Field; MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP], sorted_new_nullifiers_indexes: [u32; MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP], @@ -56,7 +56,7 @@ struct BaseRollupInputs { new_public_data_update_requests_sibling_paths: [[Field; PUBLIC_DATA_TREE_HEIGHT]; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_BASE_ROLLUP], new_public_data_reads_sibling_paths: [[Field; PUBLIC_DATA_TREE_HEIGHT]; MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP], - historic_blocks_tree_root_membership_witnesses: [HistoricBlocksTreeRootMembershipWitness; KERNELS_PER_BASE_ROLLUP], + blocks_tree_root_membership_witnesses: [BlocksTreeRootMembershipWitness; KERNELS_PER_BASE_ROLLUP], constants: ConstantRollupData, } @@ -112,8 +112,8 @@ impl BaseRollupInputs { // Calculate the overall calldata hash let calldata_hash = BaseRollupInputs::components_compute_kernel_calldata_hash(self.kernel_data); - // Perform membership checks that the notes provided exist within the historic trees data - self.perform_historical_blocks_tree_membership_checks(); + // Perform membership checks that the notes provided exist within the historical trees data + self.perform_blocks_tree_membership_checks(); let aggregation_object = self.aggregate_proofs(); @@ -373,24 +373,26 @@ impl BaseRollupInputs { U256::from_bytes32(sha_digest).to_u128_limbs() } - // Check all of the provided commitments against the historical tree roots - fn perform_historical_blocks_tree_membership_checks(self) { - // For each of the historic_note_hash_tree_membership_checks, we need to do an inclusion proof - // against the historical root provided in the rollup constants - let historic_root = self.constants.start_historic_blocks_tree_roots_snapshot.root; + // Check that the block header used by each kernel is a member of the blocks tree --> since the block header + // contains roots of all the trees this is sufficient to verify that the tree roots used by kernels are correct + fn perform_blocks_tree_membership_checks(self) { + // For each of the block header (their block hashes), we need to do an inclusion proof + // against the blocks tree root from the beginning of a rollup provided in the rollup constants + let blocks_treee_root = self.constants.start_blocks_tree_snapshot.root; for i in 0..KERNELS_PER_BASE_ROLLUP { // Rebuild the block hash - let historical_block_data = self.kernel_data[i].public_inputs.constants.block_data; - let previous_block_hash = historical_block_data.block.hash(); + let block_header = self.kernel_data[i].public_inputs.constants.block_header; + let previous_block_hash = block_header.block.hash(); - let historic_root_witness = self.historic_blocks_tree_root_membership_witnesses[i]; + let previous_block_hash_witness = self.blocks_tree_root_membership_witnesses[i]; + // Now check that the previous block hash is in the blocks tree from the beginning of the rollup components::assert_check_membership( previous_block_hash, - historic_root_witness.leaf_index, - historic_root_witness.sibling_path, - historic_root + previous_block_hash_witness.leaf_index, + previous_block_hash_witness.sibling_path, + blocks_treee_root ); } } @@ -540,7 +542,7 @@ mod tests { CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, CONTRACT_TREE_HEIGHT, CONTRACT_SUBTREE_HEIGHT, - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, KERNELS_PER_BASE_ROLLUP, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP, @@ -554,7 +556,7 @@ mod tests { PUBLIC_DATA_TREE_HEIGHT, }; use dep::types::{ - abis::membership_witness::HistoricBlocksTreeRootMembershipWitness, + abis::membership_witness::BlocksTreeRootMembershipWitness, abis::membership_witness::NullifierMembershipWitness, abis::new_contract_data::NewContractData, abis::public_data_read::PublicDataRead, @@ -610,7 +612,7 @@ mod tests { }); inputs.pre_existing_blocks = inputs.kernel_data.map(|builder: PreviousKernelDataBuilder|{ - builder.block_data.block.hash() + builder.block_header.block.hash() }); inputs @@ -729,13 +731,13 @@ mod tests { let mut start_public_data_tree = NonEmptyMerkleTree::new(self.pre_existing_public_data, [0; PUBLIC_DATA_TREE_HEIGHT], [0; PUBLIC_DATA_TREE_HEIGHT - 5], [0; 5]); let start_public_data_tree_root = start_public_data_tree.get_root(); - let start_historic_blocks_tree = NonEmptyMerkleTree::new(self.pre_existing_blocks, [0; HISTORIC_BLOCKS_TREE_HEIGHT], [0; HISTORIC_BLOCKS_TREE_HEIGHT - 1], [0; 1]); - let start_historic_blocks_tree_snapshot = AppendOnlyTreeSnapshot { - root: start_historic_blocks_tree.get_root(), - next_available_leaf_index: start_historic_blocks_tree.get_next_available_index() as u32, + let start_blocks_tree = NonEmptyMerkleTree::new(self.pre_existing_blocks, [0; BLOCKS_TREE_HEIGHT], [0; BLOCKS_TREE_HEIGHT - 1], [0; 1]); + let start_blocks_tree_snapshot = AppendOnlyTreeSnapshot { + root: start_blocks_tree.get_root(), + next_available_leaf_index: start_blocks_tree.get_next_available_index() as u32, }; - self.constants.start_historic_blocks_tree_roots_snapshot = start_historic_blocks_tree_snapshot; + self.constants.start_blocks_tree_snapshot = start_blocks_tree_snapshot; let mut new_public_data_reads_sibling_paths: [[Field; PUBLIC_DATA_TREE_HEIGHT]; MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP] = dep::std::unsafe::zeroed(); @@ -784,7 +786,7 @@ mod tests { start_nullifier_tree_snapshot, start_contract_tree_snapshot, start_public_data_tree_root, - start_historic_blocks_tree_snapshot, + start_blocks_tree_snapshot, sorted_new_nullifiers, sorted_new_nullifiers_indexes, @@ -798,14 +800,14 @@ mod tests { new_public_data_update_requests_sibling_paths, new_public_data_reads_sibling_paths, - historic_blocks_tree_root_membership_witnesses: [ - HistoricBlocksTreeRootMembershipWitness { + blocks_tree_root_membership_witnesses: [ + BlocksTreeRootMembershipWitness { leaf_index: 0, - sibling_path: start_historic_blocks_tree.get_sibling_path(0) + sibling_path: start_blocks_tree.get_sibling_path(0) }, - HistoricBlocksTreeRootMembershipWitness { + BlocksTreeRootMembershipWitness { leaf_index: 1, - sibling_path: start_historic_blocks_tree.get_sibling_path(1) + sibling_path: start_blocks_tree.get_sibling_path(1) }, ], @@ -1142,10 +1144,10 @@ mod tests { } #[test(should_fail_with = "membership check failed")] - unconstrained fn compute_membership_historic_blocks_tree_negative() { + unconstrained fn compute_membership_blocks_tree_negative() { let mut inputs = BaseRollupInputsBuilder::new().build_inputs(); - inputs.historic_blocks_tree_root_membership_witnesses[0].sibling_path[0] = 27; + inputs.blocks_tree_root_membership_witnesses[0].sibling_path[0] = 27; let _output = inputs.base_rollup_circuit(); } diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root.nr index c64ee5fcbdd..d6052cee5e2 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root.nr @@ -37,7 +37,7 @@ impl RootRollupInputs { ); // Build the block hash for this iteration from the tree roots and global variables - // Then insert the block into the historic blocks tree + // Then insert the block into the blocks tree let block_hash = compute_block_hash_with_globals(left.constants.global_variables, right.end_note_hash_tree_snapshot.root, right.end_nullifier_tree_snapshot.root, @@ -45,10 +45,10 @@ impl RootRollupInputs { new_l1_to_l2_messages_tree_snapshot.root, right.end_public_data_tree_root); - // Update the historic blocks tree - let end_historic_blocks_tree_snapshot = components::insert_subtree_to_snapshot_tree( - self.start_historic_blocks_tree_snapshot, - self.new_historic_blocks_tree_sibling_path, + // Update the blocks tree + let end_blocks_tree_snapshot = components::insert_subtree_to_snapshot_tree( + self.start_blocks_tree_snapshot, + self.new_blocks_tree_sibling_path, 0, block_hash, 0 @@ -72,19 +72,19 @@ impl RootRollupInputs { end_public_data_tree_root : right.end_public_data_tree_root, start_l1_to_l2_messages_tree_snapshot : self.start_l1_to_l2_messages_tree_snapshot, end_l1_to_l2_messages_tree_snapshot : new_l1_to_l2_messages_tree_snapshot, - start_historic_blocks_tree_snapshot : self.start_historic_blocks_tree_snapshot, - end_historic_blocks_tree_snapshot : end_historic_blocks_tree_snapshot, + start_blocks_tree_snapshot : self.start_blocks_tree_snapshot, + end_blocks_tree_snapshot : end_blocks_tree_snapshot, calldata_hash : components::compute_calldata_hash(self.previous_rollup_data), l1_to_l2_messages_hash : compute_messages_hash(self.new_l1_to_l2_messages), // The cpp code was just not initializing these, so they would be zeroed out // TODO(Lasse/Jean): add explanation for this. - end_tree_of_historic_contract_tree_roots_snapshot : zeroed_out_snapshot, - end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot : zeroed_out_snapshot, - end_tree_of_historic_note_hash_tree_roots_snapshot : zeroed_out_snapshot, - start_tree_of_historic_contract_tree_roots_snapshot : zeroed_out_snapshot, - start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot : zeroed_out_snapshot, - start_tree_of_historic_note_hash_tree_roots_snapshot : zeroed_out_snapshot, + end_tree_of_historical_contract_tree_roots_snapshot : zeroed_out_snapshot, + end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot : zeroed_out_snapshot, + end_tree_of_historical_note_hash_tree_roots_snapshot : zeroed_out_snapshot, + start_tree_of_historical_contract_tree_roots_snapshot : zeroed_out_snapshot, + start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot : zeroed_out_snapshot, + start_tree_of_historical_note_hash_tree_roots_snapshot : zeroed_out_snapshot, } } } diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_inputs.nr index 23f1f6db7e9..5c2fa4075ff 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_inputs.nr @@ -6,7 +6,7 @@ use crate::abis::constant_rollup_data::ConstantRollupData; use dep::aztec::constants_gen::{ NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, - HISTORIC_BLOCKS_TREE_HEIGHT + BLOCKS_TREE_HEIGHT }; struct RootRollupInputs { @@ -20,6 +20,6 @@ struct RootRollupInputs { start_l1_to_l2_messages_tree_snapshot : AppendOnlyTreeSnapshot, // inputs required to add the block hash - start_historic_blocks_tree_snapshot : AppendOnlyTreeSnapshot, - new_historic_blocks_tree_sibling_path : [Field; HISTORIC_BLOCKS_TREE_HEIGHT], + start_blocks_tree_snapshot : AppendOnlyTreeSnapshot, + new_blocks_tree_sibling_path : [Field; BLOCKS_TREE_HEIGHT], } \ No newline at end of file diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_public_inputs.nr index 2a1ca5daa5e..9b15ca2955f 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/root/root_rollup_public_inputs.nr @@ -26,20 +26,20 @@ struct RootRollupPublicInputs { start_public_data_tree_root : Field, end_public_data_tree_root : Field, - start_tree_of_historic_note_hash_tree_roots_snapshot : AppendOnlyTreeSnapshot, - end_tree_of_historic_note_hash_tree_roots_snapshot : AppendOnlyTreeSnapshot, + start_tree_of_historical_note_hash_tree_roots_snapshot : AppendOnlyTreeSnapshot, + end_tree_of_historical_note_hash_tree_roots_snapshot : AppendOnlyTreeSnapshot, - start_tree_of_historic_contract_tree_roots_snapshot : AppendOnlyTreeSnapshot, - end_tree_of_historic_contract_tree_roots_snapshot : AppendOnlyTreeSnapshot, + start_tree_of_historical_contract_tree_roots_snapshot : AppendOnlyTreeSnapshot, + end_tree_of_historical_contract_tree_roots_snapshot : AppendOnlyTreeSnapshot, start_l1_to_l2_messages_tree_snapshot : AppendOnlyTreeSnapshot, end_l1_to_l2_messages_tree_snapshot : AppendOnlyTreeSnapshot, - start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot : AppendOnlyTreeSnapshot, - end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot : AppendOnlyTreeSnapshot, + start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot : AppendOnlyTreeSnapshot, + end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot : AppendOnlyTreeSnapshot, - start_historic_blocks_tree_snapshot : AppendOnlyTreeSnapshot, - end_historic_blocks_tree_snapshot : AppendOnlyTreeSnapshot, + start_blocks_tree_snapshot : AppendOnlyTreeSnapshot, + end_blocks_tree_snapshot : AppendOnlyTreeSnapshot, calldata_hash : [Field; NUM_FIELDS_PER_SHA256], l1_to_l2_messages_hash : [Field; NUM_FIELDS_PER_SHA256], diff --git a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/tests/root_rollup_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/tests/root_rollup_inputs.nr index 81e026c53d5..7da05d2df6d 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/tests/root_rollup_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/tests/root_rollup_inputs.nr @@ -7,7 +7,7 @@ use dep::aztec::constants_gen::{ L1_TO_L2_MSG_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, L1_TO_L2_MSG_SUBTREE_HEIGHT, - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, }; use crate::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; use crate::tests::previous_rollup_data::default_previous_rollup_data; @@ -25,10 +25,10 @@ pub fn compute_l1_l2_empty_snapshot() -> (AppendOnlyTreeSnapshot, [Field; L1_TO_ (AppendOnlyTreeSnapshot{ root: zero_hashes[zero_hashes.len() - 1], next_available_leaf_index: 0 }, new_l1_to_l2_messages_tree_root_sibling_path) } -pub fn compute_historic_blocks_tree_snapshot() -> (AppendOnlyTreeSnapshot, [Field; HISTORIC_BLOCKS_TREE_HEIGHT]) { - let zero_hashes = compute_zero_hashes([0; HISTORIC_BLOCKS_TREE_HEIGHT]); - let mut sibling_path = [0; HISTORIC_BLOCKS_TREE_HEIGHT]; - for i in 1..HISTORIC_BLOCKS_TREE_HEIGHT { +pub fn compute_blocks_tree_snapshot() -> (AppendOnlyTreeSnapshot, [Field; BLOCKS_TREE_HEIGHT]) { + let zero_hashes = compute_zero_hashes([0; BLOCKS_TREE_HEIGHT]); + let mut sibling_path = [0; BLOCKS_TREE_HEIGHT]; + for i in 1..BLOCKS_TREE_HEIGHT { sibling_path[i] = zero_hashes[i-1]; } (AppendOnlyTreeSnapshot { root: zero_hashes[zero_hashes.len() - 1], next_available_leaf_index: 0 }, sibling_path) @@ -42,10 +42,10 @@ pub fn default_root_rollup_inputs() -> RootRollupInputs { inputs.new_l1_to_l2_messages_tree_root_sibling_path = l1_l2_empty_sibling_path; inputs.start_l1_to_l2_messages_tree_snapshot = l1_l2_empty_snapshot; - let (historic_blocks_snapshot, historic_blocks_sibling_path) = compute_historic_blocks_tree_snapshot(); + let (blocks_snapshot, blocks_sibling_path) = compute_blocks_tree_snapshot(); - inputs.start_historic_blocks_tree_snapshot = historic_blocks_snapshot; - inputs.new_historic_blocks_tree_sibling_path = historic_blocks_sibling_path; + inputs.start_blocks_tree_snapshot = blocks_snapshot; + inputs.new_blocks_tree_sibling_path = blocks_sibling_path; inputs.previous_rollup_data = default_previous_rollup_data(); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis.nr index 8fd4ee28109..dd2b52402df 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis.nr @@ -7,7 +7,7 @@ mod membership_witness; mod new_contract_data; mod contract_leaf_preimage; -mod historical_block_data; +mod block_header; mod combined_constant_data; mod public_data_read; mod public_data_update_request; diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/historical_block_data.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/block_header.nr similarity index 95% rename from yarn-project/noir-protocol-circuits/src/crates/types/src/abis/historical_block_data.nr rename to yarn-project/noir-protocol-circuits/src/crates/types/src/abis/block_header.nr index 488d4cf6ba0..9616da0aa8c 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/historical_block_data.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/block_header.nr @@ -1,6 +1,6 @@ use crate::block::Block; -struct HistoricalBlockData { +struct BlockHeader { blocks_tree_root : Field, block : Block, // Private data @@ -8,7 +8,7 @@ struct HistoricalBlockData { private_kernel_vk_tree_root : Field, } -impl HistoricalBlockData { +impl BlockHeader { fn assert_is_zero(self) { self.block.assert_is_zero(); assert(self.private_kernel_vk_tree_root == 0); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/combined_constant_data.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/combined_constant_data.nr index 947c6c88214..d1706c9624e 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/combined_constant_data.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/combined_constant_data.nr @@ -1,7 +1,7 @@ use crate::transaction::context::TxContext; -use crate::abis::historical_block_data::HistoricalBlockData; +use crate::abis::block_header::BlockHeader; struct CombinedConstantData { - block_data: HistoricalBlockData, + block_header: BlockHeader, tx_context: TxContext, } diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/membership_witness.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/membership_witness.nr index 2af3ca4ff21..6b4c29dcb71 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/membership_witness.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/membership_witness.nr @@ -5,7 +5,7 @@ use dep::aztec::constants_gen::{ NULLIFIER_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, ROLLUP_VK_TREE_HEIGHT, - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, }; struct MembershipWitness { @@ -37,9 +37,9 @@ struct NullifierMembershipWitness{ sibling_path: [Field; NULLIFIER_TREE_HEIGHT] } -struct HistoricBlocksTreeRootMembershipWitness{ +struct BlocksTreeRootMembershipWitness{ leaf_index: Field, - sibling_path: [Field; HISTORIC_BLOCKS_TREE_HEIGHT] + sibling_path: [Field; BLOCKS_TREE_HEIGHT] } struct ReadRequestMembershipWitness { diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr index 12bb26c95ad..b13e029a926 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr @@ -1,7 +1,7 @@ use crate::{ abis::{ call_context::CallContext, - historical_block_data::HistoricalBlockData, + block_header::BlockHeader, }, contrakt::deployment_data::ContractDeploymentData, hash::NUM_FIELDS_PER_SHA256, @@ -46,7 +46,7 @@ struct PrivateCircuitPublicInputs { encrypted_log_preimages_length: Field, unencrypted_log_preimages_length: Field, - historical_block_data: HistoricalBlockData, + block_header: BlockHeader, contract_deployment_data: ContractDeploymentData, @@ -73,7 +73,7 @@ impl PrivateCircuitPublicInputs { fields.push_array(self.unencrypted_logs_hash); fields.push(self.encrypted_log_preimages_length); fields.push(self.unencrypted_log_preimages_length); - fields.push_array(self.historical_block_data.to_array()); + fields.push_array(self.block_header.to_array()); fields.push(self.contract_deployment_data.hash()); fields.push(self.chain_id); fields.push(self.version); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr index 98370a90c2c..abcaf60e7af 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr @@ -11,7 +11,7 @@ use dep::aztec::constants_gen::{ use crate::{ abis::{ call_context::CallContext, - historical_block_data::HistoricalBlockData, + block_header::BlockHeader, }, address::Address, contrakt::{ @@ -42,7 +42,7 @@ struct PublicCircuitPublicInputs{ // variable-length data. unencrypted_log_preimages_length: Field, - historical_block_data: HistoricalBlockData, + block_header: BlockHeader, prover_address: Address, } @@ -66,7 +66,7 @@ impl PublicCircuitPublicInputs{ inputs.push_array(self.new_l2_to_l1_msgs); inputs.push_array(self.unencrypted_logs_hash); inputs.push(self.unencrypted_log_preimages_length); - inputs.push_array(self.historical_block_data.to_array()); + inputs.push_array(self.block_header.to_array()); inputs.push(self.prover_address.to_field()); assert_eq(inputs.len(), constants_gen::PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH, "Incorrect number of input fields when hashing PublicCircuitPublicInputs"); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/fixtures.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/fixtures.nr index 00c81df572c..fca591a7fa6 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/fixtures.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/fixtures.nr @@ -5,7 +5,7 @@ mod note_hash_tree; mod read_requests; use crate::address::Address; -use crate::abis::historical_block_data::HistoricalBlockData; +use crate::abis::block_header::BlockHeader; use crate::block::Block; use crate::point::Point; use crate::tests::fixtures; @@ -14,7 +14,7 @@ global MSG_SENDER = Address { inner: 27 }; global DEPLOYER_PUBLIC_KEY = Point { x: 123456789, y: 123456789 }; -global HISTORICAL_BLOCK_DATA = HistoricalBlockData { +global BLOCK_HEADER = BlockHeader { blocks_tree_root: 0, block: Block { note_hash_tree_root: fixtures::note_hash_tree::ROOT, diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/previous_kernel_data_builder.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/previous_kernel_data_builder.nr index b5c02900860..d41008a7ad4 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/previous_kernel_data_builder.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/previous_kernel_data_builder.nr @@ -4,7 +4,7 @@ use crate::{ call_request::{CallerContext, CallRequest}, combined_constant_data::CombinedConstantData, combined_accumulated_data::CombinedAccumulatedDataBuilder, - historical_block_data::HistoricalBlockData, + block_header::BlockHeader, kernel_circuit_public_inputs::KernelCircuitPublicInputs, previous_kernel_data::PreviousKernelData, public_data_read::PublicDataRead, @@ -34,7 +34,7 @@ struct PreviousKernelDataBuilder { contract_address: Address, portal_contract_address: EthAddress, end: CombinedAccumulatedDataBuilder, - block_data: HistoricalBlockData, + block_header: BlockHeader, tx_context: TxContext, is_private: bool, proof: Proof, @@ -55,7 +55,7 @@ impl PreviousKernelDataBuilder { contract_address: fixtures::contracts::parent_contract.address, portal_contract_address: fixtures::contracts::parent_contract.portal_contract_address, end, - block_data: fixtures::HISTORICAL_BLOCK_DATA, + block_header: fixtures::BLOCK_HEADER, tx_context, is_private: true, proof: Proof {}, @@ -171,7 +171,7 @@ impl PreviousKernelDataBuilder { let public_inputs = KernelCircuitPublicInputs { end: self.end.finish(), constants: CombinedConstantData { - block_data: self.block_data, + block_header: self.block_header, tx_context: self.tx_context, }, is_private: self.is_private, diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr index 9a4f2939797..f000639f3df 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr @@ -2,7 +2,7 @@ use crate::{ abis::{ call_context::CallContext, complete_address::CompleteAddress, - historical_block_data::HistoricalBlockData, + block_header::BlockHeader, private_circuit_public_inputs::PrivateCircuitPublicInputs, }, contrakt::deployment_data::ContractDeploymentData, @@ -50,7 +50,7 @@ struct PrivateCircuitPublicInputsBuilder { encrypted_log_preimages_length: Field, unencrypted_log_preimages_length: Field, - historical_block_data: HistoricalBlockData, + block_header: BlockHeader, contract_deployment_data: ContractDeploymentData, @@ -101,7 +101,7 @@ impl PrivateCircuitPublicInputsBuilder { public_inputs.call_context = call_context; public_inputs.args_hash = args_hash; public_inputs.contract_deployment_data = contract_deployment_data; - public_inputs.historical_block_data = fixtures::HISTORICAL_BLOCK_DATA; + public_inputs.block_header = fixtures::BLOCK_HEADER; public_inputs.chain_id = 0; public_inputs.version = 1; @@ -131,7 +131,7 @@ impl PrivateCircuitPublicInputsBuilder { encrypted_log_preimages_length: self.encrypted_log_preimages_length, unencrypted_log_preimages_length: self.unencrypted_log_preimages_length, - historical_block_data: self.historical_block_data, + block_header: self.block_header, contract_deployment_data: self.contract_deployment_data, diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/public_circuit_public_inputs_builder.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/public_circuit_public_inputs_builder.nr index 184c558a82e..7f1de0beee6 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/public_circuit_public_inputs_builder.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/public_circuit_public_inputs_builder.nr @@ -1,7 +1,7 @@ use crate::{ abis::{ call_context::CallContext, - historical_block_data::HistoricalBlockData, + block_header::BlockHeader, public_circuit_public_inputs::PublicCircuitPublicInputs, }, address::Address, @@ -35,7 +35,7 @@ struct PublicCircuitPublicInputsBuilder { new_l2_to_l1_msgs: BoundedVec, unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256], unencrypted_log_preimages_length: Field, - historical_block_data: HistoricalBlockData, + block_header: BlockHeader, prover_address: Address, } @@ -43,7 +43,7 @@ impl PublicCircuitPublicInputsBuilder { pub fn new() -> Self { let mut public_inputs: PublicCircuitPublicInputsBuilder = dep::std::unsafe::zeroed(); public_inputs.call_context.msg_sender = fixtures::MSG_SENDER; - public_inputs.historical_block_data = fixtures::HISTORICAL_BLOCK_DATA; + public_inputs.block_header = fixtures::BLOCK_HEADER; public_inputs } @@ -60,7 +60,7 @@ impl PublicCircuitPublicInputsBuilder { new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage, unencrypted_logs_hash: self.unencrypted_logs_hash, unencrypted_log_preimages_length: self.unencrypted_log_preimages_length, - historical_block_data: self.historical_block_data, + block_header: self.block_header, prover_address: self.prover_address, } } diff --git a/yarn-project/noir-protocol-circuits/src/index.test.ts b/yarn-project/noir-protocol-circuits/src/index.test.ts index 9b7671574b1..974269bb8f7 100644 --- a/yarn-project/noir-protocol-circuits/src/index.test.ts +++ b/yarn-project/noir-protocol-circuits/src/index.test.ts @@ -1,6 +1,7 @@ import { AggregationObject, AztecAddress, + BlockHeader, CONTRACT_TREE_HEIGHT, CallContext, CallRequest, @@ -12,7 +13,6 @@ import { FunctionData, FunctionLeafPreimage, FunctionSelector, - HistoricBlockData, KernelCircuitPublicInputs, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_COMMITMENTS_PER_TX, @@ -103,7 +103,7 @@ describe('Private kernel', () => { const callContext = new CallContext(AztecAddress.ZERO, contractAddress, Fr.ZERO, selector, false, false, true); - const historicBlockData = new HistoricBlockData( + const blockHeader = new BlockHeader( Fr.fromString('0x16642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb'), Fr.fromString('0x0bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278'), Fr.fromString('0x1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80'), @@ -130,7 +130,7 @@ describe('Private kernel', () => { [Fr.fromString('0xe3b0c44298fc1c149afbf4c8996fb924'), Fr.fromString('0x27ae41e4649b934ca495991b7852b855')], Fr.fromString('0xf8'), Fr.fromString('0x04'), - historicBlockData, + blockHeader, contractDeploymentData, Fr.ZERO, Fr.ZERO, @@ -215,7 +215,7 @@ describe('Private kernel', () => { makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, () => PublicDataRead.empty()), ); - const historicBlockData = new HistoricBlockData( + const blockHeader = new BlockHeader( Fr.fromString('0x16642d9ccd8346c403aa4c3fa451178b22534a27035cdaa6ec34ae53b29c50cb'), Fr.fromString('0x0bcfa3e9f1a8922ee92c6dc964d6595907c1804a86753774322b468f69d4f278'), Fr.fromString('0x1864fcdaa80ff2719154fa7c8a9050662972707168d69eac9db6fd3110829f80'), @@ -226,7 +226,7 @@ describe('Private kernel', () => { Fr.fromString('0x200569267c0f73ac89aaa414239398db9445dd4ad3a8cf37015cd55b8d4c5e8d'), ); - const constants = new CombinedConstantData(historicBlockData, txContext); + const constants = new CombinedConstantData(blockHeader, txContext); const kernelPublicInputs = new KernelCircuitPublicInputs(combinedAccumulatedData, constants, true); @@ -275,7 +275,7 @@ describe('Private kernel', () => { false, ); - const historicBlockData = new HistoricBlockData( + const blockHeader = new BlockHeader( Fr.fromString('0x0dc1f2fbe77c0c72d329cc63f2bd88cd76a30c5802f8138814874cc328148834'), Fr.fromString('0x1861d7a76f4c8f7db95fa8aa1bcbdd5cbf576efe17455fee698f625292667070'), Fr.fromString('0x2f7255183443071e94e90651593c46342978e689e1f4f3e402616fa59633b974'), @@ -305,7 +305,7 @@ describe('Private kernel', () => { [Fr.fromString('0xe3b0c44298fc1c149afbf4c8996fb924'), Fr.fromString('0x27ae41e4649b934ca495991b7852b855')], Fr.fromString('0x04'), Fr.fromString('0x04'), - historicBlockData, + blockHeader, ContractDeploymentData.empty(), chainId, version, @@ -381,7 +381,7 @@ describe('Private kernel', () => { makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, () => PublicDataRead.empty()), ); - const constants = new CombinedConstantData(historicBlockData, txContext); + const constants = new CombinedConstantData(blockHeader, txContext); const kernelPublicInputs = new KernelCircuitPublicInputs(combinedAccumulatedData, constants, true); diff --git a/yarn-project/noir-protocol-circuits/src/noir_test_gen.test.ts b/yarn-project/noir-protocol-circuits/src/noir_test_gen.test.ts index 9449c90f6d8..aada805f27a 100644 --- a/yarn-project/noir-protocol-circuits/src/noir_test_gen.test.ts +++ b/yarn-project/noir-protocol-circuits/src/noir_test_gen.test.ts @@ -90,7 +90,7 @@ describe('Data generation for noir tests', () => { }).toMatchSnapshot(); }); - it('Computes a private data tree', async () => { + it('Computes a note hash tree', async () => { const indexes = new Array(128).fill(null).map((_, i) => BigInt(i)); const leaves = indexes.map(i => new Fr(i + 1n).toBuffer()); diff --git a/yarn-project/noir-protocol-circuits/src/type_conversion.test.ts b/yarn-project/noir-protocol-circuits/src/type_conversion.test.ts index 93bf57ae940..f9cd72f820e 100644 --- a/yarn-project/noir-protocol-circuits/src/type_conversion.test.ts +++ b/yarn-project/noir-protocol-circuits/src/type_conversion.test.ts @@ -1,11 +1,11 @@ import { AztecAddress, + BlockHeader, ContractDeploymentData, EthAddress, Fr, FunctionData, FunctionSelector, - HistoricBlockData, Point, TxContext, } from '@aztec/circuits.js'; @@ -13,6 +13,8 @@ import { import { mapAztecAddressFromNoir, mapAztecAddressToNoir, + mapBlockHeaderFromNoir, + mapBlockHeaderToNoir, mapContractDeploymentDataFromNoir, mapContractDeploymentDataToNoir, mapEthAddressFromNoir, @@ -23,8 +25,6 @@ import { mapFunctionDataToNoir, mapFunctionSelectorFromNoir, mapFunctionSelectorToNoir, - mapHistoricalBlockDataFromNoir, - mapHistoricalBlockDataToNoir, mapPointFromNoir, mapPointToNoir, mapTxContextFromNoir, @@ -85,8 +85,8 @@ describe('Noir<>Circuits.js type conversion test suite', () => { expect(mapFunctionDataFromNoir(mapFunctionDataToNoir(functionData))).toEqual(functionData); }); - it('should map historical block data', () => { - const historicalBlockData = new HistoricBlockData( + it('should map block header', () => { + const blockHeader = new BlockHeader( new Fr(35n), new Fr(36n), new Fr(37n), @@ -96,9 +96,7 @@ describe('Noir<>Circuits.js type conversion test suite', () => { new Fr(41n), new Fr(42n), ); - expect(mapHistoricalBlockDataFromNoir(mapHistoricalBlockDataToNoir(historicalBlockData))).toEqual( - historicalBlockData, - ); + expect(mapBlockHeaderFromNoir(mapBlockHeaderToNoir(blockHeader))).toEqual(blockHeader); }); }); }); diff --git a/yarn-project/noir-protocol-circuits/src/type_conversion.ts b/yarn-project/noir-protocol-circuits/src/type_conversion.ts index 8a539742be1..e42a3cceb56 100644 --- a/yarn-project/noir-protocol-circuits/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits/src/type_conversion.ts @@ -2,8 +2,10 @@ import { AggregationObject, AppendOnlyTreeSnapshot, AztecAddress, + BLOCKS_TREE_HEIGHT, BaseOrMergeRollupPublicInputs, BaseRollupInputs, + BlockHeader, CallContext, CallRequest, CallerContext, @@ -19,8 +21,6 @@ import { FunctionData, FunctionSelector, GlobalVariables, - HISTORIC_BLOCKS_TREE_HEIGHT, - HistoricBlockData, KernelCircuitPublicInputs, KernelCircuitPublicInputsFinal, MAX_NEW_COMMITMENTS_PER_TX, @@ -64,6 +64,7 @@ import { import { Tuple } from '@aztec/foundation/serialize'; import { + BlockHeader as BlockHeaderNoir, CallContext as CallContextNoir, CallRequest as CallRequestNoir, CallerContext as CallerContextNoir, @@ -75,7 +76,6 @@ import { FunctionData as FunctionDataNoir, FunctionLeafMembershipWitness as FunctionLeafMembershipWitnessNoir, FunctionSelector as FunctionSelectorNoir, - HistoricalBlockData as HistoricalBlockDataNoir, KernelCircuitPublicInputs as KernelCircuitPublicInputsNoir, NewContractData as NewContractDataNoir, Address as NoirAztecAddress, @@ -112,7 +112,7 @@ import { } from './types/public_kernel_private_previous_types.js'; import { BaseRollupInputs as BaseRollupInputsNoir, - HistoricBlocksTreeRootMembershipWitness as HistoricBlocksTreeRootMembershipWitnessNoir, + BlocksTreeRootMembershipWitness as BlocksTreeRootMembershipWitnessNoir, NullifierLeafPreimage as NullifierLeafPreimageNoir, NullifierMembershipWitness as NullifierMembershipWitnessNoir, } from './types/rollup_base_types.js'; @@ -433,40 +433,40 @@ export function mapCallRequestToNoir(callRequest: CallRequest): CallRequestNoir } /** - * Maps a historical block data to a noir historical block data. - * @param historicalBlockData - The historical block data. - * @returns The noir historical block data. + * Maps a block header to a noir block header. + * @param blockHeader - The block header. + * @returns The noir block header. */ -export function mapHistoricalBlockDataToNoir(historicalBlockData: HistoricBlockData): HistoricalBlockDataNoir { +export function mapBlockHeaderToNoir(blockHeader: BlockHeader): BlockHeaderNoir { return { - blocks_tree_root: mapFieldToNoir(historicalBlockData.blocksTreeRoot), + blocks_tree_root: mapFieldToNoir(blockHeader.blocksTreeRoot), block: { - note_hash_tree_root: mapFieldToNoir(historicalBlockData.noteHashTreeRoot), - nullifier_tree_root: mapFieldToNoir(historicalBlockData.nullifierTreeRoot), - contract_tree_root: mapFieldToNoir(historicalBlockData.contractTreeRoot), - l1_to_l2_messages_tree_root: mapFieldToNoir(historicalBlockData.l1ToL2MessagesTreeRoot), - public_data_tree_root: mapFieldToNoir(historicalBlockData.publicDataTreeRoot), - global_variables_hash: mapFieldToNoir(historicalBlockData.globalVariablesHash), + note_hash_tree_root: mapFieldToNoir(blockHeader.noteHashTreeRoot), + nullifier_tree_root: mapFieldToNoir(blockHeader.nullifierTreeRoot), + contract_tree_root: mapFieldToNoir(blockHeader.contractTreeRoot), + l1_to_l2_messages_tree_root: mapFieldToNoir(blockHeader.l1ToL2MessagesTreeRoot), + public_data_tree_root: mapFieldToNoir(blockHeader.publicDataTreeRoot), + global_variables_hash: mapFieldToNoir(blockHeader.globalVariablesHash), }, - private_kernel_vk_tree_root: mapFieldToNoir(historicalBlockData.privateKernelVkTreeRoot), + private_kernel_vk_tree_root: mapFieldToNoir(blockHeader.privateKernelVkTreeRoot), }; } /** - * Maps a noir historical block data to a historical block data. - * @param historicalBlockData - The noir historical block data. - * @returns The historical block data. + * Maps a noir block header to a block header. + * @param blockHeader - The noir block header. + * @returns The block header. */ -export function mapHistoricalBlockDataFromNoir(historicalBlockData: HistoricalBlockDataNoir): HistoricBlockData { - return new HistoricBlockData( - mapFieldFromNoir(historicalBlockData.block.note_hash_tree_root), - mapFieldFromNoir(historicalBlockData.block.nullifier_tree_root), - mapFieldFromNoir(historicalBlockData.block.contract_tree_root), - mapFieldFromNoir(historicalBlockData.block.l1_to_l2_messages_tree_root), - mapFieldFromNoir(historicalBlockData.blocks_tree_root), - mapFieldFromNoir(historicalBlockData.private_kernel_vk_tree_root), - mapFieldFromNoir(historicalBlockData.block.public_data_tree_root), - mapFieldFromNoir(historicalBlockData.block.global_variables_hash), +export function mapBlockHeaderFromNoir(blockHeader: BlockHeaderNoir): BlockHeader { + return new BlockHeader( + mapFieldFromNoir(blockHeader.block.note_hash_tree_root), + mapFieldFromNoir(blockHeader.block.nullifier_tree_root), + mapFieldFromNoir(blockHeader.block.contract_tree_root), + mapFieldFromNoir(blockHeader.block.l1_to_l2_messages_tree_root), + mapFieldFromNoir(blockHeader.blocks_tree_root), + mapFieldFromNoir(blockHeader.private_kernel_vk_tree_root), + mapFieldFromNoir(blockHeader.block.public_data_tree_root), + mapFieldFromNoir(blockHeader.block.global_variables_hash), ); } @@ -511,7 +511,7 @@ export function mapPrivateCircuitPublicInputsToNoir( >, encrypted_log_preimages_length: mapFieldToNoir(privateCircuitPublicInputs.encryptedLogPreimagesLength), unencrypted_log_preimages_length: mapFieldToNoir(privateCircuitPublicInputs.unencryptedLogPreimagesLength), - historical_block_data: mapHistoricalBlockDataToNoir(privateCircuitPublicInputs.historicBlockData), + block_header: mapBlockHeaderToNoir(privateCircuitPublicInputs.blockHeader), contract_deployment_data: mapContractDeploymentDataToNoir(privateCircuitPublicInputs.contractDeploymentData), chain_id: mapFieldToNoir(privateCircuitPublicInputs.chainId), version: mapFieldToNoir(privateCircuitPublicInputs.version), @@ -894,7 +894,7 @@ export function mapCombinedAccumulatedDataToNoir( */ export function mapCombinedConstantDataFromNoir(combinedConstantData: CombinedConstantDataNoir): CombinedConstantData { return new CombinedConstantData( - mapHistoricalBlockDataFromNoir(combinedConstantData.block_data), + mapBlockHeaderFromNoir(combinedConstantData.block_header), mapTxContextFromNoir(combinedConstantData.tx_context), ); } @@ -906,7 +906,7 @@ export function mapCombinedConstantDataFromNoir(combinedConstantData: CombinedCo */ export function mapCombinedConstantDataToNoir(combinedConstantData: CombinedConstantData): CombinedConstantDataNoir { return { - block_data: mapHistoricalBlockDataToNoir(combinedConstantData.blockData), + block_header: mapBlockHeaderToNoir(combinedConstantData.blockHeader), tx_context: mapTxContextToNoir(combinedConstantData.txContext), }; } @@ -1074,9 +1074,7 @@ export function mapGlobalVariablesFromNoir(globalVariables: GlobalVariablesNoir) */ export function mapConstantRollupDataToNoir(constantRollupData: ConstantRollupData): ConstantRollupDataNoir { return { - start_historic_blocks_tree_roots_snapshot: mapAppendOnlyTreeSnapshotToNoir( - constantRollupData.startHistoricBlocksTreeRootsSnapshot, - ), + start_blocks_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(constantRollupData.startBlocksTreeSnapshot), private_kernel_vk_tree_root: mapFieldToNoir(constantRollupData.privateKernelVkTreeRoot), public_kernel_vk_tree_root: mapFieldToNoir(constantRollupData.publicKernelVkTreeRoot), base_rollup_vk_hash: mapFieldToNoir(constantRollupData.baseRollupVkHash), @@ -1110,7 +1108,7 @@ export function mapPublicCircuitPublicInputsToNoir( new_l2_to_l1_msgs: publicInputs.newL2ToL1Msgs.map(mapFieldToNoir) as FixedLengthArray, unencrypted_logs_hash: publicInputs.unencryptedLogsHash.map(mapFieldToNoir) as FixedLengthArray, unencrypted_log_preimages_length: mapFieldToNoir(publicInputs.unencryptedLogPreimagesLength), - historical_block_data: mapHistoricalBlockDataToNoir(publicInputs.historicBlockData), + block_header: mapBlockHeaderToNoir(publicInputs.blockHeader), prover_address: mapAztecAddressToNoir(publicInputs.proverAddress), }; @@ -1122,7 +1120,7 @@ export function mapPublicCircuitPublicInputsToNoir( */ export function mapConstantRollupDataFromNoir(constantRollupData: ConstantRollupDataNoir): ConstantRollupData { return new ConstantRollupData( - mapAppendOnlyTreeSnapshotFromNoir(constantRollupData.start_historic_blocks_tree_roots_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(constantRollupData.start_blocks_tree_snapshot), mapFieldFromNoir(constantRollupData.private_kernel_vk_tree_root), mapFieldFromNoir(constantRollupData.public_kernel_vk_tree_root), mapFieldFromNoir(constantRollupData.base_rollup_vk_hash), @@ -1290,12 +1288,11 @@ export function mapRootRollupInputsToNoir(rootRollupInputs: RootRollupInputs): R start_l1_to_l2_messages_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir( rootRollupInputs.startL1ToL2MessagesTreeSnapshot, ), - start_historic_blocks_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir( - rootRollupInputs.startHistoricBlocksTreeSnapshot, - ), - new_historic_blocks_tree_sibling_path: rootRollupInputs.newHistoricBlocksTreeSiblingPath.map( - mapFieldToNoir, - ) as FixedLengthArray, + start_blocks_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(rootRollupInputs.startBlocksTreeSnapshot), + new_blocks_tree_sibling_path: rootRollupInputs.newBlocksTreeSiblingPath.map(mapFieldToNoir) as FixedLengthArray< + NoirField, + 16 + >, }; } @@ -1318,20 +1315,20 @@ export function mapRootRollupPublicInputsFromNoir( mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_contract_tree_snapshot), mapFieldFromNoir(rootRollupPublicInputs.start_public_data_tree_root), mapFieldFromNoir(rootRollupPublicInputs.end_public_data_tree_root), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_tree_of_historic_note_hash_tree_roots_snapshot), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_tree_of_historic_note_hash_tree_roots_snapshot), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_tree_of_historic_contract_tree_roots_snapshot), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_tree_of_historic_contract_tree_roots_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_tree_of_historical_note_hash_tree_roots_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_tree_of_historical_note_hash_tree_roots_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_tree_of_historical_contract_tree_roots_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_tree_of_historical_contract_tree_roots_snapshot), mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_l1_to_l2_messages_tree_snapshot), mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_l1_to_l2_messages_tree_snapshot), mapAppendOnlyTreeSnapshotFromNoir( - rootRollupPublicInputs.start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot, + rootRollupPublicInputs.start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot, ), mapAppendOnlyTreeSnapshotFromNoir( - rootRollupPublicInputs.end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot, + rootRollupPublicInputs.end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot, ), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_historic_blocks_tree_snapshot), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_historic_blocks_tree_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.start_blocks_tree_snapshot), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_blocks_tree_snapshot), mapTupleFromNoir(rootRollupPublicInputs.calldata_hash, 2, mapFieldFromNoir), mapTupleFromNoir(rootRollupPublicInputs.l1_to_l2_messages_hash, 2, mapFieldFromNoir), ); @@ -1384,18 +1381,18 @@ export function mapNullifierMembershipWitnessToNoir( } /** - * Maps a membership witness of the historic blocks tree to noir. + * Maps a membership witness of the blocks tree to noir. * @param membershipWitness - The membership witness. * @returns The noir membership witness. */ -export function mapHistoricBlocksTreeRootMembershipWitnessToNoir( - membershipWitness: MembershipWitness, -): HistoricBlocksTreeRootMembershipWitnessNoir { +export function mapBlocksTreeRootMembershipWitnessToNoir( + membershipWitness: MembershipWitness, +): BlocksTreeRootMembershipWitnessNoir { return { leaf_index: membershipWitness.leafIndex.toString(), sibling_path: membershipWitness.siblingPath.map(mapFieldToNoir) as FixedLengthArray< NoirField, - typeof HISTORIC_BLOCKS_TREE_HEIGHT + typeof BLOCKS_TREE_HEIGHT >, }; } @@ -1412,7 +1409,7 @@ export function mapBaseRollupInputsToNoir(inputs: BaseRollupInputs): BaseRollupI start_nullifier_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(inputs.startNullifierTreeSnapshot), start_contract_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(inputs.startContractTreeSnapshot), start_public_data_tree_root: mapFieldToNoir(inputs.startPublicDataTreeRoot), - start_historic_blocks_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(inputs.startHistoricBlocksTreeSnapshot), + start_blocks_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir(inputs.startBlocksTreeSnapshot), sorted_new_nullifiers: inputs.sortedNewNullifiers.map(mapFieldToNoir) as FixedLengthArray, sorted_new_nullifiers_indexes: inputs.sortednewNullifiersIndexes.map(mapNumberToNoir) as FixedLengthArray< NoirField, @@ -1441,9 +1438,9 @@ export function mapBaseRollupInputsToNoir(inputs: BaseRollupInputs): BaseRollupI new_public_data_reads_sibling_paths: inputs.newPublicDataReadsSiblingPaths.map(siblingPath => siblingPath.map(mapFieldToNoir), ) as FixedLengthArray, 32>, - historic_blocks_tree_root_membership_witnesses: inputs.historicBlocksTreeRootMembershipWitnesses.map( - mapHistoricBlocksTreeRootMembershipWitnessToNoir, - ) as FixedLengthArray, + blocks_tree_root_membership_witnesses: inputs.blocksTreeRootMembershipWitnesses.map( + mapBlocksTreeRootMembershipWitnessToNoir, + ) as FixedLengthArray, constants: mapConstantRollupDataToNoir(inputs.constants), }; } diff --git a/yarn-project/noir-protocol-circuits/src/types/private_kernel_init_types.ts b/yarn-project/noir-protocol-circuits/src/types/private_kernel_init_types.ts index 4f00c7e1953..af47e9d082f 100644 --- a/yarn-project/noir-protocol-circuits/src/types/private_kernel_init_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/private_kernel_init_types.ts @@ -74,7 +74,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -96,7 +96,7 @@ export interface PrivateCircuitPublicInputs { unencrypted_logs_hash: FixedLengthArray; encrypted_log_preimages_length: Field; unencrypted_log_preimages_length: Field; - historical_block_data: HistoricalBlockData; + block_header: BlockHeader; contract_deployment_data: ContractDeploymentData; chain_id: Field; version: Field; @@ -210,7 +210,7 @@ export interface CombinedAccumulatedData { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } diff --git a/yarn-project/noir-protocol-circuits/src/types/private_kernel_inner_types.ts b/yarn-project/noir-protocol-circuits/src/types/private_kernel_inner_types.ts index e59e29b2b37..935af55a122 100644 --- a/yarn-project/noir-protocol-circuits/src/types/private_kernel_inner_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/private_kernel_inner_types.ts @@ -96,7 +96,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -125,7 +125,7 @@ export interface TxContext { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } @@ -173,7 +173,7 @@ export interface PrivateCircuitPublicInputs { unencrypted_logs_hash: FixedLengthArray; encrypted_log_preimages_length: Field; unencrypted_log_preimages_length: Field; - historical_block_data: HistoricalBlockData; + block_header: BlockHeader; contract_deployment_data: ContractDeploymentData; chain_id: Field; version: Field; diff --git a/yarn-project/noir-protocol-circuits/src/types/private_kernel_ordering_types.ts b/yarn-project/noir-protocol-circuits/src/types/private_kernel_ordering_types.ts index 67f146a9d92..a84711e7fea 100644 --- a/yarn-project/noir-protocol-circuits/src/types/private_kernel_ordering_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/private_kernel_ordering_types.ts @@ -96,7 +96,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -125,7 +125,7 @@ export interface TxContext { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } diff --git a/yarn-project/noir-protocol-circuits/src/types/public_kernel_private_previous_types.ts b/yarn-project/noir-protocol-circuits/src/types/public_kernel_private_previous_types.ts index 20dccc4b25c..7690aca56f5 100644 --- a/yarn-project/noir-protocol-circuits/src/types/public_kernel_private_previous_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/public_kernel_private_previous_types.ts @@ -96,7 +96,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -125,7 +125,7 @@ export interface TxContext { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } @@ -180,7 +180,7 @@ export interface PublicCircuitPublicInputs { new_l2_to_l1_msgs: FixedLengthArray; unencrypted_logs_hash: FixedLengthArray; unencrypted_log_preimages_length: Field; - historical_block_data: HistoricalBlockData; + block_header: BlockHeader; prover_address: Address; } diff --git a/yarn-project/noir-protocol-circuits/src/types/public_kernel_public_previous_types.ts b/yarn-project/noir-protocol-circuits/src/types/public_kernel_public_previous_types.ts index bb0596aff1c..739dce88379 100644 --- a/yarn-project/noir-protocol-circuits/src/types/public_kernel_public_previous_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/public_kernel_public_previous_types.ts @@ -96,7 +96,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -125,7 +125,7 @@ export interface TxContext { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } @@ -180,7 +180,7 @@ export interface PublicCircuitPublicInputs { new_l2_to_l1_msgs: FixedLengthArray; unencrypted_logs_hash: FixedLengthArray; unencrypted_log_preimages_length: Field; - historical_block_data: HistoricalBlockData; + block_header: BlockHeader; prover_address: Address; } diff --git a/yarn-project/noir-protocol-circuits/src/types/rollup_base_types.ts b/yarn-project/noir-protocol-circuits/src/types/rollup_base_types.ts index 424535bad73..1c880cb2cdf 100644 --- a/yarn-project/noir-protocol-circuits/src/types/rollup_base_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/rollup_base_types.ts @@ -96,7 +96,7 @@ export interface Block { global_variables_hash: Field; } -export interface HistoricalBlockData { +export interface BlockHeader { blocks_tree_root: Field; block: Block; private_kernel_vk_tree_root: Field; @@ -125,7 +125,7 @@ export interface TxContext { } export interface CombinedConstantData { - block_data: HistoricalBlockData; + block_header: BlockHeader; tx_context: TxContext; } @@ -163,7 +163,7 @@ export interface NullifierMembershipWitness { sibling_path: FixedLengthArray; } -export interface HistoricBlocksTreeRootMembershipWitness { +export interface BlocksTreeRootMembershipWitness { leaf_index: Field; sibling_path: FixedLengthArray; } @@ -176,7 +176,7 @@ export interface GlobalVariables { } export interface ConstantRollupData { - start_historic_blocks_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; private_kernel_vk_tree_root: Field; public_kernel_vk_tree_root: Field; base_rollup_vk_hash: Field; @@ -190,7 +190,7 @@ export interface BaseRollupInputs { start_nullifier_tree_snapshot: AppendOnlyTreeSnapshot; start_contract_tree_snapshot: AppendOnlyTreeSnapshot; start_public_data_tree_root: Field; - start_historic_blocks_tree_snapshot: AppendOnlyTreeSnapshot; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; sorted_new_nullifiers: FixedLengthArray; sorted_new_nullifiers_indexes: FixedLengthArray; low_nullifier_leaf_preimages: FixedLengthArray; @@ -200,7 +200,7 @@ export interface BaseRollupInputs { new_contracts_subtree_sibling_path: FixedLengthArray; new_public_data_update_requests_sibling_paths: FixedLengthArray, 32>; new_public_data_reads_sibling_paths: FixedLengthArray, 32>; - historic_blocks_tree_root_membership_witnesses: FixedLengthArray; + blocks_tree_root_membership_witnesses: FixedLengthArray; constants: ConstantRollupData; } diff --git a/yarn-project/noir-protocol-circuits/src/types/rollup_merge_types.ts b/yarn-project/noir-protocol-circuits/src/types/rollup_merge_types.ts index bf438c2c3cd..233624ab34d 100644 --- a/yarn-project/noir-protocol-circuits/src/types/rollup_merge_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/rollup_merge_types.ts @@ -22,7 +22,7 @@ export interface GlobalVariables { } export interface ConstantRollupData { - start_historic_blocks_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; private_kernel_vk_tree_root: Field; public_kernel_vk_tree_root: Field; base_rollup_vk_hash: Field; diff --git a/yarn-project/noir-protocol-circuits/src/types/rollup_root_types.ts b/yarn-project/noir-protocol-circuits/src/types/rollup_root_types.ts index ee37cbf72ff..63c4b01df51 100644 --- a/yarn-project/noir-protocol-circuits/src/types/rollup_root_types.ts +++ b/yarn-project/noir-protocol-circuits/src/types/rollup_root_types.ts @@ -22,7 +22,7 @@ export interface GlobalVariables { } export interface ConstantRollupData { - start_historic_blocks_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; private_kernel_vk_tree_root: Field; public_kernel_vk_tree_root: Field; base_rollup_vk_hash: Field; @@ -68,8 +68,8 @@ export interface RootRollupInputs { new_l1_to_l2_messages: FixedLengthArray; new_l1_to_l2_messages_tree_root_sibling_path: FixedLengthArray; start_l1_to_l2_messages_tree_snapshot: AppendOnlyTreeSnapshot; - start_historic_blocks_tree_snapshot: AppendOnlyTreeSnapshot; - new_historic_blocks_tree_sibling_path: FixedLengthArray; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; + new_blocks_tree_sibling_path: FixedLengthArray; } export interface RootRollupPublicInputs { @@ -83,16 +83,16 @@ export interface RootRollupPublicInputs { end_contract_tree_snapshot: AppendOnlyTreeSnapshot; start_public_data_tree_root: Field; end_public_data_tree_root: Field; - start_tree_of_historic_note_hash_tree_roots_snapshot: AppendOnlyTreeSnapshot; - end_tree_of_historic_note_hash_tree_roots_snapshot: AppendOnlyTreeSnapshot; - start_tree_of_historic_contract_tree_roots_snapshot: AppendOnlyTreeSnapshot; - end_tree_of_historic_contract_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_tree_of_historical_note_hash_tree_roots_snapshot: AppendOnlyTreeSnapshot; + end_tree_of_historical_note_hash_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_tree_of_historical_contract_tree_roots_snapshot: AppendOnlyTreeSnapshot; + end_tree_of_historical_contract_tree_roots_snapshot: AppendOnlyTreeSnapshot; start_l1_to_l2_messages_tree_snapshot: AppendOnlyTreeSnapshot; end_l1_to_l2_messages_tree_snapshot: AppendOnlyTreeSnapshot; - start_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot: AppendOnlyTreeSnapshot; - end_tree_of_historic_l1_to_l2_messages_tree_roots_snapshot: AppendOnlyTreeSnapshot; - start_historic_blocks_tree_snapshot: AppendOnlyTreeSnapshot; - end_historic_blocks_tree_snapshot: AppendOnlyTreeSnapshot; + start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot: AppendOnlyTreeSnapshot; + end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot: AppendOnlyTreeSnapshot; + start_blocks_tree_snapshot: AppendOnlyTreeSnapshot; + end_blocks_tree_snapshot: AppendOnlyTreeSnapshot; calldata_hash: FixedLengthArray; l1_to_l2_messages_hash: FixedLengthArray; } diff --git a/yarn-project/p2p/src/client/p2p_client.ts b/yarn-project/p2p/src/client/p2p_client.ts index 7880bf2310b..d8baeb7ac8f 100644 --- a/yarn-project/p2p/src/client/p2p_client.ts +++ b/yarn-project/p2p/src/client/p2p_client.ts @@ -114,7 +114,7 @@ export class P2PClient implements P2P { /** * In-memory P2P client constructor. - * @param l2BlockSource - P2P client's source for fetching existing block data. + * @param l2BlockSource - P2P client's source for fetching existing blocks. * @param txPool - The client's instance of a transaction pool. Defaults to in-memory implementation. * @param p2pService - The concrete instance of p2p networking to use. * @param log - A logger. diff --git a/yarn-project/pxe/src/database/database.ts b/yarn-project/pxe/src/database/database.ts index 906bc4bcc93..72f50a1c576 100644 --- a/yarn-project/pxe/src/database/database.ts +++ b/yarn-project/pxe/src/database/database.ts @@ -1,4 +1,4 @@ -import { CompleteAddress, HistoricBlockData, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, PublicKey } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { ContractDatabase, MerkleTreeId, NoteFilter } from '@aztec/types'; @@ -91,24 +91,24 @@ export interface Database extends ContractDatabase { setTreeRoots(roots: Record): Promise; /** - * Retrieve the stored Historic Block Data from the database. - * The function returns a Promise that resolves to the Historic Block Data. + * Retrieve the stored Block Header from the database. + * The function returns a Promise that resolves to the Block Header. * This data is required to reproduce block attestations. - * Throws an error if the historic block data is not available within the database. + * Throws an error if the block header is not available within the database. * * note: this data is a combination of the tree roots and the global variables hash. */ - getHistoricBlockData(): HistoricBlockData; + getBlockHeader(): BlockHeader; /** - * Set the latest Historic Block Data. + * Set the latest Block Header. * This function updates the 'global variables hash' and `tree roots` property of the instance * Note that this will overwrite any existing hash or roots in the database. * - * @param historicBlockData - An object containing the most recent historic block data. + * @param blockHeader - An object containing the most recent block header. * @returns A Promise that resolves when the hash has been successfully updated in the database. */ - setHistoricBlockData(historicBlockData: HistoricBlockData): Promise; + setBlockHeader(blockHeader: BlockHeader): Promise; /** * Adds complete address to the database. diff --git a/yarn-project/pxe/src/database/memory_db.ts b/yarn-project/pxe/src/database/memory_db.ts index 88f98601c3b..b0562f0ceb6 100644 --- a/yarn-project/pxe/src/database/memory_db.ts +++ b/yarn-project/pxe/src/database/memory_db.ts @@ -1,4 +1,4 @@ -import { CompleteAddress, HistoricBlockData, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, PublicKey } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -118,12 +118,12 @@ export class MemoryDB extends MemoryContractDatabase implements Database { return Promise.resolve(); } - public getHistoricBlockData(): HistoricBlockData { + public getBlockHeader(): BlockHeader { const roots = this.getTreeRoots(); if (!this.globalVariablesHash) { throw new Error(`Global variables hash not set in memory database`); } - return new HistoricBlockData( + return new BlockHeader( roots[MerkleTreeId.NOTE_HASH_TREE], roots[MerkleTreeId.NULLIFIER_TREE], roots[MerkleTreeId.CONTRACT_TREE], @@ -135,15 +135,15 @@ export class MemoryDB extends MemoryContractDatabase implements Database { ); } - public async setHistoricBlockData(historicBlockData: HistoricBlockData): Promise { - this.globalVariablesHash = historicBlockData.globalVariablesHash; + public async setBlockHeader(blockHeader: BlockHeader): Promise { + this.globalVariablesHash = blockHeader.globalVariablesHash; await this.setTreeRoots({ - [MerkleTreeId.NOTE_HASH_TREE]: historicBlockData.noteHashTreeRoot, - [MerkleTreeId.NULLIFIER_TREE]: historicBlockData.nullifierTreeRoot, - [MerkleTreeId.CONTRACT_TREE]: historicBlockData.contractTreeRoot, - [MerkleTreeId.L1_TO_L2_MESSAGES_TREE]: historicBlockData.l1ToL2MessagesTreeRoot, - [MerkleTreeId.BLOCKS_TREE]: historicBlockData.blocksTreeRoot, - [MerkleTreeId.PUBLIC_DATA_TREE]: historicBlockData.publicDataTreeRoot, + [MerkleTreeId.NOTE_HASH_TREE]: blockHeader.noteHashTreeRoot, + [MerkleTreeId.NULLIFIER_TREE]: blockHeader.nullifierTreeRoot, + [MerkleTreeId.CONTRACT_TREE]: blockHeader.contractTreeRoot, + [MerkleTreeId.L1_TO_L2_MESSAGES_TREE]: blockHeader.l1ToL2MessagesTreeRoot, + [MerkleTreeId.BLOCKS_TREE]: blockHeader.blocksTreeRoot, + [MerkleTreeId.PUBLIC_DATA_TREE]: blockHeader.publicDataTreeRoot, }); } diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index c3a57994f48..0f07830436f 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -16,7 +16,7 @@ import { getAcirSimulator } from '../simulator/index.js'; */ interface ProcessedData { /** - * Holds L2 block data and associated context. + * Holds L2 block and a cache of already requested tx hashes. */ blockContext: L2BlockContext; /** diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index fc0bb37c78e..8d781c1d2cd 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -449,10 +449,10 @@ export class PXEService implements PXE { /** * Retrieves the simulation parameters required to run an ACIR simulation. - * This includes the contract address, function artifact, portal contract address, and historic tree roots. + * This includes the contract address, function artifact, portal contract address, and historical tree roots. * * @param execRequest - The transaction request object containing details of the contract call. - * @returns An object containing the contract address, function artifact, portal contract address, and historic tree roots. + * @returns An object containing the contract address, function artifact, portal contract address, and historical tree roots. */ async #getSimulationParameters(execRequest: FunctionCall | TxExecutionRequest) { const contractAddress = (execRequest as FunctionCall).to ?? (execRequest as TxExecutionRequest).origin; diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 42c3edd74c4..2c1f571612a 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -1,12 +1,12 @@ import { DBOracle, FunctionArtifactWithDebugMetadata, MessageLoadOracleInputs } from '@aztec/acir-simulator'; import { AztecAddress, + BlockHeader, CompleteAddress, EthAddress, Fr, FunctionSelector, GrumpkinPrivateKey, - HistoricBlockData, PublicKey, } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -152,7 +152,7 @@ export class SimulatorOracle implements DBOracle { case MerkleTreeId.NOTE_HASH_TREE: return (await this.stateInfoProvider.getNoteHashSiblingPath(leafIndex)).toFieldArray(); case MerkleTreeId.BLOCKS_TREE: - return (await this.stateInfoProvider.getHistoricBlocksTreeSiblingPath(leafIndex)).toFieldArray(); + return (await this.stateInfoProvider.getBlocksTreeSiblingPath(leafIndex)).toFieldArray(); case MerkleTreeId.PUBLIC_DATA_TREE: return (await this.stateInfoProvider.getPublicDataTreeSiblingPath(leafIndex)).toFieldArray(); default: @@ -179,12 +179,12 @@ export class SimulatorOracle implements DBOracle { } /** - * Retrieve the databases view of the Historic Block Data object. - * This structure is fed into the circuits simulator and is used to prove against certain historic roots. + * Retrieve the databases view of the Block Header object. + * This structure is fed into the circuits simulator and is used to prove against certain historical roots. * - * @returns A Promise that resolves to a HistoricBlockData object. + * @returns A Promise that resolves to a BlockHeader object. */ - getHistoricBlockData(): Promise { - return Promise.resolve(this.db.getHistoricBlockData()); + getBlockHeader(): Promise { + return Promise.resolve(this.db.getBlockHeader()); } } diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts index 2179fecc524..6ee3071712c 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.test.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.test.ts @@ -1,4 +1,4 @@ -import { CompleteAddress, Fr, GrumpkinScalar, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, Fr, GrumpkinScalar } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { TestKeyStore } from '@aztec/key-store'; import { AztecNode, INITIAL_L2_BLOCK_NUM, L2Block, MerkleTreeId } from '@aztec/types'; @@ -14,17 +14,17 @@ describe('Synchronizer', () => { let database: Database; let synchronizer: TestSynchronizer; let roots: Record; - let blockData: HistoricBlockData; + let blockHeader: BlockHeader; beforeEach(() => { - blockData = HistoricBlockData.random(); + blockHeader = BlockHeader.random(); roots = { - [MerkleTreeId.CONTRACT_TREE]: blockData.contractTreeRoot, - [MerkleTreeId.NOTE_HASH_TREE]: blockData.noteHashTreeRoot, - [MerkleTreeId.NULLIFIER_TREE]: blockData.nullifierTreeRoot, - [MerkleTreeId.PUBLIC_DATA_TREE]: blockData.publicDataTreeRoot, - [MerkleTreeId.L1_TO_L2_MESSAGES_TREE]: blockData.l1ToL2MessagesTreeRoot, - [MerkleTreeId.BLOCKS_TREE]: blockData.blocksTreeRoot, + [MerkleTreeId.CONTRACT_TREE]: blockHeader.contractTreeRoot, + [MerkleTreeId.NOTE_HASH_TREE]: blockHeader.noteHashTreeRoot, + [MerkleTreeId.NULLIFIER_TREE]: blockHeader.nullifierTreeRoot, + [MerkleTreeId.PUBLIC_DATA_TREE]: blockHeader.publicDataTreeRoot, + [MerkleTreeId.L1_TO_L2_MESSAGES_TREE]: blockHeader.l1ToL2MessagesTreeRoot, + [MerkleTreeId.BLOCKS_TREE]: blockHeader.blocksTreeRoot, }; aztecNode = mock(); @@ -34,7 +34,7 @@ describe('Synchronizer', () => { it('sets tree roots from aztec node on initial sync', async () => { aztecNode.getBlockNumber.mockResolvedValue(3); - aztecNode.getHistoricBlockData.mockResolvedValue(blockData); + aztecNode.getBlockHeader.mockResolvedValue(blockHeader); await synchronizer.initialSync(); @@ -55,7 +55,7 @@ describe('Synchronizer', () => { it('overrides tree roots from initial sync once current block number is larger', async () => { // Initial sync is done on block with height 3 aztecNode.getBlockNumber.mockResolvedValue(3); - aztecNode.getHistoricBlockData.mockResolvedValue(blockData); + aztecNode.getBlockHeader.mockResolvedValue(blockHeader); await synchronizer.initialSync(); const roots0 = database.getTreeRoots(); diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index 524fddd2a3e..98dfd30c7e6 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -1,4 +1,4 @@ -import { AztecAddress, Fr, HistoricBlockData, PublicKey } from '@aztec/circuits.js'; +import { AztecAddress, BlockHeader, Fr, PublicKey } from '@aztec/circuits.js'; import { computeGlobalsHash } from '@aztec/circuits.js/abis'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { InterruptibleSleep } from '@aztec/foundation/sleep'; @@ -68,13 +68,10 @@ export class Synchronizer { } protected async initialSync() { - const [blockNumber, historicBlockData] = await Promise.all([ - this.node.getBlockNumber(), - this.node.getHistoricBlockData(), - ]); + const [blockNumber, blockHeader] = await Promise.all([this.node.getBlockNumber(), this.node.getBlockHeader()]); this.initialSyncBlockNumber = blockNumber; this.synchedToBlock = this.initialSyncBlockNumber; - await this.db.setHistoricBlockData(historicBlockData); + await this.db.setBlockHeader(blockHeader); } protected async work(limit = 1, retryInterval = 1000): Promise { @@ -204,18 +201,18 @@ export class Synchronizer { } const globalsHash = computeGlobalsHash(latestBlock.block.globalVariables); - const blockData = new HistoricBlockData( + const blockHeader = new BlockHeader( block.endNoteHashTreeSnapshot.root, block.endNullifierTreeSnapshot.root, block.endContractTreeSnapshot.root, block.endL1ToL2MessagesTreeSnapshot.root, - block.endHistoricBlocksTreeSnapshot.root, + block.endBlocksTreeSnapshot.root, Fr.ZERO, // todo: private kernel vk tree root block.endPublicDataTreeRoot, globalsHash, ); - await this.db.setHistoricBlockData(blockData); + await this.db.setBlockHeader(blockHeader); } /** diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index ea943c69120..808e02f6cae 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -54,10 +54,10 @@ import { EmptyRollupProver } from '../prover/empty.js'; import { RollupProver } from '../prover/index.js'; import { ProcessedTx, - makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricTreeRoots, + makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricalTreeRoots, makeProcessedTx, } from '../sequencer/processed_tx.js'; -import { getHistoricBlockData } from '../sequencer/utils.js'; +import { getBlockHeader } from '../sequencer/utils.js'; import { RollupSimulator } from '../simulator/index.js'; import { RealRollupCircuitSimulator } from '../simulator/rollup.js'; import { SoloBlockBuilder } from './solo_block_builder.js'; @@ -115,8 +115,8 @@ describe('sequencer/solo_block_builder', () => { }, 20_000); const makeEmptyProcessedTx = async () => { - const historicTreeRoots = await getHistoricBlockData(builderDb); - return makeEmptyProcessedTxFromHistoricTreeRoots(historicTreeRoots, chainId, version); + const historicalTreeRoots = await getBlockHeader(builderDb); + return makeEmptyProcessedTxFromHistoricalTreeRoots(historicalTreeRoots, chainId, version); }; // Updates the expectedDb trees based on the new commitments, contracts, and nullifiers from these txs @@ -143,7 +143,7 @@ describe('sequencer/solo_block_builder', () => { await expectsDb.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGES_TREE, asBuffer); }; - const updateHistoricBlocksTree = async () => { + const updateBlocksTree = async () => { const blockHash = computeBlockHashWithGlobals( globalVariables, rootRollupOutput.endNoteHashTreeSnapshot.root, @@ -162,7 +162,7 @@ describe('sequencer/solo_block_builder', () => { const buildMockSimulatorInputs = async () => { const kernelOutput = makePrivateKernelPublicInputsFinal(); - kernelOutput.constants.blockData = await getHistoricBlockData(expectsDb); + kernelOutput.constants.blockHeader = await getBlockHeader(expectsDb); const tx = await makeProcessedTx( new Tx( @@ -204,8 +204,8 @@ describe('sequencer/solo_block_builder', () => { // Calculate block hash rootRollupOutput.globalVariables = globalVariables; - await updateHistoricBlocksTree(); - rootRollupOutput.endHistoricBlocksTreeSnapshot = await getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); + await updateBlocksTree(); + rootRollupOutput.endBlocksTreeSnapshot = await getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); const txs = [...txsLeft, ...txsRight]; @@ -235,8 +235,8 @@ describe('sequencer/solo_block_builder', () => { endPublicDataTreeRoot: rootRollupOutput.endPublicDataTreeRoot, startL1ToL2MessagesTreeSnapshot: rootRollupOutput.startL1ToL2MessagesTreeSnapshot, endL1ToL2MessagesTreeSnapshot: rootRollupOutput.endL1ToL2MessagesTreeSnapshot, - startHistoricBlocksTreeSnapshot: rootRollupOutput.startHistoricBlocksTreeSnapshot, - endHistoricBlocksTreeSnapshot: rootRollupOutput.endHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot: rootRollupOutput.startBlocksTreeSnapshot, + endBlocksTreeSnapshot: rootRollupOutput.endBlocksTreeSnapshot, newCommitments, newNullifiers, newContracts, @@ -298,7 +298,7 @@ describe('sequencer/solo_block_builder', () => { const makeBloatedProcessedTx = async (seed = 0x1) => { const tx = mockTx(seed); const kernelOutput = KernelCircuitPublicInputs.empty(); - kernelOutput.constants.blockData = await getHistoricBlockData(builderDb); + kernelOutput.constants.blockHeader = await getBlockHeader(builderDb); kernelOutput.end.publicDataUpdateRequests = makeTuple( MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)), diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts index 464e766a69e..06976b2f209 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts @@ -1,12 +1,12 @@ import { AppendOnlyTreeSnapshot, + BLOCKS_TREE_HEIGHT, BaseOrMergeRollupPublicInputs, BaseRollupInputs, CONTRACT_SUBTREE_HEIGHT, CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, ConstantRollupData, GlobalVariables, - HISTORIC_BLOCKS_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, @@ -103,7 +103,7 @@ export class SoloBlockBuilder implements BlockBuilder { startContractTreeSnapshot, startPublicDataTreeSnapshot, startL1ToL2MessageTreeSnapshot, - startHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot, ] = await Promise.all( [ MerkleTreeId.NOTE_HASH_TREE, @@ -127,7 +127,7 @@ export class SoloBlockBuilder implements BlockBuilder { endContractTreeSnapshot, endPublicDataTreeRoot, endL1ToL2MessagesTreeSnapshot, - endHistoricBlocksTreeSnapshot, + endBlocksTreeSnapshot, } = circuitsOutput; // Collect all new nullifiers, commitments, and contracts from all txs in this block @@ -167,8 +167,8 @@ export class SoloBlockBuilder implements BlockBuilder { endPublicDataTreeRoot, startL1ToL2MessagesTreeSnapshot: startL1ToL2MessageTreeSnapshot, endL1ToL2MessagesTreeSnapshot, - startHistoricBlocksTreeSnapshot, - endHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot, + endBlocksTreeSnapshot, newCommitments, newNullifiers, newL2ToL1Msgs, @@ -193,14 +193,14 @@ export class SoloBlockBuilder implements BlockBuilder { protected validateTxs(txs: ProcessedTx[]) { for (const tx of txs) { - for (const historicTreeRoot of [ + for (const historicalTreeRoot of [ 'noteHashTreeRoot', 'contractTreeRoot', 'nullifierTreeRoot', 'l1ToL2MessagesTreeRoot', ] as const) { - if (tx.data.constants.blockData[historicTreeRoot].isZero()) { - throw new Error(`Empty ${historicTreeRoot} for tx: ${toFriendlyJSON(tx)}`); + if (tx.data.constants.blockHeader[historicalTreeRoot].isZero()) { + throw new Error(`Empty ${historicalTreeRoot} for tx: ${toFriendlyJSON(tx)}`); } } } @@ -313,15 +313,15 @@ export class SoloBlockBuilder implements BlockBuilder { this.debug(`Updating and validating root trees`); const globalVariablesHash = computeGlobalsHash(left[0].constants.globalVariables); await this.db.updateLatestGlobalVariablesHash(globalVariablesHash); - await this.db.updateHistoricBlocksTree(globalVariablesHash); + await this.db.updateBlocksTree(globalVariablesHash); await this.validateRootOutput(rootOutput); return [rootOutput, rootProof]; } - async updateHistoricBlocksTree(globalVariables: GlobalVariables) { - // Calculate the block hash and add it to the historic block hashes tree + async updateBlocksTree(globalVariables: GlobalVariables) { + // Calculate the block hash and add it to the historical block hashes tree const blockHash = await this.calculateBlockHash(globalVariables); await this.db.appendLeaves(MerkleTreeId.BLOCKS_TREE, [blockHash.toBuffer()]); } @@ -364,7 +364,7 @@ export class SoloBlockBuilder implements BlockBuilder { protected async validateRootOutput(rootOutput: RootRollupPublicInputs) { await Promise.all([ this.validateTrees(rootOutput), - this.validateTree(rootOutput, MerkleTreeId.BLOCKS_TREE, 'HistoricBlocks'), + this.validateTree(rootOutput, MerkleTreeId.BLOCKS_TREE, 'Blocks'), this.validateTree(rootOutput, MerkleTreeId.L1_TO_L2_MESSAGES_TREE, 'L1ToL2Messages'), ]); } @@ -376,7 +376,7 @@ export class SoloBlockBuilder implements BlockBuilder { name: 'Contract' | 'NoteHash' | 'L1ToL2Messages', ) { const localTree = await this.getTreeSnapshot(treeId); - const simulatedTree = rootOutput[`endTreeOfHistoric${name}TreeRootsSnapshot`]; + const simulatedTree = rootOutput[`endTreeOfHistorical${name}TreeRootsSnapshot`]; this.validateSimulatedTree(localTree, simulatedTree, name, `Roots ${name}`); } @@ -414,7 +414,7 @@ export class SoloBlockBuilder implements BlockBuilder { protected validateSimulatedTree( localTree: AppendOnlyTreeSnapshot, simulatedTree: AppendOnlyTreeSnapshot, - name: 'NoteHash' | 'Contract' | 'Nullifier' | 'L1ToL2Messages' | 'HistoricBlocks', + name: 'NoteHash' | 'Contract' | 'Nullifier' | 'L1ToL2Messages' | 'Blocks', label?: string, ) { if (!simulatedTree.root.toBuffer().equals(localTree.root.toBuffer())) { @@ -466,13 +466,13 @@ export class SoloBlockBuilder implements BlockBuilder { // Get tree snapshots const startL1ToL2MessagesTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGES_TREE); - // Get historic block tree roots - const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); - const newHistoricBlocksTreeSiblingPathArray = await getRootTreeSiblingPath(MerkleTreeId.BLOCKS_TREE); + // Get blocks tree + const startBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); + const newBlocksTreeSiblingPathArray = await getRootTreeSiblingPath(MerkleTreeId.BLOCKS_TREE); - const newHistoricBlocksTreeSiblingPath = makeTuple( - HISTORIC_BLOCKS_TREE_HEIGHT, - i => (i < newHistoricBlocksTreeSiblingPathArray.length ? newHistoricBlocksTreeSiblingPathArray[i] : Fr.ZERO), + const newBlocksTreeSiblingPath = makeTuple( + BLOCKS_TREE_HEIGHT, + i => (i < newBlocksTreeSiblingPathArray.length ? newBlocksTreeSiblingPathArray[i] : Fr.ZERO), 0, ); @@ -481,8 +481,8 @@ export class SoloBlockBuilder implements BlockBuilder { newL1ToL2Messages, newL1ToL2MessagesTreeRootSiblingPath, startL1ToL2MessagesTreeSnapshot, - startHistoricBlocksTreeSnapshot, - newHistoricBlocksTreeSiblingPath, + startBlocksTreeSnapshot, + newBlocksTreeSiblingPath, }); } @@ -539,19 +539,19 @@ export class SoloBlockBuilder implements BlockBuilder { return new MembershipWitness(height, index, assertLength(path.toFieldArray(), height)); } - protected getHistoricTreesMembershipWitnessFor(tx: ProcessedTx) { - const blockData = tx.data.constants.blockData; + protected getHistoricalTreesMembershipWitnessFor(tx: ProcessedTx) { + const blockHeader = tx.data.constants.blockHeader; const { noteHashTreeRoot, nullifierTreeRoot, contractTreeRoot, l1ToL2MessagesTreeRoot, publicDataTreeRoot } = - blockData; + blockHeader; const blockHash = computeBlockHash( - blockData.globalVariablesHash, + blockHeader.globalVariablesHash, noteHashTreeRoot, nullifierTreeRoot, contractTreeRoot, l1ToL2MessagesTreeRoot, publicDataTreeRoot, ); - return this.getMembershipWitnessFor(blockHash, MerkleTreeId.BLOCKS_TREE, HISTORIC_BLOCKS_TREE_HEIGHT); + return this.getMembershipWitnessFor(blockHash, MerkleTreeId.BLOCKS_TREE, BLOCKS_TREE_HEIGHT); } protected async getConstantRollupData(globalVariables: GlobalVariables): Promise { @@ -560,7 +560,7 @@ export class SoloBlockBuilder implements BlockBuilder { mergeRollupVkHash: DELETE_FR, privateKernelVkTreeRoot: FUTURE_FR, publicKernelVkTreeRoot: FUTURE_FR, - startHistoricBlocksTreeRootsSnapshot: await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE), + startBlocksTreeSnapshot: await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE), globalVariables, }); } @@ -651,7 +651,7 @@ export class SoloBlockBuilder implements BlockBuilder { const startContractTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE); const startNoteHashTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.NOTE_HASH_TREE); const startPublicDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PUBLIC_DATA_TREE); - const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); + const startBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE); // Get the subtree sibling paths for the circuit const newCommitmentsSubtreeSiblingPathArray = await this.getSubtreeSiblingPath( @@ -736,7 +736,7 @@ export class SoloBlockBuilder implements BlockBuilder { startContractTreeSnapshot, startNoteHashTreeSnapshot, startPublicDataTreeRoot: startPublicDataTreeSnapshot.root, - startHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot, sortedNewNullifiers: makeTuple(MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, i => Fr.fromBuffer(sortedNewNullifiers[i])), sortednewNullifiersIndexes: makeTuple(MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP, i => sortednewNullifiersIndexes[i]), newCommitmentsSubtreeSiblingPath, @@ -761,9 +761,9 @@ export class SoloBlockBuilder implements BlockBuilder { : this.makeEmptyMembershipWitness(NULLIFIER_TREE_HEIGHT), ), kernelData: [this.getKernelDataFor(left), this.getKernelDataFor(right)], - historicBlocksTreeRootMembershipWitnesses: [ - await this.getHistoricTreesMembershipWitnessFor(left), - await this.getHistoricTreesMembershipWitnessFor(right), + blocksTreeRootMembershipWitnesses: [ + await this.getHistoricalTreesMembershipWitnessFor(left), + await this.getHistoricalTreesMembershipWitnessFor(right), ], }); } diff --git a/yarn-project/sequencer-client/src/block_builder/types.ts b/yarn-project/sequencer-client/src/block_builder/types.ts index b909dbc1721..b39f0a90a17 100644 --- a/yarn-project/sequencer-client/src/block_builder/types.ts +++ b/yarn-project/sequencer-client/src/block_builder/types.ts @@ -5,7 +5,7 @@ import { AppendOnlyTreeSnapshot, BaseOrMergeRollupPublicInputs, RootRollupPublic */ export type AllowedTreeNames = T extends RootRollupPublicInputs - ? 'NoteHash' | 'Contract' | 'Nullifier' | 'L1ToL2Messages' | 'HistoricBlocks' + ? 'NoteHash' | 'Contract' | 'Nullifier' | 'L1ToL2Messages' | 'Blocks' : 'NoteHash' | 'Contract' | 'Nullifier'; /** diff --git a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts index 508981f981d..b3d098acb47 100644 --- a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts +++ b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts @@ -1,7 +1,7 @@ import { + BlockHeader, CombinedAccumulatedData, Fr, - HistoricBlockData, Proof, PublicKernelPublicInputs, makeEmptyProof, @@ -87,13 +87,9 @@ export async function makeProcessedTx( * Makes an empty tx from an empty kernel circuit public inputs. * @returns A processed empty tx. */ -export function makeEmptyProcessedTx( - historicTreeRoots: HistoricBlockData, - chainId: Fr, - version: Fr, -): Promise { +export function makeEmptyProcessedTx(historicalTreeRoots: BlockHeader, chainId: Fr, version: Fr): Promise { const emptyKernelOutput = PublicKernelPublicInputs.empty(); - emptyKernelOutput.constants.blockData = historicTreeRoots; + emptyKernelOutput.constants.blockHeader = historicalTreeRoots; emptyKernelOutput.constants.txContext.chainId = chainId; emptyKernelOutput.constants.txContext.version = version; const emptyProof = makeEmptyProof(); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 621018a0459..382730e4c36 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -2,6 +2,7 @@ import { PublicExecution, PublicExecutionResult, PublicExecutor } from '@aztec/a import { ARGS_LENGTH, AztecAddress, + BlockHeader, CallContext, CallRequest, CombinedAccumulatedData, @@ -9,7 +10,6 @@ import { Fr, FunctionData, GlobalVariables, - HistoricBlockData, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, PUBLIC_DATA_TREE_HEIGHT, @@ -85,7 +85,7 @@ describe('public_processor', () => { publicKernel, publicProver, GlobalVariables.empty(), - HistoricBlockData.empty(), + BlockHeader.empty(), publicContractsDB, publicWorldStateDB, ); @@ -140,7 +140,7 @@ describe('public_processor', () => { publicKernel, publicProver, GlobalVariables.empty(), - HistoricBlockData.empty(), + BlockHeader.empty(), publicContractsDB, publicWorldStateDB, ); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index e243f5c82e5..820da1cf0c6 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -9,13 +9,13 @@ import { } from '@aztec/acir-simulator'; import { AztecAddress, + BlockHeader, CallRequest, CombinedAccumulatedData, ContractStorageRead, ContractStorageUpdateRequest, Fr, GlobalVariables, - HistoricBlockData, KernelCircuitPublicInputs, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, @@ -52,7 +52,7 @@ import { PublicKernelCircuitSimulator } from '../simulator/index.js'; import { ContractsDataSourcePublicDB, WorldStateDB, WorldStatePublicDB } from '../simulator/public_executor.js'; import { RealPublicKernelCircuitSimulator } from '../simulator/public_kernel.js'; import { FailedTx, ProcessedTx, makeEmptyProcessedTx, makeProcessedTx } from './processed_tx.js'; -import { getHistoricBlockData } from './utils.js'; +import { getBlockHeader } from './utils.js'; /** * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source. @@ -75,18 +75,18 @@ export class PublicProcessorFactory { prevGlobalVariables: GlobalVariables, globalVariables: GlobalVariables, ): Promise { - const blockData = await getHistoricBlockData(this.merkleTree, prevGlobalVariables); + const blockHeader = await getBlockHeader(this.merkleTree, prevGlobalVariables); const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource); const worldStatePublicDB = new WorldStatePublicDB(this.merkleTree); const worldStateDB = new WorldStateDB(this.merkleTree, this.l1Tol2MessagesDataSource); - const publicExecutor = new PublicExecutor(worldStatePublicDB, publicContractsDB, worldStateDB, blockData); + const publicExecutor = new PublicExecutor(worldStatePublicDB, publicContractsDB, worldStateDB, blockHeader); return new PublicProcessor( this.merkleTree, publicExecutor, new RealPublicKernelCircuitSimulator(), new EmptyPublicProver(), globalVariables, - blockData, + blockHeader, publicContractsDB, worldStatePublicDB, ); @@ -104,7 +104,7 @@ export class PublicProcessor { protected publicKernel: PublicKernelCircuitSimulator, protected publicProver: PublicProver, protected globalVariables: GlobalVariables, - protected blockData: HistoricBlockData, + protected blockHeader: BlockHeader, protected publicContractsDB: ContractsDataSourcePublicDB, protected publicStateDB: PublicStateDB, @@ -152,7 +152,7 @@ export class PublicProcessor { */ public makeEmptyProcessedTx(): Promise { const { chainId, version } = this.globalVariables; - return makeEmptyProcessedTx(this.blockData, chainId, version); + return makeEmptyProcessedTx(this.blockHeader, chainId, version); } protected async processTx(tx: Tx): Promise { @@ -259,7 +259,7 @@ export class PublicProcessor { protected async getPublicCircuitPublicInputs(result: PublicExecutionResult) { const publicDataTreeInfo = await this.db.getTreeInfo(MerkleTreeId.PUBLIC_DATA_TREE); - this.blockData.publicDataTreeRoot = Fr.fromBuffer(publicDataTreeInfo.root); + this.blockHeader.publicDataTreeRoot = Fr.fromBuffer(publicDataTreeInfo.root); const callStackPreimages = await this.getPublicCallStackPreimages(result); const publicCallStackHashes = padArrayEnd( @@ -293,7 +293,7 @@ export class PublicProcessor { publicCallStackHashes, unencryptedLogsHash, unencryptedLogPreimagesLength, - historicBlockData: this.blockData, + blockHeader: this.blockHeader, }); } diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index 792c6236ecd..694f4ee61b7 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -1,7 +1,7 @@ import { + BlockHeader, Fr, GlobalVariables, - HistoricBlockData, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, makeEmptyProof, } from '@aztec/circuits.js'; @@ -57,7 +57,7 @@ describe('sequencer', () => { publicProcessor = mock({ process: async txs => [await Promise.all(txs.map(tx => makeProcessedTx(tx))), []], - makeEmptyProcessedTx: () => makeEmptyProcessedTx(HistoricBlockData.empty(), chainId, version), + makeEmptyProcessedTx: () => makeEmptyProcessedTx(BlockHeader.empty(), chainId, version), }); publicProcessorFactory = mock({ diff --git a/yarn-project/sequencer-client/src/sequencer/utils.ts b/yarn-project/sequencer-client/src/sequencer/utils.ts index b43747fc644..62cde96601b 100644 --- a/yarn-project/sequencer-client/src/sequencer/utils.ts +++ b/yarn-project/sequencer-client/src/sequencer/utils.ts @@ -1,18 +1,18 @@ -import { Fr, GlobalVariables, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, Fr, GlobalVariables } from '@aztec/circuits.js'; import { computeGlobalsHash } from '@aztec/circuits.js/abis'; import { MerkleTreeOperations } from '@aztec/world-state'; /** - * Fetches the private, nullifier, contract tree and l1 to l2 messages tree roots from a given db and assembles a CombinedHistoricTreeRoots object. + * Fetches the private, nullifier, contract tree and l1 to l2 messages tree roots from a given db and assembles a CombinedHistoricalTreeRoots object. */ -export async function getHistoricBlockData( +export async function getBlockHeader( db: MerkleTreeOperations, prevBlockGlobalVariables: GlobalVariables = GlobalVariables.empty(), ) { const prevGlobalsHash = computeGlobalsHash(prevBlockGlobalVariables); const roots = await db.getTreeRoots(); - return new HistoricBlockData( + return new BlockHeader( Fr.fromBuffer(roots.noteHashTreeRoot), Fr.fromBuffer(roots.nullifierTreeRoot), Fr.fromBuffer(roots.contractDataTreeRoot), diff --git a/yarn-project/types/src/aztec_node/rpc/aztec_node_client.ts b/yarn-project/types/src/aztec_node/rpc/aztec_node_client.ts index 1c312302357..4f2f702c21c 100644 --- a/yarn-project/types/src/aztec_node/rpc/aztec_node_client.ts +++ b/yarn-project/types/src/aztec_node/rpc/aztec_node_client.ts @@ -1,4 +1,4 @@ -import { FunctionSelector, HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader, FunctionSelector } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; @@ -35,7 +35,7 @@ export function createAztecNodeClient(url: string, fetch = defaultFetch): AztecN ContractData, Fr, FunctionSelector, - HistoricBlockData, + BlockHeader, L2Block, L2Tx, LogId, diff --git a/yarn-project/types/src/interfaces/aztec-node.ts b/yarn-project/types/src/interfaces/aztec-node.ts index e03966ec8ae..92463e96b0f 100644 --- a/yarn-project/types/src/interfaces/aztec-node.ts +++ b/yarn-project/types/src/interfaces/aztec-node.ts @@ -1,4 +1,4 @@ -import { HistoricBlockData } from '@aztec/circuits.js'; +import { BlockHeader } from '@aztec/circuits.js'; import { L1ContractAddresses } from '@aztec/ethereum'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -139,10 +139,10 @@ export interface AztecNode extends StateInfoProvider { getTreeRoots(): Promise>; /** - * Returns the currently committed historic block data. - * @returns The current committed block data. + * Returns the currently committed block header. + * @returns The current committed block header. */ - getHistoricBlockData(): Promise; + getBlockHeader(): Promise; /** * Simulates the public part of a transaction with the current state. diff --git a/yarn-project/types/src/interfaces/state_provider.ts b/yarn-project/types/src/interfaces/state_provider.ts index 68d01812a7e..33117aab1d5 100644 --- a/yarn-project/types/src/interfaces/state_provider.ts +++ b/yarn-project/types/src/interfaces/state_provider.ts @@ -1,7 +1,7 @@ import { + BLOCKS_TREE_HEIGHT, CONTRACT_TREE_HEIGHT, Fr, - HISTORIC_BLOCKS_TREE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, @@ -72,7 +72,7 @@ export interface StateInfoProvider { * @returns The sibling path. * TODO: https://github.com/AztecProtocol/aztec-packages/issues/3414 */ - getHistoricBlocksTreeSiblingPath(leafIndex: bigint): Promise>; + getBlocksTreeSiblingPath(leafIndex: bigint): Promise>; /** * Returns a sibling path for a leaf in the committed public data tree. diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 1ddd1347ede..67832ef2da7 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -86,9 +86,9 @@ export class L2Block { */ public startL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot, /** - * The tree snapshot of the historic blocks tree at the start of the rollup. + * The tree snapshot of the blocks tree at the start of the rollup. */ - public startHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot = AppendOnlyTreeSnapshot.empty(), + public startBlocksTreeSnapshot: AppendOnlyTreeSnapshot = AppendOnlyTreeSnapshot.empty(), /** * The tree snapshot of the note hash tree at the end of the rollup. */ @@ -110,9 +110,9 @@ export class L2Block { */ public endL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot, /** - * The tree snapshot of the historic blocks tree at the end of the rollup. + * The tree snapshot of the blocks tree at the end of the rollup. */ - public endHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot, + public endBlocksTreeSnapshot: AppendOnlyTreeSnapshot, /** * The commitments to be inserted into the note hash tree. */ @@ -216,13 +216,13 @@ export class L2Block { startContractTreeSnapshot: makeAppendOnlyTreeSnapshot(0), startPublicDataTreeRoot: Fr.random(), startL1ToL2MessagesTreeSnapshot: makeAppendOnlyTreeSnapshot(0), - startHistoricBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot(0), + startBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot(0), endNoteHashTreeSnapshot: makeAppendOnlyTreeSnapshot(newCommitments.length), endNullifierTreeSnapshot: makeAppendOnlyTreeSnapshot(newNullifiers.length), endContractTreeSnapshot: makeAppendOnlyTreeSnapshot(newContracts.length), endPublicDataTreeRoot: Fr.random(), endL1ToL2MessagesTreeSnapshot: makeAppendOnlyTreeSnapshot(1), - endHistoricBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot(1), + endBlocksTreeSnapshot: makeAppendOnlyTreeSnapshot(1), newCommitments, newNullifiers, newContracts, @@ -277,9 +277,9 @@ export class L2Block { */ startL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot; /** - * The tree snapshot of the historic blocks tree at the start of the rollup. + * The tree snapshot of the blocks tree at the start of the rollup. */ - startHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot; + startBlocksTreeSnapshot: AppendOnlyTreeSnapshot; /** * The tree snapshot of the note hash tree at the end of the rollup. */ @@ -301,9 +301,9 @@ export class L2Block { */ endL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot; /** - * The tree snapshot of the historic blocks tree at the end of the rollup. + * The tree snapshot of the blocks tree at the end of the rollup. */ - endHistoricBlocksTreeSnapshot: AppendOnlyTreeSnapshot; + endBlocksTreeSnapshot: AppendOnlyTreeSnapshot; /** * The commitments to be inserted into the note hash tree. */ @@ -352,13 +352,13 @@ export class L2Block { fields.startContractTreeSnapshot, fields.startPublicDataTreeRoot, fields.startL1ToL2MessagesTreeSnapshot, - fields.startHistoricBlocksTreeSnapshot, + fields.startBlocksTreeSnapshot, fields.endNoteHashTreeSnapshot, fields.endNullifierTreeSnapshot, fields.endContractTreeSnapshot, fields.endPublicDataTreeRoot, fields.endL1ToL2MessagesTreeSnapshot, - fields.endHistoricBlocksTreeSnapshot, + fields.endBlocksTreeSnapshot, fields.newCommitments, fields.newNullifiers, fields.newPublicDataWrites, @@ -387,13 +387,13 @@ export class L2Block { this.startContractTreeSnapshot, this.startPublicDataTreeRoot, this.startL1ToL2MessagesTreeSnapshot, - this.startHistoricBlocksTreeSnapshot, + this.startBlocksTreeSnapshot, this.endNoteHashTreeSnapshot, this.endNullifierTreeSnapshot, this.endContractTreeSnapshot, this.endPublicDataTreeRoot, this.endL1ToL2MessagesTreeSnapshot, - this.endHistoricBlocksTreeSnapshot, + this.endBlocksTreeSnapshot, this.newCommitments.length, this.newCommitments, this.newNullifiers.length, @@ -449,13 +449,13 @@ export class L2Block { const startContractTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const startPublicDataTreeRoot = reader.readObject(Fr); const startL1ToL2MessagesTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); - const startHistoricBlocksTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); + const startBlocksTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const endNoteHashTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const endNullifierTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const endContractTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const endPublicDataTreeRoot = reader.readObject(Fr); const endL1ToL2MessagesTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); - const endHistoricBlocksTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); + const endBlocksTreeSnapshot = reader.readObject(AppendOnlyTreeSnapshot); const newCommitments = reader.readVector(Fr); const newNullifiers = reader.readVector(Fr); const newPublicDataWrites = reader.readVector(PublicDataWrite); @@ -473,13 +473,13 @@ export class L2Block { startContractTreeSnapshot, startPublicDataTreeRoot, startL1ToL2MessagesTreeSnapshot: startL1ToL2MessagesTreeSnapshot, - startHistoricBlocksTreeSnapshot, + startBlocksTreeSnapshot, endNoteHashTreeSnapshot, endNullifierTreeSnapshot, endContractTreeSnapshot, endPublicDataTreeRoot, endL1ToL2MessagesTreeSnapshot, - endHistoricBlocksTreeSnapshot, + endBlocksTreeSnapshot, newCommitments, newNullifiers, newPublicDataWrites, @@ -589,13 +589,13 @@ export class L2Block { this.startContractTreeSnapshot, this.startPublicDataTreeRoot, this.startL1ToL2MessagesTreeSnapshot, - this.startHistoricBlocksTreeSnapshot, + this.startBlocksTreeSnapshot, this.endNoteHashTreeSnapshot, this.endNullifierTreeSnapshot, this.endContractTreeSnapshot, this.endPublicDataTreeRoot, this.endL1ToL2MessagesTreeSnapshot, - this.endHistoricBlocksTreeSnapshot, + this.endBlocksTreeSnapshot, this.getCalldataHash(), this.getL1ToL2MessagesHash(), ); @@ -615,7 +615,7 @@ export class L2Block { this.startContractTreeSnapshot, this.startPublicDataTreeRoot, this.startL1ToL2MessagesTreeSnapshot, - this.startHistoricBlocksTreeSnapshot, + this.startBlocksTreeSnapshot, ); return sha256(inputValue); } @@ -632,7 +632,7 @@ export class L2Block { this.endContractTreeSnapshot, this.endPublicDataTreeRoot, this.endL1ToL2MessagesTreeSnapshot, - this.endHistoricBlocksTreeSnapshot, + this.endBlocksTreeSnapshot, ); return sha256(inputValue); } @@ -843,14 +843,14 @@ export class L2Block { `startContractTreeSnapshot: ${inspectTreeSnapshot(this.startContractTreeSnapshot)}`, `startPublicDataTreeRoot: ${this.startPublicDataTreeRoot.toString()}`, `startL1ToL2MessagesTreeSnapshot: ${inspectTreeSnapshot(this.startL1ToL2MessagesTreeSnapshot)}`, - `startHistoricBlocksTreeSnapshot: ${inspectTreeSnapshot(this.startHistoricBlocksTreeSnapshot)}`, + `startBlocksTreeSnapshot: ${inspectTreeSnapshot(this.startBlocksTreeSnapshot)}`, `endNoteHashTreeSnapshot: ${inspectTreeSnapshot(this.endNoteHashTreeSnapshot)}`, `endNullifierTreeSnapshot: ${inspectTreeSnapshot(this.endNullifierTreeSnapshot)}`, `endContractTreeSnapshot: ${inspectTreeSnapshot(this.endContractTreeSnapshot)}`, `endPublicDataTreeRoot: ${this.endPublicDataTreeRoot.toString()}`, `endPublicDataTreeRoot: ${this.endPublicDataTreeRoot.toString()}`, `endL1ToL2MessagesTreeSnapshot: ${inspectTreeSnapshot(this.endL1ToL2MessagesTreeSnapshot)}`, - `endHistoricBlocksTreeSnapshot: ${inspectTreeSnapshot(this.endHistoricBlocksTreeSnapshot)}`, + `endBlocksTreeSnapshot: ${inspectTreeSnapshot(this.endBlocksTreeSnapshot)}`, `newCommitments: ${inspectFrArray(this.newCommitments)}`, `newNullifiers: ${inspectFrArray(this.newNullifiers)}`, `newPublicDataWrite: ${inspectPublicDataWriteArray(this.newPublicDataWrites)}`, diff --git a/yarn-project/world-state/README.md b/yarn-project/world-state/README.md index 42f095d9dbb..a14b1fa02b6 100644 --- a/yarn-project/world-state/README.md +++ b/yarn-project/world-state/README.md @@ -11,9 +11,9 @@ As of the time of writing the collection consisted of the following trees. #### Standard 'Append Only' trees - The Contract Tree. Every contract created within the system has a 'Function Tree', a tree of leaves generated from the functions on the contract. The root of the function tree is inserted as a leaf in the contracts tree. -- The Contract Tree Roots Tree. A tree whose leaves are the historic roots of the contract tree. +- The Contract Tree Roots Tree. A tree whose leaves are the historical roots of the contract tree. - The Note Hash Tree. A tree whose leaves are the note hashes of notes generated by the private contract function calls within the system. -- The Note Hash Tree Roots Tree. A tree whose leaves are the historic roots of the note hash tree. +- The Note Hash Tree Roots Tree. A tree whose leaves are the historical roots of the note hash tree. #### Indexed trees diff --git a/yarn-project/world-state/src/merkle-tree/merkle_tree_operations_facade.ts b/yarn-project/world-state/src/merkle-tree/merkle_tree_operations_facade.ts index 31240357748..29ba293736d 100644 --- a/yarn-project/world-state/src/merkle-tree/merkle_tree_operations_facade.ts +++ b/yarn-project/world-state/src/merkle-tree/merkle_tree_operations_facade.ts @@ -120,8 +120,8 @@ export class MerkleTreeOperationsFacade implements MerkleTreeOperations { * @param globalVariablesHash - The hash of the current global variables to include in the block hash. * @returns Empty promise. */ - public updateHistoricBlocksTree(globalVariablesHash: Fr): Promise { - return this.trees.updateHistoricBlocksTree(globalVariablesHash, this.includeUncommitted); + public updateBlocksTree(globalVariablesHash: Fr): Promise { + return this.trees.updateBlocksTree(globalVariablesHash, this.includeUncommitted); } /** diff --git a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts index 4fe162c12b0..d5e3798a7c6 100644 --- a/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts @@ -72,13 +72,13 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = startContractTreeSnapshot: getMockTreeSnapshot(), startPublicDataTreeRoot: Fr.random(), startL1ToL2MessagesTreeSnapshot: getMockTreeSnapshot(), - startHistoricBlocksTreeSnapshot: getMockTreeSnapshot(), + startBlocksTreeSnapshot: getMockTreeSnapshot(), endNoteHashTreeSnapshot: getMockTreeSnapshot(), endNullifierTreeSnapshot: getMockTreeSnapshot(), endContractTreeSnapshot: getMockTreeSnapshot(), endPublicDataTreeRoot: Fr.random(), endL1ToL2MessagesTreeSnapshot: getMockTreeSnapshot(), - endHistoricBlocksTreeSnapshot: getMockTreeSnapshot(), + endBlocksTreeSnapshot: getMockTreeSnapshot(), newCommitments: times(MAX_NEW_COMMITMENTS_PER_TX, Fr.random), newNullifiers: times(MAX_NEW_NULLIFIERS_PER_TX, Fr.random), newContracts: newContractsCommitments?.map(x => Fr.fromBuffer(x)) ?? [Fr.random()], diff --git a/yarn-project/world-state/src/world-state-db/merkle_tree_db.ts b/yarn-project/world-state/src/world-state-db/merkle_tree_db.ts index 8f191517a82..b9dc631ff1f 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_tree_db.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_tree_db.ts @@ -175,7 +175,7 @@ export interface MerkleTreeOperations { * This includes all of the current roots of all of the data trees and the current blocks global vars. * @param globalVariablesHash - The global variables hash to insert into the block hash. */ - updateHistoricBlocksTree(globalVariablesHash: Fr): Promise; + updateBlocksTree(globalVariablesHash: Fr): Promise; /** * Updates the latest global variables hash diff --git a/yarn-project/world-state/src/world-state-db/merkle_trees.ts b/yarn-project/world-state/src/world-state-db/merkle_trees.ts index a27b1706612..3d167bf4a9c 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_trees.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_trees.ts @@ -1,8 +1,8 @@ import { + BLOCKS_TREE_HEIGHT, CONTRACT_TREE_HEIGHT, Fr, GlobalVariables, - HISTORIC_BLOCKS_TREE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT, @@ -110,14 +110,14 @@ export class MerkleTrees implements MerkleTreeDb { `${MerkleTreeId[MerkleTreeId.L1_TO_L2_MESSAGES_TREE]}`, L1_TO_L2_MSG_TREE_HEIGHT, ); - const historicBlocksTree: AppendOnlyTree = await initializeTree( + const blocksTree: AppendOnlyTree = await initializeTree( StandardTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.BLOCKS_TREE]}`, - HISTORIC_BLOCKS_TREE_HEIGHT, + BLOCKS_TREE_HEIGHT, ); - this.trees = [contractTree, nullifierTree, noteHashTree, publicDataTree, l1Tol2MessagesTree, historicBlocksTree]; + this.trees = [contractTree, nullifierTree, noteHashTree, publicDataTree, l1Tol2MessagesTree, blocksTree]; this.jobQueue.start(); @@ -125,7 +125,7 @@ export class MerkleTrees implements MerkleTreeDb { if (!fromDb) { const initialGlobalVariablesHash = computeGlobalsHash(GlobalVariables.empty()); await this._updateLatestGlobalVariablesHash(initialGlobalVariablesHash); - await this._updateHistoricBlocksTree(initialGlobalVariablesHash, true); + await this._updateBlocksTree(initialGlobalVariablesHash, true); await this._commit(); } else { await this._updateLatestGlobalVariablesHash(fromDbOptions.globalVariablesHash); @@ -177,8 +177,8 @@ export class MerkleTrees implements MerkleTreeDb { * @param globalsHash - The current global variables hash. * @param includeUncommitted - Indicates whether to include uncommitted data. */ - public async updateHistoricBlocksTree(globalsHash: Fr, includeUncommitted: boolean) { - await this.synchronize(() => this._updateHistoricBlocksTree(globalsHash, includeUncommitted)); + public async updateBlocksTree(globalsHash: Fr, includeUncommitted: boolean) { + await this.synchronize(() => this._updateBlocksTree(globalsHash, includeUncommitted)); } /** @@ -427,7 +427,7 @@ export class MerkleTrees implements MerkleTreeDb { return Promise.resolve(this.latestGlobalVariablesHash.get(includeUncommitted)); } - private async _updateHistoricBlocksTree(globalsHash: Fr, includeUncommitted: boolean) { + private async _updateBlocksTree(globalsHash: Fr, includeUncommitted: boolean) { const blockHash = await this._getCurrentBlockHash(globalsHash, includeUncommitted); await this._appendLeaves(MerkleTreeId.BLOCKS_TREE, [blockHash.toBuffer()]); } @@ -532,7 +532,7 @@ export class MerkleTrees implements MerkleTreeDb { [l2Block.endNoteHashTreeSnapshot.root, MerkleTreeId.NOTE_HASH_TREE], [l2Block.endPublicDataTreeRoot, MerkleTreeId.PUBLIC_DATA_TREE], [l2Block.endL1ToL2MessagesTreeSnapshot.root, MerkleTreeId.L1_TO_L2_MESSAGES_TREE], - [l2Block.endHistoricBlocksTreeSnapshot.root, MerkleTreeId.BLOCKS_TREE], + [l2Block.endBlocksTreeSnapshot.root, MerkleTreeId.BLOCKS_TREE], ] as const; const compareRoot = (root: Fr, treeId: MerkleTreeId) => { const treeRoot = this.trees[treeId].getRoot(true); @@ -573,7 +573,7 @@ export class MerkleTrees implements MerkleTreeDb { await this._updateLeaf(MerkleTreeId.PUBLIC_DATA_TREE, newValue.toBuffer(), leafIndex.value); } - // Sync and add the block to the historic blocks tree + // Sync and add the block to the blocks tree const globalVariablesHash = computeGlobalsHash(l2Block.globalVariables); await this._updateLatestGlobalVariablesHash(globalVariablesHash); this.log(`Synced global variables with hash ${globalVariablesHash}`); diff --git a/yellow-paper/docs/transactions/tx-object.md b/yellow-paper/docs/transactions/tx-object.md index 38123b6ffb9..ccfa2f7d4a7 100644 --- a/yellow-paper/docs/transactions/tx-object.md +++ b/yellow-paper/docs/transactions/tx-object.md @@ -17,7 +17,7 @@ The fields of a transaction object are the following: ### Private kernel public inputs final -Output of the last iteration of the private kernel circuit. Includes _accumulated data_ after recursing through all private function calls, as well as _constant data_ composed of _historic block data_ reflecting the state of the chain when such functions were executed, and the global _transaction context_. Refer to the circuits section for more info. +Output of the last iteration of the private kernel circuit. Includes _accumulated data_ after recursing through all private function calls, as well as _constant data_ composed of _block header_ reflecting the state of the chain when such functions were executed, and the global _transaction context_. Refer to the circuits section for more info. **Accumulated data** @@ -37,7 +37,7 @@ Output of the last iteration of the private kernel circuit. Includes _accumulate | newContracts | NewContractData[] | All the new contracts deployed in this transaction. | | maxBlockNum | Field | Maximum block number (inclusive) for inclusion of this transaction in a block. | -**Historic block data** +**Block header** | Field | Type | Description | |-------|------|-------------| diff --git a/yellow-paper/docs/transactions/validity.md b/yellow-paper/docs/transactions/validity.md index f4121e6faad..9d464e0d858 100644 --- a/yellow-paper/docs/transactions/validity.md +++ b/yellow-paper/docs/transactions/validity.md @@ -7,7 +7,7 @@ In addition to being well-formed, the transaction object needs to pass the follo - **Proof is valid**: The `proof` for the given public `data` should be valid according to a protocol-wide verification key for the final private kernel circuit. - **No double-spends**: No `nullifier` in the transaction `data` should be already present in the nullifier tree. - **No pending private function calls**: The `data` private call stack should be empty. -- **Valid historic data**: The tree roots in the historic block data of `data` must match the tree roots of a block in the chain. +- **Valid historic data**: The tree roots in the block header of `data` must match the tree roots of a block in the chain. - **Maximum block number not exceeded**: The transaction must be included in a block with height no greater than the value specified in `maxBlockNum` within the transaction's `data`. - **Preimages must match commitments in `data`**: The expanded fields in the transaction object should match the commitments (hashes) to them in the public `data`. - The `encryptedLogs` should match the `encryptedLogsHash` and `encryptedLogPreimagesLength` in the transaction `data`.