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

Postpone public key creation in the test GenesisStorageBuilder #14142

Merged
merged 3 commits into from
May 15, 2023

Conversation

davxy
Copy link
Member

@davxy davxy commented May 15, 2023

Lazy creation of public keys from AccountId in the GenesisStorageBuilder::build() method.

Reason: the new strategy better fits when we require to create keys using a different scheme.
Previous approach assumes that all the runtime pallets will require the same scheme (sr25519) but this is not always the case (sassafras uses bandersnatch vrf keys or grandpa).

Postponing the creation of the keys allows to maintain only the account ids list in the builder and then create all the key types we require (currently only sr25519) when we require them


Other trivial tweaks:

  • substrate-test-pallet's Authorities storage is used to store other protocols keys that doesn't instance the pallet within the test runtime (e.g. aura). Thus, is more appropriate to store a raw sr25519 key instead of the babe's AuthorityId newtype.
  • (BabeApi impl) fetch babe's authorities from its pallet (should be the same list, but is formally more correct)
  • rename GenesisStorageBuilder::build_storage() to build (inline with typical name used by builder pattern)

@davxy davxy self-assigned this May 15, 2023
@davxy davxy added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels May 15, 2023
@davxy davxy requested review from bkchr, michalkucharczyk, skunert and a team May 15, 2023 10:09
@davxy davxy merged commit 204f39a into master May 15, 2023
@davxy davxy deleted the davxy-postpone-auth-key-build branch May 15, 2023 11:56
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
…ytech#14142)

* Postpone public key creation from account id in the test genesis storage builder

* Store raw sr25519 in substrate test pallet

* Nitpick
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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants