-
Notifications
You must be signed in to change notification settings - Fork 44
feat!: store/fetch reduced platform state in drive #2457
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| use crate::reduced_platform_state::v0::ReducedPlatformStateForSavingV0; | ||
| use crate::serialization::{PlatformSerializable, ReducedPlatformDeserializable}; | ||
|
Check warning on line 2 in packages/rs-dpp/src/reduced_platform_state/mod.rs
|
||
| use crate::ProtocolError; | ||
| use bincode::{config, Decode, Encode}; | ||
| use derive_more::From; | ||
|
Check warning on line 5 in packages/rs-dpp/src/reduced_platform_state/mod.rs
|
||
| use platform_version::version::PlatformVersion; | ||
| use platform_version::TryIntoPlatformVersioned; | ||
|
Check warning on line 7 in packages/rs-dpp/src/reduced_platform_state/mod.rs
|
||
| use serde::{Deserialize, Serialize}; | ||
|
Check warning on line 8 in packages/rs-dpp/src/reduced_platform_state/mod.rs
|
||
|
|
||
| pub mod v0; | ||
|
|
||
| /// Reduced Platform State For Saving | ||
| #[derive(Clone, Debug, Encode, Decode)] | ||
| pub enum ReducedPlatformStateForSaving { | ||
| V0(ReducedPlatformStateForSavingV0), | ||
| } | ||
|
|
||
| impl ReducedPlatformDeserializable for ReducedPlatformStateForSaving { | ||
|
|
||
| fn versioned_deserialize( | ||
| data: &[u8], | ||
| platform_version: &PlatformVersion, | ||
|
Check warning on line 22 in packages/rs-dpp/src/reduced_platform_state/mod.rs
|
||
| ) -> Result<Self, ProtocolError> | ||
| where | ||
| Self: Sized, | ||
| { | ||
| let config = config::standard().with_big_endian().with_no_limit(); | ||
| let reduced_platform_state_in_save_format: ReducedPlatformStateForSaving = | ||
| bincode::decode_from_slice(data, config) | ||
| .map_err(|e| { | ||
| ProtocolError::PlatformDeserializationError(format!( | ||
| "unable to deserialize ReducedPlatformStateForSaving: {}", | ||
| e | ||
| )) | ||
| })? | ||
| .0; | ||
| Ok(reduced_platform_state_in_save_format) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use crate::block::block_info::BlockInfo; | ||
|
Check warning on line 1 in packages/rs-dpp/src/reduced_platform_state/v0/mod.rs
|
||
| use crate::block::extended_block_info::ExtendedBlockInfo; | ||
| use crate::fee::default_costs::EpochIndexFeeVersionsForStorage; | ||
| use crate::util::deserializer::ProtocolVersion; | ||
| use bincode::{Decode, Encode}; | ||
| use platform_value::Bytes32; | ||
|
|
||
| /// Reduced Platform State for Saving V0 | ||
| #[derive(Clone, Debug, Encode, Decode)] | ||
| pub struct ReducedPlatformStateForSavingV0 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you want to duplicate these data in both PlatfromState and ReducedPlatform state? and serialize and store it twice a block? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this complicates the logic, I propose to make a separate PR for this, since it is only an optimisation/refactoring. |
||
| /// Information about the last block | ||
| pub last_committed_block_info: Option<ExtendedBlockInfo>, | ||
| /// Current Version | ||
| pub current_protocol_version_in_consensus: ProtocolVersion, | ||
| /// upcoming protocol version | ||
| pub next_epoch_protocol_version: ProtocolVersion, | ||
| /// current quorum | ||
| pub current_validator_set_quorum_hash: Bytes32, | ||
| /// next quorum | ||
| pub next_validator_set_quorum_hash: Option<Bytes32>, | ||
| /// previous Fee Versions | ||
| pub previous_fee_versions: EpochIndexFeeVersionsForStorage, | ||
| } | ||
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.
💡 Verification agent
🧩 Analysis chain
Consider implementing serialization for symmetry.
The enum only implements deserialization but might need serialization for completeness.
Consider adding serialization implementation:
🏁 Script executed:
Length of output: 8993
Implement serialization for ReducedPlatformStateForSaving
Currently, the enum in the file
packages/rs-dpp/src/reduced_platform_state/mod.rsonly supports deserialization. For consistency with similar types in the repository (e.g., implementations forPlatformStateandCreatedDataContract), add a serialization implementation. For example:This change will provide symmetry between serialization and deserialization for this type.