Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ci/official/*.patch -text
packaging/setup/*.bat text eol=crlf
206 changes: 206 additions & 0 deletions .github/workflows/setup-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: Set-up script test

# The guided set-up (packaging/setup) in the published packages of Linux, Windows and macOS, used as a
# user would: answers typed on stdin, the snapshot downloaded, the node started up to the mainnet
# head; then a second run that must change nothing, and a full berkeleydb configuration with a wrong
# answer first.
on:
push:
tags: ['setup-test-*']
workflow_dispatch:

permissions:
contents: read

env:
TAG: community-v4.2.532-community.14

jobs:
setup:
name: Set-up (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-24.04
package: '*-linux-x64.tar.gz'
node: ./node
- os: windows
runner: windows-2022
package: '*-windows-x64.zip'
node: ./node.exe
- os: macos
runner: macos-14
package: '*-macos-arm64.tar.gz'
node: ./node
runs-on: ${{ matrix.runner }}
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4

- name: Checkout submodules
run: git submodule update --init -- third-party/thrift-interface-definitions

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Python packages
run: python -m pip install --quiet thriftpy2 base58 pynacl

- name: Package with the set-up script
env:
GH_TOKEN: ${{ github.token }}
PACKAGE: ${{ matrix.package }}
run: |
mkdir packages
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir packages --pattern "$PACKAGE"
pkg=$(ls packages/$PACKAGE | grep -v glibc | head -1)
case "$pkg" in *.zip) unzip -q "$pkg" ;; *) tar -xzf "$pkg" ;; esac
if [ "${{ matrix.os }}" = windows ]; then
cp packaging/setup/setup.bat packaging/setup/setup.ps1 csnode/
else
cp packaging/setup/setup.sh csnode/ && chmod +x csnode/setup.sh
fi
sed -i.bak 's/^executor_multi_instance=.*/executor_multi_instance=true/' csnode/config.ini && rm csnode/config.ini.bak
[ "${{ matrix.os }}" != macos ] || xattr -dr com.apple.quarantine csnode 2>/dev/null || true
python ci/testnet/gen_keys.py 1 keys >/dev/null
cp keys/n1/NodePublic.txt keys/n1/NodePrivate.txt csnode/
cp -a csnode csnode-clean
cat > setup-run.sh <<'EOF'
# setup-run.sh <folder> <answers, one per line, \n separated>
dir=$1; answers=$2
cd "$dir"
if [ -f setup.bat ]; then
printf "$answers" | cmd //c setup.bat
else
printf "$answers" | ./setup.sh
fi
EOF
cat > check-config.py <<'EOF'
# check-config.py <config.ini> <section> <expected "k=v k=v"> ...
import sys
lines = open(sys.argv[1], newline="").read().replace("\r\n", "\n").split("\n")
sections, cur = {}, None
for l in lines:
s = l.strip()
if s.startswith("["):
cur = s
sections.setdefault(cur, [])
elif cur and s and not s.startswith(";"):
sections[cur].append(s)
bad = 0
for i in range(2, len(sys.argv), 2):
got = " ".join(sections.get("[" + sys.argv[i] + "]", []))
ok = got == sys.argv[i + 1]
bad += not ok
print(("ok " if ok else "FAIL") + f" [{sys.argv[i]}] {got!r}" + ("" if ok else f" expected {sys.argv[i + 1]!r}"))
sys.exit(1 if bad else 0)
EOF

- name: First set-up (pruned, lmdb, snapshot from GitHub, share, do not start)
run: |
# storage, database, first start, share, executor, start, write
bash setup-run.sh csnode '\n\n\n\n\nno\n\n' 2>&1 | tee setup1.txt | grep -av '^download-snapshot: .*%' | tail -40
python check-config.py csnode/config.ini snapshot "serve=on fetch=off" \
storage "db_backend=lmdb checkpoint_every=100000 checkpoint_keep=2 prune_keep_blocks=1000"
ls csnode/config.ini.bak-* && test "$(ls csnode/config.ini.bak-* | wc -l)" -eq 1
test -f csnode/snapshot.json && echo "snapshot restored"
ls csnode/db

- name: Start the node up to the head
run: |
cd csnode
( rc=0; ${{ matrix.node }} --config-file config.ini </dev/null > stdout.log 2>&1 || rc=$?; echo "the node exited with status $rc" > node-exit.txt ) &
sleep 2
pid=
[ "${{ matrix.os }}" = windows ] || pid=$(pgrep -n -f -- '--config-file config.ini' || true)
echo "NODE_PID=$pid" >> "$GITHUB_ENV"
cd ..
python ci/snapshot/check_node.py wait-head --api 127.0.0.1:9090 --timeout-min 45 \
--exit-file csnode/node-exit.txt --api-grace-min 6 || { tail -n 60 csnode/stdout.log | cut -c1-300; exit 1; }
grep -ah 'snapshot.json verified\|STATE DIGEST' csnode/log/log_*.txt | tail -3 | cut -c1-200

