Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CheckBridgedBlockNumber to BridgeRejectObsoleteGrandpaHeader #1442

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,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 @@ -594,7 +594,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 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 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