-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: emergency version upgrade to v1.3 Protocol Version 2. (#2138)
- Loading branch information
1 parent
f2ded52
commit 48a0332
Showing
15 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/rs-drive-abci/src/execution/engine/consensus_params_update/v0/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...c/execution/platform_events/protocol_upgrade/check_for_desired_protocol_upgrade/v1/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use crate::error::execution::ExecutionError; | ||
use crate::error::Error; | ||
use crate::platform_types::platform::Platform; | ||
|
||
use dpp::version::PlatformVersion; | ||
use drive::dpp::util::deserializer::ProtocolVersion; | ||
|
||
impl<C> Platform<C> { | ||
/// checks for a network upgrade and resets activation window | ||
/// this should only be called on epoch change | ||
pub(super) fn check_for_desired_protocol_upgrade_v1( | ||
&self, | ||
active_hpmns: u32, | ||
platform_version: &PlatformVersion, | ||
) -> Result<Option<ProtocolVersion>, Error> { | ||
let upgrade_percentage_needed = platform_version | ||
.drive_abci | ||
.methods | ||
.protocol_upgrade | ||
.protocol_version_upgrade_percentage_needed; | ||
|
||
let required_upgraded_hpmns = 1 | ||
+ (active_hpmns as u64) | ||
.checked_mul(upgrade_percentage_needed) | ||
.and_then(|product| product.checked_div(100)) | ||
.ok_or(Error::Execution(ExecutionError::Overflow( | ||
"overflow for required block count", | ||
)))?; | ||
|
||
// if we are at an epoch change, check to see if over 75% of blocks of previous epoch | ||
// were on the future version | ||
let protocol_versions_counter = self.drive.cache.protocol_versions_counter.read(); | ||
|
||
let mut versions_passing_threshold = | ||
protocol_versions_counter.versions_passing_threshold(required_upgraded_hpmns); | ||
|
||
if versions_passing_threshold.len() > 1 { | ||
return Err(Error::Execution( | ||
ExecutionError::ProtocolUpgradeIncoherence( | ||
"only at most 1 version should be able to pass the threshold to upgrade", | ||
), | ||
)); | ||
} | ||
|
||
tracing::debug!( | ||
active_hpmns, | ||
required_upgraded_hpmns, | ||
all_votes = ?protocol_versions_counter.global_cache, | ||
?versions_passing_threshold, | ||
"Protocol version voting is finished. we require {} upgraded, {} versions passing the threshold: {:?}", | ||
required_upgraded_hpmns, | ||
versions_passing_threshold.len(), | ||
versions_passing_threshold | ||
); | ||
|
||
if !versions_passing_threshold.is_empty() { | ||
// same as equals 1 | ||
let next_version = versions_passing_threshold.remove(0); | ||
Ok(Some(next_version)) | ||
} else { | ||
Ok(None) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v1/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.