mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51: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 relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
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 {}
|
||||
|
||||
@@ -59,6 +59,6 @@ impl SubstrateMessageLane for BridgeHubRococoMessagesToBridgeHubWococoMessageLan
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
BridgeHubRococoMessagesToBridgeHubWococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type SourceBatchCallBuilder = ();
|
||||
type TargetBatchCallBuilder = ();
|
||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
|
||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
|
||||
}
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@
|
||||
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
|
||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
||||
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 {}
|
||||
|
||||
@@ -59,6 +59,6 @@ impl SubstrateMessageLane for BridgeHubWococoMessagesToBridgeHubRococoMessageLan
|
||||
type ReceiveMessagesDeliveryProofCallBuilder =
|
||||
BridgeHubWococoMessagesToBridgeHubRococoMessageLaneReceiveMessagesDeliveryProofCallBuilder;
|
||||
|
||||
type SourceBatchCallBuilder = ();
|
||||
type TargetBatchCallBuilder = ();
|
||||
type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubWococo>;
|
||||
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<BridgeHubRococo>;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ use bp_bridge_hub_wococo::PolkadotSignedExtension;
|
||||
use bp_messages::MessageNonce;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
|
||||
SignParam, UnderlyingChainProvider, UnsignedTransaction,
|
||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
|
||||
UnsignedTransaction,
|
||||
};
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
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 {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction = runtime::UncheckedExtrinsic;
|
||||
|
||||
@@ -25,7 +25,7 @@ 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;
|
||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||
|
||||
/// Unchecked BridgeHubRococo extrinsic.
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<Call, SignedExtension>;
|
||||
@@ -49,6 +49,9 @@ pub enum Call {
|
||||
#[cfg(test)]
|
||||
#[codec(index = 0)]
|
||||
System(SystemCall),
|
||||
/// Utility pallet.
|
||||
#[codec(index = 40)]
|
||||
Utility(UtilityCall<Call>),
|
||||
|
||||
/// Wococo bridge pallet.
|
||||
#[codec(index = 41)]
|
||||
@@ -60,3 +63,9 @@ pub enum Call {
|
||||
#[codec(index = 46)]
|
||||
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 codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError,
|
||||
SignParam, UnderlyingChainProvider, UnsignedTransaction,
|
||||
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||
Error as SubstrateError, MockedRuntimeUtilityPallet, SignParam, UnderlyingChainProvider,
|
||||
UnsignedTransaction,
|
||||
};
|
||||
use sp_core::{storage::StorageKey, Pair};
|
||||
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 {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction = runtime::UncheckedExtrinsic;
|
||||
|
||||
@@ -23,7 +23,7 @@ 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;
|
||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||
|
||||
/// Unchecked BridgeHubWococo extrinsic.
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_wococo::UncheckedExtrinsic<Call, SignedExtension>;
|
||||
@@ -47,6 +47,9 @@ pub enum Call {
|
||||
#[cfg(test)]
|
||||
#[codec(index = 0)]
|
||||
System(SystemCall),
|
||||
/// Utility pallet.
|
||||
#[codec(index = 40)]
|
||||
Utility(UtilityCall<Call>),
|
||||
|
||||
/// Rococo bridge pallet.
|
||||
#[codec(index = 43)]
|
||||
@@ -59,6 +62,12 @@ pub enum Call {
|
||||
BridgeRococoMessages(BridgeRococoMessagesCall),
|
||||
}
|
||||
|
||||
impl From<UtilityCall<Call>> for Call {
|
||||
fn from(call: UtilityCall<Call>) -> Call {
|
||||
Call::Utility(call)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -31,6 +31,15 @@ pub enum SystemCall {
|
||||
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.
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
||||
#[allow(non_camel_case_types)]
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
// 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/>.
|
||||
|
||||
use crate::calls::UtilityCall;
|
||||
|
||||
use bp_messages::MessageNonce;
|
||||
use bp_runtime::{
|
||||
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`.
|
||||
pub trait ChainWithUtilityPallet: Chain {
|
||||
/// The utility pallet provider.
|
||||
|
||||
@@ -36,8 +36,8 @@ pub use crate::{
|
||||
chain::{
|
||||
AccountKeyPairOf, BlockWithJustification, CallOf, Chain, ChainWithBalances,
|
||||
ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
|
||||
FullRuntimeUtilityPallet, Parachain, RelayChain, SignParam, TransactionStatusOf,
|
||||
UnsignedTransaction, UtilityPallet,
|
||||
FullRuntimeUtilityPallet, MockedRuntimeUtilityPallet, Parachain, RelayChain, SignParam,
|
||||
TransactionStatusOf, UnsignedTransaction, UtilityPallet,
|
||||
},
|
||||
client::{
|
||||
is_ancient_block, ChainRuntimeVersion, Client, OpaqueGrandpaAuthoritiesSet,
|
||||
|
||||
Reference in New Issue
Block a user