upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorbitflash-maintainer <noreply@bitflash.invalid>2026-09-05 22:46:52 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-05 22:46:52 +0000
commitceae3d076b5ad11ee84729ae43f14e9312896646 (patch)
tree7e9132aa871fdc01cb95268d2f5ea3bb11853ddf /Makefile
parentbe63e83d79e7e00e6b8ca889a70e6a19886aa1d8 (diff)
parent66e0b9158d050c46b1ff2509faeee3f4573cac1c (diff)
Bring main onto the line this project actually ships
main had drifted to a history with no ancestor in common with the tree we build and deploy. It sat at be63e83 (2026-08-09) with 28 commits; the shipped line, deploy/soak-2026-08-21, had 383. The two shared nothing -- git merge-base returns no result at all -- so anyone cloning this repository landed on a default branch that was neither current nor related to the running node. The 28 commits on main were audited before this merge: every one is already present in the tree by content, including the two that are hardest to see because they were rewritten afterwards -- the payout reorg-safety work (PayoutBlockStillOnChain, since evolved to re-check on every retry rather than once at maturity) and the nostr relay certificate verification (SSL_set1_host, now with a Windows root-store path). Nothing on main is lost by this merge. Recorded as a merge rather than a force-push: main only ever moves forward, its old history stays reachable as the first parent, and this is revertible. The tree is taken wholesale from the merged branch, so main's content is now exactly what was built and tested. What this brings onto main: - compactblock: BIP152-style compact block relay ported from upstream 1.2.23, primitives and unit test only, with the RAND_bytes failure path closed and the reconstruction allocation bounded. - upstream/main 17741d9: isolated testnet parameters and genesis, optional 2 MB large pages for RandomX. Mainnet genesis verified byte-identical through upstream's BuildGenesisBlock() refactor. - deploy: every image built on bookworm so binaries run on Debian 12, and the container build now honours the RandomX and libsecp256k1 pins it had been silently ignoring since before 1.2.15. Gates at this tree: 15/15 selftests, compactblock's 17 checks, consensus constants unchanged against e4f898c apart from the pre-existing MAX_BLOCK_SIZE_GEN, mainnet genesis intact, money-log check ok.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile169
1 files changed, 138 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index abd75c5..342ec07 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
2# 2#
3# make linux build Bitflash-*-x86_64.AppImage 3# make linux build Bitflash-*-x86_64.AppImage
4# make windows build Bitflash-*-windows.zip (from MSYS2 UCRT64) 4# make windows build Bitflash-*-windows.zip (from MSYS2 UCRT64)
5# make windows-tor build Bitflash-*-windows-with-tor.zip
5# make tests build and run standalone unit tests 6# make tests build and run standalone unit tests
6# make checksums create SHA256SUMS for release assets 7# make checksums create SHA256SUMS for release assets
7# make verify-release TAG=v1.2.13 8# make verify-release TAG=v1.2.13
@@ -10,7 +11,10 @@
10ROOT := $(shell pwd) 11ROOT := $(shell pwd)
11NPROC := $(shell nproc 2>/dev/null || echo 2) 12NPROC := $(shell nproc 2>/dev/null || echo 2)
12SUDO := $(shell [ "$$(id -u)" = "0" ] && echo "" || echo "sudo") 13SUDO := $(shell [ "$$(id -u)" = "0" ] && echo "" || echo "sudo")
13VERSION := 1.2.15 14# Not "1.2.20". This tree is upstream v1.2.20 plus our own hardening commits and
15# a hand-merged payout ledger, so a binary built here must not be mistakable for
16# the upstream release of that number -- it names every release artifact.
17VERSION := 1.2.20+sec
14 18
15# ---- Pinned third-party sources ------------------------------------------- 19# ---- Pinned third-party sources -------------------------------------------
16# 20#
@@ -33,10 +37,23 @@ VERSION := 1.2.15
33# resolves the object by its own hash). Bump deliberately, and rebuild and 37# resolves the object by its own hash). Bump deliberately, and rebuild and
34# resync before shipping the result. 38# resync before shipping the result.
35# 39#
40# The check has to decide the exit status, so each recipe below joins its
41# commands with && the whole way to the closing echo. Ending that chain with a
42# `;` meant a failed `test` only skipped the build steps: the echo still ran,
43# the target still exited 0, and make announced a pinned dependency that
44# nothing had verified.
45#
36# RandomX pin is the commit this tree has been building and syncing against 46# RandomX pin is the commit this tree has been building and syncing against
37# (post-v2.0.1 master, 2026-05-24) -- chosen to change nothing today. 47# (post-v2.0.1 master, 2026-05-24) -- identical to upstream's pin.
48#
49# libsecp256k1 is pinned to upstream v1.2.18's commit rather than the one this
50# fork carried, so signature validation matches the binaries the rest of the
51# network runs. Consensus code must not differ from the network by accident.
52# There must be exactly ONE assignment of each of these variables in this file:
53# upstream defines them near the top too, and GNU Make takes the last `:=`, so
54# a second block silently decides the build.
38SECP256K1_REPO := https://github.com/bitcoin-core/secp256k1 55SECP256K1_REPO := https://github.com/bitcoin-core/secp256k1
39SECP256K1_COMMIT := 6e2c8bc4ecdc6e71dbe7a368f360d8d453ce435d 56SECP256K1_COMMIT := 7fecac74aed8e1fd9078380d67dd04663705c989
40RANDOMX_REPO := https://github.com/tevador/RandomX 57RANDOMX_REPO := https://github.com/tevador/RandomX
41RANDOMX_COMMIT := 1e9d4b2df63fa6edf46b06789486e23c0fcaa55a 58RANDOMX_COMMIT := 1e9d4b2df63fa6edf46b06789486e23c0fcaa55a
42 59
@@ -48,6 +65,32 @@ APPIMAGETOOL_SHA256 := ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3c
48 65
49# ---- Linux ---------------------------------------------------------------- 66# ---- Linux ----------------------------------------------------------------
50 67
68# RandomX used to build in $(HOME)/RandomX, and deps-randomx would rm -rf that
69# path whenever the library was missing -- deleting a tree the build did not
70# create and does not own (issue #27; a hand-managed pinned checkout there is
71# what this machine's miners build against). The default is now in-tree, like
72# secp256k1-build. A host that deliberately keeps RandomX elsewhere can set
73# RANDOMX_DIR=... explicitly; the recipe below will still never delete a
74# directory that lacks the marker file this build writes after a successful
75# build. Exported so src/Makefile's own RANDOMX_DIR ?= picks the same tree.
76#
77# Every use of it below is quoted, and the recipe rejects a value that cannot
78# name exactly one directory before it reaches anything destructive. Unquoted,
79# the marker guard could be stepped around: a value holding a glob that matches
80# two directories made `[ -d $(RANDOMX_DIR) ]` a two-argument test, which dies
81# with "unexpected operator" instead of answering, so the && short-circuited,
82# the guard was skipped, and the rm -rf below ran against every match. A value
83# holding a space or a `&&` broke the outer test the same way and reported
84# "already built". Whitespace and glob characters are refused outright rather
85# than merely quoted, because src/Makefile interpolates this same value into
86# -I$(RANDOMX_DIR)/src and -L$(RANDOMX_DIR)/build unquoted, where neither can
87# survive. A relative value is refused rather than silently made absolute: it
88# would mean two different directories to this Makefile and to src/Makefile,
89# whose cwd is src/, and a command-line assignment reaches the sub-make through
90# MAKEFLAGS, where it outranks anything exported from here.
91RANDOMX_DIR ?= $(ROOT)/randomx-build
92export RANDOMX_DIR
93
51linux: deps-linux 94linux: deps-linux
52 $(MAKE) -C src -f Makefile -j$(NPROC) 95 $(MAKE) -C src -f Makefile -j$(NPROC)
53 strip src/bitflash 96 strip src/bitflash
@@ -67,46 +110,79 @@ linux-node: deps-linux
67 110
68deps-linux: deps-apt deps-secp256k1 deps-randomx 111deps-linux: deps-apt deps-secp256k1 deps-randomx
69 112
113# libboost-dev, not libboost-system-dev: Boost.System has been header-only
114# since 1.69 and Ubuntu 26.04 (resolute) no longer ships the -system package.
115# This tree only includes two boost headers and links no boost library. The
116# apt-get update comes first: a fresh image's package lists are empty, and
117# install then fails on the first name it cannot find.
118#
119# A failed update is deliberately not fatal: one unreachable repository should
120# not block an install the lists already on disk can satisfy. It does say so,
121# though -- "unable to locate package" several seconds later is otherwise hard
122# to connect back to it. The install is the last command in the branch, so its
123# status is the target's, and that one does abort.
70deps-apt: 124deps-apt:
71 @if command -v apt-get >/dev/null 2>&1; then \ 125 @if command -v apt-get >/dev/null 2>&1; then \
126 $(SUDO) apt-get update || \
127 echo " warning: apt-get update failed, using the package lists on disk"; \
72 $(SUDO) apt-get install -y build-essential cmake git pkg-config autoconf \ 128 $(SUDO) apt-get install -y build-essential cmake git pkg-config autoconf \
73 libtool libssl-dev libdb5.3++-dev libsodium-dev nlohmann-json3-dev \ 129 libtool libssl-dev libdb5.3++-dev libsodium-dev nlohmann-json3-dev \
74 libboost-system-dev libglfw3-dev libgl-dev python3-pil; \ 130 libboost-dev libglfw3-dev libgl-dev libsqlite3-dev \
131 python3-pil clang; \
75 else \ 132 else \
76 echo "Not an apt system — install: g++ cmake git autoconf libtool"; \ 133 echo "Not an apt system — install: g++ cmake git autoconf libtool"; \
77 echo " libssl libdb++ libsodium nlohmann-json boost glfw3 opengl python3-pil"; \ 134 echo " libssl libdb++ libsodium nlohmann-json boost glfw3 opengl sqlite3 python3-pil"; \
78 fi 135 fi
79 136
80deps-secp256k1: 137deps-secp256k1:
81 @if [ ! -f /usr/local/lib/libsecp256k1.a ]; then \ 138 @if [ ! -f /usr/local/lib/libsecp256k1.a ]; then \
82 echo "==> building libsecp256k1"; \ 139 echo "==> building libsecp256k1"; \
83 rm -rf $(ROOT)/secp256k1-build; \ 140 rm -rf $(ROOT)/secp256k1-build && \
84 git init -q $(ROOT)/secp256k1-build; \ 141 git init -q $(ROOT)/secp256k1-build && \
85 cd $(ROOT)/secp256k1-build && \ 142 cd $(ROOT)/secp256k1-build && \
86 git remote add origin $(SECP256K1_REPO) && \ 143 git remote add origin $(SECP256K1_REPO) && \
87 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \ 144 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \
88 git checkout -q $(SECP256K1_COMMIT) && \ 145 git checkout -q --detach FETCH_HEAD && \
89 ./autogen.sh && \ 146 test "$$(git rev-parse HEAD)" = "$(SECP256K1_COMMIT)" && \
147 echo "==> libsecp256k1 pinned at $(SECP256K1_COMMIT)" && \
148 cd $(ROOT)/secp256k1-build && ./autogen.sh && \
90 ./configure --enable-module-schnorrsig --enable-module-extrakeys \ 149 ./configure --enable-module-schnorrsig --enable-module-extrakeys \
91 --disable-shared --with-pic --disable-benchmark --disable-tests && \ 150 --disable-shared --with-pic --disable-benchmark --disable-tests && \
92 make -j$(NPROC) && $(SUDO) make install && $(SUDO) ldconfig; \ 151 make -j$(NPROC) && $(SUDO) make install && $(SUDO) ldconfig && \
93 echo "==> libsecp256k1 done"; \ 152 echo "==> libsecp256k1 done"; \
94 else \ 153 else \
95 echo "==> libsecp256k1 already installed"; \ 154 echo "==> libsecp256k1 already installed"; \
96 fi 155 fi
97 156
98deps-randomx: 157deps-randomx:
99 @if [ ! -f $(HOME)/RandomX/build/librandomx.a ]; then \ 158 @ws="$$(printf ' \t')"; \
159 case "$(RANDOMX_DIR)" in \
160 "") echo "ERROR: RANDOMX_DIR is empty"; exit 1 ;; \
161 /) echo "ERROR: RANDOMX_DIR is /, refusing"; exit 1 ;; \
162 *[$$ws]*) echo "ERROR: RANDOMX_DIR contains whitespace: $(RANDOMX_DIR)"; exit 1 ;; \
163 *[*?[]*) echo "ERROR: RANDOMX_DIR contains a glob character: $(RANDOMX_DIR)"; exit 1 ;; \
164 /*) ;; \
165 *) echo "ERROR: RANDOMX_DIR must be an absolute path: $(RANDOMX_DIR)"; exit 1 ;; \
166 esac
167 @if [ ! -f "$(RANDOMX_DIR)/build/librandomx.a" ]; then \
168 if [ -d "$(RANDOMX_DIR)" ] && [ ! -f "$(RANDOMX_DIR)/.bitflash-built" ]; then \
169 echo "ERROR: $(RANDOMX_DIR) exists but was not created by this build"; \
170 echo " refusing to rm -rf it -- remove it yourself or set RANDOMX_DIR"; \
171 exit 1; \
172 fi; \
100 echo "==> building RandomX"; \ 173 echo "==> building RandomX"; \
101 rm -rf $(HOME)/RandomX; \ 174 rm -rf "$(RANDOMX_DIR)" && \
102 git init -q $(HOME)/RandomX; \ 175 git init -q "$(RANDOMX_DIR)" && \
103 cd $(HOME)/RandomX && \ 176 cd "$(RANDOMX_DIR)" && \
104 git remote add origin $(RANDOMX_REPO) && \ 177 git remote add origin $(RANDOMX_REPO) && \
105 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \ 178 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \
106 git checkout -q $(RANDOMX_COMMIT); \ 179 git checkout -q --detach FETCH_HEAD && \
107 mkdir -p $(HOME)/RandomX/build; \ 180 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \
108 cd $(HOME)/RandomX/build && cmake .. -DCMAKE_BUILD_TYPE=Release && \ 181 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \
109 make -j$(NPROC) randomx; \ 182 mkdir -p "$(RANDOMX_DIR)/build" && \
183 cd "$(RANDOMX_DIR)/build" && cmake .. -DCMAKE_BUILD_TYPE=Release && \
184 make -j$(NPROC) randomx && \
185 touch "$(RANDOMX_DIR)/.bitflash-built" && \
110 echo "==> RandomX done"; \ 186 echo "==> RandomX done"; \
111 else \ 187 else \
112 echo "==> RandomX already built"; \ 188 echo "==> RandomX already built"; \
@@ -157,13 +233,22 @@ img = ico.convert('RGBA'); \
157img.save(d + '/bitflash.png'); \ 233img.save(d + '/bitflash.png'); \
158import shutil; shutil.copy(d + '/bitflash.png', \ 234import shutil; shutil.copy(d + '/bitflash.png', \
159d + '/usr/share/icons/hicolor/256x256/apps/bitflash.png')" 235d + '/usr/share/icons/hicolor/256x256/apps/bitflash.png')"
160 @for lib in libsodium.so.23 libdb_cxx-5.3.so libglfw.so.3; do \ 236 @for lib in libsodium.so.23 libdb_cxx-5.3.so libsqlite3.so.0 libglfw.so.3; do \
161 path=$$(ldconfig -p | grep " $$lib " | awk '{print $$NF}' | head -1); \ 237 path=$$(ldconfig -p | grep " $$lib " | awk '{print $$NF}' | head -1); \
162 [ -z "$$path" ] && path=$$(find /usr/lib /lib -name "$$lib" 2>/dev/null | head -1); \ 238 [ -z "$$path" ] && path=$$(find /usr/lib /lib -name "$$lib" 2>/dev/null | head -1); \
163 [ -n "$$path" ] && cp -L "$$path" $(APPDIR)/usr/lib/ && echo " bundled $$lib" || echo " missing $$lib"; \ 239 [ -n "$$path" ] && cp -L "$$path" $(APPDIR)/usr/lib/ && echo " bundled $$lib" || echo " missing $$lib"; \
164 done 240 done
241# appimagetool's output used to be piped through grep ... || true, which
242# discarded its exit status: the target succeeded and announced "Built:"
243# even when no AppImage existed. Run the tool bare so its status decides,
244# then require the artefact to exist, be non-empty, and be newer than the
245# binary it was packaged from before saying so.
165 @ARCH=x86_64 $(APPIMAGETOOL) --no-appstream $(APPDIR) \ 246 @ARCH=x86_64 $(APPIMAGETOOL) --no-appstream $(APPDIR) \
166 $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage 2>&1 | grep -E "^Built|^Error" || true 247 $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage
248 @test -s $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage || \
249 { echo "ERROR: Bitflash-$(VERSION)-x86_64.AppImage missing or empty"; exit 1; }
250 @test $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage -nt src/bitflash || \
251 { echo "ERROR: Bitflash-$(VERSION)-x86_64.AppImage is not newer than src/bitflash"; exit 1; }
167 @echo "Built: Bitflash-$(VERSION)-x86_64.AppImage" 252 @echo "Built: Bitflash-$(VERSION)-x86_64.AppImage"
168 253
169# ---- Windows (MSYS2 UCRT64) ----------------------------------------------- 254# ---- Windows (MSYS2 UCRT64) -----------------------------------------------
@@ -175,29 +260,42 @@ deps-windows:
175 mingw-w64-ucrt-x86_64-glfw \ 260 mingw-w64-ucrt-x86_64-glfw \
176 mingw-w64-ucrt-x86_64-openssl \ 261 mingw-w64-ucrt-x86_64-openssl \
177 mingw-w64-ucrt-x86_64-db \ 262 mingw-w64-ucrt-x86_64-db \
263 mingw-w64-ucrt-x86_64-sqlite3 \
178 mingw-w64-ucrt-x86_64-libsodium \ 264 mingw-w64-ucrt-x86_64-libsodium \
179 mingw-w64-ucrt-x86_64-nlohmann-json \ 265 mingw-w64-ucrt-x86_64-nlohmann-json \
180 mingw-w64-ucrt-x86_64-boost \ 266 mingw-w64-ucrt-x86_64-boost \
181 mingw-w64-ucrt-x86_64-cmake \ 267 mingw-w64-ucrt-x86_64-cmake \
182 autoconf automake libtool 268 autoconf automake libtool
183 @if [ ! -f deps/lib/libsecp256k1.a ]; then \ 269 @if [ ! -f deps/lib/libsecp256k1.a ]; then \
184 rm -rf secp256k1-build; \ 270 rm -rf secp256k1-build && \
185 git clone --depth 1 https://github.com/bitcoin-core/secp256k1 secp256k1-build; \ 271 git init -q secp256k1-build && \
186 cd secp256k1-build && ./autogen.sh && \ 272 cd secp256k1-build && \
273 git remote add origin $(SECP256K1_REPO) && \
274 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \
275 git checkout -q --detach FETCH_HEAD && \
276 test "$$(git rev-parse HEAD)" = "$(SECP256K1_COMMIT)" && \
277 echo "==> secp256k1 pinned at $(SECP256K1_COMMIT)" && \
278 cd $(ROOT)/secp256k1-build && ./autogen.sh && \
187 ./configure --prefix=$(ROOT)/deps \ 279 ./configure --prefix=$(ROOT)/deps \
188 --enable-module-schnorrsig --enable-module-extrakeys \ 280 --enable-module-schnorrsig --enable-module-extrakeys \
189 --disable-shared --with-pic --disable-benchmark --disable-tests && \ 281 --disable-shared --with-pic --disable-benchmark --disable-tests && \
190 make install; \ 282 make install && \
191 echo "==> secp256k1 done"; \ 283 echo "==> secp256k1 done"; \
192 else \ 284 else \
193 echo "==> secp256k1 already built"; \ 285 echo "==> secp256k1 already built"; \
194 fi 286 fi
195 @if [ ! -f RandomX/build/librandomx.a ]; then \ 287 @if [ ! -f RandomX/build/librandomx.a ]; then \
196 rm -rf RandomX; \ 288 rm -rf RandomX && \
197 git clone --depth 1 https://github.com/tevador/RandomX; \ 289 git init -q RandomX && \
198 mkdir -p RandomX/build; \ 290 cd RandomX && \
199 cd RandomX/build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \ 291 git remote add origin $(RANDOMX_REPO) && \
200 make randomx; \ 292 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \
293 git checkout -q --detach FETCH_HEAD && \
294 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \
295 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \
296 mkdir -p $(ROOT)/RandomX/build && \
297 cd $(ROOT)/RandomX/build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \
298 make randomx && \
201 echo "==> RandomX done"; \ 299 echo "==> RandomX done"; \
202 else \ 300 else \
203 echo "==> RandomX already built"; \ 301 echo "==> RandomX already built"; \
@@ -213,6 +311,9 @@ windows: deps-windows
213 @zip -r Bitflash-$(VERSION)-windows.zip Bitflash-$(VERSION)-windows/ 311 @zip -r Bitflash-$(VERSION)-windows.zip Bitflash-$(VERSION)-windows/
214 @echo "Built: Bitflash-$(VERSION)-windows.zip" 312 @echo "Built: Bitflash-$(VERSION)-windows.zip"
215 313
314windows-tor: windows
315 ./scripts/package-windows-tor.sh
316
216# ---- Clean ---------------------------------------------------------------- 317# ---- Clean ----------------------------------------------------------------
217 318
218clean: 319clean:
@@ -224,6 +325,12 @@ clean:
224tests: 325tests:
225 $(MAKE) -C src -f Makefile tests 326 $(MAKE) -C src -f Makefile tests
226 327
328fuzz-net-message-smoke: deps-linux
329 $(MAKE) -C src -f Makefile fuzz-net-message-smoke
330
331fuzz-script-smoke: deps-linux
332 $(MAKE) -C src -f Makefile fuzz-script-smoke
333
227checksums: 334checksums:
228 ./scripts/make-release-checksums.sh 335 ./scripts/make-release-checksums.sh
229 336
@@ -233,6 +340,6 @@ sign-checksums:
233verify-release: 340verify-release:
234 ./scripts/verify-release.sh $(if $(TAG),$(TAG),latest) 341 ./scripts/verify-release.sh $(if $(TAG),$(TAG),latest)
235 342
236.PHONY: linux windows clean appimage \ 343.PHONY: linux windows windows-tor clean appimage \
237 tests checksums sign-checksums verify-release \ 344 tests fuzz-net-message-smoke fuzz-script-smoke checksums sign-checksums verify-release \
238 deps-linux deps-windows deps-apt deps-secp256k1 deps-randomx 345 deps-linux deps-windows deps-apt deps-secp256k1 deps-randomx