Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
feat: upgrade trappist to polkadot-v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
José Molina committed Dec 1, 2023
1 parent 2911c31 commit a944868
Show file tree
Hide file tree
Showing 22 changed files with 2,791 additions and 2,650 deletions.
4,661 changes: 2,521 additions & 2,140 deletions Cargo.lock

Large diffs are not rendered by default.

226 changes: 113 additions & 113 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ try-runtime = [
"trappist-runtime?/try-runtime",
"try-runtime-cli/try-runtime"
]
parameterized-consensus-hook = []
3 changes: 1 addition & 2 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use parachains_common::{AccountId, AssetIdForTrustBackedAssets as AssetId, Balan
use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sc_transaction_pool_api::TransactionPool;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};

Expand Down Expand Up @@ -53,7 +53,6 @@ where
+ Send
+ Sync
+ 'static,
C: CallApiAt<Block>,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
Expand Down
1 change: 1 addition & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ where
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
};

let fut =
Expand Down
3 changes: 2 additions & 1 deletion pallets/asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxLocks = ();
type MaxReserves = ();
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<0>;
type RuntimeFreezeReason = ();
}

impl pallet_assets::Config for Test {
Expand Down
3 changes: 2 additions & 1 deletion pallets/lockdown-mode/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxLocks = ();
type MaxReserves = ();
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<0>;
type RuntimeFreezeReason = ();
}

