Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 677abb1

Browse files
committed
Squashed 'bridges/' changes from 984749ba0..fb3c5ef5d
fb3c5ef5d Add integrity check for signed extensions (#1780) 3959628ff add try-runtime feature to pallets (#1779) be36ff00c Default impl for some methods in messages benchmarking pallet config (#1777) 68344e329 Relayer reward metric (#1742) 6b455597b Crate-level documentation on finality relays and relayers pallet (#1773) git-subtree-dir: bridges git-subtree-split: fb3c5ef5dae42553522c7eff37678de9bf4f6c67
1 parent d3c0763 commit 677abb1

File tree

38 files changed

+490
-388
lines changed

38 files changed

+490
-388
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/millau/runtime/src/lib.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -1001,21 +1001,6 @@ impl_runtime_apis! {
10011001
use rialto_messages::WithRialtoMessageBridge;
10021002

10031003
impl MessagesConfig<WithRialtoMessagesInstance> for Runtime {
1004-
fn bridged_relayer_id() -> Self::InboundRelayer {
1005-
[0u8; 32].into()
1006-
}
1007-
1008-
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
1009-
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(relayer, &Self::bench_lane_id()).is_some()
1010-
}
1011-
1012-
fn endow_account(account: &Self::AccountId) {
1013-
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
1014-
account,
1015-
Balance::MAX / 100,
1016-
);
1017-
}
1018-
10191004
fn prepare_message_proof(
10201005
params: MessageProofParams,
10211006
) -> (rialto_messages::FromRialtoMessagesProof, Weight) {
@@ -1032,8 +1017,8 @@ impl_runtime_apis! {
10321017
)
10331018
}
10341019

1035-
fn is_message_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
1036-
true
1020+
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
1021+
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(relayer, &Self::bench_lane_id()).is_some()
10371022
}
10381023
}
10391024

bin/rialto-parachain/runtime/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master
7575
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
7676
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
7777

78+
[dev-dependencies]
79+
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
80+
7881
[features]
7982
default = ['std']
8083
runtime-benchmarks = [

bin/rialto-parachain/runtime/src/lib.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,11 @@ mod tests {
848848
LaneId, MessageKey,
849849
};
850850
use bp_runtime::messages::MessageDispatchResult;
851-
use bridge_runtime_common::messages::target::FromBridgedChainMessageDispatch;
851+
use bridge_runtime_common::{
852+
integrity::check_additional_signed, messages::target::FromBridgedChainMessageDispatch,
853+
};
852854
use codec::Encode;
855+
use sp_runtime::generic::Era;
853856

854857
fn new_test_ext() -> sp_io::TestExternalities {
855858
sp_io::TestExternalities::new(
@@ -909,4 +912,25 @@ mod tests {
909912
);
910913
})
911914
}
915+
916+
#[test]
917+
fn ensure_signed_extension_definition_is_correct() {
918+
let payload: SignedExtra = (
919+
frame_system::CheckNonZeroSender::new(),
920+
frame_system::CheckSpecVersion::new(),
921+
frame_system::CheckTxVersion::new(),
922+
frame_system::CheckGenesis::new(),
923+
frame_system::CheckEra::from(Era::Immortal),
924+
frame_system::CheckNonce::from(10),
925+
frame_system::CheckWeight::new(),
926+
pallet_transaction_payment::ChargeTransactionPayment::from(10),
927+
);
928+
let indirect_payload = bp_rialto_parachain::SignedExtension::new(
929+
((), (), (), (), Era::Immortal, 10.into(), (), 10.into()),
930+
None,
931+
);
932+
assert_eq!(payload.encode(), indirect_payload.encode());
933+
934+
check_additional_signed::<SignedExtra, bp_rialto_parachain::SignedExtension>();
935+
}
912936
}

bin/runtime-common/src/integrity.rs

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use bp_runtime::{Chain, ChainId};
2626
use codec::Encode;
2727
use frame_support::{storage::generator::StorageValue, traits::Get};
2828
use frame_system::limits;
29+
use sp_runtime::traits::SignedExtension;
2930

3031
/// Macro that ensures that the runtime configuration and chain primitives crate are sharing
3132
/// the same types (index, block number, hash, hasher, account id and header).
@@ -319,3 +320,15 @@ pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
319320
this_chain_max_unconfirmed_messages,
320321
);
321322
}
323+
324+
/// Check that the `AdditionalSigned` type of a wrapped runtime is the same as the one of the
325+
/// corresponding actual runtime.
326+
///
327+
/// This method doesn't perform any `assert`. If the condition is not true it will generate a
328+
/// compile-time error.
329+
pub fn check_additional_signed<SignedExt, IndirectSignedExt: SignedExtension>()
330+
where
331+
SignedExt: SignedExtension,
332+
IndirectSignedExt: SignedExtension<AdditionalSigned = SignedExt::AdditionalSigned>,
333+
{
334+
}

0 commit comments

Comments
 (0)