Skip to content

Permissionless Authorized Dispatch for pallet-whitelist#12452

Open
PSYKYODAI wants to merge 9 commits into
paritytech:masterfrom
PSYKYODAI:PWD2
Open

Permissionless Authorized Dispatch for pallet-whitelist#12452
PSYKYODAI wants to merge 9 commits into
paritytech:masterfrom
PSYKYODAI:PWD2

Conversation

@PSYKYODAI

@PSYKYODAI PSYKYODAI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

closes #12224

Adds #[pallet::authorize] callbacks to dispatch_whitelisted_call and dispatch_whitelisted_call_with_preimage: an unsigned submission is admitted at the pool only if DispatchWhitelistedOrigin::try_origin(Authorized) passes and the call hash is in WhitelistedCall.

Adds frame_system::EnsureAuthorized for runtimes to opt in:

type DispatchWhitelistedOrigin =
    EitherOf<EnsureRoot<AccountId>, frame_system::EnsureAuthorized<AccountId>>;

@PSYKYODAI
PSYKYODAI marked this pull request as ready for review July 3, 2026 00:33
@PSYKYODAI
PSYKYODAI requested a review from a team as a code owner July 3, 2026 00:33
@muharem

muharem commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@PSYKYODAI marge master please. there is some major changes merged to the pallet #11336

@PSYKYODAI

Copy link
Copy Markdown
Contributor Author

/cmd label T2-pallets

@paritytech-cmd-bot-polkadot-sdk paritytech-cmd-bot-polkadot-sdk Bot added the T2-pallets This PR/Issue is related to a particular pallet. label Jul 16, 2026
@PSYKYODAI

Copy link
Copy Markdown
Contributor Author

Master has been merged @muharem

Comment thread substrate/frame/whitelist/src/lib.rs Outdated
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Comment thread substrate/frame/whitelist/src/lib.rs Outdated
}

#[pallet::authorize(Self::authorize_dispatch_whitelisted_call)]
#[pallet::weight_of_authorize(T::DbWeight::get().reads(1))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this hard-coded weights, should have proper benchmarking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both callbacks now use benchmarked weights (authorize_dispatch_whitelisted_call and authorize_dispatch_whitelisted_call_with_preimage(n)), measured via the Authorize trait as in pallet-im-online.

_call_encoded_len: &u32,
_call_weight_witness: &Weight,
) -> TransactionValidityWithRefund {
Self::authorize_whitelisted_dispatch(*call_hash)

@bkontur bkontur Jul 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we go this branch (expected Call is stored T::Preimages), shouldn't we also check T::Preimages::fetch(&call_hash, Some(call_encoded_len)) here? (Maybe just T::Preimages::len or something efficient)

Just thinking, if we whitelist_call_hash and expecting authorize_dispatch_whitelisted_call_with_preimage, then we basically allow anybody/unsigned to spam the chain for free with dispatch_whitelisted_call -> because it will pass unsigned/Authorized validation, but the extrinsic itself will fail on UnavailablePreImage and nobody will be charged for failed ones.

Also relates to my previous comment about hard-coded weight_of_authorize

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authorize_dispatch_whitelisted_call now rejects at the pool unless T::Preimages::len(call_hash) == Some(call_encoded_len), so a missing preimage or wrong length witness can't be relayed for free. Used len over fetch to keep it to one read.

The call_weight_witness can't be checked without decoding, so it stays in the dispatch body. The inline with_preimage variant already derives the hash from the call, so it's unaffected. New test coverage in authorize_dispatch_whitelisted_call_uses_hash_argument.

@PSYKYODAI

Copy link
Copy Markdown
Contributor Author

/cmd bench --pallet pallet_whitelist

@github-actions

Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_whitelist" has started 🚀 See logs here

@github-actions

Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_whitelist" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_staking_async.rs rc_on_session_report 1.56ms 26.56ms +1598.47
substrate/frame/staking-async/src/weights.rs rc_on_session_report 2.06ms 30.21ms +1365.91
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs rc_on_session_report 2.49ms 33.53ms +1244.72
cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_ethereum_client.rs force_checkpoint 106.67ms 634.97ms +495.28
cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/snowbridge_pallet_ethereum_client.rs submit_with_sync_committee 133.77ms 656.44ms +390.72
substrate/frame/revive/src/weights.rs extcodecopy 106.82us 214.76us +101.05
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs extcodecopy 110.23us 211.29us +91.69
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs dispatch_whitelisted_call_with_preimage 286.04us 502.88us +75.81
substrate/frame/whitelist/src/weights.rs dispatch_whitelisted_call_with_preimage 304.83us 447.78us +46.89
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs dispatch_whitelisted_call_with_preimage 313.67us 448.80us +43.08
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs dispatch_whitelisted_call_with_preimage 317.60us 448.37us +41.18
substrate/frame/revive/src/weights.rs seal_return_data_size 293.00ns 389.00ns +32.76
substrate/frame/revive/src/weights.rs seal_call_data_copy 119.66us 157.67us +31.77
substrate/frame/revive/src/weights.rs identity 119.27us 157.08us +31.70
substrate/frame/revive/src/weights.rs seal_value_transferred 301.00ns 396.00ns +31.56
substrate/frame/revive/src/weights.rs seal_call_data_load 306.00ns 399.00ns +30.39
substrate/frame/revive/src/weights.rs seal_block_number 309.00ns 396.00ns +28.16
substrate/frame/revive/src/weights.rs seal_now 304.00ns 388.00ns +27.63
substrate/frame/revive/src/weights.rs seal_address 349.00ns 445.00ns +27.51
substrate/frame/revive/src/weights.rs seal_call_data_size 300.00ns 381.00ns +27.00
substrate/frame/revive/src/weights.rs seal_origin 357.00ns 445.00ns +24.65
substrate/frame/revive/src/weights.rs seal_caller 374.00ns 463.00ns +23.80
substrate/frame/revive/src/weights.rs seal_gas_limit 324.00ns 398.00ns +22.84
substrate/frame/revive/src/weights.rs seal_copy_to_contract 213.39us 251.17us +17.70
substrate/frame/revive/src/weights.rs seal_return 26.72us 31.38us +17.43
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_call_data_size 428.00ns 501.00ns +17.06
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs dispatch_whitelisted_call 7.87ms 9.14ms +16.23
substrate/frame/staking-async/src/weights.rs prune_era_single_entry_cleanups 573.00us 666.00us +16.23
substrate/frame/revive/src/weights.rs instr 818.30us 950.34us +16.14
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs prune_era_single_entry_cleanups 594.56us 687.95us +15.71
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_asset_conversion.rs add_liquidity 1.09ms 1.26ms +15.43
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_call_data_load 454.00ns 520.00ns +14.54
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs instr 817.97us 931.70us +13.90
substrate/frame/revive/src/weights.rs seal_gas_price 1.14us 1.28us +12.50
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs set_staking_configs_all_remove 805.24us 905.74us +12.48
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs set_staking_configs_all_set 805.78us 906.19us +12.46
substrate/frame/revive/src/weights.rs weight_left 1.36us 1.53us +12.35
substrate/frame/revive/src/weights.rs caller_is_root 1.31us 1.47us +12.11
substrate/frame/revive/src/weights.rs seal_ref_time_left 2.04us 2.28us +11.98
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs remove_whitelisted_call 269.44us 297.91us +10.57
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_gas_price 1.43us 1.57us +9.95
substrate/frame/revive/src/weights.rs caller_is_origin 1.42us 1.55us +9.68
substrate/frame/revive/src/weights.rs seal_base_fee 1.14us 1.25us +9.56
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_base_fee 1.45us 1.59us +9.29
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_now 444.00ns 484.00ns +9.01
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs whitelist_call 271.80us 295.85us +8.85
substrate/frame/revive/src/weights.rs own_code_hash 3.65us 3.94us +8.01
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_return_data_size 448.00ns 482.00ns +7.59
substrate/frame/revive/src/weights.rs seal_deposit_event 91.63us 98.55us +7.56
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_gas_limit 464.00ns 498.00ns +7.33
substrate/frame/revive/src/weights.rs seal_contains_transient_storage 3.75us 4.02us +7.16
substrate/frame/revive/src/weights.rs seal_balance 4.58us 4.90us +6.94
substrate/frame/revive/src/weights.rs minimum_balance 1.62us 1.73us +6.79
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_block_number 457.00ns 488.00ns +6.78
substrate/frame/revive/src/weights.rs seal_sr25519_verify 5.02ms 5.29ms +5.52
substrate/frame/revive/src/weights.rs seal_get_transient_storage 2.45us 2.58us +5.35
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs rebond 1.20ms 1.13ms -5.09
substrate/frame/staking-async/src/weights.rs force_no_eras 116.00us 110.00us -5.17
substrate/frame/staking-async/src/weights.rs chill_other 1.06ms 1.00ms -5.57
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs get_transient_storage_full 2.16us 2.04us -5.64
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs withdraw_unbonded_kill 1.97ms 1.85ms -5.80
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs reap_stash 1.90ms 1.78ms -6.27
substrate/frame/revive/src/weights.rs rollback_transient_storage 1.42us 1.33us -6.68
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs force_new_era_always 115.23us 106.55us -7.54
substrate/frame/staking-async/src/weights.rs force_new_era 119.00us 110.00us -7.56
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs force_no_eras 115.30us 106.57us -7.57
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs force_new_era 115.34us 106.60us -7.57
substrate/frame/staking-async/src/weights.rs apply_slash 342.78ms 316.68ms -7.62
substrate/frame/staking-async/src/weights.rs rebond 1.07ms 988.16us -7.67
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs process_offence_queue 756.81us 694.89us -8.18
substrate/frame/staking-async/src/weights.rs force_new_era_always 120.00us 110.00us -8.33
substrate/frame/staking-async/src/weights.rs payout_stakers_alive_staked 301.88ms 274.95ms -8.92
substrate/frame/staking-async/src/weights.rs force_apply_min_commission 210.00us 189.00us -10.00
substrate/frame/staking-async/src/weights.rs prune_era_stakers_paged 586.74us 518.96us -11.55
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs withdraw_unbonded_update 612.52us 540.04us -11.83
substrate/frame/staking-async/src/weights.rs prune_era_validator_prefs 497.53us 391.40us -21.33
substrate/frame/staking-async/src/weights.rs prune_era_stakers_overview 510.28us 390.77us -23.42
substrate/frame/staking-async/src/weights.rs prune_era_validator_incentive_weight 522.97us 393.11us -24.83
substrate/frame/staking-async/src/weights.rs prune_era_claimed_rewards 530.77us 390.85us -26.36
substrate/frame/staking-async/src/weights.rs cancel_deferred_slash 3.48ms 2.49ms -28.49
substrate/frame/staking-async/src/weights.rs prune_era_validator_slash_in_era 393.25us 265.73us -32.43
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_asset_conversion.rs get_reserves 116.00us 71.63us -38.25
substrate/frame/whitelist/src/weights.rs dispatch_whitelisted_call 98.45ms 7.04ms -92.85
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs dispatch_whitelisted_call 99.84ms 5.17ms -94.82
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs dispatch_whitelisted_call 130.47ms 4.74ms -96.37
substrate/frame/whitelist/src/weights.rs remove_deferred_dispatch 139.28us Added
substrate/frame/whitelist/src/weights.rs defer_dispatch 178.09us Added
substrate/frame/whitelist/src/weights.rs authorize_dispatch_whitelisted_call_with_preimage 43.00us Added
substrate/frame/whitelist/src/weights.rs authorize_dispatch_whitelisted_call 85.00us Added
substrate/frame/staking-async/src/weights.rs chill_inactive 5.90ms Added
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs remove_deferred_dispatch 140.00us Added
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs defer_dispatch 134.00us Added
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call_with_preimage 43.00us Added
substrate/frame/staking-async/runtimes/rc/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call 85.00us Added
substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_whitelist.rs remove_deferred_dispatch 156.41us Added
substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_whitelist.rs defer_dispatch 156.41us Added
substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call_with_preimage 43.00us Added
substrate/frame/staking-async/runtimes/parachain/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call 85.00us Added
substrate/frame/revive/src/weights.rs take_storage_hot 7.38us Added
substrate/frame/revive/src/weights.rs seal_set_storage_hot 5.11us Added
substrate/frame/revive/src/weights.rs seal_get_storage_hot 4.15us Added
substrate/frame/revive/src/weights.rs overlay_probe_full 207.92ms Added
substrate/frame/revive/src/weights.rs overlay_probe_empty 1.84ms Added
substrate/frame/revive/src/weights.rs contains_storage_hot 5.62us Added
substrate/frame/revive/src/weights.rs clear_storage_hot 6.71us Added
substrate/frame/revive/src/weights.rs access_list_touch_hot_single_element 697.00ns Added
substrate/frame/revive/src/weights.rs access_list_touch_hot_full 1.19us Added
substrate/frame/revive/src/weights.rs access_list_touch_cold_full 4.29us Added
substrate/frame/revive/src/weights.rs access_list_touch_cold_empty 584.00ns Added
substrate/frame/revive/src/weights.rs access_list_rollback_amortization 4.68us Added
substrate/frame/multi-asset-bounties/src/weights.rs increase_value 305.18us Added
substrate/frame/asset-conversion/src/weights.rs set_pool_fee 142.73us Added
substrate/frame/asset-conversion/src/weights.rs create_pool_with_fee 933.93us Added
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs remove_deferred_dispatch 139.00us Added
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs defer_dispatch 134.00us Added
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call_with_preimage 43.00us Added
polkadot/runtime/rococo/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call 85.00us Added
polkadot/runtime/parachains/src/dmp/weights.rs migrate_v0_to_v1_step_msg 198.00us Added
polkadot/runtime/parachains/src/dmp/weights.rs migrate_v0_to_v1_step_iter 846.00us Added
polkadot/runtime/parachains/src/dmp/weights.rs migrate_v0_to_v1_step_base 28.00us Added
polkadot/runtime/parachains/src/dmp/weights.rs lazy_delete_some 460.00us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs remove_deferred_dispatch 190.92us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs defer_dispatch 230.41us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call_with_preimage 43.00us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_whitelist.rs authorize_dispatch_whitelisted_call 85.00us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_staking_async.rs chill_inactive 11.16ms Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs take_storage_hot 8.70us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_set_storage_hot 6.08us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs seal_get_storage_hot 4.81us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs overlay_probe_full 207.91ms Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs overlay_probe_empty 1.78ms Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs contains_storage_hot 6.72us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs clear_storage_hot 8.38us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs access_list_touch_hot_single_element 670.00ns Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs access_list_touch_hot_full 1.18us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs access_list_touch_cold_full 4.32us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs access_list_touch_cold_empty 556.00ns Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_revive.rs access_list_rollback_amortization 4.66us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_asset_conversion.rs set_pool_fee 145.50us Added
cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_asset_conversion.rs create_pool_with_fee 759.32us Added
Command output:

❌ Failed benchmarks of runtimes/pallets:
-- dev: ['pallet_whitelist']
-- asset-hub-westend: ['pallet_whitelist']

@PSYKYODAI

Copy link
Copy Markdown
Contributor Author

/cmd fmt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T2-pallets This PR/Issue is related to a particular pallet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Permissionless Authorized Dispatch for pallet-whitelist

3 participants