Skip to content
nervosnetworkPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

5 watching

Forks

Repository files navigation

Usage

Check local script changes before a Linux test

Start each published-package test from the committed sync.sh. From the ckb-sync checkout, inspect any local overrides from earlier runs.

git diff HEAD -- sync.sh

If the diff contains only edits you want to discard, restore the working copy.

git restore --source=HEAD --worktree -- sync.sh

The committed script leaves both assume-valid targets empty and keeps cp ../ckb commented out. Enable that copy only to test a binary you placed at ../ckb.

Run private v0.211.0-rc4 on mainnet with an all-zero assume-valid target

run.sh ckb-private selects the latest published v0.211* Release from nervosnetwork/ckb-private, downloads the Linux x86_64 package, and starts a fresh mainnet sync test. The new round clears the existing mainnet test data. The runner accepts a release source. An exact tag such as v0.211.0-rc4 must match the latest release selected by the runner for this recipe.

On first use, authenticate GitHub CLI as root with a GitHub account that can read the private repository.

sudo gh auth login --hostname github.com --web

After reviewing local script changes, run the block below from the checkout. It uses the runner's Release selection rule to check for rc4 before restoring sync.sh, setting the all-zero target, and starting the test. If it reports another tag, stop here. The runner queries the latest release again at startup. The check leaves the version filter in sync.sh as committed.

if latest_tag=$(sudo gh api --hostname github.com repos/nervosnetwork/ckb-private/releases \
  --jq '[.[] | select(.draft != true and (.published_at // "") != "") | select(.tag_name | startswith("v0.211"))] | sort_by([.published_at, .tag_name]) | last | .tag_name // empty') &&
  [ "$latest_tag" = v0.211.0-rc4 ]; then
    git restore --source=HEAD --worktree -- sync.sh &&
      sed -i 's/^mainnet_assume_valid_target=.*/mainnet_assume_valid_target="0x0000000000000000000000000000000000000000000000000000000000000000"/' sync.sh &&
      sudo bash run.sh ckb-private
else
    printf 'Expected v0.211.0-rc4, found %s. Sync was not started.\n' "${latest_tag:-no release}" >&2
fi

After the mainnet RPC reports the selected version series, the runner sets env.txt to mode 1 and is_exec=0 for a round without periodic restarts. A failed start preserves the previous state.

If the all-zero target is only for this round, check git diff HEAD -- sync.sh after startup and restore the script once you confirm that the target is the only edit. The running node keeps the target it was started with.

Run public v0.210 on testnet without periodic restarts

After reviewing local script changes, run this block from the checkout when ready to replace the current round and clear old testnet data. The committed empty testnet_assume_valid_target lets CKB use its built-in target. env.txt selects mode 2 and requests a new round. The runner command takes no arguments for this recipe.

git restore --source=HEAD --worktree -- sync.sh &&
  printf '2\n1\n' | sudo tee env.txt >/dev/null &&
  sudo bash run.sh

Scheduled Linux tests

# Check the active round every two hours; start a new round when env.txt requests it.
20 */2 * * * cd /home/ckb/scz/ckb-sync && sudo bash run.sh >> run.log 2>&1
# Statistics are collected every 20 minutes.
10,30,50 * * * * cd /home/ckb/scz/ckb-sync && sudo bash get_diff.sh >> get_diff.log 2>&1

With no arguments, sudo bash run.sh follows env.txt and selects public 210 whenever a new round is needed. Use sudo bash run.sh ckb to manually start a fresh public 210 mainnet round.

run.sh and get_diff.sh share a per-directory lock. A manual run waits for an active runner or collector to finish; scheduled invocations skip while startup is in progress. The two cron entries can stay enabled when using run.sh.

Release source

Scheduled no-argument run.sh and run.ps1 always start new rounds from the public nervosnetwork/ckb repository, selecting the most recently published v0.210* release. Manual sync defaults to the same public 210 series. Private 211 releases are selected only by an explicit argument for that manual invocation:

Invocation Repository Release prefix
Scheduled run.sh / run.ps1 nervosnetwork/ckb v0.210*
Manual sync with no source argument, or ckb nervosnetwork/ckb v0.210*
Manual sync with ckb-private nervosnetwork/ckb-private v0.211*

On Linux, prefer run.sh ckb-private above for automatic round-state updates. The lower-level sync.sh keeps its optional third source argument:

cd /home/ckb/scz/ckb-sync
sudo bash sync.sh main 0              # Public 210, mainnet.
sudo bash sync.sh main 0 ckb          # Explicit public 210, mainnet.
sudo bash sync.sh main 0 ckb-private  # Private 211, mainnet.
sudo bash sync.sh test 0 ckb-private  # Private 211, testnet.

On Windows, use -ReleaseRepo. The existing third positional argument remains the metrics host:

powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0
powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0 -ReleaseRepo ckb
powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0 -ReleaseRepo ckb-private
powershell -ExecutionPolicy Bypass -File .\sync.ps1 test 0 -ReleaseRepo ckb-private
# Optional metrics host with a private release:
powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0 47.131.93.120 -ReleaseRepo ckb-private

Public releases do not require GitHub CLI. For private releases, install gh and authenticate an account with access to nervosnetwork/ckb-private:

