Skip to content

Commit

Permalink
chore(upgrade): v1.8.0 to v1.9.0
Browse files Browse the repository at this point in the history
- Upgrade Polkadot-sdk to v.1.8.0.
- Update weights to reflect the new version.

Notable Changes:
- [System Callabacks](paritytech/polkadot-sdk#1781)
- [Remove of pallet pallet::getter](paritytech/polkadot-sdk#3456)
- [Add storage_proof_size host function](paritytech/polkadot-sdk#3002)

For more details, please refer to:

[Release
Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.9.0)
  • Loading branch information
enddynayn committed Jul 26, 2024
1 parent 2676db8 commit ba953e5
Show file tree
Hide file tree
Showing 21 changed files with 801 additions and 680 deletions.
1,173 changes: 613 additions & 560 deletions Cargo.lock

Large diffs are not rendered by default.

197 changes: 99 additions & 98 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions node/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ pub mod frequency_executor {

impl sc_executor::NativeExecutionDispatch for FrequencyExecutorDispatch {
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
type ExtendHostFunctions = (frame_benchmarking::benchmarking::HostFunctions, cumulus_client_service::storage_proof_size::HostFunctions);

#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();
type ExtendHostFunctions = cumulus_client_service::storage_proof_size::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
frequency_runtime::api::dispatch(method, data)
Expand Down
5 changes: 5 additions & 0 deletions pallets/capacity/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_balances::Config for Test {
Expand Down
5 changes: 5 additions & 0 deletions pallets/frequency-tx-payment/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_balances::Config for Test {
Expand Down
5 changes: 5 additions & 0 deletions pallets/handles/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_handles::Config for Test {
Expand Down
2 changes: 1 addition & 1 deletion pallets/messages/src/migration/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
pub fn migrate_to_v2<T: Config>() -> Weight {
log::info!(target: LOG_TARGET, "Running storage migration...");
let onchain_version = Pallet::<T>::on_chain_storage_version();
let current_version = Pallet::<T>::current_storage_version();
let current_version = Pallet::<T>::in_code_storage_version();
log::info!(target: LOG_TARGET, "onchain_version= {:?}, current_version={:?}", onchain_version, current_version);

if onchain_version < 2 {
Expand Down
5 changes: 5 additions & 0 deletions pallets/messages/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ impl system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

pub type MaxSchemaGrantsPerDelegation = ConstU32<30>;
Expand Down
2 changes: 1 addition & 1 deletion pallets/messages/src/tests/other_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn migration_to_v2_should_work_as_expected() {

let old_count = v2::old::Messages::<Test>::iter().count();
let new_count = MessagesV2::<Test>::iter().count();
let current_version = MessagesPallet::current_storage_version();
let current_version = MessagesPallet::in_code_storage_version();

assert_eq!(old_count, 0);
assert_eq!(new_count, message_per_block.iter().sum::<usize>());
Expand Down
3 changes: 2 additions & 1 deletion pallets/msa/src/tests/governance_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use frame_support::{assert_noop, assert_ok, traits::ChangeMembers};

use pallet_collective::ProposalOf;
use sp_weights::Weight;

use pretty_assertions::assert_eq;
Expand Down Expand Up @@ -52,7 +53,7 @@ fn propose_to_be_provider_happy_path() {

let proposal_index = proposed_events[0].0;
let proposal_hash = proposed_events[0].1;
let proposal = Council::proposal_of(proposal_hash).unwrap();
let proposal = ProposalOf::<Test, CouncilCollective>::get(proposal_hash).unwrap();
let proposal_len: u32 = proposal.encoded_size() as u32;

// Set up the council members
Expand Down
14 changes: 10 additions & 4 deletions pallets/msa/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use frame_support::{
weights::Weight,
};
use frame_system::EnsureRoot;
use pallet_collective;
use pallet_collective::{self, Members, ProposalCount};
use parity_scale_codec::MaxEncodedLen;
use sp_core::{
offchain::{testing, testing::OffchainState, OffchainDbExt, OffchainWorkerExt},
Expand Down Expand Up @@ -58,7 +58,7 @@ impl MaxEncodedLen for SchemaModelMaxBytesBoundedVecLimit {
}
}

type CouncilCollective = pallet_collective::Instance1;
pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Test {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
Expand Down Expand Up @@ -97,6 +97,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_schemas::Config for Test {
Expand Down Expand Up @@ -169,14 +174,15 @@ impl pallet_msa::ProposalProvider<AccountId, RuntimeCall> for CouncilProposalPro
who: AccountId,
proposal: Box<RuntimeCall>,
) -> Result<(u32, u32), DispatchError> {
let threshold: u32 = ((Council::members().len() / 2) + 1) as u32;
let members = Members::<Test, CouncilCollective>::get();
let threshold: u32 = ((members.len() / 2) + 1) as u32;
let length_bound: u32 = proposal.using_encoded(|p| p.len() as u32);
Council::do_propose_proposed(who, threshold, proposal, length_bound)
}

#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
fn proposal_count() -> u32 {
Council::proposal_count()
ProposalCount::<Test, CouncilCollective>::get()
}
}

Expand Down
5 changes: 5 additions & 0 deletions pallets/passkey/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_transaction_payment::Config for Test {
Expand Down
2 changes: 1 addition & 1 deletion pallets/schemas/src/migration/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV4<T> {
pub fn migrate_to_v4<T: Config>() -> Weight {
log::info!(target: LOG_TARGET, "Running storage migration...");
let onchain_version = Pallet::<T>::on_chain_storage_version();
let current_version = Pallet::<T>::current_storage_version();
let current_version = Pallet::<T>::in_code_storage_version();
log::info!(target: LOG_TARGET, "onchain_version= {:?}, current_version={:?}", onchain_version, current_version);
let each_layer_access: u64 = 33 * 16;

Expand Down
3 changes: 2 additions & 1 deletion pallets/schemas/src/tests/deprecated_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use common_primitives::{
schema::{ModelType, PayloadLocation, SchemaId, SchemaSetting},
};
use frame_support::{assert_noop, assert_ok, traits::ChangeMembers, weights::Weight, BoundedVec};
use pallet_collective::ProposalOf;
use parity_scale_codec::Encode;
use serial_test::serial;

Expand Down Expand Up @@ -107,7 +108,7 @@ fn propose_to_create_schema_happy_path() {

let proposal_index = proposed_events[0].0;
let proposal_hash = proposed_events[0].1;
let proposal = Council::proposal_of(proposal_hash).unwrap();
let proposal = ProposalOf::<Test, CouncilCollective>::get(proposal_hash).unwrap();
let proposal_len: u32 = proposal.encoded_size() as u32;

// Set up the council members
Expand Down
2 changes: 1 addition & 1 deletion pallets/schemas/src/tests/migrations_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn schemas_migration_to_v4_should_work_as_expected() {
let _ = v4::migrate_to_v4::<Test>();

// Assert
let current_version = SchemasPallet::current_storage_version();
let current_version = SchemasPallet::in_code_storage_version();
assert_eq!(current_version, StorageVersion::new(4));

let known_schemas = v4::get_known_schemas::<Test>();
Expand Down
15 changes: 11 additions & 4 deletions pallets/schemas/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use parity_scale_codec::MaxEncodedLen;

use common_primitives::node::AccountId;
use common_runtime::constants::DAYS;
use pallet_collective;
use pallet_collective::{self, Members};
use smallvec::smallvec;
use sp_core::{parameter_types, Encode, H256};
use sp_runtime::{
Expand Down Expand Up @@ -49,7 +49,7 @@ impl MaxEncodedLen for SchemaModelMaxBytesBoundedVecLimit {
}
}

type CouncilCollective = pallet_collective::Instance1;
pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Test {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
Expand Down Expand Up @@ -98,14 +98,16 @@ impl pallet_schemas::ProposalProvider<AccountId, RuntimeCall> for CouncilProposa
who: AccountId,
proposal: Box<RuntimeCall>,
) -> Result<(u32, u32), DispatchError> {
let threshold: u32 = ((Council::members().len() / 2) + 1) as u32;
let members = Members::<Test, CouncilCollective>::get();
let threshold: u32 = ((members.len() / 2) + 1) as u32;
let length_bound: u32 = proposal.using_encoded(|p| p.len() as u32);
Council::do_propose_proposed(who, threshold, proposal, length_bound)
}

#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
fn proposal_count() -> u32 {
Council::proposal_count()
use pallet_collective::ProposalCount;
ProposalCount::<Test, CouncilCollective>::get()
}
}

Expand Down Expand Up @@ -155,6 +157,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

pub fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
5 changes: 3 additions & 2 deletions pallets/schemas/src/tests/other_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use common_primitives::{
use frame_support::{
assert_noop, assert_ok, dispatch::RawOrigin, traits::ChangeMembers, weights::Weight, BoundedVec,
};
use pallet_collective::ProposalOf;
use parity_scale_codec::Encode;
use serial_test::serial;
use sp_runtime::{BuildStorage, DispatchError::BadOrigin};
Expand Down Expand Up @@ -794,7 +795,7 @@ fn propose_to_create_schema_v2_happy_path() {

let proposal_index = proposed_events[0].0;
let proposal_hash = proposed_events[0].1;
let proposal = Council::proposal_of(proposal_hash).unwrap();
let proposal = ProposalOf::<Test, CouncilCollective>::get(proposal_hash).unwrap();
let proposal_len: u32 = proposal.encoded_size() as u32;

// Set up the council members
Expand Down Expand Up @@ -943,7 +944,7 @@ fn propose_to_create_schema_name_happy_path() {

let proposal_index = proposed_events[0].0;
let proposal_hash = proposed_events[0].1;
let proposal = Council::proposal_of(proposal_hash).unwrap();
let proposal = ProposalOf::<Test, CouncilCollective>::get(proposal_hash).unwrap();
let proposal_len: u32 = proposal.encoded_size() as u32;

// Set up the council members
Expand Down
5 changes: 5 additions & 0 deletions pallets/stateful-storage/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ impl system::Config for Test {
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

pub type MaxItemizedActionsCount = ConstU32<6>;
Expand Down
5 changes: 5 additions & 0 deletions pallets/time-release/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

type Balance = u64;
Expand Down
2 changes: 1 addition & 1 deletion runtime/frequency/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.0.0"
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.8.0"}
substrate-wasm-builder = { workspace = true }

[dependencies]
parity-scale-codec = { workspace = true, features = ["derive"] }
Expand Down
22 changes: 19 additions & 3 deletions runtime/frequency/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ use sp_runtime::{
ApplyExtrinsicResult, DispatchError,
};

use pallet_collective::Members;

#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
use pallet_collective::ProposalCount;

use parity_scale_codec::Encode;

use sp_std::prelude::*;
Expand Down Expand Up @@ -114,14 +119,15 @@ impl ProposalProvider<AccountId, RuntimeCall> for CouncilProposalProvider {
who: AccountId,
proposal: Box<RuntimeCall>,
) -> Result<(u32, u32), DispatchError> {
let threshold: u32 = ((Council::members().len() / 2) + 1) as u32;
let members = Members::<Runtime, CouncilCollective>::get();
let threshold: u32 = ((members.len() / 2) + 1) as u32;
let length_bound: u32 = proposal.using_encoded(|p| p.len() as u32);
Council::do_propose_proposed(who, threshold, proposal, length_bound)
}

#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
fn proposal_count() -> u32 {
Council::proposal_count()
ProposalCount::<Runtime, CouncilCollective>::get()
}
}

Expand Down Expand Up @@ -468,6 +474,16 @@ impl frame_system::Config for Runtime {
#[cfg(feature = "frequency-no-relay")]
type OnSetCode = ();
type MaxConsumers = FrameSystemMaxConsumers;
/// A new way of configuring migrations that run in a single block.
type SingleBlockMigrations = ();
/// The migrator that is used to run Multi-Block-Migrations.
type MultiBlockMigrator = ();
/// A callback that executes in *every block* directly before all inherents were applied.
type PreInherents = ();
/// A callback that executes in *every block* directly after all inherents were applied.
type PostInherents = ();
/// A callback that executes in *every block* directly after all transactions were applied.
type PostTransactions = ();
}

impl pallet_msa::Config for Runtime {
Expand Down Expand Up @@ -1289,7 +1305,7 @@ impl_runtime_apis! {
Executive::execute_block(block)
}

fn initialize_block(header: &<Block as BlockT>::Header) {
fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
Executive::initialize_block(header)
}
}
Expand Down

0 comments on commit ba953e5

Please sign in to comment.