-
Notifications
You must be signed in to change notification settings - Fork 267
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
Conversation
✅ Deploy Preview for preeminent-bienenstitch-606ad0 canceled.
|
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.
Not sure if we really need to add the block hash in the public inputs.
@@ -22,6 +22,8 @@ template <typename NCT> struct RootRollupPublicInputs { | |||
|
|||
GlobalVariables<NCT> globalVariables; | |||
|
|||
fr block_hash; |
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.
Do we actually need the block_hash
as part of the inputs? Using the global variables and the other values you can compute it. What value does it bring to include it directly here?
@@ -378,6 +381,20 @@ 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); | |||
info("problematic sibling path"); |
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.
Should some of these infos be removed?
.next_available_leaf_index = 0, | ||
}; | ||
|
||
info("snapshot"); |
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.
More infos down here.
/** | ||
* The hash of the block being included into the historic block hashes tree. | ||
*/ | ||
public blockHash: Fr, |
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.
As earlier. Not sure you actually need this.
@@ -249,7 +248,7 @@ export class SoloBlockBuilder implements BlockBuilder { | |||
|
|||
// Run the root rollup with the last two merge rollups (or base, if no merge layers) | |||
const [mergeOutputLeft, mergeOutputRight] = mergeRollupInputs; | |||
return this.rootRollupCircuit(mergeOutputLeft, mergeOutputRight, newL1ToL2Messages); | |||
return this.rootRollupCircuit(mergeOutputLeft, mergeOutputRight, newL1ToL2Messages, globalVariables); |
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.
The globalVariables
should already be in both mergeOutputLeft
and mergeOutputRight
, you could just read it from there?
e9f0626
to
dc20631
Compare
dc20631
to
011a150
Compare
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.
A few comments on indexing of historic trees
// 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
fixing in follow up
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
fixing in followup
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
fixing in follow up
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.
other than lasse's comments lgtm
@@ -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{}; |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
why do we not have to add start_historic_blocks_tree_snapshot
and end_historic_blocks_tree_snapshot
into the root rollup PublicInputs?
Edit: just realised it was always there in that file lol
baseRollupOutputLeft = makeBaseOrMergeRollupPublicInputs(); | ||
baseRollupOutputRight = makeBaseOrMergeRollupPublicInputs(); | ||
rootRollupOutput = makeRootRollupPublicInputs(); | ||
baseRollupOutputLeft = makeBaseOrMergeRollupPublicInputs(0, blockNumber, globalVariables); |
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.
doesn't globalVariables
have blockNumber
already?
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.
good point it does, i can refactor this to remove the arg
Description
resolves #1162
Please provide a paragraph or two giving a summary of the change, including relevant motivation and context.
Checklist: