From 2cde222055f3603736d488709913da1c140d5b87 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 11 Nov 2026 18:35:24 +0700 Subject: [PATCH] fix(platform)!: end a contest without a winner when the award has no room (PV15) A contender's document waits in its contest's area, where the checks a document create runs do not see it. A contract registered before protocol version 15 can keep a contest its index values do not decide, and a document created outside such a contest while the chain ran protocol version 14 still holds the contest's index values when the contest ends. award_document_to_winner 1, selected by the protocol version 15 table, runs the two checks of a document create on the winner's document before inserting it: no document holds its id, and no document holds its unique index values (read only when the entry is one Drive shares). When one fails it inserts nothing and the contest is recorded without a winner and cleaned up like any other. Otherwise it calls version 0 unchanged. check_for_ended_vote_polls 1 is edited in place to read the award's answer. Protocol version 14 selects award version 0, which always inserts or returns the insert's error, so nothing changes there. Co-Authored-By: Claude Fable 5.2 --- book/src/contract-keywords/contested.md | 2 +- .../voting/award_document_to_winner/mod.rs | 21 +- .../voting/award_document_to_winner/v1/mod.rs | 115 +++++ .../check_for_ended_vote_polls/v1/mod.rs | 19 +- .../state_transition/state_transitions/mod.rs | 402 ++++++++++++++++++ .../drive_abci_method_versions/v11.rs | 5 + .../rs-platform-version/src/version/v15.rs | 14 +- 7 files changed, 566 insertions(+), 12 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v1/mod.rs diff --git a/book/src/contract-keywords/contested.md b/book/src/contract-keywords/contested.md index 831f70d9dda..297226163f4 100644 --- a/book/src/contract-keywords/contested.md +++ b/book/src/contract-keywords/contested.md @@ -71,7 +71,7 @@ The fund, the windows, the tallies and the special case of moderation elections - A document type has at most one contested index, and no other unique index beside it (`ContestedUniqueIndexWithUniqueIndexError`, 10249). - `resolution` is present and is `0` or `1`; `1` is refused before protocol version 14. - `fieldMatches`, when present, holds at least one entry, and each `regexPattern` is a valid regular expression (`RegexError`, 10247). -- From protocol version 15, the contest is decided by the index values, so that two documents with the same values are both contested or both ordinary: every `fieldMatches` field is a property of the index, and a match on a string property that may be empty (no `minLength` of at least 1) treats `""` and `"\0"` alike, since the two share one index key (`InvalidContractStructure`, 10231). Otherwise an ordinary document could take the values of a contested one, and the contest would have nothing left to award. A contract registered earlier keeps its contest, but can no longer be updated, since an update is checked like a registration; while such a contest is live, a create outside it with the same index values is refused (`DuplicateUniqueIndexError`). +- From protocol version 15, the contest is decided by the index values, so that two documents with the same values are both contested or both ordinary: every `fieldMatches` field is a property of the index, and a match on a string property that may be empty (no `minLength` of at least 1) treats `""` and `"\0"` alike, since the two share one index key (`InvalidContractStructure`, 10231). Otherwise an ordinary document could take the values of a contested one, and the contest would have nothing left to award. A contract registered earlier keeps its contest, but can no longer be updated, since an update is checked like a registration; while such a contest is live, a create outside it with the same index values is refused (`DuplicateUniqueIndexError`). A contest whose values a document took before protocol version 15 ends without a winner. - From protocol version 15, every property of the index is a top-level property of the document: no property path such as `records.identity` and no system property such as `$ownerId` (`InvalidContractStructure`, 10231). A contested create finds the contest by reading each index value from the document's top-level properties, where such a property is never found, so no contested create could open or join the contest. A contract registered earlier keeps such an index, but can no longer be updated. - A contested index cannot carry a [`timeRange`](time-range.md), an [`integerRange`](integer-range.md) or a ranking (a ranking needs a non-unique index), and an [index-only type](index-only.md) cannot have one. - A document type with a contested index cannot set [`ttl`](ttl.md), nor `moderatorAbilities.delete` (see [Deletion](deletion.md)): a moderator's restore puts a document back by an ordinary insert, and a contested value is only awarded through a vote. diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs index 16115f50483..18194f09dfb 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs @@ -8,12 +8,15 @@ use dpp::voting::contender_structs::FinalizedContender; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; mod v0; +mod v1; impl Platform where C: CoreRPCLike, { - /// Checks for ended vote polls + /// Awards a document to the winner of a contest, and returns whether it did. Version 0 + /// always does, or returns the insert's error; from version 1 (protocol version 15) a winner whose id or unique + /// index values a document already holds is not awarded. pub(in crate::execution) fn award_document_to_winner( &self, block_info: &BlockInfo, @@ -21,14 +24,24 @@ where vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(), Error> { + ) -> Result { match platform_version .drive_abci .methods .voting .award_document_to_winner { - 0 => self.award_document_to_winner_v0( + 0 => { + self.award_document_to_winner_v0( + block_info, + contender, + vote_poll, + transaction, + platform_version, + )?; + Ok(true) + } + 1 => self.award_document_to_winner_v1( block_info, contender, vote_poll, @@ -37,7 +50,7 @@ where ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "award_document_to_winner".to_string(), - known_versions: vec![0], + known_versions: vec![0, 1], received: version, })), } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v1/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v1/mod.rs new file mode 100644 index 00000000000..035518b4f2e --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v1/mod.rs @@ -0,0 +1,115 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::document::DocumentV0Getters; +use dpp::platform_value::Value; +use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::FinalizedContender; +use drive::drive::document::query::QueryDocumentsOutcomeV0Methods; +use drive::drive::document::shared_unique_entry::unique_index_entry_is_shared; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; +use drive::query::{DriveDocumentQuery, InternalClauses, WhereClause, WhereOperator}; +use drive::util::object_size_info::DocumentInfo; + +impl Platform +where + C: CoreRPCLike, +{ + /// Awards a document to the winner of a contest, unless the state has no room for it, and + /// returns whether it did. + /// + /// Version 0 inserts the document as it is. A contender's document waits in the contest's + /// area, where the checks a document create runs do not see it, so nothing but those + /// checks, run on other creates while the contest is live, keeps its place free. When they + /// let a document take it, the insert of version 0 has no room for the winner's document + /// and returns an error. The known case is a contest its index values do not decide, which + /// registration refuses from protocol version 15 but a contract registered earlier keeps: + /// a document outside the contest holds the contest's index values from before the + /// create's state validation 3 guarded them. + /// + /// This version runs the two checks of a document create on the winner's document first: + /// no document holds its id, and no document holds the values of its unique index. When + /// either fails nothing is inserted and `false` is returned, and the contest ends without + /// a winner. Otherwise version 0 inserts it. + #[inline(always)] + pub(super) fn award_document_to_winner_v1( + &self, + block_info: &BlockInfo, + contender: FinalizedContender, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let contract = vote_poll.contract.as_ref(); + let document_type = vote_poll.document_type()?; + + let documents_with_the_id = self.drive.query_documents( + DriveDocumentQuery { + contract, + document_type, + internal_clauses: InternalClauses { + primary_key_in_clause: None, + primary_key_equal_clause: Some(WhereClause { + field: "$id".to_string(), + operator: WhereOperator::Equal, + value: Value::Identifier(contender.document.id().to_buffer()), + }), + in_clauses: Vec::new(), + range_clause: None, + equal_clauses: Default::default(), + }, + offset: None, + limit: Some(1), + order_by: Default::default(), + start_at: None, + start_at_included: false, + block_time_ms: None, + resolved_time_ranges: vec![], + sub_queries: vec![], + }, + None, + false, + transaction, + Some(platform_version.protocol_version), + )?; + if !documents_with_the_id.documents().is_empty() { + return Ok(false); + } + + // A type with a contested index has no other unique index + // (`ContestedUniqueIndexWithUniqueIndexError`), so the contested one is the only entry + // the insert can find taken. An entry Drive keeps under the document's id, because one + // of its keys is empty, meets no other document's, whatever values that one holds. + if unique_index_entry_is_shared( + &DocumentInfo::DocumentRefInfo((&contender.document, None)), + vote_poll.index()?, + document_type, + Some(contender.identity_id.to_buffer()), + platform_version, + )? && !self + .drive + .validate_moderated_document_uniqueness( + contract, + document_type, + &contender.document, + None, + transaction, + platform_version, + )? + .is_valid() + { + return Ok(false); + } + + self.award_document_to_winner_v0( + block_info, + contender, + vote_poll, + transaction, + platform_version, + )?; + Ok(true) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v1/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v1/mod.rs index 41e77171bc9..6513dbde366 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v1/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v1/mod.rs @@ -233,15 +233,26 @@ where ContestedDocumentVotePollWinnerInfo::Locked } else { let contender_id = top_contender.identity_id; - // We award the document to the winner of the vote poll - self.award_document_to_winner( + // We award the document to the winner of the vote poll. + // Changed in place for protocol version 15: the award + // tells whether it inserted the document, and a contest + // whose winner the state has no room for ends without + // one. Protocol version 14 selects award version 0, which + // always inserts or returns the insert's error, so + // nothing changes there. + if self.award_document_to_winner( block_info, top_contender, &resolved_contested_document_resource_vote_poll, transaction, platform_version, - )?; - ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_id) + )? { + ContestedDocumentVotePollWinnerInfo::WonByIdentity( + contender_id, + ) + } else { + ContestedDocumentVotePollWinnerInfo::NoWinner + } } } else { ContestedDocumentVotePollWinnerInfo::NoWinner diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs index dd82049e016..90789be97f9 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs @@ -4239,10 +4239,15 @@ pub(in crate::execution) mod tests { use crate::platform_types::platform::PlatformStateRef; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::DefaultForPlatformVersion; + use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ + ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfoV0Getters, + }; use drive::error::drive::DriveError as DriveInnerError; + use drive::grovedb::Transaction; use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::{ DocumentBaseTransitionAction, DocumentBaseTransitionActionV0, }; + use drive::util::object_size_info::{DocumentAndContractInfo, DocumentInfo, OwnedDocumentInfo}; use drive::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::{ DocumentCreateTransitionAction, DocumentCreateTransitionActionV0, }; @@ -5078,6 +5083,403 @@ pub(in crate::execution) mod tests { let result = assert_the_contest_lookup_is_billed(false).await; assert!(result.is_valid(), "{:?}", result.errors); } + + /// The status of the contest of `domain` over `dash` and `normalized_label`, read in + /// `transaction`. + fn contest_status( + platform: &TempPlatform, + contract: &DataContract, + normalized_label: &str, + transaction: &Transaction, + platform_version: &PlatformVersion, + ) -> Option { + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec!["dash".into(), normalized_label.into()], + } + .resolve(&platform.drive, Some(transaction), platform_version) + .expect("expected to resolve the vote poll"); + platform + .drive + .fetch_contested_document_vote_poll_stored_info( + &vote_poll, + None, + Some(transaction), + platform_version, + ) + .expect("expected to fetch the contest's stored info") + .1 + .map(|stored_info| stored_info.vote_poll_status()) + } + + /// On a chain at protocol version 14, stores the contract at `contract_path`, opens a + /// contest with the `contender`'s label and normalized label and creates a second + /// domain with `second`'s without prefunding, both under `dash`. Then runs the first + /// block of the latest protocol version, advances past the poll's end date and runs the + /// resolver. Returns the two creates' results, the resolver's, the contest's status + /// after it and the contender's id. + async fn run_across_activation( + contract_path: &str, + contender_labels: (&str, &str), + second: (&str, &str), + ) -> ( + StateTransitionExecutionResult, + StateTransitionExecutionResult, + Result<(), crate::error::Error>, + Option, + Identifier, + ) { + let platform_version_14 = + PlatformVersion::get(14).expect("expected protocol version 14"); + let platform_version = PlatformVersion::latest(); + + let platform_config = PlatformConfig { + network: Network::Mainnet, + ..Default::default() + }; + let mut platform = TestPlatformBuilder::new() + .with_initial_protocol_version(14) + .with_config(platform_config) + .build_with_mock_rpc() + .with_no_core_masternodes() + .set_genesis_state(); + + let mut rng = StdRng::seed_from_u64(0x0F1E_1D00); + + let contender = setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.5)); + let other = setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.5)); + let contract_owner = setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.5)); + + let contract = setup_contract( + &platform.drive, + contract_path, + None, + Some(contract_owner.0.id().to_buffer()), + None::, + None, + Some(platform_version_14), + ); + + let contested_result = create_domain( + &platform, + &contract, + &contender, + &mut rng, + contender_labels.0, + contender_labels.1, + Some("dash"), + &[], + true, + 3000, + platform_version_14, + ) + .await; + + let second_result = create_domain( + &platform, + &contract, + &other, + &mut rng, + second.0, + second.1, + Some("dash"), + &[], + false, + 4000, + platform_version_14, + ) + .await; + + // The first block of the latest protocol version, through the production dispatcher + let platform_state = platform.state.load_full(); + let mut block_platform_state = PlatformState::clone(&platform_state); + block_platform_state + .set_current_protocol_version_in_consensus(platform_version.protocol_version); + let transaction = platform.drive.grove.start_transaction(); + platform + .perform_events_on_first_block_of_protocol_change( + &platform_state, + &mut block_platform_state, + &BlockInfo { + time_ms: 10_000, + height: 10, + core_height: 42, + epoch: Default::default(), + }, + &transaction, + 14, + platform_version, + ) + .expect("expected the protocol change events to succeed"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit the protocol change"); + platform.state.store(Arc::new(block_platform_state)); + + let after_vote_poll_end = platform_version + .dpp + .voting_versions + .default_vote_poll_time_duration_mainnet_ms + + 10_000; + + fast_forward_to_block(&platform, after_vote_poll_end, 900, 42, 0, false); + + let platform_state = platform.state.load(); + let transaction = platform.drive.grove.start_transaction(); + + let resolver_result = platform.check_for_ended_vote_polls( + &platform_state, + &platform_state, + &BlockInfo { + time_ms: after_vote_poll_end, + height: 900, + core_height: 42, + epoch: Default::default(), + }, + Some(&transaction), + platform_version, + ); + let status = resolver_result.is_ok().then(|| { + contest_status( + &platform, + &contract, + contender_labels.1, + &transaction, + platform_version, + ) + }); + + ( + contested_result, + second_result, + resolver_result, + status.flatten(), + contender.0.id(), + ) + } + + /// A document that took a contest's index values while the chain ran protocol version + /// 14 still holds them when the contest ends at the latest: the award finds no room for + /// the winner, inserts nothing, and the contest ends without a winner. + #[tokio::test] + async fn should_end_without_a_winner_a_contest_whose_values_were_taken_at_protocol_version_14( + ) { + let (contested_result, second_result, resolver_result, status, _) = + run_across_activation(CONTRACT, ("quantum", "quantum"), ("Quantum", "quantum")) + .await; + assert_matches!( + contested_result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "the contender must join the contest" + ); + assert_matches!( + second_result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "protocol version 14 creates the second document with the contender's index \ + values" + ); + assert!( + resolver_result.is_ok(), + "the contest must end; got {:?}", + resolver_result + ); + assert_eq!( + status, + Some(ContestedDocumentVotePollStatus::NotStarted), + "the contest must end without a winner" + ); + } + + /// The same for a document that took the contest's index key with other values: `"\0"` + /// beside the contender's `""`. + #[tokio::test] + async fn should_end_without_a_winner_a_contest_whose_index_key_was_taken_at_protocol_version_14( + ) { + let (contested_result, second_result, resolver_result, status, _) = + run_across_activation(EMPTY_STRING_SPLIT_CONTRACT, ("abc", ""), ("abd", "\0")) + .await; + assert_matches!( + contested_result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "the contender must join the contest" + ); + assert_matches!( + second_result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "protocol version 14 creates the second document under the contender's index key" + ); + assert!( + resolver_result.is_ok(), + "the contest must end; got {:?}", + resolver_result + ); + assert_eq!( + status, + Some(ContestedDocumentVotePollStatus::NotStarted), + "the contest must end without a winner" + ); + } + + /// CONTROL: a contest opened at protocol version 14 whose index values no document took + /// is awarded at the latest. + #[tokio::test] + async fn should_award_a_contest_opened_at_protocol_version_14_whose_values_are_free() { + let (contested_result, second_result, resolver_result, status, contender_id) = + run_across_activation(CONTRACT, ("quantum", "quantum"), ("Quantun", "quantun")) + .await; + assert_matches!( + contested_result, + StateTransitionExecutionResult::SuccessfulExecution { .. } + ); + assert_matches!( + second_result, + StateTransitionExecutionResult::SuccessfulExecution { .. } + ); + assert!( + resolver_result.is_ok(), + "control: got {:?}", + resolver_result + ); + assert_eq!( + status, + Some(ContestedDocumentVotePollStatus::Awarded(contender_id)) + ); + } + + /// A document holding the winner's id leaves the award no room either. No create can + /// produce one from protocol version 14, where an id commits to a nonce used once, so + /// the document is written straight to Drive. + #[tokio::test] + async fn should_end_without_a_winner_a_contest_whose_winners_id_a_document_holds_at_the_latest_protocol_version( + ) { + let platform_version = PlatformVersion::latest(); + let platform_config = PlatformConfig { + network: Network::Mainnet, + ..Default::default() + }; + let mut platform = TestPlatformBuilder::new() + .with_latest_protocol_version() + .with_config(platform_config) + .build_with_mock_rpc() + .set_initial_state_structure(); + + let mut rng = StdRng::seed_from_u64(0x0F1E_1D00); + + let contender = setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.5)); + let contract_owner = setup_identity(&mut platform, rng.gen(), dash_to_credits!(0.5)); + + let contract = setup_contract( + &platform.drive, + CONTRACT, + None, + Some(contract_owner.0.id().to_buffer()), + None::, + None, + Some(platform_version), + ); + + // The same random draws give the same entropy, and so the same id, to a domain + // with other index values + let (document_with_the_id, _) = domain_document( + &contract, + contender.0.id(), + &mut rng.clone(), + "other", + "other", + Some("dash"), + &[], + platform_version, + ); + + let contested_result = create_domain( + &platform, + &contract, + &contender, + &mut rng, + "quantum", + "quantum", + Some("dash"), + &[], + true, + 3000, + platform_version, + ) + .await; + assert_matches!( + contested_result, + StateTransitionExecutionResult::SuccessfulExecution { .. }, + "the contender must join the contest" + ); + + platform + .drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentInfo::DocumentRefInfo(( + &document_with_the_id, + None, + )), + owner_id: Some(contender.0.id().to_buffer()), + }, + contract: &contract, + document_type: contract + .document_type_for_name("domain") + .expect("expected a domain document type"), + }, + false, + BlockInfo::default_with_time(4000), + true, + None, + platform_version, + ) + .expect("expected to write the document holding the winner's id"); + + let after_vote_poll_end = platform_version + .dpp + .voting_versions + .default_vote_poll_time_duration_mainnet_ms + + 10_000; + + fast_forward_to_block(&platform, after_vote_poll_end, 900, 42, 0, false); + + let platform_state = platform.state.load(); + let transaction = platform.drive.grove.start_transaction(); + + let resolver_result = platform.check_for_ended_vote_polls( + &platform_state, + &platform_state, + &BlockInfo { + time_ms: after_vote_poll_end, + height: 900, + core_height: 42, + epoch: Default::default(), + }, + Some(&transaction), + platform_version, + ); + assert!( + resolver_result.is_ok(), + "the contest must end; got {:?}", + resolver_result + ); + assert_eq!( + contest_status( + &platform, + &contract, + "quantum", + &transaction, + platform_version + ), + Some(ContestedDocumentVotePollStatus::NotStarted), + "the contest must end without a winner" + ); + } } /// A contested index keyed by a property path or a system property. A contested create diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v11.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v11.rs index 71c32ad0a62..b641013636c 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v11.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v11.rs @@ -131,6 +131,10 @@ const DKG_MINING_SCHEDULES_V1: &[DkgMiningSchedule] = &[ /// `core_based_updates.masternode_updates.update_voter_identity` is 1 rather than 0: a /// masternode that returns to a voting address it used before has the key of that address's /// voter identity re-enabled, where 0 re-enabled the key of the voter identity it was leaving. +/// +/// `voting.award_document_to_winner` is 1 rather than 0: a contest's winner whose document id or +/// unique index values a document already holds is not inserted, and the contest ends without a +/// winner, where 0 inserted unchecked. pub const DRIVE_ABCI_METHOD_VERSIONS_V11: DriveAbciMethodVersions = DriveAbciMethodVersions { engine: DriveAbciEngineMethodVersions { consensus_params_update: 2, @@ -159,6 +163,7 @@ pub const DRIVE_ABCI_METHOD_VERSIONS_V11: DriveAbciMethodVersions = DriveAbciMet keep_record_of_finished_yes_no_vote_poll: Some(0), clean_up_after_yes_no_vote_polls_end: Some(0), on_yes_no_vote_poll_finished: Some(0), + award_document_to_winner: 1, // changed in v15: a winner whose id or unique index values a document already holds is not awarded, and the contest ends without a winner ..DRIVE_ABCI_METHOD_VERSIONS_V10.voting }, withdrawals: DriveAbciIdentityCreditWithdrawalMethodVersions { diff --git a/packages/rs-platform-version/src/version/v15.rs b/packages/rs-platform-version/src/version/v15.rs index d95e5e9be22..91d9c249b17 100644 --- a/packages/rs-platform-version/src/version/v15.rs +++ b/packages/rs-platform-version/src/version/v15.rs @@ -431,8 +431,16 @@ pub const PROTOCOL_VERSION_15: ProtocolVersion = 15; /// entry Drive keeps per document (`unique_index_entry_is_shared`), nor for an index /// holding a system property (`$ownerId`), whose poll no create can address. A contract /// registered earlier with such a contest keeps it, but an update, which carries the -/// whole contract, is refused like a registration. Protocol v14 and earlier keep -/// `check_document_type_schema` 0 and document create state validation 2. +/// whole contract, is refused like a registration. A document that took the values +/// before the guard, while the chain ran protocol v14, still holds them when the contest +/// ends: `award_document_to_winner` 1 (`DRIVE_ABCI_METHOD_VERSIONS_V11`) runs the two +/// checks of a document create on the winner's document before inserting it (no document +/// holds its id, none holds its unique index values, the second only when the entry is +/// shared) and, when one fails, inserts nothing: the contest is recorded without a +/// winner and cleaned up like any other. Version 0 inserts unchecked and returns the +/// insert's error. Protocol v14 and earlier keep +/// `check_document_type_schema` 0, document create state validation 2 and +/// `award_document_to_winner` 0. /// /// 20. **Asset unlocks with a stable txid once Core's V24 is active**: /// `build_untied_withdrawal_transactions_from_documents` 1 @@ -694,7 +702,7 @@ pub const PLATFORM_V15: PlatformVersion = PlatformVersion { 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, 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 stops a single document lookup at a block time above the pointer to the latest version, and verify_proof_keep_serialized 1 verifies it (note 31); add_new_keys_to_masternode_identity 1 adds a masternode key whose hash the identity already holds a reference for (note 32) drive_abci: DriveAbciVersion { structs: DRIVE_ABCI_STRUCTURE_VERSIONS_V2, - methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32) + methods: DRIVE_ABCI_METHOD_VERSIONS_V11, // changed: the yes/no poll's tally, record, clean-up and finish hook are Some(0) (note 10); verify_chain_lock_locally 1 rejects a chain lock locally only when Platform holds the quorums active at its signing height, and verify_chain_lock_through_core 1 has Core's verifychainlock check the others before submitchainlock; consensus_params_update 2 installs the full evidence policy (note 16); update_core_info 1 records the chain locked height at which Core's V24 is first seen active (note 18); build_untied_withdrawal_transactions_from_documents 1 emits asset unlock payload version 2 once V24 is recorded as active (note 20); update_voter_identity 1 re-enables the voter key of the address a masternode returns to (note 22); update_masternode_list 2 and update_operator_identity 1 make operator payouts and the operator identities' TRANSFER keys follow Core's diffs (note 32); award_document_to_winner 1 awards no winner whose id or unique index values a document holds (note 19) validation_and_processing: DRIVE_ABCI_VALIDATION_VERSIONS_V11, // changed: identity update advanced_structure 1 refuses unpaid an identity update whose added key's proof of possession does not verify (note 2); create_domain_data_trigger 2 (note 3); contract update transform_into_action 1 holds an update to the compiled size cap in check_tx (note 8); batch advanced_structure 2 refuses a token config update on a read-only contract (note 9); masternode vote transform_into_action 1 looks up a masternode's previous answer on a yes/no poll (note 10); document_reference_validation 1 keeps what a consumed commitment's lookup read (note 11); document create structure_validation 2 holds a decision proposal to its fund, rule and end date (note 12); data trigger bindings 3 refuse a replace or a delete of a token market order (note 17) and drop the DashPay bindings (note 24); document create state_validation 3 keeps a create outside a contest off the values of a live one its index values do not decide (note 19); identity create basic_structure 1 checks the identity id before the asset lock proof and advanced_structure 2 no longer does (note 23); contract user moderation transform_into_action 1 writes a moderator's field change in the name of whoever holds the document's storage (note 28) withdrawal_constants: DRIVE_ABCI_WITHDRAWAL_CONSTANTS_V3, query: DRIVE_ABCI_QUERY_VERSIONS_V2,