Skip to content

AddressFundsTransferTransition::calculate_min_required_fee is too low #3040

Open

Description

@lklimek

AddressFundsTransferTransition::calculate_min_required_fee is lower than the one that is actually expected by Drive.

Similar issue also exists for other state transitions, like IdentityTopUpFromAddressesTransition.

Expected Behavior

  1. Create an AddressFundsTransferTransition with 3 inputs and 1 output.
  2. Calculate fee using AddressFundsTransferTransition::calculate_min_required_fee() ensure that fee is available for payment.
  3. Send state transition to DAPI.
  4. State transition is executed.

Current Behavior

calculate_min_required_fee returns 0.00007500 DASH; the state transition is rejected with error:

Failed to transfer Platform credits: Protocol error: Insufficient combined address balances: total available is less than required 27122100

Drive logs

2026-02-02T16:15:42.006310Z TRACE tokio-runtime-worker ThreadId(120) drive_abci::execution::validation::state_transition::processor::traits::address_balances_and_nonces: Validating input address balances and nonces for state transition inputs={P2pkh([121, 18, 146, 107, 95, 198, 174, 237, 166, 39, 140, 185, 89, 132, 65, 21, 101, 200, 26, 206]): (5, 39985738700), P2pkh([176, 192, 12, 8, 140, 32, 167, 200, 129, 107, 155, 112, 53, 134, 190, 167, 128, 135, 186, 138]): (5, 29993262200), P2pkh([205, 108, 183, 206, 205, 136, 189, 238, 114, 94, 230, 34, 164, 28, 16, 118, 183, 219, 201, 18]): (5, 20293831300)}
2026-02-02T16:15:42.007230Z TRACE tokio-runtime-worker ThreadId(120) drive_abci::abci::handler::check_tx: AddressFundsTransfer state transition (e073919332609e01aea0474a8eaa04b2e7f46494c110cf67ceb065fe65a8c17d) rejected with code 40602 due to error: Insufficient combined address balances: total available is less than required 27122100 check_tx_result=CheckTxResult { level: FirstTimeCheck, fee_result: Some(FeeResult { storage_fee: 23814000, processing_fee: 3308100, fee_refunds: FeeRefunds({}), removed_bytes_from_system: 0 }), unique_identifiers: ["sHkSkmtfxq7tpieMuVmEQRVlyBrOAAAABQ==", "sLDADAiMIKfIgWubcDWGvqeAh7qKAAAABQ==", "sM1st87NiL3ucl7mIqQcEHa328kSAAAABQ=="], priority: 0, state_transition_name: Some("AddressFundsTransfer"), state_transition_hash: Some([224, 115, 145, 147, 50, 96, 158, 1, 174, 160, 71, 74, 142, 170, 4, 178, 231, 244, 100, 148, 193, 16, 207, 103, 206, 176, 101, 254, 101, 168, 193, 125]) } error=Some(StateError(AddressesNotEnoughFundsError(AddressesNotEnoughFundsError { addresses_with_info: {P2pkh([121, 18, 146, 107, 95, 198, 174, 237, 166, 39, 140, 185, 89, 132, 65, 21, 101, 200, 26, 206]): (5, 7500000), P2pkh([176, 192, 12, 8, 140, 32, 167, 200, 129, 107, 155, 112, 53, 134, 190, 167, 128, 135, 186, 138]): (5, 0), P2pkh([205, 108, 183, 206, 205, 136, 189, 238, 114, 94, 230, 34, 164, 28, 16, 118, 183, 219, 201, 18]): (5, 140)}, required_balance: 27122100 }))) st_hash="e073919332609e01aea0474a8eaa04b2e7f46494c110cf67ceb065fe65a8c17d" 

So, Drive logs demand 23814000 + 3308100 = 27 122 100 , while AddressFundsTransferTransitionV0::calculate_min_required_fee returns 7 500 000 .

Possible Solution

Wee need to fix the algorithm.

Context

Tried to fix fee calculations in Dash Evo Tool.

Your Environment

