Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parathread registration and collator assignment #393

Merged
merged 15 commits into from
Feb 5, 2024

Conversation

tmpolaczyk
Copy link
Contributor

Adds a new extrinsic register_parathread, identical to register but allowing some parathread-specific params.

Currently the only param is the slot duration, which is not implemented in the client side, but it will allow parathreads to specify how often do they want blocks to be produced.

@tmpolaczyk tmpolaczyk force-pushed the tomasz-register-parathread branch from 59c7447 to b4e5d61 Compare January 23, 2024 16:44
Comment on lines +994 to +996
for para_id in paras {
// TODO: sweet O(n) db reads
if let Some(parathread_params) = ParathreadParams::<T>::get(&para_id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we need some way to distinguish parathreads from parachains. I am using the ParathreadParams storage map, but that will do N reads. Here are some alternatives, not sure what's the best one because I don't yet know if params will be used on-chain or not. They will probably be updated over time, so that's why I initially choose the StorageMap. Alternatives:

* StorageMap<ParaId, Params> (current)
* StorageValue<BTreeMap<ParaId, Params>> (all under one key)
* StorageValue<Vec<ParaId>> and StorageMap<ParaId, Params> (combination of both)
* Refactor currentContainerChains from `Vec<ParaId>` to `Vec<(ParaId, IsParathread)>`

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we should not need another storage item for this. It is very likely that every time we read RegisteredParchains we will need to know whether they are a Parachain or a Parathread, so we might just want to store a struct indicating this already in RegisteredParchains...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to keep the current StorageMap, but adding a PendingParams = StorageValue<Vec<(ParaId, Params)>> so that changes are only reflected in the next session.

We also would like to change RegisteredParchains into a StorageValue<Vec<(ParaId, Option<Params>)>>, where Params includes both Option<ParathreadParams> and also other things such as paused: bool. But that looks like a big change so it will be done in a future PR.

Copy link
Contributor

github-actions bot commented Jan 23, 2024

Coverage Report

(master)

@@                      Coverage Diff                       @@
##           master   tomasz-register-parathread      +/-   ##
==============================================================
- Coverage   76.90%                       76.89%   -0.01%     
  Files         105                          105              
+ Lines       26036                        26316     +280     
==============================================================
+ Hits        20021                        20234     +213     
+ Misses       6015                         6082      +67     
Files Changed Coverage
/pallets/collator-assignment/src/lib.rs 94.86% (+0.23%) 🔼
/pallets/configuration/src/lib.rs 85.66% (+0.41%) 🔼
/pallets/registrar/src/lib.rs 90.17% (-1.84%) 🔽
/pallets/registrar/src/weights.rs 38.35% (-11.65%) 🔽
/primitives/traits/src/lib.rs 93.75% (-6.25%) 🔽
/runtime/dancebox/src/lib.rs 81.42% (+0.10%) 🔼
/runtime/flashbox/src/lib.rs 44.24% (+0.37%) 🔼

Coverage generated Thu Feb 1 18:32:28 UTC 2024

@@ -131,7 +131,7 @@ impl HostConfiguration {
if self.max_orchestrator_collators < self.min_orchestrator_collators {
return Err(InconsistentError::MaxCollatorsLowerThanMinCollators);
}
if self.collators_per_parathread != 1 || self.parathreads_per_collator != 1 {
if self.parathreads_per_collator != 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

here we are finally assuming that we always have one collator per parathread right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, here we allow more than one collator per parathread (just like with parachains), but we don't allow one collator to be assigned to more than one parathread (at least not yet).

Copy link
Collaborator

@girazoki girazoki left a comment

Choose a reason for hiding this comment

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

I think the layout looks good @tmpolaczyk good job! Now we only need to test it well

@tmpolaczyk tmpolaczyk marked this pull request as ready for review January 31, 2024 11:09
@tmpolaczyk tmpolaczyk added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes labels Jan 31, 2024
Copy link
Collaborator

@girazoki girazoki left a comment

Choose a reason for hiding this comment

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

I think it looks good! A couple of tests that I have not seen (maybe I missed them?)

  • A test where we change the parameters but we dont deregister. The params should get update after 2 sessions right?

  • An additional typescript test where we register a parathread (I would rather have redundancy on tests)

Good job!

Copy link
Contributor

@fgamundi fgamundi left a comment

Choose a reason for hiding this comment

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

LGTM

@tmpolaczyk tmpolaczyk merged commit f38cc78 into master Feb 5, 2024
30 checks passed
@tmpolaczyk tmpolaczyk deleted the tomasz-register-parathread branch February 5, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants