-
Notifications
You must be signed in to change notification settings - Fork 8
Genesis_Verification
This document outlines the procedure for creating and verifying the genesis state for the Resonance testnet. The process uses deterministic runtime builds from GitHub releases to ensure transparency and reproducibility.
The genesis file creation process is automated by the scripts/genesis_generate_spec.sh script, which generates the live-resonance.json file by building a base chain spec locally and then replacing the runtime code with a deterministic WASM artifact from a specific GitHub release.
- Clean git working directory (no uncommitted changes)
- Access to GitHub API (for downloading release artifacts)
-
curl,jq, and standard build tools installed
Before generating genesis, ensure you have a GitHub release with runtime artifacts built using srtool (Substrate Runtime Tool). These releases should contain:
quantus-runtime-v{SPEC_VERSION}.compact.compressed.wasm
Execute the genesis generation script with the desired release tag:
./scripts/genesis_generate_spec.sh v0.X.Y-test-genesisThe script performs the following automated steps:
-
Environment Verification
- Checks that the working directory is clean
- Fetches latest tags from origin
-
Checkout Release Tag
- Creates a new branch
genesis/{RELEASE_TAG} - Switches to the specified release tag
- Creates a new branch
-
Build Node Locally
- Executes
cargo build --release --package quantus-node - This builds the node binary from the checked-out source code
- Executes
-
Generate Base Chain Specification
- Executes:
./target/release/quantus-node build-spec --chain live_resonance_local --raw > node/src/chain-specs/live-resonance.json - The
live_resonance_localidentifier refers to the chain specification defined in the code - The
--rawflag generates a raw JSON file with embedded WASM runtime
- Executes:
-
Download and Replace Runtime Code
- Queries GitHub API to determine the
spec_versionfrom release assets - Downloads the deterministic compressed WASM:
quantus-runtime-v{SPEC_VERSION}.compact.compressed.wasm - Converts the WASM file to hexadecimal format
-
Directly replaces the runtime code in the generated JSON using
jq:jq '.genesis.raw.top."0x3a636f6465" = $wasm_hex' chain-spec.json - The key
0x3a636f6465represents the:codestorage key where runtime code is stored
- Queries GitHub API to determine the
After the script completes:
- Review the generated
node/src/chain-specs/live-resonance.jsonfile - Commit the changes to the new branch
- Create a pull request to merge into main branch
- Deterministic Runtime: Uses srtool-generated WASM artifacts that are identical across different build environments
- Transparent Process: The runtime replacement is explicit and verifiable
- Code-based Genesis: Initial state comes from the checked-out code, ensuring consistency
- Auditability: The process is scripted and uses version-controlled artifacts
The verification process confirms that a running node's genesis runtime matches the published release artifacts. This is handled by the scripts/genesis_verification.sh script.
- Running node with RPC access (must be archive node or have genesis state access)
-
curl,jq, andxxdinstalled - Knowledge of the release tag used to generate the genesis
Execute the verification script with the appropriate parameters:
./scripts/genesis_verification.sh --release-tag v0.X.Y-test-genesis --node-url http://localhost:9944Optional parameters:
-
--artifact-name: Specify exact WASM artifact name if multiple exist
The verification script performs the following steps:
-
Download Release Artifact
- Queries GitHub API to find WASM artifacts ending in
.compact.compressed.wasm - Downloads the artifact from the specified release tag from the
Quantus-Network/chain-ru-testrepository - If multiple artifacts exist, prompts for specific artifact name
- Queries GitHub API to find WASM artifacts ending in
-
Convert Artifact to Hex
- Uses
xxd -pto convert the downloaded WASM file to hexadecimal - Adds
0xprefix to match RPC response format
- Uses
-
Query Genesis Runtime from Node
-
Critical: Queries the genesis block (
0x0), not current state - Uses RPC call:
state_getStoragewith key:code(0x3a636f6465) - This retrieves the runtime WASM that was embedded in the genesis block
-
Critical: Queries the genesis block (
-
Compare WASM Strings
- Performs byte-for-byte comparison of the hex strings
- Displays beginning and end of each hex string for debugging
- Generates SHA256 hashes for easier comparison if mismatch occurs
Success: If the hex strings match exactly, the verification confirms that:
- The node's genesis runtime is identical to the published release artifact
- The network was initialized with the expected runtime version
Failure: If there's a mismatch, possible causes include:
- Wrong release tag specified
- Genesis was generated from a different runtime version
- Node is not an archive node and lacks genesis state access
- Network corruption or tampering
-
Genesis vs Current State: This verification checks the genesis runtime, not the current network state. Runtime upgrades after genesis will not affect this verification.
-
Archive Node Requirement: The node must have access to genesis state. Full archive nodes or nodes with genesis state retention are required.
-
Deterministic Builds: The verification relies on srtool-generated artifacts being deterministic across build environments.
-
Repository: The scripts use the
Quantus-Network/chain-ru-testrepository for downloading artifacts.
- "Node is not an archive node": Ensure your node has genesis state access
-
"Multiple WASM artifacts found": Use
--artifact-nameto specify the exact file -
"Failed to download artifact": Verify release tag exists and contains WASM artifacts in the
chain-ru-testrepository - Hash mismatch: Check if the correct release tag was used for genesis generation
The verification script provides debug output including:
- First and last 60 characters of each hex string
- SHA256 hashes of both WASM versions
- HTTP status codes for download attempts
- RPC response validation