Skip to content
Merged
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
3 changes: 3 additions & 0 deletions launch-configs/fork/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
state.json
forked-chainspec.json
data/
49 changes: 49 additions & 0 deletions launch-configs/fork/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM node:18-bookworm

RUN apt-get update && apt-get install -y \
curl \
wget \
nodejs \
npm \
ca-certificates \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /zombienet/Basilisk-node/launch-configs/fork

RUN wget -q https://github.com/paritytech/zombienet/releases/download/v1.3.128/zombienet-linux-x64 -O /usr/local/bin/zombienet && \
chmod +x /usr/local/bin/zombienet
RUN zombienet version

ARG POLKADOT_SDK_VERSION=latest

RUN mkdir -p /zombienet/polkadot-sdk/target/release
RUN if [ "$POLKADOT_SDK_VERSION" = "latest" ]; then \
DOWNLOAD_URL="https://github.com/paritytech/polkadot-sdk/releases/latest/download"; \
else \
DOWNLOAD_URL="https://github.com/paritytech/polkadot-sdk/releases/download/$POLKADOT_SDK_VERSION"; \
fi && \
for binary in polkadot polkadot-execute-worker polkadot-prepare-worker; do \
wget -q $DOWNLOAD_URL/$binary \
-O /zombienet/polkadot-sdk/target/release/$binary \
&& chmod +x /zombienet/polkadot-sdk/target/release/$binary \
&& /zombienet/polkadot-sdk/target/release/$binary --version; \
done

ARG BASILISK_BIN_URL=https://github.com/galacticcouncil/Basilisk-node/releases/latest/download
ARG SCRAPER_URL=https://github.com/galacticcouncil/hydration-node/releases/latest/download

RUN mkdir -p /zombienet/Basilisk-node/target/release
RUN wget -q $BASILISK_BIN_URL/basilisk -O /zombienet/Basilisk-node/target/release/basilisk && \
wget -q $SCRAPER_URL/scraper -O /zombienet/Basilisk-node/target/release/scraper && \
chmod +x /zombienet/Basilisk-node/target/release/*
RUN /zombienet/Basilisk-node/target/release/basilisk --version

COPY . .

RUN npm i

VOLUME /zombienet/Basilisk-node/launch-configs/fork/data
EXPOSE 9988

CMD npm start
44 changes: 44 additions & 0 deletions launch-configs/fork/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
starts zombienet instance with forked basilisk state downloaded from either:
- rpc endpoint in `STATE_RPC` (defaults to `wss://rpc.basilisk.cloud`) and block `STATE_BLOCK` (latest finalized by default)
- url of json defined in `STATE_SOURCE`

para_id: 2090, relay: rococo-local (kusama-local was retired from the polkadot binary; the local relay is cosmetic for a fork test)

### run with docker

```
docker run -d -p 9988:9988 galacticcouncil/fork:basilisk
```

### run locally

- node >18 required
- you have to have all binaries present on correct paths in `config.json`

```
npm i && npm start
```

### run with live PROD chainspec

- It scrapes the chainspec from the latest finalized block of basilisk mainnet, then spins up the fork via zombienet

```
npm run start:live
```

### run with custom chainspec

If you want to run fork with a custom chainspec, do the following:

1. Save a chainspec via the scraper (basilisk reuses hydration-node's `scraper` binary).
2. Place it at `./data/state.json`.
3. Run `npm run start:raw`.

### preauthorize a runtime upgrade

Set `AUTHORIZE_UPGRADE_CODE_HASH=0x<32-byte wasm hash>` in the container env. The fork
comes up with `System.AuthorizedUpgrade` populated, so a single
`system.applyAuthorizedUpgrade(code)` call enacts the new wasm — no governance step.

Pass `AUTHORIZE_UPGRADE_CHECK_VERSION=false` to skip the spec-version check (default: true).
90 changes: 90 additions & 0 deletions launch-configs/fork/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"settings": {
"timeout": 1000,
"provider": "native"
},
"relaychain": {
"default_command": "../../../polkadot-sdk/target/release/polkadot",
"chain": "rococo-local",
"default_args": [
"--no-hardware-benchmarks",
"--database=paritydb"
],
"genesis": {
"runtimeGenesis": {
"patch": {
"configuration": {
"config": {
"async_backing_params": {
"max_candidate_depth": 3,
"allowed_ancestry_len": 2
}
}
}
}
}
},
"nodes": [
{
"name": "alice",
"rpc_port": 9944,
"validator": true
},
{
"name": "bob",
"rpc_port": 9955,
"validator": true
},
{
"name": "charlie",
"rpc_port": 9966,
"validator": true
},
{
"name": "dave",
"rpc_port": 9977,
"validator": true
}
]
},
"types": {},
"hrmp_channels": [],
"parachains": [
{
"id": 2090,
"cumulus_based": true,
"chain": "local",
"chain_spec_path": "data/forked-chainspec.json",
"collators": [
{
"name": "alice",
"command": "../../target/release/basilisk",
"rpc_port": 9999,
"args": [
"--no-hardware-benchmarks",
"--force-authoring",
"--database=paritydb",
"--pool-type=fork-aware",
"--pruning=archive",
"--rpc-max-connections=5000",
"--tx-ban-seconds=5",
"--log=info"
]
},
{
"name": "bob",
"command": "../../target/release/basilisk",
"rpc_port": 9989,
"args": [
"--no-hardware-benchmarks",
"--force-authoring",
"--database=paritydb",
"--pool-type=fork-aware",
"--pruning=archive",
"--log=info"
]
}
]
}
]
}
44 changes: 44 additions & 0 deletions launch-configs/fork/get-state.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Define state file path
STATE_FILE="./data/state.json"

# Check if state file already exists
if [ -f "$STATE_FILE" ]; then
echo "State file already exists at $STATE_FILE. Skipping download/scrape."
exit 0
fi

# Ensure data directory exists
mkdir -p ./data

# Determine which command to run based on environment variables
if [ -n "$STATE_RPC" ]; then
echo "Using RPC endpoint: $STATE_RPC"

if [ -n "$STATE_BLOCK" ]; then
echo "Using block: $STATE_BLOCK"
fi

COMMAND="npm run state:scrape"
elif [ -n "$STATE_SOURCE" ]; then
echo "Using custom source: $STATE_SOURCE"
COMMAND="npm run state:download"
else
echo "Using default RPC endpoint"
COMMAND="npm run state:scrape"
fi

echo "Executing: $COMMAND"

if eval $COMMAND; then
if [ -f "$STATE_FILE" ]; then
echo "Successfully created state file at $STATE_FILE"
else
echo "Command completed but state file was not created!"
exit 1
fi
else
echo "Command execution failed"
exit 1
fi
Loading
Loading