diff --git a/evm-template/runtime/src/configs/asset_config.rs b/evm-template/runtime/src/configs/asset_config.rs index 5d89c92..f71aabc 100644 --- a/evm-template/runtime/src/configs/asset_config.rs +++ b/evm-template/runtime/src/configs/asset_config.rs @@ -62,7 +62,8 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = RemoveItemsLimit; type RuntimeEvent = RuntimeEvent; type StringLimit = StringLimit; - type WeightInfo = weights::pallet_assets::WeightInfo; //FIXME: run & update + /// Rerun benchmarks if you are making changes to runtime configuration. + type WeightInfo = weights::pallet_assets::WeightInfo; } // Our AssetType. For now we only handle Xcm Assets @@ -180,5 +181,6 @@ impl pallet_asset_manager::Config for Runtime { type ForeignAssetModifierOrigin = EnsureRoot; type ForeignAssetType = AssetType; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_asset_manager::WeightInfo; } diff --git a/evm-template/runtime/src/configs/governance/mod.rs b/evm-template/runtime/src/configs/governance/mod.rs index a81459a..85712be 100644 --- a/evm-template/runtime/src/configs/governance/mod.rs +++ b/evm-template/runtime/src/configs/governance/mod.rs @@ -32,6 +32,7 @@ impl pallet_conviction_voting::Config for Runtime { type Polls = Referenda; type RuntimeEvent = RuntimeEvent; type VoteLockingPeriod = VoteLockingPeriod; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_conviction_voting::WeightInfo; } @@ -47,6 +48,7 @@ impl pallet_whitelist::Config for Runtime { type Preimages = Preimage; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_whitelist::WeightInfo; type WhitelistOrigin = EnsureRoot; } @@ -74,5 +76,6 @@ impl pallet_referenda::Config for Runtime { type Tracks = tracks::TracksInfo; type UndecidingTimeout = UndecidingTimeout; type Votes = pallet_conviction_voting::VotesOf; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_referenda::WeightInfo; } diff --git a/evm-template/runtime/src/configs/mod.rs b/evm-template/runtime/src/configs/mod.rs index 024755f..43e9fd8 100644 --- a/evm-template/runtime/src/configs/mod.rs +++ b/evm-template/runtime/src/configs/mod.rs @@ -175,6 +175,7 @@ impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type ScheduleOrigin = EnsureRoot; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_scheduler::WeightInfo; } @@ -198,6 +199,7 @@ impl pallet_preimage::Config for Runtime { type Currency = Balances; type ManagerOrigin = EnsureRoot; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_preimage::WeightInfo; } @@ -209,6 +211,7 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_timestamp::WeightInfo; } @@ -283,6 +286,7 @@ impl pallet_proxy::Config for Runtime { type ProxyType = ProxyType; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_proxy::WeightInfo; } @@ -308,6 +312,7 @@ impl pallet_balances::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type RuntimeHoldReason = RuntimeHoldReason; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_balances::WeightInfo; } @@ -318,6 +323,10 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { + /// There are two possible mechanisms available: slow and fast adjusting. + /// With slow adjusting fees stay almost constant in short periods of time, changing only in long term. + /// It may lead to long inclusion times during spikes, therefore tipping is enabled. + /// With fast adjusting fees change rapidly, but fixed for all users at each block (no tipping) type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; type LengthToFee = ConstantMultiplier; type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; @@ -329,6 +338,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_sudo::WeightInfo; } @@ -351,6 +361,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedXcmpWeight = ReservedXcmpWeight; type RuntimeEvent = RuntimeEvent; type SelfParaId = parachain_info::Pallet; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo; type XcmpMessageHandler = XcmpQueue; } @@ -383,6 +394,7 @@ impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ServiceWeight = MessageQueueServiceWeight; type Size = u32; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_message_queue::WeightInfo; } @@ -401,9 +413,11 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type MaxInboundSuspended = MaxInboundSuspended; + /// Ensure that this value is not set to null (or NoPriceForMessageDelivery) to prevent spamming type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; type RuntimeEvent = RuntimeEvent; type VersionWrapper = (); + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; @@ -424,6 +438,7 @@ impl pallet_multisig::Config for Runtime { type MaxSignatories = MaxSignatories; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_multisig::WeightInfo; } @@ -447,6 +462,7 @@ impl pallet_session::Config for Runtime { type ValidatorId = ::AccountId; // we don't have stash and controller, thus we don't need the convert as well. type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_session::WeightInfo; } @@ -503,6 +519,7 @@ impl pallet_utility::Config for Runtime { type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_utility::WeightInfo; } @@ -557,6 +574,7 @@ impl pallet_treasury::Config for Runtime { type SpendFunds = (); type SpendOrigin = TreasurySpender; type SpendPeriod = SpendPeriod; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_treasury::WeightInfo; } @@ -572,7 +590,9 @@ impl pallet_ethereum::Config for Runtime { } parameter_types! { + /// Block gas limit is calculated with target for 75% of block capacity and ratio of maximum block weight and weight per gas pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + /// To calculate ratio of Gas Limit to PoV size we take the BlockGasLimit we calculated before, and divide it on MAX_POV_SIZE pub GasLimitPovSizeRatio: u64 = BlockGasLimit::get().min(u64::MAX.into()).low_u64().saturating_div(cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64); pub PrecompilesValue: OpenZeppelinPrecompiles = OpenZeppelinPrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); @@ -598,6 +618,7 @@ impl pallet_evm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_evm::WeightInfo; type WeightPerGas = WeightPerGas; type WithdrawOrigin = EnsureAccountId20; diff --git a/evm-template/runtime/src/configs/xcm_config.rs b/evm-template/runtime/src/configs/xcm_config.rs index 98f962b..ffba733 100644 --- a/evm-template/runtime/src/configs/xcm_config.rs +++ b/evm-template/runtime/src/configs/xcm_config.rs @@ -203,6 +203,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = PolkadotXcm; type Barrier = Barrier; type CallDispatcher = RuntimeCall; + /// When changing this config, keep in mind, that you should collect fees. type FeeManager = XcmFeeManagerFromComponents< IsChildSystemParachain, XcmFeeToAccount, @@ -210,6 +211,9 @@ impl xcm_executor::Config for XcmConfig { type HrmpChannelAcceptedHandler = (); type HrmpChannelClosingHandler = (); type HrmpNewChannelOpenRequestHandler = (); + /// Please, keep these two configs (`IsReserve` and `IsTeleporter`) mutually exclusive. + /// The IsReserve type must be set to specify which pair we trust to deposit reserve assets on our chain. We can also use the unit type () to block ReserveAssetDeposited instructions. + /// The IsTeleporter type must be set to specify which pair we trust to teleport assets to our chain. We can also use the unit type () to block ReceiveTeleportedAssets instruction. type IsReserve = NativeAsset; type IsTeleporter = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; @@ -289,6 +293,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type UniversalLocation = UniversalLocation; type Weigher = FixedWeightBounds; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_xcm::WeightInfo; type XcmExecuteFilter = Nothing; // ^ Disable dispatchable execute on the XCM pallet. diff --git a/evm-template/runtime/src/constants.rs b/evm-template/runtime/src/constants.rs index 5af45a4..e5e9c1b 100644 --- a/evm-template/runtime/src/constants.rs +++ b/evm-template/runtime/src/constants.rs @@ -13,6 +13,11 @@ pub mod currency { pub const DOLLARS: Balance = 100 * CENTS; pub const GRAND: Balance = 1_000 * DOLLARS; + /// NB: Notice, that existential deposit was set to 0 intentionally to increase compatibility with EVM. + /// Hovewer, it leads to some risks, most importantly state bloating. + /// We acknowledge that there is such a risk and we have an opened issue to resolve it: + /// https://github.com/OpenZeppelin/polkadot-runtime-templates/issues/195 + /// If you read this message please check out this issue to see if it is resolved and what can you do to implement the fix. #[cfg(not(feature = "runtime-benchmarks"))] pub const EXISTENTIAL_DEPOSIT: Balance = 0; diff --git a/generic-template/runtime/src/configs/governance/mod.rs b/generic-template/runtime/src/configs/governance/mod.rs index a81459a..85712be 100644 --- a/generic-template/runtime/src/configs/governance/mod.rs +++ b/generic-template/runtime/src/configs/governance/mod.rs @@ -32,6 +32,7 @@ impl pallet_conviction_voting::Config for Runtime { type Polls = Referenda; type RuntimeEvent = RuntimeEvent; type VoteLockingPeriod = VoteLockingPeriod; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_conviction_voting::WeightInfo; } @@ -47,6 +48,7 @@ impl pallet_whitelist::Config for Runtime { type Preimages = Preimage; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_whitelist::WeightInfo; type WhitelistOrigin = EnsureRoot; } @@ -74,5 +76,6 @@ impl pallet_referenda::Config for Runtime { type Tracks = tracks::TracksInfo; type UndecidingTimeout = UndecidingTimeout; type Votes = pallet_conviction_voting::VotesOf; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_referenda::WeightInfo; } diff --git a/generic-template/runtime/src/configs/mod.rs b/generic-template/runtime/src/configs/mod.rs index b887cbc..351a220 100644 --- a/generic-template/runtime/src/configs/mod.rs +++ b/generic-template/runtime/src/configs/mod.rs @@ -171,6 +171,7 @@ impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type ScheduleOrigin = EnsureRoot; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_scheduler::WeightInfo; } @@ -194,6 +195,7 @@ impl pallet_preimage::Config for Runtime { type Currency = Balances; type ManagerOrigin = EnsureRoot; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_preimage::WeightInfo; } @@ -205,6 +207,7 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_timestamp::WeightInfo; } @@ -279,6 +282,7 @@ impl pallet_proxy::Config for Runtime { type ProxyType = ProxyType; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_proxy::WeightInfo; } @@ -304,6 +308,7 @@ impl pallet_balances::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type RuntimeHoldReason = RuntimeHoldReason; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_balances::WeightInfo; } @@ -337,6 +342,7 @@ impl pallet_assets::Config for Runtime { type RemoveItemsLimit = RemoveItemsLimit; type RuntimeEvent = RuntimeEvent; type StringLimit = StringLimit; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_assets::WeightInfo; } @@ -347,6 +353,10 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { + /// There are two possible mechanisms available: slow and fast adjusting. + /// With slow adjusting fees stay almost constant in short periods of time, changing only in long term. + /// It may lead to long inclusion times during spikes, therefore tipping is enabled. + /// With fast adjusting fees change rapidly, but fixed for all users at each block (no tipping) type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; type LengthToFee = ConstantMultiplier; type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; @@ -358,6 +368,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_sudo::WeightInfo; } @@ -380,6 +391,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedXcmpWeight = ReservedXcmpWeight; type RuntimeEvent = RuntimeEvent; type SelfParaId = parachain_info::Pallet; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo; type XcmpMessageHandler = XcmpQueue; } @@ -412,6 +424,7 @@ impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ServiceWeight = MessageQueueServiceWeight; type Size = u32; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_message_queue::WeightInfo; } @@ -430,9 +443,11 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type MaxInboundSuspended = MaxInboundSuspended; + /// Ensure that this value is not set to null (or NoPriceForMessageDelivery) to prevent spamming type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; type RuntimeEvent = RuntimeEvent; type VersionWrapper = (); + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; @@ -453,6 +468,7 @@ impl pallet_multisig::Config for Runtime { type MaxSignatories = MaxSignatories; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_multisig::WeightInfo; } @@ -476,6 +492,7 @@ impl pallet_session::Config for Runtime { type ValidatorId = ::AccountId; // we don't have stash and controller, thus we don't need the convert as well. type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_session::WeightInfo; } @@ -522,6 +539,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_collator_selection::WeightInfo; } @@ -529,6 +547,7 @@ impl pallet_utility::Config for Runtime { type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_utility::WeightInfo; } @@ -583,5 +602,6 @@ impl pallet_treasury::Config for Runtime { type SpendFunds = (); type SpendOrigin = TreasurySpender; type SpendPeriod = SpendPeriod; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_treasury::WeightInfo; } diff --git a/generic-template/runtime/src/configs/xcm_config.rs b/generic-template/runtime/src/configs/xcm_config.rs index 775904d..7abffad 100644 --- a/generic-template/runtime/src/configs/xcm_config.rs +++ b/generic-template/runtime/src/configs/xcm_config.rs @@ -156,6 +156,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTrap = PolkadotXcm; type Barrier = Barrier; type CallDispatcher = RuntimeCall; + /// When changing this config, keep in mind, that you should collect fees. type FeeManager = XcmFeeManagerFromComponents< IsChildSystemParachain, XcmFeeToAccount, @@ -163,6 +164,7 @@ impl xcm_executor::Config for XcmConfig { type HrmpChannelAcceptedHandler = (); type HrmpChannelClosingHandler = (); type HrmpNewChannelOpenRequestHandler = (); + /// Please, keep these two configs (`IsReserve` and `IsTeleporter`) mutually exclusive type IsReserve = NativeAsset; type IsTeleporter = (); type MaxAssetsIntoHolding = MaxAssetsIntoHolding; @@ -217,6 +219,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type UniversalLocation = UniversalLocation; type Weigher = FixedWeightBounds; + /// Rerun benchmarks if you are making changes to runtime configuration. type WeightInfo = weights::pallet_xcm::WeightInfo; type XcmExecuteFilter = Nothing; // ^ Disable dispatchable execute on the XCM pallet.