Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Polkadot v1.2. to v1.4 upgrade #437

Open
wants to merge 25 commits into
base: new-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5f95331
bump dependnecies and fix implementation
Aideepakchaudhary Sep 30, 2024
22cc20a
fix migration issue
Aideepakchaudhary Sep 30, 2024
e1534a4
fix tests
Aideepakchaudhary Sep 30, 2024
b7633f9
bump dependencies and fix runtime impl
Aideepakchaudhary Oct 1, 2024
e5e8e1a
fix chain spec
Aideepakchaudhary Oct 1, 2024
f1d9446
fmt
Aideepakchaudhary Oct 1, 2024
509154b
bump spec_version
Aideepakchaudhary Oct 1, 2024
c64a7d0
fix mock
Aideepakchaudhary Oct 1, 2024
8d24d2f
fix types for tests
Aideepakchaudhary Oct 1, 2024
164b98c
fmt
Aideepakchaudhary Oct 1, 2024
7789626
fix runtime migration
Aideepakchaudhary Oct 2, 2024
ab573eb
fix clippy
Aideepakchaudhary Oct 2, 2024
de1f5f0
remove unused types
Aideepakchaudhary Oct 2, 2024
250b3ba
fix node version
Aideepakchaudhary Oct 2, 2024
351fdb7
update changelog file
Aideepakchaudhary Oct 3, 2024
2a8518a
remove TODOs
Aideepakchaudhary Oct 4, 2024
d846507
added some documentation
Aideepakchaudhary Oct 4, 2024
f6c5b15
choir: spacing
metricaez Oct 4, 2024
b942a2e
Merge branch 'feat/polkadot-v1.2.0-upgrade' into feat/polkadot-v1.4.0…
metricaez Oct 4, 2024
7656e16
choir: bump workspace version and update changelog
metricaez Oct 4, 2024
ad57dbb
fix CI
Aideepakchaudhary Oct 8, 2024
90ccc01
update mock
Aideepakchaudhary Oct 10, 2024
85b6e75
Merge branch 'new-staging' into feat/polkadot-v1.4.0-upgrade
Aideepakchaudhary Oct 10, 2024
cee1d9a
resolve lock file confict
Aideepakchaudhary Oct 10, 2024
ce7aa3c
remove unused variables
Aideepakchaudhary Oct 15, 2024
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
2,873 changes: 1,811 additions & 1,062 deletions Cargo.lock

Large diffs are not rendered by default.

257 changes: 132 additions & 125 deletions Cargo.toml

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::sync::Arc;
use node_primitives::Nonce;
pub use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Header, Signature};
use sc_client_api::{
AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, PairsIter, UsageProvider,
AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, MerkleValue, PairsIter,
UsageProvider,
};
pub use sc_executor::NativeElseWasmExecutor;
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
Expand Down Expand Up @@ -373,6 +374,35 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
}
}
}

fn closest_merkle_value(
&self,
hash: <Block as BlockT>::Hash,
key: &StorageKey,
) -> sp_blockchain::Result<Option<MerkleValue<<Block as BlockT>::Hash>>> {
with_client! {
self,
client,
{
client.closest_merkle_value(hash, key)
}
}
}

fn child_closest_merkle_value(
&self,
hash: <Block as BlockT>::Hash,
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<MerkleValue<<Block as BlockT>::Hash>>> {
with_client! {
self,
client,
{
client.child_closest_merkle_value(hash, child_info, key)
}
}
}
}

