feat: batch address trees#18
Merged
sergeytimoshin merged 33 commits intojorrit/feat-add-testfrom May 3, 2025
Merged
Conversation
b089102 to
db382f7
Compare
ed8b8f0 to
c24977f
Compare
Comment on lines
+123
to
+136
| for (new_address, seq) in event | ||
| .new_addresses | ||
| .iter() | ||
| .zip(event.address_sequence_numbers.iter()) | ||
| { | ||
| let tree_info = TreeInfo::get(&new_address.mt_pubkey.to_string()) | ||
| .ok_or(IngesterError::ParserError("Missing queue".to_string()))? | ||
| .clone(); | ||
| state_update_event.addresses.push(AddressQueueUpdate { | ||
| tree: tree_info.tree.into(), | ||
| address: new_address.address, | ||
| queue_index: seq.seq, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Suggested change
| for (new_address, seq) in event | |
| .new_addresses | |
| .iter() | |
| .zip(event.address_sequence_numbers.iter()) | |
| { | |
| let tree_info = TreeInfo::get(&new_address.mt_pubkey.to_string()) | |
| .ok_or(IngesterError::ParserError("Missing queue".to_string()))? | |
| .clone(); | |
| state_update_event.addresses.push(AddressQueueUpdate { | |
| tree: tree_info.tree.into(), | |
| address: new_address.address, | |
| queue_index: seq.seq, | |
| }); | |
| } | |
| for (new_address, seq) in event | |
| .new_addresses | |
| .iter() | |
| .zip(event.address_sequence_numbers.iter()) | |
| { | |
| state_update_event.addresses.push(AddressQueueUpdate { | |
| tree: new_address.mt_pubkey.into(), | |
| address: new_address.address, | |
| queue_index: seq.seq, | |
| }); | |
| } |
| } | ||
|
|
||
| pub const MAX_HEIGHT: usize = 32; | ||
| pub async fn get_subtrees( |
There was a problem hiding this comment.
shouldn't this be in persisted_indexed_merkle_tree ?
Author
There was a problem hiding this comment.
I think it makes sense to leave it here, because persisted_state_tree stores nodes for indexed trees, and persisted_indexed_merkle_tree works more like indexed array.
ananas-block
left a comment
There was a problem hiding this comment.
Thanks!
TLDR on comments:
- are we sure queue indices are set correctly if we insert 2 addresses in the same tree in the same tx?
- found some dead code in
parse_public_transaction_event - PublicTransactionEvent::V1 maybe we can get away with less diff by implementing From
- Final root assert in test
- couple smaller improvements
…id-arg feat: add support for custom account compression program ID
sergeytimoshin
commented
Apr 29, 2025
| @@ -79,18 +77,15 @@ solana-program = "1.18.0" | |||
| solana-sdk = "1.18.0" | |||
sergeytimoshin
commented
Apr 29, 2025
…d address is in the AddressQueue but not in tree yet, we should return error. For V1 trees we still return non-inclusion proof, because we don't have information about V1 queue. * Add offset as request parameter to get_batch_address_update_info. * Various cleanups
… node persistence
ananas-block
reviewed
May 2, 2025
| light-compressed-account = { git = "https://github.com/Lightprotocol/light-protocol", rev = "368f9f08272db78c74b2ade1a1c2fead27dd0a96" } | ||
| light-concurrent-merkle-tree = { git = "https://github.com/Lightprotocol/light-protocol", rev = "368f9f08272db78c74b2ade1a1c2fead27dd0a96" } | ||
| light-hasher = "2.0.0" | ||
| light-hasher = { git = "https://github.com/Lightprotocol/light-protocol", rev = "368f9f08272db78c74b2ade1a1c2fead27dd0a96" } |
There was a problem hiding this comment.
why was this necessary?
(I didn't want to release light-hasher again.)
Author
There was a problem hiding this comment.
light-merkle-tree-reference has light-hasher dependency as well => there are multiple different versions of crate light_hasher in the dependency graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pr adds support for batch address updates and introduces a new API endpoint
getBatchAddressUpdateInfoChanges:
API
getBatchAddressUpdateInfoendpoint.Retrieves addresses pending insertion from the new address queue, along with necessary proofs and context for batch updates.
Request:
Response:
DB
Added
address_queuestable, corresponding models & migrations.Table structure:
Events
Added PublicTransactionEventV2 structure and parsing logic which contains MerkleTreeSequenceNumberV2(
tree_pubkey, queue_pubkey, tree_type, seq).Tests
tests/integration_tests/batched_state_tree_tests.rs
Contains new
test_batched_address_transactionstest.Asserts:
getBatchAddressUpdateInforeturn non-empty queue after indexing of initial 50 txs and contain valid expected addresses.TODO: