Skip to content

Commit 632b3f1

Browse files
feat(platform): remove platform version patching and state migration logic (#2961)
1 parent a0f66ab commit 632b3f1

File tree

15 files changed

+9
-885
lines changed

15 files changed

+9
-885
lines changed

packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,6 @@ Your software version: {}, latest supported protocol version: {}."#,
130130
last_committed_platform_version
131131
};
132132

133-
// Patch platform version and run migrations if we have patches and/or
134-
// migrations defined for this height.
135-
// It modifies the protocol version to function version mapping to apply hotfixes
136-
// Also it performs migrations to fix corrupted state or prepare it for new features
137-
let block_platform_version = if let Some(patched_platform_version) = self
138-
.apply_platform_version_patch_and_migrate_state_for_height(
139-
block_proposal.height,
140-
&mut block_platform_state,
141-
transaction,
142-
)? {
143-
patched_platform_version
144-
} else {
145-
block_platform_version
146-
};
147-
148133
match block_platform_version
149134
.drive_abci
150135
.methods

packages/rs-drive-abci/src/execution/platform_events/block_start/migrate_state/mod.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
/// Clearing the drive cache should happen when a new block is going to be run
22
pub(in crate::execution) mod clear_drive_block_cache;
3-
/// State migration
4-
mod migrate_state;
5-
/// Patch the platform version function mapping and migrate state based on the block height
6-
pub(in crate::execution) mod patch_platform;

