Skip to content

Commit

Permalink
feat: polkadot-v1.1.0 (#14)
Browse files Browse the repository at this point in the history
* feat: polkadot-v1.1.0

* fix: tests
  • Loading branch information
mustermeiszer authored Nov 8, 2023
1 parent c6cd830 commit 7b58efe
Show file tree
Hide file tree
Showing 9 changed files with 654 additions and 141 deletions.
629 changes: 575 additions & 54 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions chainbridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
serde = { version = "1.0.102", optional = true }

# primitives
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }

# frame dependencies
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
scale-info = { version = "2.0", default-features = false, features = [
"derive",
] }

# Benchmarking primitives
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v1.0.0" }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, tag = "polkadot-v1.1.0" }

[build-dependencies]
wasm-builder-runner = { version = "3.0.0", package = "substrate-wasm-builder-runner" }
Expand Down
43 changes: 19 additions & 24 deletions chainbridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{
self as pallet_chainbridge, constants::DEFAULT_RELAYER_VOTE_THRESHOLD, ChainId,
Config as ChainBridgePalletConfig, ResourceId, WeightInfo,
};
use sp_runtime::BuildStorage;
use sp_std::convert::{TryFrom, TryInto};

// Import Substrate primitives and components
Expand All @@ -35,14 +36,13 @@ use frame_support::{
PalletId,
};

use frame_system::mocking::{MockBlock, MockUncheckedExtrinsic};
use frame_system::mocking::MockBlock;

use sp_core::H256;

use sp_io::TestExternalities;

use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
Expand All @@ -54,7 +54,6 @@ use sp_runtime::{
type Balance = u64;

// Runtime mocking types definition
type UncheckedExtrinsic = MockUncheckedExtrinsic<MockRuntime>;
type Block = MockBlock<MockRuntime>;

pub type SystemCall = frame_system::Call<MockRuntime>;
Expand All @@ -63,39 +62,39 @@ pub type SystemCall = frame_system::Call<MockRuntime>;
pub struct MockWeightInfo;
impl WeightInfo for MockWeightInfo {
fn set_threshold() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn set_resource() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn remove_resource() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn whitelist_chain() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn add_relayer() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn remove_relayer() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn acknowledge_proposal(_: Weight) -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn reject_proposal() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn eval_vote_state(_: Weight) -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}
}

Expand All @@ -113,12 +112,9 @@ pub(crate) const TEST_RELAYER_VOTE_THRESHOLD: u32 = 2;
// Build mock runtime
frame_support::construct_runtime!(

pub enum MockRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
pub enum MockRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
ChainBridge: pallet_chainbridge::{Pallet, Call, Storage, Event<T>},
}
Expand All @@ -138,7 +134,7 @@ impl SortedMembers<u64> for TestUserId {
// Parameterize FRAME system pallet
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub const MaxLocks: u32 = 100;
Expand All @@ -149,13 +145,10 @@ impl frame_system::Config for MockRuntime {
type BaseCallFilter = Everything;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
Expand All @@ -170,6 +163,8 @@ impl frame_system::Config for MockRuntime {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type Nonce = u64;
type Block = Block;
}

// Parameterize FRAME balances pallet
Expand All @@ -190,8 +185,8 @@ impl pallet_balances::Config for MockRuntime {
type WeightInfo = ();
type MaxHolds = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type RuntimeHoldReason = ();
}

// Parameterize chainbridge pallet
Expand Down Expand Up @@ -236,8 +231,8 @@ impl TestExternalitiesBuilder {
pub(crate) fn build(self) -> TestExternalities {
let bridge_id = ChainBridge::account_id();

let mut storage = frame_system::GenesisConfig::default()
.build_storage::<MockRuntime>()
let mut storage = frame_system::GenesisConfig::<MockRuntime>::default()
.build_storage()
.unwrap();

// pre-fill balances
Expand Down
14 changes: 7 additions & 7 deletions example-erc721/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
serde = { version = "1.0.102", optional = true }

# primitives
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }

# frame dependencies
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
scale-info = { version = "2.0", default-features = false, features = [
"derive",
] }
Expand All @@ -28,7 +28,7 @@ scale-info = { version = "2.0", default-features = false, features = [
chainbridge = { path = "../chainbridge", default-features = false }

[dev-dependencies]
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }

[build-dependencies]
wasm-builder-runner = { version = "3.0.0", package = "substrate-wasm-builder-runner" }
Expand Down
32 changes: 15 additions & 17 deletions example-erc721/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
// ----------------------------------------------------------------------------
// Module imports and re-exports
// ----------------------------------------------------------------------------

use frame_support::traits::Everything;
use frame_support::{parameter_types, weights::Weight};
use sp_core::{blake2_128, H256};
use sp_runtime::BuildStorage;
use sp_std::convert::{TryFrom, TryInto};

use sp_io::TestExternalities;

use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
Expand All @@ -40,22 +39,21 @@ use crate::{self as pallet_example_erc721, traits::WeightInfo};
// ----------------------------------------------------------------------------

type Balance = u64;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<MockRuntime>;
type Block = frame_system::mocking::MockBlock<MockRuntime>;

// Implement testing extrinsic weights for the pallet
pub struct MockWeightInfo;
impl WeightInfo for MockWeightInfo {
fn mint() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn transfer() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}

fn burn() -> Weight {
Weight::from_ref_time(0)
Weight::from_parts(0, 0)
}
}

Expand All @@ -71,12 +69,9 @@ pub const ENDOWED_BALANCE: u64 = 100_000_000;
// Build mock runtime
frame_support::construct_runtime!(

pub enum MockRuntime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
pub enum MockRuntime
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Config<T>, Storage, Event<T>},
Erc721: pallet_example_erc721::{Pallet, Call, Storage, Event<T>},
}
Expand All @@ -85,7 +80,7 @@ frame_support::construct_runtime!(
// Parameterize FRAME system pallet
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub const MaxLocks: u32 = 100;
Expand All @@ -96,13 +91,12 @@ impl frame_system::Config for MockRuntime {
type BaseCallFilter = Everything;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
Expand Down Expand Up @@ -135,6 +129,10 @@ impl pallet_balances::Config for MockRuntime {
type ReserveIdentifier = ();
type MaxLocks = ();
type WeightInfo = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxHolds = ();
type MaxFreezes = ();
}

// Parameterize ERC721 pallet
Expand Down Expand Up @@ -169,8 +167,8 @@ impl Default for TestExternalitiesBuilder {
impl TestExternalitiesBuilder {
// Build a genesis storage key/value store
pub(crate) fn build(self) -> TestExternalities {
let mut storage = frame_system::GenesisConfig::default()
.build_storage::<MockRuntime>()
let mut storage = frame_system::GenesisConfig::<MockRuntime>::default()
.build_storage()
.unwrap();

// pre-fill balances
Expand Down
16 changes: 8 additions & 8 deletions example-pallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
serde = { version = "1.0.101", optional = true }

# primitives
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }

# frame dependencies
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }
scale-info = { version = "2.0", default-features = false, features = [
"derive",
] }
Expand All @@ -30,7 +30,7 @@ chainbridge = { path = "../chainbridge", default-features = false }
pallet-example-erc721 = { path = "../example-erc721", default-features = false }

[dev-dependencies]
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.1.0" }

[build-dependencies]
wasm-builder-runner = { version = "3.0.0", package = "substrate-wasm-builder-runner" }
Expand Down
Loading

0 comments on commit 7b58efe

Please sign in to comment.