about summary refs log tree commit diff
path: root/tvix/castore/src/directoryservice/closure_validator.rs
AgeCommit message (Collapse)AuthorFilesLines
2024-06-16 r/8282 refactor(castore/directory): separate order logic from ClosureValidatorYureka1-309/+0
ClosureValidator was previously only suitable for a very narrow use case: Validating incoming uploads, which are in leaves-to-root order. This is because the ordering validation was hard-wired into the add() function. This - Re-name ClosureValidator to DirectoryGraph, which is more suitable since it actually stores the Directory structs and is drained in the end. - Move the ordering-related logic to a separate OrderValidator, which can be used independently. - re-write DirectoryGraph to be a general purpose validator which can accept the input in both orders and can be drained in both orders as well. This means the DirectoryGraph and OrderValidator can now serve multiple new purposes: - Validating the incoming closure on the client while downloading. - Validating the incoming closure downloaded in a caching layer from the `far` cache, and re-order it for insertion into the `near` cache. Change-Id: I2b4b226348416912d7a31935bec050e53d911b70 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11708 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: yuka <yuka@yuka.dev>
2024-05-16 r/8153 fix(castore/directory/objectstore): fix responses for deduplicated dirsYureka1-7/+13
Using remove_node messed up the extraction of nodes from the graph. Use into_nodes_edges() instead, to remove the nodes without cloning. Change-Id: Id76c7935d082d6f26192cc3cd490483594f1d1e2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11684 Tested-by: BuildkiteCI Autosubmit: yuka <yuka@yuka.dev> Reviewed-by: flokli <flokli@flokli.de>
2024-05-16 r/8150 feat(tvix/store): add ObjectStoreDirectoryServiceYureka1-8/+43
Change-Id: I1636012be2e8ee3ae64f7bc62fd28bfe0cb2bca5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11668 Autosubmit: yuka <yuka@yuka.dev> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2024-04-20 r/7985 feat(tvix/castore): Fix build warnings in release modeConnor Brewster1-0/+1
Fixes some build warnings that only happen when building in release mode which disables `debug_assertions`. Change-Id: I554d5fce7c869c23cf4aa93179f0ee9f7f7c834e Reviewed-on: https://cl.tvl.fyi/c/depot/+/11490 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Autosubmit: Connor Brewster <cbrewster@hey.com> Reviewed-by: flokli <flokli@flokli.de>
2024-04-15 r/7928 fix(tvix/castore/directory): fix graph traversalFlorian Klink1-90/+102
Use a proper graph library to ensure all nodes are reachable from the root. We had a bit of that handrolled during add(), as well as later, which had an annoying bug: Redundant nodes were omitted during insert, but when returning the list during finalize, we did not properly account they need to be introduced before their parents are sent. We now simply populate a petgraph DiGraph during insert (skipping inserting nodes we already saw), and use petgraph's DfsPostOrder to traverse the graph during finalize. If the number of returned indices equals the total number of nodes in the graph, all nodes are reachable from the root, we can consume the graph and return the nodes as a vec, in the same order as the traversal (and insertion). Providing a regression test for the initial bug is challenging, as the current code uses a bunch of HashSets. I manually tested ingesting a full NixOS closure using this mechanism (via gRPC, which exposes this problem, as it validates twice), and it now works. Change-Id: Ic1d5e3e981f2993cc08c5c6b60ad895e578326dc Reviewed-on: https://cl.tvl.fyi/c/depot/+/11418 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI
2024-04-07 r/7864 refactor(tvix/castore): migrate closure_validator to rstestFlorian Klink1-13/+14
Change-Id: I6c594d2e670a681484b858c3e04bc25b9e5a2077 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11368 Tested-by: BuildkiteCI Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
2024-03-24 r/7774 refactor(tvix/castore/directory/grpc_wrapper): use ClosureValidatorFlorian Klink1-1/+1
This greatly simplifies the code in this function, replacing it with a much better tested (and more capable!) version of the validation logic. It also enables the gRPC server frontend to make use of the DirectoryPutter interface. While this might not be too visible in terms of latency thanks to gRPC streams bursting, it also enables further optimizations later (such as bucketing of directory closures). Change-Id: I21f805aa72377dd5266de3b525905d9f445337d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11221 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2024-03-24 r/7772 feat(tvix/castore/directory): add ClosureValidatorFlorian Klink1-0/+254
This can be used to validate a Directory closure (connected DAG of Directories), and their insertion order. Directories need to be inserted (via `add`), in an order from the leaves to the root. During insertion, we validate as much as we can at that time: - individual validation of Directory messages - validation of insertion order (no upload of not-yet-known Directories) - validation of size fields of referred Directories Internally it keeps all received Directories (and their sizes) in a HashMap, keyed by digest. Once all Directories have been inserted, a drain() function can be called to get a (deduplicated and) validated list of directories, in from-leaves-to-root order (to be stored somewhere). While assembling that list, a check for graph connectivity is performed too, to ensure there's no separate components being sent (and only one root). It adds a test suite for these cases, which is much nicer to test than where we previously had these checks (only in the gRPC server wrapper). Followup CLs will move the existing putters to use this. Change-Id: Ie88c832924c170a24626e9e3e91d868497b5d7a4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11220 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de>