Repository navigation
Description
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
- For document creates, base the result on
drive::document::cost::document_create_cost(feat(drive): compute what creating a document costs for the SDKs #5159) plus the admission requirement asked for in SDK: cost functions for document replace and delete, contract update, key operations and the admission requirement #5265, so the client check andvalidate_fees_of_eventagree. - Until then, say in the documentation of
calculate_min_required_feeandvalidate_estimated_feethat the value is a floor and not an estimate, so clients do not show it to users as the cost or gate a write on it.
Steps to Reproduce (for bugs)
- Create an identity with 60,000,000 credits.
- Build the DPNS
preorderbatch for a 20-character label.validate_estimated_fee(60_000_000, ..)passes;calculate_min_required_feeis 100,000. - Broadcast it. It is accepted and about 32,100,000 credits are charged.
- Build and broadcast the
domainbatch.validate_estimated_fee(27_909_480, ..)passes; Drive refuses the batch withIdentityInsufficientBalanceError,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
- Version used:
dash-sdkat 9f7ed16; the function is unchanged onv5.0-devas of 2026-10-12 - Environment name and version: testnet
- Operating System and version: Linux
- Link to your project: fix(dpns): show and enforce the balance a username registration really needs dash-evo-tool#1075
🤖 Co-authored by Claudius the Magnificent AI Agent
Activity
fix(dpns): show and enforce the balance a username registration reall…