Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Replace Index for Nonce #2740

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
527 changes: 264 additions & 263 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bridges/bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use pallet_bridge_messages::WeightInfoExt as _;
use sp_runtime::traits::SignedExtension;

/// Macro that ensures that the runtime configuration and chain primitives crate are sharing
/// the same types (index, block number, hash, hasher, account id and header).
/// the same types (nonce, block number, hash, hasher, account id and header).
#[macro_export]
macro_rules! assert_chain_types(
( runtime: $r:path, this_chain: $this:path ) => {
Expand All @@ -41,7 +41,7 @@ macro_rules! assert_chain_types(
use frame_system::{Config as SystemConfig, pallet_prelude::*};
use static_assertions::assert_type_eq_all;

assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Nonce, bp_runtime::NonceOf<$this>);
assert_type_eq_all!(BlockNumberFor<$r>, bp_runtime::BlockNumberOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>);
assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>);
Expand Down
8 changes: 4 additions & 4 deletions bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ parameter_types! {

impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = ThisChainHash;
type Hashing = ThisChainHasher;
Expand Down Expand Up @@ -317,7 +317,7 @@ impl Chain for ThisUnderlyingChain {
type Hasher = ThisChainHasher;
type AccountId = ThisChainAccountId;
type Balance = ThisChainBalance;
type Index = u32;
type Nonce = u32;
type Signature = sp_runtime::MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand Down Expand Up @@ -356,7 +356,7 @@ impl Chain for BridgedUnderlyingChain {
type Hasher = BridgedChainHasher;
type AccountId = BridgedChainAccountId;
type Balance = BridgedChainBalance;
type Index = u32;
type Nonce = u32;
type Signature = sp_runtime::MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand All @@ -381,7 +381,7 @@ impl Chain for BridgedUnderlyingParachain {
type Hasher = BridgedChainHasher;
type AccountId = BridgedChainAccountId;
type Balance = BridgedChainBalance;
type Index = u32;
type Nonce = u32;
type Signature = sp_runtime::MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand Down
4 changes: 2 additions & 2 deletions bridges/modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ parameter_types! {

impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Chain for TestBridgedChain {

type AccountId = AccountId;
type Balance = u64;
type Index = u64;
type Nonce = u64;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub type DbWeight = RocksDbWeight;

impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down
14 changes: 7 additions & 7 deletions bridges/modules/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Chain for Parachain1 {
type Hasher = RegularParachainHasher;
type AccountId = u64;
type Balance = u64;
type Index = u64;
type Nonce = u64;
type Signature = MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand All @@ -76,7 +76,7 @@ impl Chain for Parachain2 {
type Hasher = RegularParachainHasher;
type AccountId = u64;
type Balance = u64;
type Index = u64;
type Nonce = u64;
type Signature = MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand All @@ -99,7 +99,7 @@ impl Chain for Parachain3 {
type Hasher = RegularParachainHasher;
type AccountId = u64;
type Balance = u64;
type Index = u64;
type Nonce = u64;
type Signature = MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand All @@ -125,7 +125,7 @@ impl Chain for BigParachain {
type Hasher = RegularParachainHasher;
type AccountId = u64;
type Balance = u64;
type Index = u64;
type Nonce = u64;
type Signature = MultiSignature;

fn max_extrinsic_size() -> u32 {
Expand Down Expand Up @@ -159,7 +159,7 @@ parameter_types! {

impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = RegularParachainHasher;
Expand Down Expand Up @@ -262,7 +262,7 @@ impl Chain for TestBridgedChain {

type AccountId = AccountId;
type Balance = u32;
type Index = u32;
type Nonce = u32;
type Signature = sp_runtime::testing::TestSignature;

fn max_extrinsic_size() -> u32 {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl Chain for OtherBridgedChain {

type AccountId = AccountId;
type Balance = u32;
type Index = u32;
type Nonce = u32;
type Signature = sp_runtime::testing::TestSignature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/relayers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parameter_types! {

impl frame_system::Config for TestRuntime {
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
Expand Down
12 changes: 6 additions & 6 deletions bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

pub use bp_polkadot_core::{
AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, Block, BlockNumber, Hash,
Hasher, Hashing, Header, Index, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic,
Hasher, Hashing, Header, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the Nonce that this was already using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't used anywhere in here, and in the definition it was the same as Index

/// Account Index (a.k.a. nonce).
pub type Index = u32;
/// Hashing type.
pub type Hashing = BlakeTwo256;
/// The type of object that can produce hashes on Polkadot-like chains.
pub type Hasher = BlakeTwo256;
/// The header type used by Polkadot-like chains.
pub type Header = generic::Header<BlockNumber, Hasher>;
/// Signature type used by Polkadot-like chains.
pub type Signature = MultiSignature;
/// Public key of account on Polkadot-like chains.
pub type AccountPublic = <Signature as Verify>::Signer;
/// Id of account on Polkadot-like chains.
pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
/// Address of account on Polkadot-like chains.
pub type AccountAddress = MultiAddress<AccountId, ()>;
/// Index of a transaction on the Polkadot-like chains.
pub type Nonce = u32;

EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES,
};

Expand Down Expand Up @@ -140,7 +140,7 @@ pub type SignedExtra = (
CheckTxVersion,
CheckGenesis<Hash>,
CheckEra<Hash>,
CheckNonce<Index>,
CheckNonce<Nonce>,
CheckWeight,
ChargeTransactionPayment<Balance>,
BridgeRejectObsoleteHeadersAndMessages,
Expand All @@ -159,12 +159,12 @@ pub trait BridgeHubSignedExtension {
transaction_version: u32,
era: bp_runtime::TransactionEra<BlockNumber, Hash>,
genesis_hash: Hash,
nonce: Index,
nonce: Nonce,
tip: Balance,
) -> Self;

/// Return transaction nonce.
fn nonce(&self) -> Index;
fn nonce(&self) -> Nonce;

/// Return transaction tip.
fn tip(&self) -> Balance;
Expand All @@ -177,7 +177,7 @@ impl BridgeHubSignedExtension for SignedExtension {
transaction_version: u32,
era: bp_runtime::TransactionEra<BlockNumber, Hash>,
genesis_hash: Hash,
nonce: Index,
nonce: Nonce,
tip: Balance,
) -> Self {
GenericSignedExtension::new(
Expand Down Expand Up @@ -209,7 +209,7 @@ impl BridgeHubSignedExtension for SignedExtension {
}

/// Return transaction nonce.
fn nonce(&self) -> Index {
fn nonce(&self) -> Nonce {
self.payload.5 .0
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Chain for BridgeHubKusama {
type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Nonce = Nonce;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Chain for BridgeHubPolkadot {
type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Nonce = Nonce;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Chain for BridgeHubRococo {
type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Nonce = Nonce;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-bridge-hub-wococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Chain for BridgeHubWococo {
type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Nonce = Nonce;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Chain for Kusama {

type AccountId = <PolkadotLike as Chain>::AccountId;
type Balance = <PolkadotLike as Chain>::Balance;
type Index = <PolkadotLike as Chain>::Index;
type Nonce = <PolkadotLike as Chain>::Nonce;
type Signature = <PolkadotLike as Chain>::Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Chain for Polkadot {

type AccountId = <PolkadotLike as Chain>::AccountId;
type Balance = <PolkadotLike as Chain>::Balance;
type Index = <PolkadotLike as Chain>::Index;
type Nonce = <PolkadotLike as Chain>::Nonce;
type Signature = <PolkadotLike as Chain>::Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Chain for Rococo {
type Hasher = <PolkadotLike as Chain>::Hasher;
type AccountId = <PolkadotLike as Chain>::AccountId;
type Balance = <PolkadotLike as Chain>::Balance;
type Index = <PolkadotLike as Chain>::Index;
type Nonce = <PolkadotLike as Chain>::Nonce;
type Signature = <PolkadotLike as Chain>::Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/chain-wococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Chain for Wococo {
type Hasher = <PolkadotLike as Chain>::Hasher;
type AccountId = <PolkadotLike as Chain>::AccountId;
type Balance = <PolkadotLike as Chain>::Balance;
type Index = <PolkadotLike as Chain>::Index;
type Nonce = <PolkadotLike as Chain>::Nonce;
type Signature = <PolkadotLike as Chain>::Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
5 changes: 1 addition & 4 deletions bridges/primitives/polkadot-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ pub type BlockNumber = u32;
/// Hash type used in Polkadot-like chains.
pub type Hash = <BlakeTwo256 as HasherT>::Out;

/// Account Index (a.k.a. nonce).
pub type Index = u32;

/// Hashing type.
pub type Hashing = BlakeTwo256;

Expand Down Expand Up @@ -234,7 +231,7 @@ impl Chain for PolkadotLike {
type Block = Block;
type AccountId = AccountId;
type Balance = Balance;
type Index = Index;
type Nonce = Nonce;
type Signature = Signature;

fn max_extrinsic_size() -> u32 {
Expand Down
6 changes: 3 additions & 3 deletions bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub trait Chain: Send + Sync + 'static {
+ TryFrom<sp_core::U256>
+ MaxEncodedLen;
/// Index of a transaction used by the chain.
type Index: Parameter
type Nonce: Parameter
+ Member
+ MaybeSerialize
+ Debug
Expand Down Expand Up @@ -181,7 +181,7 @@ where
type Block = <T::Chain as Chain>::Block;
type AccountId = <T::Chain as Chain>::AccountId;
type Balance = <T::Chain as Chain>::Balance;
type Index = <T::Chain as Chain>::Index;
type Nonce = <T::Chain as Chain>::Nonce;
type Signature = <T::Chain as Chain>::Signature;

fn max_extrinsic_size() -> u32 {
Expand Down Expand Up @@ -237,7 +237,7 @@ pub type AccountIdOf<C> = <C as Chain>::AccountId;
pub type BalanceOf<C> = <C as Chain>::Balance;

/// Transaction index type used by the chain.
pub type IndexOf<C> = <C as Chain>::Index;
pub type NonceOf<C> = <C as Chain>::Nonce;

/// Signature type used by the chain.
pub type SignatureOf<C> = <C as Chain>::Signature;
Expand Down
2 changes: 1 addition & 1 deletion bridges/primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec};

pub use chain::{
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf,
HasherOf, HeaderOf, IndexOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf,
HasherOf, HeaderOf, NonceOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf,
UnderlyingChainOf, UnderlyingChainProvider,
};
pub use frame_support::storage::storage_prefix as storage_value_final_key;
Expand Down
2 changes: 1 addition & 1 deletion pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl system::Config for Test {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand Down
2 changes: 1 addition & 1 deletion pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ mod tests {
impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
Expand Down
2 changes: 1 addition & 1 deletion pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ parameter_types! {
impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand Down
2 changes: 1 addition & 1 deletion pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl frame_system::Config for Test {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::sync::Arc;

use parachain_template_runtime::{opaque::Block, AccountId, Balance, Index as Nonce};
use parachain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};

use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl system::Config for Test {
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
Expand Down
Loading