sudo gh auth login
sudo gh release list --repo nervosnetwork/ckb-private --limit 5

The supplied Linux cron runs as root, so the manual Linux commands use sudo too. This keeps cache and report ownership consistent. Private sync therefore uses sudo gh auth login under that same account, or the GitHub CLI-supported GH_TOKEN in its execution environment. On Windows, use gh auth login as the account that runs sync. GitHub CLI release access is separate from Git/SSH access used by git pull. Both sources provide release packages; compiling CKB is not required.

Release lookup, download, and archive validation finish before stopping CKB or clearing the target network directory. Downloads are cached separately under .release-cache/ckb and .release-cache/ckb-private. An unavailable release or asset fails without falling back to the other source.

A successful manual sync starts a fresh round and clears that network's existing data directory. run.sh ckb-private handles the shared lock and env.txt update automatically. If calling sync.sh directly instead, pause both cron entries and wait for active invocations to finish; then mark the round as already running before restoring the entries. The lower-level private mainnet command is:

cd /home/ckb/scz/ckb-sync
sudo bash sync.sh main 0 ckb-private && printf '1\n0\n' | sudo tee env.txt >/dev/null

The sudo tee handles env.txt created by the root-run cron job.

On Windows:

powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0 -ReleaseRepo ckb-private
if ($LASTEXITCODE -eq 0) { "1`n0" | Set-Content -Encoding ASCII .\env.txt }

For testnet, use test and write mode 2 instead of 1. Modes 1/2 with is_exec=0 let the current manual round continue. After that round completes, the next scheduled new round returns to public 210 automatically.

Manual Linux restart

bash restart_mainnet.sh      # Normal restart.
bash restart_mainnet.sh 0    # Restart with --assume-valid-target set to 0x + 64 zeros.
bash restart_testnet.sh      # Normal testnet restart.
bash restart_testnet.sh 0    # Testnet restart with the same zero target.

The scripts print ./ckb --version and the full ckb run command before launching. They reuse the existing node directory and data. Exactly one matching network node directory must exist alongside the scripts.

Windows rough version

# Start mainnet, without restart report.
powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0

# Start testnet, restart report.
powershell -ExecutionPolicy Bypass -File .\sync.ps1 test 1

# Collect sync diff and send report when ready.
powershell -ExecutionPolicy Bypass -File .\get_diff.ps1

For scheduled Windows runs, use run.ps1 instead of calling sync.ps1 directly. run.ps1 follows env.txt like the Linux run.sh: mode 1/2 starts a without-restart round once, then later timer runs do nothing until get_diff.ps1 advances env.txt. Mode 3/4 uses flag 1, writes result_*.log, and periodically restarts the existing node while is_exec=0. Windows active modes are controlled by mode_sequence.txt; the default 1,2 runs mainnet, sends a report, then runs testnet and repeats without periodic restarts. Change it to 1,2,3,4 to restore the four-mode cycle. For Windows Task Scheduler, prefer get_diff_task.ps1 for diff collection because it wraps get_diff.ps1 with task-friendly logging. If Task Scheduler has quoting issues with PowerShell actions, use get_diff_task.cmd auto as the scheduled action. If Task Scheduler waits on PowerShell and leaves the task in 0x41301 running state, use get_diff_task_detached.cmd auto. See docs/windows.md for the current stable Windows deployment procedure. The Windows run.ps1 and get_diff_task.ps1 entry points also check for script updates every six hours through update_scripts.ps1, using the current branch's upstream and fast-forward-only pulls. Existing sync rounds continue normally.

The Windows report reuses sendMsg.py and the same .env / .without_restart_env files. It includes platform: Windows (PowerShell) near the top of the report. Grafana links detect the metrics host from https://ifconfig.me/ip by default. Override it with CKB_SYNC_METRICS_HOST or the optional script argument when needed:

powershell -ExecutionPolicy Bypass -File .\sync.ps1 main 0 47.131.93.120
powershell -ExecutionPolicy Bypass -File .\get_diff.ps1 47.131.93.120

Release-source regression checks

These checks use local fixtures without contacting GitHub or starting CKB:

python3 tests/linux-release-sources.Tests.py
powershell -NoProfile -ExecutionPolicy Bypass -File .\tests\windows-release-sources.Tests.ps1

Instructions

Python3 and packages such as discord and python-dotenv need to be installed on the server for testing synchronization.

sudo apt-get install jq python3-pip -y
sudo pip install discord python-dotenv

Please configure the .env file for sending test reports.

DISCORD_CHANNEL_ID=YOUR_DISCORD_CHANNEL_ID
DISCORD_TOKEN=YOUR_DISCORD_TOKEN

exit the SSH session

  1. control + A
  2. D

Debug

If there are problems with CKB sync, you can use the following command and enable the debug configuration in the ckb.toml file to help identify the issue.

curl -s -X POST 127.0.0.1:8114  -H 'Content-Type: application/json' -d '{ "id": 42, "jsonrpc": "2.0", "method": "sync_state", "params": [] }' | jq
curl -s -X POST 127.0.0.1:8114  -H 'Content-Type: application/json' -d '{ "id": 42, "jsonrpc": "2.0", "method": "get_peers", "params": [] }' | jq | grep last_common_header_number

Line 13 of ckb.toml

filter = "info,ckb=debug"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages