mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Companion for: pallet-mmr: move offchain logic to client-side gadget (#6321)
* Spawn MMR gadget when offchain indexing is enabled
* companion PR code review changes: 1st iteration
* Code review changes: 2nd iteration
* update lockfile for {"substrate"}
Co-authored-by: acatangiu <adrian@parity.io>
Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+204
-181
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,8 @@ beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "
|
|||||||
beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
mmr-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master"}
|
||||||
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ pub use polkadot_client::PolkadotExecutorDispatch;
|
|||||||
|
|
||||||
pub use chain_spec::{KusamaChainSpec, PolkadotChainSpec, RococoChainSpec, WestendChainSpec};
|
pub use chain_spec::{KusamaChainSpec, PolkadotChainSpec, RococoChainSpec, WestendChainSpec};
|
||||||
pub use consensus_common::{block_validation::Chain, Proposal, SelectChain};
|
pub use consensus_common::{block_validation::Chain, Proposal, SelectChain};
|
||||||
|
use mmr_gadget::MmrGadget;
|
||||||
#[cfg(feature = "full-node")]
|
#[cfg(feature = "full-node")]
|
||||||
pub use polkadot_client::{
|
pub use polkadot_client::{
|
||||||
AbstractClient, Client, ClientHandle, ExecuteWithClient, FullBackend, FullClient,
|
AbstractClient, Client, ClientHandle, ExecuteWithClient, FullBackend, FullClient,
|
||||||
@@ -758,6 +759,7 @@ where
|
|||||||
{
|
{
|
||||||
use polkadot_node_network_protocol::request_response::IncomingRequest;
|
use polkadot_node_network_protocol::request_response::IncomingRequest;
|
||||||
|
|
||||||
|
let is_offchain_indexing_enabled = config.offchain_worker.indexing_enabled;
|
||||||
let role = config.role.clone();
|
let role = config.role.clone();
|
||||||
let force_authoring = config.force_authoring;
|
let force_authoring = config.force_authoring;
|
||||||
let backoff_authoring_blocks = {
|
let backoff_authoring_blocks = {
|
||||||
@@ -1219,6 +1221,18 @@ where
|
|||||||
} else {
|
} else {
|
||||||
task_manager.spawn_handle().spawn_blocking("beefy-gadget", None, gadget);
|
task_manager.spawn_handle().spawn_blocking("beefy-gadget", None, gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if is_offchain_indexing_enabled {
|
||||||
|
task_manager.spawn_handle().spawn_blocking(
|
||||||
|
"mmr-gadget",
|
||||||
|
None,
|
||||||
|
MmrGadget::start(
|
||||||
|
client.clone(),
|
||||||
|
backend.clone(),
|
||||||
|
sp_mmr_primitives::INDEXING_PREFIX.to_vec(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = grandpa::Config {
|
let config = grandpa::Config {
|
||||||
|
|||||||
@@ -1694,6 +1694,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
Err(mmr::Error::PalletNotIncluded)
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
|
||||||
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_proof(
|
fn generate_proof(
|
||||||
_block_numbers: Vec<BlockNumber>,
|
_block_numbers: Vec<BlockNumber>,
|
||||||
_best_known_block_number: Option<BlockNumber>,
|
_best_known_block_number: Option<BlockNumber>,
|
||||||
|
|||||||
@@ -1851,6 +1851,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
Err(mmr::Error::PalletNotIncluded)
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
|
||||||
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_proof(
|
fn generate_proof(
|
||||||
_block_numbers: Vec<BlockNumber>,
|
_block_numbers: Vec<BlockNumber>,
|
||||||
_best_known_block_number: Option<BlockNumber>,
|
_best_known_block_number: Option<BlockNumber>,
|
||||||
|
|||||||
@@ -1224,7 +1224,7 @@ impl pallet_beefy::Config for Runtime {
|
|||||||
type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
|
type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
|
||||||
|
|
||||||
impl pallet_mmr::Config for Runtime {
|
impl pallet_mmr::Config for Runtime {
|
||||||
const INDEXING_PREFIX: &'static [u8] = b"mmr";
|
const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX;
|
||||||
type Hashing = Keccak256;
|
type Hashing = Keccak256;
|
||||||
type Hash = MmrHash;
|
type Hash = MmrHash;
|
||||||
type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
|
type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
|
||||||
@@ -1715,6 +1715,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
Ok(Mmr::mmr_root())
|
Ok(Mmr::mmr_root())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
|
||||||
|
Ok(Mmr::mmr_leaves())
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_proof(
|
fn generate_proof(
|
||||||
block_numbers: Vec<BlockNumber>,
|
block_numbers: Vec<BlockNumber>,
|
||||||
best_known_block_number: Option<BlockNumber>,
|
best_known_block_number: Option<BlockNumber>,
|
||||||
|
|||||||
@@ -930,6 +930,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
Err(mmr::Error::PalletNotIncluded)
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
|
||||||
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
|
}
|
||||||
|
|
||||||
fn generate_proof(
|
fn generate_proof(
|
||||||
_block_numbers: Vec<BlockNumber>,
|
_block_numbers: Vec<BlockNumber>,
|
||||||
_best_known_block_number: Option<BlockNumber>,
|
_best_known_block_number: Option<BlockNumber>,
|
||||||
|
|||||||
@@ -1450,7 +1450,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
|
|
||||||
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
|
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
|
||||||
fn mmr_root() -> Result<Hash, mmr::Error> {
|
fn mmr_root() -> Result<Hash, mmr::Error> {
|
||||||
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
|
||||||
Err(mmr::Error::PalletNotIncluded)
|
Err(mmr::Error::PalletNotIncluded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user