mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Dynamically generate CHT roots on a full client (#6944)
* Generate CHT roots on a full client * add changes_trie_root function * Add a test * Line widths * Fix sc-service-test * Clarify comments * Revert comments
This commit is contained in:
@@ -536,3 +536,21 @@ pub fn changes_tries_state_at_block<'a, Block: BlockT>(
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide CHT roots. These are stored on a light client and generated dynamically on a full
|
||||
/// client.
|
||||
pub trait ProvideChtRoots<Block: BlockT> {
|
||||
/// Get headers CHT root for given block. Returns None if the block is not a part of any CHT.
|
||||
fn header_cht_root(
|
||||
&self,
|
||||
cht_size: NumberFor<Block>,
|
||||
block: NumberFor<Block>,
|
||||
) -> sp_blockchain::Result<Option<Block::Hash>>;
|
||||
|
||||
/// Get changes trie CHT root for given block. Returns None if the block is not a part of any CHT.
|
||||
fn changes_trie_cht_root(
|
||||
&self,
|
||||
cht_size: NumberFor<Block>,
|
||||
block: NumberFor<Block>,
|
||||
) -> sp_blockchain::Result<Option<Block::Hash>>;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ use sp_state_machine::{
|
||||
use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata};
|
||||
|
||||
use crate::{
|
||||
backend::{self, NewBlockState},
|
||||
backend::{self, NewBlockState, ProvideChtRoots},
|
||||
blockchain::{
|
||||
self, BlockStatus, HeaderBackend, well_known_cache_keys::Id as CacheKeyId
|
||||
},
|
||||
@@ -456,7 +456,7 @@ impl<Block: BlockT> light::Storage<Block> for Blockchain<Block>
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> light::ChtRootStorage<Block> for Blockchain<Block> {
|
||||
impl<Block: BlockT> ProvideChtRoots<Block> for Blockchain<Block> {
|
||||
fn header_cht_root(
|
||||
&self,
|
||||
_cht_size: NumberFor<Block>,
|
||||
|
||||
@@ -32,7 +32,7 @@ use sp_blockchain::{
|
||||
HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache,
|
||||
Error as ClientError, Result as ClientResult,
|
||||
};
|
||||
use crate::{backend::{AuxStore, NewBlockState}, UsageInfo};
|
||||
use crate::{backend::{AuxStore, NewBlockState}, UsageInfo, ProvideChtRoots};
|
||||
|
||||
/// Remote call request.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
@@ -233,7 +233,7 @@ pub trait FetchChecker<Block: BlockT>: Send + Sync {
|
||||
|
||||
/// Light client blockchain storage.
|
||||
pub trait Storage<Block: BlockT>: AuxStore + HeaderBackend<Block>
|
||||
+ HeaderMetadata<Block, Error=ClientError> + ChtRootStorage<Block>
|
||||
+ HeaderMetadata<Block, Error=ClientError> + ProvideChtRoots<Block>
|
||||
{
|
||||
/// Store new header. Should refuse to revert any finalized blocks.
|
||||
///
|
||||
@@ -263,23 +263,6 @@ pub trait Storage<Block: BlockT>: AuxStore + HeaderBackend<Block>
|
||||
fn usage_info(&self) -> Option<UsageInfo>;
|
||||
}
|
||||
|
||||
/// Light client CHT root storage.
|
||||
pub trait ChtRootStorage<Block: BlockT> {
|
||||
/// Get headers CHT root for given block. Returns None if the block is not pruned (not a part of any CHT).
|
||||
fn header_cht_root(
|
||||
&self,
|
||||
cht_size: NumberFor<Block>,
|
||||
block: NumberFor<Block>,
|
||||
) -> ClientResult<Option<Block::Hash>>;
|
||||
|
||||
/// Get changes trie CHT root for given block. Returns None if the block is not pruned (not a part of any CHT).
|
||||
fn changes_trie_cht_root(
|
||||
&self,
|
||||
cht_size: NumberFor<Block>,
|
||||
block: NumberFor<Block>,
|
||||
) -> ClientResult<Option<Block::Hash>>;
|
||||
}
|
||||
|
||||
/// Remote header.
|
||||
#[derive(Debug)]
|
||||
pub enum LocalOrRemote<Data, Request> {
|
||||
|
||||
Reference in New Issue
Block a user