Production engineering guide for blockchain devops in Web3 and blockchain systems.
Blockchain DevOps is the discipline of reliably building, deploying, monitoring, and operating blockchain nodes, smart contracts, and full-stack dApp services in production. It matters when a system must maintain finality, uptime, and consistency across heterogeneous environments—on-prem, cloud, edge, or decentralized clusters—where node failures, consensus delays, and contract upgrades can disrupt user experience and financial value.
Deploying a blockchain node involves orchestrating binaries, data directories, configuration, and startup scripts across machines. The process begins with a static configuration file defining the network, genesis block, and node behavior.
chain_id = "ethereum-mainnet"
network = "mainnet"
rpc_addr = "0.0.0.0:8545"
ws_addr = "0.0.0.0:8546"
datadir = "/var/lib/blockchain"
pruning = "full"
sync_mode = "snap"
genesis_file = "/etc/blockchain/genesis.json"
The node binary is started via systemd with a unit file that ensures restart on failure and automatic updates.
# /etc/systemd/system/blockchain-node.service
[Unit]
Description=Blockchain Node
After=network.target
[Service]
Type=simple
User=blockchain
ExecStart=/usr/local/bin/blockchain-node --config /etc/blockchain/config.toml
Restart=on-failure
RestartSec=5s
Environment="RUST_LOG=info"
Environment="BLOCKCHAIN_NETWORK=mainnet"
[Install]
WantedBy=multi-user.target
A deployment script uses git and docker to manage updates, with a deploy.sh script that checks out a specific commit, builds the binary, and applies the config.
#!/bin/bash
set -e
BRANCH="main"
DEPLOY_DIR="/opt/blockchain/deploy"
NODE_BINARY="/usr/local/bin/blockchain-node"
cd "$DEPLOY_DIR"
git fetch origin "$BRANCH"
git checkout origin/"$BRANCH"
# Build the binary
make build
# Copy binary
cp target/release/blockchain-node "$NODE_BINARY"
# Copy config
cp config.toml /etc/blockchain/config.toml
# Reload systemd unit
systemctl reload blockchain-node.service
echo "Deployment completed: $(git rev-parse HEAD)"
A common failure mode is missing genesis.json on startup. The node logs this error:
Error: Failed to open genesis file: /etc/blockchain/genesis.json
Caused by: No such file or directory (os error 2)
The root cause is often a missing --genesis-file flag or a misconfigured datadir. The systemctl status blockchain-node.service output reveals RestartCount=3, indicating a boot loop from a missing config.
Smart contracts are deployed as immutable artifacts with versioned upgrade mechanisms. The deployment pipeline uses hardhat or foundry to compile and deploy, then updates a registry.
// contracts/contracts.json
{
"MyToken": {
"address": "0x1234567890abcdef1234567890abcdef12345678",
"abi": [ ... ],
"bytecode": "0x608060405234801561001057600080fd5b50604051610021906100e5",
"version": "1.0.2",
"deployedAt": "2024-03-15T10:30:00Z"
}
}
Deployment is triggered via a deploy-contracts.sh script that compiles, deploys to a network, and writes the registry.
#!/bin/bash
set -e
NETWORK="mainnet"
DEPLOY_DIR="./deployments"
npx hardhat compile
npx hardhat deploy --network $NETWORK
# Write deployment registry
cat > $DEPLOY_DIR/contracts.json << EOF
{
"MyToken": {
"address": "$(npx hardhat get-address MyToken --network $NETWORK)",
"abi": "$(cat build/contracts/MyToken.json | jq -c .abi)",
"bytecode": "$(cat build/contracts/MyToken.json | jq -c .bytecode)",
"version": "$(cat package.json | jq -r .version)",
"deployedAt": "$(date -Iseconds)"
}
}
EOF
# Push to Git
git add $DEPLOY_DIR
git commit -m "Deploy MyToken v$(cat package.json | jq -r .version) to $NETWORK"
git push origin main
A subtle failure occurs when hardhat get-address returns a non-JSON output. The script assumes jq -c but the get-address command outputs raw 0x... without quotes, leading to invalid JSON.
{
"MyToken": {
"address": 0x1234567890abcdef1234567890abcdef12345678,
...
}
}
The deployment fails silently because abi and bytecode are missing. The fix is to wrap get-address in jq -r and use --format json.
Nodes must be monitored continuously. The curl-based health check is common, with a /health endpoint returning JSON.
{
"status": "healthy",
"chain": "ethereum-mainnet",
"head_block": 19876543,
"last_synced": "2024-03-15T10:30:15Z",
"syncing": true,
"peers": 53,
"rpc_latency_ms": 124,
"node_version": "v1.2.3"
}
A systemd timer runs curl every 30 seconds to validate health:
# /etc/systemd/system/health-check.timer
[Unit]
Description=Check blockchain node health
Requires=health-check.service
[Timer]
OnCalendar=*-*-* 00:00:00
Persistent=true
[Install]
WantedBy=timers.target
# /etc/systemd/system/health-check.service
[Unit]
Description=Health check for blockchain node
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/health-check.sh
StandardOutput=journal
StandardError=journal
#!/bin/bash
set -e
URL="http://localhost:8545/health"
TEMP_FILE="/tmp/health-check.json"
curl -s -f -o "$TEMP_FILE" "$URL"
STATUS=$(jq -r '.status' "$TEMP_FILE")
if [ "$STATUS" != "healthy" ]; then
echo "Node health check failed: $STATUS" >&2
exit 1
fi
# Log latency
LATENCY=$(jq -r '.rpc_latency_ms' "$TEMP_FILE")
echo "Health check: $LATENCY ms" >> /var/log/blockchain/health.log
When the node is slow, rpc_latency_ms exceeds 300ms, and the health-check.service fails, triggering a systemctl alert. The journalctl log shows:
Mar 15 10:31:45 node01 health-check[1234]: Node health check failed: syncing
Mar 15 10:31:45 node01 health-check[1234]: Health check: 342 ms
A silent failure mode is syncing: true but head_block not progressing. The node is stuck at the same block for hours. The systemctl status blockchain-node.service shows Active: active (running) since Thu 2024-03-14 08:00:00 UTC, but journalctl -u blockchain-node.service reveals no new blocks logged, even though the rpc_latency_ms is low.
Node state is stored in datadir, a directory tree with chains, snapshots, and logs. Backups are performed daily using borg or rsync.
#!/bin/bash
set -e
DATADIR="/var/lib/blockchain"
BACKUP_DIR="/backups/blockchain"
DATE=$(date +%Y-%m-%d)
borg create \
--compression zstd \
--exclude 'chains/mainnet/snapshots/*' \
--exclude 'chains/mainnet/indices/*' \
"$BACKUP_DIR::$DATE" \
"$DATADIR"
# Prune old backups
borg prune \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
"$BACKUP_DIR"
A failure occurs when borg create runs during a snapshot export. The chains/mainnet/snapshots directory is locked, and borg skips it. The backup is missing recent state. The fix is to run borg during a maintenance window or use borg mount to freeze the directory.
# During maintenance
borg mount "$BACKUP_DIR::2024-03-14" /mnt/backup
cp -r /var/lib/blockchain/chains/mainnet/snapshots/* /mnt/backup/chains/mainnet/snapshots/
umount /mnt/backup
The borg repository is monitored via borg info and borg check, which detects corruption.
borg check --verify-data --progress /backups/blockchain
If borg check reports 100 missing data chunks, the node is likely to fail during restore due to missing snapshot data.
Upgrades are deployed via blue-green or rolling strategies. A new version is built and deployed to a staging node, then promoted to production.
# deploy-staging.sh
export NODE_VERSION="v1.3.0"
# Build new binary
make build
# Copy to staging
rsync -avz --delete target/release/blockchain-node staging-node:/usr/local/bin/
# Update config
scp config-staging.toml staging-node:/etc/blockchain/config.toml
# Start new service
ssh staging-node "systemctl restart blockchain-node.service"
# Verify health
curl -f http://staging-node:8545/health
When staging-node reports syncing: false, the node is fully synced. The production node is upgraded via ansible:
- name: Upgrade blockchain production nodes
hosts: production
become: yes
vars:
node_version: "{{ lookup('env', 'NODE_VERSION') }}"
tasks:
- name: Stop current node
systemd:
name: blockchain-node.service
state: stopped
- name: Copy new binary
copy:
src: "target/release/blockchain-node"
dest: "/usr/local/bin/blockchain-node"
mode: "u+x"
- name: Update config
template:
src: config-production.toml.j2
dest: "/etc/blockchain/config.toml"
- name: Start node
systemd:
name: blockchain-node.service
state: started
enabled: yes
- name: Verify health
uri:
url: "http://{{ inventory_hostname }}:8545/health"
return_content: yes
status_code: 200
A common failure is missing blockchain-node.service after systemd restart. The service fails with:
Failed to start blockchain-node.service: Unit blockchain-node.service not found
The root cause is a missing blockchain-node.service in /etc/systemd/system, often due to a misconfigured ansible playbook or a missing systemctl daemon-reload.
Rollback is triggered when health check fails or head_block stalls.
#!/bin/bash
set -e
NODE_HOST="prod-node"
BACKUP_DIR="/backups/blockchain"
DATE=$(date +%Y-%m-%d)
# Copy previous binary
rsync -avz "$BACKUP_DIR::$DATE/usr/local/bin/blockchain-node" "$NODE_HOST:/usr/local/bin/"
# Copy previous config
rsync -avz "$BACKUP_DIR::$DATE/etc/blockchain/config.toml" "$NODE_HOST:/etc/blockchain/"
# Restart
ssh "$NODE_HOST" "systemctl restart blockchain-node.service"
# Verify
curl -f "http://$NODE_HOST:8545/health"
The rollback script assumes the borg backup includes the bin and etc directories. If the config.toml is missing, the node fails to start with:
Error: Failed to parse config: missing field `rpc_addr`
The fix is to verify the backup layout and use borg list to inspect the archive.
When a node fails, the first step is journalctl with --since and --follow.
journalctl -u blockchain-node.service --since "2024-03-15 10:00:00" --follow
Common error patterns:
last_synced remains unchanged for hours. Check peers count and rpc_latency_ms. A high latency indicates network issues.Error: Failed to open genesis file: ... — verify datadir, genesis_file, and --genesis-file flag.chain_id in config does not match genesis.json. The node connects to a wrong network.Contract not found or Method not found — the abi is missing or incomplete in contracts.json.A production incident occurs when head_block stops increasing. The systemctl status blockchain-node.service shows Active: active (running), but journalctl reveals:
2024-03-15T10:30:00Z [INFO] Syncing from block 19876543
2024-03-15T10:30:05Z [INFO] Syncing from block 19876543
2024-03-15T10:30:10Z [INFO] Syncing from block 19876543
The node is stuck at block 19876543. The fix is to restart the blockchain-node.service, which triggers re-sync from the last block.
A final, sharp edge: when borg is used for backups, but rsync is used for daily file syncs, the datadir is inconsistent. The chains/mainnet/snapshots are updated via rsync, but borg includes an older version. The restore script must run rsync before borg extract to ensure consistency.
This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy