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

chore: add extensible chopsticks setup #740

Open
wants to merge 9 commits into
base: aa/zombienet
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
# ignore vscode settings
.vscode

**/__pycache__

**/node_modules

runtimes/spiritnet/src/xcm_tests/e2e/out

*.db.sqlite*
chopsticks/**/db.sqlite*
chopsticks/**/extra.yaml
1 change: 1 addition & 0 deletions chopsticks/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.0
33 changes: 33 additions & 0 deletions chopsticks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# KILT Chopsticks utilities

This project contains setup code to spawn [Chopsticks](https://github.com/AcalaNetwork/chopsticks)-based deployments for both Spiritnet and Peregrine runtimes.

## How to spawn

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.

To spin up a deployment using the actual state currently on Spiritnet or Peregrine, run either `yarn peregrine:spawn` or `yarn spiritnet:spawn`.

### Add customizations

By default, the config for each chain specifies only the endpoint to fetch the state from and the path to store the db folder.

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.
These files are not tracked by git and are specific for each user's machine.
If a chain does not include an `extra.yaml` file, the default config specified in the chain's `config.yaml` file will be used.

A list of example configurations is given in the [examples](./examples/) folder.

So, if for example the sudo key for the Peregrine network must be overridden, follow these steps:

1. Create the file `runtimes/peregrine/kilt/extra.yaml`.
2. Copy the content of [`storage.example.yaml`](./examples/storage.example.yaml) into `runtimes/peregrine/kilt/extra.yaml`.
3. From within the `chopsticks` directory run `yarn peregrine:spawn`.

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.

## How it works

When spawning a network, a temporary file called `.tmp.yaml` will be generated within each chain's folder.
**THIS DOES NOT HAVE TO BE MANUALLY EDITED**, and it will be automatically cleaned up whenever the network spawning process is stopped.
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.
5 changes: 5 additions & 0 deletions chopsticks/examples/complete.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
port: 50002
wasm-override: ../../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm
import-storage:
Sudo:
Key: 15jSz35ugoWTc61xHPoxEkHte4o7UanKCk1gx1dizA8yuNs8
1 change: 1 addition & 0 deletions chopsticks/examples/port.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
port: 50002
3 changes: 3 additions & 0 deletions chopsticks/examples/storage.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import-storage:
Sudo:
Key: 15jSz35ugoWTc61xHPoxEkHte4o7UanKCk1gx1dizA8yuNs8
1 change: 1 addition & 0 deletions chopsticks/examples/wasm.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wasm-override: ../../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm
29 changes: 29 additions & 0 deletions chopsticks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@kiltprotocol/chopsticks-networks",
"private": "true",
"license": "MIT",
"devDependencies": {
"@acala-network/chopsticks": "^0.15.0",
"@alexlafroscia/yaml-merge": "^4.1.0"
},
"scripts": {
"internal:peregrine:relay-setup": "yarn --silent yaml-merge runtimes/peregrine/relay/config.yaml runtimes/peregrine/relay/extra.yaml > runtimes/peregrine/relay/.tmp.yaml",
"internal:peregrine:relay-teardown": "rm runtimes/peregrine/relay/.tmp.yaml",
"internal:peregrine:kilt-setup": "yarn --silent yaml-merge runtimes/peregrine/kilt/config.yaml runtimes/peregrine/kilt/extra.yaml > runtimes/peregrine/kilt/.tmp.yaml",
"internal:peregrine:kilt-teardown": "rm runtimes/peregrine/kilt/.tmp.yaml",
"internal:peregrine:ah-setup": "yarn --silent yaml-merge runtimes/peregrine/ah/config.yaml runtimes/peregrine/ah/extra.yaml > runtimes/peregrine/ah/.tmp.yaml",
"internal:peregrine:ah-teardown": "rm runtimes/peregrine/ah/.tmp.yaml",
"internal:spiritnet:relay-setup": "yarn --silent yaml-merge runtimes/spiritnet/relay/config.yaml runtimes/spiritnet/relay/extra.yaml > runtimes/spiritnet/relay/.tmp.yaml",
"internal:spiritnet:relay-teardown": "rm runtimes/spiritnet/relay/.tmp.yaml",
"internal:spiritnet:kilt-setup": "yarn --silent yaml-merge runtimes/spiritnet/kilt/config.yaml runtimes/spiritnet/kilt/extra.yaml > runtimes/spiritnet/kilt/.tmp.yaml",
"internal:spiritnet:kilt-teardown": "rm runtimes/spiritnet/kilt/.tmp.yaml",
"internal:spiritnet:ah-setup": "yarn --silent yaml-merge runtimes/spiritnet/ah/config.yaml runtimes/spiritnet/ah/extra.yaml > runtimes/spiritnet/ah/.tmp.yaml",
"internal:spiritnet:ah-teardown": "rm runtimes/spiritnet/ah/.tmp.yaml",
"preperegrine:spawn": "yarn internal:peregrine:relay-setup && yarn internal:peregrine:kilt-setup && yarn internal:peregrine:ah-setup",
"peregrine:spawn": "trap 'yarn peregrine:cleanup' INT; yarn chopsticks xcm -r runtimes/peregrine/relay/.tmp.yaml -p runtimes/peregrine/kilt/.tmp.yaml -p runtimes/peregrine/ah/.tmp.yaml",
"peregrine:cleanup": "yarn internal:peregrine:relay-teardown && yarn internal:peregrine:kilt-teardown && yarn internal:peregrine:ah-teardown",
"prespiritnet:spawn": "yarn internal:spiritnet:relay-setup && yarn internal:spiritnet:kilt-setup && yarn internal:spiritnet:ah-setup",
"spiritnet:spawn": "trap 'yarn spiritnet:cleanup' INT; yarn chopsticks xcm -r runtimes/spiritnet/relay/.tmp.yaml -p runtimes/spiritnet/kilt/.tmp.yaml -p runtimes/spiritnet/ah/.tmp.yaml",
"spiritnet:cleanup": "yarn internal:spiritnet:relay-teardown && yarn internal:spiritnet:kilt-teardown && yarn internal:spiritnet:ah-teardown"
}
}
4 changes: 4 additions & 0 deletions chopsticks/runtimes/peregrine/ah/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
endpoint:
- wss://sys.ibp.network/asset-hub-paseo
- wss://asset-hub-paseo.dotters.network
db: db/peregrine/ah/db.sqlite
3 changes: 3 additions & 0 deletions chopsticks/runtimes/peregrine/kilt/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
endpoint:
- wss://peregrine.kilt.io
db: db/peregrine/kilt/db.sqlite
4 changes: 4 additions & 0 deletions chopsticks/runtimes/peregrine/relay/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
endpoint:
- wss://rpc.ibp.network/paseo
- wss://paseo.dotters.network
db: db/peregrine/relay/db.sqlite
4 changes: 4 additions & 0 deletions chopsticks/runtimes/spiritnet/ah/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
endpoint:
- wss://sys.ibp.network/asset-hub-polkadot
- wss://asset-hub-polkadot.dotters.network
db: db/spiritnet/ah/db.sqlite
3 changes: 3 additions & 0 deletions chopsticks/runtimes/spiritnet/kilt/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
endpoint:
- wss://spiritnet.kilt.io
db: db/spiritnet/kilt/db.sqlite
4 changes: 4 additions & 0 deletions chopsticks/runtimes/spiritnet/relay/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
endpoint:
- wss://rpc.ibp.network/polkadot
- wss://polkadot.dotters.network
db: db/spiritnet/relay/db.sqlite
Loading
Loading