[mst] replace jacquard-repo with in-tree mst and commit implementation
104 unmodified linesExpand all105106107108109110111112113114109110111112211 unmodified linesExpand all324325326327334335336337338339340341342343344345346328329330331250 unmodified linesExpand all58258358458560560660760860961058658758858955 unmodified lines645646647648674675676677678679680681682683684685686687688649650651652171 unmodified linesExpand all82482582682786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290382882983083186 unmodified lines91891992092199899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102692292392492512 unmodified lines938939940941104794294394494526 unmodified lines972973974975108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110697697797897988 unmodified lines1068106910701071120312041205120612071208107210731074107587 unmodified lines11631164116511661304130513061307130813091310131113121313131413151316116711681169117025 unmodified lines119611971198119913501351135213531354135513561357135813591360136113621200120112021203280 unmodified linesExpand all148414851486148716511652165316541655165616571658165914881489149014911 unmodified line1493149414951496166916701671167216731674167516761677149714981499150078 unmodified lines15791580158115821764158315841585158615871588158915901591159215931594361 unmodified linesExpand all195619571958195921411960214319611962196319643 unmodified lines19681969197019712155197219731974197512 unmodified lines19881989199019912176199219931994199538 unmodified lines203420352036203722232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562038203920402041347 unmodified linesExpand all23892390239123922612261326142615261626172618261926202621262226232624262526262627262826292630263126322393239423952396105 unmodified linesExpand all25022503250425052746274727482749275027512506250725082509295 unmodified linesExpand all28052806280728083055305630573058305930603061306230633064306528092810281128123070281328142815281628178 unmodified lines282628272828282930873088308930903091309230933094309530962830283128322833144 unmodified linesExpand all2978297929802981324929822983298429852986253 unmodified linesExpand all32403241324232433511351235133514351535163244324532463247167 unmodified linesExpand all3415341634173418369236933694369536963697369836993700370137023419342034213422153 unmodified linesExpand all35763577357835793864386538663867386838693580358135823583309 unmodified linesExpand all3893389438953896418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042213897389838993900390139023903390442303905390639073908151 unmodified linesExpand all40604061406240634390439143924393439443954396439743984399440044014402440344044405440644074408406440654066406734 unmodified lines4102410341044105445144524453445444554456410641074108410923 unmodified lines41334134413541364488448944904491449244934137413841394140578 unmodified linesExpand all104 unmodified linesExpand all "rustversion",]
[[package]]name = "arrayvec"version = "0.7.8"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
[[package]]name = "async-compression"version = "0.4.41"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d0f9ee0f6e02ffd7ad5816e9464499fba7b3effd01123b515c41d1697c43dad1"211 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
[[package]]name = "blake3"version = "1.8.7"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae"dependencies = [ "arrayvec", "cc", "cfg-if", "constant_time_eq", "cpufeatures 0.3.0",]
[[package]]name = "block-buffer"version = "0.10.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"250 unmodified linesExpand all "cc",]
[[package]]name = "cmov"version = "0.5.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
[[package]]name = "cobs"version = "0.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"55 unmodified linessource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "2f421161cb492475f1661ddc9815a745a1c894592070661180fdec3d4872e9c3"
[[package]]name = "constant_time_eq"version = "0.4.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
[[package]]name = "convert_case"version = "0.10.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"dependencies = [ "unicode-segmentation",]
[[package]]name = "cordyceps"version = "0.3.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "688d7fbb8092b8de775ef2536f36c8c31f2bc4006ece2e8d8ad2d17d00ce0a2a"171 unmodified linesExpand all "hybrid-array",]
[[package]]name = "ctutils"version = "0.4.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "03bb0e1cc970d482d121d9a1744999169b69a07470b3d644a7894e53fcaf4574"dependencies = [ "cmov",]
[[package]]name = "curve25519-dalek"version = "4.1.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"dependencies = [ "cfg-if", "cpufeatures 0.2.17", "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", "rustc_version", "subtle", "zeroize",]
[[package]]name = "curve25519-dalek-derive"version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"dependencies = [ "proc-macro2", "quote", "syn 2.0.117",]
[[package]]name = "darling"version = "0.23.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d"86 unmodified lines "powerfmt",]
[[package]]name = "derive_more"version = "2.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"dependencies = [ "derive_more-impl",]
[[package]]name = "derive_more-impl"version = "2.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", "syn 2.0.117", "unicode-xid",]
[[package]]name = "diatomic-waker"version = "0.2.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c"
[[package]]name = "digest"version = "0.10.7"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"12 unmodified linesdependencies = [ "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", "ctutils",]
[[package]]name = "displaydoc"26 unmodified lines "spki",]
[[package]]name = "ed25519"version = "2.2.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"dependencies = [ "pkcs8", "signature",]
[[package]]name = "ed25519-dalek"version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9"dependencies = [ "curve25519-dalek", "ed25519", "rand_core 0.6.4", "serde", "sha2 0.10.9", "subtle", "zeroize",]
[[package]]name = "either"version = "1.18.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"88 unmodified lines "subtle",]
[[package]]name = "fiat-crypto"version = "0.2.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
[[package]]name = "find-msvc-tools"version = "0.1.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"87 unmodified lines "futures-util",]
[[package]]name = "futures-buffered"version = "0.2.13"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4421cb78ee172b6b06080093479d3c50f058e7c81b7d577bbb8d118d551d4cd5"dependencies = [ "cordyceps", "diatomic-waker", "futures-core", "pin-project-lite", "spin 0.10.0",]
[[package]]name = "futures-channel"version = "0.3.32"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"25 unmodified linessource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718"
[[package]]name = "futures-lite"version = "2.6.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"dependencies = [ "fastrand", "futures-core", "futures-io", "parking", "pin-project-lite",]
[[package]]name = "futures-macro"version = "0.3.32"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"280 unmodified linesExpand all "tracing",]
[[package]]name = "hkdf"version = "0.13.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018"dependencies = [ "hmac 0.13.0",]
[[package]]name = "hmac"version = "0.12.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"1 unmodified line "digest 0.10.7",]
[[package]]name = "hmac"version = "0.13.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"dependencies = [ "digest 0.11.3",]
[[package]]name = "http"version = "1.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"78 unmodified lines "iroh-car", "jacquard-api", "jacquard-common", "jacquard-derive", "jacquard-repo", "k256", "libc", "lsm-tree", "miette", "mimalloc", "multibase", "nohash-hasher", "p256", "parking_lot", "rand 0.10.1", "reqwest", "rmp-serde",361 unmodified linesExpand all "chrono", "ciborium", "ciborium-io", "cid", "ed25519-dalek", "fluent-uri", "futures", "getrandom 0.2.17", "getrandom 0.3.4", "getrandom 0.4.3", "hashbrown 0.17.0",3 unmodified lines "maitake-sync", "miette", "multibase", "multihash", "n0-future", "oxilangtag", "p256", "phf", "postcard",12 unmodified lines "smol_str", "spin 0.12.3", "thiserror 2.0.18", "tokio", "tokio-tungstenite-wasm-jacquard", "tokio-util", "tracing", "trait-variant", "unicode-segmentation",38 unmodified lines "unicode-segmentation",]
[[package]]name = "jacquard-repo"version = "0.13.0"source = "git+https://tangled.org/nonbinary.computer/jacquard?rev=9046f2822f4685217300c4a03551b4484fcbc31d#9046f2822f4685217300c4a03551b4484fcbc31d"dependencies = [ "blake3", "bytes", "cid", "ed25519-dalek", "hkdf", "hmac 0.13.0", "iroh-car", "jacquard-api", "jacquard-common", "jacquard-derive", "jacquard-lexicon", "k256", "miette", "multihash", "n0-future", "p256", "rand 0.8.6", "serde", "serde_bytes", "serde_ipld_dagcbor 0.7.0", "serde_json", "sha2 0.11.1", "smol_str", "thiserror 2.0.18", "tokio", "trait-variant", "url",]
[[package]]name = "jni"version = "0.22.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"347 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "24e0cc5e2c585acbd15c5ce911dff71e1f4d5313f43345873311c4f5efd741cc"
[[package]]name = "n0-future"version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e2ab99dfb861450e68853d34ae665243a88b8c493d01ba957321a1e9b2312bbe"dependencies = [ "cfg_aliases", "derive_more", "futures-buffered", "futures-lite", "futures-util", "js-sys", "pin-project", "send_wrapper", "tokio", "tokio-util", "wasm-bindgen", "wasm-bindgen-futures", "web-time",]
[[package]]name = "ndk-context"version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"105 unmodified linesExpand all "winapi",]
[[package]]name = "parking"version = "2.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
[[package]]name = "parking_lot"version = "0.12.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"295 unmodified linesExpand allchecksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]name = "rand"version = "0.8.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4",]
[[package]]name = "rand"version = "0.9.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"dependencies = [ "rand_chacha 0.9.0", "rand_chacha", "rand_core 0.9.5",]
[[package]]8 unmodified lines]
[[package]]name = "rand_chacha"version = "0.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"dependencies = [ "ppv-lite86", "rand_core 0.6.4",]
[[package]]name = "rand_chacha"version = "0.9.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"dependencies = [144 unmodified linesExpand allversion = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"dependencies = [ "hmac 0.12.1", "hmac", "subtle",]
[[package]]253 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]name = "send_wrapper"version = "0.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]]name = "serde"version = "1.0.228"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"167 unmodified linesExpand all "xxhash-rust",]
[[package]]name = "sha1"version = "0.10.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"dependencies = [ "cfg-if", "cpufeatures 0.2.17", "digest 0.10.7",]
[[package]]name = "sha1_smol"version = "1.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"153 unmodified linesExpand all]
[[package]]name = "spin"version = "0.10.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591"
[[package]]name = "spin"version = "0.12.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0134f9043ed38b087ac4f7d4af44c79e2c9e5094421fe3164f435ce585953b10"
309 unmodified linesExpand all "tokio",]
[[package]]name = "tokio-tungstenite"version = "0.26.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084"dependencies = [ "futures-util", "log", "rustls", "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", "tungstenite",]
[[package]]name = "tokio-tungstenite-wasm-jacquard"version = "0.6.99"source = "git+https://tangled.org/nonbinary.computer/jacquard?rev=9046f2822f4685217300c4a03551b4484fcbc31d#9046f2822f4685217300c4a03551b4484fcbc31d"dependencies = [ "bytes", "futures-channel", "futures-util", "http", "httparse", "js-sys", "rustls", "thiserror 2.0.18", "tokio", "tokio-tungstenite", "wasm-bindgen", "web-sys",]
[[package]]name = "tokio-util"version = "0.7.18"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098"dependencies = [ "bytes", "futures-core", "futures-sink", "futures-util", "pin-project-lite", "tokio",]
151 unmodified linesExpand allsource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]name = "tungstenite"version = "0.26.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13"dependencies = [ "bytes", "data-encoding", "http", "httparse", "log", "rand 0.9.4", "rustls", "rustls-pki-types", "sha1", "thiserror 2.0.18", "utf-8",]
[[package]]name = "twox-hash"version = "2.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c"34 unmodified linessource = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
[[package]]name = "unicode-xid"version = "0.2.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]name = "unsigned-varint"version = "0.7.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105"23 unmodified lines "serde_derive",]
[[package]]name = "utf-8"version = "0.7.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]name = "utf8_iter"version = "1.0.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"578 unmodified linesExpand all54 unmodified lines55565758595960616221 unmodified lines84858687888990919192929394959629 unmodified lines54 unmodified linesaxum-tws = "0.6.0"
jacquard-common = { git = "https://tangled.org/nonbinary.computer/jacquard", rev = "9046f2822f4685217300c4a03551b4484fcbc31d", default-features = false, features = ["tracing", "std", "crypto", "reqwest-client"] }jacquard-api = { git = "https://tangled.org/nonbinary.computer/jacquard", rev = "9046f2822f4685217300c4a03551b4484fcbc31d" }jacquard-repo = { git = "https://tangled.org/nonbinary.computer/jacquard", rev = "9046f2822f4685217300c4a03551b4484fcbc31d" }hickory-resolver = { version = "0.26.2", features = ["system-config", "tokio"], default-features = false }jacquard-derive = { git = "https://tangled.org/nonbinary.computer/jacquard", rev = "9046f2822f4685217300c4a03551b4484fcbc31d" }chrono = { version = "0.4.43", features = ["serde"] }humantime = "2.3.0"21 unmodified linesnohash-hasher = "0.2.0"ahash = "0.8.12"# statvfs for the free-disk check before a backfill spills, already in the tree through tokiolibc = "0.2"k256 = { version = "0.13", features = ["ecdsa"] }p256 = { version = "0.13", features = ["ecdsa"] }
[dev-dependencies]tempfile = "3.26.0"k256 = { version = "0.13", features = ["ecdsa"] }tempfile = "3.26.0" criterion = { version = "0.8", default-features = false, features = ["cargo_bench_support"] }syn = { version = "2", features = ["full", "visit"] }
[[bin]]29 unmodified lines267 unmodified linesExpand all268269270271272272273274275276298 unmodified linesExpand all267 unmodified linesExpand all}
fn commit_data(parsed: &car::ParsedCar<CarBlocks>) -> IpldCid { let commit = parsed.blocks.get(&parsed.root).expect("car has its commit"); jacquard_repo::commit::Commit::<jacquard_common::DefaultStr>::from_cbor(commit) mst::AtpCommit::from_cbor(commit) .expect("commit decodes") .data}
298 unmodified linesExpand all161 unmodified linesExpand all16216316416516616616716816917085 unmodified lines256257258259260260261262263264244 unmodified linesExpand all161 unmodified linesExpand all}
fn commit_data(parsed: &car::ParsedCar<CarBlocks>) -> IpldCid { let commit = parsed.blocks.get(&parsed.root).expect("car has its commit"); jacquard_repo::commit::Commit::<jacquard_common::DefaultStr>::from_cbor(commit) mst::AtpCommit::from_cbor(commit) .expect("commit decodes") .data}
85 unmodified lines group.throughput(Throughput::Elements(blocks.len() as u64)); group.bench_function(repo.name, |b| { b.iter(|| { for bytes in &blocks { black_box(jacquard_repo::mst::util::compute_cid(bytes).expect("sha256 fits")); black_box(car::compute_cid(bytes)); } }) }); group.finish();244 unmodified linesExpand all1 unmodified line23456789101112131415161718192021108 unmodified linesExpand all130131132133124134135136137138307 unmodified linesExpand all44644744844944045045145245345494 unmodified lines54955055155254354454554654754855355455555655789 unmodified lines64764864965064665165265365465534 unmodified lines69069169269368969469569669769825 unmodified lines7247257267277237287297307317325 unmodified lines7387397407417377387427437447457467476 unmodified lines75475575675775375875976076176237 unmodified lines8008018028037998048058068078088 unmodified lines8178188198208168218228238248254 unmodified lines83083183283382983483583683783811 unmodified lines8508518528538498548558568578583 unmodified lines86286386486586186686786886987011 unmodified lines8828838848858818868878888898905 unmodified lines1 unmodified lineuse std::io::Cursor;
use bytes::{Buf, Bytes, BytesMut};use cid::Cid as IpldCid;use jacquard_common::types::crypto::{DAG_CBOR, SHA2_256};use miette::{IntoDiagnostic, Result};use sha2::{Digest, Sha256};
/// CIDv1 (dag-cbor, sha2-256) of a raw DAG-CBOR block.pub(crate) fn compute_cid(bytes: &[u8]) -> IpldCid { let digest = Sha256::digest(bytes); let mh = cid::multihash::Multihash::<64>::wrap(SHA2_256, &digest) .expect("sha2-256 digest fits a 64-byte multihash"); IpldCid::new_v1(DAG_CBOR, mh)}
/// blocks of a whole-repo CAR. hashed rather than ordered: the MST walk looks up every/// block, and cids are chosen by the PDS, so the hasher is randomly seeded.pub(crate) type CarBlocks = HashMap<IpldCid, Bytes, ahash::RandomState>;
108 unmodified linesExpand all /// a block for `bytes`, under the cid they hash to. #[cfg(test)] pub(crate) fn from_body(bytes: impl Into<Bytes>) -> Self { let bytes = bytes.into(); let cid = jacquard_repo::mst::util::compute_cid(&bytes).expect("sha256 fits a cid"); let cid = compute_cid(&bytes); Self { cid, bytes, cid_checked: true,307 unmodified linesExpand all}
/// checks that a block's payload hashes to its claimed CID (sha2-256, dag-cbor).pub(crate) fn validate_block_cid(claimed_cid: &IpldCid, bytes: &[u8]) -> Result<()> { let computed_cid = jacquard_repo::mst::util::compute_cid(bytes).into_diagnostic()?; let computed_cid = compute_cid(bytes); if computed_cid != *claimed_cid { return Err(miette::miette!( "CAR block CID mismatch: claimed {claimed_cid}, computed {computed_cid}" ));94 unmodified lines b"record".to_vec(), vec![1u8; 129], ] .into_iter() .map(|bytes| { ( jacquard_repo::mst::util::compute_cid(&bytes).unwrap(), bytes, ) }) .map(|bytes| (compute_cid(&bytes), bytes)) .collect::<Vec<_>>(); let root = blocks[0].0; let mut buf = Vec::new(); let mut writer =89 unmodified lines assert_eq!(streamed.blocks.map(), parsed.blocks.map(), "chunk {chunk}"); assert!(streamed.blocks.block(&root).unwrap().cid_checked); }
let real = jacquard_repo::mst::util::compute_cid(b"trusted").unwrap(); let real = compute_cid(b"trusted"); let forged = car_with_blocks(&[(real, b"trusted"), (cid(1), b"forged")]).await; let mut whole = WholeCar::new(true); let err = whole.push(&forged).unwrap_err(); assert!(err.to_string().contains("CAR block CID mismatch"), "{err}");34 unmodified lines }
#[tokio::test] async fn stream_rejects_a_forged_block_when_verifying() { let real = jacquard_repo::mst::util::compute_cid(b"trusted").unwrap(); let real = compute_cid(b"trusted"); let car = car_with_blocks(&[(real, b"trusted"), (cid(1), b"forged")]).await;
let err = stream_in_chunks(&car, 3, true).unwrap_err(); assert!(err.to_string().contains("CAR block CID mismatch"), "{err}");25 unmodified lines }
#[tokio::test] async fn verifying_parse_rejects_forged_block() { let real = jacquard_repo::mst::util::compute_cid(b"trusted").unwrap(); let real = compute_cid(b"trusted"); let car = car_with_blocks(&[(real, b"trusted"), (cid(1), b"forged")]).await;
assert!(parse_car(car.clone(), false).is_ok()); let err = parse_car(car.clone(), true).unwrap_err();5 unmodified lines }
#[tokio::test] async fn verifying_parse_accepts_matching_blocks() { let root = jacquard_repo::mst::util::compute_cid(b"root").unwrap(); let leaf = jacquard_repo::mst::util::compute_cid(b"leaf").unwrap(); let root = compute_cid(b"root"); let leaf = compute_cid(b"leaf"); let car = car_with_blocks(&[(root, b"root"), (leaf, b"leaf")]).await;
let parsed = parse_car(car.clone(), true).unwrap(); assert_eq!(parsed.root, root);6 unmodified lines #[tokio::test] async fn verifying_parse_rejects_forged_copy_shadowed_by_valid_duplicate() { // the map keeps only the last copy, so the forged one is caught only while parsing; // no honest pds sends it, so the whole car is rejected let real = jacquard_repo::mst::util::compute_cid(b"trusted").unwrap(); let real = compute_cid(b"trusted"); let car = car_with_blocks(&[(real, b"forged"), (real, b"trusted")]).await;
let err = parse_car(car.clone(), true).unwrap_err(); assert!(err.to_string().contains("CAR block CID mismatch"));37 unmodified lines
#[tokio::test] async fn rejects_a_block_without_payload() { // iroh-car accepts it, and the cid of empty bytes even passes verification let empty = jacquard_repo::mst::util::compute_cid(b"").unwrap(); let empty = compute_cid(b""); let car = car_with_blocks(&[(empty, b"")]).await;
let err = parse_commit_car(car, true).unwrap_err(); assert!(err.to_string().contains("has no payload"));8 unmodified lines let block = forged(cid(1)).block(&cid(1)).unwrap(); let err = block.verify().unwrap_err(); assert!(err.to_string().contains("CAR block CID mismatch"));
let real = jacquard_repo::mst::util::compute_cid(b"forged").unwrap(); let real = compute_cid(b"forged"); let block = forged(real).block(&real).unwrap(); let verified = block.verify().unwrap(); assert_eq!(verified.cid(), &real); assert_eq!(verified.bytes().as_ref(), b"forged");4 unmodified lines let block = forged(cid(1)).block(&cid(1)).unwrap(); let err = block.checked().unwrap_err(); assert!(err.to_string().contains("CAR block CID mismatch"));
let real = jacquard_repo::mst::util::compute_cid(b"forged").unwrap(); let real = compute_cid(b"forged"); let checked = forged(real).block(&real).unwrap().checked().unwrap(); assert!(checked.cid_checked); assert_eq!(checked.verify().unwrap().bytes().as_ref(), b"forged"); }11 unmodified lines }
#[tokio::test] async fn blocks_from_a_verifying_parse_verify_as_parsed() { let leaf = jacquard_repo::mst::util::compute_cid(b"leaf").unwrap(); let leaf = compute_cid(b"leaf"); let car = car_with_blocks(&[(leaf, b"leaf")]).await;
let parsed = parse_commit_car(car, true).unwrap(); let block = parsed.blocks.block(&leaf).unwrap();3 unmodified lines }
#[tokio::test] async fn merged_blocks_stay_checked_only_if_both_sides_were() { let leaf = jacquard_repo::mst::util::compute_cid(b"leaf").unwrap(); let leaf = compute_cid(b"leaf"); let car = car_with_blocks(&[(leaf, b"leaf")]).await;
let mut checked = parse_car_blocks(car.clone(), true).unwrap(); checked.extend(forged(cid(1)));11 unmodified lines #[tokio::test] async fn an_empty_default_keeps_merged_blocks_checked() { // sparse backfill folds verified fetches into a default, so a default // counted as unchecked would hash every one of them again let leaf = jacquard_repo::mst::util::compute_cid(b"leaf").unwrap(); let leaf = compute_cid(b"leaf"); let car = car_with_blocks(&[(leaf, b"leaf")]).await;
let mut merged = Blocks::default(); merged.extend(parse_car_blocks(car, true).unwrap());5 unmodified lines51 unmodified lines5253545556575856575859606162666768636465666713 unmodified lines51 unmodified lines inline_block: Option<&Bytes>, live: bool,) -> Option<JetstreamEphemeral> { use crate::types::StoredData; use jacquard_common::types::cid::{ATP_CID_HASH, IpldCid}; use jacquard_repo::DAG_CBOR_CID_CODEC; use sha2::{Digest, Sha256};
let (cid, record) = match data { StoredData::Ptr(cid) => { let record = crate::types::record_json(inline_block?).ok()?; (Some(cid.to_string()), Some(record)) } StoredData::Block(block) => { let digest = Sha256::digest(block); let hash = cid::multihash::Multihash::wrap(ATP_CID_HASH, &digest).ok()?; let cid = IpldCid::new_v1(DAG_CBOR_CID_CODEC, hash); let cid = crate::car::compute_cid(block); let record = crate::types::record_json(block).ok()?; (Some(cid.to_string()), Some(record)) } StoredData::Nothing => (None, None),13 unmodified lines43 unmodified lines44454647484849505131 unmodified lines43 unmodified linespub(crate) mod db;pub(crate) mod ingest;#[cfg(feature = "jetstream")]pub(crate) mod jetstream;#[cfg(feature = "indexer")]pub(crate) mod mst;pub(crate) mod net;#[cfg(feature = "indexer")]pub(crate) mod ops;31 unmodified lines