Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Enable changing executor params through governance #6934

Merged
merged 17 commits into from
Apr 14, 2023

Conversation

s0me0ne-unkn0wn
Copy link
Contributor

Closes #6805

Add a pallet call to session_info which sets new executor parameters. The new parameter set is stored as a separate storage value and becomes effective starting from the next session.

@s0me0ne-unkn0wn
Copy link
Contributor Author

Currently, I'm not sure I'm doing the right thing. Feel free to guide me on the right path.

runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
@s0me0ne-unkn0wn s0me0ne-unkn0wn added A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. T4-parachains_engineering This PR/Issue is related to Parachains performance, stability, maintenance. B1-note_worthy Changes should be noted in the release notes T1-runtime This PR/Issue is related to the topic “runtime”. labels Mar 21, 2023
Copy link
Contributor

@rphmeier rphmeier left a comment

Choose a reason for hiding this comment

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

Is there a reason why the executor params can't just go into the host configuration via the Configuration pallet?

@s0me0ne-unkn0wn
Copy link
Contributor Author

Is there a reason why the executor params can't just go into the host configuration via the Configuration pallet?

I believe there are no technical obstacles, but I have two concerns about that:

  1. Currently, the configuration only contains values of primitive types, like u32 and BlockNumber. Is it okay to bring the whole ExecutorParams with all its derivatives to it?
  2. Do ExecutorParams fit the HostConfiguration concept at all?

Beyond that, I have no other arguments against moving them to the configuration pallet altogether (but storage migration will be needed then).

@slumber
Copy link
Contributor

slumber commented Mar 22, 2023

I'd say moving it to configuration makes sense within this PR.

@ordian
Copy link
Member

ordian commented Mar 22, 2023

Is there a reason why the executor params can't just go into the host configuration via the Configuration pallet?

I believe there are no technical obstacles, but I have two concerns about that:

1. Currently, the `configuration` only contains values of primitive types, like `u32` and `BlockNumber`. Is it okay to bring the whole `ExecutorParams` with all its derivatives to it?

2. Do `ExecutorParams` fit the `HostConfiguration` concept at all?

Beyond that, I have no other arguments against moving them to the configuration pallet altogether (but storage migration will be needed then).

To me it feels like HostConfiguration has become a God object of sorts where many unrelated knobs are being put. For example, there are things only relevant for runtime, or things used by both validators and parachain runtime (via AbridgedHostConfiguration) or things used only on the client side (e.g. needed_approvals).

