Skip to content

Commit 919fb7c

Browse files
authored
chore: add extensible chopsticks setup (#740)
To spin up Chopsticks-based networks using actual data. It's based on top of #714. For more info about how to use this new utility, check the `chopsticks/README.md` file.
1 parent 36d3bcb commit 919fb7c

16 files changed

+4472
-3
lines changed

.gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
# ignore vscode settings
1818
.vscode
1919

20-
**/__pycache__
21-
2220
**/node_modules
21+
**/.yarn/*
22+
!**/.yarn/releases
2323

2424
runtimes/spiritnet/src/xcm_tests/e2e/out
2525

26-
*.db.sqlite*
26+
chopsticks/**/db.sqlite*
27+
chopsticks/**/extra.yaml
28+
chopsticks/**/.tmp.yaml

chopsticks/.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.11.0

chopsticks/.yarn/releases/yarn-4.5.0.cjs

+925
Large diffs are not rendered by default.

chopsticks/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# KILT Chopsticks utilities
2+
3+
This project contains setup code to spawn [Chopsticks](https://github.com/AcalaNetwork/chopsticks)-based deployments for both Spiritnet and Peregrine runtimes.
4+
5+
## How to spawn
6+
7+
First, `cd` into the `chipsticks` folder and run first `nvm use` to configure the right Node version, and then `yarn` to install any Node dependencies.
8+
9+
To spin up a deployment using the actual state currently on Spiritnet or Peregrine, run either `yarn peregrine:spawn` or `yarn spiritnet:spawn`.
10+
11+
### Add customizations
12+
13+
By default, the config for each chain specifies only the endpoint to fetch the state from and the path to store the db folder.
14+
15+
Any additional information, such as storage or WASM overrides, or port number specifications, can be specified using the same YAML format in each folder's `extra.yaml` file.
16+
These files are not tracked by git and are specific for each user's machine.
17+
If a chain does not include an `extra.yaml` file, the default config specified in the chain's `config.yaml` file will be used.
18+
19+
A list of example configurations is given in the [examples](./examples/) folder.
20+
21+
So, if for example the sudo key for the Peregrine network must be overridden, follow these steps:
22+
23+
1. Create the file `runtimes/peregrine/kilt/extra.yaml`.
24+
2. Copy the content of [`storage.example.yaml`](./examples/storage.example.yaml) into `runtimes/peregrine/kilt/extra.yaml`.
25+
3. From within the `chopsticks` directory run `yarn peregrine:spawn`.
26+
27+
This process can be applied to every chain folder, also for multiple within the same environment, e.g., the sudo key for PILT and the sudo key for Paseo can be overridden by having two `extra.yaml` files within each folder.
28+
29+
## How it works
30+
31+
When spawning a network, a temporary file called `.tmp.yaml` will be generated within each chain's folder.
32+
**THIS DOES NOT HAVE TO BE MANUALLY EDITED**, and it will be automatically cleaned up whenever the network spawning process is stopped.
33+
If, for any reason, this should not be the case, you can run `yarn peregrine:cleanup` or `yarn spiritnet:cleanup` to clean up these temporary files.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
port: 50002
2+
wasm-override: ../../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm
3+
import-storage:
4+
Sudo:
5+
Key: 15jSz35ugoWTc61xHPoxEkHte4o7UanKCk1gx1dizA8yuNs8

chopsticks/examples/port.example.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
port: 50002
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import-storage:
2+
Sudo:
3+
Key: 15jSz35ugoWTc61xHPoxEkHte4o7UanKCk1gx1dizA8yuNs8

chopsticks/examples/wasm.example.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wasm-override: ../../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm

chopsticks/package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@kiltprotocol/chopsticks-networks",
3+
"license": "MIT",
4+
"devDependencies": {
5+
"@acala-network/chopsticks": "^0.15.0",
6+
"@alexlafroscia/yaml-merge": "^4.1.0"
7+
},
8+
"scripts": {
9+
"internal:peregrine:relay-setup": "yarn yaml-merge runtimes/peregrine/relay/config.yaml runtimes/peregrine/relay/extra.yaml > runtimes/peregrine/relay/.tmp.yaml",
10+
"internal:peregrine:relay-teardown": "rm runtimes/peregrine/relay/.tmp.yaml",
11+
"internal:peregrine:kilt-setup": "yarn yaml-merge runtimes/peregrine/kilt/config.yaml runtimes/peregrine/kilt/extra.yaml > runtimes/peregrine/kilt/.tmp.yaml",
12+
"internal:peregrine:kilt-teardown": "rm runtimes/peregrine/kilt/.tmp.yaml",
13+
"internal:peregrine:ah-setup": "yarn yaml-merge runtimes/peregrine/ah/config.yaml runtimes/peregrine/ah/extra.yaml > runtimes/peregrine/ah/.tmp.yaml",
14+
"internal:peregrine:ah-teardown": "rm runtimes/peregrine/ah/.tmp.yaml",
15+
"internal:spiritnet:relay-setup": "yarn yaml-merge runtimes/spiritnet/relay/config.yaml runtimes/spiritnet/relay/extra.yaml > runtimes/spiritnet/relay/.tmp.yaml",
16+
"internal:spiritnet:relay-teardown": "rm runtimes/spiritnet/relay/.tmp.yaml",
17+
"internal:spiritnet:kilt-setup": "yarn yaml-merge runtimes/spiritnet/kilt/config.yaml runtimes/spiritnet/kilt/extra.yaml > runtimes/spiritnet/kilt/.tmp.yaml",
18+
"internal:spiritnet:kilt-teardown": "rm runtimes/spiritnet/kilt/.tmp.yaml",
19+
"internal:spiritnet:ah-setup": "yarn yaml-merge runtimes/spiritnet/ah/config.yaml runtimes/spiritnet/ah/extra.yaml > runtimes/spiritnet/ah/.tmp.yaml",
20+
"internal:spiritnet:ah-teardown": "rm runtimes/spiritnet/ah/.tmp.yaml",
21+
"pre:peregrine:spawn": "yarn internal:peregrine:relay-setup && yarn internal:peregrine:kilt-setup && yarn internal:peregrine:ah-setup",
22+
"peregrine:spawn": "bash -c 'trap \"echo \"\"Cleaning up temporary resources. Please wait a few seconds...\"\" && yarn peregrine:cleanup\" SIGINT; yarn pre:peregrine:spawn && yarn chopsticks xcm -r runtimes/peregrine/relay/.tmp.yaml -p runtimes/peregrine/kilt/.tmp.yaml -p runtimes/peregrine/ah/.tmp.yaml'",
23+
"peregrine:cleanup": "yarn internal:peregrine:relay-teardown && yarn internal:peregrine:kilt-teardown && yarn internal:peregrine:ah-teardown",
24+
"pre:spiritnet:spawn": "yarn internal:spiritnet:relay-setup && yarn internal:spiritnet:kilt-setup && yarn internal:spiritnet:ah-setup",
25+
"spiritnet:spawn": "bash -c 'trap \"echo \"\"Cleaning up temporary resources. Please wait a few seconds...\"\" && yarn spiritnet:cleanup\" SIGINT; yarn pre:spiritnet:spawn && yarn chopsticks xcm -r runtimes/spiritnet/relay/.tmp.yaml -p runtimes/spiritnet/kilt/.tmp.yaml -p runtimes/spiritnet/ah/.tmp.yaml'",
26+
"spiritnet:cleanup": "yarn internal:spiritnet:relay-teardown && yarn internal:spiritnet:kilt-teardown && yarn internal:spiritnet:ah-teardown"
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
endpoint:
2+
- wss://sys.ibp.network/asset-hub-paseo
3+
- wss://asset-hub-paseo.dotters.network
4+
db: db/peregrine/ah/db.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
endpoint:
2+
- wss://peregrine.kilt.io
3+
db: db/peregrine/kilt/db.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
endpoint:
2+
- wss://rpc.ibp.network/paseo
3+
- wss://paseo.dotters.network
4+
db: db/peregrine/relay/db.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
endpoint:
2+
- wss://sys.ibp.network/asset-hub-polkadot
3+
- wss://asset-hub-polkadot.dotters.network
4+
db: db/spiritnet/ah/db.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
endpoint:
2+
- wss://spiritnet.kilt.io
3+
db: db/spiritnet/kilt/db.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
endpoint:
2+
- wss://rpc.ibp.network/polkadot
3+
- wss://polkadot.dotters.network
4+
db: db/spiritnet/relay/db.sqlite

0 commit comments

Comments
 (0)