-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description This PR provides a new `StorageOverrideHandler` type like old `OverrideHandle` to support different ethereum schema and a fallback (runtime API) implementation. But it will automatically determine the ethereum schema version of the runtime based on `block_hash`, and then call the methods of `StorageOverride` implementation corresponding to the schema version. Before : ```rust let schema = fc_storage::onchain_storage_schema(client.as_ref(), block_hash); let handler = overrides .schemas .get(&schema) .unwrap_or(&overrides.fallback); let block = handler.current_block(block_hash); let receipts = handler.current_receipts(block_hash); ``` After: ```rust let block = storage_override.current_block(hash); let receipts = storage_override.current_receipts(hash); ``` ## Addition This PR uses `Option::<EthereumStorageSchema>::None` instead of `EthereumStorageSchema::Undefined`. ```diff /// The schema version for Pallet Ethereum's storage #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum EthereumStorageSchema { - // Undefined, + // deprecated + // #[codec(index = 0)] + // Undefined, + #[codec(index = 1)] V1, + #[codec(index = 2)] V2, + #[codec(index = 3)] V3, } ``` IMO, this is more consistent with the current semantics: use the storage override corresponding to the schema version as the preference. If there is no ethereum schema in the state, use the runtime api as the fallback implementation, like: ```rust fn current_block(&self, at: B::Hash) -> Option<BlockV2> { match self.querier.storage_schema(at) { Some(EthereumStorageSchema::V1) => { SchemaV1StorageOverrideRef::new(&self.querier).current_block(at) } Some(EthereumStorageSchema::V2) => { SchemaV2StorageOverrideRef::new(&self.querier).current_block(at) } Some(EthereumStorageSchema::V3) => { SchemaV3StorageOverrideRef::new(&self.querier).current_block(at) } None => self.fallback.current_block(at), } } ```
- Loading branch information
Showing
32 changed files
with
978 additions
and
1,105 deletions.
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
Oops, something went wrong.