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

Make author_mapping::set_keys take 1 input like pallet_session::set_keys #1525

Merged
merged 18 commits into from May 20, 2022

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented May 19, 2022

What does it do?

⚠️ Changes set_keys extrinsic from

set_keys(
	origin: OriginFor<T>,
	old_author_id: NimbusId,
	new_author_id: NimbusId,
	new_keys: T::Keys,
)

to

set_keys(origin: OriginFor<T>, keys: (NimbusId, T::Keys))

⚠️ Changes register_keys extrinsic from

register_keys(origin: OriginFor<T>, author_id: NimbusId, keys: T::Keys)

to

register_keys(origin: OriginFor<T>, keys: (NimbusId, T::Keys))

This will allow collators to copy paste their output from RPC author_rotateKeys into these extrinsics just like the Polkadot/Kusama UX.

In order to do this, it adds a reverse mapping from AccountId to NimbusId.

Breaking Change (Maximum 1 NimbusId Per AccountId)

The migration will take the first NimbusId owned by a given AccountId to insert into NimbusLookup: AccountId => Option<NimbusId>. For any additional NimbusId owned by that AccountId, the migration clears the association and returns (unreserves) the deposit.

@4meta5 4meta5 added A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 19, 2022
Copy link
Collaborator

@librelois librelois left a comment

Choose a reason for hiding this comment

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

please replace T::AllKeys by (NimbusId, T::Keys)

4meta5 and others added 3 commits May 19, 2022 11:10
@4meta5
Copy link
Contributor Author

4meta5 commented May 19, 2022

Need to change NimbusLookup from AccountId => Option<NimbusId> to AccountId => Option<Vec<NimbusId>> because current code does not enforce max 1 NimbusId per AccountId and we do not need to enforce this either

Growing the Vec<NimbusId> requires a deposit of T::DepositAmount per entry so it is not strictly bounded but economically

@librelois
Copy link
Collaborator

current code does not enforce max 1 NimbusId per AccountId

If we have no useful use case to have several NimbusId linked to a single AccountId, it is better to forbid this.

@4meta5
Copy link
Contributor Author

4meta5 commented May 19, 2022

If we have no useful use case to have several NimbusId linked to a single AccountId, it is better to forbid this.

@librelois what to do if there are existing cases of 1 AccountId linked to several NimbusId? How would the migration work?

On moonbeam, 0x88848d6A768adfaE32C9aef05D70C522893efa1C is linked to two different NimbusIds.
On moonriver, 0x19EAa6Aae65e4B02539de493a735B81d1d848829 is linked to three different NimbusIds.
There may be more cases because we did not enforce the constraint before.

@librelois librelois mentioned this pull request May 19, 2022
21 tasks
@4meta5 4meta5 changed the title Make set_keys input opaque like pallet session keys Make author_mapping::set_keys take 1 input like pallet_session::set_keys May 19, 2022
@crystalin
Copy link
Collaborator

I think migration should be simple, pick the first one in the list.
However we should document that in the migration and the breaking change doc

@crystalin
Copy link
Collaborator

We should also notify Yann that a communication with collators will be required as early as possible

@4meta5
Copy link
Contributor Author

4meta5 commented May 19, 2022

I think migration should be simple, pick the first one in the list.

Ok I will remove the association for the others

@4meta5 4meta5 added D1-runtime-migration PR introduces code that might require downstream chains to run a runtime upgrade. A0-pleasereview Pull request needs code review. and removed A3-inprogress Pull request is in progress. No review needed at this stage. labels May 19, 2022
@4meta5 4meta5 requested a review from librelois May 20, 2022 04:44
@4meta5
Copy link
Contributor Author

4meta5 commented May 20, 2022

@nbaztec @notlesh where is the output to the benchmarking stored? Before I would run benchmarking and cat /tmp/$pallet_name.rs but I can no longer find the weights file generated by the benchmarking. What is the file name?

@nbaztec
Copy link
Contributor

nbaztec commented May 20, 2022

Think if you run on the benchmarking machine it will be under moonbeam/benchmarks/{pallet_name.rs}. Locally it will be under moonbeam/weights.rs

@girazoki
Copy link
Collaborator

MY latest experience is that it is in the moonbeam root folder as weights.rs. Dont know if this has changed though

4meta5 and others added 3 commits May 20, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D1-runtime-migration PR introduces code that might require downstream chains to run a runtime upgrade. D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants