-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Executor Environment parameterization #6161
Conversation
Two rounds of Versi burn-ins have passed smoothly. It seems like it's time to wrap it up. Mighty Cthulhu, I call upon you to accept this great sacrifice of mine! |
bot merge |
Is there a follow up issue already for clearing up the error handling after things have settled? |
Not yet, I have quite a bit of follow-ups written down, I'm sorting out which ones should become separate issues so that it will appear today. |
* Add an RPC call to request `ExecutorParams` * update lockfile for {"substrate", "polkadot"} --------- Co-authored-by: parity-processbot <>
* master: (35 commits) add turboflakes system-chains bootnodes (#2223) Companion for #13349 (#2217) bump `zombienet` version to v1.3.35 (#2226) [ci] Return benchmark to bm machines (#2225) Collectives chain xcm filter (#2222) Add metaspan.io parachain boot nodes (#2218) Companion for #13390 (#2189) `BlockId` removal: `BlockBuilderProvider::new_block_at` (#2219) Benchmarks script improvements (#2214) `BlockId` removal: refactor of runtime API (#2190) Rename .feature extension to .zndsl (#2215) Companion for paritytech/polkadot#6744: Retire `OldV1SessionInfo` (#2213) WIP: Fix templates (#2204) Add stake.plus bootnodes to collectives-westend and bridge-hub-kusama (#2201) Polkadot companion #6603: Use a `BoundedVec` in `ValidationResult` (#2161) Bump clap from 4.1.4 to 4.1.6 (#2193) Bump toml from 0.6.0 to 0.7.2 (#2170) companion for paritytech/polkadot#6161 (#2151) Bump serde_json from 1.0.92 to 1.0.93 (#2175) add warp_sync_params (#1909) ...
// The order of parameters should be deterministic, that is, one should not reorder them when | ||
// changing the array contents to avoid creating excessive pressure to PVF execution subsys. | ||
const EXECUTOR_PARAMS: [ExecutorParam; 0] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, why isn't this part of the parachains configuration? Why is this some constant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I look at it this way: it's part of the session_info
pallet (and was supposed to be a part of SessionInfo
itself at some point), and the session_info
pallet is a part of the parachain host.
But you're probably right, configuration
may be a better place for it. But it's a temporary solution anyway, as in the end, we want to be able to control executor parameters through governance, not only through runtime upgrades. So IIUC, we'll need to move it to configuration
anyway and then provide some methods to schedule those config upgrades (I'm just not familiar with that part yet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raised #6805 on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay ty!
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-39/2277/1 |
* Add an RPC call to request `ExecutorParams` * update lockfile for {"substrate", "polkadot"} --------- Co-authored-by: parity-processbot <>
Current status
Ready for review
Summary
PVF execution environment (EE) gets parametrized. Parameters are kept in an abstract form, not directly bound to any concrete EE implementation, so the mechanism could be used in case of EE replacement. However, right now the only PVF EE supported is Wasmtime. The parameter set is bound to the session. When a candidate produced in an older session has to be validated in a newer session, PVF EE should use a set of EE parameters that existed in the older session.
Background
Two storage maps are added tosession_info
pallet, the first is mapping relay parent hash to session index, and the second is mapping session index to EE parameter set. Runtime API call is added to make it possible for subsystems to request a parameter set by a relay parent hash which already is a part of candidate receipt.After some discussions, it was decided to include the execution environment parameter set into theSessionInfo
structure, so no new storage maps are created, and no new runtime calls are added. Instead, the primitives version and the parachain host API version are bumped to v3, and a migration for theSessionInfo
storage is implemented.After another discussion, it was decided to roll back to the previous behavior of having a separate storage mapping and a separate runtime call. A single storage map is added to map a session index to the execution parameter set.
Corresponding calls are added to candidate validation calls from backing, approval voting and dispute coordination subsystems.Subsystems use existingRollingSessionWindow
functionality to getSessionInfo
containing executor parameters. Where not available, cachingRuntimeInfo
implementation is used to request it directly from the runtime.All the logic of requesting the execution parameters is moved to the candidate validation subsystem as a central point where execution parameters are needed to process a call of any other subsystem.
PVF pre-check procedure is parametrized as well, as that's the point where PVF code gets instrumented, enforcing logical stack limit.
When a subsystem needs to validate a candidate,
it requests an EE parameter set from runtime API using a relay parent hash from the candidate receipt. Then, it passes the EE parameter set to the PVF execution subsystem. The latter executes a PVF using the parameters provided.EE parameter set doesn't need to be exhaustive. There's a default parameter set for the EE, and a per-session parameter set is only required to overwrite default values.
Right now, there's no way to alter the parameter set on-the-fly although we were discussing that possibility. Parameters are set as a constant in
session_info
pallet, and they may only be altered along with runtime update procedure.Questions and problems
None
is returned, which means the node does not contain the required data in its storage.Should every of conditions mentioned trigger a validation error? Are there any circumstances when we want to use a default set of execution parameters if we're not able to get a correct set for a given session?
A: First two situations may indicate that runtime does not implement the API call yet (hasn't yet been upgraded). In that case we should proceed with the default EE parameter set as that's the expected behavior if we're running an old runtime. Third situation indicated an error, as we're running a new runtime and we have to have EE parameter set for every session. Getting
None
indicated that something went really wrong, e.g. storage is broken etc. (ty @eskimor)mertics_guard
calls in case of failure. I need some assistance to make it right as I'm not familiar with metrics;A: Added as "unavailable" label. A separate label may be introduced later if needed.
64 * 1024
assession_info
cache has the same size, and calls are closely connected (they both hold per-session data for the same number of sessions). Is there a better way to choose the cache size?A: It's okay for now (ty @eskimor)
ExecutorParams
structure is defined inpolkadot_primitives::vstaging
as first we thought of including the EE parameter set inSessionInfo
struct itself which would require a migration procedure so including it tostaging
version was a natural choice. Now we decided to put it aside in a separate storage map so changes seem to be non-breaking. Should I move the definition directly intopolkadot_primitives::v2
instead?v2
API skippingvstaging
?A: Totally clarified in comments (ty @tdimitrov)
A: After a research, the proper error handling has been implemented.
frame_system::parent_hash()
fromsession_info::initializer_initialize
? Is it already available at the moment?C: Non totally clear yet, but @eskimor pointed out that the mapping in question may not be needed at all as
session_index_for_child
runtime API call may be used to retrieve the session index for a given relay parent hash. Need to check how it works in disputes right now.A: Not needed, thus eliminated from code.
shared::session_index()
fromsession_info::initializer_initialize
? Does it represent a correct value at the point? What if the current block is the session border?C: Need to check pallet initialization order (ty @eskimor)
A: Not needed, thus eliminated from code.
session_info::initializer_initialize
is supposed to return weight. The function body was empty before I dropped in some code working with other pallets and storage. I'm not familiar with how weight works, how to calculate correct weight for the call?C: Check with @ordian if needed at all; if it comes out that
session_index_for_child
is enough then the first mapping may be dropped and the code in question may be deleted altogether.A: Not needed, thus eliminated from code.
Companion PRs
cumulus companion: paritytech/cumulus#2151