packages/rs-drive-abci/src/execution/platform_events/block_start/patch_platform.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/rs-drive-abci/src/platform_types/platform/mod.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,25 +232,16 @@ impl<C> Platform<C> {
232232
drive: Drive,
233233
core_rpc: C,
234234
config: PlatformConfig,
235-
mut platform_state: PlatformState,
235+
platform_state: PlatformState,
236236
checkpoint_platform_states: BTreeMap<BlockHeight, Arc<PlatformState>>,
237237
) -> Result<Platform<C>, Error>
238238
where
239239
C: CoreRPCLike,
240240
{
241241
let height = platform_state.last_committed_block_height();
242-
243-
// Set patched or original platform version as current
244-
let platform_version = platform_state
245-
.apply_all_patches_to_platform_version_up_to_height(height)
246-
.transpose()
247-
.unwrap_or_else(|| {
248-
let platform_version =
249-
PlatformVersion::get(platform_state.current_protocol_version_in_consensus())
250-
.map_err(Error::from);
251-
252-
platform_version
253-
})?;
242+
let platform_version =
243+
PlatformVersion::get(platform_state.current_protocol_version_in_consensus())
244+
.map_err(Error::from)?;
254245

255246
PlatformVersion::set_current(platform_version);
256247

packages/rs-drive-abci/src/platform_types/platform_state/accessors.rs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ use indexmap::IndexMap;
1818
use itertools::Itertools;
1919
use std::collections::BTreeMap;
2020

21-
pub(super) trait PlatformStateV0PrivateMethods {
22-
/// Set patched platform version. It's using to fix urgent bugs as not a part of normal upgrade process
23-
/// The patched version returns from the public current_platform_version getter in case if present.
24-
fn set_patched_platform_version(&mut self, version: Option<&'static PlatformVersion>);
25-
}
26-
2721
/// Platform state methods introduced in version 0 of Platform State Struct
2822
pub trait PlatformStateV0Methods {
2923
/// The last block height or 0 for genesis
@@ -56,14 +50,9 @@ pub trait PlatformStateV0Methods {
5650
fn last_committed_block_info(&self) -> &Option<ExtendedBlockInfo>;
5751
/// Returns the current protocol version that is in consensus.
5852
fn current_protocol_version_in_consensus(&self) -> ProtocolVersion;
59-
/// Patched platform version. Used to fix urgent bugs as not part of normal upgrade process.
60-
/// The patched version returns from the public current_platform_version getter in case if present.
61-
fn patched_platform_version(&self) -> Option<&'static PlatformVersion>;
62-
/// Get the current platform version or patched if present
53+
/// Get the current platform version
6354
fn current_platform_version(&self) -> Result<&'static PlatformVersion, Error> {
64-
self.patched_platform_version().map(Ok).unwrap_or_else(|| {
65-
PlatformVersion::get(self.current_protocol_version_in_consensus()).map_err(Error::from)
66-
})
55+
PlatformVersion::get(self.current_protocol_version_in_consensus()).map_err(Error::from)
6756
}
6857
/// Returns the upcoming protocol version for the next epoch.
6958
fn next_epoch_protocol_version(&self) -> ProtocolVersion;
@@ -211,14 +200,6 @@ pub trait PlatformStateV0Methods {
211200
fn hpmn_active_list_len(&self) -> usize;
212201
}
213202

214-
impl PlatformStateV0PrivateMethods for PlatformState {
215-
/// Set patched platform version. It's using to fix urgent bugs as not a part of normal upgrade process
216-
/// The patched version returns from the public current_platform_version getter in case if present.
217-
fn set_patched_platform_version(&mut self, version: Option<&'static PlatformVersion>) {
218-
self.patched_platform_version = version;
219-
}
220-
}
221-
222203
impl PlatformStateV0Methods for PlatformState {
223204
/// The last block height or 0 for genesis
224205
fn last_committed_block_height(&self) -> u64 {
@@ -349,12 +330,6 @@ impl PlatformStateV0Methods for PlatformState {
349330
self.current_protocol_version_in_consensus
350331
}
351332

352-
/// Patched platform version. Used to fix urgent bugs as not part of normal upgrade process.
353-
/// The patched version returns from the public current_platform_version getter in case if present.
354-
fn patched_platform_version(&self) -> Option<&'static PlatformVersion> {
355-
self.patched_platform_version
356-
}
357-
358333
/// Returns the upcoming protocol version for the next epoch.
359334
fn next_epoch_protocol_version(&self) -> ProtocolVersion {
360335
self.next_epoch_protocol_version

packages/rs-drive-abci/src/platform_types/platform_state/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod accessors;
22
mod masternode_list_changes;
3-
mod patch_platform_version;
43
mod platform_state_for_saving;
54

65
use crate::error::Error;
@@ -46,10 +45,6 @@ pub struct PlatformState {
4645
pub current_validator_set_quorum_hash: QuorumHash,
4746
/// next quorum
4847
pub next_validator_set_quorum_hash: Option<QuorumHash>,
49-
/// This is a modified current platform version based on
50-
/// `current_protocol_version_in_consensus` with some function versions
51-
/// changed to fix an urgent bug that is not a part of normal upgrade process
52-
pub patched_platform_version: Option<&'static PlatformVersion>,
5348
/// current validator set quorums
5449
/// The validator set quorums are a subset of the quorums, but they also contain the list of
5550
/// all members
@@ -109,7 +104,6 @@ impl Debug for PlatformState {
109104
)
110105
.field("full_masternode_list", &self.full_masternode_list)
111106
.field("hpmn_masternode_list", &self.hpmn_masternode_list)
112-
.field("patched_platform_version", &self.patched_platform_version)
113107
.field("previous_fee_versions", &self.previous_fee_versions)
114108
.field(
115109
"chain_lock_validating_quorums",
@@ -142,7 +136,6 @@ impl PlatformState {
142136
next_epoch_protocol_version,
143137
current_validator_set_quorum_hash: QuorumHash::all_zeros(),
144138
next_validator_set_quorum_hash: None,
145-
patched_platform_version: None,
146139
validator_sets: Default::default(),
147140
chain_lock_validating_quorums: SignatureVerificationQuorumSet::new(
148141
&config.chain_lock,

packages/rs-drive-abci/src/platform_types/platform_state/patch_platform_version.rs

Lines changed: 0 additions & 143 deletions
This file was deleted.

packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v0/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl From<PlatformStateForSavingV0> for PlatformState {
6565
next_validator_set_quorum_hash: value
6666
.next_validator_set_quorum_hash
6767
.map(|bytes| QuorumHash::from_byte_array(bytes.to_buffer())),
68-
patched_platform_version: None,
6968
validator_sets: value
7069
.validator_sets
7170
.into_iter()

packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v1/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ impl From<PlatformStateForSavingV1> for PlatformState {
119119
next_validator_set_quorum_hash: value
120120
.next_validator_set_quorum_hash
121121
.map(|bytes| QuorumHash::from_byte_array(bytes.to_buffer())),
122-
patched_platform_version: None,
123122
validator_sets: value
124123
.validator_sets
125124
.into_iter()

0 commit comments

Comments
 (0)