Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions book/src/data-model/contested-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ choices are a contender or abstain. A Lock vote is refused with `VoteChoiceNotAl
A contest without locking ends when its join window closes while it still has a single contender,
so that contender is awarded the value without a vote window. Its end-date entry is written at the
end of the join window when the contest opens; the first additional contender moves it to the full
poll duration, which opens the vote window. `getVotePollsByEndDate` shows whichever end applies.
poll duration, which opens the vote window, and removes the join window's end date when no other
contest ends then. `getVotePollsByEndDate` shows whichever end applies.

The moderation charters contract uses this resolution to elect moderation teams.

Expand Down Expand Up @@ -123,4 +124,5 @@ A block ends at most `maximum_vote_polls_to_process` contests (a drive-abci `eve
value, two at protocol version 14), the earliest end date first, so contests due together may end
over several blocks. The cleanup removes each ended contest's
end-date entry, and removes an end date only once none of its contests remain under it; the rest
end in the next blocks.
end in the next blocks. Before that read, a block removes any end date among the first due that
holds no contest, since each would take a place in the read and end nothing.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ use dpp::version::PlatformVersion;
use dpp::voting::contender_structs::FinalizedContender;
use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity;
use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo;
use drive::drive::votes::paths::vote_end_date_queries_tree_path_vec;
use drive::drive::votes::resolved::vote_polls::resolve::VotePollResolver;
use drive::drive::votes::resolved::vote_polls::{ResolvedVotePoll, ResolvedVotePollWithVotes};
use drive::grovedb::TransactionArg;
use drive::query::VotePollsByEndDateDriveQuery;
use drive::util::common::encode::encode_u64;
use itertools::Itertools;
use std::collections::BTreeMap;

impl<C> Platform<C>
where
C: CoreRPCLike,
{
/// Checks for ended vote polls, awarding a tie to the earliest contender
/// Checks for ended vote polls, awarding a tie to the earliest contender, after removing
/// the end dates left with no vote poll among the first due
#[inline(always)]
pub(super) fn check_for_ended_vote_polls_v1(
&self,
Expand All @@ -33,13 +36,32 @@ where
) -> Result<(), Error> {
// let's start by getting the vote polls that have finished. Version 0 carried two
// testnet clean-ups of protocol versions 1 and 2; this version only runs from
// protocol version 14, so it fetches the polls due by the block time and nothing else
// protocol version 14, so it reads only what is due by the block time
let distribute_after_time = block_info.time_ms;
let maximum_vote_polls_to_process = platform_version
.drive_abci
.validation_and_processing
.event_constants
.maximum_vote_polls_to_process;
// An end date with no vote poll under it ends nothing yet takes a slot of the read
// below, so enough of them due before every vote poll would stall them all. Those among
// the first due go before the read; the read then reaches the vote polls behind them.
for empty_end_time in VotePollsByEndDateDriveQuery::execute_no_proof_empty_end_times(
distribute_after_time,
maximum_vote_polls_to_process,
&self.drive,
transaction,
&mut vec![],
platform_version,
)? {
self.drive.grove_delete(
vote_end_date_queries_tree_path_vec().as_slice().into(),
encode_u64(empty_end_time).as_slice(),
transaction,
&mut vec![],
&platform_version.drive,
)?;
}
let vote_polls_by_timestamp =
VotePollsByEndDateDriveQuery::execute_no_proof_for_specialized_end_time_query(
distribute_after_time,
Expand Down
Loading
Loading