-
Notifications
You must be signed in to change notification settings - Fork 56
fix(drive)!: invalid protocol version is using to deserialize state #1679
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
093e8e0
feat!: persist execution state in platform state
shumkov 817e5b1
chore: verbose debug fro G1Elements
shumkov 8810fca
feat: store protocol version separately
shumkov c880879
chore: some additions
shumkov 5377011
Merge branch 'v1.0-dev' into feat/execution_state
shumkov c4f1cc6
chore: use current protocol version to deserialize state
shumkov 3482c94
chore: keep using aux data
shumkov 168de58
fix: invalid protocol version
shumkov 8f11682
style: fix formatting
shumkov 68abee5
refactor: don't use grovedb directly in drive abci
shumkov 4bb5382
chore: some fixes
shumkov 980d371
refactor: renamings
shumkov 24b742b
refactor: use map instead of if
shumkov 5e6e7f7
refactor: rename methods
shumkov 49f2b20
fix: compilation errors
shumkov 2059f6d
revert: execution -> cache
shumkov 474563d
chore: set initial protocol version on init chain
shumkov a920e33
test: fix tests
shumkov 5a73b52
Merge branch 'v1.0-dev' into feat/execution_state
QuantumExplorer e625f71
chore: introduce store_current_protocol_version
shumkov 9bc285e
docs: remove unnecessary todo
shumkov 76e05c8
revert: platform state versioned conversion
shumkov ec22c04
refactor: move fetch_platform_state into Platform
shumkov f811f09
chore: fix review comments
shumkov 7eefb1c
refactor: remove extra return
shumkov 7eabbce
chore: typo
shumkov 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
This file contains hidden or 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 hidden or 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 hidden or 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: 0 additions & 2 deletions
2
packages/rs-drive-abci/src/execution/platform_events/block_end/mod.rs
This file contains hidden or 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
53 changes: 0 additions & 53 deletions
53
packages/rs-drive-abci/src/execution/platform_events/block_end/store_ephemeral_state/mod.rs
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
...ges/rs-drive-abci/src/execution/platform_events/block_end/store_ephemeral_state/v0/mod.rs
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
32 changes: 32 additions & 0 deletions
32
packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs
This file contains hidden or 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,32 @@ | ||
| use crate::error::execution::ExecutionError; | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::platform_types::platform_state::PlatformState; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::drive::Drive; | ||
| use drive::query::TransactionArg; | ||
|
|
||
| mod v0; | ||
|
|
||
| impl<C> Platform<C> { | ||
| /// Fetches execution state from grovedb storage | ||
| pub fn fetch_platform_state( | ||
| drive: &Drive, | ||
| transaction: TransactionArg, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<Option<PlatformState>, Error> { | ||
| match platform_version | ||
| .drive_abci | ||
| .methods | ||
| .platform_state_storage | ||
| .fetch_platform_state | ||
| { | ||
| 0 => Platform::<C>::fetch_platform_state_v0(drive, transaction, platform_version), | ||
| version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { | ||
| method: "fetch_platform_state".to_string(), | ||
| known_versions: vec![0], | ||
| received: version, | ||
| })), | ||
| } | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/rs-drive-abci/src/execution/storage/fetch_platform_state/v0/mod.rs
This file contains hidden or 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,24 @@ | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::platform_types::platform_state::PlatformState; | ||
| use dpp::serialization::PlatformDeserializableFromVersionedStructure; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::drive::Drive; | ||
| use drive::query::TransactionArg; | ||
|
|
||
| impl<C> Platform<C> { | ||
| pub(super) fn fetch_platform_state_v0( | ||
| drive: &Drive, | ||
| transaction: TransactionArg, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<Option<PlatformState>, Error> { | ||
| drive | ||
| .fetch_platform_state_bytes(transaction, platform_version) | ||
| .map_err(Error::Drive)? | ||
| .map(|bytes| { | ||
| PlatformState::versioned_deserialize(&bytes, platform_version) | ||
| .map_err(Error::Protocol) | ||
| }) | ||
| .transpose() | ||
| } | ||
| } |
This file contains hidden or 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,5 @@ | ||
| mod fetch_platform_state; | ||
| mod store_platform_state; | ||
|
|
||
| pub use fetch_platform_state::*; | ||
| pub use store_platform_state::*; |
32 changes: 32 additions & 0 deletions
32
packages/rs-drive-abci/src/execution/storage/store_platform_state/mod.rs
This file contains hidden or 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,32 @@ | ||
| mod v0; | ||
|
|
||
| use crate::error::execution::ExecutionError; | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::platform_types::platform_state::PlatformState; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::query::TransactionArg; | ||
|
|
||
| impl<C> Platform<C> { | ||
| /// Store the execution state in grovedb storage | ||
| pub fn store_platform_state( | ||
| &self, | ||
| state: &PlatformState, | ||
| transaction: TransactionArg, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| match platform_version | ||
| .drive_abci | ||
| .methods | ||
| .platform_state_storage | ||
| .store_platform_state | ||
| { | ||
| 0 => self.store_platform_state_v0(state, transaction, platform_version), | ||
| version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { | ||
| method: "store_platform_state".to_string(), | ||
| known_versions: vec![0], | ||
| received: version, | ||
| })), | ||
| } | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
packages/rs-drive-abci/src/execution/storage/store_platform_state/v0/mod.rs
This file contains hidden or 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,19 @@ | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::platform_types::platform_state::PlatformState; | ||
| use dpp::serialization::PlatformSerializable; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::query::TransactionArg; | ||
|
|
||
| impl<C> Platform<C> { | ||
| pub(super) fn store_platform_state_v0( | ||
| &self, | ||
| state: &PlatformState, | ||
| transaction: TransactionArg, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| self.drive | ||
| .store_platform_state_bytes(&state.serialize_to_bytes()?, transaction, platform_version) | ||
| .map_err(Error::Drive) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.