fix: batched address tree init assert tree and queue index are the same#2318
fix: batched address tree init assert tree and queue index are the same#2318ananas-block wants to merge 5 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughBatchedAddressTree path: compute the tree index into a local variable, assign both Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@programs/system/src/processor/create_address_cpi_data.rs`:
- Around line 86-94: Move the index-equality validation for batched address
trees to run immediately on entering the BatchedAddressTree match arm (i.e.,
before calling get_index_or_insert, set_address_fee, or
insert_address_sequence_number): check that
new_address_params.address_queue_index() ==
new_address_params.address_merkle_tree_account_index() and return an appropriate
error on mismatch. Replace or clarify the current
AddressMerkleTreeAccountDiscriminatorMismatch usage—either use a new error
variant like AddressQueueIndexMismatch or add a comment/documentation in the
error definition explaining the reuse—so the intent is clear when locating the
check in the BatchedAddressTree branch.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
program-libs/compressed-account/tests/zero_copy_set.rs (1)
39-39:⚠️ Potential issue | 🟡 MinorUpdate the header docstring to reflect the new invariant.
The docstring still states "Invariant: address queue account index always 0", but the actual invariant (as documented in the updated test at lines 583-584) is now
address_queue_account_index == address_merkle_tree_account_index. This mismatch will confuse future readers.📝 Proposed fix
-/// - Invariant: address queue account index always 0 +/// - Invariant: address queue account index equals address merkle tree account index (v2 batched trees)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@program-libs/compressed-account/tests/zero_copy_set.rs` at line 39, Update the header docstring in zero_copy_set.rs to replace the outdated invariant text "Invariant: address queue account index always 0" with the new invariant "Invariant: address_queue_account_index == address_merkle_tree_account_index" so the comment matches the actual test logic; locate the header comment near the top of the file and modify the string accordingly, ensuring the exact symbol names address_queue_account_index and address_merkle_tree_account_index are used in the docstring.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@program-libs/compressed-account/tests/zero_copy_set.rs`:
- Line 39: Update the header docstring in zero_copy_set.rs to replace the
outdated invariant text "Invariant: address queue account index always 0" with
the new invariant "Invariant: address_queue_account_index ==
address_merkle_tree_account_index" so the comment matches the actual test logic;
locate the header comment near the top of the file and modify the string
accordingly, ensuring the exact symbol names address_queue_account_index and
address_merkle_tree_account_index are used in the docstring.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rsis excluded by none and included by none
📒 Files selected for processing (1)
program-libs/compressed-account/tests/zero_copy_set.rs
Summary by CodeRabbit
Bug Fixes
Tests