Skip to content

Add possibility of executing or mocking additional inherents in xcm-emulator#8809

Merged
bkchr merged 8 commits into
paritytech:masterfrom
girazoki:girazoki-add-possibility-of-executing-or-mocking-additional-inherents
Jun 23, 2025
Merged

Add possibility of executing or mocking additional inherents in xcm-emulator#8809
bkchr merged 8 commits into
paritytech:masterfrom
girazoki:girazoki-add-possibility-of-executing-or-mocking-additional-inherents

Conversation

@girazoki
Copy link
Copy Markdown
Contributor

@girazoki girazoki commented Jun 10, 2025

With the addition of #8083 there is no possibility right now of making the xcm-executor work with custom inherents. Custom inherents are usually driven by killing a storage item of the form wasInherentSet on_initialize and asserting that such inherent was set on_finalize. Before the xcm-emulator worked as these hooks were running just for the ParachainSystem pallet, but now, they run for all pallets.

My proposal is to add an item to the xcm-emulator parachain configuration of the form AdditionalInherentCode, which simply executes code that returns a DispatchResult. Whether users want to mock a storage item or run the inherent is up to them, this hook would allow them to do both.

This item is optional, meaning that if it is non-set then it would do nothing

@girazoki girazoki changed the title Add possibility of executing or mocking additional inherents Add possibility of executing or mocking additional inherents in xcm-emulator Jun 10, 2025
@girazoki
Copy link
Copy Markdown
Contributor Author

@bkontur what do you think about this?

@bkchr bkchr requested a review from bkontur June 15, 2025 21:43
@bkontur
Copy link
Copy Markdown
Contributor

bkontur commented Jun 18, 2025

@bkontur what do you think about this?

Actually, I was thinking about the same (or a similar) solution - to place the actual inherents behind a trait or callback (with a default implementation for set_validation_data) - when I was adding/refactoring set_validation_data.dispatch and timestamp_set.dispatch to support AllPalletsWithoutSystem::on_finalize.

However, I didn’t want to introduce a major breaking change at that time, and I also wasn’t sure whether the callback would require any parameters. For example, we actually need para_id, relay_block_number, and parent_head_data for set_validation_data.

@girazoki How do you plan to use fn execute_additional_inherents()? Do you have an example? You don’t need any inputs?

@girazoki
Copy link
Copy Markdown
Contributor Author

girazoki commented Jun 18, 2025

set_validation_data

In our case, we are simply thinking about "mocking" the appropriate storage items on the pallets to make them think inherents have passed correctly, so we would not need any parameters. but it is true that if one would be willing to add the inherent call, then we might require some of the parameters.

We can add some parameters, like those we add for set_validation_data, and re-iterate if someone needs some more additional info. how does that sound?

@girazoki
Copy link
Copy Markdown
Contributor Author

set_validation_data

In our case, we are simply thinking about "mocking" the appropriate storage items on the pallets to make them think inherents have passed correctly, so we would not need any parameters. but it is true that if one would be willing to add the inherent call, then we might require some of the parameters.

We can add some parameters, like those we add for set_validation_data, and re-iterate if someone needs some more additional info. how does that sound?

However one thing I just realized is that all that information should already be available in the cumulus parachainSystem pallet for anyone to use it after the set_validation_data inherent runs. so people can read them from there too, eliminating the need of parameters like timestamp, block number or headData

Comment thread cumulus/xcm/xcm-emulator/src/lib.rs Outdated
@bkontur
Copy link
Copy Markdown
Contributor

bkontur commented Jun 18, 2025

In our case, we are simply thinking about "mocking" the appropriate storage items on the pallets to make them think inherents have passed correctly, so we would not need any parameters.

It seems like a bit of a hack or workaround, and I don't see any parallel with the existing pallet flow (on_initialize / on_finalize), but for testing purposes, it's probably fine. I think we could potentially handle inherents here the same way a real node/client does — by using the ProvideInherent trait and supplying inherent providers, instead of hard-coded calls like set_validation_data.dispatch, timestamp_set.dispatch, or AdditionalInherentCode::on_new_block. But that might be unnecessary complexity without much added value.

If you only need to trigger this once when the chain starts, you can use this on_init:
https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs#L41-L47

But if you really need it on every block, then I'd say let's stick with AdditionalInherentCode::on_new_block without params and see.

@bkontur bkontur added the T10-tests This PR/Issue is related to tests. label Jun 19, 2025
@bkontur
Copy link
Copy Markdown
Contributor

bkontur commented Jun 19, 2025

/cmd prdoc --audience runtime_dev

Comment thread prdoc/pr_8809.prdoc Outdated
Comment thread prdoc/pr_8809.prdoc Outdated
@bkchr bkchr enabled auto-merge June 23, 2025 10:39
@bkchr bkchr added this pull request to the merge queue Jun 23, 2025
Merged via the queue into paritytech:master with commit 3288aa3 Jun 23, 2025
243 of 244 checks passed
dimartiro pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Jun 26, 2025
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
dimartiro pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Jul 2, 2025
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
tmpolaczyk pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Sep 17, 2025
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
tmpolaczyk pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Sep 17, 2025
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
tmpolaczyk pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Sep 18, 2025
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
…mulator (#8809)

With the addition of
#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
tmpolaczyk pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Jan 15, 2026
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
tmpolaczyk pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request Jan 15, 2026
…mulator (paritytech#8809)

With the addition of
paritytech#8083 there is no
possibility right now of making the xcm-executor work with custom
inherents. Custom inherents are usually driven by killing a storage item
of the form `wasInherentSet` `on_initialize` and asserting that such
inherent was set `on_finalize`. Before the xcm-emulator worked as these
hooks were running just for the ParachainSystem pallet, but now, they
run for all pallets.

My proposal is to add an item to the xcm-emulator parachain
configuration of the form `AdditionalInherentCode`, which simply
executes code that returns a `DispatchResult`. Whether users want to
mock a storage item or run the inherent is up to them, this hook would
allow them to do both.

This item is optional, meaning that if it is non-set then it would do
nothing

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T10-tests This PR/Issue is related to tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants