CheckBridgedBlockNumber -> BridgeRejectObsoleteGrandpaHeader (#1442)

This commit is contained in:
Svyatoslav Nikolsky
2022-06-07 12:29:03 +03:00
committed by Bastian Köcher
parent 5e2e5906e8
commit db2bc11476
3 changed files with 14 additions and 14 deletions
+2 -2
View File
@@ -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, Runtime,
Call::BridgeRialtoGrandpa => RialtoGrandpaInstance, Call::BridgeRialtoGrandpa => RialtoGrandpaInstance,
Call::BridgeWestendGrandpa => WestendGrandpaInstance Call::BridgeWestendGrandpa => WestendGrandpaInstance
@@ -585,7 +585,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>, frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>, frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>, pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
CheckBridgedBlockNumber, BridgeRejectObsoleteGrandpaHeader,
); );
/// The payload being signed in transactions. /// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
+11 -11
View File
@@ -14,27 +14,27 @@
// You should have received a copy of the GNU General Public License // 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/>. // 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 /// ## Example
/// ///
/// ```nocompile /// ```nocompile
/// pallet_bridge_grandpa::declare_check_bridged_block_number_ext!{ /// pallet_bridge_grandpa::declare_bridge_reject_obsolete_grandpa_header!{
/// Runtime, /// Runtime,
/// Call::BridgeRialtoGrandpa => RialtoGrandpaInstance, /// Call::BridgeRialtoGrandpa => RialtoGrandpaInstance,
/// Call::BridgeWestendGrandpa => WestendGrandpaInstance, /// Call::BridgeWestendGrandpa => WestendGrandpaInstance,
/// } /// }
/// ``` /// ```
#[macro_export] #[macro_export]
macro_rules! declare_check_bridged_block_number_ext { macro_rules! declare_bridge_reject_obsolete_grandpa_header {
($runtime:ident, $($call:path => $instance:ty),*) => { ($runtime:ident, $($call:path => $instance:ty),*) => {
/// Transaction-with-obsolete-bridged-header check that will reject transaction if /// Transaction-with-obsolete-bridged-header check that will reject transaction if
/// it submits obsolete bridged header. /// it submits obsolete bridged header.
#[derive(Clone, codec::Decode, codec::Encode, Eq, PartialEq, frame_support::RuntimeDebug, scale_info::TypeInfo)] #[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 { impl sp_runtime::traits::SignedExtension for BridgeRejectObsoleteGrandpaHeader {
const IDENTIFIER: &'static str = "CheckBridgedBlockNumber"; const IDENTIFIER: &'static str = "BridgeRejectObsoleteGrandpaHeader";
type AccountId = <$runtime as frame_system::Config>::AccountId; type AccountId = <$runtime as frame_system::Config>::AccountId;
type Call = <$runtime as frame_system::Config>::Call; type Call = <$runtime as frame_system::Config>::Call;
type AdditionalSigned = (); type AdditionalSigned = ();
@@ -114,13 +114,13 @@ mod tests {
use frame_support::weights::{DispatchClass, DispatchInfo, Pays}; use frame_support::weights::{DispatchClass, DispatchInfo, Pays};
use sp_runtime::traits::SignedExtension; use sp_runtime::traits::SignedExtension;
declare_check_bridged_block_number_ext! { declare_bridge_reject_obsolete_grandpa_header! {
TestRuntime, TestRuntime,
Call::Grandpa => () Call::Grandpa => ()
} }
fn validate_block_submit(num: TestNumber) -> bool { fn validate_block_submit(num: TestNumber) -> bool {
CheckBridgedBlockNumber BridgeRejectObsoleteGrandpaHeader
.validate( .validate(
&42, &42,
&Call::Grandpa(crate::Call::<TestRuntime, ()>::submit_finality_proof { &Call::Grandpa(crate::Call::<TestRuntime, ()>::submit_finality_proof {
@@ -140,7 +140,7 @@ mod tests {
} }
#[test] #[test]
fn check_bridged_block_number_rejects_obsolete_header() { fn extension_rejects_obsolete_header() {
run_test(|| { run_test(|| {
// when current best finalized is #10 and we're trying to import header#5 => tx is // when current best finalized is #10 and we're trying to import header#5 => tx is
// rejected // rejected
@@ -150,7 +150,7 @@ mod tests {
} }
#[test] #[test]
fn check_bridged_block_number_rejects_same_header() { fn extension_rejects_same_header() {
run_test(|| { run_test(|| {
// when current best finalized is #10 and we're trying to import header#10 => tx is // when current best finalized is #10 and we're trying to import header#10 => tx is
// rejected // rejected
@@ -160,7 +160,7 @@ mod tests {
} }
#[test] #[test]
fn check_bridged_block_number_accepts_new_header() { fn extension_accepts_new_header() {
run_test(|| { run_test(|| {
// when current best finalized is #10 and we're trying to import header#15 => tx is // when current best finalized is #10 and we're trying to import header#15 => tx is
// accepted // accepted
+1 -1
View File
@@ -115,7 +115,7 @@ impl TransactionSignScheme for Millau {
frame_system::CheckNonce::<millau_runtime::Runtime>::from(param.unsigned.nonce), frame_system::CheckNonce::<millau_runtime::Runtime>::from(param.unsigned.nonce),
frame_system::CheckWeight::<millau_runtime::Runtime>::new(), frame_system::CheckWeight::<millau_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<millau_runtime::Runtime>::from(param.unsigned.tip), pallet_transaction_payment::ChargeTransactionPayment::<millau_runtime::Runtime>::from(param.unsigned.tip),
millau_runtime::CheckBridgedBlockNumber, // TODO millau_runtime::BridgeRejectObsoleteGrandpaHeader,
), ),
( (
(), (),