mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Update bridges subtree (#1803)
This commit is contained in:
committed by
GitHub
parent
2b4b33d01f
commit
ebf442336f
@@ -18,6 +18,7 @@ use crate::messages::{
|
||||
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
|
||||
};
|
||||
use bp_messages::{target_chain::MessageDispatch, InboundLaneData, LaneId, MessageNonce};
|
||||
use bp_runtime::OwnedBridgeModule;
|
||||
use frame_support::{
|
||||
dispatch::CallableCallFor,
|
||||
traits::{Get, IsSubType},
|
||||
@@ -187,8 +188,22 @@ pub trait MessagesCallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:
|
||||
/// or a `ReceiveMessagesDeliveryProof` call, if the call is for the provided lane.
|
||||
fn call_info_for(&self, lane_id: LaneId) -> Option<CallInfo>;
|
||||
|
||||
/// Check that a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call is trying
|
||||
/// to deliver/confirm at least some messages that are better than the ones we know of.
|
||||
/// Ensures that a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call:
|
||||
///
|
||||
/// - does not deliver already delivered messages. We require all messages in the
|
||||
/// `ReceiveMessagesProof` call to be undelivered;
|
||||
///
|
||||
/// - does not submit empty `ReceiveMessagesProof` call with zero messages, unless the lane
|
||||
/// needs to be unblocked by providing relayer rewards proof;
|
||||
///
|
||||
/// - brings no new delivery confirmations in a `ReceiveMessagesDeliveryProof` call. We require
|
||||
/// at least one new delivery confirmation in the unrewarded relayers set;
|
||||
///
|
||||
/// - does not violate some basic (easy verifiable) messages pallet rules obsolete (like
|
||||
/// submitting a call when a pallet is halted or delivering messages when a dispatcher is
|
||||
/// inactive).
|
||||
///
|
||||
/// If one of above rules is violated, the transaction is treated as invalid.
|
||||
fn check_obsolete_call(&self) -> TransactionValidity;
|
||||
}
|
||||
|
||||
@@ -278,7 +293,17 @@ impl<
|
||||
}
|
||||
|
||||
fn check_obsolete_call(&self) -> TransactionValidity {
|
||||
let is_pallet_halted = Pallet::<T, I>::ensure_not_halted().is_err();
|
||||
match self.call_info() {
|
||||
Some(proof_info) if is_pallet_halted => {
|
||||
log::trace!(
|
||||
target: pallet_bridge_messages::LOG_TARGET,
|
||||
"Rejecting messages transaction on halted pallet: {:?}",
|
||||
proof_info
|
||||
);
|
||||
|
||||
return sp_runtime::transaction_validity::InvalidTransaction::Call.into()
|
||||
},
|
||||
Some(CallInfo::ReceiveMessagesProof(proof_info))
|
||||
if proof_info.is_obsolete(T::MessageDispatch::is_active()) =>
|
||||
{
|
||||
|
||||
@@ -838,21 +838,23 @@ mod tests {
|
||||
mock::*,
|
||||
};
|
||||
use bp_messages::{
|
||||
DeliveredMessages, InboundLaneData, MessageNonce, OutboundLaneData, UnrewardedRelayer,
|
||||
UnrewardedRelayersState,
|
||||
DeliveredMessages, InboundLaneData, MessageNonce, MessagesOperatingMode, OutboundLaneData,
|
||||
UnrewardedRelayer, UnrewardedRelayersState,
|
||||
};
|
||||
use bp_parachains::{BestParaHeadHash, ParaInfo};
|
||||
use bp_polkadot_core::parachains::{ParaHeadsProof, ParaId};
|
||||
use bp_runtime::HeaderId;
|
||||
use bp_runtime::{BasicOperatingMode, HeaderId};
|
||||
use bp_test_utils::{make_default_justification, test_keyring};
|
||||
use frame_support::{
|
||||
assert_storage_noop, parameter_types,
|
||||
traits::{fungible::Mutate, ReservableCurrency},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_bridge_grandpa::{Call as GrandpaCall, StoredAuthoritySet};
|
||||
use pallet_bridge_messages::Call as MessagesCall;
|
||||
use pallet_bridge_parachains::{Call as ParachainsCall, RelayBlockHash};
|
||||
use pallet_bridge_grandpa::{Call as GrandpaCall, Pallet as GrandpaPallet, StoredAuthoritySet};
|
||||
use pallet_bridge_messages::{Call as MessagesCall, Pallet as MessagesPallet};
|
||||
use pallet_bridge_parachains::{
|
||||
Call as ParachainsCall, Pallet as ParachainsPallet, RelayBlockHash,
|
||||
};
|
||||
use sp_runtime::{
|
||||
traits::{ConstU64, Header as HeaderT},
|
||||
transaction_validity::{InvalidTransaction, ValidTransaction},
|
||||
@@ -1592,6 +1594,99 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_rejects_batch_with_grandpa_finality_proof_when_grandpa_pallet_is_halted() {
|
||||
run_test(|| {
|
||||
initialize_environment(100, 100, 100);
|
||||
|
||||
GrandpaPallet::<TestRuntime, ()>::set_operating_mode(
|
||||
RuntimeOrigin::root(),
|
||||
BasicOperatingMode::Halted,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_rejects_batch_with_parachain_finality_proof_when_parachains_pallet_is_halted() {
|
||||
run_test(|| {
|
||||
initialize_environment(100, 100, 100);
|
||||
|
||||
ParachainsPallet::<TestRuntime, ()>::set_operating_mode(
|
||||
RuntimeOrigin::root(),
|
||||
BasicOperatingMode::Halted,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_rejects_transaction_when_messages_pallet_is_halted() {
|
||||
run_test(|| {
|
||||
initialize_environment(100, 100, 100);
|
||||
|
||||
MessagesPallet::<TestRuntime, ()>::set_operating_mode(
|
||||
RuntimeOrigin::root(),
|
||||
MessagesOperatingMode::Basic(BasicOperatingMode::Halted),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
run_pre_dispatch(message_delivery_call(200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
assert_eq!(
|
||||
run_pre_dispatch(message_confirmation_call(200)),
|
||||
Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_dispatch_parses_batch_with_relay_chain_and_parachain_headers() {
|
||||
run_test(|| {
|
||||
|
||||
Reference in New Issue
Block a user