Skip to content

Commit

Permalink
Bump xcm-v3 + substrate (#1767)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
bkontur and serban300 committed Jan 13, 2023
1 parent 5840197 commit 6fc931d
Show file tree
Hide file tree
Showing 38 changed files with 2,437 additions and 1,551 deletions.
2,929 changes: 1,939 additions & 990 deletions Cargo.lock

Large diffs are not rendered by default.

480 changes: 240 additions & 240 deletions Cargo.toml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
Expand All @@ -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",
Expand Down
72 changes: 20 additions & 52 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ 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::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
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},
Expand All @@ -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,
};
Expand Down Expand Up @@ -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() {}
}

Expand Down Expand Up @@ -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
Expand All @@ -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|
Expand All @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion bin/millau/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions bin/rialto-parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ codec = { package = 'parity-scale-codec', version = '3.1.5' }
serde = { version = '1.0', features = ['derive'] }

# RPC related Dependencies
jsonrpsee = { version = "0.15.1", features = ["server"] }
jsonrpsee = { version = "0.16.2", features = ["server"] }

# Local Dependencies
rialto-parachain-runtime = { path = '../runtime' }
Expand All @@ -47,8 +47,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", branch = "maste
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", features = ['wasmtime'] }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master"}
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand All @@ -74,8 +73,6 @@ cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" }
cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "master" }

# Polkadot dependencies
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
Expand Down
2 changes: 2 additions & 0 deletions bin/rialto-parachain/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// 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/>.

#![allow(clippy::large_enum_variant)]

use crate::chain_spec;
use clap::Parser;
use std::path::PathBuf;
Expand Down
1 change: 0 additions & 1 deletion bin/rialto-parachain/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ macro_rules! construct_async_run {
runner.async_run(|$config| {
let $components = new_partial::<
RuntimeApi,
ParachainRuntimeExecutor,
_
>(
&$config,
Expand Down
Loading

0 comments on commit 6fc931d

Please sign in to comment.