-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow blocks with empty batches #1172
Conversation
00eced8
to
a951095
Compare
@@ -130,13 +130,9 @@ impl ProposedBlock { | |||
batches: Vec<ProvenBatch>, | |||
timestamp: u32, | |||
) -> Result<Self, ProposedBlockError> { | |||
// Check for empty or duplicate batches. | |||
// Check for duplicate and max number of batches. |
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.
Non-PR question, but why does the protocol care about defining maximum counts? Feels like something that should be configurable - and while the node can enforce its own limits, this still sets the upper cap.
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.
Yeah, good question. Some kind of ProtocolConfig would be better I guess. I guess right now it makes it easier to verify consistency, for example: The max number of inputs per batch and the max number of batches per block (1024 * 64 = 2^16) guarantees we can use a BlockNoteTree
of depth 16 to represent all notes created in a block.
But we could verify such invariants in a ProtocolConfig::new
constructor, and then miden-base could assume it is consistent.
// -------------------------------------------------------------------------------------------- | ||
|
||
for tx in transactions.iter() { | ||
if block_header.block_num() != tx.block_num() | ||
if reference_block_header.block_num() != tx.block_num() |
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.
Might not be better :)
transactions
.iter()
.filter(|tx| tx.block_num != reference_block_header.block_num())
.find_map(|tx| chain_mmr.contains_block(tx.block_num()).not().then_some(tx))
.map_or(|tx| Err(ProposedBatcError:: ...)?;
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.
Looks good! Thank you!
I pushed one more change related to this comment: 0xPolygonMiden/miden-node#709 (comment), which is to make |
Allow blocks with empty batches so we can build new blocks in the node even if no transactions or batches are available.
Also clarifies comments in the proposed batch.
Consistently name
created_nullifiers
method acrossProposedBatch
,ProposedBlock
andProvenBlock
.