Pixtopia

搭建 Pixa
见证人节点

见证人验证交易,轮到自己时签署区块。先在服务器上搭建节点,再用你自己的钱包注册。

开始搭建
五个相连的区块,各装有一幅像素画
每三秒产生一个区块

01 选择服务器

你需要一个自己掌控的 Pixa 账户。在自己的电脑上登录,确认可以用账户的活跃密钥授权操作。备份账户密钥,确保电脑丢失后仍能取回。

租一台虚拟专用服务器(VPS)。即使合上笔记本电脑,它也能一直运行。在服务商的“创建服务器”页面,按下列配置开通一台专供见证人使用的新机器。

操作系统
Ubuntu Server 24.04 LTS
处理器
2 个虚拟 CPU,Intel 或 AMD (x86-64 / amd64)
内存和硬盘
4 GB 内存,至少 50 GB 固态硬盘
网络
公网 IPv4 地址,持续联网

下单前核对续费价格、存储空间和流量额度。只要保留服务器,服务商就会计费。见证人被安排出块并成功出块时可以获得奖励。注册并不保证有出块机会,也不保证奖励足以支付租金。

在服务商的防火墙或安全组中,允许任意地址连接入站 TCP 2001,让其他 Pixa 节点能连接到你。只允许你自己的 IP 通过 TCP 22 远程登录。其他入站端口保持关闭,包括供节点内部查询使用的 7777。保留出站访问权限。

服务商要求提供 SSH 密钥

SSH 密钥用于登录服务器。在 macOS 或 Linux 上打开终端,在 Windows 上打开 PowerShell。如果你已有用于该服务商的 SSH 公钥,可以沿用。要创建新密钥,请在自己的电脑上运行以下命令。

自己的电脑 · 创建登录密钥
ssh-keygen -t ed25519

按回车接受默认文件名,再设置口令。如果提示覆盖已有密钥,输入 n 保留原文件。下一条命令会显示默认文件名对应的公钥。

自己的电脑 · 显示公钥
cat ~/.ssh/id_ed25519.pub

把以 ssh-ed25519 开头的整行粘贴到服务商的 SSH 密钥栏。可以分享以 .pub 结尾的文件。同名但没有这个后缀的文件是私钥,请自己保管。

02 打开终端

在服务商控制台选中新服务器,打开控制台或网页终端,使用服务商给你的 Ubuntu 用户名登录。如果服务商提供了 SSH 命令,就将完整命令粘贴到自己电脑的终端或 PowerShell。它的格式类似 ssh ubuntu@203.0.113.10,其中地址是你服务器的实际地址。

第一次通过 SSH 连接时,先将显示的主机指纹与服务商提供的指纹核对,再确认。输入密码时屏幕上不会显示字符,这是正常的,输完按回车即可。

登录后粘贴这条命令并按回车,以管理员身份安装软件。每次重新连接都要切换一次。如果服务商已让你以 root 登录,就已经拥有管理员权限。

服务器 · 切换到管理员
sudo -i
服务器 · 检查机器
. /etc/os-release
echo "$PRETTY_NAME"
uname -m
whoami

看到以下结果再继续:Ubuntu 24.04、x86_64 和 root。后续所有命令都在这个服务器终端运行。每次只粘贴一个命令框的内容,按回车,等提示符重新出现。遇到错误先处理,再进行下一步。

03 安装工具

Docker 在容器中运行 Pixa 软件,Compose 按照指定配置启动这个容器。Chrony 校准服务器时钟,让它能赶上三秒的出块时段。下面的命令从 Ubuntu 软件源安装工具,并设置开机启动服务。

服务器 · 安装并启动服务
apt-get update &&
apt-get install -y docker.io docker-compose-v2 chrony ca-certificates python3 curl unzip &&
systemctl enable --now docker chrony &&
docker compose version
服务器 · 检查时钟
chronyc waitsync 30 0.05 0 2 && chronyc tracking

检查结果:Docker 应显示 Compose 版本,Chrony 的 Leap status 应为 Normal。命令最多等待约一分钟,直到时钟校正量低于 0.05 秒。如果超时,等一分钟后再试。

04 创建签名密钥

服务器会获得一对见证人专用密钥。私钥可以签署区块和更新见证人设置。公钥以 PIX 开头,要填入注册表单。账户的活跃密钥留在你的个人钱包中,所有者密钥离线保管。

复制下面的配置命令。看到提示后,输入你现有的公开 Pixa 账户名。程序会在链上核对名称,下载官方见证人配置,再断开密钥生成容器的网络,用节点自带的钱包生成密钥。屏幕会显示账户名和公钥。再次运行会显示同一把公钥。

服务器 · 准备见证人文件
查看配置命令
python3 - <<'PY'
import json
import os
import re
import subprocess
import tempfile
from pathlib import Path
from urllib.request import Request, urlopen

root = Path("/opt/pixa-witness")
if root.exists():
    saved = root / "public-key.txt"
    if saved.is_file():
        print(saved.read_text(), end="")
        raise SystemExit(0)
    raise SystemExit("This directory already exists. Leave its files in place and check your installation.")

print("Your public Pixa account name: ", end="", flush=True)
with open("/dev/tty") as terminal:
    name = terminal.readline().strip().removeprefix("@")
if not re.fullmatch(r"[a-z][a-z0-9.-]{2,15}", name):
    raise SystemExit("Check the spelling of your public account name and try again.")
query = {"jsonrpc": "2.0", "id": 1, "method": "condenser_api.get_accounts", "params": [[name]]}
request = Request("https://api.pixagram.com", json.dumps(query).encode(), {"Content-Type": "application/json"})
try:
    with urlopen(request, timeout=20) as reply:
        accounts = json.load(reply)["result"]
except (OSError, ValueError, KeyError):
    raise SystemExit("Could not check your account with Pixa. Check the connection and try again.") from None
if not accounts or accounts[0]["name"] != name:
    raise SystemExit("Pixa did not confirm that account. Check your name and try again.")

release = "704a68f8225ba768226dea3495095e9b9cc0bd1c"
source = "https://raw.githubusercontent.com/pixagram-blockchain/witness/" + release
image = "pixadock/pixagram:1.30.1@sha256:1f7d0ded67566af13aceb349ba0415c8b487cc96750aa7d54f7de2d28c023e0c"
os.umask(0o077)
with tempfile.TemporaryDirectory(dir="/opt") as temporary:
    work = Path(temporary) / "witness"
    data = work / "pixagram"
    data.mkdir(parents=True)
    try:
        with urlopen(source + "/docker-compose.yml", timeout=30) as reply:
            (work / "compose.yaml").write_bytes(reply.read())
        with urlopen(source + "/pixagram/config.ini", timeout=30) as reply:
            template = reply.read().decode()
    except OSError:
        raise SystemExit("Could not download the witness configuration. Check the connection and try again.") from None
    # Use this exact image for the node too. The optional upstream feed stays off.
    (work / "compose.override.yaml").write_text(
        f"services:\n  pixagram:\n    image: {image}\n  bigmac-feed:\n    profiles: [upstream-feed]\n"
    )
    (work / ".env").write_text("WITNESS_ACCOUNT=\nWITNESS_WIF=\n")
    subprocess.run(["docker", "pull", image], check=True)
    wallet = subprocess.run(
        ["docker", "run", "--rm", "-i", "--network", "none", "--log-driver", "none",
         "--entrypoint", "/home/hived/bin/cli_wallet", image, "--offline"],
        input="suggest_brain_key\n", text=True, stdout=subprocess.PIPE, check=True,
    )
    start = re.search(r'\{\s*"brain_priv_key"\s*:', wallet.stdout)
    if not start:
        raise SystemExit("The wallet did not return a key. Nothing was installed.")
    pair, _ = json.JSONDecoder().raw_decode(wallet.stdout[start.start():])
    public, private = pair["pub_key"], pair["wif_priv_key"]
    if not re.fullmatch(r"PIX[1-9A-HJ-NP-Za-km-z]{49,51}", public) or not re.fullmatch(r"5[1-9A-HJ-NP-Za-km-z]{50}", private):
        raise SystemExit("Unexpected key format. Nothing was installed.")
    (data / "config.ini").write_text(template + f'\nwitness = "{name}"\nprivate-key = {private}\n')
    (work / "feed-key.json").write_text(json.dumps({"account": name, "publicKey": public, "privateKey": private}))
    display = f"Account: @{name}\nSigning public key:\n{public}\n"
    (work / "public-key.txt").write_text(display)
    work.rename(root)
print(display, end="")
PY

确认账户名是你自己的,并且出现了一行以 PIX 开头的公钥。稍后注册时要用这一行。私密文件位于 /opt/pixa-witness 下,拥有服务器管理员权限的人都可以读取。

05 同步到最新区块

启动节点。它需要下载并验证历史区块,才能签署新区块。首次同步可能需要数小时,关闭终端不会中断同步。

服务器 · 启动节点
cd /opt/pixa-witness &&
docker compose up -d pixagram &&
docker compose ps

pixagram 服务应显示 Up 或 running。用下一条命令查看实时日志。按 Ctrl + C 返回提示符,节点会继续运行。

服务器 · 查看实时日志
cd /opt/pixa-witness && docker compose logs --tail 15 -f pixagram

看到 entering live mode 时,检查最新区块。命令会把你的节点与 Pixa 公共节点对比两次,中间相隔六秒。以后也可以随时复查。