impl sp_blockchain::HeaderBackend<Block> for Client {
Expand Down
28 changes: 16 additions & 12 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ fn cere_dev_session_keys(
/// Helper function to create Cere Dev `RuntimeGenesisConfig` for testing
#[cfg(feature = "cere-dev-native")]
pub fn cere_dev_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(
AccountId,
AccountId,
Expand Down Expand Up @@ -161,11 +160,8 @@ pub fn cere_dev_genesis(
const STASH: Balance = ENDOWMENT / 1000;

cere_dev::RuntimeGenesisConfig {
system: cere_dev::SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
..Default::default()
},
//TODO: check
Aideepakchaudhary marked this conversation as resolved.
Show resolved Hide resolved
system: cere_dev::SystemConfig::default(),
balances: cere_dev::BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
Expand Down Expand Up @@ -237,9 +233,8 @@ pub fn cere_dev_native_chain_spec_properties() -> serde_json::map::Map<String, s

/// Helper function to create Cere `RuntimeGenesisConfig` for testing
#[cfg(feature = "cere-dev-native")]
fn cere_dev_config_genesis(wasm_binary: &[u8]) -> cere_dev::RuntimeGenesisConfig {
fn cere_dev_config_genesis() -> cere_dev::RuntimeGenesisConfig {
cere_dev_genesis(
wasm_binary,
// Initial authorities
vec![authority_keys_from_seed("Alice")],
// Initial nominators
Expand All @@ -260,24 +255,28 @@ fn cere_dev_config_genesis(wasm_binary: &[u8]) -> cere_dev::RuntimeGenesisConfig
pub fn cere_dev_development_config() -> Result<CereDevChainSpec, String> {
let wasm_binary = cere_dev::WASM_BINARY.ok_or("Cere Dev development wasm not available")?;

#[allow(deprecated)]
Ok(CereDevChainSpec::from_genesis(
"Development",
"cere_dev",
ChainType::Development,
move || cere_dev_config_genesis(wasm_binary),
cere_dev_config_genesis,
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Some(cere_dev_native_chain_spec_properties()),
Default::default(),
wasm_binary,
))

//TODO: Migrate to builder
Aideepakchaudhary marked this conversation as resolved.
Show resolved Hide resolved
// Ok(CereDevChainSpec::builder(wasm_binary, Extensions::default()).build())
}

#[cfg(feature = "cere-dev-native")]
fn cere_dev_local_testnet_genesis(wasm_binary: &[u8]) -> cere_dev::RuntimeGenesisConfig {
fn cere_dev_local_testnet_genesis() -> cere_dev::RuntimeGenesisConfig {
cere_dev_genesis(
wasm_binary,
// Initial authorities
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
// Initial nominators
Expand All @@ -298,18 +297,23 @@ fn cere_dev_local_testnet_genesis(wasm_binary: &[u8]) -> cere_dev::RuntimeGenesi
pub fn cere_dev_local_testnet_config() -> Result<CereDevChainSpec, String> {
let wasm_binary = cere_dev::WASM_BINARY.ok_or("Cere Dev development wasm not available")?;

#[allow(deprecated)]
Ok(CereDevChainSpec::from_genesis(
"Local Testnet",
"cere_dev_local_testnet",
ChainType::Local,
move || cere_dev_local_testnet_genesis(wasm_binary),
cere_dev_local_testnet_genesis,
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
wasm_binary,
))

//TODO: Migrate to builder
Aideepakchaudhary marked this conversation as resolved.
Show resolved Hide resolved
// Ok(CereDevChainSpec::builder(wasm_binary, Extensions::default()).build())
}

pub fn cere_mainnet_config() -> Result<CereChainSpec, String> {
Expand Down
1 change: 1 addition & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ where
import_queue,
block_announce_validator_builder: None,
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)),
block_relay: None,
})?;

if config.offchain_worker.enabled {
Expand Down
1 change: 1 addition & 0 deletions pallets/chainbridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type RuntimeHoldReason = ();
Expand Down
7 changes: 4 additions & 3 deletions pallets/ddc-clusters-gov/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type MaxHolds = ConstU32<1>;
type RuntimeHoldReason = RuntimeHoldReason;
}

Expand All @@ -148,8 +149,7 @@ impl pallet_preimage::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
type Consideration = ();
}

parameter_types! {
Expand Down Expand Up @@ -248,6 +248,7 @@ impl pallet_contracts::Config for Test {
type Debug = ();
type Environment = ();
type Migrations = ();
type Xcm = ();
}

impl pallet_insecure_randomness_collective_flip::Config for Test {}
Expand Down
2 changes: 2 additions & 0 deletions pallets/ddc-clusters/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl contracts::Config for Test {
type Debug = ();
type Environment = ();
type Migrations = ();
type Xcm = ();
}

use frame_system::offchain::{
Expand Down Expand Up @@ -178,6 +179,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type RuntimeHoldReason = RuntimeHoldReason;
Expand Down
1 change: 1 addition & 0 deletions pallets/ddc-customers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type RuntimeHoldReason = ();
Expand Down
1 change: 1 addition & 0 deletions pallets/ddc-nodes/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type RuntimeHoldReason = ();
Expand Down
3 changes: 2 additions & 1 deletion pallets/ddc-payouts/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ddc_primitives::{
use frame_election_provider_support::SortedListProvider;
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU32, ConstU64, Everything, Randomness},
traits::{ConstU32, ConstU64, Everything, ExistenceRequirement, Randomness},
weights::constants::RocksDbWeight,
PalletId,
};
Expand Down Expand Up @@ -110,6 +110,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type RuntimeHoldReason = ();
Expand Down
20 changes: 12 additions & 8 deletions pallets/ddc-payouts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3474,9 +3474,10 @@ fn send_rewarding_providers_batch_100_nodes_small_usage_works() {

let expected_charge = calculate_charge_for_month(cluster_id, user_usage.clone());
Balances::transfer(
RuntimeOrigin::signed(bank),
user_id,
&bank,
&user_id,
(expected_charge * 2).max(Balances::minimum_balance()),
ExistenceRequirement::KeepAlive,
)
.unwrap();
total_charge += expected_charge;
Expand Down Expand Up @@ -3747,9 +3748,10 @@ fn send_rewarding_providers_batch_100_nodes_large_usage_works() {

let expected_charge = calculate_charge_for_month(cluster_id, user_usage.clone());
Balances::transfer(
RuntimeOrigin::signed(bank),
user_id,
&bank,
&user_id,
(expected_charge * 2).max(Balances::minimum_balance()),
ExistenceRequirement::KeepAlive,
)
.unwrap();
total_charge += expected_charge;
Expand Down Expand Up @@ -4020,9 +4022,10 @@ fn send_rewarding_providers_batch_100_nodes_small_large_usage_works() {

let expected_charge = calculate_charge_for_month(cluster_id, user_usage.clone());
Balances::transfer(
RuntimeOrigin::signed(bank),
user_id,
&bank,
&user_id,
(expected_charge * 2).max(Balances::minimum_balance()),
ExistenceRequirement::KeepAlive,
)
.unwrap();
total_charge += expected_charge;
Expand Down Expand Up @@ -4252,9 +4255,10 @@ fn send_rewarding_providers_batch_100_nodes_random_usage_works() {

let expected_charge = calculate_charge_for_month(cluster_id, user_usage.clone());
Balances::transfer(
RuntimeOrigin::signed(bank),
user_id,
&bank,
&user_id,
(expected_charge * 2).max(Balances::minimum_balance()),
ExistenceRequirement::KeepAlive,
)
.unwrap();
total_charge += expected_charge;
Expand Down
4 changes: 3 additions & 1 deletion pallets/ddc-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type MaxHolds = ConstU32<1>;
type RuntimeHoldReason = RuntimeHoldReason;
}

Expand Down Expand Up @@ -156,6 +157,7 @@ impl pallet_contracts::Config for Test {
type Debug = ();
type Environment = ();
type Migrations = ();
type Xcm = ();
}

impl pallet_insecure_randomness_collective_flip::Config for Test {}
Expand Down
1 change: 1 addition & 0 deletions pallets/erc721/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ();
type MaxHolds = ();
type RuntimeHoldReason = ();
Expand Down
Loading
Loading