Skip to content
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

refactor: forester: batch ops #1453

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

sergeytimoshin
Copy link
Contributor

No description provided.

@sergeytimoshin sergeytimoshin changed the title forester batch ops refactored refactor: forester: batch ops Jan 5, 2025
@sergeytimoshin sergeytimoshin marked this pull request as ready for review January 5, 2025 20:11
Comment on lines 47 to 52
TreeType::BatchedState => {
info!("Processing state batch");
state::process_batch(&self.context).await
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to distinguish between an input(nullifier) queue batch being ready and an output queue batch being ready. The current implementation assumes that both are always ready at the same time which will fail in many cases.

}
}

async fn verify_batch_ready(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't cover the output queue whichs batches are independent of input queue batches.

The input queue is part of the Merkle tree account since we usually need access to Merkle tree roots to prove inclusion (except if the account hash wasn't inserted into the tree yet then we need the output queue to proof inclusion by index in the value array).

The output queue is a separate account with separate batches. You can check whether an output queue batch is ready with the same logic used for trees the data structure is similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address Merkle tree doesn't have an output queue hence the current implementation conceptually works for address trees as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

@sergeytimoshin sergeytimoshin force-pushed the sergey/foresters-batch-ops branch from a3c5f20 to 61346cb Compare January 6, 2025 15:58
forester/package.json Outdated Show resolved Hide resolved
Comment on lines 107 to 111
if self.verify_input_queue_batch_ready(&mut rpc).await {
BatchReadyState::ReadyForNullify
} else if self.verify_output_queue_batch_ready(&mut rpc).await {
BatchReadyState::ReadyForAppend
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two thoughts:

  1. what about switching this checking verify_output_queue_batch_ready with priority since I expect more output state creation than input state creation?
  2. There could be a case where the forester isn't fast enough and one queue is filled so fast that the forester neglects the other queue. Probably not the right time to focus on this right now but makes sense to keep this in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants