1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
Received: (at submit) by debbugs.gnu.org; 16 Mar 2021 08:40:33 +0000
From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 16 04:40:32 2021
Received: from localhost ([127.0.0.1]:38147 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
id 1lM5Fe-00048j-UQ
for submit@debbugs.gnu.org; Tue, 16 Mar 2021 04:40:32 -0400
Received: from lists.gnu.org ([209.51.188.17]:43418)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <ZmnSCPxj@protonmail.com>) id 1lM5Fb-00048a-Pz
for submit@debbugs.gnu.org; Tue, 16 Mar 2021 04:40:29 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44892)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <ZmnSCPxj@protonmail.com>)
id 1lM5Fb-0002vS-AF
for guix-patches@gnu.org; Tue, 16 Mar 2021 04:40:27 -0400
Received: from mail-40137.protonmail.ch ([185.70.40.137]:14418)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <ZmnSCPxj@protonmail.com>)
id 1lM5FX-0006yz-Ar
for guix-patches@gnu.org; Tue, 16 Mar 2021 04:40:26 -0400
Date: Tue, 16 Mar 2021 08:40:04 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
s=protonmail; t=1615884014;
bh=lxEq5WI1mmjXmIcUsvSOCZaFxaO8xLmoSuz+IWIu4pE=;
h=Date:To:From:Reply-To:Subject:From;
b=yjnSFcxFqb126UpQO9fhtdvfwVaur9SgOSnRehoW5ryPka0lFkM6HD77K6085BAdk
U2Z2dpqbTrqvv496XtyBtXOBLXZiyOY3LjDlfadbpPnmpvMkoWEOlHN0D+oeYDYZFL
GQwoJKRg7Q2VzvSVulfD9u0GxPAd5zkN6fpEISYQ=
To: "guix-patches@gnu.org" <guix-patches@gnu.org>
From: ZmnSCPxj <ZmnSCPxj@protonmail.com>
Subject: [PATCH] gnu: Add c-lightning.
Message-ID: <pIzl3qY1MjcwPK5NRfKDs3jl1Gf8zurLPn-2e60bUbwzJgLjgoqtJZ82_CMCCRoIyinyASxSXrIxa4yXMW9VfDCfl8P0Gs2_6_J3Iz0r2Go=@protonmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no
autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
mailout.protonmail.ch
Received-SPF: pass client-ip=185.70.40.137;
envelope-from=ZmnSCPxj@protonmail.com; helo=mail-40137.protonmail.ch
X-Spam_score_int: -15
X-Spam_score: -1.6
X-Spam_bar: -
X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
FROM_LOCAL_NOVOWEL=0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001,
RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request@debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit@debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request@debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request@debbugs.gnu.org?subject=subscribe>
Reply-To: ZmnSCPxj <ZmnSCPxj@protonmail.com>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -1.8 (-)
Good morning Guix developers,
C-Lightning is one of the earliest living implementations of the Lightning
Network protocol.
I am one of the developers of this implementation.
I tested this as follows:
* Extracted the package `c-lightning` into a `c-lightning.scm` file.
* Ran `guix build --rounds=3D4 -f c-lightning.scm` on an X86-64 server to
check for reproducability issues.
* Ran the compiled `lightningd` with `lightningd --version`,
`lightningd --help`, and the developer-secret undocumented
`lightningd --test-daemons-only` and checked they work correctly.
* Ran the compiled `lightningd` with `lightningd --proxy=3D127.0.0.1:9050
--bind-addr=3D127.0.0.1:9735 --addr=3Dstatictor:127.0.0.1:9051
--always-use-proxy=3Dtrue` on a server with Bitcoin and Tor installed,
and checked that it indeed created an LN wallet and started operating
the node.
* This also tests the SQLITE database backend and that the sub-daemons
are accessible and runnable.
* From an existing Lightning Network node, did a `lightning-cli connect`
to the new node running on the above command, and confirmed that the
above new node was connected to, and that it started downloading the
gossip map (the first thing every new node does when it initially gets
connected to the network).
* On a separate X86-64 machine with the same Guix commit version, copied
the `c-lightning.scm` file and reran `guix build --rounds=3D4 -f
c-lightning.scm` as well.
* Checked that the same `/gnu/store` path was produced on the separate
machine as on the first test server.
* Checked that this command produced the exact same text on both computers:
`find ${GNU_STORE_PATH} -type f | sort | xargs -n1 sha256sum`.
* Extracted the package `c-lightning-postgresql` into a
`c-lightning-postgresql.scm` file.
* Ran `guix build --rounds=3D4 -f c-lightning-postgresql.scm` on a X86-64
server to check for reproducibility issues.
* Chekced that `strings ${GNU_STORE_PATH}/bin/lightningd` for the
`c-lightning-postgresql` had references to `PQ*` functions, and that
the `c-lightning` version had none, meaning that `c-lightning-postgresql`
indeed included PostgreSQL support.
Thus, PostgreSQL support is not fully tested yet, but I believe the
produced binaries will work correctly as a C-Lightning instance.
Therefore I would like to submit this patch for inclusion into Guix.
Some notes:
* C-Lightning includes an extensive suite of tests, but these require
several additional python packages, some of which (e.g.
`python-bitcoinlib`) are not yet in Guix.
The tests are extensive and *very long*, running the entire test
suite can take an hour or more depending on exact settings.
* I took advantage of the functional nature of Guix and disabled the
relative-path `BINTOPKGLIBEXECDIR`, making it an absolute path, as
it also incidentally solves the issue of "upgrading C-lightning may
cause strange problems in a running instance".
See patch for more details.
* Our `configure` and `Makefile` are weird and I should probably go
fix those upstream.
Regards,
ZmnSCPxj
From 490aa608765228fbb6bb64b9fa679bb4c8145001 Mon Sep 17 00:00:00 2001
From: ZmnSCPxj jxPCSnmZ <ZmnSCPxj@protonmail.com>
Date: Mon, 15 Mar 2021 11:53:35 +0000
Subject: [PATCH] gnu: Add c-lightning.
* gnu/packages/finance.scm (c-lightning, c-lightning-postgresql): New varia=
bles.
---
gnu/packages/finance.scm | 153 +++++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)
diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index e6df40c168..4b565ddfeb 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -22,6 +22,7 @@
;;; Copyright =C2=A9 2020 Vinicius Monego <monego@posteo.net>
;;; Copyright =C2=A9 2020 Carlo Holl <carloholl@gmail.com>
;;; Copyright =C2=A9 2020 Giacomo Leidi <goodoldpaul@autistici.org>
+;;; Copyright =C2=A9 2021 ZmnSCPxj jxPCSnmZ <ZmnSCPxj@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -57,6 +58,7 @@
#:use-module (gnu packages aidc)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
+ #:use-module (gnu packages bash)
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
@@ -99,6 +101,7 @@
#:use-module (gnu packages qt)
#:use-module (gnu packages readline)
#:use-module (gnu packages sphinx)
+ #:use-module (gnu packages sqlite)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages textutils)
#:use-module (gnu packages time)
@@ -1676,3 +1679,152 @@ Interface (UI) for the hledger accounting system. =
It can be used as a
local, single-user UI, or as a multi-user UI for viewing, adding, and
editing on the Web.")
(license license:gpl3)))
+
+(define-public c-lightning
+ (package
+ (name "c-lightning")
+ (version "0.9.3")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/ElementsProject/lightning/releases/down=
load/"
+ "v" version "/clightning-v" version ".zip"))
+ (sha256
+ (base32 "1chqzxcqpr49vbayrw4213lznmyw4lcghcdh6afxbk4bxlhkjmml"))=
))
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("bash" ,bash)
+ ("libtool" ,libtool)
+ ("pkg-config" ,pkg-config)
+ ("python" ,python)
+ ("python-mako" ,python-mako)
+ ("sed" ,sed)
+ ("unzip" ,unzip)
+ ("which" ,which)))
+ (inputs
+ `(("gmp" ,gmp)
+ ("sqlite" ,sqlite)
+ ("zlib" ,zlib)))
+ (arguments
+ ;; Tests exist, but need a lot of Python packages (some not availabl=
e
+ ;; on Guix) and they are incompatible with our BINTOPKGLIBEXECDIR ha=
ck.
+ `(#:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'patch-makefile
+ (lambda _
+ (substitute* "Makefile"
+ ;; The C-lightning Makefile uses the PYTHONPATH
+ ;; variable, which causes Guix builds to fail
+ ;; since the environment variable is masked by
+ ;; the Makefile variable.
+ ;; Insert the contents of the variable into the
+ ;; Makefile.
+ (("^PYTHONPATH=3D")
+ (string-append
+ "PYTHONPATH=3D"
+ (getenv "PYTHONPATH")
+ ":"))
+ ;; C-lightning will spawn a number of other
+ ;; processes from binaries installed in its
+ ;; libexecdir.
+ ;; It normally uses relative paths so that
+ ;; users can move around the installation
+ ;; location.
+ ;; However, it does have the drawback that if
+ ;; the installation location is overwritten
+ ;; with a newer version while an existing
+ ;; instance is still running, any new
+ ;; sub-processes launched will be the new
+ ;; version, which is likely incompatible with
+ ;; the running instance.
+ ;; Since Guix would not allow the store
+ ;; directory to be moved anyway, we use an
+ ;; absolute path instead in the below
+ ;; substitution.
+ ;; With Guix and an absolute path, even if a
+ ;; running instance was launched from a
+ ;; profile and that profile is upgraded to a
+ ;; newer version, the running instance will
+ ;; refer to the absolute store directory
+ ;; containing binaries of the running version.
+ (("BINTOPKGLIBEXECDIR=3D.*$")
+ "BINTOPKGLIBEXECDIR=3D'\"'\"$(pkglibexecdir)\"'\"'\n"))))
+ ;; C-lightning configure is unusual, it does not understand
+ ;; the standard parameters Guix passes in, so, provide those
+ ;; by env variables.
+ (replace 'configure
+ (lambda* (#:key outputs inputs (configure-flags '())
+ #:allow-other-keys)
+ (let* ((bash (string-append (assoc-ref inputs "bash") "/b=
in/bash"))
+ (python (assoc-ref inputs "python"))
+ (prefix (assoc-ref outputs "out"))
+ (flags (cons*
+ "CC=3Dgcc"
+ (string-append "--prefix=3D" prefix)
+ configure-flags)))
+ (setenv "PYTHON" (string-append python "/bin/python3"))
+ (setenv "CONFIG_SHELL" bash)
+ (setenv "SHELL" bash)
+ (format #t "build directory: ~s~%" (getcwd))
+ (format #t "configure flags: ~s~%" flags)
+ (apply invoke bash
+ "./configure"
+ flags))))
+ ;; Rather than call the configure script of its external
+ ;; libraries from its own configure script, the external
+ ;; configure are created and called at build time.
+ ;; Unfortunately, it is a single Makefile stanza which
+ ;; does the autoreconf, configure, and make.
+ ;; This means we cannot "cut" through here by creating
+ ;; the external configure before this step (the Makefile
+ ;; stanza will recreate and overwrite the external
+ ;; configure), we have to modify the autogen.sh scripts
+ ;; of the external libraries instead so that they
+ ;; patch the shebangs after autoreconf.
+ (add-before 'build 'fix-autoreconf
+ (lambda _
+ (substitute* "external/libsodium/autogen.sh"
+ (("exec autoreconf(.*)$" exec-autoreconf flags)
+ (string-append
+ "autoreconf" flags
+ "sed 's:/bin/sh:" (getenv "SHELL") ":g' < configure > c=
onfigure.tmp\n"
+ "mv configure.tmp configure\n"
+ "chmod +x configure\n"
+ "exit 0\n")))
+ (substitute* "external/libwally-core/tools/autogen.sh"
+ (("autoreconf(.*)$" autoreconf)
+ (string-append
+ autoreconf
+ "sed 's:/bin/sh:" (getenv "SHELL") ":g' < configure > c=
onfigure.tmp\n"
+ "mv configure.tmp configure\n"
+ "chmod +x configure\n"))))))))
+ (home-page "https://github.com/ElementsProject/lightning")
+ (synopsis "Lightweight Lightning Network protocol implementation in C"=
)
+ (description
+ "c-lightning is a lightweight, highly customizable, and standard
+compliant implementation of the Lightning Network protocol.")
+ (license license:expat)))
+
+(define-public c-lightning-postgresql
+ (package
+ (inherit c-lightning)
+ (name "c-lightning-postgresql")
+ (inputs
+ `(("postgresql" ,postgresql)
+ ;; C-Lightning requires SQLITE3 as of 0.9.3, and will
+ ;; fail to build if it is not found.
+ ;; (The configure script will allow PostgreSQL without
+ ;; SQLITE3 but some build tool of C-Lightning fails if
+ ;; SQLITE3 is not found.)
+ ,@(package-inputs c-lightning)))
+ (description
+ "c-lightning is a lightweight, highly customizable, and standard
+compliant implementation of the Lightning Network protocol.
+
+This package includes support for using a PostgreSQL database to back
+your node; you will need to set up the PostgreSQL separately and pass
+in its details using an appropriate flag setting.")))
--
2.30.1
|