pub struct RuntimeBlackListedCalls;
Expand Down
6 changes: 4 additions & 2 deletions pallets/lockdown-mode/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ fn call_not_filtered_in_lockdown_mode() {
fn call_filtered_in_lockdown_mode() {
new_test_ext(false).execute_with(|| {
assert_ok!(LockdownMode::activate_lockdown_mode(RuntimeOrigin::root()));
let balance_call = RuntimeCall::Balance(BalancesCall::transfer { dest: 1, value: 2 });
let balance_call =
RuntimeCall::Balance(BalancesCall::transfer_allow_death { dest: 1, value: 2 });

let result: bool = LockdownMode::contains(&balance_call);
assert!(!result);
Expand All @@ -93,7 +94,8 @@ fn call_not_filtered_in_normal_mode() {
new_test_ext(false).execute_with(|| {
let lockdown_mode = LockdownModeStatus::<Test>::get();
assert_eq!(lockdown_mode, DEACTIVATED);
let balance_call = RuntimeCall::Balance(BalancesCall::transfer { dest: 1, value: 2 });
let balance_call =
RuntimeCall::Balance(BalancesCall::transfer_allow_death { dest: 1, value: 2 });
let result: bool = LockdownMode::contains(&balance_call);
assert!(result);
});
Expand Down
2 changes: 1 addition & 1 deletion pallets/withdraw-teleport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<T: Config> Pallet<T> {

//Build the message to execute on origin.
let assets: MultiAssets = assets.into();
let mut message: Xcm<<T as frame_system::Config>::RuntimeCall> = Xcm(vec![
let mut message = Xcm(vec![
WithdrawAsset(assets.clone()),
SetFeesMode { jit_withdraw: true },
// Burn the native asset.
Expand Down
3 changes: 2 additions & 1 deletion pallets/withdraw-teleport/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxLocks = ();
type MaxReserves = ();
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<0>;
type RuntimeFreezeReason = ();
}

parameter_types! {
Expand Down
5 changes: 4 additions & 1 deletion runtime/stout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ parachain-info = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true }

# Polkadot Dependencies
kusama-runtime-constants = { workspace = true }
rococo-runtime-constants = { workspace = true }
pallet-xcm = { workspace = true }
polkadot-core-primitives = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
Expand Down Expand Up @@ -188,3 +188,6 @@ runtime-benchmarks = [
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
]
parameterized-consensus-hook = [
"cumulus-pallet-parachain-system/parameterized-consensus-hook",
]
2 changes: 1 addition & 1 deletion runtime/stout/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// limitations under the License.

pub mod currency {
use kusama_runtime_constants as constants;
use polkadot_core_primitives::Balance;
use rococo_runtime_constants as constants;

/// The existential deposit. Set to 1/10 of its parent Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
Expand Down
25 changes: 22 additions & 3 deletions runtime/stout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ use sp_version::RuntimeVersion;
use xcm_config::{CollatorSelectionUpdateOrigin, RelayLocation};

pub use frame_system::Call as SystemCall;
use pallet_identity::simple::IdentityInfo;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

Expand Down Expand Up @@ -227,8 +228,9 @@ impl pallet_balances::Config for Runtime {
type FreezeIdentifier = ();
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<0>;
type RuntimeFreezeReason = RuntimeFreezeReason;
}

parameter_types! {
Expand Down Expand Up @@ -285,6 +287,15 @@ parameter_types! {
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
}

/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;

impl cumulus_pallet_parachain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
Expand All @@ -295,6 +306,13 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
#[cfg(feature = "parameterized-consensus-hook")]
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
}

impl pallet_insecure_randomness_collective_flip::Config for Runtime {}
Expand Down Expand Up @@ -416,6 +434,7 @@ parameter_types! {
pub const BasicDeposit: Balance = deposit(1, 258); // 258 bytes on-chain
pub const FieldDeposit: Balance = deposit(0, 66); // 66 bytes on-chain
pub const SubAccountDeposit: Balance = deposit(1, 53); // 53 bytes on-chain
pub const MaxAdditionalFields: u32 = 100;
}

impl pallet_identity::Config for Runtime {
Expand All @@ -426,6 +445,7 @@ impl pallet_identity::Config for Runtime {
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = ConstU32<100>;
type MaxAdditionalFields = ConstU32<100>;
type IdentityInformation = IdentityInfo<MaxAdditionalFields>;
type MaxRegistrars = ConstU32<20>;
type Slashed = ();
type ForceOrigin = EnsureRootOrHalfCouncil;
Expand Down Expand Up @@ -494,8 +514,7 @@ impl pallet_preimage::Config for Runtime {
type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
type Consideration = ();
}

parameter_types! {
Expand Down
4 changes: 3 additions & 1 deletion runtime/stout/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.

use crate::AllPalletsWithSystem;
use cumulus_primitives_core::ParaId;

use super::{
AccountId, AssetRegistry, Assets, Balance, Balances, ParachainInfo, ParachainSystem,
Expand All @@ -36,6 +37,7 @@ use xcm_executor::traits::JustTry;

use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use xcm::latest::{prelude::*, MultiAsset, MultiLocation};
use xcm_primitives::{AsAssetMultiLocation, ConvertedRegisteredAssetId};

Expand Down Expand Up @@ -354,7 +356,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Runtime>;
type PriceForSiblingDelivery = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
Expand Down
7 changes: 5 additions & 2 deletions runtime/trappist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ parachain-info = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true }

# Polkadot Dependencies
kusama-runtime-constants = { workspace = true }
rococo-runtime-constants = { workspace = true }
pallet-xcm = { workspace = true }
polkadot-core-primitives = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
polkadot-runtime-parachains = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
Expand Down Expand Up @@ -192,7 +193,6 @@ runtime-benchmarks = [
"pallet-assets/runtime-benchmarks",
"pallet-asset-registry/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"trappist-runtime-benchmarks/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
Expand Down Expand Up @@ -253,3 +253,6 @@ try-runtime = [
"pallet-asset-tx-payment/try-runtime",
"pallet-withdraw-teleport/try-runtime",
]
parameterized-consensus-hook = [
"cumulus-pallet-parachain-system/parameterized-consensus-hook",
]
2 changes: 1 addition & 1 deletion runtime/trappist/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// limitations under the License.

pub mod currency {
use kusama_runtime_constants as constants;
use polkadot_core_primitives::Balance;
use rococo_runtime_constants as constants;

/// The existential deposit. Set to 1/10 of its parent Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
Expand Down
26 changes: 20 additions & 6 deletions runtime/trappist/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub struct ToAuthor<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>: From<polkadot_core_primitives::v2::AccountId>
+ Into<polkadot_core_primitives::v2::AccountId>,
AccountIdOf<R>:
From<polkadot_core_primitives::AccountId> + Into<polkadot_core_primitives::AccountId>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
Expand All @@ -57,8 +57,8 @@ impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config + pallet_treasury::Config,
pallet_treasury::Pallet<R>: OnUnbalanced<NegativeImbalance<R>>,
AccountIdOf<R>: From<polkadot_core_primitives::v2::AccountId>
+ Into<polkadot_core_primitives::v2::AccountId>,
AccountIdOf<R>:
From<polkadot_core_primitives::AccountId> + Into<polkadot_core_primitives::AccountId>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
Expand Down Expand Up @@ -115,14 +115,15 @@ impl xcm_primitives::PauseXcmExecution for XcmExecutionManager {

#[cfg(test)]
mod tests {
use frame_support::traits::tokens::PayFromAccount;
use frame_support::{
parameter_types,
traits::{FindAuthor, ValidatorRegistration},
PalletId,
};
use frame_system::{limits, EnsureRoot};
use pallet_collator_selection::IdentityCollator;
use polkadot_core_primitives::v2::AccountId;
use polkadot_core_primitives::AccountId;
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, ConstU32, ConstU64, IdentityLookup},
Expand Down Expand Up @@ -188,8 +189,9 @@ mod tests {
type FreezeIdentifier = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<0>;
type RuntimeFreezeReason = ();
}

pub struct OneAuthor;
Expand Down Expand Up @@ -256,6 +258,10 @@ mod tests {
}
}

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

impl pallet_treasury::Config for Test {
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = EnsureRoot<AccountId>;
Expand All @@ -273,6 +279,14 @@ mod tests {
type SpendFunds = ();
type MaxApprovals = ConstU32<100>;
type SpendOrigin = TestSpendOrigin;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU64<10>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

pub fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
Loading

0 comments on commit a944868

Please sign in to comment.