Skip to content

Commit

Permalink
refactor: naming fixes (#3476)
Browse files Browse the repository at this point in the history
Fixes #3471

1. historic -> historical
2. `HistoricBlockData`  -> `BlockHeader`
3. `Historic Blocks Tree` -> `Blocks Tree`
4. Blocks Tree was sometimes incorrectly referred to as Blocks Tree
Roots so I fixed that in [this
commit](8c9ae59).
5. Rewrote documentation of `perform_blocks_tree_membership_checks` in
[this
commit](8c9ae59)
as it was confusing.
6. Fixed some stale naming of note hash tree (private data tree)
  • Loading branch information
benesjan authored Nov 30, 2023
1 parent 8cc54a4 commit 1db30bf
Show file tree
Hide file tree
Showing 144 changed files with 996 additions and 1,018 deletions.
14 changes: 7 additions & 7 deletions circuits/cpp/src/aztec3/circuits/abis/combined_constant_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#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"

#include <barretenberg/barretenberg.hpp>

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;
Expand All @@ -19,11 +19,11 @@ template <typename NCT> struct CombinedConstantData {
using fr = typename NCT::fr;
using boolean = typename NCT::boolean;

HistoricBlockData<NCT> block_data{};
BlockHeader<NCT> block_header{};
TxContext<NCT> tx_context{};

// for serialization: update up with new fields
MSGPACK_FIELDS(block_data, tx_context);
MSGPACK_FIELDS(block_header, tx_context);
boolean operator==(CombinedConstantData<NCT> const& other) const
{
return msgpack_derived_equals<boolean>(*this, other);
Expand All @@ -34,7 +34,7 @@ template <typename NCT> struct CombinedConstantData {
static_assert((std::is_same<NativeTypes, NCT>::value));

CombinedConstantData<CircuitTypes<Builder>> constant_data = {
block_data.to_circuit_type(builder),
block_header.to_circuit_type(builder),
tx_context.to_circuit_type(builder),
};

Expand All @@ -48,7 +48,7 @@ template <typename NCT> struct CombinedConstantData {
auto to_native_type = []<typename T>(T& e) { return e.template to_native_type<Builder>(); };

CombinedConstantData<NativeTypes> constant_data = {
to_native_type(block_data),
to_native_type(block_header),
to_native_type(tx_context),
};

Expand All @@ -59,7 +59,7 @@ template <typename NCT> struct CombinedConstantData {
{
static_assert(!(std::is_same<NativeTypes, NCT>::value));

block_data.set_public();
block_header.set_public();
tx_context.set_public();
}
};
Expand Down
14 changes: 7 additions & 7 deletions circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using aztec3::utils::types::CircuitTypes;
using aztec3::utils::types::NativeTypes;
using std::is_same;

template <typename NCT> struct HistoricBlockData {
template <typename NCT> struct BlockHeader {
using fr = typename NCT::fr;
using boolean = typename NCT::boolean;

Expand All @@ -43,12 +43,12 @@ template <typename NCT> struct HistoricBlockData {
public_data_tree_root,
global_variables_hash);

boolean operator==(HistoricBlockData<NCT> const& other) const
boolean operator==(BlockHeader<NCT> 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;
Expand All @@ -68,14 +68,14 @@ template <typename NCT> struct HistoricBlockData {
global_variables_hash.assert_is_zero();
}

template <typename Builder> HistoricBlockData<CircuitTypes<Builder>> to_circuit_type(Builder& builder) const
template <typename Builder> BlockHeader<CircuitTypes<Builder>> to_circuit_type(Builder& builder) const
{
static_assert((std::is_same<NativeTypes, NCT>::value));

// Capture the circuit builder:
auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); };

HistoricBlockData<CircuitTypes<Builder>> data = {
BlockHeader<CircuitTypes<Builder>> 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),
Expand All @@ -84,12 +84,12 @@ template <typename NCT> struct HistoricBlockData {
return data;
};

template <typename Builder> HistoricBlockData<NativeTypes> to_native_type() const
template <typename Builder> BlockHeader<NativeTypes> to_native_type() const
{
static_assert(std::is_same<CircuitTypes<Builder>, NCT>::value);
auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt<Builder>(e); };

HistoricBlockData<NativeTypes> data = {
BlockHeader<NativeTypes> 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),
Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/abis/packers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -46,7 +46,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
fr encrypted_log_preimages_length = 0;
fr unencrypted_log_preimages_length = 0;

HistoricBlockData<NCT> historic_block_data{};
BlockHeader<NCT> block_header{};

ContractDeploymentData<NCT> contract_deployment_data{};

Expand All @@ -69,7 +69,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
unencrypted_logs_hash,
encrypted_log_preimages_length,
unencrypted_log_preimages_length,
historic_block_data,
block_header,
contract_deployment_data,
chain_id,
version);
Expand All @@ -85,9 +85,8 @@ template <typename NCT> 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 <typename Builder>
Expand Down Expand Up @@ -122,7 +121,7 @@ template <typename NCT> 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),

Expand Down Expand Up @@ -162,7 +161,7 @@ template <typename NCT> 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),

Expand Down Expand Up @@ -201,7 +200,7 @@ template <typename NCT> 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());

Expand Down Expand Up @@ -252,7 +251,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
opt_fr encrypted_log_preimages_length;
opt_fr unencrypted_log_preimages_length;

std::optional<HistoricBlockData<NCT>> historic_block_data;
std::optional<BlockHeader<NCT>> block_header;

std::optional<ContractDeploymentData<NCT>> contract_deployment_data;

Expand All @@ -275,7 +274,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
unencrypted_logs_hash,
encrypted_log_preimages_length,
unencrypted_log_preimages_length,
historic_block_data,
block_header,
contract_deployment_data,
chain_id,
version);
Expand Down Expand Up @@ -305,7 +304,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
opt_fr const& encrypted_log_preimages_length,
opt_fr const& unencrypted_log_preimages_length,

std::optional<HistoricBlockData<NCT>> const& historic_block_data,
std::optional<BlockHeader<NCT>> const& block_header,

std::optional<ContractDeploymentData<NCT>> const& contract_deployment_data,

Expand All @@ -326,7 +325,7 @@ template <typename NCT> 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){};
Expand Down Expand Up @@ -359,7 +358,7 @@ template <typename NCT> 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;

Expand Down Expand Up @@ -425,7 +424,7 @@ template <typename NCT> 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);

Expand Down Expand Up @@ -465,7 +464,7 @@ template <typename NCT> 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();

Expand Down Expand Up @@ -507,7 +506,7 @@ template <typename NCT> 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),

Expand Down Expand Up @@ -549,7 +548,7 @@ template <typename NCT> 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),

Expand Down Expand Up @@ -592,7 +591,7 @@ template <typename NCT> 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());

Expand Down Expand Up @@ -630,7 +629,7 @@ template <typename NCT> 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(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -42,7 +42,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
// variable-length data.
fr unencrypted_log_preimages_length = 0;

HistoricBlockData<NCT> historic_block_data{};
BlockHeader<NCT> block_header{};

address prover_address{};

Expand All @@ -58,7 +58,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
new_l2_to_l1_msgs,
unencrypted_logs_hash,
unencrypted_log_preimages_length,
historic_block_data,
block_header,
prover_address);

boolean operator==(PublicCircuitPublicInputs<NCT> const& other) const
Expand Down Expand Up @@ -91,7 +91,7 @@ template <typename NCT> 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),
};
Expand Down Expand Up @@ -121,7 +121,7 @@ template <typename NCT> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ template <typename NCT> struct BaseRollupInputs {
AppendOnlyTreeSnapshot<NCT> start_nullifier_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_contract_tree_snapshot{};
fr start_public_data_tree_root{};
AppendOnlyTreeSnapshot<NCT> start_historic_blocks_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_blocks_tree_snapshot{};

std::array<NullifierLeafPreimage<NCT>, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP> low_nullifier_leaf_preimages{};
std::array<MembershipWitness<NCT, NULLIFIER_TREE_HEIGHT>, MAX_NEW_NULLIFIERS_PER_BASE_ROLLUP>
Expand All @@ -37,8 +37,8 @@ template <typename NCT> struct BaseRollupInputs {
std::array<std::array<fr, PUBLIC_DATA_TREE_HEIGHT>, MAX_PUBLIC_DATA_READS_PER_BASE_ROLLUP>
new_public_data_reads_sibling_paths{};

std::array<MembershipWitness<NCT, HISTORIC_BLOCKS_TREE_HEIGHT>, KERNELS_PER_BASE_ROLLUP>
historic_blocks_tree_root_membership_witnesses{};
std::array<MembershipWitness<NCT, BLOCKS_TREE_HEIGHT>, KERNELS_PER_BASE_ROLLUP>
blocks_tree_root_membership_witnesses{};

ConstantRollupData<NCT> constants{};

Expand All @@ -48,15 +48,15 @@ template <typename NCT> 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,
new_nullifiers_subtree_sibling_path,
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<NCT> const& other) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template <typename NCT> struct ConstantRollupData {
using fr = typename NCT::fr;

// The very latest roots as at the very beginning of the entire rollup:
AppendOnlyTreeSnapshot<NCT> start_historic_blocks_tree_roots_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_blocks_tree_snapshot{};

// Some members of this struct tbd:
fr private_kernel_vk_tree_root = 0;
Expand All @@ -21,7 +21,7 @@ template <typename NCT> struct ConstantRollupData {

GlobalVariables<NCT> 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,
Expand Down
Loading

0 comments on commit 1db30bf

Please sign in to comment.