diff --git a/Cargo.lock b/Cargo.lock index b8fc192..94976ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,7 +311,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" dependencies = [ "num-traits", - "rand 0.8.5", + "rand 0.8.6", ] [[package]] @@ -522,7 +522,7 @@ dependencies = [ "bitcoin", "bitcoin_hashes 0.15.0", "chacha20-poly1305", - "rand 0.8.5", + "rand 0.8.6", "tokio", ] @@ -656,9 +656,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" [[package]] name = "blake2" @@ -801,9 +801,9 @@ checksum = "4b4b0fc281743d80256607bd65e8beedc42cb0787ea119c85b81b4c0eab85e5f" [[package]] name = "clap" -version = "4.6.0" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" dependencies = [ "clap_builder", "clap_derive", @@ -823,9 +823,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.6.0" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -1138,7 +1138,7 @@ dependencies = [ "dashmap", "hex", "libveritas", - "rand 0.9.3", + "rand 0.9.4", "reqwest", "secp256k1", "serde", @@ -1383,7 +1383,7 @@ dependencies = [ "parking_lot", "portable-atomic", "quanta", - "rand 0.9.3", + "rand 0.9.4", "smallvec", "spinning_top", "web-time", @@ -1626,9 +1626,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.8" +version = "0.27.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2b52f86d1d4bc0d6b4e6826d960b1b333217e07d36b882dca570a5e1c48895b" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" dependencies = [ "http 1.4.0", "hyper 1.9.0", @@ -1901,7 +1901,7 @@ dependencies = [ "hyper 0.14.32", "jsonrpsee-types", "parking_lot", - "rand 0.8.5", + "rand 0.8.6", "rustc-hash 1.1.0", "serde", "serde_json", @@ -2000,9 +2000,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.184" +version = "0.2.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af" +checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" [[package]] name = "libm" @@ -2016,7 +2016,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "libc", "plain", "redox_syscall 0.7.4", @@ -2035,9 +2035,9 @@ dependencies = [ [[package]] name = "libveritas" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cf115fd0ad4269e52e6887481c216735a72b8e6c606317bbe9b97a3b7f19e3" +checksum = "76d82373509126c4da380014710f2c2605d4fa78797877d8f1eed8632093f636" dependencies = [ "base64 0.22.1", "borsh", @@ -2054,9 +2054,9 @@ dependencies = [ [[package]] name = "libveritas_testutil" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69a2e9b822fcdb97d696d8b354148dc283f0119b0589dc67a309a71e911b525" +checksum = "eff1f4c3819010a26f5f254c01a6488c572bc6dbb5a273ebe87eff52e3c8c72c" dependencies = [ "bitcoin", "borsh", @@ -2163,7 +2163,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "block", "core-graphics-types", "foreign-types", @@ -2437,9 +2437,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" dependencies = [ "portable-atomic", ] @@ -2520,9 +2520,9 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "num-traits", - "rand 0.9.3", + "rand 0.9.4", "rand_chacha 0.9.0", "rand_xorshift", "unarray", @@ -2572,7 +2572,7 @@ dependencies = [ "bytes", "getrandom 0.3.4", "lru-slab", - "rand 0.9.3", + "rand 0.9.4", "ring", "rustc-hash 2.1.2", "rustls 0.23.38", @@ -2615,9 +2615,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", "rand_chacha 0.3.1", @@ -2626,9 +2626,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec095654a25171c2124e9e3393a930bddbffdc939556c914957a4c3e0a87166" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.5", @@ -2687,7 +2687,7 @@ version = "11.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", ] [[package]] @@ -2696,7 +2696,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", ] [[package]] @@ -2705,7 +2705,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f450ad9c3b1da563fb6948a8e0fb0fb9269711c9c73d9ea1de5058c79c8d643a" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", ] [[package]] @@ -2764,7 +2764,7 @@ dependencies = [ "hex", "libveritas", "libveritas_testutil", - "rand 0.9.3", + "rand 0.9.4", "reqwest", "rusqlite", "serde_json", @@ -2795,7 +2795,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.9.0", - "hyper-rustls 0.27.8", + "hyper-rustls 0.27.9", "hyper-util", "js-sys", "log", @@ -2849,7 +2849,7 @@ dependencies = [ "elf", "lazy_static", "postcard", - "rand 0.9.3", + "rand 0.9.4", "risc0-zkp", "risc0-zkvm-platform", "ruint", @@ -3042,8 +3042,8 @@ checksum = "c141e807189ad38a07276942c6623032d3753c8859c146104ac2e4d68865945a" dependencies = [ "borsh", "proptest", - "rand 0.8.5", - "rand 0.9.3", + "rand 0.8.6", + "rand 0.9.4", "ruint-macro", "serde_core", "valuable", @@ -3062,7 +3062,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -3103,7 +3103,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "errno", "libc", "linux-raw-sys", @@ -3132,7 +3132,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.11", + "rustls-webpki 0.103.12", "subtle", "zeroize", ] @@ -3180,9 +3180,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.11" +version = "0.103.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a6af516fea4b20eccceaf166e8aa666ac996208e8a644ce3ef5aa783bc7cd4" +checksum = "8279bb85272c9f10811ae6a6c547ff594d6a7f3c6c6b02ee9726d1d0dcfcdd06" dependencies = [ "ring", "rustls-pki-types", @@ -3233,7 +3233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "bitcoin_hashes 0.14.1", - "rand 0.8.5", + "rand 0.8.6", "secp256k1-sys", "serde", ] @@ -3253,7 +3253,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "core-foundation", "core-foundation-sys", "libc", @@ -3457,7 +3457,7 @@ dependencies = [ "http 0.2.12", "httparse", "log", - "rand 0.8.5", + "rand 0.8.6", "sha-1", ] @@ -3514,7 +3514,7 @@ dependencies = [ "hyper 0.14.32", "jsonrpsee", "log", - "rand 0.8.5", + "rand 0.8.6", "reqwest", "rusqlite", "serde", @@ -3921,7 +3921,7 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ - "bitflags 2.11.0", + "bitflags 2.11.1", "bytes", "futures-util", "http 1.4.0", @@ -4024,9 +4024,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" [[package]] name = "unarray" @@ -4173,9 +4173,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.2+wasi-0.2.9" +version = "1.0.3+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" dependencies = [ "wit-bindgen", ] @@ -4270,9 +4270,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" dependencies = [ "rustls-pki-types", ] @@ -4538,9 +4538,9 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" [[package]] name = "writeable" diff --git a/fabric/go/fabric.go b/fabric/go/fabric.go index dd04881..cd89912 100644 --- a/fabric/go/fabric.go +++ b/fabric/go/fabric.go @@ -590,7 +590,7 @@ func (f *Fabric) ResolveAll(handles []string) (ResolvedBatch, error) { if slicesEqual(batch, prevBatch) { break } - verified, err := f.resolveFlat(batch) + verified, err := f.resolveFlat(batch, true) if err != nil { return ResolvedBatch{}, err } @@ -629,7 +629,7 @@ func (f *Fabric) Export(handle string) ([]byte, error) { if slicesEqual(batch, prevBatch) { break } - verified, err := f.resolveFlat(batch) + verified, err := f.resolveFlat(batch, false) if err != nil { return nil, err } @@ -699,7 +699,7 @@ func (f *Fabric) Publish(cert []byte, records []byte, secretKey []byte, primary return f.Broadcast(msg) } -func (f *Fabric) resolveFlat(handles []string) (*libveritas.VerifiedMessage, error) { +func (f *Fabric) resolveFlat(handles []string, hints bool) (*libveritas.VerifiedMessage, error) { bySpace := make(map[string][]string) for _, h := range handles { space, label := parseHandle(h) @@ -709,13 +709,15 @@ func (f *Fabric) resolveFlat(handles []string) (*libveritas.VerifiedMessage, err var queries []Query for space, labels := range bySpace { q := Query{Space: space, Handles: labels} - f.mu.Lock() - if cached, ok := f.zoneCache[space]; ok { - if hint := epochHintFromZone(cached); hint != nil { - q.EpochHint = hint + if hints { + f.mu.Lock() + if cached, ok := f.zoneCache[space]; ok { + if hint := epochHintFromZone(cached); hint != nil { + q.EpochHint = hint + } } + f.mu.Unlock() } - f.mu.Unlock() queries = append(queries, q) } diff --git a/fabric/go/go.mod b/fabric/go/go.mod index 1cc1bf7..e840f93 100644 --- a/fabric/go/go.mod +++ b/fabric/go/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/btcsuite/btcd/btcec/v2 v2.3.6 - github.com/spacesprotocol/libveritas-go v0.1.2 + github.com/spacesprotocol/libveritas-go v0.1.4 ) require ( diff --git a/fabric/go/go.sum b/fabric/go/go.sum index 173fd97..5223a91 100644 --- a/fabric/go/go.sum +++ b/fabric/go/go.sum @@ -8,5 +8,5 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/spacesprotocol/libveritas-go v0.1.2 h1:uMhRnQaPWgDIJtYGXo9wO10aav36G8lmgWXK3gw73gc= -github.com/spacesprotocol/libveritas-go v0.1.2/go.mod h1:HXnX2FNL43ueJuedsQwX9GF5jRHYZLqXYfFLWz900H8= +github.com/spacesprotocol/libveritas-go v0.1.4 h1:FuTQO25UgTocr3HMZm/qQnR4SihDVqWZ33On7+AtFD8= +github.com/spacesprotocol/libveritas-go v0.1.4/go.mod h1:HXnX2FNL43ueJuedsQwX9GF5jRHYZLqXYfFLWz900H8= diff --git a/fabric/js/fabric-core/src/fabric.ts b/fabric/js/fabric-core/src/fabric.ts index ec37d61..871fd5b 100644 --- a/fabric/js/fabric-core/src/fabric.ts +++ b/fabric/js/fabric-core/src/fabric.ts @@ -557,7 +557,7 @@ export class Fabric { let batch = lookup.start(); while (batch.length > 0) { if (arraysEqual(batch, prevBatch)) break; - const verified = await this.resolveFlat(batch); + const verified = await this.resolveFlat(batch, false); allCertBytes.push(...verified.certificates()); const zones = verified.zones(); prevBatch = batch; @@ -568,7 +568,7 @@ export class Fabric { } /** Resolve a flat list of non-dotted handles in a single relay query. */ - private async resolveFlat(handles: string[]): Promise { + private async resolveFlat(handles: string[], hints = true): Promise { const bySpace = new Map(); for (const h of handles) { const { space, label } = parseHandle(h); @@ -580,14 +580,16 @@ export class Fabric { const queries: Query[] = []; for (const [space, labels] of bySpace) { const q: Query = { space, handles: labels }; - const cached = this.zoneCache.get(space); - if (cached) { - const json = cached.zone.toJson(); - if (json?.commitment?.onchain) { - q.epoch_hint = { - root: json.commitment.onchain.state_root, - height: json.commitment.onchain.block_height, - }; + if (hints) { + const cached = this.zoneCache.get(space); + if (cached) { + const json = cached.zone.toJson(); + if (json?.commitment?.onchain) { + q.epoch_hint = { + root: json.commitment.onchain.state_root, + height: json.commitment.onchain.block_height, + }; + } } } queries.push(q); diff --git a/fabric/js/fabric-web/package.json b/fabric/js/fabric-web/package.json index afc69b2..dfbc4f3 100644 --- a/fabric/js/fabric-web/package.json +++ b/fabric/js/fabric-web/package.json @@ -27,7 +27,7 @@ "dependencies": { "@noble/curves": "^1.8.0", "@spacesprotocol/fabric-core": "*", - "@spacesprotocol/libveritas": "^0.1.2" + "@spacesprotocol/libveritas": "^0.1.4" }, "devDependencies": { "@types/node": "^25.5.0", diff --git a/fabric/js/package-lock.json b/fabric/js/package-lock.json index aba5223..c264373 100644 --- a/fabric/js/package-lock.json +++ b/fabric/js/package-lock.json @@ -42,7 +42,7 @@ "dependencies": { "@noble/curves": "^1.8.0", "@spacesprotocol/fabric-core": "*", - "@spacesprotocol/libveritas": "^0.0.0-dev.20260407165333" + "@spacesprotocol/libveritas": "^0.1.4" }, "bin": { "fabric": "dist/cli.js" @@ -972,9 +972,9 @@ "link": true }, "node_modules/@spacesprotocol/libveritas": { - "version": "0.0.0-dev.20260407165333", - "resolved": "https://registry.npmjs.org/@spacesprotocol/libveritas/-/libveritas-0.0.0-dev.20260407165333.tgz", - "integrity": "sha512-YTBvFbODHzr5XhpApkDuFXf6eWy+kqhCV+7rYHXDW/YYd25uWqqcAOIRXRPPGxRNgzbviDFqMRNAuhy5Vtc7UQ==" + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@spacesprotocol/libveritas/-/libveritas-0.1.4.tgz", + "integrity": "sha512-65HvMZE5750AW83rQRQdWln3YWwu6Lcs7SBhtXGBUcmyjRNOZ0NfGGIvUCzqhUYAvCvyqSt+A89Zx3K50f/ssQ==" }, "node_modules/@spacesprotocol/react-native-libveritas": { "version": "0.0.0-dev.20260407170644", diff --git a/fabric/kotlin/build.gradle.kts b/fabric/kotlin/build.gradle.kts index 3363314..bc3e06a 100644 --- a/fabric/kotlin/build.gradle.kts +++ b/fabric/kotlin/build.gradle.kts @@ -19,9 +19,9 @@ dependencies { // compileOnly — consumers provide the right variant at runtime: // Android: org.spacesprotocol:libveritas (AAR) // JVM: org.spacesprotocol:libveritas-jvm (JAR) - compileOnly("org.spacesprotocol:libveritas-jvm:0.1.2") + compileOnly("org.spacesprotocol:libveritas-jvm:0.1.4") // CLI needs it at runtime - runtimeOnly("org.spacesprotocol:libveritas-jvm:0.1.2") + runtimeOnly("org.spacesprotocol:libveritas-jvm:0.1.4") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") compileOnly("fr.acinq.secp256k1:secp256k1-kmp:0.17.3") diff --git a/fabric/kotlin/src/main/kotlin/org/spacesprotocol/fabric/Fabric.kt b/fabric/kotlin/src/main/kotlin/org/spacesprotocol/fabric/Fabric.kt index f5d7143..9f6d726 100644 --- a/fabric/kotlin/src/main/kotlin/org/spacesprotocol/fabric/Fabric.kt +++ b/fabric/kotlin/src/main/kotlin/org/spacesprotocol/fabric/Fabric.kt @@ -300,7 +300,7 @@ class Fabric( var batch = lookup.start() while (batch.isNotEmpty()) { if (batch == prevBatch) break - val verified = resolveFlat(batch) + val verified = resolveFlat(batch, true) val zones = verified.zones() prevBatch = batch batch = lookup.advance(zones) @@ -319,7 +319,7 @@ class Fabric( var batch = lookup.start() while (batch.isNotEmpty()) { if (batch == prevBatch) break - val verified = resolveFlat(batch) + val verified = resolveFlat(batch, false) allCertBytes.addAll(verified.certificates()) val zones = verified.zones() prevBatch = batch @@ -329,7 +329,7 @@ class Fabric( return createCertificateChain(handle, allCertBytes) } - private fun resolveFlat(handles: List): VerifiedMessage { + private fun resolveFlat(handles: List, hints: Boolean): VerifiedMessage { val bySpace = mutableMapOf>() for (h in handles) { val (space, label) = parseHandle(h) @@ -339,9 +339,11 @@ class Fabric( val queries = mutableListOf() for ((space, labels) in bySpace) { var epochHint: EpochHint? = null - synchronized(lock) { - zoneCache[space]?.let { cached -> - epochHintFromZone(cached)?.let { epochHint = it } + if (hints) { + synchronized(lock) { + zoneCache[space]?.let { cached -> + epochHintFromZone(cached)?.let { epochHint = it } + } } } queries.add(Query(space = space, handles = labels, epochHint = epochHint)) diff --git a/fabric/python/fabric/client.py b/fabric/python/fabric/client.py index 1591040..de460f9 100644 --- a/fabric/python/fabric/client.py +++ b/fabric/python/fabric/client.py @@ -324,7 +324,7 @@ def resolve_all(self, handles: list[str]) -> ResolvedBatch: while batch: if batch == prev_batch: break - verified = self._resolve_flat(batch) + verified = self._resolve_flat(batch, hints=True) zones = verified.zones() prev_batch = batch batch = lookup.advance(zones) @@ -344,7 +344,7 @@ def export(self, handle: str) -> bytes: while batch: if batch == prev_batch: break - verified = self._resolve_flat(batch) + verified = self._resolve_flat(batch, hints=False) all_cert_bytes.extend(verified.certificates()) zones = verified.zones() prev_batch = batch @@ -514,7 +514,7 @@ def _update_anchors(self, trust_id: Optional[str] = None, kind: str = ""): else: self._observed = trust_set - def _resolve_flat(self, handles: list[str]) -> lv.VerifiedMessage: + def _resolve_flat(self, handles: list[str], *, hints: bool = True) -> lv.VerifiedMessage: by_space: dict[str, list[str]] = {} for h in handles: space, label = _parse_handle(h) @@ -523,12 +523,13 @@ def _resolve_flat(self, handles: list[str]) -> lv.VerifiedMessage: queries = [] for space, labels in by_space.items(): q = _Query(space=space, handles=labels) - with self._lock: - cached = self._zone_cache.get(space) - if cached is not None: - hint = _epoch_hint_from_zone(cached) - if hint is not None: - q.epoch_hint = hint + if hints: + with self._lock: + cached = self._zone_cache.get(space) + if cached is not None: + hint = _epoch_hint_from_zone(cached) + if hint is not None: + q.epoch_hint = hint queries.append(q) return self._query(_QueryRequest(queries=queries)) diff --git a/fabric/python/pyproject.toml b/fabric/python/pyproject.toml index 8693f64..84d7dd5 100644 --- a/fabric/python/pyproject.toml +++ b/fabric/python/pyproject.toml @@ -3,7 +3,7 @@ name = "fabric-resolver" version = "0.1.0" description = "Python client for the certrelay fabric network" requires-python = ">=3.10" -dependencies = ["libveritas>=0.1.2"] +dependencies = ["libveritas>=0.1.4"] [project.optional-dependencies] signing = ["coincurve"] diff --git a/fabric/rust/src/client.rs b/fabric/rust/src/client.rs index 1540fae..e4da536 100644 --- a/fabric/rust/src/client.rs +++ b/fabric/rust/src/client.rs @@ -587,7 +587,7 @@ impl Fabric { } let strs: Vec = batch.iter().map(|s| s.to_string()).collect(); let refs: Vec<&str> = strs.iter().map(|s| s.as_str()).collect(); - let (verified, relay_url) = self.resolve_flat(&refs).await?; + let (verified, relay_url) = self.resolve_flat(&refs, true).await?; prev_batch = batch; batch = lookup.advance(&verified.zones); all_zones.extend(verified.zones); @@ -622,7 +622,7 @@ impl Fabric { } let strs: Vec = batch.iter().map(|s| s.to_string()).collect(); let refs: Vec<&str> = strs.iter().map(|s| s.as_str()).collect(); - let (verified, _relay_url) = self.resolve_flat(&refs).await?; + let (verified, _relay_url) = self.resolve_flat(&refs, false).await?; prev_batch = batch; batch = lookup.advance(&verified.zones); all_verified.push(verified); @@ -638,7 +638,11 @@ impl Fabric { } /// Resolve a flat list of non-dotted handles in a single relay query. - async fn resolve_flat(&self, handles: &[&str]) -> Result<(VerifiedMessage, String)> { + async fn resolve_flat( + &self, + handles: &[&str], + hints: bool, + ) -> Result<(VerifiedMessage, String)> { let mut by_space: HashMap> = HashMap::new(); for &h in handles { let sname = SName::try_from(h).map_err(|e| { @@ -658,9 +662,11 @@ impl Fabric { .into_iter() .map(|(space, handles)| { let mut q = Query::new(space.clone(), handles); - if let Some(zone) = self.root_cache.get(&space) { - if let Some(hint) = epoch_hint_from_zone(&zone) { - q = q.with_epoch_hint(hint); + if hints { + if let Some(zone) = self.root_cache.get(&space) { + if let Some(hint) = epoch_hint_from_zone(&zone) { + q = q.with_epoch_hint(hint); + } } } q diff --git a/fabric/swift/Package.swift b/fabric/swift/Package.swift index 0437329..b9475e5 100644 --- a/fabric/swift/Package.swift +++ b/fabric/swift/Package.swift @@ -9,7 +9,7 @@ let package = Package( .executable(name: "fabric", targets: ["FabricCLI"]), ], dependencies: [ - .package(url: "https://github.com/spacesprotocol/libveritas-swift.git", exact: "0.1.2"), + .package(url: "https://github.com/spacesprotocol/libveritas-swift.git", exact: "0.1.4"), .package(url: "https://github.com/21-DOT-DEV/swift-secp256k1.git", exact: "0.17.0"), ], targets: [ diff --git a/fabric/swift/Sources/Fabric/Fabric.swift b/fabric/swift/Sources/Fabric/Fabric.swift index 7038419..73caca6 100644 --- a/fabric/swift/Sources/Fabric/Fabric.swift +++ b/fabric/swift/Sources/Fabric/Fabric.swift @@ -411,7 +411,7 @@ public final class Fabric: @unchecked Sendable { var batch = lookup.start() while !batch.isEmpty { if batch == prevBatch { break } - let verified = try await resolveFlat(batch) + let verified = try await resolveFlat(batch, hints: true) let zones = verified.zones() prevBatch = batch batch = try lookup.advance(zones: zones) @@ -432,7 +432,7 @@ public final class Fabric: @unchecked Sendable { var batch = lookup.start() while !batch.isEmpty { if batch == prevBatch { break } - let verified = try await resolveFlat(batch) + let verified = try await resolveFlat(batch, hints: false) allCertBytes.append(contentsOf: verified.certificates()) let zones = verified.zones() prevBatch = batch @@ -472,7 +472,7 @@ public final class Fabric: @unchecked Sendable { } /// Resolve a flat list of non-dotted handles in a single relay query. - private func resolveFlat(_ handles: [String]) async throws -> VerifiedMessage { + private func resolveFlat(_ handles: [String], hints: Bool) async throws -> VerifiedMessage { var bySpace = [String: [String]]() for h in handles { let parsed = parseHandle(h) @@ -482,14 +482,16 @@ public final class Fabric: @unchecked Sendable { var queries = [Query]() for (space, labels) in bySpace { var q = Query(space: space, handles: labels) - lock.lock() - let cached = zoneCache[space] - lock.unlock() - if let cached, case .exists(let stateRoot, _, _, let blockHeight, _) = cached.commitment { - q.epoch_hint = EpochHint( - root: stateRoot.map { String(format: "%02x", $0) }.joined(), - height: blockHeight - ) + if hints { + lock.lock() + let cached = zoneCache[space] + lock.unlock() + if let cached, case .exists(let stateRoot, _, _, let blockHeight, _) = cached.commitment { + q.epoch_hint = EpochHint( + root: stateRoot.map { String(format: "%02x", $0) }.joined(), + height: blockHeight + ) + } } queries.append(q) }