mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 07:31:02 +00:00
use complex transactions on RBH/WBH bridge hubs (#1893)
This commit is contained in:
committed by
Bastian Köcher
parent
976e96608c
commit
bb078b8226
+3
-3
@@ -19,7 +19,7 @@
|
|||||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
||||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||||
use relay_bridge_hub_wococo_client::BridgeHubWococo;
|
use relay_bridge_hub_wococo_client::BridgeHubWococo;
|
||||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
use substrate_relay_helper::{messages_lane::SubstrateMessageLane, UtilityPalletBatchCallBuilder};
|
||||||
|
|
||||||
pub struct BridgeHubRococoToBridgeHubWococoMessagesCliBridge {}
|
pub struct BridgeHubRococoToBridgeHubWococoMessagesCliBridge {}
|
||||||
|
|
||||||
@@ -59,6 +59,6 @@ impl SubstrateMessageLane for BridgeHubRococoMessagesToBridgeHubWococoMessageLan
|
|||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
||||||
|
|
||||||
type SourceBatchCallBuilder = ();
|
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
|
||||||
type TargetBatchCallBuilder = ();
|
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -19,7 +19,7 @@
|
|||||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
||||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||||
use relay_bridge_hub_wococo_client::BridgeHubWococo;
|
use relay_bridge_hub_wococo_client::BridgeHubWococo;
|
||||||
use substrate_relay_helper::messages_lane::SubstrateMessageLane;
|
use substrate_relay_helper::{messages_lane::SubstrateMessageLane, UtilityPalletBatchCallBuilder};
|
||||||
|
|
||||||
pub struct BridgeHubWococoToBridgeHubRococoMessagesCliBridge {}
|
pub struct BridgeHubWococoToBridgeHubRococoMessagesCliBridge {}
|
||||||
|
|
||||||
@@ -59,6 +59,6 @@ impl SubstrateMessageLane for BridgeHubWococoMessagesToBridgeHubRococoMessageLan
|
|||||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||||
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
||||||
|
|
||||||
type SourceBatchCallBuilder = ();
|
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
|
||||||
type TargetBatchCallBuilder = ();
|
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ use bp_bridge_hub_wococo::PolkadotSignedExtension;
|
|||||||
use bp_messages::MessageNonce;
|
use bp_messages::MessageNonce;
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use relay_substrate_client::{
|
use relay_substrate_client::{
|
||||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
|
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||||
SignParam, UnderlyingChainProvider, UnsignedTransaction,
|
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
|
||||||
|
UnsignedTransaction,
|
||||||
};
|
};
|
||||||
use sp_core::{storage::StorageKey, Pair};
|
use sp_core::{storage::StorageKey, Pair};
|
||||||
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
||||||
@@ -57,6 +58,10 @@ impl ChainWithBalances for BridgeHubRococo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChainWithUtilityPallet for BridgeHubRococo {
|
||||||
|
type UtilityPallet = MockedRuntimeUtilityPallet<runtime::Call>;
|
||||||
|
}
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubRococo {
|
impl ChainWithTransactions for BridgeHubRococo {
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||||
type SignedTransaction = runtime::UncheckedExtrinsic;
|
type SignedTransaction = runtime::UncheckedExtrinsic;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use bp_bridge_hub_rococo::SignedExtension;
|
|||||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
pub use bp_header_chain::BridgeGrandpaCallOf;
|
||||||
pub use bp_parachains::BridgeParachainCall;
|
pub use bp_parachains::BridgeParachainCall;
|
||||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
||||||
pub use relay_substrate_client::calls::SystemCall;
|
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||||
|
|
||||||
/// Unchecked BridgeHubRococo extrinsic.
|
/// Unchecked BridgeHubRococo extrinsic.
|
||||||
pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<Call, SignedExtension>;
|
pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<Call, SignedExtension>;
|
||||||
@@ -49,6 +49,9 @@ pub enum Call {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[codec(index = 0)]
|
#[codec(index = 0)]
|
||||||
System(SystemCall),
|
System(SystemCall),
|
||||||
|
/// Utility pallet.
|
||||||
|
#[codec(index = 40)]
|
||||||
|
Utility(UtilityCall<Call>),
|
||||||
|
|
||||||
/// Wococo bridge pallet.
|
/// Wococo bridge pallet.
|
||||||
#[codec(index = 41)]
|
#[codec(index = 41)]
|
||||||
@@ -60,3 +63,9 @@ pub enum Call {
|
|||||||
#[codec(index = 46)]
|
#[codec(index = 46)]
|
||||||
BridgeWococoMessages(BridgeWococoMessagesCall),
|
BridgeWococoMessages(BridgeWococoMessagesCall),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<UtilityCall<Call>> for Call {
|
||||||
|
fn from(call: UtilityCall<Call>) -> Call {
|
||||||
|
Call::Utility(call)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ use bp_bridge_hub_wococo::{PolkadotSignedExtension, AVERAGE_BLOCK_INTERVAL};
|
|||||||
use bp_messages::MessageNonce;
|
use bp_messages::MessageNonce;
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use relay_substrate_client::{
|
use relay_substrate_client::{
|
||||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
|
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||||
SignParam, UnderlyingChainProvider, UnsignedTransaction,
|
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
|
||||||
|
UnsignedTransaction,
|
||||||
};
|
};
|
||||||
use sp_core::{storage::StorageKey, Pair};
|
use sp_core::{storage::StorageKey, Pair};
|
||||||
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
|
||||||
@@ -56,6 +57,10 @@ impl ChainWithBalances for BridgeHubWococo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChainWithUtilityPallet for BridgeHubWococo {
|
||||||
|
type UtilityPallet = MockedRuntimeUtilityPallet<runtime::Call>;
|
||||||
|
}
|
||||||
|
|
||||||
impl ChainWithTransactions for BridgeHubWococo {
|
impl ChainWithTransactions for BridgeHubWococo {
|
||||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||||
type SignedTransaction = runtime::UncheckedExtrinsic;
|
type SignedTransaction = runtime::UncheckedExtrinsic;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use bp_bridge_hub_wococo::SignedExtension;
|
|||||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
pub use bp_header_chain::BridgeGrandpaCallOf;
|
||||||
pub use bp_parachains::BridgeParachainCall;
|
pub use bp_parachains::BridgeParachainCall;
|
||||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
||||||
pub use relay_substrate_client::calls::SystemCall;
|
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||||
|
|
||||||
/// Unchecked BridgeHubWococo extrinsic.
|
/// Unchecked BridgeHubWococo extrinsic.
|
||||||
pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic<Call, SignedExtension>;
|
pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic<Call, SignedExtension>;
|
||||||
@@ -47,6 +47,9 @@ pub enum Call {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[codec(index = 0)]
|
#[codec(index = 0)]
|
||||||
System(SystemCall),
|
System(SystemCall),
|
||||||
|
/// Utility pallet.
|
||||||
|
#[codec(index = 40)]
|
||||||
|
Utility(UtilityCall<Call>),
|
||||||
|
|
||||||
/// Rococo bridge pallet.
|
/// Rococo bridge pallet.
|
||||||
#[codec(index = 43)]
|
#[codec(index = 43)]
|
||||||
@@ -59,6 +62,12 @@ pub enum Call {
|
|||||||
BridgeRococoMessages(BridgeRococoMessagesCall),
|
BridgeRococoMessages(BridgeRococoMessagesCall),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<UtilityCall<Call>> for Call {
|
||||||
|
fn from(call: UtilityCall<Call>) -> Call {
|
||||||
|
Call::Utility(call)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -31,6 +31,15 @@ pub enum SystemCall {
|
|||||||
remark(Vec<u8>),
|
remark(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A minimized version of `pallet-utility::Call` that can be used without a runtime.
|
||||||
|
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub enum UtilityCall<Call> {
|
||||||
|
/// `pallet-utility::Call::batch_all`
|
||||||
|
#[codec(index = 2)]
|
||||||
|
batch_all(Vec<Call>),
|
||||||
|
}
|
||||||
|
|
||||||
/// A minimized version of `pallet-sudo::Call` that can be used without a runtime.
|
/// A minimized version of `pallet-sudo::Call` that can be used without a runtime.
|
||||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
// 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/>.
|
||||||
|
|
||||||
|
use crate::calls::UtilityCall;
|
||||||
|
|
||||||
use bp_messages::MessageNonce;
|
use bp_messages::MessageNonce;
|
||||||
use bp_runtime::{
|
use bp_runtime::{
|
||||||
Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra,
|
Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra,
|
||||||
@@ -276,6 +278,21 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Structure that implements `UtilityPalletProvider` based on a call conversion.
|
||||||
|
pub struct MockedRuntimeUtilityPallet<Call> {
|
||||||
|
_phantom: std::marker::PhantomData<Call>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C, Call> UtilityPallet<C> for MockedRuntimeUtilityPallet<Call>
|
||||||
|
where
|
||||||
|
C: Chain,
|
||||||
|
C::Call: From<UtilityCall<C::Call>>,
|
||||||
|
{
|
||||||
|
fn build_batch_call(calls: Vec<C::Call>) -> C::Call {
|
||||||
|
UtilityCall::batch_all(calls).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Substrate-based chain that uses `pallet-utility`.
|
/// Substrate-based chain that uses `pallet-utility`.
|
||||||
pub trait ChainWithUtilityPallet: Chain {
|
pub trait ChainWithUtilityPallet: Chain {
|
||||||
/// The utility pallet provider.
|
/// The utility pallet provider.
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ pub use crate::{
|
|||||||
chain::{
|
chain::{
|
||||||
AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances,
|
AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances,
|
||||||
ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||||
FullRuntimeUtilityPallet, Parachain, RelayChain, SignParam, TransactionStatusOf,
|
FullRuntimeUtilityPallet, MockedRuntimeUtilityPallet, Parachain, RelayChain, SignParam,
|
||||||
UnsignedTransaction, UtilityPallet,
|
TransactionStatusOf, UnsignedTransaction, UtilityPallet,
|
||||||
},
|
},
|
||||||
client::{
|
client::{
|
||||||
is_ancient_block, ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet,
|
is_ancient_block, ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet,
|
||||||
|
|||||||
Reference in New Issue
Block a user