Move some associated types from relay_substrate_client::Chain to bp_runtime::Chain (#1087)

* move some associated types from relay_substrate_client::Chain to bp_runtime::Chain

* dummy commit

* Revert "dummy commit"

This reverts commit 81bc64aa092df115a7c68e7bb7ca5e83ec31fd20.
This commit is contained in:
Svyatoslav Nikolsky
2021-09-09 11:19:39 +03:00
committed by Bastian Köcher
parent 1df7076c4f
commit 7369ff9d70
34 changed files with 254 additions and 162 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ pub type AccountIndex = u32;
pub type Balance = bp_millau::Balance; pub type Balance = bp_millau::Balance;
/// Index of a transaction in the chain. /// Index of a transaction in the chain.
pub type Index = u32; pub type Index = bp_millau::Index;
/// A hash of some data used by the chain. /// A hash of some data used by the chain.
pub type Hash = bp_millau::Hash; pub type Hash = bp_millau::Hash;
+1 -1
View File
@@ -95,7 +95,7 @@ pub type AccountIndex = u32;
pub type Balance = bp_rialto::Balance; pub type Balance = bp_rialto::Balance;
/// Index of a transaction in the chain. /// Index of a transaction in the chain.
pub type Index = u32; pub type Index = bp_rialto::Index;
/// A hash of some data used by the chain. /// A hash of some data used by the chain.
pub type Hash = bp_rialto::Hash; pub type Hash = bp_rialto::Hash;
+6 -1
View File
@@ -22,7 +22,7 @@ use frame_support::{construct_runtime, parameter_types, weights::Weight};
use sp_runtime::{ use sp_runtime::{
testing::{Header, H256}, testing::{Header, H256},
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
Perbill, AnySignature, Perbill,
}; };
pub type AccountId = u64; pub type AccountId = u64;
@@ -101,6 +101,11 @@ impl Chain for TestBridgedChain {
type Hash = <TestRuntime as frame_system::Config>::Hash; type Hash = <TestRuntime as frame_system::Config>::Hash;
type Hasher = <TestRuntime as frame_system::Config>::Hashing; type Hasher = <TestRuntime as frame_system::Config>::Hashing;
type Header = <TestRuntime as frame_system::Config>::Header; type Header = <TestRuntime as frame_system::Config>::Header;
type AccountId = AccountId;
type Balance = u64;
type Index = u64;
type Signature = AnySignature;
} }
pub fn run_test<T>(test: impl FnOnce() -> T) -> T { pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
+51 -37
View File
@@ -122,25 +122,30 @@ pub mod pallet {
/// Converter from raw hash (derived from swap) to This chain account. /// Converter from raw hash (derived from swap) to This chain account.
type FromSwapToThisAccountIdConverter: Convert<H256, Self::AccountId>; type FromSwapToThisAccountIdConverter: Convert<H256, Self::AccountId>;
/// Tokens balance type at the Bridged chain. /// The chain we're bridged to.
type BridgedBalance: Parameter; type BridgedChain: bp_runtime::Chain;
/// Account identifier type at the Bridged chain.
type BridgedAccountId: Parameter;
/// Account public key type at the Bridged chain.
type BridgedAccountPublic: Parameter;
/// Account signature type at the Bridged chain.
type BridgedAccountSignature: Parameter;
/// Converter from raw hash (derived from Bridged chain account) to This chain account. /// Converter from raw hash (derived from Bridged chain account) to This chain account.
type FromBridgedToThisAccountIdConverter: Convert<H256, Self::AccountId>; type FromBridgedToThisAccountIdConverter: Convert<H256, Self::AccountId>;
} }
/// Type of the Bridged chain.
pub type BridgedChainOf<T, I> = <T as Config<I>>::BridgedChain;
/// Tokens balance type at the Bridged chain.
pub type BridgedBalanceOf<T, I> = bp_runtime::BalanceOf<BridgedChainOf<T, I>>;
/// Account identifier type at the Bridged chain.
pub type BridgedAccountIdOf<T, I> = bp_runtime::AccountIdOf<BridgedChainOf<T, I>>;
/// Account public key type at the Bridged chain.
pub type BridgedAccountPublicOf<T, I> = bp_runtime::AccountPublicOf<BridgedChainOf<T, I>>;
/// Account signature type at the Bridged chain.
pub type BridgedAccountSignatureOf<T, I> = bp_runtime::SignatureOf<BridgedChainOf<T, I>>;
/// SCALE-encoded `Currency::transfer` call on the bridged chain. /// SCALE-encoded `Currency::transfer` call on the bridged chain.
pub type RawBridgedTransferCall = Vec<u8>; pub type RawBridgedTransferCall = Vec<u8>;
/// Bridge message payload used by the pallet. /// Bridge message payload used by the pallet.
pub type MessagePayloadOf<T, I> = bp_message_dispatch::MessagePayload< pub type MessagePayloadOf<T, I> = bp_message_dispatch::MessagePayload<
<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId,
<T as Config<I>>::BridgedAccountPublic, BridgedAccountPublicOf<T, I>,
<T as Config<I>>::BridgedAccountSignature, BridgedAccountSignatureOf<T, I>,
RawBridgedTransferCall, RawBridgedTransferCall,
>; >;
/// Type of `TokenSwap` used by the pallet. /// Type of `TokenSwap` used by the pallet.
@@ -148,8 +153,8 @@ pub mod pallet {
BlockNumberFor<T>, BlockNumberFor<T>,
<<T as Config<I>>::ThisCurrency as Currency<<T as frame_system::Config>::AccountId>>::Balance, <<T as Config<I>>::ThisCurrency as Currency<<T as frame_system::Config>::AccountId>>::Balance,
<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId,
<T as Config<I>>::BridgedBalance, BridgedBalanceOf<T, I>,
<T as Config<I>>::BridgedAccountId, BridgedAccountIdOf<T, I>,
>; >;
#[pallet::pallet] #[pallet::pallet]
@@ -160,7 +165,10 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {} impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {}
#[pallet::call] #[pallet::call]
impl<T: Config<I>, I: 'static> Pallet<T, I> { impl<T: Config<I>, I: 'static> Pallet<T, I>
where
BridgedAccountPublicOf<T, I>: Parameter,
{
/// Start token swap procedure. /// Start token swap procedure.
/// ///
/// The dispatch origin for this call must be exactly the `swap.source_account_at_this_chain` account. /// The dispatch origin for this call must be exactly the `swap.source_account_at_this_chain` account.
@@ -194,11 +202,11 @@ pub mod pallet {
pub fn create_swap( pub fn create_swap(
origin: OriginFor<T>, origin: OriginFor<T>,
swap: TokenSwapOf<T, I>, swap: TokenSwapOf<T, I>,
target_public_at_bridged_chain: T::BridgedAccountPublic, target_public_at_bridged_chain: BridgedAccountPublicOf<T, I>,
bridged_chain_spec_version: u32, bridged_chain_spec_version: u32,
bridged_currency_transfer: RawBridgedTransferCall, bridged_currency_transfer: RawBridgedTransferCall,
bridged_currency_transfer_weight: Weight, bridged_currency_transfer_weight: Weight,
bridged_currency_transfer_signature: T::BridgedAccountSignature, bridged_currency_transfer_signature: BridgedAccountSignatureOf<T, I>,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
// ensure that the `origin` is the same account that is mentioned in the `swap` intention // ensure that the `origin` is the same account that is mentioned in the `swap` intention
let origin_account = ensure_signed(origin)?; let origin_account = ensure_signed(origin)?;
@@ -541,12 +549,18 @@ mod tests {
const CAN_START_BLOCK_NUMBER: u64 = 10; const CAN_START_BLOCK_NUMBER: u64 = 10;
const CAN_CLAIM_BLOCK_NUMBER: u64 = CAN_START_BLOCK_NUMBER + 1; const CAN_CLAIM_BLOCK_NUMBER: u64 = CAN_START_BLOCK_NUMBER + 1;
const BRIDGED_CHAIN_ACCOUNT_PUBLIC: BridgedAccountPublic = 1;
const BRIDGED_CHAIN_ACCOUNT_SIGNATURE: BridgedAccountSignature = 2;
const BRIDGED_CHAIN_ACCOUNT: BridgedAccountId = 3; const BRIDGED_CHAIN_ACCOUNT: BridgedAccountId = 3;
const BRIDGED_CHAIN_SPEC_VERSION: u32 = 4; const BRIDGED_CHAIN_SPEC_VERSION: u32 = 4;
const BRIDGED_CHAIN_CALL_WEIGHT: Balance = 5; const BRIDGED_CHAIN_CALL_WEIGHT: Balance = 5;
fn bridged_chain_account_public() -> BridgedAccountPublic {
1.into()
}
fn bridged_chain_account_signature() -> BridgedAccountSignature {
sp_runtime::testing::TestSignature(2, Vec::new())
}
fn test_swap() -> TokenSwapOf<TestRuntime, ()> { fn test_swap() -> TokenSwapOf<TestRuntime, ()> {
bp_token_swap::TokenSwap { bp_token_swap::TokenSwap {
swap_type: TokenSwapType::LockClaimUntilBlock(CAN_START_BLOCK_NUMBER, 0.into()), swap_type: TokenSwapType::LockClaimUntilBlock(CAN_START_BLOCK_NUMBER, 0.into()),
@@ -569,11 +583,11 @@ mod tests {
assert_ok!(Pallet::<TestRuntime>::create_swap( assert_ok!(Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
)); ));
} }
@@ -591,11 +605,11 @@ mod tests {
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT + 1), Origin::signed(THIS_CHAIN_ACCOUNT + 1),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::MismatchedSwapSourceOrigin Error::<TestRuntime, ()>::MismatchedSwapSourceOrigin
); );
@@ -611,11 +625,11 @@ mod tests {
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
swap, swap,
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::TooLowBalanceOnThisChain Error::<TestRuntime, ()>::TooLowBalanceOnThisChain
); );
@@ -631,11 +645,11 @@ mod tests {
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
swap, swap,
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::FailedToTransferToSwapAccount Error::<TestRuntime, ()>::FailedToTransferToSwapAccount
); );
@@ -651,11 +665,11 @@ mod tests {
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
transfer, transfer,
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::FailedToSendTransferMessage Error::<TestRuntime, ()>::FailedToSendTransferMessage
); );
@@ -668,22 +682,22 @@ mod tests {
assert_ok!(Pallet::<TestRuntime>::create_swap( assert_ok!(Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
)); ));
assert_noop!( assert_noop!(
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::SwapAlreadyStarted Error::<TestRuntime, ()>::SwapAlreadyStarted
); );
@@ -698,11 +712,11 @@ mod tests {
Pallet::<TestRuntime>::create_swap( Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
), ),
Error::<TestRuntime, ()>::SwapPeriodIsFinished Error::<TestRuntime, ()>::SwapPeriodIsFinished
); );
@@ -716,11 +730,11 @@ mod tests {
assert_ok!(Pallet::<TestRuntime>::create_swap( assert_ok!(Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
)); ));
}); });
} }
@@ -734,11 +748,11 @@ mod tests {
assert_ok!(Pallet::<TestRuntime>::create_swap( assert_ok!(Pallet::<TestRuntime>::create_swap(
Origin::signed(THIS_CHAIN_ACCOUNT), Origin::signed(THIS_CHAIN_ACCOUNT),
test_swap(), test_swap(),
BRIDGED_CHAIN_ACCOUNT_PUBLIC, bridged_chain_account_public(),
BRIDGED_CHAIN_SPEC_VERSION, BRIDGED_CHAIN_SPEC_VERSION,
test_transfer(), test_transfer(),
BRIDGED_CHAIN_CALL_WEIGHT, BRIDGED_CHAIN_CALL_WEIGHT,
BRIDGED_CHAIN_ACCOUNT_SIGNATURE, bridged_chain_account_signature(),
)); ));
let swap_hash = test_swap_hash(); let swap_hash = test_swap_hash();
+17 -6
View File
@@ -31,8 +31,8 @@ pub type AccountId = u64;
pub type Balance = u64; pub type Balance = u64;
pub type Block = frame_system::mocking::MockBlock<TestRuntime>; pub type Block = frame_system::mocking::MockBlock<TestRuntime>;
pub type BridgedAccountId = u64; pub type BridgedAccountId = u64;
pub type BridgedAccountPublic = u64; pub type BridgedAccountPublic = sp_runtime::testing::UintAuthorityId;
pub type BridgedAccountSignature = u64; pub type BridgedAccountSignature = sp_runtime::testing::TestSignature;
pub type BridgedBalance = u64; pub type BridgedBalance = u64;
pub type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>; pub type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
@@ -122,13 +122,24 @@ impl pallet_bridge_token_swap::Config for TestRuntime {
type ThisCurrency = pallet_balances::Pallet<TestRuntime>; type ThisCurrency = pallet_balances::Pallet<TestRuntime>;
type FromSwapToThisAccountIdConverter = TestAccountConverter; type FromSwapToThisAccountIdConverter = TestAccountConverter;
type BridgedBalance = BridgedBalance; type BridgedChain = BridgedChain;
type BridgedAccountId = BridgedAccountId;
type BridgedAccountPublic = BridgedAccountPublic;
type BridgedAccountSignature = BridgedAccountSignature;
type FromBridgedToThisAccountIdConverter = TestAccountConverter; type FromBridgedToThisAccountIdConverter = TestAccountConverter;
} }
pub struct BridgedChain;
impl bp_runtime::Chain for BridgedChain {
type BlockNumber = u64;
type Hash = H256;
type Hasher = BlakeTwo256;
type Header = sp_runtime::generic::Header<u64, BlakeTwo256>;
type AccountId = BridgedAccountId;
type Balance = BridgedBalance;
type Index = u64;
type Signature = BridgedAccountSignature;
}
pub struct TestMessagesBridge; pub struct TestMessagesBridge;
impl MessagesBridge<AccountId, Balance, MessagePayloadOf<TestRuntime, ()>> for TestMessagesBridge { impl MessagesBridge<AccountId, Balance, MessagePayloadOf<TestRuntime, ()>> for TestMessagesBridge {
@@ -149,6 +149,9 @@ pub type AccountSigner = MultiSigner;
/// Balance of an account. /// Balance of an account.
pub type Balance = u64; pub type Balance = u64;
/// Index of a transaction in the chain.
pub type Index = u32;
/// Weight-to-Fee type used by Millau. /// Weight-to-Fee type used by Millau.
pub type WeightToFee = IdentityFee<Balance>; pub type WeightToFee = IdentityFee<Balance>;
@@ -161,6 +164,11 @@ impl Chain for Millau {
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
type Header = Header; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Signature = Signature;
} }
/// Millau Hasher (Blake2-256 ++ Keccak-256) implementation. /// Millau Hasher (Blake2-256 ++ Keccak-256) implementation.
@@ -148,6 +148,9 @@ pub type Balance = u128;
/// An instant or duration in time. /// An instant or duration in time.
pub type Moment = u64; pub type Moment = u64;
/// Index of a transaction in the chain.
pub type Index = u32;
/// Weight-to-Fee type used by Rialto. /// Weight-to-Fee type used by Rialto.
pub type WeightToFee = IdentityFee<Balance>; pub type WeightToFee = IdentityFee<Balance>;
@@ -160,6 +163,11 @@ impl Chain for Rialto {
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
type Header = Header; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Signature = Signature;
} }
/// Convert a 256-bit hash into an AccountId. /// Convert a 256-bit hash into an AccountId.
@@ -342,6 +342,11 @@ impl Chain for PolkadotLike {
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
type Header = Header; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Signature = Signature;
} }
/// Convert a 256-bit hash into an AccountId. /// Convert a 256-bit hash into an AccountId.
+58 -7
View File
@@ -15,12 +15,15 @@
// 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 frame_support::Parameter; use frame_support::Parameter;
use num_traits::AsPrimitive; use num_traits::{AsPrimitive, Bounded, CheckedSub, SaturatingAdd, Zero};
use sp_runtime::traits::{ use sp_runtime::{
AtLeast32BitUnsigned, Hash as HashT, Header as HeaderT, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, traits::{
Member, SimpleBitOps, AtLeast32Bit, AtLeast32BitUnsigned, Hash as HashT, Header as HeaderT, MaybeDisplay, MaybeMallocSizeOf,
MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps, Verify,
},
FixedPointOperand,
}; };
use sp_std::str::FromStr; use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr};
/// Minimal Substrate-based chain representation that may be used from no_std environment. /// Minimal Substrate-based chain representation that may be used from no_std environment.
pub trait Chain: Send + Sync + 'static { pub trait Chain: Send + Sync + 'static {
@@ -34,7 +37,7 @@ pub trait Chain: Send + Sync + 'static {
type BlockNumber: Parameter type BlockNumber: Parameter
+ Member + Member
+ MaybeSerializeDeserialize + MaybeSerializeDeserialize
+ sp_std::hash::Hash + Hash
+ Copy + Copy
+ Default + Default
+ MaybeDisplay + MaybeDisplay
@@ -54,7 +57,7 @@ pub trait Chain: Send + Sync + 'static {
type Hash: Parameter type Hash: Parameter
+ Member + Member
+ MaybeSerializeDeserialize + MaybeSerializeDeserialize
+ sp_std::hash::Hash + Hash
+ Ord + Ord
+ Copy + Copy
+ MaybeDisplay + MaybeDisplay
@@ -75,6 +78,39 @@ pub trait Chain: Send + Sync + 'static {
// See here for more info: // See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html // https://crates.parity.io/sp_runtime/traits/trait.Header.html
type Header: Parameter + HeaderT<Number = Self::BlockNumber, Hash = Self::Hash> + MaybeSerializeDeserialize; type Header: Parameter + HeaderT<Number = Self::BlockNumber, Hash = Self::Hash> + MaybeSerializeDeserialize;
/// The user account identifier type for the runtime.
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
/// Balance of an account in native tokens.
///
/// The chain may support multiple tokens, but this particular type is for token that is used
/// to pay for transaction dispatch, to reward different relayers (headers, messages), etc.
type Balance: AtLeast32BitUnsigned
+ FixedPointOperand
+ Parameter
+ Parameter
+ Member
+ MaybeSerializeDeserialize
+ Clone
+ Copy
+ Bounded
+ CheckedSub
+ PartialOrd
+ SaturatingAdd
+ Zero
+ TryFrom<sp_core::U256>;
/// Index of a transaction used by the chain.
type Index: Parameter
+ Member
+ MaybeSerialize
+ Debug
+ Default
+ MaybeDisplay
+ MaybeSerializeDeserialize
+ AtLeast32Bit
+ Copy;
/// Signature type, used on this chain.
type Signature: Parameter + Verify;
} }
/// Block number used by the chain. /// Block number used by the chain.
@@ -89,5 +125,20 @@ pub type HasherOf<C> = <C as Chain>::Hasher;
/// Header type used by the chain. /// Header type used by the chain.
pub type HeaderOf<C> = <C as Chain>::Header; pub type HeaderOf<C> = <C as Chain>::Header;
/// Account id type used by the chain.
pub type AccountIdOf<C> = <C as Chain>::AccountId;
/// Balance type used by the chain.
pub type BalanceOf<C> = <C as Chain>::Balance;
/// Transaction index type used by the chain.
pub type IndexOf<C> = <C as Chain>::Index;
/// Signature type used by the chain.
pub type SignatureOf<C> = <C as Chain>::Signature;
/// Account public type used by the chain.
pub type AccountPublicOf<C> = <SignatureOf<C> as Verify>::Signer;
/// Transaction era used by the chain. /// Transaction era used by the chain.
pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>; pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>;
+4 -1
View File
@@ -24,7 +24,10 @@ use sp_core::hash::H256;
use sp_io::hashing::blake2_256; use sp_io::hashing::blake2_256;
use sp_std::convert::TryFrom; use sp_std::convert::TryFrom;
pub use chain::{BlockNumberOf, Chain, HashOf, HasherOf, HeaderOf, TransactionEraOf}; pub use chain::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, HashOf, HasherOf, HeaderOf, IndexOf, SignatureOf,
TransactionEraOf,
};
pub use storage_proof::{Error as StorageProofError, StorageProofChecker}; pub use storage_proof::{Error as StorageProofError, StorageProofChecker};
#[cfg(feature = "std")] #[cfg(feature = "std")]
@@ -22,7 +22,7 @@ use sp_core::{Bytes, Pair};
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use relay_millau_client::{Millau, SyncHeader as MillauSyncHeader}; use relay_millau_client::{Millau, SyncHeader as MillauSyncHeader};
use relay_rialto_client::{Rialto, SigningParams as RialtoSigningParams}; use relay_rialto_client::{Rialto, SigningParams as RialtoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
/// Millau-to-Rialto finality sync pipeline. /// Millau-to-Rialto finality sync pipeline.
@@ -55,7 +55,7 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto {
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Rialto>, era: bp_runtime::TransactionEraOf<Rialto>,
transaction_nonce: <Rialto as Chain>::Index, transaction_nonce: IndexOf<Rialto>,
header: MillauSyncHeader, header: MillauSyncHeader,
proof: GrandpaJustification<bp_millau::Header>, proof: GrandpaJustification<bp_millau::Header>,
) -> Bytes { ) -> Bytes {
@@ -28,7 +28,7 @@ use frame_support::weights::Weight;
use messages_relay::message_lane::MessageLane; use messages_relay::message_lane::MessageLane;
use relay_millau_client::{HeaderId as MillauHeaderId, Millau, SigningParams as MillauSigningParams}; use relay_millau_client::{HeaderId as MillauHeaderId, Millau, SigningParams as MillauSigningParams};
use relay_rialto_client::{HeaderId as RialtoHeaderId, Rialto, SigningParams as RialtoSigningParams}; use relay_rialto_client::{HeaderId as RialtoHeaderId, Rialto, SigningParams as RialtoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Chain, Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use substrate_relay_helper::messages_lane::{ use substrate_relay_helper::messages_lane::{
select_delivery_transaction_limits, MessagesRelayParams, StandaloneMessagesMetrics, SubstrateMessageLane, select_delivery_transaction_limits, MessagesRelayParams, StandaloneMessagesMetrics, SubstrateMessageLane,
@@ -76,7 +76,7 @@ impl SubstrateMessageLane for MillauMessagesToRialto {
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
transaction_nonce: <Millau as Chain>::Index, transaction_nonce: IndexOf<Millau>,
_generated_at_block: RialtoHeaderId, _generated_at_block: RialtoHeaderId,
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes { ) -> Bytes {
@@ -108,7 +108,7 @@ impl SubstrateMessageLane for MillauMessagesToRialto {
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
transaction_nonce: <Rialto as Chain>::Index, transaction_nonce: IndexOf<Rialto>,
_generated_at_header: MillauHeaderId, _generated_at_header: MillauHeaderId,
_nonces: RangeInclusive<MessageNonce>, _nonces: RangeInclusive<MessageNonce>,
proof: <Self::MessageLane as MessageLane>::MessagesProof, proof: <Self::MessageLane as MessageLane>::MessagesProof,
@@ -22,7 +22,7 @@ use sp_core::{Bytes, Pair};
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use relay_millau_client::{Millau, SigningParams as MillauSigningParams}; use relay_millau_client::{Millau, SigningParams as MillauSigningParams};
use relay_rialto_client::{Rialto, SyncHeader as RialtoSyncHeader}; use relay_rialto_client::{Rialto, SyncHeader as RialtoSyncHeader};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
/// Rialto-to-Millau finality sync pipeline. /// Rialto-to-Millau finality sync pipeline.
@@ -56,7 +56,7 @@ impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau {
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Millau>, era: bp_runtime::TransactionEraOf<Millau>,
transaction_nonce: <Millau as Chain>::Index, transaction_nonce: IndexOf<Millau>,
header: RialtoSyncHeader, header: RialtoSyncHeader,
proof: GrandpaJustification<bp_rialto::Header>, proof: GrandpaJustification<bp_rialto::Header>,
) -> Bytes { ) -> Bytes {
@@ -28,7 +28,7 @@ use frame_support::weights::Weight;
use messages_relay::message_lane::MessageLane; use messages_relay::message_lane::MessageLane;
use relay_millau_client::{HeaderId as MillauHeaderId, Millau, SigningParams as MillauSigningParams}; use relay_millau_client::{HeaderId as MillauHeaderId, Millau, SigningParams as MillauSigningParams};
use relay_rialto_client::{HeaderId as RialtoHeaderId, Rialto, SigningParams as RialtoSigningParams}; use relay_rialto_client::{HeaderId as RialtoHeaderId, Rialto, SigningParams as RialtoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Chain, Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use substrate_relay_helper::messages_lane::{ use substrate_relay_helper::messages_lane::{
select_delivery_transaction_limits, MessagesRelayParams, StandaloneMessagesMetrics, SubstrateMessageLane, select_delivery_transaction_limits, MessagesRelayParams, StandaloneMessagesMetrics, SubstrateMessageLane,
@@ -76,7 +76,7 @@ impl SubstrateMessageLane for RialtoMessagesToMillau {
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
transaction_nonce: <Rialto as Chain>::Index, transaction_nonce: IndexOf<Rialto>,
_generated_at_block: MillauHeaderId, _generated_at_block: MillauHeaderId,
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes { ) -> Bytes {
@@ -108,7 +108,7 @@ impl SubstrateMessageLane for RialtoMessagesToMillau {
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
transaction_nonce: <Millau as Chain>::Index, transaction_nonce: IndexOf<Millau>,
_generated_at_header: RialtoHeaderId, _generated_at_header: RialtoHeaderId,
_nonces: RangeInclusive<MessageNonce>, _nonces: RangeInclusive<MessageNonce>,
proof: <Self::MessageLane as MessageLane>::MessagesProof, proof: <Self::MessageLane as MessageLane>::MessagesProof,
@@ -21,7 +21,7 @@ use sp_core::{Bytes, Pair};
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use relay_rococo_client::{Rococo, SyncHeader as RococoSyncHeader}; use relay_rococo_client::{Rococo, SyncHeader as RococoSyncHeader};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use relay_wococo_client::{SigningParams as WococoSigningParams, Wococo}; use relay_wococo_client::{SigningParams as WococoSigningParams, Wococo};
use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
@@ -78,7 +78,7 @@ impl SubstrateFinalitySyncPipeline for RococoFinalityToWococo {
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Wococo>, era: bp_runtime::TransactionEraOf<Wococo>,
transaction_nonce: <Wococo as Chain>::Index, transaction_nonce: IndexOf<Wococo>,
header: RococoSyncHeader, header: RococoSyncHeader,
proof: GrandpaJustification<bp_rococo::Header>, proof: GrandpaJustification<bp_rococo::Header>,
) -> Bytes { ) -> Bytes {
@@ -26,7 +26,7 @@ use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof;
use frame_support::weights::Weight; use frame_support::weights::Weight;
use messages_relay::message_lane::MessageLane; use messages_relay::message_lane::MessageLane;
use relay_rococo_client::{HeaderId as RococoHeaderId, Rococo, SigningParams as RococoSigningParams}; use relay_rococo_client::{HeaderId as RococoHeaderId, Rococo, SigningParams as RococoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Chain, Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use relay_wococo_client::{HeaderId as WococoHeaderId, SigningParams as WococoSigningParams, Wococo}; use relay_wococo_client::{HeaderId as WococoHeaderId, SigningParams as WococoSigningParams, Wococo};
use substrate_relay_helper::messages_lane::{ use substrate_relay_helper::messages_lane::{
@@ -75,7 +75,7 @@ impl SubstrateMessageLane for RococoMessagesToWococo {
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
transaction_nonce: <Rococo as Chain>::Index, transaction_nonce: IndexOf<Rococo>,
_generated_at_block: WococoHeaderId, _generated_at_block: WococoHeaderId,
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes { ) -> Bytes {
@@ -109,7 +109,7 @@ impl SubstrateMessageLane for RococoMessagesToWococo {
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
transaction_nonce: <Wococo as Chain>::Index, transaction_nonce: IndexOf<Wococo>,
_generated_at_header: RococoHeaderId, _generated_at_header: RococoHeaderId,
_nonces: RangeInclusive<MessageNonce>, _nonces: RangeInclusive<MessageNonce>,
proof: <Self::MessageLane as MessageLane>::MessagesProof, proof: <Self::MessageLane as MessageLane>::MessagesProof,
@@ -21,7 +21,7 @@ use sp_core::{Bytes, Pair};
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use relay_millau_client::{Millau, SigningParams as MillauSigningParams}; use relay_millau_client::{Millau, SigningParams as MillauSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use relay_westend_client::{SyncHeader as WestendSyncHeader, Westend}; use relay_westend_client::{SyncHeader as WestendSyncHeader, Westend};
use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
@@ -64,7 +64,7 @@ impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau {
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Millau>, era: bp_runtime::TransactionEraOf<Millau>,
transaction_nonce: <Millau as Chain>::Index, transaction_nonce: IndexOf<Millau>,
header: WestendSyncHeader, header: WestendSyncHeader,
proof: GrandpaJustification<bp_westend::Header>, proof: GrandpaJustification<bp_westend::Header>,
) -> Bytes { ) -> Bytes {
@@ -21,7 +21,7 @@ use sp_core::{Bytes, Pair};
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use relay_rococo_client::{Rococo, SigningParams as RococoSigningParams}; use relay_rococo_client::{Rococo, SigningParams as RococoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use relay_wococo_client::{SyncHeader as WococoSyncHeader, Wococo}; use relay_wococo_client::{SyncHeader as WococoSyncHeader, Wococo};
use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; use substrate_relay_helper::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
@@ -83,7 +83,7 @@ impl SubstrateFinalitySyncPipeline for WococoFinalityToRococo {
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Rococo>, era: bp_runtime::TransactionEraOf<Rococo>,
transaction_nonce: <Rococo as Chain>::Index, transaction_nonce: IndexOf<Rococo>,
header: WococoSyncHeader, header: WococoSyncHeader,
proof: GrandpaJustification<bp_wococo::Header>, proof: GrandpaJustification<bp_wococo::Header>,
) -> Bytes { ) -> Bytes {
@@ -26,7 +26,7 @@ use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof;
use frame_support::weights::Weight; use frame_support::weights::Weight;
use messages_relay::message_lane::MessageLane; use messages_relay::message_lane::MessageLane;
use relay_rococo_client::{HeaderId as RococoHeaderId, Rococo, SigningParams as RococoSigningParams}; use relay_rococo_client::{HeaderId as RococoHeaderId, Rococo, SigningParams as RococoSigningParams};
use relay_substrate_client::{Chain, Client, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Chain, Client, IndexOf, TransactionSignScheme, UnsignedTransaction};
use relay_utils::metrics::MetricsParams; use relay_utils::metrics::MetricsParams;
use relay_wococo_client::{HeaderId as WococoHeaderId, SigningParams as WococoSigningParams, Wococo}; use relay_wococo_client::{HeaderId as WococoHeaderId, SigningParams as WococoSigningParams, Wococo};
use substrate_relay_helper::messages_lane::{ use substrate_relay_helper::messages_lane::{
@@ -74,7 +74,7 @@ impl SubstrateMessageLane for WococoMessagesToRococo {
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
transaction_nonce: <Wococo as Chain>::Index, transaction_nonce: IndexOf<Wococo>,
_generated_at_block: RococoHeaderId, _generated_at_block: RococoHeaderId,
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes { ) -> Bytes {
@@ -108,7 +108,7 @@ impl SubstrateMessageLane for WococoMessagesToRococo {
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
transaction_nonce: <Rococo as Chain>::Index, transaction_nonce: IndexOf<Rococo>,
_generated_at_header: WococoHeaderId, _generated_at_header: WococoHeaderId,
_nonces: RangeInclusive<MessageNonce>, _nonces: RangeInclusive<MessageNonce>,
proof: <Self::MessageLane as MessageLane>::MessagesProof, proof: <Self::MessageLane as MessageLane>::MessagesProof,
@@ -17,6 +17,7 @@
use crate::cli::bridge::FullBridge; use crate::cli::bridge::FullBridge;
use crate::cli::{Balance, CliChain, HexBytes, HexLaneId, SourceConnectionParams}; use crate::cli::{Balance, CliChain, HexBytes, HexLaneId, SourceConnectionParams};
use crate::select_full_bridge; use crate::select_full_bridge;
use bp_runtime::BalanceOf;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use relay_substrate_client::Chain; use relay_substrate_client::Chain;
use structopt::StructOpt; use structopt::StructOpt;
@@ -53,7 +54,7 @@ impl EstimateFee {
let lane = lane.into(); let lane = lane.into();
let payload = Source::encode_message(payload).map_err(|e| anyhow::format_err!("{:?}", e))?; let payload = Source::encode_message(payload).map_err(|e| anyhow::format_err!("{:?}", e))?;
let fee: <Source as Chain>::Balance = let fee: BalanceOf<Source> =
estimate_message_delivery_and_dispatch_fee(&source_client, ESTIMATE_MESSAGE_FEE_METHOD, lane, payload) estimate_message_delivery_and_dispatch_fee(&source_client, ESTIMATE_MESSAGE_FEE_METHOD, lane, payload)
.await?; .await?;
@@ -22,6 +22,7 @@ use crate::cli::{
TargetSigningParams, TargetSigningParams,
}; };
use bp_message_dispatch::{CallOrigin, MessagePayload}; use bp_message_dispatch::{CallOrigin, MessagePayload};
use bp_runtime::BalanceOf;
use codec::Encode; use codec::Encode;
use frame_support::weights::Weight; use frame_support::weights::Weight;
use relay_substrate_client::{Chain, TransactionSignScheme, UnsignedTransaction}; use relay_substrate_client::{Chain, TransactionSignScheme, UnsignedTransaction};
@@ -159,7 +160,7 @@ impl SendMessage {
let fee = match self.fee { let fee = match self.fee {
Some(fee) => fee, Some(fee) => fee,
None => Balance( None => Balance(
estimate_message_delivery_and_dispatch_fee::<<Source as Chain>::Balance, _, _>( estimate_message_delivery_and_dispatch_fee::<BalanceOf<Source>, _, _>(
&source_client, &source_client,
ESTIMATE_MESSAGE_FEE_METHOD, ESTIMATE_MESSAGE_FEE_METHOD,
lane, lane,
+5 -3
View File
@@ -31,6 +31,11 @@ impl ChainBase for Kusama {
type Hash = bp_kusama::Hash; type Hash = bp_kusama::Hash;
type Hasher = bp_kusama::Hasher; type Hasher = bp_kusama::Hasher;
type Header = bp_kusama::Header; type Header = bp_kusama::Header;
type AccountId = bp_kusama::AccountId;
type Balance = bp_kusama::Balance;
type Index = bp_kusama::Nonce;
type Signature = bp_kusama::Signature;
} }
impl Chain for Kusama { impl Chain for Kusama {
@@ -39,11 +44,8 @@ impl Chain for Kusama {
const STORAGE_PROOF_OVERHEAD: u32 = bp_kusama::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_kusama::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_kusama::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_kusama::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = bp_kusama::AccountId;
type Index = bp_kusama::Nonce;
type SignedBlock = bp_kusama::SignedBlock; type SignedBlock = bp_kusama::SignedBlock;
type Call = (); type Call = ();
type Balance = bp_kusama::Balance;
type WeightToFee = bp_kusama::WeightToFee; type WeightToFee = bp_kusama::WeightToFee;
} }
+9 -6
View File
@@ -18,7 +18,8 @@
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainBase, ChainWithBalances, TransactionEraOf, TransactionSignScheme, UnsignedTransaction, BalanceOf, Chain, ChainBase, ChainWithBalances, IndexOf, TransactionEraOf, TransactionSignScheme,
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};
@@ -36,6 +37,11 @@ impl ChainBase for Millau {
type Hash = millau_runtime::Hash; type Hash = millau_runtime::Hash;
type Hasher = millau_runtime::Hashing; type Hasher = millau_runtime::Hashing;
type Header = millau_runtime::Header; type Header = millau_runtime::Header;
type AccountId = millau_runtime::AccountId;
type Balance = millau_runtime::Balance;
type Index = millau_runtime::Index;
type Signature = millau_runtime::Signature;
} }
impl Chain for Millau { impl Chain for Millau {
@@ -44,11 +50,8 @@ impl Chain for Millau {
const STORAGE_PROOF_OVERHEAD: u32 = bp_millau::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_millau::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = millau_runtime::AccountId;
type Index = millau_runtime::Index;
type SignedBlock = millau_runtime::SignedBlock; type SignedBlock = millau_runtime::SignedBlock;
type Call = millau_runtime::Call; type Call = millau_runtime::Call;
type Balance = millau_runtime::Balance;
type WeightToFee = bp_millau::WeightToFee; type WeightToFee = bp_millau::WeightToFee;
} }
@@ -115,10 +118,10 @@ impl TransactionSignScheme for Millau {
let extra = &tx.signature.as_ref()?.2; let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction { Some(UnsignedTransaction {
call: tx.function, call: tx.function,
nonce: Compact::<<Self::Chain as Chain>::Index>::decode(&mut &extra.4.encode()[..]) nonce: Compact::<IndexOf<Self::Chain>>::decode(&mut &extra.4.encode()[..])
.ok()? .ok()?
.into(), .into(),
tip: Compact::<<Self::Chain as Chain>::Balance>::decode(&mut &extra.6.encode()[..]) tip: Compact::<BalanceOf<Self::Chain>>::decode(&mut &extra.6.encode()[..])
.ok()? .ok()?
.into(), .into(),
}) })
+5 -3
View File
@@ -31,6 +31,11 @@ impl ChainBase for Polkadot {
type Hash = bp_polkadot::Hash; type Hash = bp_polkadot::Hash;
type Hasher = bp_polkadot::Hasher; type Hasher = bp_polkadot::Hasher;
type Header = bp_polkadot::Header; type Header = bp_polkadot::Header;
type AccountId = bp_polkadot::AccountId;
type Balance = bp_polkadot::Balance;
type Index = bp_polkadot::Nonce;
type Signature = bp_polkadot::Signature;
} }
impl Chain for Polkadot { impl Chain for Polkadot {
@@ -39,11 +44,8 @@ impl Chain for Polkadot {
const STORAGE_PROOF_OVERHEAD: u32 = bp_polkadot::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_polkadot::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_polkadot::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_polkadot::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = bp_polkadot::AccountId;
type Index = bp_polkadot::Nonce;
type SignedBlock = bp_polkadot::SignedBlock; type SignedBlock = bp_polkadot::SignedBlock;
type Call = (); type Call = ();
type Balance = bp_polkadot::Balance;
type WeightToFee = bp_polkadot::WeightToFee; type WeightToFee = bp_polkadot::WeightToFee;
} }
+9 -6
View File
@@ -18,7 +18,8 @@
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainBase, ChainWithBalances, TransactionEraOf, TransactionSignScheme, UnsignedTransaction, BalanceOf, Chain, ChainBase, ChainWithBalances, IndexOf, TransactionEraOf, TransactionSignScheme,
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};
@@ -36,6 +37,11 @@ impl ChainBase for Rialto {
type Hash = rialto_runtime::Hash; type Hash = rialto_runtime::Hash;
type Hasher = rialto_runtime::Hashing; type Hasher = rialto_runtime::Hashing;
type Header = rialto_runtime::Header; type Header = rialto_runtime::Header;
type AccountId = rialto_runtime::AccountId;
type Balance = rialto_runtime::Balance;
type Index = rialto_runtime::Index;
type Signature = rialto_runtime::Signature;
} }
impl Chain for Rialto { impl Chain for Rialto {
@@ -44,11 +50,8 @@ impl Chain for Rialto {
const STORAGE_PROOF_OVERHEAD: u32 = bp_rialto::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_rialto::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = rialto_runtime::AccountId;
type Index = rialto_runtime::Index;
type SignedBlock = rialto_runtime::SignedBlock; type SignedBlock = rialto_runtime::SignedBlock;
type Call = rialto_runtime::Call; type Call = rialto_runtime::Call;
type Balance = rialto_runtime::Balance;
type WeightToFee = bp_rialto::WeightToFee; type WeightToFee = bp_rialto::WeightToFee;
} }
@@ -115,10 +118,10 @@ impl TransactionSignScheme for Rialto {
let extra = &tx.signature.as_ref()?.2; let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction { Some(UnsignedTransaction {
call: tx.function, call: tx.function,
nonce: Compact::<<Self::Chain as Chain>::Index>::decode(&mut &extra.4.encode()[..]) nonce: Compact::<IndexOf<Self::Chain>>::decode(&mut &extra.4.encode()[..])
.ok()? .ok()?
.into(), .into(),
tip: Compact::<<Self::Chain as Chain>::Balance>::decode(&mut &extra.6.encode()[..]) tip: Compact::<BalanceOf<Self::Chain>>::decode(&mut &extra.6.encode()[..])
.ok()? .ok()?
.into(), .into(),
}) })
+5 -3
View File
@@ -41,6 +41,11 @@ impl ChainBase for Rococo {
type Hash = bp_rococo::Hash; type Hash = bp_rococo::Hash;
type Hasher = bp_rococo::Hashing; type Hasher = bp_rococo::Hashing;
type Header = bp_rococo::Header; type Header = bp_rococo::Header;
type AccountId = bp_rococo::AccountId;
type Balance = bp_rococo::Balance;
type Index = bp_rococo::Nonce;
type Signature = bp_rococo::Signature;
} }
impl Chain for Rococo { impl Chain for Rococo {
@@ -49,11 +54,8 @@ impl Chain for Rococo {
const STORAGE_PROOF_OVERHEAD: u32 = bp_rococo::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_rococo::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_rococo::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_rococo::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = bp_rococo::AccountId;
type Index = bp_rococo::Index;
type SignedBlock = bp_rococo::SignedBlock; type SignedBlock = bp_rococo::SignedBlock;
type Call = crate::runtime::Call; type Call = crate::runtime::Call;
type Balance = bp_rococo::Balance;
type WeightToFee = bp_rococo::WeightToFee; type WeightToFee = bp_rococo::WeightToFee;
} }
+4 -41
View File
@@ -16,17 +16,14 @@
use bp_runtime::{Chain as ChainBase, TransactionEraOf}; use bp_runtime::{Chain as ChainBase, TransactionEraOf};
use codec::{Codec, Encode}; use codec::{Codec, Encode};
use frame_support::{weights::WeightToFeePolynomial, Parameter}; use frame_support::weights::WeightToFeePolynomial;
use jsonrpsee_ws_client::{DeserializeOwned, Serialize}; use jsonrpsee_ws_client::{DeserializeOwned, Serialize};
use num_traits::{Bounded, CheckedSub, SaturatingAdd, Zero}; use num_traits::Zero;
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{ use sp_runtime::{
generic::SignedBlock, generic::SignedBlock,
traits::{ traits::{Block as BlockT, Dispatchable, Member},
AtLeast32Bit, AtLeast32BitUnsigned, Block as BlockT, Dispatchable, MaybeDisplay, MaybeSerialize, EncodedJustification,
MaybeSerializeDeserialize, Member,
},
EncodedJustification, FixedPointOperand,
}; };
use std::{fmt::Debug, time::Duration}; use std::{fmt::Debug, time::Duration};
@@ -44,49 +41,15 @@ pub trait Chain: ChainBase + Clone {
/// Maximal size (in bytes) of SCALE-encoded account id on this chain. /// Maximal size (in bytes) of SCALE-encoded account id on this chain.
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32;
/// The user account identifier type for the runtime.
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
/// Index of a transaction used by the chain.
type Index: Parameter
+ Member
+ MaybeSerialize
+ Debug
+ Default
+ MaybeDisplay
+ DeserializeOwned
+ AtLeast32Bit
+ Copy;
/// Block type. /// Block type.
type SignedBlock: Member + Serialize + DeserializeOwned + BlockWithJustification<Self::Header>; type SignedBlock: Member + Serialize + DeserializeOwned + BlockWithJustification<Self::Header>;
/// The aggregated `Call` type. /// The aggregated `Call` type.
type Call: Clone + Dispatchable + Debug; type Call: Clone + Dispatchable + Debug;
/// Balance of an account in native tokens.
///
/// The chain may support multiple tokens, but this particular type is for token that is used
/// to pay for transaction dispatch, to reward different relayers (headers, messages), etc.
type Balance: AtLeast32BitUnsigned
+ FixedPointOperand
+ Parameter
+ Parameter
+ Member
+ DeserializeOwned
+ Clone
+ Copy
+ Bounded
+ CheckedSub
+ PartialOrd
+ SaturatingAdd
+ Zero
+ std::convert::TryFrom<sp_core::U256>;
/// Type that is used by the chain, to convert from weight to fee. /// Type that is used by the chain, to convert from weight to fee.
type WeightToFee: WeightToFeePolynomial<Balance = Self::Balance>; type WeightToFee: WeightToFeePolynomial<Balance = Self::Balance>;
} }
/// Balance type used by the chain
pub type BalanceOf<C> = <C as Chain>::Balance;
/// Index type used by the chain
pub type IndexOf<C> = <C as Chain>::Index;
/// Weight-to-Fee type used by the chain /// Weight-to-Fee type used by the chain
pub type WeightToFeeOf<C> = <C as Chain>::WeightToFee; pub type WeightToFeeOf<C> = <C as Chain>::WeightToFee;
+7 -4
View File
@@ -165,6 +165,7 @@ impl<C: ChainWithBalances> Environment<C> for Client<C> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use frame_support::weights::IdentityFee;
use futures::{ use futures::{
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}, channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
future::FutureExt, future::FutureExt,
@@ -180,6 +181,11 @@ mod tests {
type Hash = sp_core::H256; type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256; type Hasher = sp_runtime::traits::BlakeTwo256;
type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>; type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
type AccountId = u32;
type Balance = u32;
type Index = u32;
type Signature = sp_runtime::testing::TestSignature;
} }
impl Chain for TestChain { impl Chain for TestChain {
@@ -188,13 +194,10 @@ mod tests {
const STORAGE_PROOF_OVERHEAD: u32 = 0; const STORAGE_PROOF_OVERHEAD: u32 = 0;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = 0; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = 0;
type AccountId = u32;
type Index = u32;
type SignedBlock = type SignedBlock =
sp_runtime::generic::SignedBlock<sp_runtime::generic::Block<Self::Header, sp_runtime::OpaqueExtrinsic>>; sp_runtime::generic::SignedBlock<sp_runtime::generic::Block<Self::Header, sp_runtime::OpaqueExtrinsic>>;
type Call = (); type Call = ();
type Balance = u32; type WeightToFee = IdentityFee<u32>;
type WeightToFee = frame_support::weights::IdentityFee<u32>;
} }
impl ChainWithBalances for TestChain { impl ChainWithBalances for TestChain {
+4 -3
View File
@@ -32,13 +32,14 @@ pub mod metrics;
use std::time::Duration; use std::time::Duration;
pub use crate::chain::{ pub use crate::chain::{
BalanceOf, BlockWithJustification, Chain, ChainWithBalances, IndexOf, TransactionSignScheme, UnsignedTransaction, BlockWithJustification, Chain, ChainWithBalances, TransactionSignScheme, UnsignedTransaction, WeightToFeeOf,
WeightToFeeOf,
}; };
pub use crate::client::{Client, JustificationsSubscription, OpaqueGrandpaAuthoritiesSet}; pub use crate::client::{Client, JustificationsSubscription, OpaqueGrandpaAuthoritiesSet};
pub use crate::error::{Error, Result}; pub use crate::error::{Error, Result};
pub use crate::sync_header::SyncHeader; pub use crate::sync_header::SyncHeader;
pub use bp_runtime::{BlockNumberOf, Chain as ChainBase, HashOf, HeaderOf, TransactionEra, TransactionEraOf}; pub use bp_runtime::{
BalanceOf, BlockNumberOf, Chain as ChainBase, HashOf, HeaderOf, IndexOf, TransactionEra, TransactionEraOf,
};
/// Header id used by the chain. /// Header id used by the chain.
pub type HeaderIdOf<C> = relay_utils::HeaderId<HashOf<C>, BlockNumberOf<C>>; pub type HeaderIdOf<C> = relay_utils::HeaderId<HashOf<C>, BlockNumberOf<C>>;
+5 -3
View File
@@ -35,6 +35,11 @@ impl ChainBase for Westend {
type Hash = bp_westend::Hash; type Hash = bp_westend::Hash;
type Hasher = bp_westend::Hasher; type Hasher = bp_westend::Hasher;
type Header = bp_westend::Header; type Header = bp_westend::Header;
type AccountId = bp_westend::AccountId;
type Balance = bp_westend::Balance;
type Index = bp_westend::Nonce;
type Signature = bp_westend::Signature;
} }
impl Chain for Westend { impl Chain for Westend {
@@ -43,11 +48,8 @@ impl Chain for Westend {
const STORAGE_PROOF_OVERHEAD: u32 = bp_westend::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_westend::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_westend::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_westend::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = bp_westend::AccountId;
type Index = bp_westend::Nonce;
type SignedBlock = bp_westend::SignedBlock; type SignedBlock = bp_westend::SignedBlock;
type Call = bp_westend::Call; type Call = bp_westend::Call;
type Balance = bp_westend::Balance;
type WeightToFee = bp_westend::WeightToFee; type WeightToFee = bp_westend::WeightToFee;
} }
+5 -3
View File
@@ -41,6 +41,11 @@ impl ChainBase for Wococo {
type Hash = bp_wococo::Hash; type Hash = bp_wococo::Hash;
type Hasher = bp_wococo::Hashing; type Hasher = bp_wococo::Hashing;
type Header = bp_wococo::Header; type Header = bp_wococo::Header;
type AccountId = bp_wococo::AccountId;
type Balance = bp_wococo::Balance;
type Index = bp_wococo::Nonce;
type Signature = bp_wococo::Signature;
} }
impl Chain for Wococo { impl Chain for Wococo {
@@ -49,11 +54,8 @@ impl Chain for Wococo {
const STORAGE_PROOF_OVERHEAD: u32 = bp_wococo::EXTRA_STORAGE_PROOF_SIZE; const STORAGE_PROOF_OVERHEAD: u32 = bp_wococo::EXTRA_STORAGE_PROOF_SIZE;
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_wococo::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE; const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32 = bp_wococo::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE;
type AccountId = bp_wococo::AccountId;
type Index = bp_wococo::Index;
type SignedBlock = bp_wococo::SignedBlock; type SignedBlock = bp_wococo::SignedBlock;
type Call = crate::runtime::Call; type Call = crate::runtime::Call;
type Balance = bp_wococo::Balance;
type WeightToFee = bp_wococo::WeightToFee; type WeightToFee = bp_wococo::WeightToFee;
} }
@@ -19,6 +19,7 @@
use crate::finality_target::SubstrateFinalityTarget; use crate::finality_target::SubstrateFinalityTarget;
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::justification::GrandpaJustification;
use bp_runtime::AccountIdOf;
use finality_relay::{FinalitySyncParams, FinalitySyncPipeline}; use finality_relay::{FinalitySyncParams, FinalitySyncPipeline};
use relay_substrate_client::{finality_source::FinalitySource, BlockNumberOf, Chain, Client, HashOf, SyncHeader}; use relay_substrate_client::{finality_source::FinalitySource, BlockNumberOf, Chain, Client, HashOf, SyncHeader};
use relay_utils::{metrics::MetricsParams, BlockNumberBase}; use relay_utils::{metrics::MetricsParams, BlockNumberBase};
@@ -63,13 +64,13 @@ pub trait SubstrateFinalitySyncPipeline: 'static + Clone + Debug + Send + Sync {
fn start_relay_guards(&self) {} fn start_relay_guards(&self) {}
/// Returns id of account that we're using to sign transactions at target chain. /// Returns id of account that we're using to sign transactions at target chain.
fn transactions_author(&self) -> <Self::TargetChain as Chain>::AccountId; fn transactions_author(&self) -> AccountIdOf<Self::TargetChain>;
/// Make submit header transaction. /// Make submit header transaction.
fn make_submit_finality_proof_transaction( fn make_submit_finality_proof_transaction(
&self, &self,
era: bp_runtime::TransactionEraOf<Self::TargetChain>, era: bp_runtime::TransactionEraOf<Self::TargetChain>,
transaction_nonce: <Self::TargetChain as Chain>::Index, transaction_nonce: bp_runtime::IndexOf<Self::TargetChain>,
header: <Self::FinalitySyncPipeline as FinalitySyncPipeline>::Header, header: <Self::FinalitySyncPipeline as FinalitySyncPipeline>::Header,
proof: <Self::FinalitySyncPipeline as FinalitySyncPipeline>::FinalityProof, proof: <Self::FinalitySyncPipeline as FinalitySyncPipeline>::FinalityProof,
) -> Bytes; ) -> Bytes;
@@ -22,6 +22,7 @@ use crate::on_demand_headers::OnDemandHeadersRelay;
use async_trait::async_trait; use async_trait::async_trait;
use bp_messages::{LaneId, MessageNonce}; use bp_messages::{LaneId, MessageNonce};
use bp_runtime::{AccountIdOf, IndexOf};
use frame_support::weights::Weight; use frame_support::weights::Weight;
use messages_relay::message_lane::{MessageLane, SourceHeaderIdOf, TargetHeaderIdOf}; use messages_relay::message_lane::{MessageLane, SourceHeaderIdOf, TargetHeaderIdOf};
use relay_substrate_client::{ use relay_substrate_client::{
@@ -101,24 +102,24 @@ pub trait SubstrateMessageLane: 'static + Clone + Send + Sync {
type TargetChain: Chain; type TargetChain: Chain;
/// Returns id of account that we're using to sign transactions at target chain (messages proof). /// Returns id of account that we're using to sign transactions at target chain (messages proof).
fn target_transactions_author(&self) -> <Self::TargetChain as Chain>::AccountId; fn target_transactions_author(&self) -> AccountIdOf<Self::TargetChain>;
/// Make messages delivery transaction. /// Make messages delivery transaction.
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
transaction_nonce: <Self::TargetChain as Chain>::Index, transaction_nonce: IndexOf<Self::TargetChain>,
generated_at_header: SourceHeaderIdOf<Self::MessageLane>, generated_at_header: SourceHeaderIdOf<Self::MessageLane>,
nonces: RangeInclusive<MessageNonce>, nonces: RangeInclusive<MessageNonce>,
proof: <Self::MessageLane as MessageLane>::MessagesProof, proof: <Self::MessageLane as MessageLane>::MessagesProof,
) -> Bytes; ) -> Bytes;
/// Returns id of account that we're using to sign transactions at source chain (delivery proof). /// Returns id of account that we're using to sign transactions at source chain (delivery proof).
fn source_transactions_author(&self) -> <Self::SourceChain as Chain>::AccountId; fn source_transactions_author(&self) -> AccountIdOf<Self::SourceChain>;
/// Make messages receiving proof transaction. /// Make messages receiving proof transaction.
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
transaction_nonce: <Self::SourceChain as Chain>::Index, transaction_nonce: IndexOf<Self::SourceChain>,
generated_at_header: TargetHeaderIdOf<Self::MessageLane>, generated_at_header: TargetHeaderIdOf<Self::MessageLane>,
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes; ) -> Bytes;
@@ -108,7 +108,7 @@ where
BlockNumber = <P::MessageLane as MessageLane>::SourceHeaderNumber, BlockNumber = <P::MessageLane as MessageLane>::SourceHeaderNumber,
Balance = <P::MessageLane as MessageLane>::SourceChainBalance, Balance = <P::MessageLane as MessageLane>::SourceChainBalance,
>, >,
BalanceOf<P::SourceChain>: TryFrom<<P::TargetChain as Chain>::Balance> + Bounded, BalanceOf<P::SourceChain>: TryFrom<BalanceOf<P::TargetChain>> + Bounded,
P::TargetChain: Chain< P::TargetChain: Chain<
Hash = <P::MessageLane as MessageLane>::TargetHeaderHash, Hash = <P::MessageLane as MessageLane>::TargetHeaderHash,
BlockNumber = <P::MessageLane as MessageLane>::TargetHeaderNumber, BlockNumber = <P::MessageLane as MessageLane>::TargetHeaderNumber,
@@ -454,7 +454,7 @@ mod tests {
fn make_messages_receiving_proof_transaction( fn make_messages_receiving_proof_transaction(
&self, &self,
_transaction_nonce: <Rococo as Chain>::Index, _transaction_nonce: IndexOf<Rococo>,
_generated_at_block: TargetHeaderIdOf<Self::MessageLane>, _generated_at_block: TargetHeaderIdOf<Self::MessageLane>,
_proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof, _proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
) -> Bytes { ) -> Bytes {
@@ -467,7 +467,7 @@ mod tests {
fn make_messages_delivery_transaction( fn make_messages_delivery_transaction(
&self, &self,
_transaction_nonce: <Wococo as Chain>::Index, _transaction_nonce: IndexOf<Wococo>,
_generated_at_header: SourceHeaderIdOf<Self::MessageLane>, _generated_at_header: SourceHeaderIdOf<Self::MessageLane>,
_nonces: RangeInclusive<MessageNonce>, _nonces: RangeInclusive<MessageNonce>,
_proof: <Self::MessageLane as MessageLane>::MessagesProof, _proof: <Self::MessageLane as MessageLane>::MessagesProof,