Another concern is tying breaking changes and migration between the two (although I don't expect many breaking changes to ExecutorParams).

Don't have any other objection.

runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
))]
pub fn set_executor_params(origin: OriginFor<T>, new: ExecutorParams) -> DispatchResult {
ensure_root(origin)?;
<PendingExecutorParams<T>>::put(Some(new));
Copy link
Member

Choose a reason for hiding this comment

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

And probably emit an event, so wallets and indexers can be notified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do they need to know about execution parameters change? That's a validators' business iiuc.

Copy link
Member

Choose a reason for hiding this comment

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

I dont know of the implications of this - events are good when the outside world us supposed to be notified.
Your call.

runtime/parachains/src/session_info.rs Outdated Show resolved Hide resolved
@bkchr
Copy link
Member

bkchr commented Mar 23, 2023

To me it feels like HostConfiguration has become a God object of sorts where many unrelated knobs are being put.

I think the main problem here being that we always need to decode the entire HostConfiguration for just accessing some small detail of the configuration. Maybe with the ExecutorParams it is a good start to put these into their own Configuration storage item. Nevertheless, the configuration pallet should be re-used to host this.

@s0me0ne-unkn0wn
Copy link
Contributor Author

@bkchr, one more concern is that we're accessing executor params on the session base, not on the state base, and we're maintaining a sliding window of different executor params for the sessions inside the dispute period. The session_info pallet maintains some infrastructure to support that (similar to SessionInfo storage), like keeping the earliest stored session number, etc. Moving the whole thing to the configuration pallet would introduce calls from the configuration pallet to the storage of the session_info pallet. Are we okay with that?

@bkchr
Copy link
Member

bkchr commented Mar 23, 2023

etc. Moving the whole thing to the configuration pallet would introduce calls from the configuration pallet to the storage of the session_info pallet. Are we okay with that?

Isn't the session info not just caching certain parameters per session and also currently caches things that are already part of the host configuration?

@slumber
Copy link
Contributor

slumber commented Mar 23, 2023

@s0me0ne-unkn0wn configuration change is always buffered to be applied in a couple of sessions, if this is somethings you're worried about

@s0me0ne-unkn0wn
Copy link
Contributor Author

s0me0ne-unkn0wn commented Mar 23, 2023

Isn't the session info not just caching certain parameters per session and also currently caches things that are already part of the host configuration?

In principle, yes. But

  1. It maintains a sliding window of those caches to make them available when referred by session index, not by relay parent
  2. It works the other way round: session_info gets some information from configuration and then caches it, and that's quite natural. But I'm not sure how natural it is for the configuration to request from session_info (I didn't check yet, but at least I'm afraid to get a pallet initialization order conflict)

@s0me0ne-unkn0wn configuration change is always buffered to be applied in a couple of sessions, if this is somethings you're worried about

It currently only does for the parameters encapsulated into the HostConfiguration struct, which is stored and updated as a whole; if we're talking about taking ExecutorParams out of it, we can implement any different logic as needed, I believe.

@s0me0ne-unkn0wn
Copy link
Contributor Author

Moved pending changes to the configuration pallet. Now the whole thing looks much more logical and straightforward to me.

@s0me0ne-unkn0wn s0me0ne-unkn0wn marked this pull request as ready for review March 29, 2023 17:16
@s0me0ne-unkn0wn s0me0ne-unkn0wn removed the T4-parachains_engineering This PR/Issue is related to Parachains performance, stability, maintenance. label Mar 29, 2023
@mrcnski
Copy link
Contributor

mrcnski commented Mar 30, 2023

Moved pending changes to the configuration pallet. Now the whole thing looks much more logical and straightforward to me.

+1. To me it definitely makes sense to have executor params reflected in the
session info, as we need to keep them per session. But the pending value
should be present in some external configuration which feeds the session info,
and this other configuration can be governanced.

@s0me0ne-unkn0wn
Copy link
Contributor Author

I'm a little bit stuck with the configuration pallet migration.

If I add something to HostConfiguration I have to add a migration that translates storage. But HostConfiguation is not a versioned primitive, and we have an active storage migration from v4 to v5. It refers to the current version of HostConfiguration as a translation target structure, so if I change anything in HostConfiguration, I have to change the migration.

And here I'm not sure, if that migration to v5 is over now, and the code may be safely removed and replaced with similar migration from v5 to v6, or if I should add my changes to the existing migration from v4 to v5. How do I determine that?

@eskimor
Copy link
Member

eskimor commented Apr 7, 2023

I'm a little bit stuck with the configuration pallet migration.

If I add something to HostConfiguration I have to add a migration that translates storage. But HostConfiguation is not a versioned primitive, and we have an active storage migration from v4 to v5. It refers to the current version of HostConfiguration as a translation target structure, so if I change anything in HostConfiguration, I have to change the migration.

And here I'm not sure, if that migration to v5 is over now, and the code may be safely removed and replaced with similar migration from v5 to v6, or if I should add my changes to the existing migration from v4 to v5. How do I determine that?

If the v5 migration has been released already, we have to do a v6. Not sure how well this works with runtime releases being skipped, but it is the only sensible way.

@s0me0ne-unkn0wn
Copy link
Contributor Author

If the v5 migration has been released already

I've checked that the latest release branch (release-v0.9.41) does not include the v5 migration, so it's not been released yet? How to know for sure?

@slumber
Copy link
Contributor

slumber commented Apr 7, 2023

If the v5 migration has been released already

I've checked that the latest release branch (release-v0.9.41) does not include the v5 migration, so it's not been released yet? How to know for sure?

@coderobe

@eskimor
Copy link
Member

eskimor commented Apr 7, 2023

If the v5 migration has been released already

I've checked that the latest release branch (release-v0.9.41) does not include the v5 migration, so it's not been released yet? How to know for sure?

That's how you are sure. If it is not yet on the latest release branch, It cannot be released. I mean in theory things could be backported, would still be very weird (and a bug) to not have that backport in the next release as well.

@ordian
Copy link
Member

ordian commented Apr 7, 2023

I think the idea was to keep previous migrations for a few releases at least. Since each migration does version check (if on_chain_version == expected), it's safe to keep outdated migrations, they just need to be applied in the right order. Whereas, if we remove them prematurely, it will cause problems for us, potentially corrupting the storage.

@s0me0ne-unkn0wn
Copy link
Contributor Author

Whereas, if we remove them prematurely, it will cause problems for us, potentially corrupting the storage.

I'm much more concerned about if it is safe to add my changes to the existing migration :) If it's not been released, then it's safe, right?

@coderobe
Copy link
Contributor

If the v5 migration has been released already

I've checked that the latest release branch (release-v0.9.41) does not include the v5 migration, so it's not been released yet? How to know for sure?

@coderobe

parachains_configuration::migration::v5::MigrateToV5<Runtime> is unreleased and can still be modified until 0.9.42 is cut, yes

@s0me0ne-unkn0wn
Copy link
Contributor Author

bot merge

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. T1-runtime This PR/Issue is related to the topic “runtime”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Executor environment parameters should be configurable on the fly
9 participants