Skip to content

Commit

Permalink
able to override parachain genesis (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Dec 27, 2021
1 parent 9c4ac6a commit dd10c7e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
13 changes: 10 additions & 3 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Relaychain Configuration
relaychain:
image: parity/polkadot:v0.9.9-1 # the docker image to use
image: parity/polkadot:v0.9.13 # the docker image to use
chain: rococo-local # the chain to use
runtimeGenesisConfig: # additonal genesis override
configuration:
Expand All @@ -27,14 +27,21 @@ relaychain:
# Parachain Configuration
parachains:
# Config for first parachain
- image: acala/karura-node:1.3.0
- image: acala/karura-node:2.1.1
chain: # this could be a string like `dev` or a config object
base: karura-dev # the chain to use
collators: # override collators
- alice # this imply //Alice
- rXMrmePtNnyZ61hvpjfEEZ1zmKzueUnTqijDncTzE8Wa2sJ # or could be a session key public address
- 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # or could be a session key public address
- charlie
sudo: alice # override sudo key to //Alice
runtimeGenesisConfig: # additonal genesis override
balances:
balances:
- [5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty, 10000000000000000]
tokens:
balances:
- [5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty, { token: 'KUSD' }, 10000000000000000]
id: 2000 # override parachain id
parachain: true # this is parachain, not parathread
flags: # CLI flags for this parachain nodes
Expand Down
25 changes: 11 additions & 14 deletions configs/acala.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
relaychain:
image: parity/polkadot:v0.9.12
image: parity/polkadot:v0.9.13
chain: rococo-local
runtimeGenesisConfig:
configuration:
config:
validation_upgrade_frequency: 1
validation_upgrade_delay: 1
validation_upgrade_frequency: 5
validation_upgrade_delay: 5
env:
RUST_LOG: parachain::candidate-backing=trace,parachain::candidate-selection=trace,parachain::pvf=trace,parachain::collator-protocol=trace,parachain::provisioner=trace
RUST_LOG: parachain::candidate-backing=trace,parachain::candidate-selection=trace,parachain::pvf=debug,parachain::provisioner=trace
flags:
- --rpc-methods=unsafe
- --wasm-execution=compiled
Expand All @@ -18,12 +18,12 @@ relaychain:
- name: bob

parachains:
- image: acala/acala-node:50f66b96
- image: acala/acala-node:2.0.3
chain:
base: acala #-latest
# collators:
# - alice
# sudo: alice
base: acala-latest
collators:
- alice
sudo: alice
id: 2000
parachain: true
flags:
Expand All @@ -39,9 +39,6 @@ parachains:
RUST_LOG: sc_basic_authorship=trace,cumulus-consensus=trace,cumulus-collator=trace,collator_protocol=trace,collation_generation=trace,aura=debug
volumePath: /acala/data
nodes:
- {}
- {}
- {}
# - flags:
# - --alice
- flags:
- --alice

8 changes: 4 additions & 4 deletions configs/karura.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
relaychain:
image: parity/polkadot:v0.9.12
image: parity/polkadot:v0.9.13
chain: rococo-local
runtimeGenesisConfig:
configuration:
config:
validation_upgrade_frequency: 1
validation_upgrade_delay: 1
validation_upgrade_frequency: 5
validation_upgrade_delay: 5
env:
RUST_LOG: parachain::candidate-backing=trace,parachain::candidate-selection=trace,parachain::pvf=trace,parachain::collator-protocol=trace,parachain::provisioner=trace
flags:
Expand All @@ -18,7 +18,7 @@ relaychain:
- name: bob

parachains:
- image: acala/karura-node:1.6.0
- image: acala/karura-node:2.1.1
chain:
base: karura-dev
collators:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-web3/parachain-launch",
"version": "1.0.6",
"version": "1.1.0",
"author": "Laminar Developers <[email protected]>",
"license": "Apache-2.0",
"main": "lib/index.js",
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,20 @@ const generateParachainGenesisFile = (
for (const [addr, val] of balances) {
balObj[addr] = val;
}
if (chain.runtimeGenesisConfig?.balances) {
for (const [addr, val] of chain.runtimeGenesisConfig.balances.balances) {
balObj[addr] = (balObj[addr] || 0) + val;
}
delete chain.runtimeGenesisConfig.balances;
}
for (const addr of endowed) {
// TODO: https://github.com/open-web3-stack/parachain-launch/issues/5
balObj[addr] = (balObj[addr] || 0) + Math.pow(10, decimals) * 1000;
}
setParachainRuntimeValue(runtime, 'balances', { balances: Object.entries(balObj).map((x) => x) });
setParachainRuntimeValue(runtime, 'balances', { balances: Object.entries(balObj) });
}

if (chain.runtimeGenesisConfig) {
_.merge(runtime, chain.runtimeGenesisConfig);
}

fs.writeFileSync(filepath, jsonStringify(spec));
Expand Down
8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface RelayChain {
flags: string[];
nodes: Node[];
runtimeGenesisConfig: {
configuration: { config: { [index: string]: string | number } };
configuration?: { config: { [index: string]: string | number } };
hrmp?: {
preopenHrmpChannels: HrmpChannelsConfig[];
};
Expand All @@ -33,6 +33,12 @@ export interface Chain {
base: string;
collators?: string[];
sudo?: string;
runtimeGenesisConfig?: {
balances?: { balances: [string, number][] };
tokens?: { balances: [string, any, number][] };
parachainInfo?: { parachainId: number };
[key: string]: any;
};
}

export interface Node {
Expand Down

0 comments on commit dd10c7e

Please sign in to comment.