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: Update substrate to v1.3.0 #3921

Merged
merged 19 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
839 changes: 522 additions & 317 deletions Cargo.lock

Large diffs are not rendered by default.

242 changes: 121 additions & 121 deletions Cargo.toml

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions common/src/pallet_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ macro_rules! impl_pallet_balances {
($runtime:ty) => {
impl pallet_balances::Config for $runtime {
type MaxLocks = ();
type MaxHolds = ();
type MaxFreezes = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
type MaxReserves = ();
type FreezeIdentifier = ();
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = RuntimeFreezeReason;
type RuntimeHoldReason = RuntimeHoldReason;
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
Expand Down
2 changes: 1 addition & 1 deletion gsdk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const GSDK_API_GEN: &str = "GSDK_API_GEN";
const GSDK_API_GEN_PKG: &str = "gsdk-api-gen";
const GSDK_API_GEN_RELATIVE_PATH: &str = "gsdk-api-gen";
const VARA_RUNTIME_PKG: &str = "vara-runtime";
const VARA_RUNTIME_RELATIVE_PATH: &str = "wbuild/vara-runtime/vara_runtime.compact.compressed.wasm";
const VARA_RUNTIME_RELATIVE_PATH: &str = "wbuild/vara-runtime/vara_runtime.wasm";
const GENERATED_API_PATH: &str = "src/metadata/generated.rs";
const ENV_RUNTIME_WASM: &str = "RUNTIME_WASM";

Expand Down
251 changes: 201 additions & 50 deletions gsdk/src/metadata/generated.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pallets/gas/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate as pallet_gear_gas;
use frame_support::{construct_runtime, parameter_types, weights::constants::RocksDbWeight};
use frame_support::{
construct_runtime, parameter_types, traits::ConstU32, weights::constants::RocksDbWeight,
};
use frame_system::{self as system, pallet_prelude::BlockNumberFor};
use primitive_types::H256;
use sp_runtime::{
Expand Down
4 changes: 3 additions & 1 deletion pallets/gear-bank/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

use crate as pallet_gear_bank;
use frame_support::{
construct_runtime, parameter_types, traits::FindAuthor, weights::constants::RocksDbWeight,
construct_runtime, parameter_types,
traits::{ConstU32, FindAuthor},
weights::constants::RocksDbWeight,
};
use primitive_types::H256;
use sp_io::TestExternalities;
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-builtin/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use common::{GasProvider, GasTree};
use core::cell::RefCell;
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstBool, ConstU64, FindAuthor, OnFinalize, OnInitialize},
traits::{ConstBool, ConstU32, ConstU64, FindAuthor, OnFinalize, OnInitialize},
};
use frame_support_test::TestRandomness;
use frame_system::{self as system, pallet_prelude::BlockNumberFor};
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-builtin/src/tests/bad_builtin_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::{self as pallet_gear_builtin, BuiltinActor, BuiltinActorError};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstBool, ConstU64, FindAuthor, OnFinalize, OnInitialize},
traits::{ConstBool, ConstU32, ConstU64, FindAuthor, OnFinalize, OnInitialize},
};
use frame_support_test::TestRandomness;
use frame_system::{self as system, pallet_prelude::BlockNumberFor};
Expand Down
7 changes: 4 additions & 3 deletions pallets/gear-debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,20 @@ pub mod pallet {
/// Used in tests to exhaust block resources.
///
/// Parameters:
/// - `_fraction`: the fraction of the `max_extrinsic` the extrinsic will use.
/// - `fraction`: the fraction of the `max_extrinsic` the extrinsic will use.
#[pallet::call_index(1)]
#[pallet::weight({
if let Some(max) = T::BlockWeights::get().get(DispatchClass::Normal).max_extrinsic {
*_fraction * max
*fraction * max
} else {
Weight::zero()
}
})]
pub fn exhaust_block_resources(
origin: OriginFor<T>,
_fraction: Percent,
fraction: Percent,
) -> DispatchResultWithPostInfo {
let _ = fraction; // We dont need to check the weight witness.
ukint-vs marked this conversation as resolved.
Show resolved Hide resolved
ensure_root(origin)?;
Ok(Pays::No.into())
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-debug/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use frame_support::{
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{FindAuthor, Get, OnFinalize, OnInitialize},
traits::{ConstU32, FindAuthor, Get, OnFinalize, OnInitialize},
weights::Weight,
};
use frame_support_test::TestRandomness;
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-messenger/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use crate as pallet_gear_messenger;
use frame_support::{
construct_runtime, parameter_types,
traits::{OnFinalize, OnInitialize},
traits::{ConstU32, OnFinalize, OnInitialize},
weights::constants::RocksDbWeight,
};
use frame_system::{self as system, pallet_prelude::BlockNumberFor};
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-program/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
construct_runtime,
pallet_prelude::*,
parameter_types,
traits::{ConstU64, FindAuthor},
traits::{ConstU32, ConstU64, FindAuthor},
weights::RuntimeDbWeight,
};
use frame_system::{self as system, pallet_prelude::BlockNumberFor};
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear-scheduler/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame_support::{
dispatch::DispatchClass,
pallet_prelude::*,
parameter_types,
traits::{ConstU64, FindAuthor},
traits::{ConstU32, ConstU64, FindAuthor},
weights::constants::RocksDbWeight,
};
use frame_support_test::TestRandomness;
Expand Down
1 change: 1 addition & 0 deletions pallets/gear-voucher/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use common::{
};
use frame_support::{
construct_runtime, parameter_types,
traits::ConstU32,
weights::{constants::RocksDbWeight, Weight},
PalletId,
};
Expand Down
2 changes: 1 addition & 1 deletion pallets/gear/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame_support::{
construct_runtime,
pallet_prelude::*,
parameter_types,
traits::{ConstU64, FindAuthor, Get},
traits::{ConstU32, ConstU64, FindAuthor, Get},
PalletId,
};
use frame_support_test::TestRandomness;
Expand Down
3 changes: 2 additions & 1 deletion pallets/payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use common::storage::Messenger;
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU128, ConstU8, Contains, Currency, FindAuthor, OnFinalize, OnInitialize, OnUnbalanced,
ConstU128, ConstU32, ConstU8, Contains, Currency, FindAuthor, OnFinalize, OnInitialize,
OnUnbalanced,
},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight},
PalletId,
Expand Down
22 changes: 21 additions & 1 deletion pallets/staking-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use frame_election_provider_support::{
};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU32, Contains, Currency, FindAuthor, Hooks, NeverEnsureOrigin},
traits::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ConstU32, ConstU64, Contains, Currency, FindAuthor, Hooks, NeverEnsureOrigin,
},
weights::{constants::RocksDbWeight, Weight},
PalletId,
};
Expand Down Expand Up @@ -340,6 +343,7 @@ parameter_types! {
pub const SpendPeriod: u32 = 100;
pub const Burn: Permill = Permill::from_percent(50);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub TreasuryAccount: AccountId = Treasury::account_id();
pub const MaxApprovals: u32 = 100;
}

