diff options
author | Florian Klink <flokli@flokli.de> | 2022-12-28T13·06+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2022-12-28T13·55+0000 |
commit | d973c9772d63ea106cf378267298d87bd37beee1 (patch) | |
tree | 86d5d5120c35be6ba1e8c17cc2b8d741cb0b2427 /tvix/store/protos/rpc_pathinfo.proto | |
parent | ce7be009946221425b1176b79fe44f559dd66c53 (diff) |
chore(tvix/store/protos): add PathInfoService::CalculateNAR() r/5525
Expose the NAR calculation to a separate `CalculateNAR` method, which responds with the NAR size and sha256 hash. Contrary to what cl/7618 and cl/7620 initially did, don't add different other request types. In the CalculateNARResponse message, there's now some duplication in the (optional) `narinfo` field of a PathInfo, but I'm not entirely sure if we want to drop the fields from there yet. Change-Id: Id797c56e17efedac115fbd43de9dfde9fa1db140 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7663 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/protos/rpc_pathinfo.proto')
-rw-r--r-- | tvix/store/protos/rpc_pathinfo.proto | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tvix/store/protos/rpc_pathinfo.proto b/tvix/store/protos/rpc_pathinfo.proto index f9710f572228..f37794c291be 100644 --- a/tvix/store/protos/rpc_pathinfo.proto +++ b/tvix/store/protos/rpc_pathinfo.proto @@ -9,23 +9,42 @@ import "tvix/store/protos/pathinfo.proto"; option go_package = "code.tvl.fyi/tvix/store/protos;storev1"; service PathInfoService { - // Get retrieves a PathInfo object, by using the lookup parameters in - // GetPathInfoRequest. - // If the PathInfo object contains a DirectoryNode, it needs to be looked - // up separately via the DirectoryService, which is purely - // content-addressed. + // Return a PathInfo message, identified by the decoded nixbase32 part + // of a Nix output path. + // + // To substitute /nix/store/xm35nga2g20mz5sm5l6n8v3bdm86yj83- + // cowsay-3.04 the bytes in the request would be + // nixbase32dec("xm35nga2g20mz5sm5l6n8v3bdm86yj83"). rpc Get(GetPathInfoRequest) returns (PathInfo); // Put uploads a PathInfo object to the remote end. It MUST not return // until the PathInfo object has been written on the the remote end. + // // The remote end MAY check if a potential DirectoryNode has already been // uploaded. + // // Uploading clients SHOULD obviously not steer other machines to try to // substitute before from the remote end before having finished uploading // PathInfo, Directories and Blobs. // The returned PathInfo object MAY contain additional narinfo signatures, // but is otherwise left untouched. rpc Put(PathInfo) returns (PathInfo); + + + // Calculate the NAR representation of the contents specified by the + // root_node. The calculation SHOULD be cached server-side for subsequent + // requests. + // + // All references (to blobs or Directory messages) MUST already exist in + // the store. + // + // The method can be used to produce a Nix fixed-output path, which + // contains the (compressed) sha256 of the NAR content representation in + // the root_node name (suffixed with the name). + // + // It can also be used to calculate arbitrary NAR hashes of output paths, + // in case a legacy Nix Binary Cache frontend is provided. + rpc CalculateNAR(Node) returns (CalculateNARResponse); } // GetPathInfoRequest describes the lookup parameters that can be used to @@ -38,7 +57,17 @@ message GetPathInfoRequest { // /nix/store/xm35nga2g20mz5sm5l6n8v3bdm86yj83-cowsay-3.04 // this field would contain nixbase32dec("xm35nga2g20mz5sm5l6n8v3bdm86yj83"). bytes by_output_hash = 1; + }; +} + +// CalculateNARResponse is the response returned by the CalculateNAR request. +// +// It contains the size of the NAR representation (in bytes), and the sha56 +// digest. +message CalculateNARResponse { + // This size of the NAR file, in bytes. + uint32 nar_size = 1; - // placeholder: by_drv and output name? - } + // The sha256 of the NAR file representation. + bytes nar_sha256 = 2; } |