Noah Bergh
Noah Bergh

Reputation: 495

Substrate Create authority from runtime

Is every account created an aura and/or grandpa authority? Could we create authorities from the runtime or is this only possible from the chainspec?

Upvotes: 1

Views: 486

Answers (1)

JoshOrndorff
JoshOrndorff

Reputation: 1701

Creating an account is not as clearly defined as your question implies. Anyone can create a keypair and get their address without interacting with the chain at all. Once the account receives funds* it will have account data stored on chain. Neither notion of creating an account causes the account to become an authority.

Authorities are determined by the runtime in both Aura and Grandpa. Aura uses the AuraAPI for this and Grandpa uses the GrandpaAPI. So it is not only possible, but actually mandatory, for the authorities to be chosen by the runtime.

When you specify authorities in the chain spec file, you are actually only declaring the initial set of authorities. That set of authorities may change as the chain progresses.

If you'd like your authorities to change all you have to do is implement to two APIs I linked above. In practice, you probably don't want to implement them directly, but rather interface with the Session Pallet.

You even be able to use an existing solutions. For Proof of Stake, check out the Staking Pallet. For Proof of Authority, check out this substrate-validator-set pallet.

Footnotes:

  • Receiving funds is what makes an account have data stored on chain in most Substrate chains including polkadot and the node template. This logic is configurable.

Upvotes: 4

Related Questions