Activity

  1. added
    bug
    on Feb 2, 2026
  2. added
    effort: S
    priority: high
    on Mar 12, 2026
  3. Claudius-Maginificent commented on Apr 30, 2026

    @Claudius-Maginificent
    Collaborator

    Hit again in the wild. Surfaced empirically in PR #3549's e2e harness while validating PR #3554's [ReduceOutput(0)] auto-select path.

    Reproducer (1in/1out, [ReduceOutput(0)])

    • AddressFundsTransferTransition::estimate_min_fee ≈ 6_500_000
    • Drive chain-time total_base_fee() = storage_fee + processing_fee ≈ 14_939_900
    • Auto-select greenlights selection with output[0] = 10_000_000 (passes Phase 4: 10M ≥ 6.5M).
    • Broadcast then fails:
      AddressesNotEnoughFundsError {
        addresses_with_info: { addr_1: (nonce=1, balance=30_600_900) },
        required_balance: 14_939_900
      }
      
    • Path: validate_fees_of_event::v0::PaidFromAddressInputs arm → deduct_fee_from_outputs_or_remaining_balance_of_inputs → output[0] absorbs 10M of the 14.94M, the remaining 4.94M can't be drawn from anywhere because the strategy is [ReduceOutput(0)] only.

    Same shape as the original report (3in/1out, 7.5M static vs 27.1M chain-time, +19.6M gap), just smaller.

    Workarounds applied today

    Why we didn't add a wallet-side band-aid
    DET tried (dashpay/dash-evo-tool#514) and closed as "blocked on #3040". A more conservative wallet estimate would just create two parallel bad estimates; the real fix is in dpp's calculate_min_required_fee algorithm. Suggest pairing this with #3041's API redesign so the new estimator can be queried by the wallet without constructing a signed transition.

    🤖 Co-authored by Claudius the Magnificent AI Agent

  4. lklimek commented on Nov 3, 2026

    @lklimek
    ContributorAuthor

    Still reproduced on 2026-11-03, live Testnet, using the official Dash Evo Tool v1.0.0-weekly.20261103+d94e6245d distribution.

    Pinned dependencies: Platform 575d961fe0c54bd7e01a3cf3823494e58c6c4fdb, rust-dashcore aca020263990a86a15cc1d97ae2cbf965d488db5 (DET manifest, lockfile). This confirms the problem at those pins, not at every newer upstream head.

    GUI reproduction: Wallet → Send → Platform Addresses → another Platform address → Max → confirm. One P2PKH input, one output, [DeductFromInput(0)].

    Value Credits
    Source balance before the attempt 4,420,135,880
    Amount offered by Max 4,404,935,480
    DET's estimated fee reserve 15,200,400
    Consensus-required remaining balance 15,308,500
    Reserve shortfall 108,100

    This is not just the bare static minimum: DET's production estimate already adds estimated storage and a 20% buffer. It is still insufficient.

    At 08:54:36.029798 UTC, the node rejected the signed attempt 370dccc11f43ea9bd89b385671301ea49e6764bd0c9ab0ac271d906df26e5e91 (consensus code 40602):

    AddressesNotEnoughFundsError {
        addresses_with_info: { <source>: (1, 15200400) },
        required_balance: 15308500
    }
    

    The hash above identifies the rejected local attempt; it was not included in a block.

    Control: without adding funds, I reduced the output to 4,404,827,380 credits, leaving 15,308,500 available for admission. The transfer then succeeded in block 657664, ST 717c82ce…42a33abf. The SDK verified the returned proof, and the independent explorer reports SUCCESS, amount 4404827380, gas used 3388960.

    The actual charge was 3,388,960 credits, leaving 11,919,540 in the source:

    4,420,135,880 = 4,404,827,380 sent + 3,388,960 fee + 11,919,540 remaining
    

    Thus the admission reserve differs from the charged fee. Subtracting a previous receipt's gas use would not be a safe Max calculation. This adds a current 1-input/1-output DeductFromInput reproduction to the earlier cases in this issue; accurate admission estimation is still needed.

    🤖 Co-authored by Claudius the Magnificent AI Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugeffort: Spriority: highrs-sdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions