[FRAME] Simplify pallet config definition: remove RuntimeEvent associated type#7229
Conversation
RuntimeEvent as an associated type boundRuntimeEvent associated type
|
@bkchr bunch of CI is failing because they treat the |
gui1117
left a comment
There was a problem hiding this comment.
Looks good to me, after the suggestion, and also a few comments
| /// | ||
| /// ```rs | ||
| /// pub trait Config: frame_system::Config { | ||
| /// ``` |
There was a problem hiding this comment.
As a note personally I would always bound the supertrait: frame_system::Config<RuntimeEvent: From<Event>>, always, except if there is the flag is_frame_system.
If user wants to write it, he can do, then it will still compile fine.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7cfad8342293e593a0c8041cd4b5a958
But this is also ok.
There was a problem hiding this comment.
thanks for this tip, really helpful)
|
@bkchr I replaced with proc macro warning but now I have to put the #[frame_support::pallet]
#[allow(deprecated)]
pub mod pallet {but this way it would take a big span and we could ignore other deprecation warnings as well. Putting |
You need to detect the |
…o feat/runtime-event-associated-type-bound
85171bc to
cf1d716
Compare
Yeah and that is was this feature brings you! You can also extend and add more bounds. Most of the time |
Why will this not work? EVERY pallet needs to have the |
Okay so I didn't fully understand how this was meant to be implemented for
Yeah, I was wrong about this, sorry, it works now! |
yeah, it is more about automatically adding common |
…ciated type (paritytech#7229) part of paritytech#3743 ## Motivation This PR removes the need for defining `RuntimeEvent` in the `Config` trait of a pallet. It uses associated type bound feature under the hood to make sure that `Event` of the pallet is convertible to the aggregated runtime event type `frame_system::RuntimeEvent`. This is an initial PR for `RuntimeEvent` type and will be followed with other types, e.g `RuntimeCall`. As a demo, example pallets' config definition is updated to use this feature. With this change, we can do this (and have support for events): ```rs #[pallet::config] pub trait Config: frame_system::Config { } ``` instead of this: ```rs #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; } ``` The latter will emit deprecation warnings and is redundant. polkadot address: 16FqwPZ8GRC5U5D4Fu7W33nA55ZXzXGWHwmbnE1eT6pxuqcT --------- Co-authored-by: Bastian Köcher <git@kchr.de>
…ciated type (#7229) part of #3743 ## Motivation This PR removes the need for defining `RuntimeEvent` in the `Config` trait of a pallet. It uses associated type bound feature under the hood to make sure that `Event` of the pallet is convertible to the aggregated runtime event type `frame_system::RuntimeEvent`. This is an initial PR for `RuntimeEvent` type and will be followed with other types, e.g `RuntimeCall`. As a demo, example pallets' config definition is updated to use this feature. With this change, we can do this (and have support for events): ```rs #[pallet::config] pub trait Config: frame_system::Config { } ``` instead of this: ```rs #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; } ``` The latter will emit deprecation warnings and is redundant. polkadot address: 16FqwPZ8GRC5U5D4Fu7W33nA55ZXzXGWHwmbnE1eT6pxuqcT --------- Co-authored-by: Bastian Köcher <git@kchr.de>
Upgrade polkadot v1.19.1 (nodes/rust/duniter-v2s!341) * regenerate metadata * update srtool * fix ci * upgrade doc-gen * fix clippy * update subxt * regenerate metadata * regenerate weights * fix benchmarks * fix deprecation from paritytech/polkadot-sdk#7229 * fix binding modifier not allowed under ref * upgrade SDK and Rust
Polkadot SDK changes: paritytech/polkadot-sdk#7229
* chore: ⬆️ upgrade dependencies to 2506 * refactor: 🚨 use workspace dependencies in pallet crowdloan rewards * chore: 📌 depend on crates.io ethereum (similarly to frontier) * fix: 🐛 remove PassByCodec PassByCodec was replaced by PassFatPointerAndDecode in paritytech/polkadot-sdk@1cb22ca * fix: 🐛 use Weight::MAX instead of Weight::max_value() * fix: 🐛 add TrieCacheContext parameter to state_at * fix: 🐛 add missing relay_parent_descendants and collator_peer_id fields to ParachainInherentData * fix: 🐛 remove deprecated AssetHubMigrationStarted config * fix: 🐛 update ExecuteXcm::prepare() to accept weight_limit parameter * fix: 🐛 add generic parameters to Sha3FIPS256<Runtime, ()> * fix: 🐛 add metrics field to BuildNetworkParams * chore: 📌 upgrade pins * fix: 🐛 add OnNewHead to bridge parachain configs This adds the required OnNewHead configuration parameter introduced in paritytech/polkadot-sdk#8531 * fix: 🐛 add relay chain slot duration to FixedVelocityConsensusHook * fix: 🐛 add SlotDuration trait items Upstream PR: Moonsong-Labs/moonkit#83 - "Use PostInherents to validate timestamp" - Author: Rodrigo Quelhas (RomarQ) - Merged: September 30, 2025 Details: This trait item is used in the PostInherents validation to ensure that the configured block time in the node and runtime is compatible with Nimbus's consensus mechanism. The value is set to MILLISECS_PER_BLOCK (12000ms for Moonbeam), matching the parachain's block production time. This change prepares for Polkadot SDK updates that deprecated the CheckInherents parameter in favor of PostInherents validation. * fix: 🐛 add RelayParentOffset trait item Upstream PR: paritytech/polkadot-sdk#8299 - "Allow building on older relay parents" - Author: Sebastian Kunert (skunert) - Merged: May 29, 2025 Details: With an offset of 0, blocks are built on the current relay chain tip. Non-zero values allow building on older relay parents (e.g., offset of 2 means building 2 blocks behind the tip) to avoid building on short-lived relay chain forks. The runtime enforces this offset by requiring multiple relay parent descendants to be present in the set_validation_data inherent. * fix: 🐛 refactor build_relay_chain_interface to return only required tuple elements * fix: 🐛 fixed RuntimeOrigin trait bounds by removing From<Option<AccountId>> bound Fixed RuntimeOrigin trait bounds - Removed From<Option<AccountId>> bound and updated all precompiles to use frame_system::RawOrigin::Signed().into() * fix: 🐛 update cumulus_pallet_xcmp_queue WeightInfo methods * fix: 🐛 fix AccountId ambiguity Added proper type qualifications and EncodeLike trait bound in crowdloan-rewards precompile * fix: 🐛 use QueueFootprintQuery trait for message queue footprint method paritytech/polkadot-sdk#8021 * fix: 🐛 remove deprecated RuntimeEvent * fix: 🐛 update the runtime interface to use explicit marshalling strategies PR #7375 - Host/Runtime Interface Refactoring 🔗 paritytech/polkadot-sdk#7375 * fix: 🐛 do not enable SharedTrieCache * fix: 🐛 implement BenchmarkHelper * fix: 🐛 remove PalletTransactionPaymentBenchmark * fix: 🐛 add missing crate in Cargo feature * fix: 🐛 remove RuntimeEvent associated type Polkadot SDK changes: paritytech/polkadot-sdk#7229 * fix: 🐛 remove unused imports * fix: 🐛 remove RuntimeEvent associated type * fix: 🐛 remove AssetHubMigrationStarted associated type * fix: 🐛 add RelayParentOffset associated type * fix: 🐛 add metrics_registry: None to database configuration * fix: 🐛 add warm_up_trie_cache: None to service configuration * fix: 🐛 fix reference to deprecated RuntimeEvent associated type * fix: 🐛 update WeightBounds trait API * fix: 🐛 add missing fields to ParachainInherentData * fix: 🐛 add missing associated types to Runtime * fix: 🐛 replace `Fail(Option<T::Hash>, XcmError)` with `Fail(Option<T::Hash>, InstructionError)` * style: 🎨 format code * fix: 🐛 fix `XcmExecutor::prepare` args * fix: 🐛 impl create_bare from CreateInherent trait * fix: 🐛 mock BenchmarkHelper * fix: ⬆️ upgrade frame-metadata * chore: ⬆️ upgrade polkadot-sdk * fix: 🐛 silence warning * style: 🚨 mark args as unused * fix: 🐛 fix deprecation warning * style: 🎨 format code * test: 🐛 update snapshot * chore: 📌 update pins * refactor: ♻️ move lint directive to root Cargo.toml * chore: ⚡ run benchmarks * chore: ⚡ run benchmarks * test: ✅ assert specific error type * test: ✅ use proper assert_noop! * test: ✅ use new extrinsic for asset transfers using explicit XCM transfer types paritytech/polkadot-sdk#3695 * fix: 🐛 pin udeps Rust nightly version * Revert "fix: 🐛 pin udeps Rust nightly version" This reverts commit 09e6d03. * fix: 🐛 fix some Cargo.toml features * revert: 🔥 remove AssetHubMigrationStarted storage flag * refactor: 🔥 remove unused import * fix: 🐛 add missing feature flags for pallet-assets dependency * refactor: 🚨 remove duplicated feature flags * revert: 🔥 delete file committed by mistake * fix: 📌 properly pin polkadot-sdk version * test: ✅ initialize ParachainSystem HostConfiguration in runtime tests The ParentAsUmp XCM router now validates upward messages by checking HostConfiguration, which was previously uninitialized in test environments, causing ErrorValidating and SendFailure errors. * update polkadot-sdk pin * update polkadot-sdk pin * fix unit tests * update polkadot-sdk pin * fix check-unused-dependencies * fix test * refactor: ♻️ remove IdentityBenchmarkHelper * Revert "refactor: ♻️ remove IdentityBenchmarkHelper" This reverts commit b872ee4. * revert: ⏪ restore pallet_transaction_payment * test: ✅ update tests call_pallet_xcm_with_fee * refactor: ♻️ add mock_abridged_host_config function * fix pallet-identity benchmarks * fix: 🐛 add helper function to set up XCM router for benchmarks * fix: 🐛 add custom delivery helper for Moonbeam * chore: 🔧 update weights * style: 🎨 keep original name TestDeliveryHelper * fix pallet-randomness benchmarks * Revert "chore: 🔧 update weights" This reverts commit ea91959. * test: ✅ update snapshots --------- Co-authored-by: Rodrigo Quelhas <22591718+RomarQ@users.noreply.github.com> Co-authored-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Upgrade all polkadot-sdk git dependencies from branch `stable2503` to `stable2506`. Upgrade all Frontier EVM dependencies from branch `stable2503` to tag `frontier-stable2506`. Fix all compilation errors and test failures caused by upstream breaking API changes in polkadot-sdk stable2506 (134 PRs) and 9 patch releases. Upstream breaking changes addressed: - Remove local `AccountIdFor` alias, now provided by `frame_system::pallet_prelude` (paritytech/polkadot-sdk#7229) - Add `RelayParentOffset = ConstU32<0>` to parachain system config (paritytech/polkadot-sdk#8299) - Fix `Outcome` enum pattern matching: `Error` is now tuple variant wrapping `InstructionError` (paritytech/polkadot-sdk#8535) - Remove `RuntimeEvent` from `pallet_evm::Config` and `pallet_ethereum::Config` (frontier stable2506) - Add `RuntimeEvent` to `pallet_session::historical::Config` - Remove `PassByInner` import, use `.0` for `H256` inner access (paritytech/polkadot-sdk#7375) - Destructure 4 return values from `build_relay_chain_interface` (paritytech/polkadot-sdk#8072) - Add `metrics` field to `BuildNetworkParams` (paritytech/polkadot-sdk#8332) - Add `prometheus_registry` to `StartRelayChainTasksParams` (paritytech/polkadot-sdk#8332) Release: https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2506 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FRAME now auto-derives the RuntimeEvent conversion using associated type bounds on frame_system::Config when a #[pallet::event] block is present, making the explicit `type RuntimeEvent` in pallet Config traits redundant. Removed from 7 StorageHub pallets (bucket-nfts, file-system, payment-streams, proofs-dealer, providers, randomness, provider-randomness), the mock_message_queue pallet, and all corresponding mock/runtime/xcm-simulator Config implementations. Events themselves are unchanged — only the redundant associated type declaration was removed. Ref: paritytech/polkadot-sdk#7229 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerate api-augment metadata and TypeScript type definitions from fresh stable2506 runtime binaries built via cargo build --release, crossbuild:mac, and docker:build. Reflects all runtime API and pallet changes from the polkadot-sdk stable2506 upgrade including V16 metadata stabilization (paritytech/polkadot-sdk#8443) and RuntimeEvent removal from pallet Config traits (paritytech/polkadot-sdk#7229). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove unused `pallet_prelude::*` import in pallet-bucket-nfts (leftover from RuntimeEvent removal in paritytech/polkadot-sdk#7229) - Prefix unused `relay_network_service` and `relay_req_receiver` variables with underscore (new return values from build_relay_chain_interface in paritytech/polkadot-sdk#8072) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace `<T as pallet::Config>::RuntimeEvent` with `<T as frame_system::Config>::RuntimeEvent` in all benchmark files, since RuntimeEvent was removed from pallet Config traits (paritytech/polkadot-sdk#7229) - Add missing 5th argument (SharedTrieCache) to storage benchmark `cmd.run()` calls in node/src/command.rs (paritytech/polkadot-sdk#7556) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
part of #3743
Motivation
This PR removes the need for defining
RuntimeEventin theConfigtrait of a pallet. It uses associated type bound feature under the hood to make sure thatEventof the pallet is convertible to the aggregated runtime event typeframe_system::RuntimeEvent.This is an initial PR for
RuntimeEventtype and will be followed with other types, e.gRuntimeCall. As a demo, example pallets' config definition is updated to use this feature.With this change, we can do this (and have support for events):
instead of this:
The latter will emit deprecation warnings and is redundant.
polkadot address: 16FqwPZ8GRC5U5D4Fu7W33nA55ZXzXGWHwmbnE1eT6pxuqcT