Skip to content

feat(platform)!: state transition minimum required balance for fees - #2899

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

QuantumExplorer merged 5 commits into
feat/platformAddressesfrom
feat/estimatedFees

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Dec 15, 2025 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Refactors estimated fee validation logic from drive-abci to dpp, centralizing fee calculation and balance validation in the data layer. This improves code organization, reduces duplication, and
makes fee estimation logic reusable across different contexts.

What was done?

New Trait Hierarchy in dpp

Created a three-tier trait hierarchy for fee estimation and validation:

  1. StateTransitionEstimatedFeeValidation (base trait)
    - calculate_min_required_fee(&self, platform_version) -> Result<Credits, ProtocolError>
  2. StateTransitionAddressEstimatedFeeValidation (for address-based transitions)
    - Extends base trait with validate_estimated_fee() default implementation
    - calculate_amount_available() for fee strategy-based amount calculation
  3. StateTransitionIdentityEstimatedFeeValidation (for identity-based transitions)
    - Extends base trait with validate_estimated_fee() for identity balance checks

Implementations Added (15 total)

Address-based transitions (4):

  • AddressCreditWithdrawalTransition
  • AddressFundsTransferTransition
  • IdentityCreateFromAddressesTransition
  • IdentityTopUpFromAddressesTransition

Identity-based transitions (8):

  • IdentityCreditTransferTransition
  • IdentityCreditWithdrawalTransition
  • IdentityCreditTransferToAddressesTransition
  • BatchTransition
  • DataContractCreateTransition
  • DataContractUpdateTransition
  • IdentityUpdateTransition
  • MasternodeVoteTransition

Asset-lock-based transitions (3):

  • IdentityCreateTransition (with versioned fee calculation v0/v1)
  • IdentityTopUpTransition (with versioned fee calculation v0/v1)
  • AddressFundingFromAssetLockTransition

Fee Version Structure Changes

Renamed fee fields for clarity:

  • identity_create_from_addresses_base_cost → identity_create_base_cost
  • identity_topup_from_addresses → identity_topup_base_cost

drive-abci Simplification

Removed modules (~600 lines deleted):

  • common/validate_simple_pre_check_balance/
  • batch/balance/
  • identity_credit_transfer/balance/
  • identity_credit_transfer_to_addresses/balance/
  • identity_credit_withdrawal/balance/

Simplified:

  • addresses_minimum_balance.rs: 245 → ~80 lines (now delegates to dpp traits)
  • identity_balance.rs: Consolidated to use StateTransitionIdentityEstimatedFeeValidation
  • masternode_vote/balance/: Now uses calculate_min_required_fee() from dpp

Platform Versioning

  • Added STATE_TRANSITION_VERSIONS_V3 with new versioned fee calculation fields:
    • calculate_min_required_fee_on_identity_create_transition
    • calculate_min_required_fee_on_identity_top_up_transition

How Has This Been Tested?

Verify dpp builds
cargo check -p dpp

Verify drive-abci builds
cargo check -p drive-abci

Run existing tests
cargo test -p drive-abci --test strategy_tests

Breaking Changes

Yep, they are there. The fee amounts should work with versioning.

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/estimatedFees

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: "80465036e25dc75593eba861e15fc45cf885ee8502eeb0fae4242108b1f916d9"
)

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(platform): state transition minimum required balance for fees feat(platform)!: state transition minimum required balance for fees Dec 15, 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