Open rphmeier opened 5 years ago
Worth taking a look at the polkadot/runtime/parachains
implementation of Upward
messages for inspiration: we'll want a custom Origin::InboundMessage
for the calls that this module produces.
i'll take this.
On the runtime side it's up to you - only the notes I left in the issue above.
Take a look at the cumulus-collator
crate which Basti authored - this is invoked by polkadot-collator
, which automatically fetches the messages from the network and feeds them to the polkadot_collator::ParachainContext
, which cumulus-collator
provides. So it should be possible to feed it into an inherent data.
Yeah, the node side should be relative easy. If we have the runtime side, we can just feed the ingress data into the inherent data on the node side. Or better would be to have a dedicated runtime call to create the inherent, as we don't store it in the block. Otherwise we don't know which extrinsic we should remove from the block.
A runtime call to create the inherent? You mean exposing an additional runtime API:
type Messages = Vec<Vec<u8>>;
enum Endpoint { Relay, Para(ParaId) }
trait BatchIncoming {
/// Accepts a bunch of `messages` from various endpoints and creates an inherent extrinsic suitable for introducing into this runtime in order to dispatch the messages.
fn batch_incoming(messages: Vec<(Endpoint, Messages)>) -> Vec<u8>;
}
Yeah, exposing an additional runtime API.
Would that be an optimal API ^^^?
The current collator interface only gets messages from other parachains, but no messages from the relay chain.
So something like:
trait CollatorApi {
fn create_inherent(messages: Vec<(ParaId, Message)>) -> Block::Extrinsic;
}
should work.
ParaId
is defined as Id
in polkadot-parachain
and Message
is defined in polkadot-primitives/parachain
We should get messages from the relay chain as well now
Yeah, that'll require an upstream PR and a PolkadotApi
alteration - not saying it should be done only in Cumulus, just that we should support it at some point.
At a minimum, we can have the runtime interface accommodate relay-chain messages (upwards and downwards) without actually passing them through, yet.
so: polkadot validators explicitly check that the inherent extrinsic which contains message data is valid?
how i'd like it to work: the validation function should contain the block body (sans inherent), and accepts the messages as argument. as a first step, it constructs the actual block body by constructing the inherent from the passed messages.
We will want a runtime component for parachains to handle incoming messages.
The module will look something like this.