Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polkadot staging update #1294

Merged
merged 8 commits into from
Jan 25, 2022
Merged
33 changes: 7 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 7 additions & 108 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,6 @@ impl_runtime_apis! {
}

impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime {
fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce {
BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane)
}

fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState {
BridgeRialtoMessages::inbound_unrewarded_relayers_state(lane)
}
Expand Down Expand Up @@ -828,17 +824,16 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

use bp_runtime::messages::DispatchFeePayment;
use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof, prepare_message_proof, prepare_outbound_message};
use bridge_runtime_common::messages;
use pallet_bridge_messages::benchmarking::{
Pallet as MessagesBench,
Config as MessagesConfig,
MessageDeliveryProofParams,
MessageParams,
MessageProofParams,
ProofSize as MessagesProofSize,
};
use rialto_messages::{ToRialtoMessagePayload, WithRialtoMessageBridge};
use rialto_messages::WithRialtoMessageBridge;

impl MessagesConfig<WithRialtoMessagesInstance> for Runtime {
fn maximal_message_size() -> u32 {
Expand All @@ -863,120 +858,24 @@ impl_runtime_apis! {
fn prepare_outbound_message(
params: MessageParams<Self::AccountId>,
) -> (rialto_messages::ToRialtoMessagePayload, Balance) {
let message_payload = vec![0; params.size as usize];
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(
params.sender_account,
);

let message = ToRialtoMessagePayload {
spec_version: 0,
weight: params.size as _,
origin: dispatch_origin,
call: message_payload,
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
};
(message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into())
prepare_outbound_message::<WithRialtoMessageBridge>(params)
}

fn prepare_message_proof(
params: MessageProofParams,
) -> (rialto_messages::FromRialtoMessagesProof, Weight) {
use bp_messages::{MessageKey, storage_keys};
use bridge_runtime_common::{
messages::MessageBridge,
messages_benchmarking::{ed25519_sign, prepare_message_proof},
};
use codec::Encode;
use frame_support::weights::GetDispatchInfo;
use rialto_messages::WithRialtoMessageBridge;
use sp_runtime::traits::{Header, IdentifyAccount};

let remark = match params.size {
MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _],
_ => vec![],
};
let call = Call::System(SystemCall::remark { remark });
let call_weight = call.get_dispatch_info().weight;

let rialto_account_id: bp_rialto::AccountId = Default::default();
let (millau_raw_public, millau_raw_signature) = ed25519_sign(
&call,
&rialto_account_id,
VERSION.spec_version,
bp_runtime::RIALTO_CHAIN_ID,
bp_runtime::MILLAU_CHAIN_ID,
);
let millau_public = MultiSigner::Ed25519(sp_core::ed25519::Public::from_raw(millau_raw_public));
let millau_signature = MultiSignature::Ed25519(sp_core::ed25519::Signature::from_raw(
millau_raw_signature,
));

if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain {
Self::endow_account(&millau_public.clone().into_account());
}

let make_rialto_message_key = |message_key: MessageKey| storage_keys::message_key(
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
&message_key.lane_id, message_key.nonce,
).0;
let make_rialto_outbound_lane_data_key = |lane_id| storage_keys::outbound_lane_data_key(
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
&lane_id,
).0;

let make_rialto_header = |state_root| bp_rialto::Header::new(
0,
Default::default(),
state_root,
Default::default(),
Default::default(),
);

let dispatch_fee_payment = params.dispatch_fee_payment.clone();
prepare_message_proof::<WithRialtoMessageBridge, bp_rialto::Hasher, Runtime, (), _, _, _>(
prepare_message_proof::<Runtime, (), (), WithRialtoMessageBridge, bp_rialto::Header, bp_rialto::Hasher>(
params,
make_rialto_message_key,
make_rialto_outbound_lane_data_key,
make_rialto_header,
call_weight,
bp_message_dispatch::MessagePayload {
spec_version: VERSION.spec_version,
weight: call_weight,
origin: bp_message_dispatch::CallOrigin::<
bp_rialto::AccountId,
MultiSigner,
Signature,
>::TargetAccount(
rialto_account_id,
millau_public,
millau_signature,
),
dispatch_fee_payment,
call: call.encode(),
}.encode(),
&VERSION,
Balance::MAX / 100,
)
}

fn prepare_message_delivery_proof(
params: MessageDeliveryProofParams<Self::AccountId>,
) -> rialto_messages::ToRialtoMessagesDeliveryProof {
use bridge_runtime_common::messages_benchmarking::prepare_message_delivery_proof;
use rialto_messages::WithRialtoMessageBridge;
use sp_runtime::traits::Header;

prepare_message_delivery_proof::<WithRialtoMessageBridge, bp_rialto::Hasher, Runtime, (), _, _>(
prepare_message_delivery_proof::<Runtime, (), WithRialtoMessageBridge, bp_rialto::Header, bp_rialto::Hasher>(
params,
|lane_id| bp_messages::storage_keys::inbound_lane_data_key(
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
&lane_id,
).0,
|state_root| bp_rialto::Header::new(
0,
Default::default(),
state_root,
Default::default(),
Default::default(),
),
)
}

Expand Down
30 changes: 1 addition & 29 deletions bin/rialto/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ sc-consensus-uncles = { git = "https://github.com/paritytech/substrate", branch
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
#sc-finality-grandpa-warp-sync = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand All @@ -77,37 +76,10 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate

# Polkadot Dependencies

polkadot-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }

# Polkadot (parachain) Dependencies

polkadot-approval-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-availability-bitfield-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-availability-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-availability-recovery = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-collator-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-dispute-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-gossip-support = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-network-bridge = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-collation-generation = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-approval-voting = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-av-store = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-backing = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-bitfield-signing = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-candidate-validation = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-chain-api = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-chain-selection = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-parachains-inherent = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-provisioner = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-runtime-api = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-dispute-coordinator = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-network-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-subsystem-util = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-statement-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, features = [ "full-node", "polkadot-native" ] }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
7 changes: 4 additions & 3 deletions bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
pub type ChainSpec =
sc_service::GenericChainSpec<GenesisConfig, polkadot_service::chain_spec::Extensions>;

/// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted
Expand Down Expand Up @@ -104,7 +105,7 @@ impl Alternative {
None,
None,
properties,
None,
Default::default(),
),
Alternative::LocalTestnet => ChainSpec::from_genesis(
"Rialto Local",
Expand All @@ -128,7 +129,7 @@ impl Alternative {
None,
None,
properties,
None,
Default::default(),
),
}
}
Expand Down
Loading