GNU bug report logs

#52555 [RFC PATCH 0/3] Decentralized substitute distribution with ERIS

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Full log

Message #190 received at 52555@debbugs.gnu.org (full text, mbox, reply):

Received: (at 52555) by debbugs.gnu.org; 28 Dec 2023 09:40:40 +0000
From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 28 04:40:40 2023
Received: from localhost ([127.0.0.1]:38524 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1rImsa-0005jj-4K
	for submit@debbugs.gnu.org; Thu, 28 Dec 2023 04:40:40 -0500
Received: from mout02.posteo.de ([185.67.36.66]:38673)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pukkamustard@posteo.net>) id 1rImsW-0005iS-3U
 for 52555@debbugs.gnu.org; Thu, 28 Dec 2023 04:40:36 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 16657240104
 for <52555@debbugs.gnu.org>; Thu, 28 Dec 2023 10:40:31 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1703756431; bh=MpsZR+/mCFO0Zar2E/8aRpMlNeo5yh3syt0Ter6cMiw=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:
 Content-Transfer-Encoding:From;
 b=B87bev7hDLjGtYTHgZDQzkIxu1aVihuiG90xoP16QlBpSGABWOsK3zKNacwdSSvKz
 f6zbwqZ0xRl4YPuviLTiF/hOmmm3AGa749vIV19QMQ0RqhjM6pV/cq93VYpRQOiqKY
 xsQHOzMxPfhBHpDsq6N+HzlUzgfLt74CScBrnoQ0rdL80zcCTC8e5C4lA4R4wLauGo
 v2AEDh+26Rccv4yC2MpMfsfArCYlve1V5VYqTPsEBGEpQem4FH7NmSNA/bZOPxOv56
 PqSa95Raz1ppzndV7QziSOlD7DaB+XvgeXodWzSysweyYtkF4lPSGq/T1yu50O9PjV
 zeH6ghbQTxucw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4T13Qk21ZPz6tn4;
 Thu, 28 Dec 2023 10:40:30 +0100 (CET)
From: pukkamustard <pukkamustard@posteo.net>
To: 52555@debbugs.gnu.org
Subject: [PATCH v4 5/7] eris: Connect with an ERIS Store over CoAP+Unix.
Date: Thu, 28 Dec 2023 09:40:08 +0000
Message-ID: <cd7432fcc871296d8a14b902e65190669ef89d62.1703316055.git.pukkamustard@posteo.net>
In-Reply-To: <cover.1703316055.git.pukkamustard@posteo.net>
References: <cover.1703316055.git.pukkamustard@posteo.net>
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic Courtès <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 52555
Cc: pukkamustard <pukkamustard@posteo.net>, ludo@gnu.org,
 maximedevos@telenet.be
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>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
* guix/eris.scm (open-coap-unix-socket): New procedure.
  (guix-eris-block-reducer): Handle coap+unix URIs.
* guix/publish.scm (bake-narinfo+nar): Start a fibers scheduler when encoding
item with ERIS.
---
 guix/eris.scm            | 63 ++++++++++++++++++++++++++++++----------
 guix/scripts/publish.scm |  9 +++++-
 2 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/guix/eris.scm b/guix/eris.scm
