feat: core 692 upgrade peaq token stream - #395
Conversation
|
The preview deployment for peaqnetwork/peaq-network-node:ci/012453_add-auto-upgrade-on-preview-environment-iswg08ckww0c4k48oggoo400 is ready. 🟢 Open Preview | Open Build Logs Last updated at: 2026-08-28 04:57:09 CET |
There was a problem hiding this comment.
Pull request overview
This PR upgrades the pallet-block-reward token distribution model from a fixed, hard-coded beneficiary split to a configurable “token sinks” list that can target either Substrate pallet pots or EVM H160 addresses (via runtime-provided address mapping). It also introduces a one-time migration path from the legacy on-chain config, updates the runtimes/chain-specs to seed the new sinks, and refreshes benchmarks/weights/tests accordingly.
Changes:
- Replace legacy reward distribution configuration with
Sinks(bounded list of{target, share}) + validation, events, and new weight functions. - Add v3 storage migration to delete legacy config and adopt runtime-provided migration sinks; update runtimes + chain-spec genesis config to use those sinks.
- Regenerate benchmarking + weights and update tests/mocks to cover sink validation, distribution behavior, and migration behavior.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| runtime/peaq/src/lib.rs | Bumps runtime spec_version, wires pallet_block_reward to new sinks config + address mapping, adds migration sinks constants. |
| runtime/peaq-dev/src/lib.rs | Same as peaq runtime: new sinks wiring, spec_version bump, alloc String return update. |
| runtime/krest/src/lib.rs | Same sinks wiring for krest, with krest-specific sink list preserving legacy split. |
| pallets/block-reward/src/lib.rs | Core refactor: replaces config storage with Sinks, adds set_sinks, validation, and sink-based distribution logic. |
| pallets/block-reward/src/types.rs | Introduces Sink, RewardTarget, SinkPalletId, compile-time distribution check helper, and address mapping trait. |
| pallets/block-reward/src/migrations.rs | Replaces old migration with v3 migration adopting runtime-provided sink list when legacy storage is detected. |
| pallets/block-reward/src/benchmarking.rs | Updates benchmarks for set_sinks and sink-based distribution. |
| pallets/block-reward/src/weights.rs | Updates autogenerated weights to new extrinsics/paths (set_sinks, distribute_imbalances). |
| pallets/block-reward/src/weightinfo.rs | Updates WeightInfo trait to match new benchmarking/weights functions. |
| pallets/block-reward/src/tests.rs | Reworks tests to validate sink rules, distribution correctness, genesis behavior, and burn fallback behavior. |
| pallets/block-reward/src/mock.rs | Updates mock runtime to support sinks + address mapping, and adds fixtures for migration tests. |
| pallets/block-reward/Cargo.toml | Adjusts dependencies for new types/tests (e.g., sp-core non-optional, adds hex-literal). |
| pallets/address-unification/src/lib.rs | Exposes convert_impl publicly so runtimes can reuse the address mapping implementation. |
| node/src/parachain/peaq_chain_spec.rs | Seeds genesis block-reward sinks using runtime-provided BlockRewardMigrationSinks. |
| node/src/parachain/krest_chain_spec.rs | Same genesis sink seeding for krest. |
| node/src/parachain/dev_chain_spec.rs | Same genesis sink seeding for dev runtime. |
| Cargo.lock | Locks new dependency (hex-literal). |
Suppressed comments (1)
pallets/block-reward/src/types.rs:51
- This public doc comment mixes German and English. Keeping public API docs in one language (English, as used elsewhere in this crate) improves clarity.
/// One token sink mit ihrem Anteil an der Gesamtausschuettung.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
No description provided.