-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Backporting the following PRs from the dev branch: - [#191](#191) - [#176](#176) --------- Co-authored-by: Alisher A. Khassanov <a.khssnv@gmail.com>
- Loading branch information
1 parent
974077a
commit 2885ae9
Showing
12 changed files
with
359 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# State preset | ||
|
||
Sometimes we use the blockchain as a part of a test environment. | ||
Those tests typically want a certain state of the blockchain. | ||
One option is to make a script which sends a number of transactions to put the blockchain into the desired state. | ||
But those scripts may become large and execution may take significant time. | ||
Another option is to make a chain specification, a JSON file with the desired genesis state of the blockchain. | ||
And launch the chain with the desired state from the first block. | ||
|
||
## Build a chain spec | ||
|
||
Chain specification is a JSON file which contains network parameters with the the initial runtime and a genesis state of the database for each runtime module. | ||
There are two forms of chain specification - a human-readable _plain_ form where each runtime module is represented by it's name. | ||
And a _raw_ form with key-value pairs which will be written to the database. | ||
|
||
1. Create a plain form chain spec. | ||
|
||
```console | ||
./target/release/cere build-spec --chain=dev --disable-default-bootnode > plain.json | ||
``` | ||
|
||
1. Set genesis state for each module. | ||
There is an example in `node/service/example.json`, you can copy everything except the `code` field value from it to the `plain.json`. | ||
|
||
1. Create a raw form chain spec. | ||
|
||
```console | ||
./target/release/cere build-spec --chain=plain.json --disable-default-bootnode --raw > raw.json | ||
``` | ||
|
||
## Launch the chain | ||
|
||
```console | ||
./target/release/cere --chain=raw.json --tmp --alice --unsafe-rpc-external --unsafe-ws-external --rpc-cors=all | ||
``` | ||
|
||
## See also | ||
|
||
[docs.substrate.io: Create a custom chain specification](https://docs.substrate.io/tutorials/build-a-blockchain/add-trusted-nodes/#create-a-custom-chain-specification) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
{ | ||
"includes": [ | ||
"**/*.{toml}" | ||
], | ||
"excludes": [ | ||
"**/target" | ||
], | ||
"plugins": [ | ||
"https://plugins.dprint.dev/toml-0.5.3.wasm" | ||
] | ||
} | ||
"includes": ["**/*.{toml}"], | ||
"excludes": ["**/target"], | ||
"plugins": ["https://plugins.dprint.dev/toml-0.5.3.wasm"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
{ | ||
"name": "Development", | ||
"id": "cere_dev", | ||
"chainType": "Development", | ||
"bootNodes": [], | ||
"telemetryEndpoints": null, | ||
"protocolId": "cere", | ||
"properties": { | ||
"ss58Format": 54, | ||
"tokenDecimals": 10, | ||
"tokenSymbol": "CERE" | ||
}, | ||
"forkBlocks": null, | ||
"badBlocks": null, | ||
"lightSyncState": null, | ||
"codeSubstitutes": {}, | ||
"genesis": { | ||
"runtime": { | ||
"system": { | ||
"code": "0x00" | ||
}, | ||
"babe": { | ||
"authorities": [], | ||
"epochConfig": { | ||
"c": [ | ||
1, | ||
4 | ||
], | ||
"allowed_slots": "PrimaryAndSecondaryPlainSlots" | ||
} | ||
}, | ||
"indices": { | ||
"indices": [] | ||
}, | ||
"balances": { | ||
"balances": [ | ||
[ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
10000000000000 | ||
], | ||
[ | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", | ||
10000000000000 | ||
], | ||
[ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
10000000000000 | ||
], | ||
[ | ||
"5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc", | ||
10000000000000 | ||
], | ||
[ | ||
"5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", | ||
10000000000000 | ||
] | ||
] | ||
}, | ||
"transactionPayment": { | ||
"multiplier": "10000000000" | ||
}, | ||
"staking": { | ||
"validatorCount": 1, | ||
"minimumValidatorCount": 1, | ||
"invulnerables": [ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY" | ||
], | ||
"forceEra": "NotForcing", | ||
"slashRewardFraction": 100000000, | ||
"canceledPayout": 0, | ||
"stakers": [ | ||
[ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
1000000000000, | ||
"Validator" | ||
] | ||
], | ||
"minNominatorBond": 0, | ||
"minValidatorBond": 0, | ||
"maxValidatorCount": null, | ||
"maxNominatorCount": null | ||
}, | ||
"session": { | ||
"keys": [ | ||
[ | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", | ||
{ | ||
"grandpa": "5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu", | ||
"babe": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"im_online": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"authority_discovery": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" | ||
} | ||
] | ||
] | ||
}, | ||
"democracy": { | ||
"phantom": null | ||
}, | ||
"council": { | ||
"phantom": null, | ||
"members": [] | ||
}, | ||
"technicalCommittee": { | ||
"phantom": null, | ||
"members": [ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" | ||
] | ||
}, | ||
"elections": { | ||
"members": [ | ||
[ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
10000000000 | ||
], | ||
[ | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", | ||
10000000000 | ||
] | ||
] | ||
}, | ||
"technicalMembership": { | ||
"members": [], | ||
"phantom": null | ||
}, | ||
"grandpa": { | ||
"authorities": [] | ||
}, | ||
"treasury": null, | ||
"sudo": { | ||
"key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" | ||
}, | ||
"imOnline": { | ||
"keys": [] | ||
}, | ||
"authorityDiscovery": { | ||
"keys": [] | ||
}, | ||
"society": { | ||
"pot": 0, | ||
"members": [ | ||
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" | ||
], | ||
"maxMembers": 999 | ||
}, | ||
"vesting": { | ||
"vesting": [] | ||
}, | ||
"nominationPools": { | ||
"minJoinBond": 0, | ||
"minCreateBond": 0, | ||
"maxPools": 16, | ||
"maxMembersPerPool": 32, | ||
"maxMembers": 512 | ||
}, | ||
"ddcStaking": { | ||
"cdns": [], | ||
"storages": [] | ||
}, | ||
"ddcCustomers": { | ||
"buckets": [ | ||
[ | ||
"0x0000000000000000000000000000000000000001", | ||
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", | ||
10000000000 | ||
] | ||
] | ||
}, | ||
"ddcNodes": { | ||
"storageNodes": [ | ||
{ | ||
"pub_key": "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", | ||
"provider_id": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"cluster_id": "0x0000000000000000000000000000000000000001", | ||
"props": { | ||
"host": [], | ||
"http_port": 8080, | ||
"grpc_port": 8081, | ||
"p2p_port": 8082 | ||
} | ||
} | ||
], | ||
"cdnNodes": [] | ||
}, | ||
"ddcClusters": { | ||
"clusters": [ | ||
{ | ||
"cluster_id": "0x0000000000000000000000000000000000000001", | ||
"manager_id": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"reserve_id": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", | ||
"props": { | ||
"node_provider_auth_contract": null | ||
} | ||
} | ||
], | ||
"clustersGovParams": [ | ||
[ | ||
"0x0000000000000000000000000000000000000001", | ||
{ | ||
"treasury_share": 0, | ||
"validators_share": 0, | ||
"cluster_reserve_share": 0, | ||
"cdn_bond_size": 0, | ||
"cdn_chill_delay": 0, | ||
"cdn_unbonding_delay": 0, | ||
"storage_bond_size": 0, | ||
"storage_chill_delay": 0, | ||
"storage_unbonding_delay": 0, | ||
"unit_per_mb_stored": 0, | ||
"unit_per_mb_streamed": 0, | ||
"unit_per_put_request": 0, | ||
"unit_per_get_request": 0 | ||
} | ||
] | ||
], | ||
"clustersNodes": [ | ||
[ | ||
"0x0000000000000000000000000000000000000001", | ||
[ | ||
{ | ||
"StoragePubKey": "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y" | ||
} | ||
] | ||
] | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.