Skip to content

[JAM parachain-service] Implement additional data support - #13022

Merged
bkchr merged 11 commits into
parchain-servicefrom
alindima/relay-proof-read-hostfn-rebased
Sep 2, 2026
Merged

[JAM parachain-service] Implement additional data support#13022
bkchr merged 11 commits into
parchain-servicefrom
alindima/relay-proof-read-hostfn-rebased

Conversation

@alindima

Copy link
Copy Markdown
Contributor

Implements paritytech/parachain-service#14

Completes the implementation started on the parchain-service branch.

V3 parachains now rely on this new data transport for the relay state proof

@paritytech-review-bot
paritytech-review-bot Bot requested a review from a team August 28, 2026 11:54

@bkchr bkchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this goes into the right direction, but I would do some conceptual changes.

  1. sp-additional-data should only expose generic/shared host functions, types and constants. E.g. only the finalize host functions and nothing around read_relay_state.
  2. cumulus-client-addtional-data should be changed to host all the relevant bits and pieces for reading the relay state.
trait RelayState {
     fn read(key: Vec<u8>) -> Option<Vec<u8>> {
              self.get_extension<RelayStateExt>()?.read(key)
     }
}

sp-addiotional-data should expose some AdditionalDataExt (this is for example used by finalize to generate the hash). This extension should just contain "pointers" to all the other extensions that also host additonal data. So, that it can later on all self.all_additional_datas.iter().map(|dp| dp.finalize()).fold_into_hash().


use sp_runtime_interface::{pass_by::PassFatPointerAndRead, runtime_interface};

#[allow(unused_imports)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Which are unused?

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.

I don't remember, there was some CI test failing because of this. But there were many of them unused. Would be a good idea to get the CI in a running state on the current state of the parchain-service branch before merging more stuff on top

Comment thread substrate/primitives/additional-data/src/lib.rs Outdated
Comment thread substrate/primitives/additional-data/src/lib.rs Outdated
@@ -0,0 +1,23 @@
[package]
name = "cumulus-client-additional-data"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect that this is specific for only reading relay chain state.

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.

for now, but maybe follow-up use cases will emerge

@alindima

alindima commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

sp-additional-data should only expose generic/shared host functions, types and constants. E.g. only the finalize host functions and nothing around read_relay_state.

I agree that the substrate crate should be kept generic. The reality is that the finalize host function also would need to have some logic specific to each particular item in the additional data. That's up to each such "extension" to determine.
For example, for they relay/JAM state proof, we also check that the state proof does not contain keys that are not needed during block execution. But this is a particular thing for parachains, not a general substrate thing and not all such extensions will need to do this.
This is what I was talking about here: paritytech/parachain-service#14 (comment)

So IMO, it makes sense to either:

  1. Define both the read and finalise host functions in substrate, and have them called with a string identifier (having overall two host function calls that drive the entire additional data onchain interaction). This would call into an extension defined in substrate that wraps over a generic dyn AdditionalDataProvider that the parachain implements and registers.
  2. Remove the host functions from the substrate crate. So the only thing remaining there will be the pub type AdditionalData = BTreeMap<String, Vec<u8>>; type definition. Move the entire host function definition in cumulus

sp-addiotional-data should expose some AdditionalDataExt (this is for example used by finalize to generate the hash). This extension should just contain "pointers" to all the other extensions that also host additonal data. So, that it can later on all self.all_additional_datas.iter().map(|dp| dp.finalize()).fold_into_hash().

This sounds very similar to the idea number 1 above. Do you agree that it'd then make sense to also have a common read host function that dispatches based on some param identifier?

@bkchr

bkchr commented Sep 1, 2026

Copy link
Copy Markdown
Member
  1. Define both the read and finalise host functions in substrate, and have them called with a string identifier (having overall two host function calls that drive the entire additional data onchain interaction). This would call into an extension defined in substrate that wraps over a generic dyn AdditionalDataProvider that the parachain implements and registers.

No, we should not add any strings there. We just need some generic AdditionalDataProvider or whatever trait that provides the finalize method. finalize would call this method for all additional data providers. And in the case of e.g. the relay state reading, it returns an Err if not all values got read. (The error is not forwarded to the runtime, we could just panic on the node side)

Split the block "additional data" mechanism into a producer-agnostic core
and a relay-specific side
@alindima
alindima requested a review from a team as a code owner September 2, 2026 13:20
@paritytech-workflow-stopper

Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/33635139602
Failed job name: quick-benchmarks-omni

@bkchr
bkchr merged commit f2cbb23 into parchain-service Sep 2, 2026
92 of 206 checks passed
@bkchr
bkchr deleted the alindima/relay-proof-read-hostfn-rebased branch September 2, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants