Bump Substrate/Polkadot/Cumulus refs (aka Weights v1.5) (#1597)

* update Substrate + Polkadot + Cumulus refs

* Origin -> RuntimeOrigin

* weights v1.5

* update refs once again + `cargo test -p pallet-bridge-grandpa` works

* started work on `cargo test -p pallet-bridge-messages`

* cargo test -p pallet-bridge-relayers

* cargo test -p pallet-bridge-parachains

* cargo test -p millau-runtime

* cargo test -p bridge-runtime-common

* cargo test -p rialto-runtime

* cargo test -p rialto-parachain-runtime

* cargo test -p millau-bridge-node

* cargo test -p rialto-bridge-node

* cargo test -p rialto-parachain-collator

* cargo test -p messages-relay

* cargo test -p parachains-relay

* cargo test -p substrate-relay

* cargo test --all

* cargo check -p millau-runtime --locked --features runtime-benchmarks

* fix remaining test

* fmt

* try to allow clippy failure temporarily

* Revert "try to allow clippy failure temporarily"

This reverts commit d1b6593580f07e0dbeecb7ab0aa92cee98888ed3.

* use min_by

* Revert "use min_by"

This reverts commit 33042f49ed37e8dd0505370289e17f03bf1a56ee.

* Revert "Revert "use min_by""

This reverts commit 1d2204f0b14dc81e5650bb574dedb5fa78c7097d.

* trigger CI

* Revert "trigger CI"

This reverts commit 259d91b5606743bba9d043c69f07eac6c8700ef5.

* new day, new clippy warning

* more clippy issues
This commit is contained in:
Svyatoslav Nikolsky
2022-10-20 10:27:23 +03:00
committed by Bastian Köcher
parent 9e1847d12a
commit a3dc2d2748
66 changed files with 991 additions and 893 deletions
@@ -50,7 +50,7 @@ impl CliEncodeMessage for Millau {
),
};
Ok(millau_runtime::Call::XcmPallet(millau_runtime::XcmCall::send {
Ok(millau_runtime::RuntimeCall::XcmPallet(millau_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
})
@@ -64,7 +64,7 @@ impl CliEncodeMessage for Millau {
bridge_instance_index: u8,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
Ok(match bridge_instance_index {
bridge::MILLAU_TO_RIALTO_INDEX => millau_runtime::Call::BridgeRialtoMessages(
bridge::MILLAU_TO_RIALTO_INDEX => millau_runtime::RuntimeCall::BridgeRialtoMessages(
millau_runtime::MessagesCall::send_message {
lane_id: lane,
payload,
@@ -73,7 +73,7 @@ impl CliEncodeMessage for Millau {
)
.into(),
bridge::MILLAU_TO_RIALTO_PARACHAIN_INDEX =>
millau_runtime::Call::BridgeRialtoParachainMessages(
millau_runtime::RuntimeCall::BridgeRialtoParachainMessages(
millau_runtime::MessagesCall::send_message {
lane_id: lane,
payload,
@@ -69,8 +69,9 @@ mod tests {
}
#[test]
fn rialto_tx_extra_bytes_constant_is_correct() {
let rialto_call =
rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { remark: vec![] });
let rialto_call = rialto_runtime::RuntimeCall::System(rialto_runtime::SystemCall::remark {
remark: vec![],
});
let rialto_tx = Rialto::sign_transaction(
SignParam {
spec_version: 1,
@@ -92,8 +93,9 @@ mod tests {
#[test]
fn millau_tx_extra_bytes_constant_is_correct() {
let millau_call =
millau_runtime::Call::System(millau_runtime::SystemCall::remark { remark: vec![] });
let millau_call = millau_runtime::RuntimeCall::System(millau_runtime::SystemCall::remark {
remark: vec![],
});
let millau_tx = Millau::sign_transaction(
SignParam {
spec_version: 0,
@@ -42,7 +42,7 @@ impl CliEncodeMessage for Rialto {
),
};
Ok(rialto_runtime::Call::XcmPallet(rialto_runtime::XcmCall::send {
Ok(rialto_runtime::RuntimeCall::XcmPallet(rialto_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
})
@@ -56,7 +56,7 @@ impl CliEncodeMessage for Rialto {
bridge_instance_index: u8,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
Ok(match bridge_instance_index {
bridge::RIALTO_TO_MILLAU_INDEX => rialto_runtime::Call::BridgeMillauMessages(
bridge::RIALTO_TO_MILLAU_INDEX => rialto_runtime::RuntimeCall::BridgeMillauMessages(
rialto_runtime::MessagesCall::send_message {
lane_id: lane,
payload,
@@ -42,10 +42,12 @@ impl CliEncodeMessage for RialtoParachain {
),
};
Ok(rialto_parachain_runtime::Call::PolkadotXcm(rialto_parachain_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
})
Ok(rialto_parachain_runtime::RuntimeCall::PolkadotXcm(
rialto_parachain_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
},
)
.into())
}
@@ -57,7 +59,7 @@ impl CliEncodeMessage for RialtoParachain {
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
Ok(match bridge_instance_index {
bridge::RIALTO_PARACHAIN_TO_MILLAU_INDEX =>
rialto_parachain_runtime::Call::BridgeMillauMessages(
rialto_parachain_runtime::RuntimeCall::BridgeMillauMessages(
rialto_parachain_runtime::MessagesCall::send_message {
lane_id: lane,
payload,
+2 -2
View File
@@ -85,7 +85,7 @@ impl Chain for Millau {
const STORAGE_PROOF_OVERHEAD: u32 = bp_millau::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = millau_runtime::SignedBlock;
type Call = millau_runtime::Call;
type Call = millau_runtime::RuntimeCall;
}
impl ChainWithBalances for Millau {
@@ -186,7 +186,7 @@ mod tests {
#[test]
fn parse_transaction_works() {
let unsigned = UnsignedTransaction {
call: millau_runtime::Call::System(millau_runtime::SystemCall::remark {
call: millau_runtime::RuntimeCall::System(millau_runtime::SystemCall::remark {
remark: b"Hello world!".to_vec(),
})
.into(),
@@ -65,7 +65,7 @@ impl Chain for RialtoParachain {
const STORAGE_PROOF_OVERHEAD: u32 = bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = rialto_parachain_runtime::SignedBlock;
type Call = rialto_parachain_runtime::Call;
type Call = rialto_parachain_runtime::RuntimeCall;
}
impl ChainWithBalances for RialtoParachain {
+2 -2
View File
@@ -65,7 +65,7 @@ impl Chain for Rialto {
const STORAGE_PROOF_OVERHEAD: u32 = bp_rialto::EXTRA_STORAGE_PROOF_SIZE;
type SignedBlock = rialto_runtime::SignedBlock;
type Call = rialto_runtime::Call;
type Call = rialto_runtime::RuntimeCall;
}
impl RelayChain for Rialto {
@@ -189,7 +189,7 @@ mod tests {
#[test]
fn parse_transaction_works() {
let unsigned = UnsignedTransaction {
call: rialto_runtime::Call::System(rialto_runtime::SystemCall::remark {
call: rialto_runtime::RuntimeCall::System(rialto_runtime::SystemCall::remark {
remark: b"Hello world!".to_vec(),
})
.into(),
@@ -168,7 +168,7 @@ async fn watch_transaction_status<
loop {
match subscription.next().await {
Some(TransactionStatusOf::<C>::Finalized(block_hash)) => {
Some(TransactionStatusOf::<C>::Finalized((block_hash, _))) => {
// the only "successful" outcome of this method is when the block with transaction
// has been finalized
log::trace!(
@@ -32,7 +32,7 @@ use bridge_runtime_common::messages::{
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
};
use codec::Encode;
use frame_support::weights::{GetDispatchInfo, Weight};
use frame_support::{dispatch::GetDispatchInfo, weights::Weight};
use messages_relay::{message_lane::MessageLane, relay_strategy::RelayStrategy};
use pallet_bridge_messages::{Call as BridgeMessagesCall, Config as BridgeMessagesConfig};
use relay_substrate_client::{
@@ -461,17 +461,23 @@ pub fn select_delivery_transaction_limits<W: pallet_bridge_messages::WeightInfoE
let delivery_tx_base_weight = W::receive_messages_proof_overhead() +
W::receive_messages_proof_outbound_lane_state_overhead();
let delivery_tx_weight_rest = weight_for_delivery_tx - delivery_tx_base_weight;
let max_number_of_messages = std::cmp::min(
delivery_tx_weight_rest / W::receive_messages_proof_messages_overhead(1),
max_unconfirmed_messages_at_inbound_lane,
);
let max_number_of_messages = if delivery_tx_weight_rest.ref_time() /
W::receive_messages_proof_messages_overhead(1).ref_time() <
max_unconfirmed_messages_at_inbound_lane
{
delivery_tx_weight_rest.ref_time() /
W::receive_messages_proof_messages_overhead(1).ref_time()
} else {
max_unconfirmed_messages_at_inbound_lane
};
assert!(
max_number_of_messages > 0,
"Relay should fit at least one message in every delivery transaction",
);
assert!(
weight_for_messages_dispatch >= max_extrinsic_weight / 2,
weight_for_messages_dispatch.ref_time() >= max_extrinsic_weight.ref_time() / 2,
"Relay shall be able to deliver messages with dispatch weight = max_extrinsic_weight / 2",
);
@@ -500,7 +506,9 @@ mod tests {
// i.e. weight reserved for messages dispatch allows dispatch of non-trivial messages.
//
// Any significant change in this values should attract additional attention.
(1024, 216_609_134_667),
//
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
(1024, Weight::from_ref_time(216_609_134_667).set_proof_size(217)),
);
}
}
@@ -653,7 +653,7 @@ mod tests {
.into_iter()
.map(|nonce| bp_messages::OutboundMessageDetails {
nonce,
dispatch_weight: 0,
dispatch_weight: Weight::from_ref_time(0),
size: 0,
delivery_and_dispatch_fee: 0,
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
@@ -730,7 +730,7 @@ mod tests {
for (idx, _) in payload_sizes.iter().enumerate() {
out_msgs_details.push(OutboundMessageDetails::<BalanceOf<Rialto>> {
nonce: idx as MessageNonce,
dispatch_weight: 0,
dispatch_weight: Weight::from_ref_time(0),
size: 0,
delivery_and_dispatch_fee: 0,
dispatch_fee_payment: DispatchFeePayment::AtTargetChain,
@@ -347,7 +347,7 @@ where
// chain. This requires more knowledge of the Target chain, but seems there's no better way
// to solve this now.
let expected_refund_in_target_tokens = if total_prepaid_nonces != 0 {
const WEIGHT_DIFFERENCE: Weight = 100;
const WEIGHT_DIFFERENCE: Weight = Weight::from_ref_time(100);
let (spec_version, transaction_version) =
self.target_client.simple_runtime_version().await?;
@@ -533,7 +533,7 @@ mod tests {
#[test]
fn prepare_dummy_messages_proof_works() {
const DISPATCH_WEIGHT: Weight = 1_000_000;
const DISPATCH_WEIGHT: Weight = Weight::from_ref_time(1_000_000);
const SIZE: u32 = 1_000;
let dummy_proof = prepare_dummy_messages_proof::<Rococo>(1..=10, DISPATCH_WEIGHT, SIZE);
assert_eq!(dummy_proof.0, DISPATCH_WEIGHT);
@@ -563,21 +563,24 @@ mod tests {
#[test]
fn compute_fee_multiplier_returns_sane_results() {
let multiplier: FixedU128 = bp_rialto::WeightToFee::weight_to_fee(&1).into();
let multiplier: FixedU128 =
bp_rialto::WeightToFee::weight_to_fee(&Weight::from_ref_time(1)).into();
let smaller_weight = 1_000_000;
let smaller_adjusted_weight_fee =
multiplier.saturating_mul_int(WeightToFeeOf::<Rialto>::weight_to_fee(&smaller_weight));
let smaller_adjusted_weight_fee = multiplier.saturating_mul_int(
WeightToFeeOf::<Rialto>::weight_to_fee(&Weight::from_ref_time(smaller_weight)),
);
let larger_weight = smaller_weight + 200_000;
let larger_adjusted_weight_fee =
multiplier.saturating_mul_int(WeightToFeeOf::<Rialto>::weight_to_fee(&larger_weight));
let larger_adjusted_weight_fee = multiplier.saturating_mul_int(
WeightToFeeOf::<Rialto>::weight_to_fee(&Weight::from_ref_time(larger_weight)),
);
assert_eq!(
compute_fee_multiplier::<Rialto>(
smaller_adjusted_weight_fee,
smaller_weight,
Weight::from_ref_time(smaller_weight),
larger_adjusted_weight_fee,
larger_weight,
Weight::from_ref_time(larger_weight),
),
multiplier,
);
@@ -589,7 +592,9 @@ mod tests {
compute_prepaid_messages_refund::<Rialto>(
10,
FixedU128::saturating_from_rational(110, 100),
) > (10 * Rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN).into()
) > Rialto::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN
.saturating_mul(10u64)
.ref_time() as _
);
}
}
@@ -678,7 +678,7 @@ pub(crate) mod tests {
(
nonce,
MessageDetails {
dispatch_weight: 1,
dispatch_weight: Weight::from_ref_time(1),
size: 1,
reward: 1,
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
@@ -879,9 +879,11 @@ pub(crate) mod tests {
total_dispatch_weight: Weight,
total_size: u32,
) -> Result<TestSourceChainBalance, TestError> {
Ok(BASE_MESSAGE_DELIVERY_TRANSACTION_COST * (nonces.end() - nonces.start() + 1) +
Ok((Weight::from_ref_time(BASE_MESSAGE_DELIVERY_TRANSACTION_COST) *
(nonces.end() - nonces.start() + 1) +
total_dispatch_weight +
total_size as TestSourceChainBalance)
Weight::from_ref_time(total_size as u64))
.ref_time())
}
}
@@ -916,7 +918,7 @@ pub(crate) mod tests {
max_unrewarded_relayer_entries_at_target: 4,
max_unconfirmed_nonces_at_target: 4,
max_messages_in_single_batch: 4,
max_messages_weight_in_single_batch: 4,
max_messages_weight_in_single_batch: Weight::from_ref_time(4),
max_messages_size_in_single_batch: 4,
relay_strategy: AltruisticStrategy,
},
@@ -295,7 +295,7 @@ impl<P: MessageLane, Strategy: RelayStrategy, SC, TC> MessageDeliveryStrategy<P,
.source_queue()
.iter()
.flat_map(|(_, range)| range.values().map(|details| details.dispatch_weight))
.fold(0, |total, weight| total.saturating_add(weight))
.fold(Weight::from_ref_time(0), |total, weight| total.saturating_add(weight))
}
}
@@ -578,11 +578,11 @@ mod tests {
use super::*;
const DEFAULT_DISPATCH_WEIGHT: Weight = 1;
const DEFAULT_DISPATCH_WEIGHT: Weight = Weight::from_ref_time(1);
const DEFAULT_SIZE: u32 = 1;
const DEFAULT_REWARD: TestSourceChainBalance = CONFIRMATION_TRANSACTION_COST +
BASE_MESSAGE_DELIVERY_TRANSACTION_COST +
DEFAULT_DISPATCH_WEIGHT +
DEFAULT_DISPATCH_WEIGHT.ref_time() +
(DEFAULT_SIZE as TestSourceChainBalance);
type TestRaceState = RaceState<TestSourceHeaderId, TestTargetHeaderId, TestMessagesProof>;
@@ -629,7 +629,7 @@ mod tests {
max_unrewarded_relayer_entries_at_target: 4,
max_unconfirmed_nonces_at_target: 4,
max_messages_in_single_batch: 4,
max_messages_weight_in_single_batch: 4,
max_messages_weight_in_single_batch: Weight::from_ref_time(4),
max_messages_size_in_single_batch: 4,
latest_confirmed_nonces_at_source: vec![(header_id(1), 19)].into_iter().collect(),
lane_source_client: TestSourceClient::default(),
@@ -667,10 +667,10 @@ mod tests {
(race_state, race_strategy)
}
fn proof_parameters(state_required: bool, weight: Weight) -> MessageProofParameters {
fn proof_parameters(state_required: bool, weight: u32) -> MessageProofParameters {
MessageProofParameters {
outbound_state_proof_required: state_required,
dispatch_weight: weight,
dispatch_weight: Weight::from_ref_time(weight as u64),
}
}
@@ -684,7 +684,7 @@ mod tests {
(
idx,
MessageDetails {
dispatch_weight: idx,
dispatch_weight: Weight::from_ref_time(idx),
size: idx as _,
reward: idx as _,
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
@@ -813,7 +813,7 @@ mod tests {
let (state, mut strategy) = prepare_strategy();
// not all queued messages may fit in the batch, because batch has max weight
strategy.max_messages_weight_in_single_batch = 3;
strategy.max_messages_weight_in_single_batch = Weight::from_ref_time(3);
assert_eq!(
strategy.select_nonces_to_deliver(state).await,
Some(((20..=22), proof_parameters(false, 3)))
@@ -827,7 +827,8 @@ mod tests {
// first message doesn't fit in the batch, because it has weight (10) that overflows max
// weight (4)
strategy.strategy.source_queue_mut()[0].1.get_mut(&20).unwrap().dispatch_weight = 10;
strategy.strategy.source_queue_mut()[0].1.get_mut(&20).unwrap().dispatch_weight =
Weight::from_ref_time(10);
assert_eq!(
strategy.select_nonces_to_deliver(state).await,
Some(((20..=20), proof_parameters(false, 10)))
@@ -1023,7 +1024,7 @@ mod tests {
let nonces = source_nonces(
24..=24,
19,
DEFAULT_REWARD - DEFAULT_DISPATCH_WEIGHT,
DEFAULT_REWARD - DEFAULT_DISPATCH_WEIGHT.ref_time(),
dispatch_fee_payment,
);
strategy.strategy.source_nonces_updated(header_id(2), nonces);
@@ -1031,7 +1032,7 @@ mod tests {
strategy.max_unrewarded_relayer_entries_at_target = 100;
strategy.max_unconfirmed_nonces_at_target = 100;
strategy.max_messages_in_single_batch = 100;
strategy.max_messages_weight_in_single_batch = 100;
strategy.max_messages_weight_in_single_batch = Weight::from_ref_time(100);
strategy.max_messages_size_in_single_batch = 100;
strategy.relay_strategy = MixStrategy::new(RelayerMode::Rational);
@@ -1070,7 +1071,7 @@ mod tests {
strategy.max_unrewarded_relayer_entries_at_target = 100;
strategy.max_unconfirmed_nonces_at_target = 100;
strategy.max_messages_in_single_batch = 5;
strategy.max_messages_weight_in_single_batch = 100;
strategy.max_messages_weight_in_single_batch = Weight::from_ref_time(100);
strategy.max_messages_size_in_single_batch = 100;
state.best_finalized_source_header_id_at_best_target = Some(header_id(2));
@@ -55,7 +55,7 @@ impl<Strategy: RelayStrategy> EnforcementStrategy<Strategy> {
let mut hard_selected_count = 0;
let mut soft_selected_count = 0;
let mut selected_weight: Weight = 0;
let mut selected_weight = Weight::from_ref_time(0);
let mut selected_count: MessageNonce = 0;
let hard_selected_begin_nonce =
@@ -77,12 +77,12 @@ impl<Strategy: RelayStrategy> EnforcementStrategy<Strategy> {
hard_selected_begin_nonce,
selected_prepaid_nonces: 0,
selected_unpaid_weight: 0,
selected_unpaid_weight: Weight::from_ref_time(0),
index: 0,
nonce: 0,
details: MessageDetails {
dispatch_weight: 0,
dispatch_weight: Weight::from_ref_time(0),
size: 0,
reward: P::SourceChainBalance::zero(),
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
@@ -105,9 +105,10 @@ impl<Strategy: RelayStrategy> EnforcementStrategy<Strategy> {
// transaction will be rejected by the target runtime, but at least we have tried.
// limit messages in the batch by weight
let new_selected_weight = match selected_weight.checked_add(details.dispatch_weight) {
let new_selected_weight = match selected_weight.checked_add(&details.dispatch_weight) {
Some(new_selected_weight)
if new_selected_weight <= reference.max_messages_weight_in_single_batch =>
if new_selected_weight.ref_time() <=
reference.max_messages_weight_in_single_batch.ref_time() =>
new_selected_weight,
new_selected_weight if selected_count == 0 => {
log::warn!(