-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(blocks_tree): compute block hashes within root rollup circuit #1214
Changes from 18 commits
8553fa0
4580093
1991a57
e0808b8
98692dd
2942f95
e8f9fbc
376e71a
9403830
7520217
3c9422c
de68edd
520b9a6
55fbd5f
f1d9fc7
3ae5a4d
011a150
830721f
035c41f
5340a79
d9bda7b
455058a
515bb60
613e8be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,22 @@ template <typename NCT> struct RootRollupInputs { | |
using fr = typename NCT::fr; | ||
|
||
// All below are shared between the base and merge rollups | ||
std::array<PreviousRollupData<NCT>, 2> previous_rollup_data; | ||
std::array<PreviousRollupData<NCT>, 2> previous_rollup_data{}; | ||
|
||
std::array<fr, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT> new_historic_private_data_tree_root_sibling_path; | ||
std::array<fr, CONTRACT_TREE_ROOTS_TREE_HEIGHT> new_historic_contract_tree_root_sibling_path; | ||
std::array<fr, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT> new_historic_private_data_tree_root_sibling_path{}; | ||
std::array<fr, CONTRACT_TREE_ROOTS_TREE_HEIGHT> new_historic_contract_tree_root_sibling_path{}; | ||
|
||
// inputs required to process l1 to l2 messages | ||
std::array<fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP> l1_to_l2_messages; | ||
std::array<fr, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH> new_l1_to_l2_message_tree_root_sibling_path; | ||
std::array<fr, L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT> new_historic_l1_to_l2_message_roots_tree_sibling_path; | ||
std::array<fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP> l1_to_l2_messages{}; | ||
std::array<fr, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH> new_l1_to_l2_message_tree_root_sibling_path{}; | ||
std::array<fr, L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT> new_historic_l1_to_l2_message_roots_tree_sibling_path{}; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_l1_to_l2_message_tree_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> start_historic_tree_l1_to_l2_message_tree_roots_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> start_l1_to_l2_message_tree_snapshot{}; | ||
AppendOnlyTreeSnapshot<NCT> start_historic_tree_l1_to_l2_message_tree_roots_snapshot{}; | ||
|
||
// inputs required to add the block hash | ||
AppendOnlyTreeSnapshot<NCT> start_historic_blocks_tree_snapshot{}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we not have to add Edit: just realised it was always there in that file lol |
||
std::array<fr, HISTORIC_BLOCKS_TREE_HEIGHT> new_historic_blocks_tree_sibling_path{}; | ||
|
||
bool operator==(RootRollupInputs<NCT> const&) const = default; | ||
}; | ||
|
@@ -44,6 +48,8 @@ template <typename NCT> void read(uint8_t const*& it, RootRollupInputs<NCT>& obj | |
read(it, obj.new_historic_l1_to_l2_message_roots_tree_sibling_path); | ||
read(it, obj.start_l1_to_l2_message_tree_snapshot); | ||
read(it, obj.start_historic_tree_l1_to_l2_message_tree_roots_snapshot); | ||
read(it, obj.start_historic_blocks_tree_snapshot); | ||
read(it, obj.new_historic_blocks_tree_sibling_path); | ||
}; | ||
|
||
template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupInputs<NCT> const& obj) | ||
|
@@ -58,6 +64,8 @@ template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupInputs<N | |
write(buf, obj.new_historic_l1_to_l2_message_roots_tree_sibling_path); | ||
write(buf, obj.start_l1_to_l2_message_tree_snapshot); | ||
write(buf, obj.start_historic_tree_l1_to_l2_message_tree_roots_snapshot); | ||
write(buf, obj.start_historic_blocks_tree_snapshot); | ||
write(buf, obj.new_historic_blocks_tree_sibling_path); | ||
}; | ||
|
||
template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupInputs<NCT> const& obj) | ||
|
@@ -73,7 +81,9 @@ template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupInp | |
<< obj.new_historic_l1_to_l2_message_roots_tree_sibling_path << "\n" | ||
<< "start_l1_to_l2_message_tree_snapshot: " << obj.start_l1_to_l2_message_tree_snapshot << "\n" | ||
<< "start_historic_tree_l1_to_l2_message_tree_roots_snapshot: " | ||
<< obj.start_historic_tree_l1_to_l2_message_tree_roots_snapshot << "\n"; | ||
<< obj.start_historic_tree_l1_to_l2_message_tree_roots_snapshot << "\n" | ||
<< "start_historic_blocks_tree_snapshot: " << obj.start_historic_blocks_tree_snapshot << "\n" | ||
<< "new_historic_blocks_tree_sibling_path: " << obj.new_historic_blocks_tree_sibling_path << "\n"; | ||
} | ||
|
||
} // namespace aztec3::circuits::abis |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,7 +341,6 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, | |
MemoryStore historic_l1_to_l2_msg_tree_store; | ||
MerkleTree historic_l1_to_l2_msg_tree(historic_l1_to_l2_msg_tree_store, L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT); | ||
|
||
|
||
MemoryStore private_data_store; | ||
const MerkleTree private_data_tree(private_data_store, PRIVATE_DATA_TREE_HEIGHT); | ||
|
||
|
@@ -351,6 +350,9 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, | |
MemoryStore l1_to_l2_msg_tree_store; | ||
MerkleTree l1_to_l2_msg_tree(l1_to_l2_msg_tree_store, L1_TO_L2_MSG_TREE_HEIGHT); | ||
|
||
MemoryStore historic_blocks_tree_store; | ||
MerkleTree historic_blocks_tree(historic_blocks_tree_store, HISTORIC_BLOCKS_TREE_HEIGHT); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be initialised with empty root for position 0 like we were doing with the others. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixing in follow up |
||
|
||
// Historic trees are initialised with an empty root at position 0. | ||
historic_private_data_tree.update_element(0, private_data_tree.root()); | ||
|
@@ -364,6 +366,7 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, | |
get_sibling_path<CONTRACT_TREE_ROOTS_TREE_HEIGHT>(historic_contract_tree, 1, 0); | ||
auto historic_l1_to_l2_msg_sibling_path = | ||
get_sibling_path<L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT>(historic_l1_to_l2_msg_tree, 1, 0); | ||
|
||
// l1 to l2 tree | ||
auto l1_to_l2_tree_sibling_path = | ||
get_sibling_path<L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>(l1_to_l2_msg_tree, 0, L1_TO_L2_MSG_SUBTREE_HEIGHT); | ||
|
@@ -378,6 +381,15 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, | |
.next_available_leaf_index = 1, | ||
}; | ||
|
||
// Blocks tree | ||
auto blocks_tree_sibling_path = get_sibling_path<HISTORIC_BLOCKS_TREE_HEIGHT>(historic_blocks_tree, 0, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming wise would add the historic to the name here for clarity. Should probably also be for index 1? As our historic starts there instead of at 0 where the initial was inserted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixing in followup |
||
|
||
// Blocks tree snapshots | ||
AppendOnlyTreeSnapshot const start_historic_blocks_tree_snapshot = { | ||
.root = historic_blocks_tree.root(), | ||
.next_available_leaf_index = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The next available should probably be one here similarly to how the other historic trees are handled now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixing in follow up |
||
}; | ||
|
||
RootRollupInputs rootRollupInputs = { | ||
.previous_rollup_data = get_previous_rollup_data(builder, std::move(kernel_data)), | ||
.new_historic_private_data_tree_root_sibling_path = historic_data_sibling_path, | ||
|
@@ -388,6 +400,8 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, | |
.start_l1_to_l2_message_tree_snapshot = start_l1_to_l2_msg_tree_snapshot, | ||
.start_historic_tree_l1_to_l2_message_tree_roots_snapshot = | ||
start_historic_tree_l1_to_l2_message_tree_roots_snapshot, | ||
.start_historic_blocks_tree_snapshot = start_historic_blocks_tree_snapshot, | ||
.new_historic_blocks_tree_sibling_path = blocks_tree_sibling_path, | ||
}; | ||
return rootRollupInputs; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ export { | |
CircuitError, | ||
Point, | ||
Coordinate, | ||
GlobalVariables, | ||
} from '../structs/index.js'; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.