-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(drive): platform version patching and state migrations #1941
Merged
QuantumExplorer
merged 38 commits into
v1.0-dev
from
feat/drive/version-patch-and-migrations
Jul 16, 2024
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
be2b0cc
feat(drive): platform version patching and state migrations
shumkov a4d0988
chore: remove duplicate dependency
shumkov b45a1db
refactor: unnecessary reference
shumkov bbad647
docs: update field documentation
shumkov 82dbe71
refactor: fix review comments
shumkov 4e5a790
refactor: move patches to version crate
shumkov 3857883
refactor: rename patch function and move version setting to if condition
shumkov 386cb65
docs: fix comment
shumkov 90e984b
refactor: remove dbg
shumkov 3fb9e7a
docs: reword patched_platform_version doc
shumkov 17c7c72
Merge branch 'refs/heads/v1.0-dev' into feat/drive/version-patch-and-…
shumkov a8f2746
test: use default_minimal_verifications
shumkov fc90dac
chore: add logging to migration function
shumkov 3c68376
modifed yaml file for AWS secrets
vivekgsharma b23e693
updated workflos to use AWS secrets from github secrets
vivekgsharma dacdf32
aws login credentials github secrets
vivekgsharma 9e6312b
added aws account id
vivekgsharma a2e62b7
configre sccache env
vivekgsharma b644ac7
small fix
vivekgsharma 975e57a
fix2
vivekgsharma eb972df
fix
vivekgsharma 25eefa8
fix
vivekgsharma 94bfc42
fix
vivekgsharma 6cb211b
fix_fin
vivekgsharma f7ef6b3
fic
vivekgsharma febed5e
fix
vivekgsharma ffb2607
printing env varibles to see if aws creds are there during the build …
vivekgsharma a9621f3
ci: pass AWS creds to docker build
shumkov 127ceae
build: remove aws debug call
shumkov 4d7eb3e
Changed to github secrets for Rust packages workflows
vivekgsharma f98b441
proto fix
vivekgsharma c0552dc
chore: remove unused once_cell
shumkov 26cd101
chore: kick off CI
shumkov cb923ac
Merge branch 'refs/heads/v1.0-dev' into feat/drive/version-patch-and-…
shumkov b67c6d0
revert: ci changes
shumkov 29e5314
chore: fix code after merging v1
shumkov 5139ca7
Merge branch 'v1.0-dev' into feat/drive/version-patch-and-migrations
shumkov 31734aa
Merge branch 'v1.0-dev' into feat/drive/version-patch-and-migrations
QuantumExplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
30 changes: 30 additions & 0 deletions
30
packages/rs-drive-abci/src/execution/platform_events/block_start/migrate_state/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,30 @@ | ||
use crate::error::Error; | ||
|
||
use dpp::prelude::BlockHeight; | ||
use drive::grovedb::Transaction; | ||
|
||
use crate::platform_types::platform::Platform; | ||
|
||
use crate::platform_types::platform_state::PlatformState; | ||
|
||
impl<C> Platform<C> { | ||
/// Perform state migration based on block height | ||
pub fn migrate_state_for_height( | ||
&self, | ||
height: BlockHeight, | ||
_block_platform_state: &mut PlatformState, | ||
_transaction: &Transaction, | ||
) -> Result<(), Error> { | ||
#[allow(clippy::match_single_binding)] | ||
let is_migrated = match height { | ||
// 30 => self.migration_30_test(block_platform_state, transaction)?, | ||
_ => false, | ||
}; | ||
|
||
if is_migrated { | ||
tracing::debug!("Successfully migrated state for height {}", height); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/rs-drive-abci/src/execution/platform_events/block_start/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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
/// Clearing the drive cache should happen when a new block is going to be run | ||
pub(in crate::execution) mod clear_drive_block_cache; | ||
/// State migration | ||
mod migrate_state; | ||
/// Patch the platform version function mapping and migrate state based on the block height | ||
pub(in crate::execution) mod patch_platform; |
28 changes: 28 additions & 0 deletions
28
packages/rs-drive-abci/src/execution/platform_events/block_start/patch_platform.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,28 @@ | ||
use crate::error::Error; | ||
use crate::platform_types::platform::Platform; | ||
use crate::platform_types::platform_state::PlatformState; | ||
use dpp::prelude::BlockHeight; | ||
use dpp::version::PlatformVersion; | ||
use drive::grovedb::Transaction; | ||
|
||
impl<C> Platform<C> { | ||
/// This function patches platform version and run migrations | ||
/// It modifies protocol version to function version mapping to apply hotfixes | ||
/// Also it performs migrations to fix corrupted state or prepare it for new features | ||
/// | ||
/// This function appends the patch to PlatformState, potentially alter Drive and Platform execution state | ||
/// and returns patched version | ||
pub fn apply_platform_version_patch_and_migrate_state_for_height( | ||
&self, | ||
height: BlockHeight, | ||
platform_state: &mut PlatformState, | ||
transaction: &Transaction, | ||
) -> Result<Option<&'static PlatformVersion>, Error> { | ||
let patched_platform_version = | ||
platform_state.apply_platform_version_patch_for_height(height)?; | ||
|
||
self.migrate_state_for_height(height, platform_state, transaction)?; | ||
|
||
Ok(patched_platform_version) | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to remain here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed to move inside if-condition in run_block_proposal to make PlatformState consistent with patching