Skip to content

Commit 8c29f7c

Browse files
bkonturserban300
andauthored
Bump xcm-v3 + substrate (paritytech#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 <[email protected]>
1 parent aa0d008 commit 8c29f7c

File tree

36 files changed

+258
-321
lines changed

36 files changed

+258
-321
lines changed

bridges/bin/millau/node/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
1010

1111
[dependencies]
1212
clap = { version = "4.0.9", features = ["derive"] }
13-
jsonrpsee = { version = "0.15.1", features = ["server"] }
13+
jsonrpsee = { version = "0.16.2", features = ["server"] }
1414
serde_json = "1.0.79"
1515

1616
# Bridge dependencies
@@ -21,14 +21,14 @@ millau-runtime = { path = "../runtime" }
2121

2222
beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" }
2323
beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
24-
beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" }
24+
sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master" }
2525
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
2626
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
2727
node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" }
28-
pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
28+
mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
2929
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
3030
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" }
31-
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
31+
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master"}
3232
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
3333
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
3434
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }

bridges/bin/millau/node/src/chain_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use beefy_primitives::crypto::AuthorityId as BeefyId;
1817
use millau_runtime::{
1918
AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig,
2019
BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig,
2120
SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY,
2221
};
22+
use sp_beefy::crypto::AuthorityId as BeefyId;
2323
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
2424
use sp_core::{sr25519, Pair, Public};
2525
use sp_finality_grandpa::AuthorityId as GrandpaId;

bridges/bin/millau/node/src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
272272
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
273273

274274
use beefy_gadget_rpc::{Beefy, BeefyApiServer};
275-
use pallet_mmr_rpc::{Mmr, MmrApiServer};
275+
use mmr_rpc::{Mmr, MmrApiServer};
276276
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
277277
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
278278
use sc_rpc::DenyUnsafe;
@@ -391,7 +391,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
391391
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
392392

