Skip to content

feat(platform): use count sum tree for addresses - #2897

Merged
QuantumExplorer merged 5 commits into
feat/platformAddressesfrom
feat/useCountSumTreeForAddresses
Dec 16, 2025
Merged

QuantumExplorer merged 5 commits into
feat/platformAddressesfrom
feat/useCountSumTreeForAddresses

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Dec 15, 2025 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The address balances tree (CLEAR_ADDRESS_POOL) was using a SumTree which doesn't track element counts. Switching to CountSumTree provides both sum aggregation and element counting, which
improves fee estimation accuracy and enables more efficient queries.

Additionally, the grove_insert_empty_sum_tree API was redundant since grove_insert_empty_tree can handle all tree types with an explicit TreeType parameter.

What was done?

Tree Type Changes

  • Changed CLEAR_ADDRESS_POOL from SumTree to CountSumTree in drive initialization (v2)
  • Updated fee estimation layer information to reflect CountSumTree type and weights

API Consolidation

  • Removed grove_insert_empty_sum_tree function
  • Updated grove_insert_empty_tree to accept explicit TreeType parameter (NormalTree, SumTree, CountSumTree, etc.)
  • Updated all call sites to pass the appropriate TreeType

Fee Regression Test Updates

  • Updated expected fee values in address_funds_transfer/tests.rs to reflect slightly higher costs with CountSumTree
  • Updated identity_credit_transfer_to_addresses/tests.rs fee estimation test (now succeeds with exact balance due to more accurate estimation)

Bug Fixes

  • Fixed incorrect error type in verify_identity_keys_by_identity_id: changed from grovedb::Error::WrongElementType to ProofError::IncorrectValueSize when revision bytes have wrong length

How Has This Been Tested?

  • cargo test -p drive-abci address_funds_transfer::tests::tests::fee_regression - All 9 fee regression tests pass
  • cargo test -p drive-abci test_exact_actual_fee_balance_succeeds_with_128_outputs - Fee estimation accuracy test passes
  • cargo check -p drive --features verify - Verification code compiles correctly

Breaking Changes

None compared with 2.1

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@coderabbitai

coderabbitai Bot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/useCountSumTreeForAddresses

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Dec 15, 2025 •

Copy link
Copy Markdown
Contributor

✅ gRPC Query Coverage Report

================================================================================
gRPC Query Coverage Report - NEW QUERIES ONLY
================================================================================

Total queries in proto: 49
Previously known queries: 47
New queries found: 2

================================================================================

New Query Implementation Status:
--------------------------------------------------------------------------------
✓ getAddressInfo                                /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getAddressesInfos                             /home/runner/work/platform/platform/packages/rs-sdk/src/platform/fetch_many.rs

================================================================================
Summary:
--------------------------------------------------------------------------------
New queries implemented: 2 (100.0%)
New queries missing: 0 (0.0%)

Total known queries: 49
  - Implemented: 46
  - Not implemented: 2
  - Excluded: 1

Not implemented queries:
  - getConsensusParams
  - getTokenPreProgrammedDistributions

@github-actions

github-actions Bot commented Dec 15, 2025 •

Copy link
Copy Markdown
Contributor

✅ DashSDKFFI.xcframework built for this PR.

SwiftPM (host the zip at a stable URL, then use):

.binaryTarget(
  name: "DashSDKFFI",
  url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
  checksum: "2bab052ab6af2114bef769de25e89d508a3a362b353215b2037e79504d107f87"
)

Xcode manual integration:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

@QuantumExplorer QuantumExplorer changed the title feat: use count sum tree for addresses feat(platform): use count sum tree for addresses Dec 16, 2025

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self Reviewed

@QuantumExplorer
QuantumExplorer merged commit c60914a into feat/platformAddresses Dec 16, 2025
@QuantumExplorer
QuantumExplorer deleted the feat/useCountSumTreeForAddresses branch December 16, 2025 13:13
@thephez thephez added this to the v3.0 milestone Dec 22, 2025
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.

3 participants