Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

MMR: move RPC code from frame/ to client/ #12805

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ members = [
"client/informant",
"client/keystore",
"client/merkle-mountain-range",
"client/merkle-mountain-range/rpc",
"client/network",
"client/network-gossip",
"client/network/bitswap",
Expand Down Expand Up @@ -108,7 +109,6 @@ members = [
"frame/lottery",
"frame/membership",
"frame/merkle-mountain-range",
"frame/merkle-mountain-range/rpc",
"frame/multisig",
"frame/nicks",
"frame/node-authorization",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
jsonrpsee = { version = "0.15.1", features = ["server"] }
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/" }
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-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
Expand Down
8 changes: 2 additions & 6 deletions bin/node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ where
+ Send
+ 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_mmr_rpc::MmrRuntimeApi<
Block,
<Block as sp_runtime::traits::Block>::Hash,
BlockNumber,
>,
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
Expand All @@ -121,7 +117,7 @@ where
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
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 sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-mmr-rpc"
version = "3.0.0"
name = "mmr-rpc"
version = "4.0.0-dev"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
11 changes: 7 additions & 4 deletions client/merkle-mountain-range/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub mod test_utils;
use std::{marker::PhantomData, sync::Arc};

use futures::StreamExt;
use log::{debug, error, trace, warn};
use log::{error, trace, warn};

use sc_client_api::{Backend, BlockchainEvents, FinalityNotifications};
use sc_offchain::OffchainDb;
Expand Down Expand Up @@ -110,13 +110,16 @@ where
}
},
_ => {
trace!(target: LOG_TARGET, "Finality notification: {:?}", notification);
debug!(target: LOG_TARGET, "Waiting for MMR pallet to become available ...");
trace!(
target: LOG_TARGET,
"Waiting for MMR pallet to become available... (best finalized {:?})",
notification.header.number()
);
},
}
}

warn!(
error!(
target: LOG_TARGET,
"Finality notifications stream closed unexpectedly. \
Couldn't build the canonicalization engine",
Expand Down
4 changes: 2 additions & 2 deletions client/merkle-mountain-range/src/offchain_mmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where
match self.client.header_metadata(hash) {
Ok(header) => Some(header),
_ => {
error!(
debug!(
target: LOG_TARGET,
"Block {} not found. Couldn't {} associated branch.", hash, action
);
Expand Down Expand Up @@ -168,7 +168,7 @@ where
canon_key
);
} else {
error!(
debug!(
target: LOG_TARGET,
"Couldn't canonicalize elem at pos {} using temp key {:?}", pos, temp_key
);
Expand Down
14 changes: 7 additions & 7 deletions frame/merkle-mountain-range/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{log, weights::Weight};
use sp_mmr_primitives::utils;
use sp_runtime::{
traits::{self, One, Saturating},
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")]
mod benchmarking;
Expand All @@ -71,13 +78,6 @@ mod mock;
#[cfg(test)]
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,
/// so that any point in time in the future we can receive a proof about some past
/// blocks without using excessive on-chain storage.
Expand Down
1 change: 0 additions & 1 deletion frame/merkle-mountain-range/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup, Keccak256},
};
use sp_std::prelude::*;

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
Expand Down