index d98a9a62bd..3fbedd0cb7 100644
--- a/guix/eris.scm
+++ b/guix/eris.scm
@@ -21,8 +21,11 @@ (define-module (guix eris)
   #:use-module (eris)
   #:use-module (eris fs)
   #:use-module (eris sqlite)
+  #:use-module (eris coap)
   #:use-module (eris read-capability)
 
+  #:use-module (coap tcp)
+
   #:use-module (web uri)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-171)
@@ -42,27 +45,57 @@ (define %eris-store-url
 (define %guix-eris-convergence-secret
   (make-parameter %null-convergence-secret))
 
+(define (open-coap-unix-socket path)
+  (let ((sock (socket PF_UNIX SOCK_STREAM 0)))
+    ;; Release FD on exec
+    (fcntl sock F_SETFD FD_CLOEXEC)
+    ;; Set to non-blocking
+    (fcntl sock F_SETFL (logior O_NONBLOCK (fcntl sock F_GETFL)))
+    ;; Connect
+    (connect sock AF_UNIX path)
+
+    ;; Initialize the CoAP connection
+    (open-socket-for-uri #f
+                         #:socket sock
+                         ;; Allow up to 64 in-flight requests
+                         #:nstart 64)))
+
 (define (guix-eris-block-reducer)
   "Returns an ERIS block reducer."
-  (if (uri? (%eris-store-url))
-      (match (uri-scheme (%eris-store-url))
+  (let ((store-url (%eris-store-url)))
+    (if (uri? store-url)
+        (match (uri-scheme store-url)
+
+          ;; Store blocks in an SQLite database (see
+          ;; https://eris.codeberg.page/eer/sqlite.xml)
+          ('sqlite
+           (eris-sqlite-block-reducer (uri-path store-url)))
 
-        ;; Store blocks in an SQLite database (see
-        ;; https://eris.codeberg.page/eer/sqlite.xml)
-        ('sqlite
-         (eris-sqlite-block-reducer (uri-path (%eris-store-url))))
+          ;; Connect to a CoAP ERIS store over a Unix socket
+          ('coap+unix
+           ;; Wrap the eris-coap-block-reducer to close the provided connection.
+           (let ((ecbr (eris-coap-block-reducer
+                      (build-uri 'coap #:path ".well-known/eris")
+                      #:nstart 64
+                      #:connection (open-coap-unix-socket
+                                    (uri-path store-url)))))
+             (case-lambda
+               (() (ecbr))
+               ((conn ref-block) (ecbr conn ref-block))
+               ((conn)
+                (ecbr conn)
+                (close-port conn)))))
 
-        ;; TODO
-        ;; ('coap+unix #f)
-        ;; ('coap+tcp #f)
+          ;; TODO
+          ;; ('coap+tcp #f)
 
-        (_ (error "Don't know how to handle ERIS store URL "
-                  (uri->string (%eris-store-url)))))
+          (_ (error "Don't know how to handle ERIS store URL "
+                    (uri->string (%eris-store-url)))))
 
-      ;; If no ERIS store URL is provided we just compute the ERIS URN without
-      ;; storing the blocks anywhere. As dummy block-reducer we use `rcount` from
-      ;; SRFI-171 that counts the number of blocks.
-      rcount))
+        ;; If no ERIS store URL is provided we just compute the ERIS URN without
+        ;; storing the blocks anywhere. As dummy block-reducer we use `rcount` from
+        ;; SRFI-171 that counts the number of blocks.
+        rcount)))
 
 (define* (eris-encode-store-item item)
   "Encodes the store item ITEM using ERIS and returns the read capability as
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 2e7138f3c7..0b61354327 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -54,6 +54,7 @@ (define-module (guix scripts publish)
   #:use-module (guix store)
   #:use-module ((guix serialization) #:select (write-file))
   #:use-module (guix eris)
+  #:use-module (fibers)
   #:use-module (zlib)
   #:autoload   (lzlib) (call-with-lzip-output-port
                         make-lzip-output-port)
@@ -655,7 +656,13 @@ (define* (bake-narinfo+nar cache item
 
   (let ((compression (actual-compressions item compressions))
         (eris-urn (if eris?
-                      (eris-encode-store-item item)
+                      ;; Encode with fibers.
+                      ;; XXX: There seems to be some buggy interactions when
+                      ;; running a fibers scheduler and connecting to the
+                      ;; store.
+                      (run-fibers (lambda ()
+                                    (eris-encode-store-item item))
+                                  #:drain? #t)
                       #f)))
 
     (for-each (cut compress-nar cache item <>) compressions)
-- 
2.41.0





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Mon Sep 8 15:49:41 2025; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.