Bump xcm-v3 + substrate (#1767)

* Bump xcm-v3 + substrate

* More fixes

* Added `#[pallet::call_index`

* Fixes for MMR (TODO:plese check)

* More call indexes

* Cumulus bump

* Fixes for mmr

* Fixes for weights

* Fixes for xcm

* MMR fixes + cargo fmt

* Fix some rpc errors (bump jsonrpsee version)

* Fix cumulus stuff

* Fixes cumulus

* clippy

* more clipy

* Fix test + unused deps

* PR fixes

* cargo update (bump xcm-v3)

Co-authored-by: Serban Iorga <serban@parity.io>
This commit is contained in:
Branislav Kontur
2023-01-13 23:23:50 +01:00
committed by Bastian Köcher
parent add2914a5c
commit 5fdc89d651
36 changed files with 258 additions and 321 deletions
+2 -2
View File
@@ -18,12 +18,12 @@ rialto-runtime = { path = "../runtime" }
# Substrate Dependencies
beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master"}
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
+1 -1
View File
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::weights::Weight;
use polkadot_primitives::v2::{AssignmentId, ValidatorId};
use rialto_runtime::{
@@ -24,6 +23,7 @@ use rialto_runtime::{
};
use serde_json::json;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_beefy::crypto::AuthorityId as BeefyId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::{sr25519, Pair, Public};
use sp_finality_grandpa::AuthorityId as GrandpaId;
+2 -4
View File
@@ -26,7 +26,7 @@ pallet-shift-session-manager = { path = "../../../modules/shift-session-manager"
# Substrate Dependencies
beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -51,7 +51,6 @@ sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch =
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -79,7 +78,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
[features]
default = ["std"]
std = [
"beefy-primitives/std",
"sp-beefy/std",
"bp-messages/std",
"bp-millau/std",
"bp-relayers/std",
@@ -104,7 +103,6 @@ std = [
"pallet-grandpa/std",
"pallet-mmr/std",
"pallet-xcm/std",
"sp-mmr-primitives/std",
"pallet-shift-session-manager/std",
"pallet-sudo/std",
"pallet-timestamp/std",
+32 -68
View File
@@ -32,19 +32,15 @@ pub mod millau_messages;
pub mod parachains;
pub mod xcm_config;
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use bp_runtime::HeaderId;
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;
use sp_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_mmr_primitives::{
DataOrHash, EncodableOpaqueLeaf, Error as MmrError, LeafDataProvider, Proof as MmrProof,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys},
@@ -62,7 +58,7 @@ pub use frame_support::{
dispatch::DispatchClass,
parameter_types,
traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight},
StorageValue,
};
@@ -269,9 +265,6 @@ 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;
@@ -300,7 +293,7 @@ parameter_types! {
pub struct BeefyDummyDataProvider;
impl beefy_primitives::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
impl sp_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
fn extra_data() {}
}
@@ -574,6 +567,16 @@ pub type Executive = frame_executive::Executive<
AllPalletsWithSystem,
>;
/// MMR helper types.
mod mmr {
use super::Runtime;
pub use pallet_mmr::primitives::*;
pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
pub type Hash = <Runtime as pallet_mmr::Config>::Hash;
pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
}
impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
@@ -622,66 +625,30 @@ impl_runtime_apis! {
}
}
impl beefy_primitives::BeefyApi<Block> for Runtime {
impl sp_beefy::BeefyApi<Block> for Runtime {
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
Beefy::validator_set()
}
}
impl sp_mmr_primitives::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn generate_proof(block_number: BlockNumber)
-> Result<(EncodableOpaqueLeaf, MmrProof<Hash>), MmrError>
{
Mmr::generate_batch_proof(vec![block_number])
.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>)
-> Result<(), MmrError>
{
pub type Leaf = <
<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider
>::LeafData;
let leaf: Leaf = leaf
.into_opaque_leaf()
.try_decode()
.ok_or(MmrError::Verify)?;
Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof))
}
fn verify_proof_stateless(
root: Hash,
leaf: EncodableOpaqueLeaf,
proof: MmrProof<Hash>
) -> Result<(), MmrError> {
let node = DataOrHash::Data(leaf.into_opaque_leaf());
pallet_mmr::verify_leaves_proof::<MmrHashing, _>(
root,
vec![node],
pallet_mmr::primitives::Proof::into_batch_proof(proof),
)
}
fn mmr_root() -> Result<Hash, MmrError> {
impl pallet_mmr::primitives::MmrApi<
Block,
mmr::Hash,
BlockNumber,
> for Runtime {
fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
Ok(Mmr::mmr_root())
}
fn generate_batch_proof(block_numbers: Vec<BlockNumber>)
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<MmrHash>), mmr::Error>
{
Mmr::generate_batch_proof(block_numbers)
.map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof))
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
Ok(Mmr::mmr_leaves())
}
fn generate_historical_batch_proof(
fn generate_proof(
block_numbers: Vec<BlockNumber>,
best_known_block_number: BlockNumber
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<MmrHash>), mmr::Error> {
Mmr::generate_historical_batch_proof(block_numbers, best_known_block_number).map(
best_known_block_number: Option<BlockNumber>,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::Proof<mmr::Hash>), mmr::Error> {
Mmr::generate_proof(block_numbers, best_known_block_number).map(
|(leaves, proof)| {
(
leaves
@@ -694,26 +661,23 @@ impl_runtime_apis! {
)
}
fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<MmrHash>)
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::Proof<mmr::Hash>)
-> 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>>()?;
.ok_or(mmr::Error::Verify)).collect::<Result<Vec<mmr::Leaf>, mmr::Error>>()?;
Mmr::verify_leaves(leaves, proof)
}
fn verify_batch_proof_stateless(
root: MmrHash,
fn verify_proof_stateless(
root: mmr::Hash,
leaves: Vec<mmr::EncodableOpaqueLeaf>,
proof: mmr::BatchProof<MmrHash>
proof: mmr::Proof<mmr::Hash>
) -> 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)
pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)
}
}
+12 -1
View File
@@ -28,6 +28,7 @@ use bridge_runtime_common::{
use frame_support::{
parameter_types,
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -91,7 +92,8 @@ pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000;
parameter_types! {
/// The amount of weight an XCM operation takes. This is a safe overestimate.
pub const BaseXcmWeight: u64 = BASE_XCM_WEIGHT;
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026?
pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0);
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
/// calculations getting too crazy.
pub const MaxInstructions: u32 = 100;
@@ -142,6 +144,7 @@ impl xcm_executor::Config for XcmConfig {
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = Everything;
}
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
@@ -151,6 +154,11 @@ pub type LocalOriginToLocation = (
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
);
#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = todo!("We dont use benchmarks for pallet_xcm, so if you hit this message, you need to remove this and define value instead");
}
impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// We don't allow any messages to be sent via the transaction yet. This is basically safe to
@@ -180,6 +188,9 @@ impl pallet_xcm::Config for Runtime {
type TrustedLockers = ();
type SovereignAccountOf = SovereignAccountOf;
type MaxLockers = frame_support::traits::ConstU32<8>;
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
}
/// With-Millau bridge.