-
Notifications
You must be signed in to change notification settings - Fork 47
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: forester batched ops #1357
base: jorrit/test-rebase-audit-branch
Are you sure you want to change the base?
feat: forester batched ops #1357
Conversation
@@ -35,6 +37,17 @@ fn process_state_account(account: &Account, pubkey: Pubkey) -> Result<TreeAccoun | |||
)) | |||
} | |||
|
|||
fn process_batch_state_account(account: &mut Account, pubkey: Pubkey) -> Result<TreeAccounts> { | |||
check_discriminator::<BatchedMerkleTreeAccount>(&account.data)?; | |||
let tree_account = ZeroCopyBatchedMerkleTreeAccount::from_bytes_mut(&mut account.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.
from_bytes_mut
checks the discriminator
forester/tests/batched_op_test.rs
Outdated
if i == merkle_tree.get_account().queue.batch_size / 2 { | ||
instruction_data = Some( | ||
create_append_batch_ix_data( | ||
&mut e2e_env.rpc, | ||
&mut e2e_env.indexer.state_merkle_trees[0], | ||
state_merkle_tree_pubkey, | ||
output_queue_pubkey, | ||
) | ||
.await, | ||
); | ||
} |
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.
best remove this it was just to test concurrency in the other test
.ok_or(AccountCompressionErrorCode::InclusionProofByIndexFailed)?; | ||
|
||
if element == value { | ||
*element = [0; 32]; |
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.
*element = [0; 32]; |
We need to remove this so that we can use the value from output_queue.value_vec[full_batch_index]
directly instead from the indexer.
2db5b62
to
c9952ce
Compare
forester/src/batched_ops.rs
Outdated
.indexer | ||
.lock() | ||
.await | ||
.get_proof_by_index(self.merkle_tree, i as usize); |
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 we add a batched call to the indexer for this?
forester/src/batched_ops.rs
Outdated
let mut merkle_proofs = Vec::new(); | ||
|
||
let batch = { | ||
let mut merkle_tree_account = rpc.get_account(self.merkle_tree).await.unwrap().unwrap(); |
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.
duplicate get_account
call its already fetched in line 331.
.indexer | ||
.lock() | ||
.await | ||
.get_leaf_indices_tx_hashes(self.merkle_tree, zkp_batch_size as usize); |
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.
wondering whether it would make sense to return get_proof_by_index(self.merkle_tree, *index as usize);
with this call as well so that we avoid the second call to the indexer.
@@ -271,7 +267,6 @@ impl ZeroCopyBatchedQueueAccount { | |||
.ok_or(AccountCompressionErrorCode::InclusionProofByIndexFailed)?; | |||
|
|||
if element == value { | |||
*element = [0; 32]; |
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.
unfortunately we need to revert this because it leads to some issues onchain.
This means that we can't get the leaves for the batch append circuit inputs from the batch Merkle tree account value array because some values have been zeroed out.
Instead we need to get the data from the indexer. I think it makes sense to add a get_queue_elements
method to the Indexer
trait like I have for the batch address tree see here.
fa35b58
to
e1e2ed9
Compare
e1e2ed9
to
0f8eae2
Compare
No description provided.