Skip to content

Commit

Permalink
CheckBridgedBlockNumber -> BridgeRejectObsoleteGrandpaHeader (parityt…
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 10, 2024
1 parent 297d293 commit 6fa0f1f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ construct_runtime!(
}
);

pallet_bridge_grandpa::declare_check_bridged_block_number_ext! {
pallet_bridge_grandpa::declare_bridge_reject_obsolete_grandpa_header! {
Runtime,
Call::BridgeRialtoGrandpa => RialtoGrandpaInstance,
Call::BridgeWestendGrandpa => WestendGrandpaInstance
Expand All @@ -585,7 +585,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
CheckBridgedBlockNumber,
BridgeRejectObsoleteGrandpaHeader,
);
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down
22 changes: 11 additions & 11 deletions bridges/modules/grandpa/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

/// Declares a runtime-specific `CheckBridgedBlockNumber` signed extension.
/// Declares a runtime-specific `BridgeRejectObsoleteGrandpaHeader` signed extension.
///
/// ## Example
///
/// ```nocompile
/// pallet_bridge_grandpa::declare_check_bridged_block_number_ext!{
/// pallet_bridge_grandpa::declare_bridge_reject_obsolete_grandpa_header!{
/// Runtime,
/// Call::BridgeRialtoGrandpa => RialtoGrandpaInstance,
/// Call::BridgeWestendGrandpa => WestendGrandpaInstance,
/// }
/// ```
#[macro_export]
macro_rules! declare_check_bridged_block_number_ext {
macro_rules! declare_bridge_reject_obsolete_grandpa_header {
($runtime:ident, $($call:path => $instance:ty),*) => {
/// Transaction-with-obsolete-bridged-header check that will reject transaction if
/// it submits obsolete bridged header.
#[derive(Clone, codec::Decode, codec::Encode, Eq, PartialEq, frame_support::RuntimeDebug, scale_info::TypeInfo)]
pub struct CheckBridgedBlockNumber;
pub struct BridgeRejectObsoleteGrandpaHeader;

impl sp_runtime::traits::SignedExtension for CheckBridgedBlockNumber {
const IDENTIFIER: &'static str = "CheckBridgedBlockNumber";
impl sp_runtime::traits::SignedExtension for BridgeRejectObsoleteGrandpaHeader {
const IDENTIFIER: &'static str = "BridgeRejectObsoleteGrandpaHeader";
type AccountId = <$runtime as frame_system::Config>::AccountId;
type Call = <$runtime as frame_system::Config>::Call;
type AdditionalSigned = ();
Expand Down Expand Up @@ -114,13 +114,13 @@ mod tests {
use frame_support::weights::{DispatchClass, DispatchInfo, Pays};
use sp_runtime::traits::SignedExtension;

declare_check_bridged_block_number_ext! {
declare_bridge_reject_obsolete_grandpa_header! {
TestRuntime,
Call::Grandpa => ()
}

fn validate_block_submit(num: TestNumber) -> bool {
CheckBridgedBlockNumber
BridgeRejectObsoleteGrandpaHeader
.validate(
&42,
&Call::Grandpa(crate::Call::<TestRuntime, ()>::submit_finality_proof {
Expand All @@ -140,7 +140,7 @@ mod tests {
}

#[test]
fn check_bridged_block_number_rejects_obsolete_header() {
fn extension_rejects_obsolete_header() {
run_test(|| {
// when current best finalized is #10 and we're trying to import header#5 => tx is
// rejected
Expand All @@ -150,7 +150,7 @@ mod tests {
}

#[test]
fn check_bridged_block_number_rejects_same_header() {
fn extension_rejects_same_header() {
run_test(|| {
// when current best finalized is #10 and we're trying to import header#10 => tx is
// rejected
Expand All @@ -160,7 +160,7 @@ mod tests {
}

#[test]
fn check_bridged_block_number_accepts_new_header() {
fn extension_accepts_new_header() {
run_test(|| {
// when current best finalized is #10 and we're trying to import header#15 => tx is
// accepted
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/client-millau/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl TransactionSignScheme for Millau {
frame_system::CheckNonce::<millau_runtime::Runtime>::from(param.unsigned.nonce),
frame_system::CheckWeight::<millau_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<millau_runtime::Runtime>::from(param.unsigned.tip),
millau_runtime::CheckBridgedBlockNumber, // TODO
millau_runtime::BridgeRejectObsoleteGrandpaHeader,
),
(
(),
Expand Down

0 comments on commit 6fa0f1f

Please sign in to comment.