- name: Stop the node
if: always()
run: |
if [ "${{ matrix.os }}" = windows ]; then
taskkill //F //IM node.exe >/dev/null 2>&1 || true
taskkill //F //IM java.exe >/dev/null 2>&1 || true
else
[ -z "${NODE_PID:-}" ] || kill -TERM "$NODE_PID" 2>/dev/null || true
for _ in $(seq 1 120); do [ -z "${NODE_PID:-}" ] || kill -0 "$NODE_PID" 2>/dev/null || break; sleep 1; done
pkill -f '[c]ontract-executor[.]jar' || true
fi
sleep 5

- name: Second set-up (Enter everywhere, do not start) changes nothing
run: |
sleep 1
# storage, database, share, executor, start, write (no first-start question: the database exists)
bash setup-run.sh csnode '\n\n\n\nno\n\n' 2>&1 | tee setup2.txt | tail -20
grep -a "already holds a lmdb database" setup2.txt
if grep -a "How should the node get the chain" setup2.txt; then echo "asked about the first start"; exit 1; fi
python check-config.py csnode/config.ini snapshot "serve=on fetch=off" \
storage "db_backend=lmdb checkpoint_every=100000 checkpoint_keep=2 prune_keep_blocks=1000"
test "$(grep -c '^; written by setup' csnode/config.ini)" -eq 1
test "$(ls csnode/config.ini.bak-* | wc -l)" -eq 2

- name: Full berkeleydb set-up with a wrong answer first
run: |
# storage (wrong, then full), database, share (no), executor, start, write
bash setup-run.sh csnode-clean 'maybe\nfull\n\nno\n\nno\n\n' 2>&1 | tee setup3.txt | tail -20
grep -a "Please answer one of" setup3.txt
python check-config.py csnode-clean/config.ini snapshot "serve=off fetch=off" storage "db_backend=berkeleydb"
# the rest of config.ini is the package's
python - <<'EOF'
import glob
def body(p):
out = []
for l in open(p, newline="").read().replace("\r\n", "\n").split("\n"):
if l.startswith("; written by setup"):
break
if l.strip():
out.append(l)
return out
new, old = body("csnode-clean/config.ini"), body(glob.glob("csnode-clean/config.ini.bak-*")[0])
assert new == old, "the rest of config.ini changed"
print("the rest of config.ini is unchanged")
EOF

- name: Executor of a folder upgraded by copying the node only
run: |
build=$(python -c "import re, zipfile; print(re.search(r'git.total.commit.count=(\d+)', zipfile.ZipFile('csnode-clean/contract-executor.jar').read('git.properties').decode()).group(1))")
echo "community executor in the package: build $build"
# the official config.ini kept: the node would refuse the community executor (max 1518)
cp -a csnode-clean csnode-exec && rm -f csnode-exec/config.ini.bak-*
sed -i.orig 's/^executor_commit_max=.*/executor_commit_max=1518/' csnode-exec/config.ini && rm csnode-exec/config.ini.orig
# storage, database, first start (sync), share, executor (Enter: community), start, write
bash setup-run.sh csnode-exec 'pruned\nlmdb\nsync\nno\n\nno\n\n' 2>&1 | tee setup4.txt | tail -12
grep -a "In this folder: build $build (community); config.ini accepts 1518..1518" setup4.txt
grep -q "^executor_commit_max=$build" csnode-exec/config.ini && echo "executor_commit_max=$build"
# no executor jars at all: the community one is downloaded from GitHub and checked
rm csnode-exec/contract-executor.jar csnode-exec/sc-api-support.jar
# storage, database, first start (sync), share, executor (community), download (Enter: yes), start, write
bash setup-run.sh csnode-exec 'pruned\nlmdb\nsync\nno\ncommunity\n\nno\n\n' 2>&1 | tee setup5.txt | tail -12
grep -a "contract-executor.jar and sc-api-support.jar replaced: build [0-9]* (community)" setup5.txt
test -f csnode-exec/contract-executor.jar && test -f csnode-exec/sc-api-support.jar

- name: Collect
if: always()
run: |
mkdir -p result
cp setup*.txt csnode/config.ini result/ 2>/dev/null || true
cp csnode-clean/config.ini result/config-full.ini 2>/dev/null || true
tail -c 1000000 csnode/stdout.log > result/stdout.log 2>/dev/null || true

