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

Store Chain Id in runtime storage #101

Merged
merged 16 commits into from
Nov 10, 2020
Merged

Store Chain Id in runtime storage #101

merged 16 commits into from
Nov 10, 2020

Conversation

JoshOrndorff
Copy link
Contributor

@JoshOrndorff JoshOrndorff commented Nov 9, 2020

This PR solves the problem of all moonbeam chains having the same chain id. The implementation chosen is to introduce a simple pallet that stores a u64 chain id in runtime storage. This solution is simple, and compatible with existing evm and ethereum pallets.

This PR does not use the SystemChainId type available in pallet_evm because it relies on a host function that is not well documented or understood. While we could introduce a custom host function to make that approach work, it adds complexity, and pushes concern about setting the right chain id to node operators.

This approach has lots of room for growth including:

  • Changing the chain Id via governance
  • Being combined with other configuration information such as those stored in parachain info

This PR also includes one mostly unrelated change. It adds empty genesis config entries to all the json-encoded spec files in the repo. This will ensure we can get ethereum block 0 via rpc when using these json specs.

@crystalin
Copy link
Collaborator

It looks good but we should discuss the chainId we will provide. I took 43 cause substrate was 42 (which is also Kovan) but we might want to go wither other values.

@tgmichel
Copy link
Contributor

May I suggest a rename for the pallet?

I propose calling it just a more generic pallet-evm-chain-id, simply because it is self-describing and can be plugged into non-moonbeam projects that use EVM or Frontier without any rebranding.

@JoshOrndorff
Copy link
Contributor Author

After discussion on Slack we decided to go with these chain Ids

Local parachain testnet 1280
Local standalone testnet 1281
Reserved for other testnets 1282 - 1283
Moonbeam 1284 (mean milliseconds for a moonbeam to reach earth)
Moonriver 1285
Moonrock 1286
Public parachain testnet (currently alphanet) 1287
Reserved for other public networks 1288 - 1289

I'll update the code and rename the pallet as Telmo suggested, then i think we're good to go.

Copy link
Collaborator

@crystalin crystalin left a comment

Choose a reason for hiding this comment

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

Needs to update the chainId in the hardcoded specs

node/standalone/src/chain_spec.rs Outdated Show resolved Hide resolved
@crystalin crystalin merged commit 7730146 into master Nov 10, 2020
@crystalin crystalin deleted the joshy-chainid branch November 10, 2020 21:03
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

Successfully merging this pull request may close these issues.

3 participants