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 03:16:00 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-05 03:16:00 +0000
commit60538c5a935787521a5ad8c2a7dce52b5f250f3a (patch)
treeb78632a9d3b15b7a99567fe3c213d0bb00fd1731 /src/Makefile
parent152c859b18b222a7c11a82b5485110e902267d40 (diff)
compactblock: import BIP152-style compact block relay from upstream 1.2.23
Brings src/compactblock.{cpp,h} and test_compactblock.cpp across verbatim from the upstream-v1.2.23 tag, and gives them a build. 1.2.23 is not a newer release of the line this fork ships. It is a lightweight tag (7ab5a8c) cut 2026-07-30, on a lineage that upstream/main (e0be70e, 2026-08-20) does not contain and no remote branch carries -- 272 commits that are not ours, against 376 of ours that are not theirs, from a merge-base at 56df983. Merging that tag would have deleted 18 files from src/, selftest.{cpp,h} and the whole 14-test suite among them, so the content is ported file by file instead. Compact block relay is the piece worth having: a peer that advertises sendcmpct gets 48-bit keyed short IDs per transaction rather than the transaction bytes, and reconstructs the block from its own mempool. It is purely additive on the wire -- a peer that never sends sendcmpct keeps receiving full block messages, so no coordinated upgrade is needed. This commit is the primitives and their unit test only. Nothing calls BuildCompactBlock or TryReconstructBlock yet: the P2P message handlers (sendcmpct/cmpctblock/getblocktxn/blocktxn) live in 1.2.23's main.cpp and are deliberately left for a follow-up, so that no attacker-controlled bytes reach this code until that wiring is reviewed on its own. The files needed no API adaptation -- mapTransactions, BEGIN/END and IMPLEMENT_SERIALIZE are unchanged across the divergence, and it compiled clean first time. Upstream never wired test_compactblock.cpp into its own Makefile, so it had never been built there; it links standalone the way test_bip32 does, supplying its own mapTransactions and GetAppDir to keep main.cpp out of the link. TEST_LIBS is overridable for the same reason NODE_LIBS is: the pinned dep tree ships libsodium as a static archive only. All 17 checks in test_compactblock pass, all 14 selftests still pass, and the consensus constants are unchanged against e4f898c.
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Makefile b/src/Makefile
index b931007..888110f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -55,7 +55,8 @@ LIBS = -L$(SECP_LIB) -lsecp256k1 \
55HEADERS = 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 \
56 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 \
57 randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h \ 57 randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h \
58 selftest.h walletcmd.h wallet_sqlite.h compat.h sockcount.h proxy.h tor.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
59 60
60IMGUI_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 \
61 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
@@ -64,7 +65,7 @@ NODE_OBJS = obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \
64 obj/sha.o obj/nostr.o obj/randomx_pow.o \ 65 obj/sha.o obj/nostr.o obj/randomx_pow.o \
65 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 \
66 obj/selftest.o obj/bip32.o obj/walletcmd.o obj/wallet_sqlite.o \ 67 obj/selftest.o obj/bip32.o obj/walletcmd.o obj/wallet_sqlite.o \
67 obj/proxy.o obj/tor.o 68 obj/proxy.o obj/tor.o obj/compactblock.o
68 69
69GUI_OBJS = obj/gui.o obj/main_gui.o 70GUI_OBJS = obj/gui.o obj/main_gui.o
70 71
@@ -194,13 +195,28 @@ fuzz-script-smoke: fuzz-script
194 ./fuzz-script -runs=128 ../work/fuzz-corpus/script 195 ./fuzz-script -runs=128 ../work/fuzz-corpus/script
195 196
196clean: 197clean:
197 rm -rf obj obj-node obj-fuzz bitflash bitflash-node fuzz-net-message fuzz-script test_bip32 198 rm -rf obj obj-node obj-fuzz bitflash bitflash-node fuzz-net-message fuzz-script test_bip32 test_compactblock
198 199
199test_bip32: test_bip32.cpp bip32.cpp bip32.h bip39_english.h 200test_bip32: test_bip32.cpp bip32.cpp bip32.h bip39_english.h
200 $(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto 201 $(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto
201 202
202tests: 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
203 ./test_bip32 218 ./test_bip32
219 ./test_compactblock
204 ./bitflash-node -selftest=wallet-keypool 220 ./bitflash-node -selftest=wallet-keypool
205 ./bitflash-node -selftest=wallet-hd 221 ./bitflash-node -selftest=wallet-hd
206 ./bitflash-node -selftest=wallet-format 222 ./bitflash-node -selftest=wallet-format