- uses: actions/upload-artifact@v4
if: always()
with:
name: setup-${{ matrix.os }}
path: result/
retention-days: 14
1 change: 1 addition & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ lines under the new release.
| #126 | api: after a quick start at the last stored block, contract calls through the API returned "Transaction in progress" and never their result; the node now marks its stored blocks as read when it runs |
| #127 | ci: token tests: `ci/contracts/executor_harness.py` compares contract executors on token contracts without a node, and `TOKENS=1` runs `ci/testnet/tokens.py` (v1 and v0 tokens, balances and states on every node, the token API; `TOKENS_VIA` through another node) on the private network |
| #128 | api: the token cache (`[api] tokens_cache=true`, any build) follows v1/v2 tokens (BigDecimal amounts, standards 3 and 4) and only successful calls. It reads balances from the contract for the wallets a call involves, refreshes them in the background at start, and is rebuilt from the chain when the checkpoint holds none. `approve()` without arguments no longer reads out of bounds. `TokensListGet` filters before paging, and the token lists sort without exceptions or invalid orderings. `TokenTransfersListGet` reports the signer as the sender. See [tokens.md](tokens.md) |
| #131 | packaging: a guided set-up in every package (`setup.sh`, `setup.bat`): pruned or full, database, how the first start gets the chain, snapshot sharing, and the contract executor (community or official: it shows the build in the folder, can download either, checked, and sets `executor_commit_min/max` so that the node starts it; an upgrade by copying only the node binary keeps the old executor) |

## community.14 — 2026-10-27

Expand Down
26 changes: 26 additions & 0 deletions packaging/make-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ install -m 644 "${hosts:-$here/mainnet/known_hosts.txt}" "$dir/known_hosts.txt"
# the serving nodes the weekly survey found (ci/known-hosts/snapshot_sources.py), when it has found any
[ ! -f "$here/mainnet/snapshot_sources.txt" ] || install -m 644 "$here/mainnet/snapshot_sources.txt" "$dir/snapshot_sources.txt"

# the guided set-up (setup.sh, or setup.bat with setup.ps1 on Windows): writes [snapshot] and [storage]
if [ "$os" = windows ]; then
install -m 644 "$here/setup/setup.bat" "$here/setup/setup.ps1" "$dir/"
setup=setup.bat
setup_files="setup.bat, setup.ps1"
else
install -m 755 "$here/setup/setup.sh" "$dir/"
setup=./setup.sh
setup_files=setup.sh
fi

# the node accepts an executor only within [executor_commit_min, executor_commit_max], and the
# executor reports its git commit count, which our fixes raised above the release's 1518
commits=$(unzip -p "$executor/contract-executor.jar" git.properties | sed -n 's/^git.total.commit.count=//p' | tr -d '\r')
Expand Down Expand Up @@ -104,6 +115,21 @@ Changing the block database (db_backend)
only reads berkeleydb: convert back before running it on this folder. In Docker, use
CREDITS_CONVERT_DB=yes. Every [storage] setting and the conversion in detail: https://github.com/EnzinoBB/node/blob/master/docs/storage.md

First time: cd csnode && $setup
asks a few questions (pruned or full, database, snapshot, sharing, contract executor; Enter keeps
each default), writes config.ini (the previous one is kept as config.ini.bak-<date>) and starts
the node.

Upgrading an existing folder (an official one too): stop the node, copy $exe, contract-executor.jar,
sc-api-support.jar and $setup_files from this package into it, then run $setup there. Copying only
$exe keeps the old executor. The node starts an executor only if its build is within
executor_commit_min..executor_commit_max of config.ini: with the official config.ini (1518..1518)
it stops the community executor (build $commits) and runs no smart contract. The set-up shows the
build in the folder, asks whether to run the community executor or the official one (it can
download either: the community one from https://github.com/EnzinoBB/contract-executor/releases,
the official one from the CREDITSCOM release), keeps the replaced jars aside and sets the range in
config.ini. Both executors give the same contract results: either is compatible with the network.

Start: cd csnode && $start (full storage, as the official node)
or: cd csnode && $start --config-file config.pruned.ini (pruned storage)
A pruned node can start from the published snapshot: $start --config-file config.pruned.ini --download-snapshot
Expand Down
13 changes: 13 additions & 0 deletions packaging/setup/setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
rem Guided set-up of the node in this folder: double-click it, or run "setup.bat --defaults" to take
rem every default. The questions and the changes to config.ini are in setup.ps1, next to this file.
setlocal
set "ARGS="
if /i "%~1"=="--defaults" set "ARGS=-Defaults"
if /i "%~1"=="-y" set "ARGS=-Defaults"
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0setup.ps1" %ARGS%
set "RC=%ERRORLEVEL%"
rem a double-clicked window stays open to show the result
echo.
pause
exit /b %RC%
Loading
Loading