-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Collator execution environment parametrization #6497
Comments
After some research (thanks @ordian for the consultations) I didn't find anything that has to be done here. A PVF is never prepared nor executed on the collator side. A collator submits PVF to the relay chain where it is included in a block and caught up by the PVF pre-checker which is already parametrized. Pre-checkers vote for the validation code hash, and if supermajority ensures it can produce a valid artifact, it is considered valid. That is, all the checking is done on the relay chain side. So I'm closing it for now, feel free to reopen if I'm missing something. |
They could submit a block/PoV that would be considered invalid. PVF is less of a problem: All that could happen is that a runtime upgrade gets rejected. |
They could, but how to avoid it? I mean, without bringing the whole executor infrastructure into the collator code? |
As long as we are only using them for limits which honest code should never exceed any way, it does not matter too much, but once we also use it to upgrading/switching compilers it is starting to matter. I mean if the risk of incompatibilities is low enough, we might still be able to punt on it for quite a while. Worst thing that can happen is that a parachain is stalled until they upgraded their nodes - bad enough for a production parachain though. Considering that we have Kusama this might still be acceptable for quite a while: If things break, they break on Kusama first (where chaos is expected) and collators can upgrade their nodes, before we hit Polkadot. Also I just found this comment: This is actually an interestingidea: If collators demand a particular execution environment in the candidate receipt, this would work as well - at the cost of complicating validators. Anyhow, resolving this can easily wait until we have versioning - we might make creation of these tickets a todo on that ticket, so we have less clutter until the time comes when we should start thinking about it. |
The whole executor (substrate) infrastructure is already in the collator code. At some point we will need to fetch these parameters as well for configuring the block building environment. |
That's true, but currently, the collator doesn't feature any interface to the executor. We could create one if need be, but do we really have to? The collator always runs a full node nearby, is it possible to use its already available executor interface (probably using RPC calls?) to check what we want to check and not to incorporate that logic into the collator itself? My concern is that we'll have to support two different yet homogenous executor interfaces. |
I have later seen that @eskimor already created issues for the things paritytech/polkadot-sdk#2339
I don't know exactly what you mean by this. |
Well, we have quite a bit of infrastructure on the node side to run PVFs and validate candidates. PVF host with preparation end execution pools/queues/workers, the executor interface itself, which implements validation backend that wraps the substrate executor and serves as an intermediary between execution requests and the execution itself, and so on. If we want similar functionality in collators, we should either abstract part of that infrastructure and reuse it in collators (which would create a kind of overkill if we don't put some effort into extensively tearing the abstractions apart), or implement a similar but more simple infrastructure in collators (which would result in some functionality duplication). We can go either way, but I believe first we should evaluate if we can reuse something that already exists, that's why I'm asking if we can make use of the node running along with the collator. All those things are already there in the node software. If we implement an RPC call that accepts a candidate, validates it off-chain, and provides the collator with the answer like "valid/not valid", that would be enough. Do you think it makes any sense? |
Ahh okay, so you really spoke about the entire executor infrastructure. So no, we don't need this. From the collator POV the runtime is trusted. However, we will need to run block building under certain constraints as it is done while validation on the relay chain. For sure we need to run with less memory than we have while validating a block, because validation stores more stuff in memory. We need to respect the maximum stack depth. We need to build a block while ensuring that it doesn't take more time than we give backers to validate it #6793. And whatever things come up over time. Stuff like preparation time of the wasm binary isn't really important to check. Wasm binaries that don't fit into the timeout will not be accepted as runtime upgrade and the collator doesn't need to check this. |
And to validate anything, we need at least the following:
So it seems to me like we still need pretty much the same infrastructure, just vastly scaled down, it doesn't need support parallel preparation and execution and other bells and whistles, but neither it looks like something trivial. Am I correct? |
We already share the same infrastructure by using the |
Sure, but I'm talking about the part between |
No, collators don't use the PVF mechanism. Their job is to make something that passes the PVF, and they do this with a Substrate runtime & client. It's also executed as WebAssembly, yes, so some things like stack depth and memory limits might need to be shared. But pre-checking or other execution worker logic is unnecessary. For a collator the runtime is trusted, for a validator the runtime is not. |
I feel like I'm losing the thread 😅 Let's try from another end. I'll make a numbered list to address points easily.
Am I missing something? Because if I am not, it still sounds to me like "we need a somewhat scaled-down implementation of PVF host for collators" 🤷 |
No we don't want this. Normal mode is that you produce a PoV and send it to the relay chain. You are clearly trusting yourself to build a proper candidate ;) |
See: paritytech/polkadot-sdk#917, PR #6161
After adopting #6161, we should make collators aware of execution environment parameters, too. Otherwise, they could submit a PVF that they checked to be valid, but that would be invalid for any validator because of different execution environment parameters in the relay chain runtime.
It's not an urgent concern as, right now, execution environment parameters are set to default values, and collators share the same defaults, so the situation described cannot happen. It will only become problematic if we change any execution environment parameters in the relay chain runtime.
The text was updated successfully, but these errors were encountered: