Skip to content

About

Public Pixagram API node: hived, HAF, Hivemind, Jussi and TLS. For block production see pixagram-blockchain/witness.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

Pixagram API node

Full public API node for the Pixagram blockchain: consensus node, HAF indexer, Hivemind social layer, JSON-RPC routing and TLS.

This node does not produce blocks. If that is what you want, use pixagram-blockchain/witness — a two-container stack that needs a fraction of the resources.

Architecture

Internet → Caddy (TLS) → Jussi (routing + field translation) → hived / Hivemind

Jussi sends chain queries to hived and social queries to Hivemind, and rewrites Hive-derived field names on the wire so clients see Pixagram ones (hbd_balance → pxs_balance, reward_hive → reward_pixa, and so on).

Service Image Purpose
pixagram pixadock/pixagram:1.30.1 Consensus node (hived)
pixagram_haf pixadock/pixagram-haf:1.30.1 HAF node — hived plus PostgreSQL
hivemind_setup pixadock/hivemind:1.28.8 One-shot schema and role creation
hivemind_sync pixadock/hivemind:1.28.8 Block processor
hivemind pixadock/hivemind:1.28.8 PostgREST social API
jussi openresty/openresty:alpine Request routing, field translation
ssl-proxy caddy:alpine TLS termination, automatic certificates

Required: a synchronised clock

Run an NTP daemon on this machine. An API node does not produce blocks, so a drifting clock will not cost you missed blocks directly — but this node is a P2P peer that relays blocks onward, and it stamps every response it serves. A node that is seconds out of step relays late and reports a view of the chain that disagrees with everyone else's.

It matters far more if you ever add a witness to this stack. Block slots are 3 seconds; a witness whose clock is a second or two slow emits its block at the boundary of the next witness's slot, and that witness — not the one with the bad clock — is the one recorded as missing a block. On this network a single witness running 2.672 s slow caused 121 of 123 same-height block collisions and 109 missed blocks for one unlucky peer.

Check:

timedatectl | grep -E 'synchronized|NTP service'

Ubuntu ships systemd-timesyncd enabled. Debian cloud images frequently ship with no time daemon at all. If yours has none:

sudo apt-get update && sudo apt-get install -y chrony
sudo systemctl enable --now chrony

Verify the real offset from the machine itself — comparing date over SSH measures your connection latency, not your clock:

python3 - <<'PY'
import socket, struct, time, statistics
def probe(host):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.settimeout(4)
    try:
        t1 = time.time(); s.sendto(b'\x1b' + 47 * b'\0', (host, 123))
        d, _ = s.recvfrom(1024); t4 = time.time()
    finally:
        s.close()
    u = struct.unpack('!12I', d[:48])
    t2 = u[8] + u[9] / 2**32 - 2208988800
    t3 = u[10] + u[11] / 2**32 - 2208988800
    return ((t2 - t1) + (t3 - t4)) / 2
offsets = []
for host in ('pool.ntp.org', 'time.google.com', 'time.cloudflare.com'):
    for _ in range(3):
        try: offsets.append(probe(host))
        except Exception: pass
print(f'clock offset: {statistics.median(offsets):+.4f}s  ({len(offsets)} samples)'
      if offsets else 'could not reach any NTP server')
PY

Under ~50 ms is fine.


Sizing

Measured on a production node at 1.75M blocks, two weeks of uptime.

RAM, actually resident 5.4 GB
CPU, steady state 0.21 vCPU (2.7% of 8)
CPU, peak during initial sync 2.46 vCPU
Disk, chain data 5.1 GB
Disk, total including images ~15 GB

Recommended: 4 vCPU / 16 GB / 100 GB SSD.

Those RAM figures are PSS, not RSS. docker stats sums to about 10 GB because it double-counts shared memory — PostgreSQL's shared buffers and hived's mmap are counted once per process that maps them.

One thing to know before you shrink the box: HAF ships PostgreSQL tuned for full Hive, with shared_buffers at 16 GiB against a database that is currently about 1.3 GB. Postgres will not start if it cannot reserve that, so below roughly 24 GB of RAM you must retune it. The override directory is bind-mounted and empty by default:

cat > pixagram-haf/haf_postgresql_conf.d/local.conf <<'EOF'
shared_buffers = 2GB
effective_cache_size = 4GB
maintenance_work_mem = 512MB
EOF

With that in place the stack is comfortable on 8–16 GB.

Setup

git clone https://github.com/pixagram-blockchain/pixagram-node.git
cd pixagram-node

# Your public hostname. Caddy obtains and renews the certificate for it.
echo 'SITE_ADDRESS=api.example.com' > .env
chmod 600 .env

docker compose up -d
docker compose logs -f pixagram_haf

SITE_ADDRESS defaults to :80 — plain HTTP, no certificate requests. That is deliberate: a hardcoded hostname in a public template means everyone who runs it unedited asks Let's Encrypt for a certificate they cannot pass the challenge for, and those failures count against that domain's rate limits.

First sync pulls the chain over P2P and indexes it into HAF and Hivemind. The hivemind_setup container is a one-shot: it must exit 0 before hivemind_sync and hivemind will start.

Ports

Port Exposure Purpose
80, 443 public TLS termination and the public API
2001 public hived P2P — needed to sync and to serve peers
2002 public HAF node P2P
7777 local hived HTTP, direct
7778 local Hivemind, direct
7779 local HAF node HTTP, direct

Verify

# chain
curl -s -X POST https://your-host -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","method":"condenser_api.get_dynamic_global_properties","params":[],"id":1}'

# social layer
curl -s -X POST https://your-host -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","method":"bridge.get_ranked_posts","params":{"sort":"created","tag":"","limit":1},"id":1}'

Compare head_block_number against https://api.pixagram.com. Hivemind's own progress is in hivemind_app.hive_state.last_completed_block_num; on a healthy node it tracks the head block with no lag, because the app runs in HAF forking mode.

Restarting

Every long-running service is unless-stopped, so the stack comes back by itself after a host reboot. init_permissions and hivemind_setup stay at no because they are one-shot.

Upstream ships pixagram and hivemind without any restart policy, which docker treats as no. That is worth knowing if you compare against other deployments: a reboot brings such a box back with HAF, Jussi and Caddy healthy and hived not running, which looks fine and serves nothing.

Jussi is nginx, which resolves its upstreams when it parses its config and hard -fails if Hivemind is not up yet. It recovers on its own through its restart policy, but expect it to flap for up to a minute after a cold start.

Upgrading

block_log* is the chain itself — never delete it. Everything else under blockchain/ is derived state and is rebuilt by a replay:

docker compose down
rm -f pixagram/blockchain/shared_memory.bin
rm -rf pixagram/blockchain/account-history-rocksdb-storage \
       pixagram/blockchain/comments-rocksdb-storage
HIVED_EXTRA_ARGS=--replay-blockchain docker compose up -d pixagram
# once it logs "entering live mode":
docker compose up -d

Both steps are needed when enabling a plugin that adds a chainbase index: keeping the state file gives you "Inconsistency occurs. A new index is created", and skipping the replay gives you "Headblock and statefile are inconsistent".

To 1.30.1

1.30.1 is a maintenance release without a hardfork, so 1.30.0 and 1.30.1 nodes run side by side. Hivemind 1.28.8 needs the new HAF, so HAF and Hivemind resync together:

git pull                                            # 1.30.1 tags in docker-compose.yml
docker compose pull

# 1. consensus node: rebuild the state file from block_log, then start normally
docker compose stop pixagram
HIVED_EXTRA_ARGS="--force-replay --exit-before-sync" docker compose run --rm --no-deps pixagram
docker compose up -d pixagram

# 2. HAF + Hivemind: drop derived state and let them resync together
docker compose stop pixagram_haf hivemind_sync hivemind hivemind_setup
docker compose rm -f pixagram_haf hivemind_sync hivemind hivemind_setup
sudo rm -rf pixagram-haf/haf_db_store pixagram-haf/blockchain pixagram-haf/logs pixagram-haf/p2p
docker compose up -d

# 3. Jussi keeps the old Hivemind address and answers 502 on bridge.* until restarted
docker compose restart jussi

To 1.30.0 (hardfork 30)

Hardfork 30 activated on 2026-10-07 12:00:00 UTC at block 949330. Every hived on the network - API nodes included - must run 1.30.0; a node left on 1.29.0 applies the old rules after that block and drifts from the network. The procedure is the same as for 1.29.0 below:

git pull                                            # 1.30.0 tags in docker-compose.yml
docker compose pull pixagram pixagram_haf

# 1. consensus node: rebuild the state file from block_log, then start normally
docker compose stop pixagram
HIVED_EXTRA_ARGS="--force-replay --exit-before-sync" docker compose run --rm --no-deps pixagram
docker compose up -d pixagram

# 2. HAF + Hivemind: drop derived state and let them resync together
docker compose stop pixagram_haf hivemind_sync hivemind hivemind_setup
docker compose rm -f pixagram_haf hivemind_sync hivemind hivemind_setup
sudo rm -rf pixagram-haf/haf_db_store pixagram-haf/blockchain pixagram-haf/logs pixagram-haf/p2p
docker compose up -d

# 3. Jussi keeps the old Hivemind address and answers 502 on bridge.* until restarted
docker compose restart jussi

To 1.29.0 (hardfork 29)

Hardfork 29 activated on 2026-09-18 12:00:00 UTC at block 402205. Every hived on the network - API nodes included - had to run 1.29.0 before then; after activation the network rejects blocks and state produced by older versions.

hived stamps its build configuration into shared_memory.bin and refuses a state file written by another version ("Blockchain config from shared memory file mismatch current version of app"), so a plain restart is not enough. HAF's serializer likewise cannot replay into a database that already holds blocks. The upgrade is therefore: replay the consensus node from its block log, and rebuild HAF and Hivemind from scratch - the whole chain resyncs in minutes.

git pull                                            # 1.29.0 tags in docker-compose.yml
docker compose pull pixagram pixagram_haf

# 1. consensus node: rebuild the state file from block_log (~20 s), then start normally
docker compose stop pixagram
HIVED_EXTRA_ARGS="--force-replay --exit-before-sync" docker compose run --rm --no-deps pixagram
docker compose up -d pixagram

# 2. HAF + Hivemind: drop derived state and let them resync together
docker compose stop pixagram_haf hivemind_sync hivemind hivemind_setup
docker compose rm -f pixagram_haf hivemind_sync hivemind hivemind_setup
sudo rm -rf pixagram-haf/haf_db_store pixagram-haf/blockchain pixagram-haf/logs pixagram-haf/p2p
docker compose up -d

# 3. Jussi keeps the old Hivemind address and answers 502 on bridge.* until restarted
docker compose restart jussi

HAF is healthy within a few minutes; hivemind_sync logs live blocks N-N lines after 10-15 minutes. Start Hivemind together with HAF as above - started against an already-synced HAF, its massive-to-live hand-over has tripped on hive_notification_cache_pkey.

Notes

  • .env and every datadir are in .gitignore. Keep it that way — this repo is public and the datadir would otherwise leak your peer list and logs.
  • metadata must stay in the plugin list. From hived 1.28.7 the account metadata index moved out of the core chain object into that plugin, so without it every account profile reads back empty.
  • If you see Permission denied on startup, fix ownership: sudo chown -R 1000:1000 ./pixagram ./pixagram-haf

About

Public Pixagram API node: hived, HAF, Hivemind, Jussi and TLS. For block production see pixagram-blockchain/witness.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages