From 126d9504abb14ce6c1cab9931ccc0ff749598686 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 13:03:57 +0100 Subject: [PATCH 1/9] Rewards refund for relaying BridgeHubRococo/BridgeHubWococo --- Cargo.lock | 1 + .../chain-bridge-hub-cumulus/Cargo.toml | 2 + .../chain-bridge-hub-cumulus/src/lib.rs | 76 ++++++++++++++++++- relays/client-bridge-hub-rococo/src/lib.rs | 13 +++- .../src/runtime_wrapper.rs | 8 +- relays/client-bridge-hub-wococo/src/lib.rs | 14 +++- .../src/runtime_wrapper.rs | 6 +- 7 files changed, 104 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 374e17bb28..e64671ec9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -815,6 +815,7 @@ version = "0.1.0" dependencies = [ "bp-messages", "bp-polkadot-core", + "bp-runtime", "frame-support", "frame-system", "polkadot-primitives", diff --git a/primitives/chain-bridge-hub-cumulus/Cargo.toml b/primitives/chain-bridge-hub-cumulus/Cargo.toml index cb7f55d336..2bbe3d029a 100644 --- a/primitives/chain-bridge-hub-cumulus/Cargo.toml +++ b/primitives/chain-bridge-hub-cumulus/Cargo.toml @@ -11,6 +11,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false } bp-messages = { path = "../../primitives/messages", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } # Substrate Based Dependencies @@ -27,6 +28,7 @@ default = ["std"] std = [ "bp-polkadot-core/std", "bp-messages/std", + "bp-runtime/std", "frame-system/std", "frame-support/std", "sp-api/std", diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index dfa5afe2a5..536f0b48a6 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -19,8 +19,8 @@ use bp_messages::*; pub use bp_polkadot_core::{ AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash, Hasher, - Hashing, Header, Index, Nonce, Perbill, PolkadotSignedExtension, Signature, SignedBlock, - UncheckedExtrinsic, EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES, + Hashing, Header, Index, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic, + EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES, }; use frame_support::{ dispatch::DispatchClass, @@ -124,3 +124,75 @@ pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; /// Maximal number of unconfirmed messages at inbound lane for Cumulus-based parachains. pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096; + +/// Module with rewarding bridge signed extension utils +pub mod rewarding_bridge_signed_extension { + use super::*; + use bp_polkadot_core::PolkadotLike; + use bp_runtime::extensions::*; + + /// The `SignedExtensionSchema` for `RefundRelayerForMessagesFromParachain`. + type RefundRelayerForMessagesFromParachain = GenericSignedExtensionSchema<(), ()>; + + type RewardingBridgeSignedExtra = ( + CheckNonZeroSender, + CheckSpecVersion, + CheckTxVersion, + CheckGenesis, + CheckEra, + CheckNonce, + CheckWeight, + ChargeTransactionPayment, + BridgeRejectObsoleteHeadersAndMessages, + RefundRelayerForMessagesFromParachain, + ); + + /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. + pub type RewardingBridgeSignedExtension = GenericSignedExtension; + + pub fn from_params( + spec_version: u32, + transaction_version: u32, + era: bp_runtime::TransactionEraOf, + genesis_hash: Hash, + nonce: Nonce, + tip: Balance, + ) -> RewardingBridgeSignedExtension { + GenericSignedExtension::::new( + ( + (), // non-zero sender + (), // spec version + (), // tx version + (), // genesis + era.frame_era(), // era + nonce.into(), // nonce (compact encoding) + (), // Check weight + tip.into(), // transaction payment / tip (compact encoding) + (), // bridge reject obsolete headers and msgs + (), // bridge register reward to relayer for message passing + ), + Some(( + (), + spec_version, + transaction_version, + genesis_hash, + era.signed_payload(genesis_hash), + (), + (), + (), + (), + (), + )), + ) + } + + /// Return signer nonce, used to craft transaction. + pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { + sign_ext.payload.5.into() + } + + /// Return transaction tip. + pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { + sign_ext.payload.7.into() + } +} diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index d2e421423a..20d09a72a4 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -17,7 +17,6 @@ //! Types used to connect to the BridgeHub-Rococo-Substrate parachain. use bp_bridge_hub_rococo::AVERAGE_BLOCK_INTERVAL; -use bp_bridge_hub_wococo::PolkadotSignedExtension; use bp_messages::MessageNonce; use codec::Encode; use relay_substrate_client::{ @@ -72,7 +71,7 @@ impl ChainWithTransactions for BridgeHubRococo { ) -> Result { let raw_payload = SignedPayload::new( unsigned.call, - bp_bridge_hub_rococo::SignedExtension::from_params( + bp_bridge_hub_rococo::rewarding_bridge_signed_extension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -86,7 +85,7 @@ impl ChainWithTransactions for BridgeHubRococo { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - Ok(bp_bridge_hub_rococo::UncheckedExtrinsic::new_signed( + Ok(runtime::UncheckedExtrinsic::new_signed( call, signer.into_account().into(), signature.into(), @@ -109,7 +108,13 @@ impl ChainWithTransactions for BridgeHubRococo { fn parse_transaction(tx: Self::SignedTransaction) -> Option> { let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) + Some( + UnsignedTransaction::new( + tx.function, + bp_bridge_hub_rococo::rewarding_bridge_signed_extension::nonce(&extra), + ) + .tip(bp_bridge_hub_rococo::rewarding_bridge_signed_extension::tip(&extra)), + ) } } diff --git a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs index fc945d8c95..6418d2b310 100644 --- a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs @@ -14,21 +14,21 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -// TODO: join with primitives do we need this here or move to the primitives? - //! Types that are specific to the BridgeHubRococo runtime. use codec::{Decode, Encode}; use scale_info::TypeInfo; -use bp_bridge_hub_rococo::SignedExtension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubRococo extrinsic. -pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic; +pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic< + Call, + bp_bridge_hub_rococo::rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, +>; // The indirect pallet call used to sync `Wococo` GRANDPA finality to `BHRococo`. pub type BridgeWococoGrandpaCall = BridgeGrandpaCallOf; diff --git a/relays/client-bridge-hub-wococo/src/lib.rs b/relays/client-bridge-hub-wococo/src/lib.rs index 2c211ae86c..3d4c3bc683 100644 --- a/relays/client-bridge-hub-wococo/src/lib.rs +++ b/relays/client-bridge-hub-wococo/src/lib.rs @@ -16,7 +16,7 @@ //! Types used to connect to the BridgeHub-Wococo-Substrate parachain. -use bp_bridge_hub_wococo::{PolkadotSignedExtension, AVERAGE_BLOCK_INTERVAL}; +use bp_bridge_hub_wococo::AVERAGE_BLOCK_INTERVAL; use bp_messages::MessageNonce; use codec::Encode; use relay_substrate_client::{ @@ -71,7 +71,7 @@ impl ChainWithTransactions for BridgeHubWococo { ) -> Result { let raw_payload = SignedPayload::new( unsigned.call, - bp_bridge_hub_wococo::SignedExtension::from_params( + bp_bridge_hub_wococo::rewarding_bridge_signed_extension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -85,7 +85,7 @@ impl ChainWithTransactions for BridgeHubWococo { let signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - Ok(bp_bridge_hub_wococo::UncheckedExtrinsic::new_signed( + Ok(runtime::UncheckedExtrinsic::new_signed( call, signer.into_account().into(), signature.into(), @@ -108,7 +108,13 @@ impl ChainWithTransactions for BridgeHubWococo { fn parse_transaction(tx: Self::SignedTransaction) -> Option> { let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) + Some( + UnsignedTransaction::new( + tx.function, + bp_bridge_hub_wococo::rewarding_bridge_signed_extension::nonce(&extra), + ) + .tip(bp_bridge_hub_wococo::rewarding_bridge_signed_extension::tip(&extra)), + ) } } diff --git a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs index c16e7d1a45..50ac43a1ab 100644 --- a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs @@ -19,14 +19,16 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; -use bp_bridge_hub_wococo::SignedExtension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubWococo extrinsic. -pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic; +pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic< + Call, + bp_bridge_hub_wococo::rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, +>; // The indirect pallet call used to sync `Rococo` GRANDPA finality to `BHWococo`. pub type BridgeRococoGrandpaCall = BridgeGrandpaCallOf; From 5be62f4312c24be2f7204e915bce6aed21ec161a Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 13:43:00 +0100 Subject: [PATCH 2/9] spellcheck + clippy --- primitives/chain-bridge-hub-cumulus/src/lib.rs | 2 +- relays/client-bridge-hub-rococo/src/lib.rs | 4 ++-- relays/client-bridge-hub-wococo/src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 536f0b48a6..5d20025aba 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -125,7 +125,7 @@ pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; /// Maximal number of unconfirmed messages at inbound lane for Cumulus-based parachains. pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096; -/// Module with rewarding bridge signed extension utils +/// Module with rewarding bridge signed extension support pub mod rewarding_bridge_signed_extension { use super::*; use bp_polkadot_core::PolkadotLike; diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index 20d09a72a4..5af54e5552 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -111,9 +111,9 @@ impl ChainWithTransactions for BridgeHubRococo { Some( UnsignedTransaction::new( tx.function, - bp_bridge_hub_rococo::rewarding_bridge_signed_extension::nonce(&extra), + bp_bridge_hub_rococo::rewarding_bridge_signed_extension::nonce(extra), ) - .tip(bp_bridge_hub_rococo::rewarding_bridge_signed_extension::tip(&extra)), + .tip(bp_bridge_hub_rococo::rewarding_bridge_signed_extension::tip(extra)), ) } } diff --git a/relays/client-bridge-hub-wococo/src/lib.rs b/relays/client-bridge-hub-wococo/src/lib.rs index 3d4c3bc683..8fb7a339da 100644 --- a/relays/client-bridge-hub-wococo/src/lib.rs +++ b/relays/client-bridge-hub-wococo/src/lib.rs @@ -111,9 +111,9 @@ impl ChainWithTransactions for BridgeHubWococo { Some( UnsignedTransaction::new( tx.function, - bp_bridge_hub_wococo::rewarding_bridge_signed_extension::nonce(&extra), + bp_bridge_hub_wococo::rewarding_bridge_signed_extension::nonce(extra), ) - .tip(bp_bridge_hub_wococo::rewarding_bridge_signed_extension::tip(&extra)), + .tip(bp_bridge_hub_wococo::rewarding_bridge_signed_extension::tip(extra)), ) } } From 4ac2aae4f4b90db791fc7c989dc8cfa04bd5e71b Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 15:25:58 +0100 Subject: [PATCH 3/9] RefundBridgedParachainMessages move to bp-runtime --- primitives/chain-bridge-hub-cumulus/src/lib.rs | 5 +---- primitives/runtime/src/extensions.rs | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 5d20025aba..724c0423ee 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -131,9 +131,6 @@ pub mod rewarding_bridge_signed_extension { use bp_polkadot_core::PolkadotLike; use bp_runtime::extensions::*; - /// The `SignedExtensionSchema` for `RefundRelayerForMessagesFromParachain`. - type RefundRelayerForMessagesFromParachain = GenericSignedExtensionSchema<(), ()>; - type RewardingBridgeSignedExtra = ( CheckNonZeroSender, CheckSpecVersion, @@ -144,7 +141,7 @@ pub mod rewarding_bridge_signed_extension { CheckWeight, ChargeTransactionPayment, BridgeRejectObsoleteHeadersAndMessages, - RefundRelayerForMessagesFromParachain, + RefundBridgedParachainMessages, ); /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. diff --git a/primitives/runtime/src/extensions.rs b/primitives/runtime/src/extensions.rs index eefe10f705..14af937d03 100644 --- a/primitives/runtime/src/extensions.rs +++ b/primitives/runtime/src/extensions.rs @@ -76,6 +76,9 @@ pub type ChargeTransactionPayment = GenericSignedExtensionSchema; +/// The `SignedExtensionSchema` for `RefundBridgedParachainMessages`. +pub type RefundBridgedParachainMessages = GenericSignedExtensionSchema<(), ()>; + #[impl_for_tuples(1, 12)] impl SignedExtensionSchema for Tuple { for_tuples!( type Payload = ( #( Tuple::Payload ),* ); ); From 1ae0a85d2cd97d68291ed04c8a25105b1100e9ce Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 15:58:19 +0100 Subject: [PATCH 4/9] Dedicated RewardingBridgeSignedExtra for Rococo/Wococo shared runtime with two instances of `RefundBridgedParachainMessages` --- Cargo.lock | 2 + relays/client-bridge-hub-rococo/Cargo.toml | 2 + relays/client-bridge-hub-rococo/src/lib.rs | 6 +- .../src/runtime_wrapper.rs | 74 ++++++++++++++++++- relays/client-bridge-hub-wococo/Cargo.toml | 1 + relays/client-bridge-hub-wococo/src/lib.rs | 6 +- .../src/runtime_wrapper.rs | 74 ++++++++++++++++++- 7 files changed, 157 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 899367d037..6eb6e9ee53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9201,6 +9201,8 @@ dependencies = [ "bp-header-chain", "bp-messages", "bp-parachains", + "bp-polkadot-core", + "bp-runtime", "bp-wococo", "bridge-runtime-common", "parity-scale-codec", diff --git a/relays/client-bridge-hub-rococo/Cargo.toml b/relays/client-bridge-hub-rococo/Cargo.toml index 9a9316fa11..26fe2dd90a 100644 --- a/relays/client-bridge-hub-rococo/Cargo.toml +++ b/relays/client-bridge-hub-rococo/Cargo.toml @@ -17,6 +17,8 @@ bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" } bp-header-chain = { path = "../../primitives/header-chain" } bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } +bp-polkadot-core = { path = "../../primitives/polkadot-core" } +bp-runtime = { path = "../../primitives/runtime" } bp-wococo = { path = "../../primitives/chain-wococo" } bridge-runtime-common = { path = "../../bin/runtime-common" } diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index 5af54e5552..b6b844021e 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -71,7 +71,7 @@ impl ChainWithTransactions for BridgeHubRococo { ) -> Result { let raw_payload = SignedPayload::new( unsigned.call, - bp_bridge_hub_rococo::rewarding_bridge_signed_extension::from_params( + runtime::rewarding_bridge_signed_extension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -111,9 +111,9 @@ impl ChainWithTransactions for BridgeHubRococo { Some( UnsignedTransaction::new( tx.function, - bp_bridge_hub_rococo::rewarding_bridge_signed_extension::nonce(extra), + runtime::rewarding_bridge_signed_extension::nonce(extra), ) - .tip(bp_bridge_hub_rococo::rewarding_bridge_signed_extension::tip(extra)), + .tip(runtime::rewarding_bridge_signed_extension::tip(extra)), ) } } diff --git a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs index 6418d2b310..0f85d25b93 100644 --- a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs @@ -27,7 +27,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubRococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic< Call, - bp_bridge_hub_rococo::rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, >; // The indirect pallet call used to sync `Wococo` GRANDPA finality to `BHRococo`. @@ -69,3 +69,75 @@ impl From> for Call { Call::Utility(call) } } + +// TODO: remove this and use common from cumulus-like once fixed (https://github.com/paritytech/parity-bridges-common/issues/1598) +/// Module with rewarding bridge signed extension support +pub mod rewarding_bridge_signed_extension { + use bp_polkadot_core::{Balance, Hash, Nonce, PolkadotLike}; + use bp_runtime::extensions::*; + + type RewardingBridgeSignedExtra = ( + CheckNonZeroSender, + CheckSpecVersion, + CheckTxVersion, + CheckGenesis, + CheckEra, + CheckNonce, + CheckWeight, + ChargeTransactionPayment, + BridgeRejectObsoleteHeadersAndMessages, + RefundBridgedParachainMessages, + RefundBridgedParachainMessages, + ); + + /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. + pub type RewardingBridgeSignedExtension = GenericSignedExtension; + + pub fn from_params( + spec_version: u32, + transaction_version: u32, + era: bp_runtime::TransactionEraOf, + genesis_hash: Hash, + nonce: Nonce, + tip: Balance, + ) -> RewardingBridgeSignedExtension { + GenericSignedExtension::::new( + ( + (), // non-zero sender + (), // spec version + (), // tx version + (), // genesis + era.frame_era(), // era + nonce.into(), // nonce (compact encoding) + (), // Check weight + tip.into(), // transaction payment / tip (compact encoding) + (), // bridge reject obsolete headers and msgs + (), // bridge-hub-rococo instance1 register reward for message passing + (), // bridge-hub-rococo instance2 register reward for message passing + ), + Some(( + (), + spec_version, + transaction_version, + genesis_hash, + era.signed_payload(genesis_hash), + (), + (), + (), + (), + (), + (), + )), + ) + } + + /// Return signer nonce, used to craft transaction. + pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { + sign_ext.payload.5.into() + } + + /// Return transaction tip. + pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { + sign_ext.payload.7.into() + } +} diff --git a/relays/client-bridge-hub-wococo/Cargo.toml b/relays/client-bridge-hub-wococo/Cargo.toml index 7c9b90975d..7b8952da0e 100644 --- a/relays/client-bridge-hub-wococo/Cargo.toml +++ b/relays/client-bridge-hub-wococo/Cargo.toml @@ -17,6 +17,7 @@ bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" } bp-header-chain = { path = "../../primitives/header-chain" } bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } +bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-rococo = { path = "../../primitives/chain-rococo" } bp-runtime = { path = "../../primitives/runtime" } diff --git a/relays/client-bridge-hub-wococo/src/lib.rs b/relays/client-bridge-hub-wococo/src/lib.rs index 8fb7a339da..a466df3549 100644 --- a/relays/client-bridge-hub-wococo/src/lib.rs +++ b/relays/client-bridge-hub-wococo/src/lib.rs @@ -71,7 +71,7 @@ impl ChainWithTransactions for BridgeHubWococo { ) -> Result { let raw_payload = SignedPayload::new( unsigned.call, - bp_bridge_hub_wococo::rewarding_bridge_signed_extension::from_params( + runtime::rewarding_bridge_signed_extension::from_params( param.spec_version, param.transaction_version, unsigned.era, @@ -111,9 +111,9 @@ impl ChainWithTransactions for BridgeHubWococo { Some( UnsignedTransaction::new( tx.function, - bp_bridge_hub_wococo::rewarding_bridge_signed_extension::nonce(extra), + runtime::rewarding_bridge_signed_extension::nonce(extra), ) - .tip(bp_bridge_hub_wococo::rewarding_bridge_signed_extension::tip(extra)), + .tip(runtime::rewarding_bridge_signed_extension::tip(extra)), ) } } diff --git a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs index 50ac43a1ab..8c0263c6bb 100644 --- a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs @@ -27,7 +27,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubWococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic< Call, - bp_bridge_hub_wococo::rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, >; // The indirect pallet call used to sync `Rococo` GRANDPA finality to `BHWococo`. @@ -70,6 +70,78 @@ impl From> for Call { } } +// TODO: remove this and use common from cumulus-like once fixed (https://github.com/paritytech/parity-bridges-common/issues/1598) +/// Module with rewarding bridge signed extension support +pub mod rewarding_bridge_signed_extension { + use bp_polkadot_core::{Balance, Hash, Nonce, PolkadotLike}; + use bp_runtime::extensions::*; + + type RewardingBridgeSignedExtra = ( + CheckNonZeroSender, + CheckSpecVersion, + CheckTxVersion, + CheckGenesis, + CheckEra, + CheckNonce, + CheckWeight, + ChargeTransactionPayment, + BridgeRejectObsoleteHeadersAndMessages, + RefundBridgedParachainMessages, + RefundBridgedParachainMessages, + ); + + /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. + pub type RewardingBridgeSignedExtension = GenericSignedExtension; + + pub fn from_params( + spec_version: u32, + transaction_version: u32, + era: bp_runtime::TransactionEraOf, + genesis_hash: Hash, + nonce: Nonce, + tip: Balance, + ) -> RewardingBridgeSignedExtension { + GenericSignedExtension::::new( + ( + (), // non-zero sender + (), // spec version + (), // tx version + (), // genesis + era.frame_era(), // era + nonce.into(), // nonce (compact encoding) + (), // Check weight + tip.into(), // transaction payment / tip (compact encoding) + (), // bridge reject obsolete headers and msgs + (), // bridge-hub-rococo instance1 register reward for message passing + (), // bridge-hub-rococo instance2 register reward for message passing + ), + Some(( + (), + spec_version, + transaction_version, + genesis_hash, + era.signed_payload(genesis_hash), + (), + (), + (), + (), + (), + (), + )), + ) + } + + /// Return signer nonce, used to craft transaction. + pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { + sign_ext.payload.5.into() + } + + /// Return transaction tip. + pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { + sign_ext.payload.7.into() + } +} + #[cfg(test)] mod tests { use super::*; From 83ad36081decd09fa229f41ba81e08597283ac67 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 17:05:33 +0100 Subject: [PATCH 5/9] RefundBridgedParachainMessages with Tuple support for multiple --- .../chain-bridge-hub-cumulus/src/lib.rs | 56 +++++++++++--- primitives/runtime/src/extensions.rs | 2 +- relays/client-bridge-hub-rococo/src/lib.rs | 2 + .../src/runtime_wrapper.rs | 75 +------------------ relays/client-bridge-hub-wococo/src/lib.rs | 2 + .../src/runtime_wrapper.rs | 75 +------------------ 6 files changed, 54 insertions(+), 158 deletions(-) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 724c0423ee..11029f66c9 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -130,8 +130,26 @@ pub mod rewarding_bridge_signed_extension { use super::*; use bp_polkadot_core::PolkadotLike; use bp_runtime::extensions::*; - - type RewardingBridgeSignedExtra = ( + use frame_support::{ + codec::{Decode, Encode}, + scale_info::StaticTypeInfo, + }; + + // TODO: refactor this to extentions.rs + // TODO: replace with bound bellow + // #[impl_for_tuples(1, 12)] + // pub trait SignedExtensionSchemaPayload: + // Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo + // { + // } + // + // #[impl_for_tuples(1, 12)] + // pub trait SignedExtensionSchemaAdditionalSigned: + // Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo + // { + // } + + type RewardingBridgeSignedExtra = ( CheckNonZeroSender, CheckSpecVersion, CheckTxVersion, @@ -141,21 +159,27 @@ pub mod rewarding_bridge_signed_extension { CheckWeight, ChargeTransactionPayment, BridgeRejectObsoleteHeadersAndMessages, - RefundBridgedParachainMessages, + RefundBridgedParachainMessages, ); /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. - pub type RewardingBridgeSignedExtension = GenericSignedExtension; + pub type RewardingBridgeSignedExtension = + GenericSignedExtension>; - pub fn from_params( + pub fn from_params< + RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + >( spec_version: u32, transaction_version: u32, era: bp_runtime::TransactionEraOf, genesis_hash: Hash, nonce: Nonce, tip: Balance, - ) -> RewardingBridgeSignedExtension { - GenericSignedExtension::::new( + reward_payload: RewardPayload, + reward_additional_signed: RewardAdditionalSigned, + ) -> RewardingBridgeSignedExtension { + GenericSignedExtension::>::new( ( (), // non-zero sender (), // spec version @@ -166,7 +190,7 @@ pub mod rewarding_bridge_signed_extension { (), // Check weight tip.into(), // transaction payment / tip (compact encoding) (), // bridge reject obsolete headers and msgs - (), // bridge register reward to relayer for message passing + reward_payload, // bridge register reward to relayer for message passing ), Some(( (), @@ -178,18 +202,28 @@ pub mod rewarding_bridge_signed_extension { (), (), (), - (), + reward_additional_signed, )), ) } /// Return signer nonce, used to craft transaction. - pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { + pub fn nonce< + RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + >( + sign_ext: &RewardingBridgeSignedExtension, + ) -> Nonce { sign_ext.payload.5.into() } /// Return transaction tip. - pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { + pub fn tip< + RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, + >( + sign_ext: &RewardingBridgeSignedExtension, + ) -> Balance { sign_ext.payload.7.into() } } diff --git a/primitives/runtime/src/extensions.rs b/primitives/runtime/src/extensions.rs index 14af937d03..440a6df9d7 100644 --- a/primitives/runtime/src/extensions.rs +++ b/primitives/runtime/src/extensions.rs @@ -77,7 +77,7 @@ pub type ChargeTransactionPayment = GenericSignedExtensionSchema; /// The `SignedExtensionSchema` for `RefundBridgedParachainMessages`. -pub type RefundBridgedParachainMessages = GenericSignedExtensionSchema<(), ()>; +pub type RefundBridgedParachainMessages = GenericSignedExtensionSchema; #[impl_for_tuples(1, 12)] impl SignedExtensionSchema for Tuple { diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index b6b844021e..4d551393d2 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -78,6 +78,8 @@ impl ChainWithTransactions for BridgeHubRococo { param.genesis_hash, unsigned.nonce, unsigned.tip, + ((), ()), + ((), ()), ), )?; diff --git a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs index 0f85d25b93..63cdd79e5d 100644 --- a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs @@ -19,6 +19,7 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; +pub use bp_bridge_hub_rococo::rewarding_bridge_signed_extension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; @@ -27,7 +28,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubRococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic< Call, - rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension<((), ()), ((), ())>, >; // The indirect pallet call used to sync `Wococo` GRANDPA finality to `BHRococo`. @@ -69,75 +70,3 @@ impl From> for Call { Call::Utility(call) } } - -// TODO: remove this and use common from cumulus-like once fixed (https://github.com/paritytech/parity-bridges-common/issues/1598) -/// Module with rewarding bridge signed extension support -pub mod rewarding_bridge_signed_extension { - use bp_polkadot_core::{Balance, Hash, Nonce, PolkadotLike}; - use bp_runtime::extensions::*; - - type RewardingBridgeSignedExtra = ( - CheckNonZeroSender, - CheckSpecVersion, - CheckTxVersion, - CheckGenesis, - CheckEra, - CheckNonce, - CheckWeight, - ChargeTransactionPayment, - BridgeRejectObsoleteHeadersAndMessages, - RefundBridgedParachainMessages, - RefundBridgedParachainMessages, - ); - - /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. - pub type RewardingBridgeSignedExtension = GenericSignedExtension; - - pub fn from_params( - spec_version: u32, - transaction_version: u32, - era: bp_runtime::TransactionEraOf, - genesis_hash: Hash, - nonce: Nonce, - tip: Balance, - ) -> RewardingBridgeSignedExtension { - GenericSignedExtension::::new( - ( - (), // non-zero sender - (), // spec version - (), // tx version - (), // genesis - era.frame_era(), // era - nonce.into(), // nonce (compact encoding) - (), // Check weight - tip.into(), // transaction payment / tip (compact encoding) - (), // bridge reject obsolete headers and msgs - (), // bridge-hub-rococo instance1 register reward for message passing - (), // bridge-hub-rococo instance2 register reward for message passing - ), - Some(( - (), - spec_version, - transaction_version, - genesis_hash, - era.signed_payload(genesis_hash), - (), - (), - (), - (), - (), - (), - )), - ) - } - - /// Return signer nonce, used to craft transaction. - pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { - sign_ext.payload.5.into() - } - - /// Return transaction tip. - pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { - sign_ext.payload.7.into() - } -} diff --git a/relays/client-bridge-hub-wococo/src/lib.rs b/relays/client-bridge-hub-wococo/src/lib.rs index a466df3549..8c56647f05 100644 --- a/relays/client-bridge-hub-wococo/src/lib.rs +++ b/relays/client-bridge-hub-wococo/src/lib.rs @@ -78,6 +78,8 @@ impl ChainWithTransactions for BridgeHubWococo { param.genesis_hash, unsigned.nonce, unsigned.tip, + ((), ()), + ((), ()), ), )?; diff --git a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs index 8c0263c6bb..7d2e7e50e9 100644 --- a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs @@ -19,6 +19,7 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; +pub use bp_bridge_hub_wococo::rewarding_bridge_signed_extension; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; @@ -27,7 +28,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubWococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic< Call, - rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension<((), ()), ((), ())>, >; // The indirect pallet call used to sync `Rococo` GRANDPA finality to `BHWococo`. @@ -70,78 +71,6 @@ impl From> for Call { } } -// TODO: remove this and use common from cumulus-like once fixed (https://github.com/paritytech/parity-bridges-common/issues/1598) -/// Module with rewarding bridge signed extension support -pub mod rewarding_bridge_signed_extension { - use bp_polkadot_core::{Balance, Hash, Nonce, PolkadotLike}; - use bp_runtime::extensions::*; - - type RewardingBridgeSignedExtra = ( - CheckNonZeroSender, - CheckSpecVersion, - CheckTxVersion, - CheckGenesis, - CheckEra, - CheckNonce, - CheckWeight, - ChargeTransactionPayment, - BridgeRejectObsoleteHeadersAndMessages, - RefundBridgedParachainMessages, - RefundBridgedParachainMessages, - ); - - /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. - pub type RewardingBridgeSignedExtension = GenericSignedExtension; - - pub fn from_params( - spec_version: u32, - transaction_version: u32, - era: bp_runtime::TransactionEraOf, - genesis_hash: Hash, - nonce: Nonce, - tip: Balance, - ) -> RewardingBridgeSignedExtension { - GenericSignedExtension::::new( - ( - (), // non-zero sender - (), // spec version - (), // tx version - (), // genesis - era.frame_era(), // era - nonce.into(), // nonce (compact encoding) - (), // Check weight - tip.into(), // transaction payment / tip (compact encoding) - (), // bridge reject obsolete headers and msgs - (), // bridge-hub-rococo instance1 register reward for message passing - (), // bridge-hub-rococo instance2 register reward for message passing - ), - Some(( - (), - spec_version, - transaction_version, - genesis_hash, - era.signed_payload(genesis_hash), - (), - (), - (), - (), - (), - (), - )), - ) - } - - /// Return signer nonce, used to craft transaction. - pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { - sign_ext.payload.5.into() - } - - /// Return transaction tip. - pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { - sign_ext.payload.7.into() - } -} - #[cfg(test)] mod tests { use super::*; From 3d2061393bd084ab159b21645cd7d21d6d732022 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 17:23:32 +0100 Subject: [PATCH 6/9] Fix additional_signed --- primitives/chain-bridge-hub-cumulus/src/lib.rs | 1 + primitives/polkadot-core/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 11029f66c9..b329e54fb7 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -202,6 +202,7 @@ pub mod rewarding_bridge_signed_extension { (), (), (), + (), reward_additional_signed, )), ) diff --git a/primitives/polkadot-core/src/lib.rs b/primitives/polkadot-core/src/lib.rs index 3b1712042d..1df89863fe 100644 --- a/primitives/polkadot-core/src/lib.rs +++ b/primitives/polkadot-core/src/lib.rs @@ -366,6 +366,7 @@ impl PolkadotSignedExtension for BridgeSignedExtension { (), (), (), + (), )), ) } From ead47f55cdca3a0b48eec0cdd082ed2cee00f3f5 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 20 Feb 2023 17:25:59 +0100 Subject: [PATCH 7/9] revert fix --- primitives/chain-bridge-hub-cumulus/src/lib.rs | 1 - primitives/polkadot-core/src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index b329e54fb7..11029f66c9 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -202,7 +202,6 @@ pub mod rewarding_bridge_signed_extension { (), (), (), - (), reward_additional_signed, )), ) diff --git a/primitives/polkadot-core/src/lib.rs b/primitives/polkadot-core/src/lib.rs index 1df89863fe..3b1712042d 100644 --- a/primitives/polkadot-core/src/lib.rs +++ b/primitives/polkadot-core/src/lib.rs @@ -366,7 +366,6 @@ impl PolkadotSignedExtension for BridgeSignedExtension { (), (), (), - (), )), ) } From d3db63aab6332ae6fffd8703691ecd629b9148a3 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 21 Feb 2023 10:36:58 +0100 Subject: [PATCH 8/9] Refactor to `RefundBridgedParachainMessagesSchema` --- .../chain-bridge-hub-cumulus/src/lib.rs | 56 ++++--------------- primitives/runtime/src/extensions.rs | 8 ++- relays/client-bridge-hub-rococo/src/lib.rs | 2 - .../src/runtime_wrapper.rs | 2 +- relays/client-bridge-hub-wococo/src/lib.rs | 2 - .../src/runtime_wrapper.rs | 2 +- 6 files changed, 20 insertions(+), 52 deletions(-) diff --git a/primitives/chain-bridge-hub-cumulus/src/lib.rs b/primitives/chain-bridge-hub-cumulus/src/lib.rs index 11029f66c9..3a05cb48b3 100644 --- a/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -130,26 +130,8 @@ pub mod rewarding_bridge_signed_extension { use super::*; use bp_polkadot_core::PolkadotLike; use bp_runtime::extensions::*; - use frame_support::{ - codec::{Decode, Encode}, - scale_info::StaticTypeInfo, - }; - - // TODO: refactor this to extentions.rs - // TODO: replace with bound bellow - // #[impl_for_tuples(1, 12)] - // pub trait SignedExtensionSchemaPayload: - // Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo - // { - // } - // - // #[impl_for_tuples(1, 12)] - // pub trait SignedExtensionSchemaAdditionalSigned: - // Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo - // { - // } - - type RewardingBridgeSignedExtra = ( + + type RewardingBridgeSignedExtra = ( CheckNonZeroSender, CheckSpecVersion, CheckTxVersion, @@ -159,27 +141,21 @@ pub mod rewarding_bridge_signed_extension { CheckWeight, ChargeTransactionPayment, BridgeRejectObsoleteHeadersAndMessages, - RefundBridgedParachainMessages, + RefundBridgedParachainMessagesSchema, ); /// The signed extension used by Cumulus and Cumulus-like parachain with bridging and rewarding. - pub type RewardingBridgeSignedExtension = - GenericSignedExtension>; + pub type RewardingBridgeSignedExtension = GenericSignedExtension; - pub fn from_params< - RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - >( + pub fn from_params( spec_version: u32, transaction_version: u32, era: bp_runtime::TransactionEraOf, genesis_hash: Hash, nonce: Nonce, tip: Balance, - reward_payload: RewardPayload, - reward_additional_signed: RewardAdditionalSigned, - ) -> RewardingBridgeSignedExtension { - GenericSignedExtension::>::new( + ) -> RewardingBridgeSignedExtension { + GenericSignedExtension::::new( ( (), // non-zero sender (), // spec version @@ -190,7 +166,7 @@ pub mod rewarding_bridge_signed_extension { (), // Check weight tip.into(), // transaction payment / tip (compact encoding) (), // bridge reject obsolete headers and msgs - reward_payload, // bridge register reward to relayer for message passing + (), // bridge register reward to relayer for message passing ), Some(( (), @@ -202,28 +178,18 @@ pub mod rewarding_bridge_signed_extension { (), (), (), - reward_additional_signed, + (), )), ) } /// Return signer nonce, used to craft transaction. - pub fn nonce< - RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - >( - sign_ext: &RewardingBridgeSignedExtension, - ) -> Nonce { + pub fn nonce(sign_ext: &RewardingBridgeSignedExtension) -> Nonce { sign_ext.payload.5.into() } /// Return transaction tip. - pub fn tip< - RewardPayload: Encode + Decode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - RewardAdditionalSigned: Encode + std::fmt::Debug + Eq + Clone + StaticTypeInfo, - >( - sign_ext: &RewardingBridgeSignedExtension, - ) -> Balance { + pub fn tip(sign_ext: &RewardingBridgeSignedExtension) -> Balance { sign_ext.payload.7.into() } } diff --git a/primitives/runtime/src/extensions.rs b/primitives/runtime/src/extensions.rs index 440a6df9d7..ea51d03741 100644 --- a/primitives/runtime/src/extensions.rs +++ b/primitives/runtime/src/extensions.rs @@ -77,7 +77,13 @@ pub type ChargeTransactionPayment = GenericSignedExtensionSchema; /// The `SignedExtensionSchema` for `RefundBridgedParachainMessages`. -pub type RefundBridgedParachainMessages = GenericSignedExtensionSchema; +/// This schema is dedicated for `RefundBridgedParachainMessages` signed extension as +/// wildcard/placeholder, which relies on the scale encoding for `()` or `((), ())`, or `((), (), +/// ())` is the same. So runtime can contains any kind of tuple: +/// `(BridgeRefundBridgeHubRococoMessages)` +/// `(BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWococoMessages)` +/// `(BridgeRefundParachainMessages1, ..., BridgeRefundParachainMessagesN)` +pub type RefundBridgedParachainMessagesSchema = GenericSignedExtensionSchema<(), ()>; #[impl_for_tuples(1, 12)] impl SignedExtensionSchema for Tuple { diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index 4d551393d2..b6b844021e 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -78,8 +78,6 @@ impl ChainWithTransactions for BridgeHubRococo { param.genesis_hash, unsigned.nonce, unsigned.tip, - ((), ()), - ((), ()), ), )?; diff --git a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs index 63cdd79e5d..711306b012 100644 --- a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs @@ -28,7 +28,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubRococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic< Call, - rewarding_bridge_signed_extension::RewardingBridgeSignedExtension<((), ()), ((), ())>, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, >; // The indirect pallet call used to sync `Wococo` GRANDPA finality to `BHRococo`. diff --git a/relays/client-bridge-hub-wococo/src/lib.rs b/relays/client-bridge-hub-wococo/src/lib.rs index 8c56647f05..a466df3549 100644 --- a/relays/client-bridge-hub-wococo/src/lib.rs +++ b/relays/client-bridge-hub-wococo/src/lib.rs @@ -78,8 +78,6 @@ impl ChainWithTransactions for BridgeHubWococo { param.genesis_hash, unsigned.nonce, unsigned.tip, - ((), ()), - ((), ()), ), )?; diff --git a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs index 7d2e7e50e9..13fb1a7e6a 100644 --- a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs @@ -28,7 +28,7 @@ pub use relay_substrate_client::calls::{SystemCall, UtilityCall}; /// Unchecked BridgeHubWococo extrinsic. pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic< Call, - rewarding_bridge_signed_extension::RewardingBridgeSignedExtension<((), ()), ((), ())>, + rewarding_bridge_signed_extension::RewardingBridgeSignedExtension, >; // The indirect pallet call used to sync `Rococo` GRANDPA finality to `BHWococo`. From 51dd1ff0933b740f95b808ad14d111517b66ba56 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 21 Feb 2023 10:41:28 +0100 Subject: [PATCH 9/9] removed unused deps --- Cargo.lock | 2 -- relays/client-bridge-hub-rococo/Cargo.toml | 2 -- relays/client-bridge-hub-wococo/Cargo.toml | 1 - 3 files changed, 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6eb6e9ee53..899367d037 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9201,8 +9201,6 @@ dependencies = [ "bp-header-chain", "bp-messages", "bp-parachains", - "bp-polkadot-core", - "bp-runtime", "bp-wococo", "bridge-runtime-common", "parity-scale-codec", diff --git a/relays/client-bridge-hub-rococo/Cargo.toml b/relays/client-bridge-hub-rococo/Cargo.toml index 26fe2dd90a..9a9316fa11 100644 --- a/relays/client-bridge-hub-rococo/Cargo.toml +++ b/relays/client-bridge-hub-rococo/Cargo.toml @@ -17,8 +17,6 @@ bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" } bp-header-chain = { path = "../../primitives/header-chain" } bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } -bp-polkadot-core = { path = "../../primitives/polkadot-core" } -bp-runtime = { path = "../../primitives/runtime" } bp-wococo = { path = "../../primitives/chain-wococo" } bridge-runtime-common = { path = "../../bin/runtime-common" } diff --git a/relays/client-bridge-hub-wococo/Cargo.toml b/relays/client-bridge-hub-wococo/Cargo.toml index 7b8952da0e..7c9b90975d 100644 --- a/relays/client-bridge-hub-wococo/Cargo.toml +++ b/relays/client-bridge-hub-wococo/Cargo.toml @@ -17,7 +17,6 @@ bp-bridge-hub-wococo = { path = "../../primitives/chain-bridge-hub-wococo" } bp-header-chain = { path = "../../primitives/header-chain" } bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } -bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-rococo = { path = "../../primitives/chain-rococo" } bp-runtime = { path = "../../primitives/runtime" }