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 #151 received at 52555@debbugs.gnu.org (full text, mbox, reply):

Received: (at 52555) by debbugs.gnu.org; 29 Dec 2022 18:14:36 +0000
From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 13:14:36 2022
Received: from localhost ([127.0.0.1]:32806 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1pAxQK-0007PQ-AR
	for submit@debbugs.gnu.org; Thu, 29 Dec 2022 13:14:36 -0500
Received: from mout02.posteo.de ([185.67.36.66]:36003)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pukkamustard@posteo.net>) id 1pAxQC-0007OI-DL
 for 52555@debbugs.gnu.org; Thu, 29 Dec 2022 13:14:29 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id E41B62401A9
 for <52555@debbugs.gnu.org>; Thu, 29 Dec 2022 19:14:22 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1672337662; bh=7ucG2aEORDt0EkiJ7tlZhrXCVtV20NuUyG5fyIXtlLw=;
 h=From:To:Cc:Subject:Date:From;
 b=UeM+QlMO0JxAbCTDMB9I+C5ReuvbFqqnir/JNRT7DwV0sNGJXBqtDEwbS4F+Ejvp2
 StQ5lWzKwGOSYWuwl11l2mcaTnWpJRcS0vNrVlNJi7/gKZRcKx6p6b9lgQfkiFzQC1
 EbFm3DEHSJU7ZVf32t2im+lw7mEFgET5VHHbLtcDf/DxD46x/ONvT5p6rvmgz7EgXX
 /Ra2FXjtFGRvR4B0j+OnUioR9Y0WLDJsSTMXf1k4q1KWFz8dIN8nkcIrj9eVm3wOyd
 RspPmI2m0JbPJHHoZ9epxs58wg7tJsgPNR5GAKJps04/tzaCRADM3t8s8DRoaya5cE
 Dy6OrJaPf+eww==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Njc3f2lbTz6tmY;
 Thu, 29 Dec 2022 19:14:22 +0100 (CET)
From: pukkamustard <pukkamustard@posteo.net>
To: 52555@debbugs.gnu.org
Subject: [PATCH v3 3/8] publish: Add HTTP endpoint for resolving ERIS blocks.
Date: Thu, 29 Dec 2022 18:13:22 +0000
Message-Id: <20221229181327.758-4-pukkamustard@posteo.net>
In-Reply-To: <20221229181327.758-1-pukkamustard@posteo.net>
References: <20221229181327.758-1-pukkamustard@posteo.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 52555
Cc: pukkamustard <pukkamustard@posteo.net>
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/http.scm: New file.
* Makefile.am (MODULES): Add it.
* guix/scripts/publish.scm (make-request-handler): Add handler for RFC 2169
URN resolution endpoint.
---
 Makefile.am              |  1 +
 guix/eris/http.scm       | 40 ++++++++++++++++++++++++++++++++++++++++
 guix/scripts/publish.scm | 20 ++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 guix/eris/http.scm

diff --git a/Makefile.am b/Makefile.am
index c549fc8580..373f6b7c27 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -134,6 +134,7 @@ MODULES =					\
   guix/ipfs.scm					\
   guix/eris.scm                                 \
   guix/eris/fs-store.scm                        \
+  guix/eris/http.scm                            \
   guix/platform.scm                             \
   guix/platforms/arm.scm                        \
   guix/platforms/mips.scm                       \
diff --git a/guix/eris/http.scm b/guix/eris/http.scm
new file mode 100644
index 0000000000..a8a9520197
--- /dev/null
+++ b/guix/eris/http.scm
@@ -0,0 +1,40 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 pukkamustard <pukkamustard@posteo.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix eris http)
+  #:use-module (eris utils base32)
+  #:use-module (web uri)
+
+  #:use-module (srfi srfi-2)
+
+  #:export (make-blake2b-urn-query-ref))
+
+(define blake2b-uri-path-regexp
+  (make-regexp "^blake2b:" regexp/icase))
+
+(define (make-blake2b-urn-query-ref block-ref)
+  (lambda (query)
+    (and-let* ((_ query) ; ensure query is not false
+               (urn (string->uri query))
+               (_ (uri? urn))
+               (_ (eqv? (uri-scheme urn) 'urn))
+               (_ (regexp-exec blake2b-uri-path-regexp
+                               (uri-path urn)))
+               (blake2b-ref (base32-decode
+                             (string-drop (uri-path urn) 8))))
+      (block-ref blake2b-ref))))
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 7f14e4d4d4..15bdf02670 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -53,6 +53,8 @@ (define-module (guix scripts publish)
   #:use-module (guix config)
   #:use-module (guix derivations)
   #:use-module (guix eris)
+  #:use-module (guix eris fs-store)
+  #:use-module (guix eris http)
   #:use-module (gcrypt hash)
   #:use-module (guix pki)
   #:use-module (gcrypt pk-crypto)
@@ -1083,6 +1085,14 @@ (define nar-path?
     (let ((expected (split-and-decode-uri-path nar-path)))
       (cut equal? expected <>)))
 
+  ;; Get ERIS blocks directly from the filesystem store.
+  (define eris-block-ref
+    (eris-fs-store-ref (%eris-block-store-directory)))
+
+  ;; Create a handler for resolving blake2b URN queries.
+  (define blake2b-urn-query-ref
+    (make-blake2b-urn-query-ref eris-block-ref))
+
   (define (handle request body)
     (format #t "~a ~a~%"
             (request-method request)
@@ -1125,6 +1135,16 @@ (define (handle request body)
           (("log" name)
            (render-log-file store request name))
 
+          ;; /uri-res/N2R - RFC2169 URN resolution
+          (("uri-res" "N2R")
+           (let ((block (blake2b-urn-query-ref
+                         (uri-query (request-uri request)))))
+             (if block
+                 (values `((content-type . (application/octet-stream
+                                            (charset . "ISO-8859-1"))))
+                         block)
+                 (not-found request))))
+
           ;; Use different URLs depending on the compression type.  This
           ;; guarantees that /nar URLs remain valid even when 'guix publish'
           ;; is restarted with different compression parameters.
-- 
2.38.1





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Mon Sep 8 11:51:02 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.