diff mbox series

[bug#66120,3/3] gnu: fulcrum: Update to 1.9.1.

Message ID 20230920123933.1241422-3-jean@foundationdevices.com
State New
Headers show
Series gnu: fulcrum: Update to 1.9.1. | expand

Commit Message

Jean-Pierre De Jesus DIAZ Sept. 20, 2023, 12:39 p.m. UTC
* gnu/packages/finance.scm (fulcrum): Use the upstream origin instead of
  the Flowee's fork of it, updates and expands the synopsis and
  description.  Updates the package to 1.9.1 and build without any
  bundled libraries with the help of a patch.

* gnu/packages/patches/fulcrum-1.9.1-unbundled-libraries.patch: New
  patch.

Signed-off-by: Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com>
---
 gnu/packages/finance.scm                      |  88 +++++---
 .../fulcrum-1.9.1-unbundled-libraries.patch   | 210 ++++++++++++++++++
 2 files changed, 272 insertions(+), 26 deletions(-)
 create mode 100644 gnu/packages/patches/fulcrum-1.9.1-unbundled-libraries.patch
diff mbox series

Patch

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index a1e2216ae0..63de983472 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -34,6 +34,7 @@ 
 ;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
 ;;; Copyright © 2023 Frank Pursel <frank.pursel@gmail.com>
 ;;; Copyright © 2023 Skylar Hill <stellarskylark@posteo.net>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -76,6 +77,7 @@  (define-module (gnu packages finance)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages databases)
@@ -1795,36 +1797,70 @@  (define-public bitcoin-unlimited
 (define-public fulcrum
   (package
     (name "fulcrum")
-    (version "1.1.1")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://gitlab.com/FloweeTheHub/fulcrum/-/archive/v"
-                           version "/fulcrum-v" version ".tar.gz"))
-       (sha256
-        (base32 "04w5gw02d39caa8a0l6wkn87kc43zzad2prqsyrcq97vlbkdx6x6"))))
+    (version "1.9.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/cculianu/Fulcrum")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (modules '((guix build utils)))
+              (snippet
+                #~(for-each delete-file-recursively
+                            '("src/Json/simdjson"
+                              "src/bitcoin/secp256k1"
+                              "src/robin_hood"
+                              "src/zmq"
+                              "staticlibs")))
+              (sha256
+               (base32
+                "1110vanl6aczlq25i4ck9j4vr81in5icw4z383wyhjpcy6rwxsw2"))
+              (patches
+               (search-patches "fulcrum-1.9.1-unbundled-libraries.patch"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         ;; Call qmake instead of configure to create a Makefile.
-         (replace 'configure
-           (lambda _
-             (invoke
-              "qmake"
-              (string-append "PREFIX=" %output)
-              "features="))))))
-    (native-inputs
-     (list qttools-5))
+     (list #:configure-flags
+           #~(list "CONFIG+=config_without_bundled_cppzmq"
+                   "CONFIG+=config_without_bundled_robin_hood"
+                   "CONFIG+=config_without_bundled_secp256k1"
+                   "LIBS+=-lrocksdb"
+                   #$@(if (target-64bit?) '("LIBS+=-lsimdjson") '())
+                   (format #f "DEFINES+=GIT_COMMIT=\"\\\\\\~s\\\\\\\""
+                           #$version)
+                   (string-append "PREFIX=" #$output))
+           #:phases
+           #~(modify-phases %standard-phases
+               (replace 'configure
+                 (lambda* (#:key configure-flags #:allow-other-keys)
+                   (apply invoke "qmake" configure-flags))))))
+    (native-inputs (list pkg-config qttools-5))
     (inputs
-     (list python qtbase-5 rocksdb zlib))
-    (home-page "https://gitlab.com/FloweeTheHub/fulcrum/")
-    (synopsis "Fast and nimble SPV server for Bitcoin Cash")
+     (append (list cppzmq
+                   jemalloc
+                   python
+                   qtbase-5
+                   robin-hood-hashing
+                   rocksdb
+                   zeromq
+                   zlib)
+             (if (target-64bit?)
+                 (list simdjson-0.6)
+                 '())))
+    (home-page "https://github.com/cculianu/Fulcrum")
+    (synopsis "Payment verification server for Bitcoin-like crypto-currencies")
     (description
-     "Flowee Fulcrum is a server that is the back-end for @acronym{SPV,
-Simplified Payment Verification} wallets, it provides the full API for those
-walets in a fast and small server.  The full data is stored in a full node,
-like Flowee the Hub, which Fulcrum connects to over RPC.")
+     "Fulcrum is a @acronym{SPV, Simplified Payment Verification} server for
+Bitcoin-like crypto-currencies.  The server indexes the blockchain of the
+crypto-currency used, and the resulting index can be used by wallets to
+perform queries to keep real-time track of balances.
+
+Supported crypto-currencies:
+
+@itemize
+@item Bitcoin Core.
+@item Bitcoin Cash-like.
+@item Litecoin.
+@end itemize")
     (license license:gpl3+)))
 
 (define-public flowee
diff --git a/gnu/packages/patches/fulcrum-1.9.1-unbundled-libraries.patch b/gnu/packages/patches/fulcrum-1.9.1-unbundled-libraries.patch
new file mode 100644
index 0000000000..327846b7aa
--- /dev/null
+++ b/gnu/packages/patches/fulcrum-1.9.1-unbundled-libraries.patch
@@ -0,0 +1,210 @@ 
+SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
+SPDX-License-Identifier: GPL-3.0-or-later
+
+These patch series allow to compile Fulcrum without using any bundled
+libraries.
+
+From 141d590b4189908a88ca07ad8e3880e4933e6427 Mon Sep 17 00:00:00 2001
+From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+Date: Thu, 6 Jul 2023 14:56:53 +0200
+Subject: [PATCH 1/4] Add config to build without secp256k1
+
+Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+---
+ Fulcrum.pro | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Fulcrum.pro b/Fulcrum.pro
+index e7fdfde..2dad355 100644
+--- a/Fulcrum.pro
++++ b/Fulcrum.pro
+@@ -480,7 +480,7 @@ HEADERS += \
+ # Enable secp256k1 compilation on x86_64 only -- we don't actually use this lib
+ # yet in Fulcrum, so on platforms that aren't x86_64 it's ok to exclude it; it
+ # was included in case we wish to someday verify signatures in Fulcrum, etc.
+-contains(QT_ARCH, x86_64):!win32-msvc {
++contains(QT_ARCH, x86_64):!contains(CONFIG, config_without_bundled_secp256k1):!win32-msvc {
+     message("Including embedded secp256k1")
+ 
+     SOURCES += bitcoin/secp256k1/secp256k1.c
+-- 
+2.34.1
+
+
+From 093a43d02dd14039ae8aed992223e5167f3fb866 Mon Sep 17 00:00:00 2001
+From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+Date: Thu, 6 Jul 2023 15:49:01 +0200
+Subject: [PATCH 2/4] Allow using system simdjson
+
+Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+---
+ Fulcrum.pro              | 7 +++++++
+ src/Json/Json_Parser.cpp | 5 ++++-
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/Fulcrum.pro b/Fulcrum.pro
+index 2dad355..c478af6 100644
+--- a/Fulcrum.pro
++++ b/Fulcrum.pro
+@@ -149,6 +149,13 @@ contains(CONFIG, config_endian_big) {
+ }
+ # /GIT_COMMIT=
+ 
++# simdjson
++contains(LIBS, -lsimdjson) {
++    message("simdjson: Using CLI override")
++    DEFINES += SYSTEM_SIMDJSON
++}
++# /simdjson
++
+ # ZMQ
+ !contains(LIBS, -lzmq) {
+     # Test for ZMQ, and if found, add pkg-config which we will rely upon to find libs
+diff --git a/src/Json/Json_Parser.cpp b/src/Json/Json_Parser.cpp
+index c24fe94..eb42eec 100644
+--- a/src/Json/Json_Parser.cpp
++++ b/src/Json/Json_Parser.cpp
+@@ -56,7 +56,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ // embed simdjson here, if we are on a known 64-bit platform and the header & sources are available
+ #if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(_M_ARM64)
+-#if __has_include("simdjson/simdjson.h") && __has_include("simdjson/simdjson.cpp")
++#if defined(SYSTEM_SIMDJSON)
++#include <simdjson.h>
++#define HAVE_SIMDJSON 1
++#elif __has_include("simdjson/simdjson.h") && __has_include("simdjson/simdjson.cpp")
+ #include "simdjson/simdjson.h"
+ #include "simdjson/simdjson.cpp"
+ #define HAVE_SIMDJSON 1
+-- 
+2.34.1
+
+
+From 4c609cb1467478cb669b5ca2290606128543a48c Mon Sep 17 00:00:00 2001
+From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+Date: Thu, 6 Jul 2023 15:56:01 +0200
+Subject: [PATCH 3/4] Allow using system robin-hood-hashing
+
+Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+---
+ Fulcrum.pro        | 13 ++++++++++---
+ src/Controller.cpp |  2 +-
+ src/Storage.cpp    |  4 ++--
+ 3 files changed, 13 insertions(+), 6 deletions(-)
+
+diff --git a/Fulcrum.pro b/Fulcrum.pro
+index c478af6..99c7659 100644
+--- a/Fulcrum.pro
++++ b/Fulcrum.pro
+@@ -149,6 +149,16 @@ contains(CONFIG, config_endian_big) {
+ }
+ # /GIT_COMMIT=
+ 
++# robin-hood-hashing
++!contains(CONFIG, config_without_bundled_robin_hood) {
++    # Robin Hood unordered_flat_map implememntation (single header and MUCH more efficient than unordered_map!)
++    HEADERS += robin_hood/robin_hood.h
++    INCLUDEPATH += src/robin_hood/
++} else {
++    message("robin-hood-hashing: Using CLI override")
++}
++# /robin-hood-hashing
++
+ # simdjson
+ contains(LIBS, -lsimdjson) {
+     message("simdjson: Using CLI override")
+@@ -402,9 +412,6 @@ HEADERS += \
+     WebSocket.h \
+     ZmqSubNotifier.h
+ 
+-# Robin Hood unordered_flat_map implememntation (single header and MUCH more efficient than unordered_map!)
+-HEADERS += robin_hood/robin_hood.h
+-
+ RESOURCES += \
+     resources.qrc
+ 
+diff --git a/src/Controller.cpp b/src/Controller.cpp
+index 918c1f2..d0cab56 100644
+--- a/src/Controller.cpp
++++ b/src/Controller.cpp
+@@ -33,7 +33,7 @@
+ #include "bitcoin/crypto/common.h"  // ReadLE32
+ #include "bitcoin/rpc/protocol.h" // for RPC_INVALID_ADDRESS_OR_KEY
+ #include "bitcoin/transaction.h"
+-#include "robin_hood/robin_hood.h"
++#include <robin_hood.h>
+ 
+ #include <algorithm>
+ #include <cassert>
+diff --git a/src/Storage.cpp b/src/Storage.cpp
+index e74278c..0f0b91e 100644
+--- a/src/Storage.cpp
++++ b/src/Storage.cpp
+@@ -31,7 +31,7 @@
+ 
+ #include "bitcoin/hash.h"
+ 
+-#include "robin_hood/robin_hood.h"
++#include <robin_hood.h>
+ 
+ #if __has_include(<rocksdb/advanced_cache.h>)
+ // Newer rocksdb 8.1 defines the `Cache` class in this header. :/
+@@ -4537,7 +4537,7 @@ namespace {
+ } // end anon namespace
+ 
+ #ifdef ENABLE_TESTS
+-#include "robin_hood/robin_hood.h"
++#include <robin_hood.h>
+ namespace {
+ 
+     template<size_t NB>
+-- 
+2.34.1
+
+
+From 0e3888b12f62553b032a56b71d2c1545add080b6 Mon Sep 17 00:00:00 2001
+From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+Date: Thu, 6 Jul 2023 16:04:57 +0200
+Subject: [PATCH 4/4] Allow using system cppzmq
+
+Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
+---
+ Fulcrum.pro            | 8 ++++++++
+ src/ZmqSubNotifier.cpp | 2 +-
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/Fulcrum.pro b/Fulcrum.pro
+index 99c7659..0948834 100644
+--- a/Fulcrum.pro
++++ b/Fulcrum.pro
+@@ -186,6 +186,14 @@ contains(LIBS, -lsimdjson) {
+ }
+ # /ZMQ
+ 
++# cppzmq
++!contains(CONFIG, config_without_bundled_cppzmq) {
++    INCLUDEPATH += src/zmq
++} else {
++    message("cppzmq: Using CLI override")
++}
++# /cppzmq
++
+ # - Try and detect rocksdb and if not, fall back to the staticlib.
+ # - User can suppress this behavior by specifying a "LIBS+=-lrocksdb..." on the
+ #   CLI when they invoked qmake. In that case, they must set-up the LIBS+= and
+diff --git a/src/ZmqSubNotifier.cpp b/src/ZmqSubNotifier.cpp
+index 6b03784..48a41be 100644
+--- a/src/ZmqSubNotifier.cpp
++++ b/src/ZmqSubNotifier.cpp
+@@ -23,7 +23,7 @@
+ #if defined(ENABLE_ZMQ)
+ // real implementation
+ #define ZMQ_CPP11
+-#include "zmq/zmq.hpp"
++#include <zmq.hpp>
+ 
+ #include <QRandomGenerator>
+ 
+-- 
+2.34.1
+