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

feat: add devnet custom genesis, aura and grandpa support #935

Merged
merged 6 commits into from
May 8, 2023

Conversation

kratico
Copy link
Contributor

@kratico kratico commented Apr 26, 2023

Resolves #889

How to test?

  • for aura and grandpa, compile substrate node-template
  • execute the following script
import { bins, net } from "./mod.ts"

const controller = new AbortController()

Deno.addSignalListener("SIGTERM", () => controller.abort())
Deno.addSignalListener("SIGINT", () => controller.abort())

const bin = bins({
  nodeTemplate: "/Users/parity/ghq/github.com/paritytech/substrate/target/release/node-template",
})

const relay = net.dev({
  bin: bin.nodeTemplate,
  chain: "local",
  customize(chainSpec) {
    // @ts-ignore
    chainSpec.genesis.runtime.sudo.key = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
  },
})
relay.name = "relay"

console.log(await relay.spawnNet(controller.signal, await Deno.makeTempDirSync({ dir: "./tmp" })))
  • check the logs ./tmp/cbfda8c3/relay/alice/stderr and validate that blocks are produced and finalized
  • check the sudo key is 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty (or await chain.Sudo.Key.value())

@kratico
Copy link
Contributor Author

kratico commented Apr 27, 2023

@harrysolovay @tjjfvi
Given that the pallet name could be aliased to any string, Shall I implement an option to pass an optional genesis config in DevChainConfig?
This genesis config will be merged with chain spec genesis config.

For example, Moonbean manages consensus with their pallet-author-mapping and sets an AuthorMapping attribute in construct_rutime.
In the capi.config.ts, we could have something like

{
  binary: ...,
  chain: "...",
  genesis: { ... },
}

@kratico kratico marked this pull request as ready for review April 27, 2023 15:57
@harrysolovay
Copy link
Contributor

That seems like a good path, but not necessarily expressing it in the TS. What's the most likely user story? Given that devs will generate the chainspec for their target chain, maybe they could pass the entire chainspec str, from which we'd extract the genesis config? Any simpler way to go about this?

@kratico
Copy link
Contributor Author

kratico commented Apr 27, 2023

That seems like a good path, but not necessarily expressing it in the TS. What's the most likely user story? Given that devs will generate the chainspec for their target chain, maybe they could pass the entire chainspec str, from which we'd extract the genesis config? Any simpler way to go about this?

For this story, I would just merge a custom genesis with the default genesis generated from the binary chain spec (for example, polkadot build-spec --chain rococo-local).

On the other hand, if devs pass a chainspec, I would just use that chainspec, add the bootnodes and use the genesis from that chainspec. For this, I would assume that the dev has already customized the genesis for their needs.

devnets/Config.ts Outdated Show resolved Hide resolved
@deno-deploy deno-deploy bot had a problem deploying to Preview May 3, 2023 15:19 Failure
@kratico kratico force-pushed the feat/devnet-aura-grandpa-authorities branch from f3450b1 to c1cdf03 Compare May 5, 2023 12:42
nets/DevParachainSpec.ts Outdated Show resolved Hide resolved
nets/DevRelaySpec.ts Show resolved Hide resolved
nets/chain_spec/addAuthorities.ts Outdated Show resolved Hide resolved
@kratico kratico force-pushed the feat/devnet-aura-grandpa-authorities branch from f1d9f55 to edfed8c Compare May 5, 2023 16:38
@deno-deploy deno-deploy bot had a problem deploying to Preview May 5, 2023 16:38 Failure
@harrysolovay harrysolovay added this pull request to the merge queue May 8, 2023
Merged via the queue into main with commit f645482 May 8, 2023
@harrysolovay harrysolovay deleted the feat/devnet-aura-grandpa-authorities branch May 8, 2023 13:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Devnet add support configure pallet_session, pallet_aura and pallet_grandpa at genesis
3 participants