393393
let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name();
394-
let payload_provider = beefy_primitives::mmr::MmrRootProvider::new(client.clone());
394+
let payload_provider = sp_beefy::mmr::MmrRootProvider::new(client.clone());
395395
let beefy_params = beefy_gadget::BeefyParams {
396396
client: client.clone(),
397397
backend,

bridges/bin/millau/runtime/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pallet-shift-session-manager = { path = "../../../modules/shift-session-manager"
3131

3232
# Substrate Dependencies
3333

34-
beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
34+
sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
3535
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
3636
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
3737
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 =
5656
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5757
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5858
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
59-
sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6059
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6160
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6261
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
8180
[features]
8281
default = ["std"]
8382
std = [
84-
"beefy-primitives/std",
83+
"sp-beefy/std",
8584
"bp-messages/std",
8685
"bp-millau/std",
8786
"bp-parachains/std",

bridges/bin/millau/runtime/src/lib.rs

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ pub mod rialto_messages;
3232
pub mod rialto_parachain_messages;
3333
pub mod xcm_config;
3434

35-
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
3635
use bp_parachains::SingleParaStoredHeaderDataBuilder;
3736
use bp_runtime::HeaderId;
3837
use pallet_grandpa::{
3938
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
4039
};
4140
use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo};
4241
use sp_api::impl_runtime_apis;
42+
use sp_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
4343
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
4444
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
45-
use sp_mmr_primitives::{DataOrHash, EncodableOpaqueLeaf, Error as MmrError, Proof as MmrProof};
4645
use sp_runtime::{
4746
create_runtime_str, generic, impl_opaque_keys,
4847
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
@@ -64,7 +63,8 @@ pub use frame_support::{
6463
parameter_types,
6564
traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
6665
weights::{
67-
constants::WEIGHT_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight,
66+
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight,
67+
Weight,
6868
},
6969
RuntimeDebug, StorageValue,
7070
};
@@ -281,7 +281,7 @@ parameter_types! {
281281

282282
pub struct BeefyDummyDataProvider;
283283

284-
impl beefy_primitives::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
284+
impl sp_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider {
285285
fn extra_data() {}
286286
}
287287

@@ -766,62 +766,30 @@ impl_runtime_apis! {
766766
}
767767
}
768768

769-
impl beefy_primitives::BeefyApi<Block> for Runtime {
769+
impl sp_beefy::BeefyApi<Block> for Runtime {
770770
fn validator_set() -> Option<ValidatorSet<BeefyId>> {
771771
Beefy::validator_set()
772772
}
773773
}
774774

775-
impl sp_mmr_primitives::MmrApi<Block, mmr::Hash, BlockNumber> for Runtime {
776-
fn generate_proof(block_number: BlockNumber)
777-
-> Result<(EncodableOpaqueLeaf, MmrProof<mmr::Hash>), MmrError>
778-
{
779-
Mmr::generate_batch_proof(vec![block_number])
780-
.and_then(|(leaves, proof)| Ok((
781-
mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]),
782-
mmr::BatchProof::into_single_leaf_proof(proof)?
783-
)))
784-
}
785-
786-
fn verify_proof(leaf: EncodableOpaqueLeaf, proof: MmrProof<mmr::Hash>)
787-
-> Result<(), MmrError>
788-
{
789-
let leaf: mmr::Leaf = leaf
790-
.into_opaque_leaf()
791-
.try_decode()
792-
.ok_or(MmrError::Verify)?;
793-
Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof))
794-
}
795-
796-
fn verify_proof_stateless(
797-
root: mmr::Hash,
798-
leaf: EncodableOpaqueLeaf,
799-
proof: MmrProof<mmr::Hash>
800-
) -> Result<(), MmrError> {
801-
let node = DataOrHash::Data(leaf.into_opaque_leaf());
802-
pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(
803-
root,
804-
vec![node],
805-
pallet_mmr::primitives::Proof::into_batch_proof(proof),
806-
)
807-
}
808-
809-
fn mmr_root() -> Result<mmr::Hash, MmrError> {
775+
impl pallet_mmr::primitives::MmrApi<
776+
Block,
777+
mmr::Hash,
778+
BlockNumber,
779+
> for Runtime {
780+
fn mmr_root() -> Result<mmr::Hash, mmr::Error> {
810781
Ok(Mmr::mmr_root())
811782
}
812783

813-
fn generate_batch_proof(block_numbers: Vec<BlockNumber>)
814-
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<mmr::Hash>), mmr::Error>
815-
{
816-
Mmr::generate_batch_proof(block_numbers)
817-
.map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof))
784+
fn mmr_leaf_count() -> Result<mmr::LeafIndex, mmr::Error> {
785+
Ok(Mmr::mmr_leaves())
818786
}
819787

820-
fn generate_historical_batch_proof(
788+
fn generate_proof(
821789
block_numbers: Vec<BlockNumber>,
822-
best_known_block_number: BlockNumber
823-
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<mmr::Hash>), mmr::Error> {
824-
Mmr::generate_historical_batch_proof(block_numbers, best_known_block_number).map(
790+
best_known_block_number: Option<BlockNumber>,
791+
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::Proof<mmr::Hash>), mmr::Error> {
792+
Mmr::generate_proof(block_numbers, best_known_block_number).map(
825793
|(leaves, proof)| {
826794
(
827795
leaves
@@ -834,7 +802,7 @@ impl_runtime_apis! {
834802
)
835803
}
836804

837-
fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<mmr::Hash>)
805+
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::Proof<mmr::Hash>)
838806
-> Result<(), mmr::Error>
839807
{
840808
let leaves = leaves.into_iter().map(|leaf|
@@ -844,10 +812,10 @@ impl_runtime_apis! {
844812
Mmr::verify_leaves(leaves, proof)
845813
}
846814

847-
fn verify_batch_proof_stateless(
815+
fn verify_proof_stateless(
848816
root: mmr::Hash,
849817
leaves: Vec<mmr::EncodableOpaqueLeaf>,
850-
proof: mmr::BatchProof<mmr::Hash>
818+
proof: mmr::Proof<mmr::Hash>
851819
) -> Result<(), mmr::Error> {
852820
let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect();
853821
pallet_mmr::verify_leaves_proof::<mmr::Hashing, _>(root, nodes, proof)

bridges/bin/millau/runtime/src/xcm_config.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use bridge_runtime_common::{
3232
use frame_support::{
3333
parameter_types,
3434
traits::{ConstU32, Everything, Nothing},
35+
weights::Weight,
3536
};
3637
use xcm::latest::prelude::*;
3738
use xcm_builder::{
@@ -97,7 +98,8 @@ pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000;
9798

9899
parameter_types! {
99100
/// The amount of weight an XCM operation takes. This is a safe overestimate.
100-
pub const BaseXcmWeight: u64 = BASE_XCM_WEIGHT;
101+
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026?
102+
pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0);
101103
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
102104
/// calculations getting too crazy.
103105
pub const MaxInstructions: u32 = 100;
@@ -150,6 +152,7 @@ impl xcm_executor::Config for XcmConfig {
150152
type MessageExporter = ();
151153
type UniversalAliases = Nothing;
152154
type CallDispatcher = RuntimeCall;
155+
type SafeCallFilter = Everything;
153156
}
154157

155158
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
@@ -159,6 +162,11 @@ pub type LocalOriginToLocation = (
159162
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
160163
);
161164

165+
#[cfg(feature = "runtime-benchmarks")]
166+
parameter_types! {
167+
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");
168+
}
169+
162170
impl pallet_xcm::Config for Runtime {
163171
type RuntimeEvent = RuntimeEvent;
164172
// 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 {
188196
type TrustedLockers = ();
189197
type SovereignAccountOf = SovereignAccountOf;
190198
type MaxLockers = frame_support::traits::ConstU32<8>;
199+
type WeightInfo = pallet_xcm::TestWeightInfo;
200+
#[cfg(feature = "runtime-benchmarks")]
201+
type ReachableDest = ReachableDest;
191202
}
192203

193204
/// With-Rialto bridge.

bridges/bin/rialto-parachain/node/Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ codec = { package = 'parity-scale-codec', version = '3.1.5' }
2323
serde = { version = '1.0', features = ['derive'] }
2424

2525
# RPC related Dependencies
26-
jsonrpsee = { version = "0.15.1", features = ["server"] }
26+
jsonrpsee = { version = "0.16.2", features = ["server"] }
2727

2828
# Local Dependencies
2929
rialto-parachain-runtime = { path = '../runtime' }
@@ -47,8 +47,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", branch = "maste
4747
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
4848
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
4949
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
50-
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", features = ['wasmtime'] }
51-
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
50+
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master"}
5251
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
5352
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
5453
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -74,8 +73,6 @@ cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch
7473
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
7574
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
7675
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
77-
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
78-
cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "master" }
7976

8077
# Polkadot dependencies
8178
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }

bridges/bin/rialto-parachain/node/src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
1616

17+
#![allow(clippy::large_enum_variant)]
18+
1719
use crate::chain_spec;
1820
use clap::Parser;
1921
use std::path::PathBuf;

bridges/bin/rialto-parachain/node/src/command.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ macro_rules! construct_async_run {
138138
runner.async_run(|$config| {
139139
let $components = new_partial::<
140140
RuntimeApi,
141-
ParachainRuntimeExecutor,
142141
_
143142
>(
144143
&$config,

0 commit comments

Comments
 (0)