Skip to content

BatchTransition::calculate_min_required_fee is far below what Drive requires for a document create #5383

Open

Description

@Claudius-Maginificent

TL;DR: For a document create, BatchTransition::calculate_min_required_fee returns 100,000 credits per document. On testnet Drive charged 32 to 47 million credits for each DPNS document and refused the second one unless the identity held 84 to 88 million. A client that relies on this function, or on validate_estimated_fee, lets a user start a write that Drive then turns down after the first document was paid for.

Same family as #3040 (address transitions). Related: #5159 (document_create_cost), #5265 (a function for the admission requirement), #5264 (dry run).

Expected Behavior

calculate_min_required_fee and validate_estimated_fee on a BatchTransition tell a client whether the identity's balance is enough for Drive to accept the batch, or at least come within a small margin of it.

Current Behavior

calculate_min_required_fee is state_transition_min_fees.document_batch_sub_transition × transitions_len() (state_transition_estimated_fee_validation.rs): the minimum-fee floor, with no storage part. validate_estimated_fee compares the identity's balance with that floor.

Drive decides differently. validate_fees_of_event runs the batch's drive operations as a dry run (apply_drive_operations(.., apply = false, ..)) and requires the balance to cover that estimate, which is above what it then charges.

Measured on testnet on 2026-10-12, registering DPNS names for newly created identities (credits):

Document calculate_min_required_fee Charged Balance Drive required
preorder 100,000 32,090,520 to 32,554,660 not measured
domain, 20-character label 100,000 42,817,780 83,627,060
domain, 63-character label 100,000 47,465,940 88,397,980
domain, 19-letter contested label 100,000 83,152,940 plus the vote fund not measured

The required balance comes from the refusal itself: IdentityInsufficientBalanceError { balance: 27909480, required_balance: 83627060 } for an identity that had started with 60,000,000 credits and had already paid for its preorder.

So the floor is about 320 times below the charge for a preorder and about 840 times below the balance Drive requires for a domain.

Possible Solution

Steps to Reproduce (for bugs)

  1. Create an identity with 60,000,000 credits.
  2. Build the DPNS preorder batch for a 20-character label. validate_estimated_fee(60_000_000, ..) passes; calculate_min_required_fee is 100,000.
  3. Broadcast it. It is accepted and about 32,100,000 credits are charged.
  4. Build and broadcast the domain batch. validate_estimated_fee(27_909_480, ..) passes; Drive refuses the batch with IdentityInsufficientBalanceError, required_balance: 83627060.

Context

Dash Evo Tool showed this floor as the cost of registering a username (0.000002 DASH) and enabled the pay button on it. An identity with a small balance paid for the preorder and was refused at the domain. We replaced the floor with figures fitted to Drive's behaviour for the DPNS contract (dashpay/dash-evo-tool#1075); they have to be re-measured whenever Drive changes how documents or indexes are stored, and they cover one contract only.

Your Environment

🤖 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions