Skip to content

Commit

Permalink
refactor: Renaming blockstree to archive (#3569)
Browse files Browse the repository at this point in the history
Fixes #3572 from #3533.
  • Loading branch information
LHerskind authored Dec 5, 2023
1 parent ff893b2 commit 6c200e9
Show file tree
Hide file tree
Showing 74 changed files with 358 additions and 362 deletions.
19 changes: 9 additions & 10 deletions circuits/cpp/src/aztec3/circuits/abis/block_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ template <typename NCT> struct BlockHeader {
fr nullifier_tree_root = 0;
fr contract_tree_root = 0;
fr l1_to_l2_messages_tree_root = 0;
fr blocks_tree_root = 0;
fr archive_root = 0;
fr private_kernel_vk_tree_root = 0; // TODO: future enhancement

// Public data
Expand All @@ -38,7 +38,7 @@ template <typename NCT> struct BlockHeader {
nullifier_tree_root,
contract_tree_root,
l1_to_l2_messages_tree_root,
blocks_tree_root,
archive_root,
private_kernel_vk_tree_root,
public_data_tree_root,
global_variables_hash);
Expand All @@ -47,8 +47,7 @@ template <typename NCT> struct BlockHeader {
{
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.blocks_tree_root &&
l1_to_l2_messages_tree_root == other.l1_to_l2_messages_tree_root && archive_root == other.archive_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 @@ -62,7 +61,7 @@ template <typename NCT> struct BlockHeader {
nullifier_tree_root.assert_is_zero();
contract_tree_root.assert_is_zero();
l1_to_l2_messages_tree_root.assert_is_zero();
blocks_tree_root.assert_is_zero();
archive_root.assert_is_zero();
private_kernel_vk_tree_root.assert_is_zero();
public_data_tree_root.assert_is_zero();
global_variables_hash.assert_is_zero();
Expand All @@ -77,7 +76,7 @@ template <typename NCT> struct BlockHeader {

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(l1_to_l2_messages_tree_root), to_ct(archive_root), to_ct(private_kernel_vk_tree_root),
to_ct(public_data_tree_root), to_ct(global_variables_hash),
};

Expand All @@ -91,7 +90,7 @@ template <typename NCT> struct BlockHeader {

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(l1_to_l2_messages_tree_root), to_nt(archive_root), to_nt(private_kernel_vk_tree_root),
to_nt(public_data_tree_root), to_nt(global_variables_hash),
};

Expand All @@ -106,7 +105,7 @@ template <typename NCT> struct BlockHeader {
nullifier_tree_root.set_public();
contract_tree_root.set_public();
l1_to_l2_messages_tree_root.set_public();
blocks_tree_root.set_public();
archive_root.set_public();
private_kernel_vk_tree_root.set_public();
public_data_tree_root.set_public();
global_variables_hash.set_public();
Expand All @@ -118,8 +117,8 @@ template <typename NCT> struct BlockHeader {
nullifier_tree_root,
contract_tree_root,
l1_to_l2_messages_tree_root,
blocks_tree_root, // TODO(#3441) Note private_kernel_vk_tree_root, is not included yet as
// it is not present in noir,
archive_root, // TODO(#3441) Note private_kernel_vk_tree_root, is not included yet as
// it is not present in noir,
public_data_tree_root,
global_variables_hash };
}
Expand Down
2 changes: 1 addition & 1 deletion 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,
BLOCKS_TREE_HEIGHT,
ARCHIVE_HEIGHT,
NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH,
L1_TO_L2_MSG_SUBTREE_HEIGHT),
NVP(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_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_blocks_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_archive_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,7 @@ 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, BLOCKS_TREE_HEIGHT>, KERNELS_PER_BASE_ROLLUP>
blocks_tree_root_membership_witnesses{};
std::array<MembershipWitness<NCT, ARCHIVE_HEIGHT>, KERNELS_PER_BASE_ROLLUP> archive_root_membership_witnesses{};

ConstantRollupData<NCT> constants{};

Expand All @@ -48,15 +47,15 @@ template <typename NCT> struct BaseRollupInputs {
start_nullifier_tree_snapshot,
start_contract_tree_snapshot,
start_public_data_tree_root,
start_blocks_tree_snapshot,
start_archive_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,
blocks_tree_root_membership_witnesses,
archive_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_blocks_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_archive_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_blocks_tree_snapshot,
MSGPACK_FIELDS(start_archive_snapshot,
private_kernel_vk_tree_root,
public_kernel_vk_tree_root,
base_rollup_vk_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ template <typename NCT> struct RootRollupInputs {
AppendOnlyTreeSnapshot<NCT> start_l1_to_l2_messages_tree_snapshot{};

// inputs required to add the block hash
AppendOnlyTreeSnapshot<NCT> start_blocks_tree_snapshot{};
std::array<fr, BLOCKS_TREE_HEIGHT> new_blocks_tree_sibling_path{};
AppendOnlyTreeSnapshot<NCT> start_archive_snapshot{};
std::array<fr, ARCHIVE_HEIGHT> new_archive_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_blocks_tree_snapshot,
new_blocks_tree_sibling_path);
start_archive_snapshot,
new_archive_sibling_path);
bool operator==(RootRollupInputs<NCT> const&) const = default;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ template <typename NCT> struct RootRollupPublicInputs {
AppendOnlyTreeSnapshot<NCT> start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot{};
AppendOnlyTreeSnapshot<NCT> end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot{};

AppendOnlyTreeSnapshot<NCT> start_blocks_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> end_blocks_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_archive_snapshot{};
AppendOnlyTreeSnapshot<NCT> end_archive_snapshot{};

std::array<fr, NUM_FIELDS_PER_SHA256> calldata_hash{};
std::array<fr, NUM_FIELDS_PER_SHA256> l1_to_l2_messages_hash{};
Expand All @@ -68,8 +68,8 @@ template <typename NCT> struct RootRollupPublicInputs {
end_l1_to_l2_messages_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,
start_archive_snapshot,
end_archive_snapshot,
calldata_hash,
l1_to_l2_messages_hash);

Expand All @@ -88,7 +88,7 @@ template <typename NCT> struct RootRollupPublicInputs {
write(buf, start_public_data_tree_root);
write(buf, start_l1_to_l2_messages_tree_snapshot);
write(buf, start_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot);
write(buf, start_blocks_tree_snapshot);
write(buf, start_archive_snapshot);
write(buf, end_note_hash_tree_snapshot);
write(buf, end_nullifier_tree_snapshot);
write(buf, end_contract_tree_snapshot);
Expand All @@ -97,7 +97,7 @@ template <typename NCT> struct RootRollupPublicInputs {
write(buf, end_public_data_tree_root);
write(buf, end_l1_to_l2_messages_tree_snapshot);
write(buf, end_tree_of_historical_l1_to_l2_messages_tree_roots_snapshot);
write(buf, end_blocks_tree_snapshot);
write(buf, end_archive_snapshot);

// Stitching calldata hash together
auto high_buffer = calldata_hash[0].to_buffer();
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ PublicKernelInputs<NT> get_kernel_inputs_with_previous_kernel(NT::boolean privat
.nullifier_tree_root = ++seed,
.contract_tree_root = ++seed,
.l1_to_l2_messages_tree_root = ++seed,
.blocks_tree_root = ++seed,
.archive_root = ++seed,
.private_kernel_vk_tree_root = ++seed,
.public_data_tree_root = ++seed,
.global_variables_hash = ++seed,
Expand Down
12 changes: 6 additions & 6 deletions circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ TEST_F(base_rollup_tests, native_calldata_hash)
// run_cbind(inputs, outputs);
}

TEST_F(base_rollup_tests, native_compute_membership_blocks_tree_negative)
TEST_F(base_rollup_tests, native_compute_membership_archive_negative)
{
// WRITE a negative test that will fail the inclusion proof

Expand All @@ -639,15 +639,15 @@ TEST_F(base_rollup_tests, native_compute_membership_blocks_tree_negative)
BaseRollupInputs inputs = base_rollup_inputs_from_kernels(kernel_data);

MemoryStore blocks_store;
auto blocks_tree = MerkleTree(blocks_store, BLOCKS_TREE_HEIGHT);
auto archive = MerkleTree(blocks_store, ARCHIVE_HEIGHT);

// 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<NT::fr, BLOCKS_TREE_HEIGHT> sibling_path{};
for (size_t i = 0; i < BLOCKS_TREE_HEIGHT; ++i) {
auto hash_path = archive.get_sibling_path(0);
std::array<NT::fr, ARCHIVE_HEIGHT> sibling_path{};
for (size_t i = 0; i < ARCHIVE_HEIGHT; ++i) {
sibling_path[i] = hash_path[i] + 1;
}
inputs.blocks_tree_root_membership_witnesses[0] = {
inputs.archive_root_membership_witnesses[0] = {
.leaf_index = 0,
.sibling_path = sibling_path,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ NT::fr calculate_commitments_subtree(DummyBuilder& builder, BaseRollupInputs con
* @param constantBaseRollupData
* @param baseRollupInputs
*/
void perform_blocks_tree_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs)
void perform_archive_membership_checks(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs)
{
// 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 historical_root = baseRollupInputs.constants.start_blocks_tree_snapshot.root;
auto historical_root = baseRollupInputs.constants.start_archive_snapshot.root;

for (size_t i = 0; i < 2; i++) {
// Rebuild the block hash
Expand All @@ -155,8 +155,8 @@ void perform_blocks_tree_membership_checks(DummyBuilder& builder, BaseRollupInpu
l1_to_l2_messages_tree_root,
public_data_tree_root);

abis::MembershipWitness<NT, BLOCKS_TREE_HEIGHT> const historical_root_witness =
baseRollupInputs.blocks_tree_root_membership_witnesses[i];
abis::MembershipWitness<NT, ARCHIVE_HEIGHT> const historical_root_witness =
baseRollupInputs.archive_root_membership_witnesses[i];

check_membership<NT>(builder,
previous_block_hash,
Expand Down Expand Up @@ -524,7 +524,7 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRol
components::compute_kernels_calldata_hash(baseRollupInputs.kernel_data);

// Perform membership checks that the notes provided exist within the historical trees data
perform_blocks_tree_membership_checks(builder, baseRollupInputs);
perform_archive_membership_checks(builder, baseRollupInputs);

AggregationObject const aggregation_object = aggregate_proofs(baseRollupInputs);

Expand Down
18 changes: 8 additions & 10 deletions circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic)
// Create initial nullifier tree with 32 initial nullifiers
auto nullifier_tree = get_initial_nullifier_tree_empty();

MemoryStore blocks_tree_store;
MerkleTree blocks_tree(blocks_tree_store, BLOCKS_TREE_HEIGHT);
MemoryStore archive_store;
MerkleTree archive(archive_store, ARCHIVE_HEIGHT);

std::array<KernelData, 4> kernels = {
get_empty_kernel(), get_empty_kernel(), get_empty_kernel(), get_empty_kernel()
Expand All @@ -192,9 +192,8 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic)
contract_tree.root(),
l1_to_l2_messages_tree.root(),
public_data_tree.root());
blocks_tree.update_element(0, start_block_hash);
AppendOnlyTreeSnapshot<NT> start_blocks_tree_snapshot = { .root = blocks_tree.root(),
.next_available_leaf_index = 1 };
archive.update_element(0, start_block_hash);
AppendOnlyTreeSnapshot<NT> start_archive_snapshot = { .root = archive.root(), .next_available_leaf_index = 1 };

// Create commitments
for (size_t kernel_j = 0; kernel_j < 4; kernel_j++) {
Expand Down Expand Up @@ -243,9 +242,8 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic)
contract_tree.root(),
l1_to_l2_messages_tree.root(),
public_data_tree.root());
blocks_tree.update_element(1, end_block_hash);
AppendOnlyTreeSnapshot<NT> end_blocks_tree_snapshot = { .root = blocks_tree.root(),
.next_available_leaf_index = 2 };
archive.update_element(1, end_block_hash);
AppendOnlyTreeSnapshot<NT> end_archive_snapshot = { .root = archive.root(), .next_available_leaf_index = 2 };

// Compute the end snapshot
AppendOnlyTreeSnapshot<NT> const end_l1_to_l2_messages_tree_snapshot = { .root = l1_to_l2_messages_tree.root(),
Expand Down Expand Up @@ -292,8 +290,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_blocks_tree_snapshot, start_blocks_tree_snapshot);
ASSERT_EQ(outputs.end_blocks_tree_snapshot, end_blocks_tree_snapshot);
ASSERT_EQ(outputs.start_archive_snapshot, start_archive_snapshot);
ASSERT_EQ(outputs.end_archive_snapshot, end_archive_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] });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu
right.end_public_data_tree_root);

// Update the blocks tree
auto end_blocks_tree_snapshot = components::insert_subtree_to_snapshot_tree(
auto end_archive_snapshot = components::insert_subtree_to_snapshot_tree(
builder,
rootRollupInputs.start_blocks_tree_snapshot,
rootRollupInputs.new_blocks_tree_sibling_path,
rootRollupInputs.start_archive_snapshot,
rootRollupInputs.new_archive_sibling_path,
fr::zero(),
block_hash,
0,
Expand All @@ -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_blocks_tree_snapshot = rootRollupInputs.start_blocks_tree_snapshot,
.end_blocks_tree_snapshot = end_blocks_tree_snapshot,
.start_archive_snapshot = rootRollupInputs.start_archive_snapshot,
.end_archive_snapshot = end_archive_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)
};
Expand Down
Loading

0 comments on commit 6c200e9

Please sign in to comment.