Expand All @@ -360,6 +364,12 @@ impl pallet_treasury::Config for Test {
type WeightInfo = ();
type MaxApprovals = MaxApprovals;
type SpendOrigin = NeverEnsureOrigin<u128>;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU64<10>;
}

parameter_types! {
Expand Down Expand Up @@ -865,6 +875,10 @@ pub(crate) mod two_block_producers {
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
}

parameter_types! {
pub TreasuryAccount: AccountId = Treasury::account_id();
}

impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -882,6 +896,12 @@ pub(crate) mod two_block_producers {
type WeightInfo = ();
type MaxApprovals = MaxApprovals;
type SpendOrigin = NeverEnsureOrigin<u128>;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU64<10>;
}

impl pallet_bags_list::Config<pallet_bags_list::Instance1> for Test {
Expand Down
32 changes: 25 additions & 7 deletions runtime/vara/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ pub use frame_support::{
dispatch::{DispatchClass, WeighData},
parameter_types,
traits::{
fungible::HoldConsideration, ConstU128, ConstU16, ConstU32, Contains, Currency, EitherOf,
EitherOfDiverse, EqualPrivilegeOnly, Everything, FindAuthor, InstanceFilter,
KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness,
StorageInfo, WithdrawReasons,
fungible::HoldConsideration,
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ConstU128, ConstU16, ConstU32, Contains, Currency, EitherOf, EitherOfDiverse,
EqualPrivilegeOnly, Everything, FindAuthor, InstanceFilter, KeyOwnerProofSystem,
LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness, StorageInfo,
WithdrawReasons,
},
weights::{
constants::{
Expand All @@ -61,6 +63,7 @@ pub use pallet_gear_staking_rewards::StakingBlackList;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
use pallet_identity::simple::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical::{self as pallet_session_historical};
pub use pallet_timestamp::Call as TimestampCall;
Expand All @@ -87,7 +90,10 @@ use sp_runtime::traits::HashingFor;
use sp_runtime::{
codec::{Decode, Encode, MaxEncodedLen},
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys},
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup, NumberFor,
OpaqueKeys,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, Perbill, Percent, Permill, Perquintill, RuntimeDebug,
};
Expand Down Expand Up @@ -360,8 +366,9 @@ impl pallet_balances::Config for Runtime {
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = RuntimeFreezeReason;
type MaxFreezes = ConstU32<8>;
type RuntimeHoldReason = RuntimeHoldReason;
type MaxHolds = ConstU32<2>;
}
Expand Down Expand Up @@ -691,6 +698,7 @@ impl pallet_nomination_pools::Config for Runtime {
type WeightInfo = ();
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type RuntimeFreezeReason = RuntimeFreezeReason;
type RewardCounter = FixedU128;
type BalanceToU256 = BalanceToU256;
type U256ToBalance = U256ToBalance;
Expand Down Expand Up @@ -719,8 +727,11 @@ parameter_types! {
pub const TipReportDepositBase: Balance = ECONOMIC_UNITS;
pub const DataDepositPerByte: Balance = ECONOMIC_CENTIUNITS;
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
pub TreasuryAccount: AccountId = Treasury::account_id();
pub const MaximumReasonLength: u32 = 300;
pub const MaxApprovals: u32 = 100;
pub const MaxBalance: Balance = Balance::max_value();
}

impl pallet_treasury::Config for Runtime {
Expand All @@ -740,6 +751,12 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
type MaxApprovals = MaxApprovals;
type SpendOrigin = TreasurySpender;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = PayoutSpendPeriod;
}

parameter_types! {
Expand Down Expand Up @@ -821,6 +838,7 @@ impl pallet_identity::Config for Runtime {
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type MaxAdditionalFields = MaxAdditionalFields;
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = MaxRegistrars;
type Slashed = Treasury;
type ForceOrigin = EitherOf<EnsureRoot<AccountId>, GeneralAdmin>;
Expand Down
2 changes: 2 additions & 0 deletions runtime/vara/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ pub type Migrations = (
pallet_gear_program::migration::AppendStackEndMigration<Runtime>,
// migration for removed waiting init list
pallet_gear::migrations::MigrateWaitingInitList<Runtime>,
pallet_nomination_pools::migration::versioned_migrations::V5toV6<Runtime>,
pallet_nomination_pools::migration::versioned_migrations::V6ToV7<Runtime>,
ekovalev marked this conversation as resolved.
Show resolved Hide resolved
);
Loading