服务器 · 检查是否就绪
查看同步检查命令
cd /opt/pixa-witness && docker compose exec -T pixagram python3 - <<'PY'
import json
import time
from datetime import datetime, timezone
from urllib.request import Request, urlopen

def head(url):
    call = {"jsonrpc": "2.0", "id": 1, "method": "condenser_api.get_dynamic_global_properties", "params": []}
    request = Request(url, json.dumps(call).encode(), {"Content-Type": "application/json"})
    with urlopen(request, timeout=12) as reply:
        state = json.load(reply)["result"]
    return state["head_block_number"], datetime.fromisoformat(state["time"] + "+00:00")

previous = None
for sample in range(2):
    try:
        local, stamp = head("http://127.0.0.1:7777")
        network, _ = head("https://api.pixagram.com")
    except (OSError, ValueError, KeyError):
        raise SystemExit("Could not read both nodes. Check the log and try again later.") from None
    age = (datetime.now(timezone.utc) - stamp).total_seconds()
    print(f"Your block {local:,} | Network block {network:,} | Your block is {age:.0f}s old", flush=True)
    if sample == 0:
        previous = local
        time.sleep(6)
ready = local > previous and abs(network - local) <= 3 and -3 <= age <= 15
print("Ready to register." if ready else "Still catching up. Wait and run this check again.")
PY

看到 Ready to register. 再注册。如果仍在追赶进度,让节点继续运行,稍后重新检查,直到它能跟上新区块。

06 注册见证人

回到自己电脑上的 Pixtopia。注册会把你的账户与服务器的签名公钥公开关联。准备一个公开页面或帖子链接,让投票人知道是谁在维护节点、怎样联系你。

服务器 · 再次显示公开信息
cat /opt/pixa-witness/public-key.txt
  1. 登录上面显示的账户。打开见证人,在你的见证人下选择成为见证人。
  2. 在你的见证人页面中填写你的公开 HTTPS 链接。将以 PIX… 开头的整行粘贴到签名公钥。
  3. 其余字段表示你对网络参数的投票。编写本指南时,网络中位数是开户费用 20 PIXA、最大区块 2097152 字节、PXS 利率百分之 0。开户费用是你建议采用的网络参数。注册见证人本身免费。
  4. 选择核对,再选显示完整交易。核对 witness_update 里的账户、网址、完整 block_signing_key 和参数。确认一致后,在自己的设备上使用 PIXA Keychain 或 Pixtopia 钱包的活跃密钥批准。

检查注册结果:打开见证人 → 你的页面,核对显示的签名公钥与服务器的公钥是否相同。“运行中”表示密钥已启用。真正出块后,最近区块才会更新。20 名当选见证人与一个轮换的候补席位分享出块时段。节点就绪后可以请支持者为你投票。

07 发布喂价

见证人还要报告一个 PXS 值多少 PIXA。PXS 跟踪美国一个巨无霸汉堡的价格。每个见证人自行选择计算方法,并对公布的价格负责。Pixtopia 使用 Pixa Markets 流动性池的成交数据。查看计算方法和发布程序。

要手动发布,打开见证人 → 发布价格,输入每 1 PXS 对应的 PIXA 数量,检查后在钱包中批准。要按流动性池价格每小时自动发布,请执行以下步骤。

配置每小时自动发布

注册后再开始。命令会下载指定日期的发布程序,校验文件,在 Node 24 中安装指定版本的依赖,并运行测试。程序使用见证人专用密钥,账户密钥留在个人设备上。

服务器 · 安装并测试发布程序
cd /opt/pixa-witness &&
release=pixa-witness-feed-2026-11-28 &&
curl -fLsS --retry 3 "https://pixtopia.net/witness-feed/$release.zip" -o "$release.zip" &&
echo "d0c008c4f461b329f9e774893b92ce0540ad9edaa2c5ac779f8c1ee71b289512  $release.zip" | sha256sum -c - &&
unzip -oq "$release.zip" &&
docker run --rm -v "$PWD/$release:/feed" -w /feed node:24-bookworm-slim sh -ec 'npm ci --ignore-scripts && node --test tests/feed-price.test.mjs'

创建启动命令,预览首次更新。程序会核对专用密钥是否匹配已注册公钥,并显示确切汇率。不加选项运行只会预览。

服务器 · 预览自己的报价
cd /opt/pixa-witness && cat > price-feed <<'SH'
#!/bin/sh
set -eu
cd /opt/pixa-witness
exec /usr/bin/docker run --rm \
  -v "$PWD/pixa-witness-feed-2026-11-28:/feed:ro" -w /feed \
  -v "$PWD/feed-key.json:/run/witness-key.json:ro" \
  -e PIXA_MARKET_URL=https://pixa.markets \
  node:24-bookworm-slim node scripts/pixagram/price-feed.mjs \
  --signing-key /run/witness-key.json "$@"
