mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 13:31:04 +00:00
MMR: move RPC code from frame/ to client/ (#12805)
* mmr: move MMR RPC from frame/ to client/ Signed-off-by: Adrian Catangiu <adrian@parity.io> * client/mmr: adjust logging levels to avoid spam * cargo fmt * remove unused imports Signed-off-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Generated
+17
-17
@@ -4253,6 +4253,22 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mmr-rpc"
|
||||||
|
version = "4.0.0-dev"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"jsonrpsee",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sp-api",
|
||||||
|
"sp-blockchain",
|
||||||
|
"sp-core",
|
||||||
|
"sp-mmr-primitives",
|
||||||
|
"sp-runtime",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mockall"
|
name = "mockall"
|
||||||
version = "0.11.2"
|
version = "0.11.2"
|
||||||
@@ -4685,8 +4701,8 @@ name = "node-rpc"
|
|||||||
version = "3.0.0-dev"
|
version = "3.0.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jsonrpsee",
|
"jsonrpsee",
|
||||||
|
"mmr-rpc",
|
||||||
"node-primitives",
|
"node-primitives",
|
||||||
"pallet-mmr-rpc",
|
|
||||||
"pallet-transaction-payment-rpc",
|
"pallet-transaction-payment-rpc",
|
||||||
"sc-chain-spec",
|
"sc-chain-spec",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
@@ -5682,22 +5698,6 @@ dependencies = [
|
|||||||
"sp-std",
|
"sp-std",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pallet-mmr-rpc"
|
|
||||||
version = "3.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"jsonrpsee",
|
|
||||||
"parity-scale-codec",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"sp-api",
|
|
||||||
"sp-blockchain",
|
|
||||||
"sp-core",
|
|
||||||
"sp-mmr-primitives",
|
|
||||||
"sp-runtime",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pallet-multisig"
|
name = "pallet-multisig"
|
||||||
version = "4.0.0-dev"
|
version = "4.0.0-dev"
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ members = [
|
|||||||
"client/informant",
|
"client/informant",
|
||||||
"client/keystore",
|
"client/keystore",
|
||||||
"client/merkle-mountain-range",
|
"client/merkle-mountain-range",
|
||||||
|
"client/merkle-mountain-range/rpc",
|
||||||
"client/network",
|
"client/network",
|
||||||
"client/network-gossip",
|
"client/network-gossip",
|
||||||
"client/network/bitswap",
|
"client/network/bitswap",
|
||||||
@@ -108,7 +109,6 @@ members = [
|
|||||||
"frame/lottery",
|
"frame/lottery",
|
||||||
"frame/membership",
|
"frame/membership",
|
||||||
"frame/merkle-mountain-range",
|
"frame/merkle-mountain-range",
|
||||||
"frame/merkle-mountain-range/rpc",
|
|
||||||
"frame/multisig",
|
"frame/multisig",
|
||||||
"frame/nicks",
|
"frame/nicks",
|
||||||
"frame/node-authorization",
|
"frame/node-authorization",
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
jsonrpsee = { version = "0.15.1", features = ["server"] }
|
jsonrpsee = { version = "0.15.1", features = ["server"] }
|
||||||
node-primitives = { version = "2.0.0", path = "../primitives" }
|
node-primitives = { version = "2.0.0", path = "../primitives" }
|
||||||
pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" }
|
|
||||||
pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" }
|
pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" }
|
||||||
|
mmr-rpc = { version = "4.0.0-dev", path = "../../../client/merkle-mountain-range/rpc/" }
|
||||||
sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
|
sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
|
||||||
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
|
||||||
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
|
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
|
||||||
|
|||||||
@@ -108,11 +108,7 @@ where
|
|||||||
+ Send
|
+ Send
|
||||||
+ 'static,
|
+ 'static,
|
||||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
|
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
|
||||||
C::Api: pallet_mmr_rpc::MmrRuntimeApi<
|
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
|
||||||
Block,
|
|
||||||
<Block as sp_runtime::traits::Block>::Hash,
|
|
||||||
BlockNumber,
|
|
||||||
>,
|
|
||||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||||
C::Api: BabeApi<Block>,
|
C::Api: BabeApi<Block>,
|
||||||
C::Api: BlockBuilder<Block>,
|
C::Api: BlockBuilder<Block>,
|
||||||
@@ -121,7 +117,7 @@ where
|
|||||||
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
|
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
|
||||||
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
|
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
|
||||||
{
|
{
|
||||||
use pallet_mmr_rpc::{Mmr, MmrApiServer};
|
use mmr_rpc::{Mmr, MmrApiServer};
|
||||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||||
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
|
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
|
||||||
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
|
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pallet-mmr-rpc"
|
name = "mmr-rpc"
|
||||||
version = "3.0.0"
|
version = "4.0.0-dev"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
@@ -44,7 +44,7 @@ pub mod test_utils;
|
|||||||
use std::{marker::PhantomData, sync::Arc};
|
use std::{marker::PhantomData, sync::Arc};
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use log::{debug, error, trace, warn};
|
use log::{error, trace, warn};
|
||||||
|
|
||||||
use sc_client_api::{Backend, BlockchainEvents, FinalityNotifications};
|
use sc_client_api::{Backend, BlockchainEvents, FinalityNotifications};
|
||||||
use sc_offchain::OffchainDb;
|
use sc_offchain::OffchainDb;
|
||||||
@@ -110,13 +110,16 @@ where
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
trace!(target: LOG_TARGET, "Finality notification: {:?}", notification);
|
trace!(
|
||||||
debug!(target: LOG_TARGET, "Waiting for MMR pallet to become available ...");
|
target: LOG_TARGET,
|
||||||
|
"Waiting for MMR pallet to become available... (best finalized {:?})",
|
||||||
|
notification.header.number()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!(
|
error!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"Finality notifications stream closed unexpectedly. \
|
"Finality notifications stream closed unexpectedly. \
|
||||||
Couldn't build the canonicalization engine",
|
Couldn't build the canonicalization engine",
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ where
|
|||||||
match self.client.header_metadata(hash) {
|
match self.client.header_metadata(hash) {
|
||||||
Ok(header) => Some(header),
|
Ok(header) => Some(header),
|
||||||
_ => {
|
_ => {
|
||||||
error!(
|
debug!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"Block {} not found. Couldn't {} associated branch.", hash, action
|
"Block {} not found. Couldn't {} associated branch.", hash, action
|
||||||
);
|
);
|
||||||
@@ -168,7 +168,7 @@ where
|
|||||||
canon_key
|
canon_key
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
error!(
|
debug!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"Couldn't canonicalize elem at pos {} using temp key {:?}", pos, temp_key
|
"Couldn't canonicalize elem at pos {} using temp key {:?}", pos, temp_key
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -57,10 +57,17 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use frame_support::{log, weights::Weight};
|
use frame_support::{log, weights::Weight};
|
||||||
|
use sp_mmr_primitives::utils;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{self, One, Saturating},
|
traits::{self, One, Saturating},
|
||||||
SaturatedConversion,
|
SaturatedConversion,
|
||||||
};
|
};
|
||||||
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
|
pub use pallet::*;
|
||||||
|
pub use sp_mmr_primitives::{
|
||||||
|
self as primitives, utils::NodesUtils, Error, LeafDataProvider, LeafIndex, NodeIndex,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
@@ -71,13 +78,6 @@ mod mock;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub use pallet::*;
|
|
||||||
use sp_mmr_primitives::utils;
|
|
||||||
pub use sp_mmr_primitives::{
|
|
||||||
self as primitives, utils::NodesUtils, Error, LeafDataProvider, LeafIndex, NodeIndex,
|
|
||||||
};
|
|
||||||
use sp_std::prelude::*;
|
|
||||||
|
|
||||||
/// The most common use case for MMRs is to store historical block hashes,
|
/// The most common use case for MMRs is to store historical block hashes,
|
||||||
/// so that any point in time in the future we can receive a proof about some past
|
/// so that any point in time in the future we can receive a proof about some past
|
||||||
/// blocks without using excessive on-chain storage.
|
/// blocks without using excessive on-chain storage.
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use sp_runtime::{
|
|||||||
testing::Header,
|
testing::Header,
|
||||||
traits::{BlakeTwo256, IdentityLookup, Keccak256},
|
traits::{BlakeTwo256, IdentityLookup, Keccak256},
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
|
||||||
|
|
||||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
type Block = frame_system::mocking::MockBlock<Test>;
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
|
|||||||
Reference in New Issue
Block a user