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
+4 -4
View File
@@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
clap = { version = "4.0.9", features = ["derive"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
jsonrpsee = { version = "0.16.2", features = ["server"] }
serde_json = "1.0.79"
# Bridge dependencies
@@ -21,14 +21,14 @@ millau-runtime = { path = "../runtime" }
beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" }
beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
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" }
node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-basic-authorship = { 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-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
+1 -1
View File
@@ -14,12 +14,12 @@
// 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 millau_runtime::{
AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig,
BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig,
SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY,
};
use sp_beefy::crypto::AuthorityId as BeefyId;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{sr25519, Pair, Public};
use sp_finality_grandpa::AuthorityId as GrandpaId;
+2 -2
View File
@@ -272,7 +272,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
use beefy_gadget_rpc::{Beefy, BeefyApiServer};
use pallet_mmr_rpc::{Mmr, MmrApiServer};
use mmr_rpc::{Mmr, MmrApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
use sc_rpc::DenyUnsafe;
@@ -391,7 +391,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name();
let payload_provider = beefy_primitives::mmr::MmrRootProvider::new(client.clone());
let payload_provider = sp_beefy::mmr::MmrRootProvider::new(client.clone());
let beefy_params = beefy_gadget::BeefyParams {
client: client.clone(),
backend,
+2 -3
View File
@@ -31,7 +31,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 }
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 }
@@ -56,7 +56,6 @@ sp-consensus-aura = { 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 }
@@ -81,7 +80,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-parachains/std",
+20 -52
View File
@@ -32,7 +32,6 @@ pub mod rialto_messages;
pub mod rialto_parachain_messages;
pub mod xcm_config;
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::HeaderId;
use pallet_grandpa::{
@@ -40,9 +39,9 @@ use pallet_grandpa::{
};
use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo};
use sp_api::impl_runtime_apis;
use sp_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_mmr_primitives::{DataOrHash, EncodableOpaqueLeaf, Error as MmrError, Proof as MmrProof};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
@@ -64,7 +63,8 @@ pub use frame_support::{
parameter_types,
traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
weights::{
constants::WEIGHT_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight,
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight,
Weight,
},
RuntimeDebug, StorageValue,
};
@@ -281,7 +281,7 @@ parameter_types! {
pub struct BeefyDummyDataProvider;
impl beefy_primitives::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
impl sp_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
fn extra_data() {}
}
@@ -766,62 +766,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, mmr::Hash, BlockNumber> for Runtime {
fn generate_proof(block_number: BlockNumber)
-> Result<(EncodableOpaqueLeaf, MmrProof<mmr::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<mmr::Hash>)
-> Result<(), MmrError>
{
let leaf: mmr::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: mmr::Hash,
leaf: EncodableOpaqueLeaf,
proof: MmrProof<mmr::Hash>
) -> Result<(), MmrError> {
let node = DataOrHash::Data(leaf.into_opaque_leaf());
pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(
root,
vec![node],
pallet_mmr::primitives::Proof::into_batch_proof(proof),
)
}
fn mmr_root() -> Result<mmr::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<mmr::Hash>), 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<mmr::Hash>), 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
@@ -834,7 +802,7 @@ impl_runtime_apis! {
)
}
fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<mmr::Hash>)
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::Proof<mmr::Hash>)
-> Result<(), mmr::Error>
{
let leaves = leaves.into_iter().map(|leaf|
@@ -844,10 +812,10 @@ impl_runtime_apis! {
Mmr::verify_leaves(leaves, proof)
}
fn verify_batch_proof_stateless(
fn verify_proof_stateless(
root: mmr::Hash,
leaves: Vec<mmr::EncodableOpaqueLeaf>,
proof: mmr::BatchProof<mmr::Hash>
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::<mmr::Hashing, _>(root, nodes, proof)
+12 -1
View File
@@ -32,6 +32,7 @@ use bridge_runtime_common::{
use frame_support::{
parameter_types,
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -97,7 +98,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;
@@ -150,6 +152,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
@@ -159,6 +162,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
@@ -188,6 +196,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-Rialto bridge.