-
Notifications
You must be signed in to change notification settings - Fork 48
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
chore: cleanup & fix zero out bloom filter #1487
Conversation
2eeee1d
to
259288c
Compare
259288c
to
6c60c3a
Compare
d71ba2b
to
31f6675
Compare
pub next_full_batch_index: u64, | ||
pub bloom_filter_capacity: u64, | ||
} | ||
|
||
impl BatchMetadata { |
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.
impl BatchMetadata { | |
impl BatchMetadata { | |
/// Returns the number of ZKP batches contained within a single regular batch. | |
pub fn get_num_zkp_batches(&self) -> u64 { | |
self.batch_size / self.zkp_batch_size | |
} | |
/// Validates that the batch size is properly divisible by the ZKP batch size. | |
fn validate_batch_sizes(batch_size: u64, zkp_batch_size: u64) -> Result<(), BatchedMerkleTreeError> { | |
if batch_size % zkp_batch_size != 0 { | |
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | |
} | |
Ok(()) | |
} | |
if batch_size % zkp_batch_size != 0 { | ||
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | ||
} | ||
Ok(BatchMetadata { |
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.
if batch_size % zkp_batch_size != 0 { | |
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | |
} | |
Ok(BatchMetadata { | |
Self::validate_batch_sizes(batch_size, zkp_batch_size)?; | |
Ok(BatchMetadata { |
if batch_size % zkp_batch_size != 0 { | ||
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | ||
} | ||
Ok(BatchMetadata { |
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.
if batch_size % zkp_batch_size != 0 { | |
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | |
} | |
Ok(BatchMetadata { | |
Self::validate_batch_sizes(batch_size, zkp_batch_size)?; | |
Ok(BatchMetadata { |
self.next_full_batch_index += 1; | ||
self.next_full_batch_index %= self.num_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.
self.next_full_batch_index += 1; | |
self.next_full_batch_index %= self.num_batches; | |
self.next_full_batch_index = (self.next_full_batch_index + 1) % self.num_batches; | |
self.currently_processing_batch_index += 1; | ||
self.currently_processing_batch_index %= self.num_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.
self.currently_processing_batch_index += 1; | |
self.currently_processing_batch_index %= self.num_batches; | |
self.currently_processing_batch_index = (self.currently_processing_batch_index + 1) % self.num_batches; | |
self.num_batches = num_batches; | ||
self.batch_size = batch_size; | ||
// Check that batch size is divisible by zkp_batch_size. | ||
if batch_size % zkp_batch_size != 0 { | ||
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | ||
} |
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.
self.num_batches = num_batches; | |
self.batch_size = batch_size; | |
// Check that batch size is divisible by zkp_batch_size. | |
if batch_size % zkp_batch_size != 0 { | |
return Err(BatchedMerkleTreeError::BatchSizeNotDivisibleByZkpBatchSize); | |
} | |
Self::validate_batch_sizes(batch_size, zkp_batch_size)?; | |
self.num_batches = num_batches; | |
self.batch_size = batch_size; |
Ok((num_value_stores, num_stores, num_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.
#[test] | |
fn test_batch_size_validation() { | |
// Test invalid batch size | |
assert!(BatchMetadata::new_input_queue(10, 10, 3, 2).is_err()); | |
assert!(BatchMetadata::new_output_queue(10, 3, 2).is_err()); | |
// Test valid batch size | |
assert!(BatchMetadata::new_input_queue(9, 10, 3, 2).is_ok()); | |
assert!(BatchMetadata::new_output_queue(9, 3, 2).is_ok()); | |
} |
Changes:
BatchState::CanBeFilled
->BatchState::Fill
*_wiped
->*_zeroed
-> needed to adapt expected len assertion in batched forester tests