SH
chmod 700 /opt/pixa-witness/price-feed && /opt/pixa-witness/price-feed

确认 base 为 1.000 PXS,quote 以 PIXA 计价。如果测试或预览失败,先解决错误。运行下一条命令,即表示你授权在链上定期发布真实价格更新。它会立即发布一次,此后只要定时器启用,就每小时发布一次。

服务器 · 现在发布,之后每小时发布
cat > /etc/systemd/system/pixa-witness-feed.service <<'UNIT'
[Unit]
Description=Publish this Pixa witness price
After=docker.service network-online.target
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/opt/pixa-witness/price-feed --broadcast
UNIT
cat > /etc/systemd/system/pixa-witness-feed.timer <<'UNIT'
[Unit]
Description=Update this witness price hourly
[Timer]
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=timers.target
UNIT
systemctl daemon-reload &&
systemctl start pixa-witness-feed.service &&
systemctl enable --now pixa-witness-feed.timer &&
systemctl list-timers pixa-witness-feed.timer

核对结果:在见证人页面查看价格更新,定时器也应列出下次运行时间。超过七天未更新的价格会从网络中位数计算中剔除。

服务器 · 查看最近一次发布结果
journalctl -u pixa-witness-feed.service -n 12 --no-pager

08 维护见证人节点

收藏你的见证人页面,定期查看最近区块、错过的区块和价格更新。候补见证人可能要等一段时间才轮到第一次出块。如果错过的区块数不断增加,说明轮到你时网络没有及时收到你的区块。

服务器 · 检查状态和剩余空间
cd /opt/pixa-witness && docker compose ps
df -h /opt/pixa-witness
chronyc tracking

留足磁盘空间供区块链增长。安装 Ubuntu 安全更新,关注 Pixa 版本,并在计划中的硬分叉(网络规则变更)前按说明升级。本指南固定使用 1.30.1 版,重新运行配置命令只会保留原密钥和版本。官方版本和升级说明 ↗

下线或更换服务器

在见证人页面选择停止出块,检查后用活跃密钥签名。等页面显示已停止,并等当前轮次结束。此后新的排班不再使用你的公钥,账户和已获得的选票会保留。

服务器 · 关闭已启用的报价定时器
systemctl disable --now pixa-witness-feed.timer
服务器 · 停止节点并保留数据
cd /opt/pixa-witness && docker compose stop -t 120 pixagram

要在原机器上恢复,请重新启动并检查同步状态,然后在见证人 → 设置恢复公钥。如果服务器丢失或被入侵,先通过钱包禁用旧密钥,用全新的签名密钥搭建替代节点,同步后在设置中登记新公钥。每把签名密钥只用于一台出块节点。重新启用定时器前再次预览价格。

加密备份私密配置和恢复密钥,保存在自己掌控的地方。请勿向客服发送 config.ini、feed-key.json 或钱包密钥。永久退役时,先停用见证人,保存所需资料,然后取消服务器租用。

排查问题

无法登录或粘贴命令

SSH 超时时,打开服务商的网页控制台。核对服务器地址、登录名以及针对你当前 IP 的 TCP 22 入站规则。部分控制台提供“剪贴板”或“粘贴文本”菜单。在 Linux 终端用 Ctrl + Shift + V,macOS 用 Command + V。没有复制按钮时,可展开命令,选中文字并自行复制。

Docker 安装或时钟检查失败

重做第 2 步的机器检查。Ubuntu 24.04 的两个 Docker 包均来自 universe 软件源。如果 apt 找不到它们,在软件源设置中启用该源并重做第 3 步。时钟超时时运行 chronyc sources -v,标有 ^* 的行就是选用的时间源。确认允许出站 UDP 123 后重新检查。

节点反复重启或区块高度停止增长

按第 5 步查看日志,按第 8 步检查磁盘空间。确认服务商防火墙放行 TCP 2001,服务器能连接 api.pixagram.com:2001。首次同步时落后很多是正常的,只要高度还在上升即可。在追上链之前可以保持节点运行,暂缓注册签名公钥。

注册后一直没有出块

将第 6 步的完整公钥与见证人页面核对,再查同步状态、得票和错过的区块。如果最近区块和错过数都没有变化,可能还没轮到你。若错过数上升,检查时钟和日志。维修耗时较长时,先通过钱包停止出块。

预览提示密钥不匹配

将 public-key.txt 中的账户和公钥与见证人页面核对。已停止的见证人会禁用签名密钥。等节点就绪后恢复正确公钥,等链上显示变更,再做一次预览。预览成功后才能启用定时器。

版本和网络设置核对日期 . 见证人配置 ↗ · Pixa 节点运营参考 ↗ · 服务器要求 ↗