From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id uKKEDNhCjWVZfQEAkFu2QA (envelope-from ) for ; Thu, 28 Dec 2023 10:41:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id AHsGBthCjWX8FQEAe85BDQ (envelope-from ) for ; Thu, 28 Dec 2023 10:41:44 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=B87bev7h; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1703756503; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1LimAnY48UBr1rD+TsvYRFPb3pWr/6T2C91Ar0dK1Zw=; b=nWezp83zCRu4oMeJ0qQqthfRuYWcxFmbd8Ocbh3BABEExb/PE7lG97whVGPumaUSHBkpjf p1SSVz7dcwslOtU/amn2dT/PNmJJeOyUC3KcqzzV2nqV3CnGfwLweaELiMt7NXPv/Ncn1/ 0dd1Drf2de3ke4jsqyUSSnffwASiVMBFj47aiaOoP8ksyhjYrGiv2N2kdpmB1MywyR0HNc wftgzhjQCcfUpaXBZ3nG0WABiRrl9dCjt8vhIU1HgQjD09FIueoZ4ZgTopXxeS359uMszX p0HP8HtkIwYN4jcMulBJYmfs8WfowoZ+XEv810zuLcn9i0xn8a8VQugascL8Dw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=B87bev7h; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1703756503; a=rsa-sha256; cv=none; b=GAgGOhTwz5KDsXSy1rCWg3piX68ERPc6AzkOvyf1lIy97bL+Z4h4Oc3/8pYhif6Pvx+j1r AirYZQuhUw2XX3APl1NCaXE4CRI3OhRM2FQf8R1UU/3IrnnA2/fXKSvCHydi07J2eHeKff m5KSW1FPBdZC5cAm2/ADNSf+yo1w2KNNWbjpKCvJjQeKP4bkwX2ompOF2DClEGu4zFam0H AIj3Uj1DxAsEWYXxZ7/h3uqbV+Oqn1ivVl+YLChps66flsxhJxVgllzJF0kocRLHgyDoiP krdblR34moqLuOdp6xKZscjcyqZWKAY+E+FNwC/D/9pU74wGy70aHsAyqWo2vg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A0B731666E for ; Thu, 28 Dec 2023 10:41:43 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rImt3-0007eD-Cq; Thu, 28 Dec 2023 04:41:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rImt1-0007d5-4z for guix-patches@gnu.org; Thu, 28 Dec 2023 04:41:07 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rImt0-000838-RU; Thu, 28 Dec 2023 04:41:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rImsy-0005lZ-17; Thu, 28 Dec 2023 04:41:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [PATCH v4 5/7] eris: Connect with an ERIS Store over CoAP+Unix. Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 28 Dec 2023 09:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52555@debbugs.gnu.org Cc: pukkamustard , ludo@gnu.org, maximedevos@telenet.be, Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.170375644022065 (code B ref 52555); Thu, 28 Dec 2023 09:41:03 +0000 Received: (at 52555) by debbugs.gnu.org; 28 Dec 2023 09:40:40 +0000 Received: from localhost ([127.0.0.1]:38524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) 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 ) 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 Date: Thu, 28 Dec 2023 09:40:08 +0000 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -2.33 X-Spam-Score: -2.33 X-Migadu-Queue-Id: A0B731666E X-TUID: r6RT+3IaZ2kd * 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