Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
7d4319d
Bump futures from 0.3.26 to 0.3.27 (#2359)
dependabot[bot] Mar 27, 2023
ea6598c
Bump clap from 4.1.11 to 4.1.13 (#2388)
dependabot[bot] Mar 27, 2023
35d79f3
Remove HeaderBackend from RelayChainRPCClient (#2385)
skunert Mar 28, 2023
0ef1444
Bump scale-info from 2.3.1 to 2.4.0 (#2386)
dependabot[bot] Mar 28, 2023
066db6b
Bump serde_json from 1.0.94 to 1.0.95 (#2387)
dependabot[bot] Mar 28, 2023
1d8208b
Companion: wasm-builder support stable Rust (#2393)
bkchr Mar 29, 2023
559f3ca
Bump thiserror from 1.0.38 to 1.0.40 (#2396)
dependabot[bot] Mar 29, 2023
69dd6ae
Bump syn from 1.0.109 to 2.0.9 (#2397)
dependabot[bot] Mar 29, 2023
247e843
Bump serde from 1.0.156 to 1.0.159 (#2395)
dependabot[bot] Mar 29, 2023
2ce882f
Companion for https://github.com/paritytech/substrate/pull/13725 (#2401)
altonen Mar 30, 2023
3ce4e83
Bump syn from 2.0.9 to 2.0.11 (#2405)
dependabot[bot] Mar 30, 2023
693e973
Bump scale-info from 2.4.0 to 2.5.0 (#2404)
dependabot[bot] Mar 30, 2023
f5340e7
Bump tempfile from 3.4.0 to 3.5.0 (#2406)
dependabot[bot] Mar 30, 2023
337bd17
bump zombienet version (#2411)
pepoviola Mar 30, 2023
826e1aa
Bump tokio from 1.26.0 to 1.27.0 (#2413)
dependabot[bot] Mar 31, 2023
a4188ea
Merge remote-tracking branch 'origin/master' into bridge-hub-rococo-w…
Mar 31, 2023
93d9b6a
Bump syn from 2.0.11 to 2.0.12 (#2414)
dependabot[bot] Mar 31, 2023
b1cd3d5
Bump proc-macro2 from 1.0.52 to 1.0.54 (#2415)
dependabot[bot] Mar 31, 2023
9106fa8
Companion PR for contract deletion updates (#2409)
pgherveou Mar 31, 2023
e5035c8
Allow arbitrary key-values in RelayStateSproofBuilder (#2407)
tmpolaczyk Mar 31, 2023
e5d994b
help text examples + clean up (#2418)
skunert Apr 1, 2023
e67094e
Bump futures from 0.3.27 to 0.3.28 (#2420)
dependabot[bot] Apr 1, 2023
6bdcf1f
Bump clap from 4.1.13 to 4.1.14 (#2421)
dependabot[bot] Apr 1, 2023
66bfb2c
Update Substrate & Polkadot (#2422)
bkchr Apr 3, 2023
d12c6d0
Bump syn from 2.0.12 to 2.0.13 (#2428)
dependabot[bot] Apr 3, 2023
697f0cd
Bump hex-literal from 0.3.4 to 0.4.0 (#2426)
dependabot[bot] Apr 3, 2023
2b4467c
Updated scripts for transfer assets
bkontur Mar 27, 2023
53c6b8d
Companion for #6986 (#2416)
bkontur Apr 4, 2023
5ed3677
[backport] weights 9400 (#2425)
EgorPopelyaev Apr 4, 2023
88ead41
Cleanup: Remove polkadot-service dependency from minimal node (#2430)
skunert Apr 4, 2023
2cbaa39
Co #13699: Remove old calls (#2431)
ggwpez Apr 4, 2023
b49628f
[Backport] version bumps 9400 (#2424)
EgorPopelyaev Apr 5, 2023
d8d5781
Merge branch 'master' into bridge-hub-rococo-wococo
bkontur Apr 5, 2023
25b7b44
Cargo.lock
bkontur Apr 5, 2023
98f6ca7
Bump hex-literal from 0.4.0 to 0.4.1 (#2434)
dependabot[bot] Apr 5, 2023
a5a79db
Updated bridge-hub-polkadot.json (#2435)
bkontur Apr 6, 2023
b0715f9
The Polkadot Fellowship import (#2236)
muharem Apr 9, 2023
dcedafb
Script updates for `ping-via-bridge-from-statemine-rococo`
bkontur Apr 11, 2023
03763dd
Companion for #13302 (#2357)
lexnv Apr 11, 2023
b4a50e2
use stable rust toolchain in ci
Apr 11, 2023
4733416
Bump syn from 2.0.13 to 2.0.14 (#2446)
dependabot[bot] Apr 12, 2023
5a0ebad
Bump serde from 1.0.159 to 1.0.160 (#2445)
dependabot[bot] Apr 12, 2023
a9a6c30
Added `transfer-asset-from-statemine-rococo`
bkontur Apr 12, 2023
030db02
Invoke cargo build commands with `--locked` (#2444)
Apr 12, 2023
8252d87
Finished scripts
bkontur Apr 12, 2023
c70f503
README.md
bkontur Apr 12, 2023
df9ed24
Bump actions/checkout from 3.1.0 to 3.5.1 (#2448)
dependabot[bot] Apr 12, 2023
977587b
Merge remote-tracking branch 'origin/master' into bridge-hub-rococo-w…
Apr 13, 2023
574f425
Bump serde_json from 1.0.95 to 1.0.96 (#2453)
dependabot[bot] Apr 13, 2023
b42855d
Bump actions/checkout from 3.5.1 to 3.5.2 (#2452)
dependabot[bot] Apr 14, 2023
f776496
Merge remote-tracking branch 'origin/master' into bridge-hub-rococo-w…
bkontur Apr 14, 2023
6a12724
Compile fix + log xcm trace all
bkontur Apr 14, 2023
a26ebb2
Bump syn from 2.0.14 to 2.0.15 (#2454)
dependabot[bot] Apr 14, 2023
863e94d
Bump assert_cmd from 2.0.10 to 2.0.11 (#2457)
dependabot[bot] Apr 15, 2023
795fe4e
Initial version of bridges pallet as subtree of https://github.com/pa…
bkontur Apr 14, 2023
f891b32
Merge remote-tracking branch 'origin/master' into bridge-hub-rococo-w…
bkontur Apr 17, 2023
3a8b6ea
Squashed 'bridges/' changes from ecddd4a31..d30927c08
bkontur Apr 17, 2023
4156016
Merge commit '3a8b6ea5290368cb0dbf39e76555d15d380fc194' into bridge-h…
bkontur Apr 17, 2023
20f7a55
Fixes
bkontur Apr 17, 2023
a9e2773
Squashed 'bridges/' content from commit d30927c08
bkontur Apr 17, 2023
71a1d47
Merge commit 'a9e27730296e3269b82cd315aed9d635610f076c' as 'bridges'
bkontur Apr 17, 2023
8f67dc5
Merge branch 'bridge-hub-subtree' into bridge-hub-rococo-wococo
bkontur Apr 17, 2023
1e489dd
Updated REAMDE.md and BRIDGES.md (inspired by original https://github…
bkontur Apr 17, 2023
0670d9f
Squashed 'bridges/' changes from d30927c08..d3970944b
bkontur Apr 17, 2023
71aad1e
Merge commit '0670d9fa5ae67f6f01028440318a723d1b330720' into bridge-h…
bkontur Apr 17, 2023
5b20c4e
Merge branch 'bridge-hub-subtree' into bridge-hub-rococo-wococo
bkontur Apr 17, 2023
72349fc
Changed `query_account_balances` return type (#2455)
bkontur Apr 17, 2023
f2277b6
Squashed 'bridges/' changes from d3970944b..2180797fb
bkontur Apr 18, 2023
873f5cc
Merge commit 'f2277b6f81208bd38a15cb74ebd535c4cd851b32' into bridge-h…
bkontur Apr 18, 2023
8f2b30d
Merge remote-tracking branch 'origin/master' into bridge-hub-subtree
bkontur Apr 18, 2023
6ffe4f3
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur Apr 18, 2023
926799c
Companion for substrate#13883 (#2460)
andresilva Apr 18, 2023
3de5354
Optimize level monitor reconstruction (#2461)
davxy Apr 19, 2023
4449044
Bump clap from 4.1.14 to 4.2.3 (#2465)
dependabot[bot] Apr 19, 2023
ea44f8c
Bump Swatinem/rust-cache from 2.2.0 to 2.2.1 (#2456)
dependabot[bot] Apr 19, 2023
d403b49
Companion for substrate#13771 (#2410)
muharem Apr 19, 2023
eced0cb
Parachain node should not recover blocks while syncing (#2462)
skunert Apr 19, 2023
8615ac8
[Polkadot Companion] for 7101 (#2470)
mrcnski Apr 21, 2023
2c1dd4f
Align BridgeHub runtimes with other SP runtimes + reused test for tel…
bkontur Apr 24, 2023
77c0b76
[ci] Update buildah command and version (#2479)
alvicsam Apr 24, 2023
321e81e
Bump enumflags2 from 0.7.5 to 0.7.7 (#2481)
dependabot[bot] Apr 24, 2023
1ad8cc8
Bump ruby/setup-ruby from 1.133.2 to 1.146.0 (#2466)
dependabot[bot] Apr 25, 2023
383f399
Bump ruby/setup-ruby from 1.146.0 to 1.147.0 (#2484)
dependabot[bot] Apr 26, 2023
e63a06d
Bump actions/download-artifact from 3.0.0 to 3.0.1 (#1798)
dependabot[bot] Apr 26, 2023
b54ccba
Bump actions/upload-artifact from 3.1.0 to 3.1.1 (#1799)
dependabot[bot] Apr 26, 2023
263ebdf
Bump actions/cache from 3.0.11 to 3.2.3 (#2082)
dependabot[bot] Apr 26, 2023
db74a62
Companion for substrate#13565 (#2306)
agryaznov Apr 26, 2023
7e59781
Bump actions/download-artifact from 3.0.1 to 3.0.2 (#2485)
dependabot[bot] Apr 26, 2023
2014997
Bump chevdor/srtool-actions from 0.6.0 to 0.7.0 (#2486)
dependabot[bot] Apr 26, 2023
1e83f6e
Bump actions/upload-artifact from 3.1.1 to 3.1.2 (#2487)
dependabot[bot] Apr 26, 2023
44dfcae
Bump actions/cache from 3.2.3 to 3.3.1 (#2488)
dependabot[bot] Apr 26, 2023
6524f14
Bump h2 from 0.3.9 to 0.3.17 (#2451)
dependabot[bot] Apr 26, 2023
ad6bfdf
Merge remote-tracking branch 'origin/master' into bridge-hub-subtree
bkontur Apr 27, 2023
20647a6
Reused `teleports_for_native_asset_works` test to all bridge-hub runtime
bkontur Apr 13, 2023
c7e5556
Added test case `initialize_bridge_by_governance_works`
bkontur Apr 20, 2023
1dba38d
Added test case `handle_export_message_from_system_parachain_to_outbo…
bkontur Apr 24, 2023
e6fedb9
Added test-case `message_dispatch_routing_works`
bkontur Apr 27, 2023
9c5701c
Squashed 'bridges/' changes from 2180797fbf..4850aac8ce
bkontur Apr 27, 2023
a6bf890
Merge commit '9c5701c8ccafd307cae9abff43e8a3f86e855f47' into bridge-h…
bkontur Apr 27, 2023
1f3d70e
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur Apr 27, 2023
a7b7f39
Fmt
bkontur Apr 27, 2023
6c29018
Merge commit 'fd69d9414cdc2586be3e26d7599dc50b587c7428' into bridge-h…
bkontur Apr 27, 2023
fd69d94
Squashed 'bridges/' changes from 4850aac8ce..66aaf0dd23
bkontur Apr 27, 2023
3d2a818
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur Apr 27, 2023
56aa147
Add JSON chainspecs for Wococo and Rococo Bridge-hub (#2473)
PierreBesson Apr 27, 2023
4f7c913
Merge remote-tracking branch 'origin/master' into bridge-hub-subtree
Apr 27, 2023
4e100ec
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur Apr 27, 2023
cf4a6ef
Companion for paritytech/polkadot#7098 (#2469)
KiChjang Apr 27, 2023
6c5bec5
Cleaning
bkontur Apr 27, 2023
9240ded
level-monitor: Use prroper log target (#2493)
bkchr Apr 28, 2023
ad86283
Bump ruby/setup-ruby from 1.147.0 to 1.148.0 (#2496)
dependabot[bot] Apr 30, 2023
5892628
Skip av-store, make consensus task blocking (#2497)
skunert May 1, 2023
cd91e6b
Bump scale-info from 2.5.0 to 2.6.0 (#2500)
dependabot[bot] May 2, 2023
70b426b
bridge-hub-rococo: minor fixes
acatangiu May 2, 2023
d904495
Bump clap to 4.2.5 (#2505)
May 2, 2023
17fc1c1
Merge remote-tracking branch 'origin/master' into bridge-hub-subtree
bkontur May 3, 2023
8b62a00
Squashed 'bridges/' changes from 66aaf0dd23..557ecbcecc
bkontur May 3, 2023
00e45c5
Merge commit '8b62a005717fbe976832504b1f0c39eee19ac0a6' into bridge-h…
bkontur May 3, 2023
b93712d
fmt
bkontur May 3, 2023
ca6e8ac
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur May 3, 2023
8afd1fb
Fix compile
bkontur May 3, 2023
6612cae
Fix benchmark
bkontur May 3, 2023
0004d04
[ci] Run gha fmt in docker (#2511)
alvicsam May 3, 2023
e6497d4
Merge remote-tracking branch 'origin/master' into bridge-hub-subtree
bkontur May 3, 2023
65ee2dc
Squashed 'bridges/' changes from 557ecbcecc..04b3dda6aa
bkontur May 3, 2023
6dd9e36
Merge commit '65ee2dc77f5c0832f48b5331371483ff5c3c2574' into bridge-h…
bkontur May 3, 2023
6f7e193
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
bkontur May 3, 2023
a93f995
Fix
bkontur May 3, 2023
1a986c5
".git/.scripts/commands/fmt/fmt.sh"
May 3, 2023
499d9a2
Merge remote-tracking branch 'origin/bridge-hub-subtree' into bridge-…
May 3, 2023
e6b02ea
".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo brid…
May 3, 2023
22d1f8e
".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo brid…
May 3, 2023
68cd27a
".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo brid…
May 3, 2023
dbb1a7e
".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo brid…
May 3, 2023
1182cfc
Companion PR for add events to ContractResult (#2510)
juangirini May 3, 2023
8ca3fc4
Bump tokio from 1.27.0 to 1.28.0 (#2508)
dependabot[bot] May 3, 2023
f632ad7
Bump clap from 4.2.5 to 4.2.7 (#2516)
dependabot[bot] May 3, 2023
c78addf
Merge branch 'bridge-hub-rococo-wococo' into alistair/merged-rococo-w…
alistair-singh May 5, 2023
08f0981
updated dependencies
alistair-singh May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/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"
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
hash-db = { version = "0.16.0", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.6.0", default-features = false, features = ["derive"] }
static_assertions = { version = "1.1", optional = true }

# Bridge dependencies
Expand Down
32 changes: 29 additions & 3 deletions bridges/bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ use crate::{messages, messages::MessageBridge};
use bp_messages::{InboundLaneData, MessageNonce};
use bp_runtime::{Chain, ChainId};
use codec::Encode;
use frame_support::{storage::generator::StorageValue, traits::Get};
use frame_support::{storage::generator::StorageValue, traits::Get, weights::Weight};
use frame_system::limits;
use pallet_bridge_messages::WeightInfoExt as _;
use sp_runtime::traits::SignedExtension;

/// Macro that ensures that the runtime configuration and chain primitives crate are sharing
Expand Down Expand Up @@ -289,15 +290,25 @@ where
}

/// Check that the message lane weights are correct.
pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
pub fn check_message_lane_weights<
C: Chain,
T: frame_system::Config + pallet_bridge_messages::Config,
>(
bridged_chain_extra_storage_proof_size: u32,
this_chain_max_unrewarded_relayers: MessageNonce,
this_chain_max_unconfirmed_messages: MessageNonce,
// whether `RefundBridgedParachainMessages` extension is deployed at runtime and is used for
// refunding this bridge transactions?
//
// in other words: pass true for all known production chains
runtime_includes_refund_extension: bool,
) {
type Weights<T> = pallet_bridge_messages::weights::BridgeWeight<T>;
type Weights<T> = <T as pallet_bridge_messages::Config>::WeightInfo;

// check basic weight assumptions
pallet_bridge_messages::ensure_weights_are_correct::<Weights<T>>();

// check that weights allow us to receive messages
let max_incoming_message_proof_size = bridged_chain_extra_storage_proof_size
.saturating_add(messages::target::maximal_incoming_message_size(C::max_extrinsic_size()));
pallet_bridge_messages::ensure_able_to_receive_message::<Weights<T>>(
Expand All @@ -307,6 +318,7 @@ pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
messages::target::maximal_incoming_message_dispatch_weight(C::max_extrinsic_weight()),
);

// check that weights allow us to receive delivery confirmations
let max_incoming_inbound_lane_data_proof_size =
InboundLaneData::<()>::encoded_size_hint_u32(this_chain_max_unrewarded_relayers as _);
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights<T>>(
Expand All @@ -316,6 +328,20 @@ pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
this_chain_max_unrewarded_relayers,
this_chain_max_unconfirmed_messages,
);

// check that extra weights of delivery/confirmation transactions include the weight
// of `RefundBridgedParachainMessages` operations. This signed extension assumes the worst case
// (i.e. slashing if delivery transaction was invalid) and refunds some weight if
// assumption was wrong (i.e. if we did refund instead of slashing). This check
// ensures the extension will not refund weight when it doesn't need to (i.e. if pallet
// weights do not account weights of refund extension).
if runtime_includes_refund_extension {
assert_ne!(Weights::<T>::receive_messages_proof_overhead_from_runtime(), Weight::zero());
assert_ne!(
Weights::<T>::receive_messages_delivery_proof_overhead_from_runtime(),
Weight::zero()
);
}
}

/// Check that the `AdditionalSigned` type of a wrapped runtime is the same as the one of the
Expand Down
14 changes: 14 additions & 0 deletions bridges/bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,21 @@ pub enum CustomNetworkId {
RialtoParachain,
}

impl TryFrom<bp_runtime::ChainId> for CustomNetworkId {
type Error = ();

fn try_from(chain: bp_runtime::ChainId) -> Result<Self, Self::Error> {
Ok(match chain {
bp_runtime::MILLAU_CHAIN_ID => Self::Millau,
bp_runtime::RIALTO_CHAIN_ID => Self::Rialto,
bp_runtime::RIALTO_PARACHAIN_CHAIN_ID => Self::RialtoParachain,
_ => return Err(()),
})
}
}

impl CustomNetworkId {
/// Converts self to XCM' network id.
pub const fn as_network_id(&self) -> NetworkId {
match *self {
CustomNetworkId::Millau => NetworkId::Kusama,
Expand Down
47 changes: 35 additions & 12 deletions bridges/bin/runtime-common/src/refund_relayer_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ use pallet_bridge_parachains::{
BoundedBridgeGrandpaConfig, CallSubType as ParachainsCallSubType, Config as ParachainsConfig,
RelayBlockNumber, SubmitParachainHeadsHelper, SubmitParachainHeadsInfo,
};
use pallet_bridge_relayers::{Config as RelayersConfig, Pallet as RelayersPallet};
use pallet_bridge_relayers::{
Config as RelayersConfig, Pallet as RelayersPallet, WeightInfoExt as _,
};
use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTransaction};
use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -445,11 +447,19 @@ where

// decrease post-dispatch weight/size using extra weight/size that we know now
let post_info_len = len.saturating_sub(extra_size as usize);
let mut post_info = *post_info;
post_info.actual_weight =
Some(post_info.actual_weight.unwrap_or(info.weight).saturating_sub(extra_weight));
let mut post_info_weight =
post_info.actual_weight.unwrap_or(info.weight).saturating_sub(extra_weight);

// let's also replace the weight of slashing relayer with the weight of rewarding relayer
if call_info.is_receive_messages_proof_call() {
post_info_weight = post_info_weight.saturating_sub(
<Runtime as RelayersConfig>::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(),
);
}

// compute the relayer refund
let mut post_info = *post_info;
post_info.actual_weight = Some(post_info_weight);
let refund = Refund::compute_refund(info, &post_info, post_info_len, tip);

// we can finally reward relayer
Expand Down Expand Up @@ -1052,7 +1062,20 @@ mod tests {
assert_eq!(post_dispatch_result, Ok(()));
}

fn expected_reward() -> ThisChainBalance {
fn expected_delivery_reward() -> ThisChainBalance {
let mut post_dispatch_info = post_dispatch_info();
let extra_weight = <TestRuntime as RelayersConfig>::WeightInfo::extra_weight_of_successful_receive_messages_proof_call();
post_dispatch_info.actual_weight =
Some(dispatch_info().weight.saturating_sub(extra_weight));
pallet_transaction_payment::Pallet::<TestRuntime>::compute_actual_fee(
1024,
&dispatch_info(),
&post_dispatch_info,
Zero::zero(),
)
}

fn expected_confirmation_reward() -> ThisChainBalance {
pallet_transaction_payment::Pallet::<TestRuntime>::compute_actual_fee(
1024,
&dispatch_info(),
Expand Down Expand Up @@ -1449,7 +1472,7 @@ mod tests {

// without any size/weight refund: we expect regular reward
let pre_dispatch_data = all_finality_pre_dispatch_data();
let regular_reward = expected_reward();
let regular_reward = expected_delivery_reward();
run_post_dispatch(Some(pre_dispatch_data), Ok(()));
assert_eq!(
RelayersPallet::<TestRuntime>::relayer_reward(
Expand Down Expand Up @@ -1496,7 +1519,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_delivery_reward()),
);

run_post_dispatch(Some(all_finality_confirmation_pre_dispatch_data()), Ok(()));
Expand All @@ -1505,7 +1528,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgDeliveryProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_confirmation_reward()),
);
});
}
Expand All @@ -1521,7 +1544,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_delivery_reward()),
);

run_post_dispatch(Some(parachain_finality_confirmation_pre_dispatch_data()), Ok(()));
Expand All @@ -1530,7 +1553,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgDeliveryProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_confirmation_reward()),
);
});
}
Expand All @@ -1546,7 +1569,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_delivery_reward()),
);

run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(()));
Expand All @@ -1555,7 +1578,7 @@ mod tests {
relayer_account_at_this_chain(),
MsgDeliveryProofsRewardsAccount::get()
),
Some(expected_reward()),
Some(expected_confirmation_reward()),
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.6.0", default-features = false, features = ["derive"] }

# Bridge Dependencies

Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// --wasm-execution=Compiled
// --heap-pages=4096
// --output=./modules/grandpa/src/weights.rs
// --template=./.maintain/millau-weight-template.hbs
// --template=./.maintain/bridge-weight-template.hbs

#![allow(clippy::all)]
#![allow(unused_parens)]
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/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"
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
log = { version = "0.4.17", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.6.0", default-features = false, features = ["derive"] }

# Bridge dependencies

Expand Down
3 changes: 2 additions & 1 deletion bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,10 @@ pub mod pallet {
if let Some(updated_latest_confirmed_nonce) = updated_latest_confirmed_nonce {
log::trace!(
target: LOG_TARGET,
"Received lane {:?} state update: latest_confirmed_nonce={}",
"Received lane {:?} state update: latest_confirmed_nonce={}. Unrewarded relayers: {:?}",
lane_id,
updated_latest_confirmed_nonce,
UnrewardedRelayersState::from(&lane.storage().data()),
);
}
}
Expand Down
16 changes: 3 additions & 13 deletions bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use bp_messages::{
DeliveryPayments, DispatchMessage, DispatchMessageData, MessageDispatch,
ProvedLaneMessages, ProvedMessages, SourceHeaderChain,
},
total_unrewarded_messages, DeliveredMessages, InboundLaneData, LaneId, Message, MessageKey,
MessageNonce, MessagePayload, OutboundLaneData, UnrewardedRelayer, UnrewardedRelayersState,
DeliveredMessages, InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload,
OutboundLaneData, UnrewardedRelayer, UnrewardedRelayersState,
};
use bp_runtime::{messages::MessageDispatchResult, Size};
use codec::{Decode, Encode};
Expand Down Expand Up @@ -485,17 +485,7 @@ pub fn unrewarded_relayer(
/// Returns unrewarded relayers state at given lane.
pub fn inbound_unrewarded_relayers_state(lane: bp_messages::LaneId) -> UnrewardedRelayersState {
let inbound_lane_data = crate::InboundLanes::<TestRuntime, ()>::get(lane).0;
let last_delivered_nonce = inbound_lane_data.last_delivered_nonce();
let relayers = inbound_lane_data.relayers;
UnrewardedRelayersState {
unrewarded_relayer_entries: relayers.len() as _,
messages_in_oldest_entry: relayers
.front()
.map(|entry| 1 + entry.messages.end - entry.messages.begin)
.unwrap_or(0),
total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX),
last_delivered_nonce,
}
UnrewardedRelayersState::from(&inbound_lane_data)
}

/// Return test externalities to use in tests.
Expand Down
3 changes: 0 additions & 3 deletions bridges/modules/messages/src/outbound_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ fn ensure_unrewarded_relayers_are_correct<RelayerId>(
// entry can't confirm messages larger than `inbound_lane_data.latest_received_nonce()`
// (guaranteed by the `InboundLane::receive_message()`)
if entry.messages.end > latest_received_nonce {
// technically this will be detected in the next loop iteration as
// `InvalidNumberOfDispatchResults` but to guarantee safety of loop operations below
// this is detected now
return Err(ReceivalConfirmationResult::FailedToConfirmFutureMessages)
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// --wasm-execution=Compiled
// --heap-pages=4096
// --output=./modules/messages/src/weights.rs
// --template=./.maintain/millau-weight-template.hbs
// --template=./.maintain/bridge-weight-template.hbs

#![allow(clippy::all)]
#![allow(unused_parens)]
Expand Down
43 changes: 43 additions & 0 deletions bridges/modules/messages/src/weights_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ pub trait WeightInfoExt: WeightInfo {
/// this value, we're going to charge relayer for that.
fn expected_extra_storage_proof_size() -> u32;

// Our configuration assumes that the runtime has special signed extensions used to:
//
// 1) reject obsolete delivery and confirmation transactions;
//
// 2) refund transaction cost to relayer and register his rewards.
//
// The checks in (1) are trivial, so its computation weight may be ignored. And we only touch
// storage values that are read during the call. So we may ignore the weight of this check.
//
// However, during (2) we read and update storage values of other pallets
// (`pallet-bridge-relayers` and balances/assets pallet). So we need to add this weight to the
// weight of our call. Hence two following methods.

/// Extra weight that is added to the `receive_messages_proof` call weight by signed extensions
/// that are declared at runtime level.
fn receive_messages_proof_overhead_from_runtime() -> Weight;

/// Extra weight that is added to the `receive_messages_delivery_proof` call weight by signed
/// extensions that are declared at runtime level.
fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight;

// Functions that are directly mapped to extrinsics weights.

/// Weight of message delivery extrinsic.
Expand All @@ -276,6 +297,8 @@ pub trait WeightInfoExt: WeightInfo {
) -> Weight {
// basic components of extrinsic weight
let transaction_overhead = Self::receive_messages_proof_overhead();
let transaction_overhead_from_runtime =
Self::receive_messages_proof_overhead_from_runtime();
let outbound_state_delivery_weight =
Self::receive_messages_proof_outbound_lane_state_overhead();
let messages_delivery_weight =
Expand All @@ -292,6 +315,7 @@ pub trait WeightInfoExt: WeightInfo {
);

transaction_overhead
.saturating_add(transaction_overhead_from_runtime)
.saturating_add(outbound_state_delivery_weight)
.saturating_add(messages_delivery_weight)
.saturating_add(messages_dispatch_weight)
Expand All @@ -305,6 +329,8 @@ pub trait WeightInfoExt: WeightInfo {
) -> Weight {
// basic components of extrinsic weight
let transaction_overhead = Self::receive_messages_delivery_proof_overhead();
let transaction_overhead_from_runtime =
Self::receive_messages_delivery_proof_overhead_from_runtime();
let messages_overhead =
Self::receive_messages_delivery_proof_messages_overhead(relayers_state.total_messages);
let relayers_overhead = Self::receive_messages_delivery_proof_relayers_overhead(
Expand All @@ -319,6 +345,7 @@ pub trait WeightInfoExt: WeightInfo {
);

transaction_overhead
.saturating_add(transaction_overhead_from_runtime)
.saturating_add(messages_overhead)
.saturating_add(relayers_overhead)
.saturating_add(proof_size_overhead)
Expand Down Expand Up @@ -424,12 +451,28 @@ impl WeightInfoExt for () {
fn expected_extra_storage_proof_size() -> u32 {
EXTRA_STORAGE_PROOF_SIZE
}

fn receive_messages_proof_overhead_from_runtime() -> Weight {
Weight::zero()
}

fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight {
Weight::zero()
}
}

impl<T: frame_system::Config> WeightInfoExt for crate::weights::BridgeWeight<T> {
fn expected_extra_storage_proof_size() -> u32 {
EXTRA_STORAGE_PROOF_SIZE
}

fn receive_messages_proof_overhead_from_runtime() -> Weight {
Weight::zero()
}

fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight {
Weight::zero()
}
}

#[cfg(test)]
Expand Down
Loading