mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
update Substrate/Polkadot/Cumulus refs (#1562)
* update Substrate/Polkadot/Cumulus refs * finality-grandpa 0.16 * fix miillau-runtime compilation * fix rialto runtime compilation * fixed rialto-parachain runtime compilation * backport GRANDPA test fixes * helper instead of removed record_all_keys * substrate-relay is compiling * millau-bridge-node at least compiles * rialto-bridge-node at least compiles * rialto-parachain-collator compiles * fixings tests (wip) * fmt * fixed BEEFY alert * clippy * removed unused dep * -extra var * move Leaf to mod mmr * fix benchmarks
This commit is contained in:
committed by
Bastian Köcher
parent
ad38cdb873
commit
95c30c780c
@@ -17,7 +17,7 @@
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use frame_benchmarking_cli::BenchmarkCmd;
|
||||
use rialto_runtime::{Block, RuntimeApi};
|
||||
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
||||
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
@@ -186,34 +186,30 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
// let is_collator = crate::service::IsCollator::No;
|
||||
let overseer_gen = polkadot_service::overseer::RealOverseerGen;
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
match config.role {
|
||||
Role::Light => Err(sc_cli::Error::Service(sc_service::Error::Other(
|
||||
"Light client is not supported by this node".into(),
|
||||
))),
|
||||
_ => {
|
||||
let is_collator = polkadot_service::IsCollator::No;
|
||||
let grandpa_pause = None;
|
||||
let enable_beefy = true;
|
||||
let jaeger_agent = None;
|
||||
let telemetry_worker_handle = None;
|
||||
let program_path = None;
|
||||
let overseer_enable_anyways = false;
|
||||
let is_collator = polkadot_service::IsCollator::No;
|
||||
let grandpa_pause = None;
|
||||
let enable_beefy = true;
|
||||
let jaeger_agent = None;
|
||||
let telemetry_worker_handle = None;
|
||||
let program_path = None;
|
||||
let overseer_enable_anyways = false;
|
||||
|
||||
polkadot_service::new_full::<rialto_runtime::RuntimeApi, ExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
enable_beefy,
|
||||
jaeger_agent,
|
||||
telemetry_worker_handle,
|
||||
program_path,
|
||||
overseer_enable_anyways,
|
||||
overseer_gen,
|
||||
)
|
||||
.map(|full| full.task_manager)
|
||||
.map_err(service_error)
|
||||
},
|
||||
}
|
||||
polkadot_service::new_full::<rialto_runtime::RuntimeApi, ExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
enable_beefy,
|
||||
jaeger_agent,
|
||||
telemetry_worker_handle,
|
||||
program_path,
|
||||
overseer_enable_anyways,
|
||||
overseer_gen,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.map(|full| full.task_manager)
|
||||
.map_err(service_error)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ use bridge_runtime_common::messages::{
|
||||
use pallet_grandpa::{
|
||||
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
|
||||
};
|
||||
use pallet_mmr::primitives as mmr;
|
||||
use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
@@ -252,6 +253,8 @@ impl pallet_babe::Config for Runtime {
|
||||
|
||||
impl pallet_beefy::Config for Runtime {
|
||||
type BeefyId = BeefyId;
|
||||
type MaxAuthorities = MaxAuthorities;
|
||||
type OnNewValidatorSet = MmrLeaf;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
@@ -270,6 +273,9 @@ impl pallet_grandpa::Config for Runtime {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
|
||||
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
|
||||
|
||||
impl pallet_mmr::Config for Runtime {
|
||||
const INDEXING_PREFIX: &'static [u8] = b"mmr";
|
||||
type Hashing = Keccak256;
|
||||
@@ -367,6 +373,7 @@ impl pallet_transaction_payment::Config for Runtime {
|
||||
AdjustmentVariable,
|
||||
MinimumMultiplier,
|
||||
>;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
@@ -484,7 +491,7 @@ construct_runtime!(
|
||||
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>},
|
||||
|
||||
// Consensus support.
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
|
||||
@@ -620,8 +627,11 @@ impl_runtime_apis! {
|
||||
fn generate_proof(leaf_index: u64)
|
||||
-> Result<(EncodableOpaqueLeaf, MmrProof<Hash>), MmrError>
|
||||
{
|
||||
Mmr::generate_proof(leaf_index)
|
||||
.map(|(leaf, proof)| (EncodableOpaqueLeaf::from_leaf(&leaf), proof))
|
||||
Mmr::generate_batch_proof(vec![leaf_index])
|
||||
.and_then(|(leaves, proof)| Ok((
|
||||
mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]),
|
||||
mmr::BatchProof::into_single_leaf_proof(proof)?
|
||||
)))
|
||||
}
|
||||
|
||||
fn verify_proof(leaf: EncodableOpaqueLeaf, proof: MmrProof<Hash>)
|
||||
@@ -635,7 +645,7 @@ impl_runtime_apis! {
|
||||
.into_opaque_leaf()
|
||||
.try_decode()
|
||||
.ok_or(MmrError::Verify)?;
|
||||
Mmr::verify_leaf(leaf, proof)
|
||||
Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof))
|
||||
}
|
||||
|
||||
fn verify_proof_stateless(
|
||||
@@ -643,14 +653,46 @@ impl_runtime_apis! {
|
||||
leaf: EncodableOpaqueLeaf,
|
||||
proof: MmrProof<Hash>
|
||||
) -> Result<(), MmrError> {
|
||||
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
|
||||
let node = DataOrHash::Data(leaf.into_opaque_leaf());
|
||||
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
|
||||
pallet_mmr::verify_leaves_proof::<MmrHashing, _>(
|
||||
root,
|
||||
vec![node],
|
||||
pallet_mmr::primitives::Proof::into_batch_proof(proof),
|
||||
)
|
||||
}
|
||||
|
||||
fn mmr_root() -> Result<Hash, MmrError> {
|
||||
Ok(Mmr::mmr_root())
|
||||
}
|
||||
|
||||
fn generate_batch_proof(leaf_indices: Vec<pallet_mmr::primitives::LeafIndex>)
|
||||
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<MmrHash>), mmr::Error>
|
||||
{
|
||||
Mmr::generate_batch_proof(leaf_indices)
|
||||
.map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof))
|
||||
}
|
||||
|
||||
fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<MmrHash>)
|
||||
-> Result<(), mmr::Error>
|
||||
{
|
||||
type Leaf = <
|
||||
<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider
|
||||
>::LeafData;
|
||||
let leaves = leaves.into_iter().map(|leaf|
|
||||
leaf.into_opaque_leaf()
|
||||
.try_decode()
|
||||
.ok_or(mmr::Error::Verify)).collect::<Result<Vec<Leaf>, mmr::Error>>()?;
|
||||
Mmr::verify_leaves(leaves, proof)
|
||||
}
|
||||
|
||||
fn verify_batch_proof_stateless(
|
||||
root: MmrHash,
|
||||
leaves: Vec<mmr::EncodableOpaqueLeaf>,
|
||||
proof: mmr::BatchProof<MmrHash>
|
||||
) -> Result<(), mmr::Error> {
|
||||
let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
|
||||
pallet_mmr::verify_leaves_proof::<MmrHashing, _>(root, nodes, proof)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_millau::MillauFinalityApi<Block> for Runtime {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::{
|
||||
AccountId, Babe, Balance, Balances, BlockNumber, Call, Event, Origin, Registrar, Runtime,
|
||||
Slots, UncheckedExtrinsic,
|
||||
ShiftSessionManager, Slots, UncheckedExtrinsic,
|
||||
};
|
||||
|
||||
use frame_support::{parameter_types, weights::Weight};
|
||||
@@ -95,7 +95,9 @@ impl parachains_paras_inherent::Config for Runtime {
|
||||
|
||||
impl parachains_scheduler::Config for Runtime {}
|
||||
|
||||
impl parachains_session_info::Config for Runtime {}
|
||||
impl parachains_session_info::Config for Runtime {
|
||||
type ValidatorSet = ShiftSessionManager;
|
||||
}
|
||||
|
||||
impl parachains_shared::Config for Runtime {}
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
type FeeManager = ();
|
||||
type MessageExporter = ();
|
||||
type UniversalAliases = Nothing;
|
||||
type CallDispatcher = Call;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
|
||||
@@ -237,7 +238,7 @@ mod tests {
|
||||
let xcm: Xcm<()> = vec![Instruction::Trap(42)].into();
|
||||
|
||||
let send_result = send_xcm::<XcmRouter>(dest.into(), xcm);
|
||||
let expected_fee = MultiAssets::from((Here, 4_345_002_552_u128));
|
||||
let expected_fee = MultiAssets::from((Here, 4_259_858_152_u128));
|
||||
let expected_hash =
|
||||
([0u8, 0u8, 0u8, 0u8], 1u64).using_encoded(sp_io::hashing::blake2_256);
|
||||
assert_eq!(send_result, Ok((expected_hash, expected_fee)),);
|
||||
|
||||
Reference in New Issue
Block a user