upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/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 /src/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 'src/Makefile')
-rw-r--r--src/Makefile110
1 files changed, 100 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile
index 171afe0..c997ae3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,10 +2,13 @@
2# Called by: make linux (root Makefile) 2# Called by: make linux (root Makefile)
3 3
4CXX ?= g++ 4CXX ?= g++
5FUZZ_CXX ?= clang++
5 6
6SECP_INC ?= /usr/local/include 7SECP_INC ?= /usr/local/include
7SECP_LIB ?= /usr/local/lib 8SECP_LIB ?= /usr/local/lib
8RANDOMX_DIR ?= $(HOME)/RandomX 9# The root Makefile exports RANDOMX_DIR (default: <repo>/randomx-build, built
10# by deps-randomx). This fallback only applies when src/ is built standalone.
11RANDOMX_DIR ?= $(abspath $(CURDIR)/..)/randomx-build
9 12
10IMGUI_DIR = imgui 13IMGUI_DIR = imgui
11 14
@@ -29,14 +32,17 @@ WARNFLAGS = -Wformat -Werror=format \
29 -Wno-narrowing -Wno-unused-result 32 -Wno-narrowing -Wno-unused-result
30 33
31CXXFLAGS = -std=gnu++14 -O2 $(WARNFLAGS) -fpermissive -pthread \ 34CXXFLAGS = -std=gnu++14 -O2 $(WARNFLAGS) -fpermissive -pthread \
32 -DSECP256K1_STATIC \ 35 -DSECP256K1_STATIC -DBITFLASH_NODE_BUILD \
33 -I$(SECP_INC) -I$(RANDOMX_DIR)/src \ 36 -I$(SECP_INC) -I$(RANDOMX_DIR)/src \
34 -I/usr/include/nlohmann \ 37 -I/usr/include/nlohmann \
35 -I$(IMGUI_DIR) 38 -I$(IMGUI_DIR)
39FUZZ_CXXFLAGS = $(filter-out -O2,$(CXXFLAGS)) -O1 -g -fno-omit-frame-pointer \
40 -fsanitize=fuzzer-no-link,address,undefined
41FUZZ_LDFLAGS = -fsanitize=fuzzer,address,undefined
36 42
37LIBS = -L$(SECP_LIB) -lsecp256k1 \ 43LIBS = -L$(SECP_LIB) -lsecp256k1 \
38 -L$(RANDOMX_DIR)/build -lrandomx \ 44 -L$(RANDOMX_DIR)/build -lrandomx \
39 -lsodium -lssl -lcrypto -ldb_cxx -lpthread \ 45 -lsodium -lssl -lcrypto -ldb_cxx -lsqlite3 -lpthread \
40 -lglfw -lGL 46 -lglfw -lGL
41 47
42# Every header a .cpp here includes has to be listed, not just the interesting 48# Every header a .cpp here includes has to be listed, not just the interesting
@@ -49,7 +55,8 @@ LIBS = -L$(SECP_LIB) -lsecp256k1 \
49HEADERS = headers_core.h headers.h util.h main.h serialize.h uint256.h \ 55HEADERS = headers_core.h headers.h util.h main.h serialize.h uint256.h \
50 key.h bignum.h script.h db.h base58.h net.h nostr.h \ 56 key.h bignum.h script.h db.h base58.h net.h nostr.h \
51 randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h \ 57 randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h \
52 selftest.h walletcmd.h compat.h sockcount.h font_roboto.h 58 selftest.h walletcmd.h wallet_sqlite.h compat.h sockcount.h proxy.h tor.h font_roboto.h \
59 compactblock.h
53 60
54IMGUI_OBJS = obj/imgui.o obj/imgui_draw.o obj/imgui_tables.o \ 61IMGUI_OBJS = obj/imgui.o obj/imgui_draw.o obj/imgui_tables.o \
55 obj/imgui_widgets.o obj/imgui_impl_glfw.o obj/imgui_impl_opengl3.o 62 obj/imgui_widgets.o obj/imgui_impl_glfw.o obj/imgui_impl_opengl3.o
@@ -57,7 +64,8 @@ IMGUI_OBJS = obj/imgui.o obj/imgui_draw.o obj/imgui_tables.o \
57NODE_OBJS = obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \ 64NODE_OBJS = obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \
58 obj/sha.o obj/nostr.o obj/randomx_pow.o \ 65 obj/sha.o obj/nostr.o obj/randomx_pow.o \
59 obj/btfaddr.o obj/btfchan.o obj/btfrv.o obj/btftunnel.o obj/rpc.o \ 66 obj/btfaddr.o obj/btfchan.o obj/btfrv.o obj/btftunnel.o obj/rpc.o \
60 obj/selftest.o obj/bip32.o obj/walletcmd.o 67 obj/selftest.o obj/bip32.o obj/walletcmd.o obj/wallet_sqlite.o \
68 obj/proxy.o obj/tor.o obj/compactblock.o
61 69
62GUI_OBJS = obj/gui.o obj/main_gui.o 70GUI_OBJS = obj/gui.o obj/main_gui.o
63 71
@@ -96,7 +104,7 @@ obj/imgui_impl_opengl3.o: $(IMGUI_DIR)/imgui_impl_opengl3.cpp
96 $(CXX) -c $(CXXFLAGS) -o $@ $< 104 $(CXX) -c $(CXXFLAGS) -o $@ $<
97 105
98bitflash: $(IMGUI_OBJS) $(NODE_OBJS) $(GUI_OBJS) 106bitflash: $(IMGUI_OBJS) $(NODE_OBJS) $(GUI_OBJS)
99 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) 107 $(CXX) $(CXXFLAGS) $(LDHARDFLAGS) -o $@ $^ $(LIBS)
100 @echo "Built: bitflash" 108 @echo "Built: bitflash"
101 109
102# ---- headless node --------------------------------------------------------- 110# ---- headless node ---------------------------------------------------------
@@ -110,13 +118,31 @@ bitflash: $(IMGUI_OBJS) $(NODE_OBJS) $(GUI_OBJS)
110# Objects go to obj-node/ because main_gui.cpp is compiled twice, with and 118# Objects go to obj-node/ because main_gui.cpp is compiled twice, with and
111# without -DBITFLASH_NO_GUI, and the two must not overwrite each other. 119# without -DBITFLASH_NO_GUI, and the two must not overwrite each other.
112 120
121# RandomX links a hand-written assembly JIT stub, jit_compiler_x86_static.S,
122# which carries no .note.GNU-stack marker. Older binutils -- Debian 12's, which
123# is what builds against the oldest glibc we ship to -- reads a missing marker
124# as "this object wants an executable stack" and marks the whole binary RWE,
125# switching NX off for the process. Newer toolchains default the other way, so
126# identical source produced GNU_STACK RW on Ubuntu 26.04 and RWE on bookworm,
127# announced by nothing louder than a linker warning in the middle of the build.
128#
129# Assert it here rather than inherit whichever default the build host happens
130# to carry. The JIT maps its own W^X pages and never executes from the stack,
131# so nothing needs the permission this takes away. Check with:
132# readelf -lW bitflash-node | grep -A1 GNU_STACK # expect RW, not RWE
133LDHARDFLAGS = -Wl,-z,noexecstack
134
113NODE_LIBS = -L$(SECP_LIB) -lsecp256k1 \ 135NODE_LIBS = -L$(SECP_LIB) -lsecp256k1 \
114 -L$(RANDOMX_DIR)/build -lrandomx \ 136 -L$(RANDOMX_DIR)/build -lrandomx \
115 -lsodium -lssl -lcrypto -ldb_cxx -lpthread 137 -lsodium -lssl -lcrypto -ldb_cxx -lsqlite3 -lpthread
116 138
117NODE_ONLY_OBJS = $(patsubst obj/%,obj-node/%,$(NODE_OBJS)) \ 139NODE_ONLY_OBJS = $(patsubst obj/%,obj-node/%,$(NODE_OBJS)) \
118 obj-node/main_gui.o obj-node/headless.o 140 obj-node/main_gui.o obj-node/headless.o
119 141
142FUZZ_BASE_OBJS = $(patsubst obj/%,obj-fuzz/%,$(NODE_OBJS))
143FUZZ_NET_MESSAGE_OBJS = $(FUZZ_BASE_OBJS) obj-fuzz/fuzz_net_message.o
144FUZZ_SCRIPT_OBJS = $(FUZZ_BASE_OBJS) obj-fuzz/fuzz_script.o
145
120obj-node/%.o: %.cpp $(HEADERS) 146obj-node/%.o: %.cpp $(HEADERS)
121 @mkdir -p obj-node 147 @mkdir -p obj-node
122 $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -o $@ $< 148 $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -o $@ $<
@@ -126,21 +152,85 @@ obj-node/sha.o: sha.cpp sha.h
126 $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -O3 -o $@ $< 152 $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -O3 -o $@ $<
127 153
128bitflash-node: $(NODE_ONLY_OBJS) 154bitflash-node: $(NODE_ONLY_OBJS)
129 $(CXX) $(CXXFLAGS) -o $@ $^ $(NODE_LIBS) 155 $(CXX) $(CXXFLAGS) $(LDHARDFLAGS) -o $@ $^ $(NODE_LIBS)
130 @echo "Built: bitflash-node (headless, no libGL needed)" 156 @echo "Built: bitflash-node (headless, no libGL needed)"
131 157
158obj-fuzz/%.o: %.cpp $(HEADERS)
159 @mkdir -p obj-fuzz
160 $(FUZZ_CXX) -c $(FUZZ_CXXFLAGS) -DBITFLASH_FUZZ -o $@ $<
161
162obj-fuzz/sha.o: sha.cpp sha.h
163 @mkdir -p obj-fuzz
164 $(FUZZ_CXX) -c $(FUZZ_CXXFLAGS) -DBITFLASH_FUZZ -O1 -o $@ $<
165
166obj-fuzz/fuzz_net_message.o: fuzz_net_message.cpp $(HEADERS)
167 @mkdir -p obj-fuzz
168 $(FUZZ_CXX) -c $(FUZZ_CXXFLAGS) -DBITFLASH_FUZZ -o $@ $<
169
170obj-fuzz/fuzz_script.o: fuzz_script.cpp $(HEADERS)
171 @mkdir -p obj-fuzz
172 $(FUZZ_CXX) -c $(FUZZ_CXXFLAGS) -DBITFLASH_FUZZ -o $@ $<
173
174fuzz-net-message: $(FUZZ_NET_MESSAGE_OBJS)
175 $(FUZZ_CXX) $(filter-out -fsanitize=fuzzer-no-link%,$(FUZZ_CXXFLAGS)) \
176 $(FUZZ_LDFLAGS) -o $@ $^ $(NODE_LIBS)
177 @echo "Built: fuzz-net-message"
178
179fuzz-script: $(FUZZ_SCRIPT_OBJS)
180 $(FUZZ_CXX) $(filter-out -fsanitize=fuzzer-no-link%,$(FUZZ_CXXFLAGS)) \
181 $(FUZZ_LDFLAGS) -o $@ $^ $(NODE_LIBS)
182 @echo "Built: fuzz-script"
183
184fuzz-net-message-smoke: fuzz-net-message
185 @mkdir -p ../work/fuzz-corpus/net-message
186 @printf '\277\040\134\375ping\000\000\000\000\000\000\000\000\000\000\000\000' > ../work/fuzz-corpus/net-message/ping-header
187 @printf '\277\040\134\375version\000\000\000\000\000\000\000\000\000' > ../work/fuzz-corpus/net-message/version-header
188 ./fuzz-net-message -runs=128 ../work/fuzz-corpus/net-message
189
190fuzz-script-smoke: fuzz-script
191 @mkdir -p ../work/fuzz-corpus/script
192 @printf '\000\121' > ../work/fuzz-corpus/script/op-true
193 @printf '\001\166\251\024\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\210\254' > ../work/fuzz-corpus/script/p2pkh-shape
194 @printf '\000\115\377\377' > ../work/fuzz-corpus/script/truncated-pushdata2
195 ./fuzz-script -runs=128 ../work/fuzz-corpus/script
196
132clean: 197clean:
133 rm -rf obj obj-node bitflash bitflash-node test_bip32 198 rm -rf obj obj-node obj-fuzz bitflash bitflash-node fuzz-net-message fuzz-script test_bip32 test_compactblock
134 199
135test_bip32: test_bip32.cpp bip32.cpp bip32.h bip39_english.h 200test_bip32: test_bip32.cpp bip32.cpp bip32.h bip39_english.h
136 $(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto 201 $(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto
137 202
138tests: test_bip32 bitflash-node 203# Upstream shipped test_compactblock.cpp with no build rule at all, so it was
204# never compiled there. It links the standalone way test_bip32 does: it supplies
205# its own mapTransactions and GetAppDir so main.cpp stays out of the link, and
206# only needs sha.cpp/util.cpp for Hash() and the logging helpers.
207#
208# TEST_LIBS is overridable for the same reason NODE_LIBS is: the pinned dep tree
209# ships libsodium as a static archive only, so a build against it passes
210# TEST_LIBS="... -l:libsodium.a ...".
211TEST_LIBS ?= -lsodium -lssl -lcrypto -lpthread
212
213test_compactblock: test_compactblock.cpp compactblock.cpp compactblock.h $(HEADERS)
214 $(CXX) $(CXXFLAGS) -o $@ test_compactblock.cpp compactblock.cpp sha.cpp util.cpp \
215 $(TEST_LIBS)
216
217tests: test_bip32 test_compactblock bitflash-node
139 ./test_bip32 218 ./test_bip32
219 ./test_compactblock
140 ./bitflash-node -selftest=wallet-keypool 220 ./bitflash-node -selftest=wallet-keypool
141 ./bitflash-node -selftest=wallet-hd 221 ./bitflash-node -selftest=wallet-hd
142 ./bitflash-node -selftest=wallet-format 222 ./bitflash-node -selftest=wallet-format
223 ./bitflash-node -selftest=wallet-sqlite
224 ./bitflash-node -selftest=wallet-sqlite-migration
143 ./bitflash-node -selftest=wallet-crypto 225 ./bitflash-node -selftest=wallet-crypto
144 ./bitflash-node -selftest=wallet-encrypt 226 ./bitflash-node -selftest=wallet-encrypt
145 ./bitflash-node -selftest=net-message 227 ./bitflash-node -selftest=net-message
228 ./bitflash-node -selftest=network-params
146 ./bitflash-node -selftest=consensus-limits 229 ./bitflash-node -selftest=consensus-limits
230 ./bitflash-node -selftest=pool-stratum
231 ./bitflash-node -selftest=payout-ledger
232 ./bitflash-node -selftest=parse-money
233 ./bitflash-node -selftest=socks5-proxy
234 ./bitflash-node -selftest=managed-tor
235
236.PHONY: tests fuzz-net-message-smoke fuzz-script-smoke