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

Commit

Permalink
Squashed 'bridges/' changes from 984749ba0..fb3c5ef5d
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bkontur committed Jan 19, 2023
1 parent d3c0763 commit 677abb1
Show file tree
Hide file tree
Showing 38 changed files with 490 additions and 388 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

19 changes: 2 additions & 17 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,21 +1001,6 @@ impl_runtime_apis! {
use rialto_messages::WithRialtoMessageBridge;

impl MessagesConfig<WithRialtoMessagesInstance> for Runtime {
fn bridged_relayer_id() -> Self::InboundRelayer {
[0u8; 32].into()
}

fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(relayer, &Self::bench_lane_id()).is_some()
}

fn endow_account(account: &Self::AccountId) {
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
account,
Balance::MAX / 100,
);
}

fn prepare_message_proof(
params: MessageProofParams,
) -> (rialto_messages::FromRialtoMessagesProof, Weight) {
Expand All @@ -1032,8 +1017,8 @@ impl_runtime_apis! {
)
}

fn is_message_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
true
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(relayer, &Self::bench_lane_id()).is_some()
}
}

Expand Down
3 changes: 3 additions & 0 deletions bin/rialto-parachain/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }

[dev-dependencies]
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }

[features]
default = ['std']
runtime-benchmarks = [
Expand Down
26 changes: 25 additions & 1 deletion bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,11 @@ mod tests {
LaneId, MessageKey,
};
use bp_runtime::messages::MessageDispatchResult;
use bridge_runtime_common::messages::target::FromBridgedChainMessageDispatch;
use bridge_runtime_common::{
integrity::check_additional_signed, messages::target::FromBridgedChainMessageDispatch,
};
use codec::Encode;
use sp_runtime::generic::Era;

fn new_test_ext() -> sp_io::TestExternalities {
sp_io::TestExternalities::new(
Expand Down Expand Up @@ -909,4 +912,25 @@ mod tests {
);
})
}

#[test]
fn ensure_signed_extension_definition_is_correct() {
let payload: SignedExtra = (
frame_system::CheckNonZeroSender::new(),
frame_system::CheckSpecVersion::new(),
frame_system::CheckTxVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(Era::Immortal),
frame_system::CheckNonce::from(10),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
);
let indirect_payload = bp_rialto_parachain::SignedExtension::new(
((), (), (), (), Era::Immortal, 10.into(), (), 10.into()),
None,
);
assert_eq!(payload.encode(), indirect_payload.encode());

check_additional_signed::<SignedExtra, bp_rialto_parachain::SignedExtension>();
}
}
13 changes: 13 additions & 0 deletions bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use bp_runtime::{Chain, ChainId};
use codec::Encode;
use frame_support::{storage::generator::StorageValue, traits::Get};
use frame_system::limits;
use sp_runtime::traits::SignedExtension;

/// Macro that ensures that the runtime configuration and chain primitives crate are sharing
/// the same types (index, block number, hash, hasher, account id and header).
Expand Down Expand Up @@ -319,3 +320,15 @@ pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
this_chain_max_unconfirmed_messages,
);
}

/// Check that the `AdditionalSigned` type of a wrapped runtime is the same as the one of the
/// corresponding actual runtime.
///
/// This method doesn't perform any `assert`. If the condition is not true it will generate a
/// compile-time error.
pub fn check_additional_signed<SignedExt, IndirectSignedExt: SignedExtension>()
where
SignedExt: SignedExtension,
IndirectSignedExt: SignedExtension<AdditionalSigned = SignedExt::AdditionalSigned>,
{
}
Loading

0 comments on commit 677abb1

Please sign in to comment.