From fb99541fa239fb613536f6b8eef526803c193a1e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 13 Nov 2026 00:28:04 +0700 Subject: [PATCH 1/2] feat(platform)!: charge a processing fee for a multiple choice proposal (PV15) A multiple choice proposal opens no poll of its own: its first choice opens a contest, and each choice pays the contest's fund. Creating the proposal cost its storage and gas alone, against the 0.5 Dash fund a yes/no proposal pays. Creating one now pays a flat processing fee of 0.2 Dash on top of its gas. - `VoteResolutionFundFees` gains `multiple_choice_proposal_processing_fee`: 0.2 Dash in `VOTE_RESOLUTION_FUND_FEES_VERSION3` (`FEE_VERSION4`, protocol version 15), 0 in every earlier schedule. - The execution event of a document batch adds it to the batch's processing fee once for each `multipleChoiceProposal` of the decision proposals contract the batch creates, as a contract's registration cost is added. It is read off the transitions as state validation left them, so a create that is refused pays its gas alone. - It is not a fund: it prefunds no votes and goes to the processing fee pools. The create does not state it, and a payer whose balance does not cover it creates no proposal (`IdentityInsufficientBalanceError`). The shared execution event code is edited in place. It cannot change what protocol version 14 and earlier do: their fee schedules carry 0, and the decision proposals contract does not exist there. Co-Authored-By: Claude Fable 5.2 --- book/src/fees/overview.md | 8 + docs/protocol/decision-proposals.md | 28 ++- .../decision-proposals-contract/README.md | 4 +- packages/rs-dpp/src/decision_proposal/mod.rs | 23 +++ .../execution/types/execution_event/mod.rs | 10 +- .../multiple_choice_proposal_tests.rs | 184 +++++++++++++++++- .../src/state_transition_action/batch/mod.rs | 29 +++ .../fee/vote_resolution_fund_fees/mod.rs | 10 + .../fee/vote_resolution_fund_fees/v1.rs | 2 + .../fee/vote_resolution_fund_fees/v3.rs | 3 + .../rs-platform-version/src/version/v15.rs | 12 ++ 11 files changed, 305 insertions(+), 8 deletions(-) diff --git a/book/src/fees/overview.md b/book/src/fees/overview.md index c0ba80481db..3f8bb7dc5b3 100644 --- a/book/src/fees/overview.md +++ b/book/src/fees/overview.md @@ -156,6 +156,7 @@ left when the contest ends is released as processing fees. The amounts are | Contested document fund (DPNS and every other contest) | 0.2 Dash | 0.1 Dash | 0.1 Dash | | Moderation election fund (an `electedCharter` application) | none exist | 0.5 Dash | 0.5 Dash | | Decision proposal fund (a `proposal` on the decision proposals contract) | none exist | none exist | 0.5 Dash | +| Multiple choice proposal processing fee (a `multipleChoiceProposal` on the decision proposals contract; not a fund, see below) | none exist | none exist | 0.2 Dash | | One vote | 0.0001 Dash | 0.00002 Dash | 0.00002 Dash | `required_vote_resolution_fund` in `rs-dpp` picks between the two contest @@ -168,6 +169,13 @@ vote poll rather than a contest, and its fund protocol version 15) prefunds that poll's votes the same way. The schedules before 15 carry 0 there, unread. +A multiple choice proposal opens no poll of its own: the first choice entered +for it opens a contest, and each choice pays the contested document fund. So +its create prefunds nothing, and pays a flat processing fee instead +(`multiple_choice_proposal_processing_fee`, also added in `FEE_VERSION4`): the +amount is added to the processing fee of the batch that creates it and goes +to the fee pools. The schedules before 15 carry 0 there. + ## User Fee Increase Every state transition carries a `user_fee_increase` field (a `UserFeeIncrease` diff --git a/docs/protocol/decision-proposals.md b/docs/protocol/decision-proposals.md index 87967e481bf..7918a3e0b60 100644 --- a/docs/protocol/decision-proposals.md +++ b/docs/protocol/decision-proposals.md @@ -146,8 +146,9 @@ proposal's creation whether or not a choice has been entered, so a choice entered in the first two hours may answer a text that is edited afterwards. The type keeps its history (`documentsKeepHistory: true`), so every version stays readable. `open` is listed under `immutable` by name and never changes. -Creating one opens no vote and states no fund. Additional properties are -rejected. +Creating one opens no vote and states no fund. It pays a flat processing fee +instead, 0.2 Dash on top of its gas (see [What it costs](#what-it-costs)). +Additional properties are rejected. | Property | Type | Meaning | | --- | --- | --- | @@ -163,9 +164,9 @@ neither unique. #### The description -A proposal costs its storage and nothing else, so text held in it would be -cheap to fill with anything and could never be taken down: the proposal is -undeletable. It therefore holds no description. What is being decided is said +Text held in a proposal could never be taken down: the proposal is +undeletable, and for the price of one proposal it would stay for good. It +therefore holds no description. What is being decided is said in one of two places, or both: - **A description document**, hosted on Platform where an elected team can @@ -327,6 +328,23 @@ If the proposal is not open (a rule reads `false` as 0), the choice's owner must be the proposal's owner; a choice anyone else enters is refused (`DocumentPropertyConstraintViolatedError`, 10422) and opens no vote. +### What it costs + +| Action | Pays | Where it goes | +| --- | --- | --- | +| Creating a multiple choice proposal | 0.2 Dash, added to the processing fee of the create (`multiple_choice_proposal_processing_fee` in `VoteResolutionFundFees`, set in `FEE_VERSION4`, protocol version 15), and its gas | The processing fee pools, like any processing fee | +| Entering a choice | The contest's fund, 0.1 Dash, doubling once the vote holds 250 choices and again for every 50 more, and its gas | The vote's prefunded balance: each masternode vote takes a fixed cost from it (0.00002 Dash), and what is left when the vote ends is released as processing fees | + +The proposal's fee is not a fund. A multiple choice proposal opens no poll of +its own (the first choice does), so there are no votes for it to prefund. The +create does not state the fee: it is charged as processing, whoever pays the +gas pays it, and an identity whose balance does not cover it creates no +proposal (`IdentityInsufficientBalanceError`). A create that is refused pays +its gas alone. A batch pays the fee once for each proposal it creates. + +A question with two answers therefore costs 0.4 Dash and its gas, against the +0.5 Dash fund of a yes/no proposal. + ### The vote - **Entering a choice.** The create states the contest's fund as its prefunded diff --git a/packages/decision-proposals-contract/README.md b/packages/decision-proposals-contract/README.md index baa8c01a04a..35cd1add267 100644 --- a/packages/decision-proposals-contract/README.md +++ b/packages/decision-proposals-contract/README.md @@ -59,7 +59,9 @@ and point it at another description, for two hours after creating it; after that they freeze. Every version is kept (`documentsKeepHistory`), so a reader can see the proposal as it was when a choice was entered. Whether it is `open` never changes. Creating it opens no vote and states no fund: the first choice -does. +does. It pays a flat processing fee of 0.2 Dash instead, on top of its gas, +which goes to the processing fee pools; each choice then pays its contest's +fund (0.1 Dash at first). The proposal holds no description of its own. What is being decided is said in one of two places, or both: at its `url`, for a description hosted diff --git a/packages/rs-dpp/src/decision_proposal/mod.rs b/packages/rs-dpp/src/decision_proposal/mod.rs index 933e7132bf3..ae87e9a5f47 100644 --- a/packages/rs-dpp/src/decision_proposal/mod.rs +++ b/packages/rs-dpp/src/decision_proposal/mod.rs @@ -39,6 +39,10 @@ pub const PROPOSAL_DOCUMENT_TYPE_NAME: &str = "proposal"; /// proposal's own type. A contested create names its contested index there instead. pub const DECISION_PROPOSAL_FUND_NAME: &str = PROPOSAL_DOCUMENT_TYPE_NAME; +/// The name of the multiple choice proposal document type: a question whose answers are the +/// choices entered for it, which contend in a masternode vote the first choice opens. +pub const MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME: &str = "multipleChoiceProposal"; + /// The properties of a proposal. pub mod properties { /// The question, in one line. Editable for a day after the proposal is created. @@ -76,6 +80,25 @@ pub fn decision_proposal_required_fund(platform_version: &PlatformVersion) -> Cr .decision_proposal_fund_required_amount } +/// Whether a document of `document_type_name` in the contract `contract_id` is a multiple +/// choice proposal: a `multipleChoiceProposal` of the decision proposals contract. Its create +/// opens no poll and states no fund; it pays the multiple choice proposal processing fee. +pub fn is_multiple_choice_proposal(contract_id: &Identifier, document_type_name: &str) -> bool { + *contract_id == DECISION_PROPOSALS_CONTRACT_ID + && document_type_name == MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME +} + +/// What creating one multiple choice proposal adds to the processing fee of its batch: the +/// fee version's `multiple_choice_proposal_processing_fee`. Unlike a yes/no proposal's fund +/// it prefunds no votes, since the proposal opens no poll: it goes to the processing fee +/// pools, and the create does not state it. 0 before protocol version 15. +pub fn multiple_choice_proposal_processing_fee(platform_version: &PlatformVersion) -> Credits { + platform_version + .fee_version + .vote_resolution_fund_fees + .multiple_choice_proposal_processing_fee +} + /// The id of the yes/no poll the proposal `document_id` opens: the id of the purpose /// [`YesNoVotePollPurpose::DecisionProposal`], which a vote on the proposal names and the poll /// queries take. Known from the proposal's id alone, before or after the poll opens. diff --git a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs index 6d33f4ed4c7..cbbe553674d 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs @@ -5,6 +5,7 @@ use crate::error::Error; use dpp::address_funds::{AddressFundsFeeStrategy, PlatformAddress}; use dpp::asset_lock::reduced_asset_lock_value::AssetLockValueGettersV0; use dpp::block::epoch::Epoch; +use dpp::decision_proposal::multiple_choice_proposal_processing_fee; use dpp::fee::Credits; use std::collections::BTreeMap; @@ -314,6 +315,12 @@ impl ExecutionEvent<'_> { // Read off the transitions as state validation left them: one it replaced with // a nonce bump owes no action fee. let action_fees = batch_action.resolved_action_fees()?; + // Each multiple choice proposal the batch creates (protocol version 15) pays a + // flat processing fee: it opens no poll, so it prefunds no votes. The fee + // schedules before that version carry 0, and no such proposal exists there. + let multiple_choice_proposal_fees = batch_action + .multiple_choice_proposals_created() + .saturating_mul(multiple_choice_proposal_processing_fee(platform_version)); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; if let Some(identity) = identity { @@ -323,7 +330,8 @@ impl ExecutionEvent<'_> { added_to_balance_outputs: None, operations, execution_operations: execution_context.operations_consume(), - additional_fixed_fee_cost: None, + additional_fixed_fee_cost: (multiple_choice_proposal_fees > 0) + .then_some(multiple_choice_proposal_fees), user_fee_increase, signing_key_limits, gas_sponsor, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs index 2bc15f40db9..c1304cf1a53 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs @@ -41,7 +41,10 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV2Getters; use dpp::data_contract::document_type::DocumentReferenceKind; use dpp::data_contract::schema::DataContractSchemaMethodsV0; use dpp::data_contract::DataContract; -use dpp::decision_proposal::DECISION_PROPOSALS_CONTRACT_ID; +use dpp::decision_proposal::{ + multiple_choice_proposal_processing_fee, DECISION_PROPOSALS_CONTRACT_ID, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME, +}; use dpp::document::document_methods::DocumentMethodsV0; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::{Document, DocumentV0, DocumentV0Getters, DocumentV0Setters}; @@ -2342,3 +2345,182 @@ async fn should_take_the_description_from_a_document_a_url_or_both() { } } } + +/// The identity's balance now. +fn balance( + platform: &TempPlatform, + identity_id: Identifier, + platform_version: &PlatformVersion, +) -> Credits { + platform + .drive + .fetch_identity_balance(identity_id.to_buffer(), None, platform_version) + .expect("expected to read the balance") + .expect("expected the identity") +} + +/// Creating a multiple choice proposal opens no poll and prefunds no votes, so it pays a +/// flat processing fee instead: 0.2 Dash on top of its gas. Nothing else of the contract +/// pays it, a create that is refused does not, and an identity that cannot cover it creates +/// no proposal. +#[tokio::test] +async fn should_charge_a_flat_processing_fee_for_a_multiple_choice_proposal() { + let (mut platform, platform_version, contract, mut rng) = setup(); + let fee = multiple_choice_proposal_processing_fee(platform_version); + assert_eq!(fee, dash_to_credits!(0.2)); + // No fee schedule before protocol version 15 charges it + assert_eq!( + multiple_choice_proposal_processing_fee( + PlatformVersion::get(14).expect("expected protocol version 14") + ), + 0 + ); + assert_eq!( + multiple_choice_proposal::NAME, + MULTIPLE_CHOICE_PROPOSAL_DOCUMENT_TYPE_NAME + ); + // The gas of any transition here is far below the fee + let at_most_gas = fee / 10; + + let mut proposer = writer(&mut platform, &mut rng); + let mut alice = writer(&mut platform, &mut rng); + let described_at_a_url = |question: &str| { + BTreeMap::from([ + ( + multiple_choice_proposal::properties::TITLE.to_string(), + Value::Text(question.to_string()), + ), + ( + multiple_choice_proposal::properties::URL.to_string(), + Value::Text("https://example.org/proposals/mascot".to_string()), + ), + ( + multiple_choice_proposal::properties::OPEN.to_string(), + Value::Bool(true), + ), + ]) + }; + + // The proposal pays the fee as processing, whoever described it and wherever + let before = balance(&platform, proposer.id(), platform_version); + let (transition, proposal_id) = create_transition( + &contract, + &mut proposer, + multiple_choice_proposal::NAME, + described_at_a_url("Which mascot?"), + &mut rng, + platform_version, + ) + .await; + let StateTransitionExecutionResult::SuccessfulExecution { fee_result, .. } = + process(&platform, transition, 20_000, platform_version) + else { + panic!("expected the proposal to be created"); + }; + assert!( + fee_result.processing_fee >= fee && fee_result.processing_fee < fee + at_most_gas, + "expected the gas and the proposal fee, got {}", + fee_result.processing_fee + ); + let after = balance(&platform, proposer.id(), platform_version); + assert_eq!( + before - after, + fee_result.processing_fee + fee_result.storage_fee + ); + + // A choice pays its contest's fund, which prefunds the votes, and no proposal fee + let before = balance(&platform, alice.id(), platform_version); + let (transition, _) = choice_transition( + &contract, + &mut alice, + proposal_id, + "An owl", + &mut rng, + platform_version, + ) + .await; + let StateTransitionExecutionResult::SuccessfulExecution { fee_result, .. } = + process(&platform, transition, 30_000, platform_version) + else { + panic!("expected the choice to be entered"); + }; + assert!( + fee_result.processing_fee < at_most_gas, + "{}", + fee_result.processing_fee + ); + let fund = platform_version + .fee_version + .vote_resolution_fund_fees + .contested_document_vote_resolution_fund_required_amount; + assert_eq!( + before - balance(&platform, alice.id(), platform_version), + fund + fee_result.processing_fee + fee_result.storage_fee + ); + + // A proposal that is refused is not created, and pays its gas alone + let (transition, _) = create_transition( + &contract, + &mut proposer, + multiple_choice_proposal::NAME, + BTreeMap::from([ + ( + multiple_choice_proposal::properties::TITLE.to_string(), + Value::Text("Described nowhere".to_string()), + ), + ( + multiple_choice_proposal::properties::OPEN.to_string(), + Value::Bool(true), + ), + ]), + &mut rng, + platform_version, + ) + .await; + let StateTransitionExecutionResult::PaidConsensusError { actual_fees, .. } = + process(&platform, transition, 40_000, platform_version) + else { + panic!("expected the proposal described nowhere to be refused"); + }; + assert!( + actual_fees.processing_fee < at_most_gas, + "{}", + actual_fees.processing_fee + ); + + // An identity holding less than the fee creates no proposal and keeps its balance + let mut poor = Writer { + info: setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.1)), + next_nonce: 1, + }; + let (transition, unaffordable_id) = create_transition( + &contract, + &mut poor, + multiple_choice_proposal::NAME, + described_at_a_url("Which colour?"), + &mut rng, + platform_version, + ) + .await; + let result = process(&platform, transition, 50_000, platform_version); + assert!( + matches!( + result, + StateTransitionExecutionResult::UnpaidConsensusError(ConsensusError::StateError( + StateError::IdentityInsufficientBalanceError(_) + )) + ), + "{result:?}" + ); + assert!(stored_document( + &platform, + &contract, + multiple_choice_proposal::NAME, + unaffordable_id + ) + .is_none()); + assert_eq!( + balance(&platform, poor.id(), platform_version), + dash_to_credits!(0.1) + ); +} diff --git a/packages/rs-drive/src/state_transition_action/batch/mod.rs b/packages/rs-drive/src/state_transition_action/batch/mod.rs index 58bb3fc7a25..5c925b57cca 100644 --- a/packages/rs-drive/src/state_transition_action/batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/batch/mod.rs @@ -1,3 +1,4 @@ +use crate::state_transition_action::batch::batched_transition::document_transition::DocumentTransitionAction; use crate::state_transition_action::batch::batched_transition::BatchedTransitionAction; use crate::state_transition_action::batch::v0::BatchTransitionActionV0; use crate::state_transition_action::contract::moderators_pot_settlement::ModeratorsPotSettlement; @@ -10,6 +11,7 @@ use dpp::tokens::gas_fees_paid_by::GasFeesPaidBy; use crate::drive::contract_groups::types::ContractGroupMembershipsForContract; use dpp::fee::fee_result::FeeResult; use dpp::consensus::ConsensusError; +use dpp::decision_proposal::is_multiple_choice_proposal; use dpp::balances::credits::MAX_CREDITS; use dpp::fee::Credits; use dpp::identity::SecurityLevel; @@ -432,6 +434,33 @@ impl BatchTransitionAction { } } + /// How many multiple choice proposals the batch creates (protocol version 15): each adds + /// the multiple choice proposal processing fee to what the batch pays. + /// + /// Read off the transitions as they are now, like the action fees: state validation + /// replaces a create that fails with a nonce bump, which creates nothing and owes + /// nothing. + pub fn multiple_choice_proposals_created(&self) -> u64 { + match self { + BatchTransitionAction::V0(v0) => v0 + .transitions + .iter() + .filter(|transition| match transition { + BatchedTransitionAction::DocumentAction( + document_action @ DocumentTransitionAction::CreateAction(_), + ) => { + let base = document_action.base(); + is_multiple_choice_proposal( + &base.data_contract_id(), + base.document_type_name(), + ) + } + _ => false, + }) + .count() as u64, + } + } + /// The elected contracts on whose moderated document types some document transition of the /// batch agrees to a discounted moderators part (protocol version 14): the contracts whose /// seated moderation charter the batch transformer reads the moderators share of. diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs index 7c1cf616254..f645c232cac 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs @@ -34,6 +34,13 @@ pub struct VoteResolutionFundFees { /// yes/no poll; what is left when the poll ends is released as processing fees. Decision /// proposals exist from protocol version 15; earlier schedules carry 0, unread. pub decision_proposal_fund_required_amount: u64, + /// The amount added to the processing fee of a batch for each multiple choice proposal it + /// creates (a `multipleChoiceProposal` create on the decision proposals contract). Such a + /// proposal opens no poll of its own, so it prefunds no votes: the amount goes to the + /// processing fee pools with the rest of the batch's processing fee, paid by whoever + /// pays its gas. Multiple choice proposals exist from protocol version 15; earlier + /// schedules carry 0, which charges nothing. + pub multiple_choice_proposal_processing_fee: u64, } /// The vote resolution fund fees exactly as every pre-1.4 release serialized them inside @@ -65,6 +72,7 @@ impl From for VoteResolutionFundFees contested_document_contenders_per_fund_doubling: 0, // Pre-4.2 tables predate decision proposals (protocol version 15) decision_proposal_fund_required_amount: 0, + multiple_choice_proposal_processing_fee: 0, } } } @@ -85,6 +93,7 @@ mod tests { contested_document_contenders_before_fund_doubling: 5, contested_document_contenders_per_fund_doubling: 6, decision_proposal_fund_required_amount: 7, + multiple_choice_proposal_processing_fee: 8, }; let version2 = VoteResolutionFundFees { @@ -95,6 +104,7 @@ mod tests { contested_document_contenders_before_fund_doubling: 5, contested_document_contenders_per_fund_doubling: 6, decision_proposal_fund_required_amount: 7, + multiple_choice_proposal_processing_fee: 8, }; // This assertion will check if all fields are considered in the equality comparison diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs index 99d44067e8e..e7cad6885de 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs @@ -12,4 +12,6 @@ pub const VOTE_RESOLUTION_FUND_FEES_VERSION1: VoteResolutionFundFees = VoteResol contested_document_contenders_per_fund_doubling: 0, // Decision proposals exist from protocol version 15; unread before it. decision_proposal_fund_required_amount: 0, + // Multiple choice proposals exist from protocol version 15; 0 charges nothing before it. + multiple_choice_proposal_processing_fee: 0, }; diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v3.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v3.rs index 8e06ca89b45..744f157ef0e 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v3.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v3.rs @@ -6,5 +6,8 @@ pub const VOTE_RESOLUTION_FUND_FEES_VERSION3: VoteResolutionFundFees = VoteResol // Opening a decision proposal prefunds 25,000 masternode votes on its poll, more than every // masternode casting all of its votes on it decision_proposal_fund_required_amount: 50_000_000_000, // 0.5 DASH + // A multiple choice proposal opens no poll and prefunds no votes (each choice entered for + // it pays the contest's fund), so creating one pays a flat processing fee instead + multiple_choice_proposal_processing_fee: 20_000_000_000, // 0.2 DASH ..VOTE_RESOLUTION_FUND_FEES_VERSION2 }; diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index 5c06c99bda6..ae7b0edad95 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -843,6 +843,18 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// names with the one its document type expects by contract, document type and index /// name, where generation 1, which protocol v14 keeps, compares them whole. Protocol /// v14 keeps generation 0 of `canonical_contested_index_values`. +/// +/// 40. **A multiple choice proposal pays a processing fee**: a `multipleChoiceProposal` of +/// the decision proposals contract opens no poll (its first choice does, note 37), so +/// its create prefunds no votes. `FEE_VERSION4` charges it +/// `multiple_choice_proposal_processing_fee` (0.2 Dash, in `VoteResolutionFundFees`) +/// instead: the execution event of a document batch adds it to the batch's processing +/// fee once for each such proposal the batch creates, read off the transitions as state +/// validation left them, so a create that is refused pays its gas alone. It goes to the +/// processing fee pools with the rest of the processing fee, the create does not state +/// it, and a payer whose balance does not cover it is refused +/// (`IdentityInsufficientBalanceError`). The fee schedules of protocol v14 and earlier +/// carry 0, and the contract does not exist there, so nothing is charged. pub const PLATFORM_V15: PlatformVersion = PlatformVersion { protocol_version: PROTOCOL_VERSION_15, drive: DRIVE_VERSION_V10, // changed: calculate_fee 1 prices a refund at the storing epoch's rate (note 27); apply_contract_with_serialization 1 writes nothing for a contract whose format version 1 bytes match the stored one's (note 8); vote method versions v4: register_identity_vote 1 registers a yes/no vote, remove_all_votes_given_by_identities 1 also removes the yes/no votes of a masternode that left the list, every yes_no method and remove_vote_poll_end_date_query_operations Some(0) make yes/no polls active, add_vote_poll_end_date_query_operations 1 adds only the entry when the batch already queues the end date's tree with other storage flags, and verify methods v4 make the yes/no proof verifiers active (note 10) and verify_private_document_entries Some(0) a page of a private type's store (note 13); state transition method versions v5: document_create_transition 1 deletes a consumed document from what its lookup read (note 11); document method versions v5: insert_empty_private_document_store_operation Some(0) creates a private document type's store, and fetch_private_document_entries and prove_private_document_entries Some(0) read and prove a page of it (note 13); apply_drive_operations 2 resolves a batch's estimate, remove_reference_for_index_level_for_contract_operations 2, add_reference_for_index_level_for_contract_operations 1, stateless_delete_of_non_tree_for_costs 1 and for_total_system_credits_update 1 describe their layers as they are (note 14); create_initial_state_structure 5 adds the token marketplace escrow trees; calculate_total_tokens_balance 2 counts escrowed tokens; the escrow primitives; the identity balance, token balance, prefunded specialized balance and contract fee pot estimations (for_balances 1, for_token_balances 1, estimated_cost_for_prefunded_specialized_balance_update 2, add_estimation_costs_for_contract_fee_pot_update 1) keep a deeper layer description (note 17); fetch_core_fork_activation_height and store_core_fork_activation_height Some(0) keep the Core fork activations (note 18); document method versions v5: append_private_document_entries_operations Some(0) appends a private document create's entries (note 25); grove_version GROVE_V5 (note 26); verify methods v4: verify_proof_keep_serialized 1 verifies a document that may be contested (note 29); document method versions v5: single_document_path_query 1 selects the latest retained revision at or before a block time, and verify_proof_keep_serialized 1 verifies it (note 31); retained-history writers, readers, estimates and verifiers select the per-type revision layout (note 35); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32); document method versions v5: add_indices_for_top_index_level_for_contract_operations 3 writes no entry in an expired time range bucket (note 36) From 7eebf73ef7ceacba9a7a43ef425cd99a3496d46d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 13 Nov 2026 01:45:46 +0700 Subject: [PATCH 2/2] test(drive-abci): cover a multiple choice proposal refused in state validation The fee test refused a proposal described nowhere, which a property constraint rejects before the create becomes an action of the batch. The fee is counted off the batch's transitions as state validation left them, so the case that matters is a create replaced there by a nonce bump: a proposal naming a description document that does not exist. It is refused with 40120, not stored, and pays its gas alone. Also names the fee in the `fee_version` comment of protocol version 15 and in `FEE_VERSION4`'s own, which listed what the schedule changes. Co-Authored-By: Claude Fable 5.2 --- .../multiple_choice_proposal_tests.rs | 45 +++++++++++++++++++ .../rs-platform-version/src/version/fee/v4.rs | 3 +- .../rs-platform-version/src/version/v15.rs | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs index c1304cf1a53..f80fd37439d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/multiple_choice_proposal_tests.rs @@ -2488,6 +2488,51 @@ async fn should_charge_a_flat_processing_fee_for_a_multiple_choice_proposal() { actual_fees.processing_fee ); + // Nor does one that state validation refuses: it passes every check on the transition + // itself, becomes an action of the batch, and is replaced there by a nonce bump when the + // description document it names turns out not to exist. A bump creates nothing + let host = description_host(true, platform_version); + let (transition, never_created_id) = create_transition( + &contract, + &mut proposer, + multiple_choice_proposal::NAME, + question_properties( + "Described by a document that is not there", + true, + host.id(), + TEXT, + Identifier::new([7; 32]), + ), + &mut rng, + platform_version, + ) + .await; + let StateTransitionExecutionResult::PaidConsensusError { + error, actual_fees, .. + } = process(&platform, transition, 45_000, platform_version) + else { + panic!("expected the proposal naming a missing description to be refused"); + }; + assert!( + matches!( + error, + ConsensusError::StateError(StateError::ReferencedEntityNotFoundError(_)) + ), + "{error:?}" + ); + assert!( + actual_fees.processing_fee < at_most_gas, + "{}", + actual_fees.processing_fee + ); + assert!(stored_document( + &platform, + &contract, + multiple_choice_proposal::NAME, + never_created_id + ) + .is_none()); + // An identity holding less than the fee creates no proposal and keeps its balance let mut poor = Writer { info: setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.1)), diff --git a/packages/rs-platform-version/src/version/fee/v4.rs b/packages/rs-platform-version/src/version/fee/v4.rs index c0f2ca26427..196c7e00ca6 100644 --- a/packages/rs-platform-version/src/version/fee/v4.rs +++ b/packages/rs-platform-version/src/version/fee/v4.rs @@ -5,7 +5,8 @@ use crate::version::fee::FeeVersion; /// Introduced in protocol version 15 (5.1). pub const FEE_VERSION4: FeeVersion = FeeVersion { - // Decision proposals (new in protocol version 15) prefund their poll's votes. Storage rates + // Decision proposals (new in protocol version 15) prefund their poll's votes, and a multiple + // choice proposal, which opens no poll, pays a flat processing fee on create. Storage rates // are unchanged, so the fee_version_number inherited from FEE_VERSION3 stays. vote_resolution_fund_fees: VOTE_RESOLUTION_FUND_FEES_VERSION3, // Each private document entry (new in protocol version 15) pays its storage and a flat diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index ae7b0edad95..23a4fad22f8 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -883,7 +883,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { factory_versions: DPP_FACTORY_VERSIONS_V1, }, system_data_contracts: SYSTEM_DATA_CONTRACT_VERSIONS_V4, // changed: DPNS v3 checks a name's create with keywords (note 3); the decision proposals contract (note 12); the token market contract is selected (note 17); DashPay v3 states what its data triggers checked (note 24) - fee_version: FEE_VERSION4, // changed: decision proposals prefund their poll with 0.5 Dash (note 12); a private document entry pays its storage and 10,000,000 credits (note 25) + fee_version: FEE_VERSION4, // changed: decision proposals prefund their poll with 0.5 Dash (note 12); a private document entry pays its storage and 10,000,000 credits (note 25); a multiple choice proposal pays a 0.2 Dash processing fee on create (note 40) system_limits: SYSTEM_LIMITS_V5, // changed: max_compiled_contract_size caps a contract stored compiled at 1 MiB (note 8); max_private_document_entry_size caps a private type's entries at 4096 bytes, and the private document store limits size its store (note 13); max_private_document_entries_per_transition caps a private document create at 16 entries (note 25) consensus: ConsensusVersions { tenderdash_consensus_version: 1,