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

Initial collator set-up #512

Closed
c410-f3r opened this issue Jun 16, 2021 · 5 comments
Closed

Initial collator set-up #512

c410-f3r opened this issue Jun 16, 2021 · 5 comments

Comments

@c410-f3r
Copy link

c410-f3r commented Jun 16, 2021

Hello,

Could you guys answer a question about setting up an initial collator? Let me introduce some context first.

To attach a regular validator session key to an account, it is usually a matter of calling the insertKey RPC endpoint but similar thing doesn't exist for the pallet-author-mapping pallet and the add_association method is an extrinsic that needs a collator in the first place. So it is like trying to register the first collator without a collator to produce the first block.

AuthorMappingConfig 's genesis mapping is useful for development networks and local test-nets because --alice (or --bob, or --fred, etc) are fixed known keys with a gentle Substrate CLI application that automatically inserts these pre-fixed keys (https://github.com/paritytech/substrate/blob/7f09a7619c863c964a93ceb915d6e0b9ddc39e2e/primitives/session/src/lib.rs#L109-L112). Unfortunately, the same can not be said to live networks as, for example, an initial genesis mapping to Alice could be easily exploited by third-parties.

With all that said, how to set-up an initial collator to start producing blocks or how did you guys end up doing to successfully achieve this situation? Any tip would be very helpful.

Cheers

@JoshOrndorff
Copy link
Contributor

Hi there. it sounds like you're trying to start your own local Moonbeam network using your own generated keys rather than Alice, Bob, etc, right? You're definitely on the right track. I'll give an overview here and feel free to ask further questions.

  1. Generate an account ID for your colaltor account. You can use metamask, or polkadot js or whatever for this.
  2. Use subkey or any other tool to generate an SR25519 session key
subkey generate
Secret phrase `learn possible obey useful ill venue wine ivory divide secret gallery fortune` is account:
  Secret seed:       0xa5621d70ee2834728867a6d221ed01ce23edea9a6e43b0e50b9d52a65c46cf93
  Public key (hex):  0x7c3174f25a5d6fa706948a31614c6a8e82a6f3337b29274855ffb1461a4b994b
  Public key (SS58): 5EsYVBCuVTWKX4NUeDmQePHvGiy8Jeg56ySpqtpe4Tp88xek
  Account ID:        0x7c3174f25a5d6fa706948a31614c6a8e82a6f3337b29274855ffb1461a4b994b
  SS58 Address:      5EsYVBCuVTWKX4NUeDmQePHvGiy8Jeg56ySpqtpe4Tp88xek
  1. Export our local chain spec into a json file that you can edit moonbeam build-spec --chain moonbase-local > moonbase-custom.json. (If you want to use the development service without a relay chain, start with moonbase-dev instead.)
  2. Edit that spec to contain your account information. Here are some considerations:
    • Give your account some tokens
    • List your account as sudo (not necessary, but possibly useful)
    • List your account as a collator candidate
    • Enter your author mapping in the genesis config.
  3. make your spec raw `moonbeam build-spec --chain moonbase-custom.json --raw > moonbase-custom-raw.json (Not necessary if you're doing everything locally, but necessary for production)
  4. Start your node moonbeam --collator --chain moonbase-custom-raw.json
  5. Insert your key via RPC. You can use curl or Apps. The keytype is nmbs.

@JoshOrndorff
Copy link
Contributor

cc @albertov19 @themacexpert @eshaben this might be a good thing to have in the docs eventually.

@c410-f3r
Copy link
Author

c410-f3r commented Jun 17, 2021

@JoshOrndorff Thanks for the detailed information and congratulations for all the hard work in regards to Cumulus.

As lucky as lucky can be, the above steps were already tried without success on my side. Quoting your example, there is an account ID and a session key (Author ID) so the genesis mapping should be:

(
    hex::hex!["SOME_RANDOM_ACCOUNT_ID_HEX"].into(),
    hex::hex!["0x7c3174f25a5d6fa706948a31614c6a8e82a6f3337b29274855ffb1461a4b994b"].unchecked_into(),
    SOME_STAKING_AMOUNT
)

But the collator session key is different than 0x7c3174f25a5d6fa706948a31614c6a8e82a6f3337b29274855ffb1461a4b994b causing an address mismatch, therefore, no block will be produced. This situation could be solved with an hypothetical way to enforce session keys at application start-up. For example:

moonbeam --collator --chain moonbase-custom-raw.json --session-key 0x7c3174f25a5d6fa706948a31614c6a8e82a6f3337b29274855ffb1461a4b994b

Also unsuccessfully tried to call author_insertKey providing the manually generated session key public key and/or the collator session key (rotateKeys) along side the account seed and/or the manually generated session key seed. Every possible combination, variant and alternative didn't change anything.

Maybe I am doing something wrong but this relationship between Author ID/Session key and a genesis collator that produces initial blocks is not clear to me. Could you provide more insight?

@JoshOrndorff
Copy link
Contributor

I don't understand what the first block of code you wrote means. The author mapping genesis config has just two fields. There is no amount there.

The --session-key flag idea would work but is not secure. It requires you putting the key on the cli. The RPC call is the standard way to do it. If you don't like that you could also try moonbeam key insert but I'd recommend against that until you have it working with the RPC call.

unsuccessfully tried to call author_insertKey

What was unsucessful about it. Did you get an error message?

rotateKeys

This is not useful for starting a network. This is useful for adding new collators or rotating the keys of existing collators after genesis. If you are trying to launch a new network, don't waste time with this rpc call.

@c410-f3r
Copy link
Author

My apologies @JoshOrndorff, everything is now working as expected. Previous attempts weren't successful because of my lack of attention.
In any case, I really appreciate your help and patience. Not everybody is keen to help so thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants