diff --git a/Cargo.lock b/Cargo.lock index 3278e574..3c9c6cff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,15 +26,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -136,46 +127,12 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" -[[package]] -name = "aws-lc-rs" -version = "1.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b281d307588d634de920874890732659e2e7672f72b5e10e81badc1a8a83621e" -dependencies = [ - "aws-lc-sys", - "zeroize", -] - -[[package]] -name = "aws-lc-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bff6c3b54fad79a2e60b8102caf565819711497c1f5f092f49508e2f5c31b27" -dependencies = [ - "cc", - "cmake", - "dunce", - "fs_extra", - "pkg-config", -] - [[package]] name = "axum" version = "0.8.9" @@ -228,45 +185,18 @@ dependencies = [ "tracing", ] -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "base64" version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" -[[package]] -name = "base64ct" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "binout" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -282,15 +212,6 @@ dependencies = [ "dyn_size_of", ] -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.12.1" @@ -302,10 +223,9 @@ dependencies = [ [[package]] name = "blockzilla" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", - "bincode", "blockzilla-archive-v2", "blockzilla-compact", "blockzilla-compact-v2-reader", @@ -314,30 +234,26 @@ dependencies = [ "blockzilla-primitives", "blockzilla-program-logs", "blockzilla-registry", - "bs58", - "clap 4.6.6", + "clap", "five8", "gxhash", "itoa", "libc", "memmap2", - "rayon", - "reqwest", "serde", "serde_json", - "sha2 0.11.0", - "solana-pubkey", - "solana-vote-interface", + "sha2", "tempfile", "tracing", "tracing-subscriber", - "wincode 0.6.1", + "url", + "wincode", "zstd", ] [[package]] name = "blockzilla-archive-gateway" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "async-stream", @@ -348,7 +264,7 @@ dependencies = [ "blockzilla-read-sdk", "blockzilla-registry", "bytes", - "clap 4.6.6", + "clap", "futures-core", "hex", "http", @@ -356,22 +272,22 @@ dependencies = [ "libc", "serde", "serde_json", - "sha2 0.11.0", + "sha2", "subtle", "tempfile", "tokio", "tokio-util", "tower", - "tower-http 0.7.1", + "tower-http", "tracing", "tracing-subscriber", - "wincode 0.6.1", + "wincode", "zstd", ] [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -379,8 +295,8 @@ dependencies = [ "blockzilla-program-logs", "blockzilla-solana-wire", "serde", - "sha2 0.11.0", - "wincode 0.6.1", + "sha2", + "wincode", ] [[package]] @@ -392,12 +308,12 @@ dependencies = [ "bytes", "serde", "serde_json", - "sha2 0.11.0", + "sha2", ] [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -409,13 +325,12 @@ dependencies = [ "heapless", "prost", "serde", - "solana-pubkey", - "wincode 0.6.1", + "wincode", ] [[package]] name = "blockzilla-compact-v2-reader" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", @@ -428,23 +343,23 @@ dependencies = [ "blockzilla-source-cache", "blockzilla-source-http", "blockzilla-source-local", - "ed25519-dalek 3.0.0", + "ed25519-dalek", + "five8", "rayon", "serde", "serde_json", - "sha2 0.11.0", + "sha2", "smallvec", - "solana-signature", "tempfile", "thiserror", "url", - "wincode 0.6.1", + "wincode", "zstd", ] [[package]] name = "blockzilla-dump-examples" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla", @@ -452,10 +367,10 @@ dependencies = [ [[package]] name = "blockzilla-get-block" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", - "base64 0.23.1", + "base64", "blockzilla-archive-v2", "blockzilla-bank-stream-v2", "blockzilla-compact", @@ -463,8 +378,8 @@ dependencies = [ "blockzilla-program-logs", "blockzilla-registry", "bytes", - "clap 4.6.6", - "ed25519-dalek 3.0.0", + "clap", + "ed25519-dalek", "five8", "futures-channel", "futures-util", @@ -473,106 +388,102 @@ dependencies = [ "ruzstd", "serde", "serde_json", - "sha2 0.11.0", - "solana-signature", + "sha2", "thiserror", "tokio", "wasm-bindgen", "wasm-bindgen-futures", - "wincode 0.6.1", + "wincode", "worker", "zstd", ] [[package]] name = "blockzilla-live-format" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-archive-v2", "blockzilla-compact", "blockzilla-primitives", "serde", - "wincode 0.6.1", + "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" dependencies = [ "criterion", ] [[package]] name = "blockzilla-model" -version = "0.2.0" +version = "0.3.0" dependencies = [ "serde", "serde_json", - "sha2 0.11.0", + "sha2", "thiserror", ] [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", - "wincode 0.6.1", + "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", - "wincode 0.6.1", + "wincode", ] [[package]] name = "blockzilla-read-sdk" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-archive-v2", "blockzilla-compact", "blockzilla-primitives", "blockzilla-program-logs", "blockzilla-registry", + "blockzilla-source", + "blockzilla-source-http", "rayon", - "reqwest", "rustix", "serde", "serde_json", - "sha2 0.11.0", + "sha2", "smallvec", - "solana-pubkey", "tempfile", "thiserror", "url", - "wincode 0.6.1", + "wincode", "zstd", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] name = "blockzilla-sample-block-bench" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", @@ -581,38 +492,35 @@ dependencies = [ "blockzilla-primitives", "serde", "serde_json", - "sha2 0.11.0", - "wincode 0.6.1", + "sha2", + "wincode", "zstd", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", "prost", - "prost-build", - "protoc-bin-vendored", "quick-protobuf", "ruzstd", "serde", "serde_json", - "wincode 0.6.1", + "wincode", "zstd", ] [[package]] name = "blockzilla-source" -version = "0.2.0" +version = "0.3.0" dependencies = [ "thiserror", ] [[package]] name = "blockzilla-source-cache" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-source", "blockzilla-source-http", @@ -622,17 +530,20 @@ dependencies = [ [[package]] name = "blockzilla-source-http" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-source", - "reqwest", - "sha2 0.11.0", + "httparse", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "sha2", "url", ] [[package]] name = "blockzilla-source-local" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-source", "rustix", @@ -640,30 +551,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.6", -] - [[package]] name = "bs58" version = "0.5.1" @@ -715,34 +602,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cfg_aliases" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" - -[[package]] -name = "cfg_eval" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "chacha20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "rand_core 0.10.1", -] - [[package]] name = "chrono" version = "0.4.45" @@ -781,21 +640,6 @@ dependencies = [ "half", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.6.6" @@ -815,7 +659,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -836,15 +680,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" -[[package]] -name = "cmake" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" -dependencies = [ - "cc", -] - [[package]] name = "colorchoice" version = "1.0.5" @@ -861,12 +696,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "const-oid" version = "0.10.2" @@ -889,15 +718,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - [[package]] name = "cpufeatures" version = "0.3.1" @@ -917,7 +737,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.6.6", + "clap", "criterion-plot", "itertools 0.13.0", "num-traits", @@ -973,16 +793,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.2" @@ -992,22 +802,6 @@ dependencies = [ "hybrid-array", ] -[[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 0.2.9", - "rustc_version", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" version = "5.0.0" @@ -1015,10 +809,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", + "cpufeatures", "curve25519-dalek-derive", - "digest 0.11.3", - "fiat-crypto 0.3.0", + "digest", + "fiat-crypto", "rustc_version", "subtle", "zeroize", @@ -1054,7 +848,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.119", ] @@ -1075,35 +869,15 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid 0.9.6", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common 0.1.7", -] - [[package]] name = "digest" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", - "const-oid 0.10.2", - "crypto-common 0.2.2", + "block-buffer", + "const-oid", + "crypto-common", ] [[package]] @@ -1117,49 +891,19 @@ dependencies = [ "syn 3.0.6", ] -[[package]] -name = "dunce" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" - [[package]] name = "dyn_size_of" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a742b95783b1f45b900129082cbc47717b6a77ee8d17eea70a8ea62462f5de3" -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8", - "signature 2.2.0", -] - [[package]] name = "ed25519" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" dependencies = [ - "signature 3.0.0", -] - -[[package]] -name = "ed25519-dalek" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" -dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", - "serde", - "sha2 0.10.9", - "subtle", - "zeroize", + "signature", ] [[package]] @@ -1168,9 +912,9 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" dependencies = [ - "curve25519-dalek 5.0.0", - "ed25519 3.0.0", - "sha2 0.11.0", + "curve25519-dalek", + "ed25519", + "sha2", "subtle", "zeroize", ] @@ -1181,25 +925,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - [[package]] name = "errno" version = "0.3.14" @@ -1216,12 +941,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - [[package]] name = "fiat-crypto" version = "0.3.0" @@ -1243,33 +962,12 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -1279,12 +977,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "futures-channel" version = "0.3.34" @@ -1346,16 +1038,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.17" @@ -1363,10 +1045,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1376,11 +1056,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", - "js-sys", "libc", "r-efi", - "rand_core 0.10.1", - "wasm-bindgen", ] [[package]] @@ -1413,25 +1090,10 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.15.5" +name = "heapless" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash", -] - -[[package]] -name = "hashbrown" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" - -[[package]] -name = "heapless" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ba4bd83f9415b58b4ed8dc5714c76e626a105be4646c02630ad730ad3b5aa4" +checksum = "25ba4bd83f9415b58b4ed8dc5714c76e626a105be4646c02630ad730ad3b5aa4" dependencies = [ "hash32", "serde_core", @@ -1444,15 +1106,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hex" version = "0.4.3" @@ -1504,15 +1157,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.14" @@ -1540,22 +1184,6 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" -dependencies = [ - "http", - "hyper", - "hyper-util", - "rustls", - "tokio", - "tokio-rustls", - "tower-service", ] [[package]] @@ -1564,21 +1192,13 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ - "base64 0.22.1", "bytes", - "futures-channel", - "futures-util", "http", "http-body", "hyper", - "ipnet", - "libc", - "percent-encoding", "pin-project-lite", - "socket2", "tokio", "tower-service", - "tracing", ] [[package]] @@ -1691,22 +1311,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "2.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" -dependencies = [ - "equivalent", - "hashbrown 0.17.1", -] - -[[package]] -name = "ipnet" -version = "2.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" - [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -1831,27 +1435,12 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" -[[package]] -name = "lru-slab" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" - [[package]] name = "matchers" version = "0.2.0" @@ -1899,27 +1488,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" @@ -1932,22 +1500,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -1957,17 +1509,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "num-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2011,64 +1552,18 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", -] - [[package]] name = "pastey" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.34.0", - "env_logger", - "log", - "nom", -] - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -2110,16 +1605,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.34" @@ -2163,25 +1648,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.119", -] - -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -2201,25 +1667,6 @@ dependencies = [ "prost-derive", ] -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools 0.14.0", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.119", - "tempfile", -] - [[package]] name = "prost-derive" version = "0.14.4" @@ -2233,85 +1680,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quick-protobuf" version = "0.8.1" @@ -2321,63 +1689,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "quinn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8" -dependencies = [ - "bytes", - "cfg_aliases", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls", - "socket2", - "thiserror", - "tokio", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-proto" -version = "0.11.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04759210543be93709136e28212294a659ef5001836ff4eab4d663e4529bba83" -dependencies = [ - "aws-lc-rs", - "bytes", - "getrandom 0.4.3", - "lru-slab", - "rand", - "rand_pcg", - "ring", - "rustc-hash", - "rustls", - "rustls-pki-types", - "slab", - "thiserror", - "tinyvec", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-udp" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35a133f956daabe89a61a685c2649f13d82d5aa4bd5d12d1277e1072a21c0694" -dependencies = [ - "cfg_aliases", - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.61.2", -] - [[package]] name = "quote" version = "1.0.47" @@ -2393,41 +1704,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" -dependencies = [ - "chacha20", - "getrandom 0.4.3", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] - -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - -[[package]] -name = "rand_pcg" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" -dependencies = [ - "rand_core 0.10.1", -] - [[package]] name = "rayon" version = "1.12.0" @@ -2448,15 +1724,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.13.1", -] - [[package]] name = "regex" version = "1.13.1" @@ -2486,43 +1753,6 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" -[[package]] -name = "reqwest" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "js-sys", - "log", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls", - "rustls-pki-types", - "rustls-platform-verifier", - "sync_wrapper", - "tokio", - "tokio-rustls", - "tower", - "tower-http 0.6.11", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "ring" version = "0.17.14" @@ -2535,13 +1765,7 @@ dependencies = [ "libc", "untrusted", "windows-sys 0.52.0", -] - -[[package]] -name = "rustc-hash" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" +] [[package]] name = "rustc_version" @@ -2558,7 +1782,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -2571,8 +1795,8 @@ version = "0.23.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" dependencies = [ - "aws-lc-rs", "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -2597,7 +1821,6 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" dependencies = [ - "web-time", "zeroize", ] @@ -2634,7 +1857,6 @@ version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ - "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -2679,19 +1901,13 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "security-framework" version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -2797,39 +2013,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "3.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee78f1fbe43ac4a0e47aadb3dbd357b69eb0d3793e948624cd03dd2750ab1c0a" -dependencies = [ - "serde_core", - "serde_with_macros", -] - -[[package]] -name = "serde_with_macros" -version = "3.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8705578779c2b6bd90d84d66eb2e206b708b1a4d7b9f17641b293545bf1c7e46" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.11.0" @@ -2837,8 +2020,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", + "cpufeatures", + "digest", ] [[package]] @@ -2866,15 +2049,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "rand_core 0.6.4", -] - [[package]] name = "signature" version = "3.0.0" @@ -2919,219 +2093,12 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "solana-address" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c93e262f671bf402e1040e4a7e40b05d81da5956c7681948c975a0997517bb" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "serde_derive", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode 0.5.5", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-clock" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0acdace90d96e2c9e70d681465b4fe888b6bcf27c354ae9774e9f8a3b72923d" -dependencies = [ - "solana-sdk-macro", -] - -[[package]] -name = "solana-define-syscall" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8209ece2bd9f1450e672858ffc0e5c8c786ff6916d2a862b126dd0128f380f" - -[[package]] -name = "solana-hash" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4c847893a2ea50b4ae3ca723b124e07cd0544fecea3598f785168f9b78333f" -dependencies = [ - "five8", - "serde", - "serde_derive", -] - -[[package]] -name = "solana-instruction" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ebb0ffd19263051bc3f683fcc086134b8ff23af894dcb63f7563c7137b42f1" -dependencies = [ - "solana-define-syscall", - "solana-instruction-error", - "solana-pubkey", -] - -[[package]] -name = "solana-instruction-error" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e7db78c122d02189619490b1fef04a2a042c389662920617c0e6381fdf8fdd" -dependencies = [ - "num-traits", - "solana-program-error", -] - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab5a422939ca3b81180f79c87f43600728e4c5513d6034902675f96df25d033" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-rent" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f0d780bf8e8a1fe8b5b5fce1acad6b209485b86dec246e7523d5e4a8b7c7fc" -dependencies = [ - "solana-sdk-macro", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - -[[package]] -name = "solana-sdk-ids" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def234c1956ff616d46c9dd953f251fa7096ddbaa6d52b165218de97882b7280" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sdk-macro" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8765316242300c48242d84a41614cb3388229ec353ba464f6fe62a733e41806f" -dependencies = [ - "bs58", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "solana-serde-varint" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "950e5b83e839dc0f92c66afc124bb8f40e89bc90f0579e8ec5499296d27f54e3" -dependencies = [ - "serde", -] - -[[package]] -name = "solana-serialize-utils" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761357b0853c9623bf12c1d2314b3d6160a85b087b84c45224fb85766d22616b" -dependencies = [ - "solana-instruction-error", - "solana-pubkey", - "solana-sanitize", -] - -[[package]] -name = "solana-short-vec" -version = "3.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d8250a4495aad49ad20556a607da53bdcb20de78da10b65afbf918b7f1de647" -dependencies = [ - "serde_core", -] - -[[package]] -name = "solana-signature" -version = "3.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0364c7577c3c82a693ce28a1febc8d1b5d1b0a175fdc2114ae6186b69effe1e" -dependencies = [ - "ed25519-dalek 2.2.0", - "five8", - "serde", - "solana-sanitize", - "wincode 0.5.5", -] - -[[package]] -name = "solana-vote-interface" -version = "6.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a7a204b455a53fe8c9a26a6885391a5896835e06694dbe0cf37c580f82f128" -dependencies = [ - "cfg_eval", - "num-derive", - "num-traits", - "serde", - "serde_derive", - "serde_with", - "solana-clock", - "solana-hash", - "solana-instruction", - "solana-instruction-error", - "solana-pubkey", - "solana-rent", - "solana-sdk-ids", - "solana-serde-varint", - "solana-serialize-utils", - "solana-short-vec", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -3192,9 +2159,6 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -dependencies = [ - "futures-core", -] [[package]] name = "synstructure" @@ -3220,24 +2184,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.20" @@ -3329,16 +2275,6 @@ dependencies = [ "syn 3.0.6", ] -[[package]] -name = "tokio-rustls" -version = "0.26.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c85f2c3ef0b1cd58b36682f4b17aaa995f0e5db534d85692b4903abce21f67" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.19" @@ -3352,36 +2288,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml_datetime" -version = "1.1.1+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.25.13+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" -dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" -dependencies = [ - "winnow", -] - [[package]] name = "tower" version = "0.5.3" @@ -3399,31 +2305,13 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" -dependencies = [ - "bitflags 2.13.1", - "bytes", - "futures-util", - "http", - "http-body", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", - "url", -] - [[package]] name = "tower-http" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" dependencies = [ - "bitflags 2.13.1", + "bitflags", "bytes", "http", "http-body", @@ -3509,12 +2397,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "twox-hash" version = "2.1.4" @@ -3533,12 +2415,6 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "untrusted" version = "0.9.0" @@ -3575,18 +2451,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "voracious_radix_sort" version = "1.2.0" @@ -3606,15 +2470,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -3699,16 +2554,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "webpki-root-certs" version = "1.0.9" @@ -3749,19 +2594,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "wincode" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d967db7705dc29120bb6e8ce5b5a2e27734ed5976d1c904e95bd238d1c3c5a" -dependencies = [ - "pastey", - "proc-macro2", - "quote", - "thiserror", - "wincode-derive 0.4.6", -] - [[package]] name = "wincode" version = "0.6.1" @@ -3773,19 +2605,7 @@ dependencies = [ "quote", "smallvec", "thiserror", - "wincode-derive 0.5.1", -] - -[[package]] -name = "wincode-derive" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ab90b719560d0fda79c74550ad1c948d17b118765942838055ebaf34d67071" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.119", + "wincode-derive", ] [[package]] @@ -3888,15 +2708,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" -dependencies = [ - "memchr", -] - [[package]] name = "worker" version = "0.8.5" diff --git a/Cargo.toml b/Cargo.toml index 8409701b..78c437e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ exclude = [ ] [workspace.package] -version = "0.2.0" +version = "0.3.0" edition = "2024" rust-version = "1.98" license = "MIT" diff --git a/README.md b/README.md index dc1364c7..5956709c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ RUSTFLAGS="-C target-cpu=native" cargo run --locked -p blockzilla -- \ ``` This reads five block rows from the public Foundation archive. No API key is needed. +Add `--no-cache` to stream directly over HTTPS with zero local disk cache, or +`--output summary` to verify and decode an epoch with live throughput bars. Use `--help` to see the commands, or start with the [small examples](examples). ## In this repository diff --git a/bench/sample-block/Cargo.toml b/bench/sample-block/Cargo.toml index ac8f6705..31dfd0ca 100644 --- a/bench/sample-block/Cargo.toml +++ b/bench/sample-block/Cargo.toml @@ -14,9 +14,9 @@ blockzilla-compact-v2-reader = { path = "../../crates/compact-v2/blockzilla-comp blockzilla-primitives = { path = "../../crates/blockzilla-primitives" } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } wincode = { version = "=0.6.1", features = ["derive"] } -zstd = "0.14.0" +zstd = { version = "0.14.0", default-features = false } [lints] workspace = true diff --git a/blockzilla/archive-gateway/Cargo.toml b/blockzilla/archive-gateway/Cargo.toml index 81a2b99e..3342baee 100644 --- a/blockzilla/archive-gateway/Cargo.toml +++ b/blockzilla/archive-gateway/Cargo.toml @@ -10,14 +10,14 @@ description = "Read-only HTTP range gateway for immutable Blockzilla Archive V2 autobins = false [dependencies] -blockzilla-archive-v2 = { path = "../../crates/compact-v2/blockzilla-archive-v2", default-features = false, version = "0.2.0" } -blockzilla-compact = { path = "../../crates/compact-v2/blockzilla-compact", default-features = false, version = "0.2.0" } -blockzilla-primitives = { path = "../../crates/blockzilla-primitives", default-features = false, version = "0.2.0" } -blockzilla-registry = { path = "../../crates/compact-v2/blockzilla-registry", default-features = false, version = "0.2.0" } +blockzilla-archive-v2 = { path = "../../crates/compact-v2/blockzilla-archive-v2", default-features = false, version = "0.3.0" } +blockzilla-compact = { path = "../../crates/compact-v2/blockzilla-compact", default-features = false, version = "0.3.0" } +blockzilla-primitives = { path = "../../crates/blockzilla-primitives", default-features = false, version = "0.3.0" } +blockzilla-registry = { path = "../../crates/compact-v2/blockzilla-registry", default-features = false, version = "0.3.0" } anyhow = "1.0.104" async-stream = "0.3.6" axum = { version = "0.8.9", features = ["http1", "json", "tokio"] } -blockzilla-read-sdk = { package = "blockzilla-read-sdk", path = "../../crates/reader/blockzilla-read-sdk", version = "0.2.0" } +blockzilla-read-sdk = { package = "blockzilla-read-sdk", path = "../../crates/reader/blockzilla-read-sdk", version = "0.3.0" } bytes = "1.12.1" clap = { version = "4.6.6", features = ["derive", "env"] } hex = "0.4.3" @@ -25,7 +25,7 @@ http = "1.5.0" futures-core = "0.3.34" serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } subtle = "2.6.1" tokio = { version = "1.53.1", features = ["fs", "io-util", "macros", "net", "rt-multi-thread", "signal"] } tokio-util = { version = "0.7.19", features = ["io"] } @@ -41,7 +41,7 @@ libc = "0.2.189" http-body-util = "0.1.5" tempfile = "3.27.0" wincode = { version = "=0.6.1", features = ["derive"] } -zstd = "0.14.0" +zstd = { version = "0.14.0", default-features = false } [[bin]] name = "blockzilla-archive-gateway" diff --git a/blockzilla/builder/Cargo.lock b/blockzilla/builder/Cargo.lock index c0877dda..af009c96 100644 --- a/blockzilla/builder/Cargo.lock +++ b/blockzilla/builder/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -81,35 +63,12 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "binout" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -136,7 +95,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -162,7 +121,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -172,88 +131,54 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] -[[package]] -name = "borsh" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88b7ea17d208c4193f2c1e6de3c35fe71f98c96982d5ced308bdcc749ff6e1f" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f347189c62a579b8cd5f80714efa178f52e461dc2e6d701d264f5ff22e566c" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "bs58" version = "0.5.1" @@ -299,27 +224,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.6.7" @@ -339,7 +243,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -416,12 +320,6 @@ version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.2.1" @@ -450,7 +348,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.117", ] @@ -494,25 +392,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - [[package]] name = "errno" version = "0.3.10" @@ -556,33 +435,12 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -609,17 +467,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -629,22 +476,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -653,7 +491,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -682,25 +520,16 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hivezilla-direct-agave" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", "blockzilla-bank-stream-v2", "blockzilla-compact", "blockzilla-primitives", - "clap 4.6.7", + "clap", "libc", "rusqlite", "serde", @@ -712,15 +541,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.10" @@ -736,31 +556,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "indexmap" -version = "2.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" -dependencies = [ - "equivalent", - "hashbrown 0.17.0", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.9" @@ -809,22 +610,6 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" - [[package]] name = "memchr" version = "2.6.3" @@ -845,44 +630,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "minimal-lexical" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c64630dcdd71f1a64c435f54885086a0de5d6a12d104d69b165fb7d5286d677" - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - -[[package]] -name = "nom" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1" -dependencies = [ - "memchr", - "minimal-lexical", - "version_check", -] [[package]] name = "once_cell" @@ -890,58 +637,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.0", -] - [[package]] name = "pastey" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.33.3", - "env_logger", - "log", - "nom", -] - -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.1", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -963,25 +664,6 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.106" @@ -991,136 +673,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.117", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quote" version = "1.0.45" @@ -1156,44 +708,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" - [[package]] name = "rsqlite-vfs" version = "0.1.1" @@ -1210,7 +724,7 @@ version = "0.40.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3" dependencies = [ - "bitflags 2.13.1", + "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -1225,7 +739,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1238,12 +752,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "seedable_hash" version = "0.2.3" @@ -1316,59 +824,6 @@ version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" -[[package]] -name = "solana-address" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01332a01c0a3098404d55a724c8d9a92aed4a50fe40a7dd0c7a51e29274c14de" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-define-syscall" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8209ece2bd9f1450e672858ffc0e5c8c786ff6916d2a862b126dd0128f380f" - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f71b7a414de2ced1071f015834e9be581592d013432adbd06d02e4af11eba9" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - [[package]] name = "sqlite-wasm-rs" version = "0.5.5" @@ -1387,12 +842,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -1434,24 +883,6 @@ dependencies = [ "windows-sys 0.61.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.19" @@ -1487,23 +918,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.19.0" @@ -1516,12 +930,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "utf8parse" version = "0.2.2" @@ -1534,18 +942,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "voracious_radix_sort" version = "1.2.0" @@ -1600,37 +996,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "wincode" version = "0.6.1" @@ -1668,7 +1033,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -1680,67 +1045,34 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1753,86 +1085,33 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" -dependencies = [ - "memchr", -] - -[[package]] -name = "zerocopy" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "zillastream-capture-core" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", diff --git a/blockzilla/builder/Cargo.toml b/blockzilla/builder/Cargo.toml index 70b0b665..c7660c4b 100644 --- a/blockzilla/builder/Cargo.toml +++ b/blockzilla/builder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hivezilla-direct-agave" -version = "0.2.0" +version = "0.3.0" edition = "2024" rust-version = "1.97.1" license = "MIT" diff --git a/blockzilla/cli/Cargo.toml b/blockzilla/cli/Cargo.toml index 9fe88205..d6aa089b 100644 --- a/blockzilla/cli/Cargo.toml +++ b/blockzilla/cli/Cargo.toml @@ -27,35 +27,32 @@ name = "blockzilla" path = "src/main.rs" [dependencies] -blockzilla-model = { version = "0.2.0", path = "../../crates/blockzilla-model" } -blockzilla-compact-v2-reader = { path = "../../crates/compact-v2/blockzilla-compact-v2-reader", features = ["http"], version = "0.2.0" } -blockzilla-archive-v2 = { path = "../../crates/compact-v2/blockzilla-archive-v2", default-features = false, version = "0.2.0" } -blockzilla-compact = { path = "../../crates/compact-v2/blockzilla-compact", default-features = false, version = "0.2.0" } -blockzilla-live-format = { path = "../../crates/blockzilla-live-format", default-features = false, version = "0.2.0" } -blockzilla-primitives = { path = "../../crates/blockzilla-primitives", default-features = false, version = "0.2.0" } -blockzilla-program-logs = { path = "../../crates/parser/blockzilla-program-logs", default-features = false, version = "0.2.0" } -blockzilla-registry = { path = "../../crates/compact-v2/blockzilla-registry", default-features = false, version = "0.2.0" } +blockzilla-model = { version = "0.3.0", path = "../../crates/blockzilla-model" } +blockzilla-compact-v2-reader = { path = "../../crates/compact-v2/blockzilla-compact-v2-reader", features = ["http"], version = "0.3.0" } +blockzilla-archive-v2 = { path = "../../crates/compact-v2/blockzilla-archive-v2", default-features = false, version = "0.3.0" } +blockzilla-compact = { path = "../../crates/compact-v2/blockzilla-compact", default-features = false, version = "0.3.0" } +blockzilla-live-format = { path = "../../crates/blockzilla-live-format", default-features = false, version = "0.3.0" } +blockzilla-primitives = { path = "../../crates/blockzilla-primitives", default-features = false, version = "0.3.0" } +blockzilla-program-logs = { path = "../../crates/parser/blockzilla-program-logs", default-features = false, version = "0.3.0" } +blockzilla-registry = { path = "../../crates/compact-v2/blockzilla-registry", default-features = false, version = "0.3.0" } anyhow = "1.0.104" -bs58 = "0.5.1" -bincode = "1.3.3" -# Allocation-free base58 and integer text for the token dump rows. +# Allocation-free base58 and integer text for dump rows. five8 = "1.0.0" itoa = "1.0.18" -clap = { version = "4.6.6", features = ["derive", "env"] } +clap = { version = "4.6.6", default-features = false, features = ["std", "derive", "env", "help", "usage", "error-context"] } gxhash = "3.5.0" -libc = "0.2.189" memmap2 = "0.9.11" -rayon = "1.12.0" -reqwest = { version = "0.13.4", default-features = false, features = ["blocking", "rustls"] } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" -sha2 = "0.11.0" -solana-pubkey = "4.2.1" -solana-vote-interface = { version = "=6.0.3", features = ["serde"] } +sha2 = { version = "0.11.0", default-features = false } tracing = "0.1.44" tracing-subscriber = "0.3.23" +url = "2.5.8" wincode = { version = "=0.6.1", features = ["derive"] } -zstd = "0.14.0" +zstd = { version = "0.14.0", default-features = false } + +[target.'cfg(unix)'.dependencies] +libc = "0.2.189" [dev-dependencies] tempfile = "3.27.0" diff --git a/blockzilla/cli/README.md b/blockzilla/cli/README.md index 6db63c72..36b9c5cf 100644 --- a/blockzilla/cli/README.md +++ b/blockzilla/cli/README.md @@ -5,7 +5,7 @@ The core command tree contains: | Command | Purpose | | --- | --- | -| `stream` | Read an archive epoch as ordered JSON block summaries. | +| `stream` | Stream an archive epoch as ordered JSON block summaries or a throughput summary. | | `token-dump` | Export recorded token balances as JSON Lines. | | `wallet-dump` | Export transactions that one wallet signed. | | `program-dump` | Export recorded outer and inner calls of one program. | @@ -15,7 +15,9 @@ The core command tree contains: ```sh cargo run --locked -p blockzilla -- --help -blockzilla stream --epoch 900 --max-blocks 5 +blockzilla stream --epoch 200 --max-blocks 5 +blockzilla stream --epoch 200 --max-blocks 5 --no-cache +blockzilla stream --epoch 800 --output summary --plain blockzilla token-dump --epoch 200 --max-blocks 20 --mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v > usdc.jsonl blockzilla token-dump --archive-url https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004/epoch-1094 --epoch 1094 --mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v blockzilla wallet-dump --epoch 1094 --key WALLET @@ -23,11 +25,25 @@ blockzilla program-dump --epoch 1094 --key PROGRAM blockzilla inspect --epoch 900 ``` -`token-dump` takes `--epoch`, `--origin`, `--archive-url`, `--s3-region`, -`--cache-root`, `--archive-dir`, `--source-id`, `--read-concurrency`, -`--threads`, `--first-block`, `--max-blocks`, and `--mint`. With no -`--archive-url`, `--origin`, or `--archive-dir`, it reads the public Foundation -directory +`stream` writes ordered JSON Lines (`--output jsonl`, default) or verifies and +decodes blocks with a live progress display and throughput report +(`--output summary`). Over HTTPS, `--no-cache` (the default for +`--output summary`) streams directly from `archive-v2-blocks.zstd` through +ETag-pinned HTTP `206` ranges with zero local disk cache. Tune worker counts +and depth with `--threads` (1..=128), `--net-workers` (1..=512), +`--decode full|block`, `--segment-mb`, `--sub-batch-mb`, `--first-block`, +`--max-blocks`, and `--plain`. Private S3-compatible buckets work with +`--archive-url` and `--s3-region` on cached and `--no-cache` runs alike. + +`inspect` accepts archive location options only (`--epoch`, `--origin`, +`--archive-url`, `--archive-base`, `--s3-region`, `--cache-root`, +`--archive-dir`, and `--source-id`). + +`token-dump` takes `--epoch`, `--origin`, `--archive-url`, `--archive-base`, +`--s3-region`, `--cache-root`, `--archive-dir`, `--source-id`, +`--read-concurrency`, `--threads` (1..=128), `--net-workers` (1..=512), +`--first-block`, `--max-blocks`, and `--mint`. With no `--archive-url`, +`--origin`, or `--archive-dir`, it reads the public Foundation directory `https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004/epoch-`. It writes one JSON line per recorded token balance. Each line includes the transaction signature. The command stops when execution status or token data diff --git a/blockzilla/cli/src/archive_dump.rs b/blockzilla/cli/src/archive_dump.rs index 4d540c85..7c3f05af 100644 --- a/blockzilla/cli/src/archive_dump.rs +++ b/blockzilla/cli/src/archive_dump.rs @@ -192,10 +192,11 @@ pub fn execute(kind: Kind, args: Args) -> Result<()> { let key = args .key .map(|value| -> Result<[u8; 32]> { - bs58::decode(value) - .into_vec()? - .try_into() - .map_err(|_| anyhow::anyhow!("key must contain 32 bytes")) + let mut key = [0u8; 32]; + five8::decode_32(&value, &mut key).map_err(|error| { + anyhow::anyhow!("key must be a 32-byte base58 address: {error}") + })?; + Ok(key) }) .transpose()?; anyhow::ensure!(key.is_some(), "--key is required"); @@ -334,7 +335,11 @@ mod tests { let mut bytes = serde_json::to_vec(&json!({ "slot": slot, "tx_index": tx_index, "status": format!("{:?}", status), - "signature": signature.map(|v| bs58::encode(v).into_string()) + "signature": signature.map(|v| { + let mut out = [0u8; five8::BASE58_ENCODED_64_MAX_LEN]; + let len = five8::encode_64(v, &mut out) as usize; + String::from_utf8(out[..len].to_vec()).unwrap() + }) })) .unwrap(); bytes.push(b'\n'); diff --git a/blockzilla/cli/src/archive_v2.rs b/blockzilla/cli/src/archive_v2.rs index 2e468240..76e7d37e 100644 --- a/blockzilla/cli/src/archive_v2.rs +++ b/blockzilla/cli/src/archive_v2.rs @@ -43,7 +43,8 @@ use blockzilla_live_format::{ }; use blockzilla_primitives::{ - CompactPubkey, WincodeLeb128FramedReader, WincodeLeb128FramedWriter, wincode_leb128_config, + COMPUTE_BUDGET_PROGRAM_ID, CompactPubkey, SYSTEM_PROGRAM_ID, VOTE_PROGRAM_ID, + WincodeLeb128FramedReader, WincodeLeb128FramedWriter, wincode_leb128_config, }; use blockzilla_program_logs::{ @@ -60,17 +61,8 @@ use gxhash::{GxBuildHasher, HashMap as GxHashMap}; use memmap2::{Mmap, MmapOptions}; -use rayon::prelude::*; - use sha2::{Digest, Sha256}; -use solana_pubkey::Pubkey; - -use solana_vote_interface::{ - instruction::VoteInstruction, - state::{TowerSync as SolanaTowerSync, VoteStateUpdate as SolanaVoteStateUpdate}, -}; - #[cfg(unix)] use std::os::unix::fs::MetadataExt; @@ -82,12 +74,22 @@ use std::{ time::{Duration, Instant, SystemTime}, }; -use tracing::{info, warn}; - use wincode::{ReadResult, SchemaRead, config::Config, io::Reader, len::SeqLen}; use crate::{BUFFER_SIZE, ProgressTracker}; +macro_rules! info { + ($($arg:tt)*) => { + eprintln!("INFO {}", format_args!($($arg)*)); + }; +} + +macro_rules! warn { + ($($arg:tt)*) => { + eprintln!("WARN {}", format_args!($($arg)*)); + }; +} + pub(crate) mod direct_agave; pub(crate) mod execution_canary; @@ -894,12 +896,10 @@ fn build_live_no_registry_pubkey_registry( .then_with(|| left_key.cmp(right_key)) }); - const BUILTIN_PROGRAM_KEYS: &[Pubkey] = &[solana_pubkey::pubkey!( - "ComputeBudget111111111111111111111111111111" - )]; + const BUILTIN_PROGRAM_KEYS: &[[u8; 32]] = &[COMPUTE_BUDGET_PROGRAM_ID]; let missing_builtins = BUILTIN_PROGRAM_KEYS .iter() - .map(|key| key.to_bytes()) + .copied() .filter(|builtin| !items.iter().any(|(key, _)| key == builtin)) .collect::>(); let registry_len = missing_builtins.len() + items.len(); @@ -967,12 +967,10 @@ fn build_live_pubkey_registry_from_counts( .then_with(|| left_key.cmp(right_key)) }); - const BUILTIN_PROGRAM_KEYS: &[Pubkey] = &[solana_pubkey::pubkey!( - "ComputeBudget111111111111111111111111111111" - )]; + const BUILTIN_PROGRAM_KEYS: &[[u8; 32]] = &[COMPUTE_BUDGET_PROGRAM_ID]; let missing_builtins = BUILTIN_PROGRAM_KEYS .iter() - .map(|key| key.to_bytes()) + .copied() .filter(|builtin| !items.iter().any(|(key, _)| key == builtin)) .collect::>(); let registry_len = missing_builtins.len() + items.len(); @@ -1698,8 +1696,7 @@ impl PartialOrd for FrequencyRunHeapItem { } fn live_builtin_program_keys() -> &'static [[u8; 32]] { - const BUILTIN_PROGRAM_KEYS: [[u8; 32]; 1] = - [solana_pubkey::pubkey!("ComputeBudget111111111111111111111111111111").to_bytes()]; + const BUILTIN_PROGRAM_KEYS: [[u8; 32]; 1] = [COMPUTE_BUDGET_PROGRAM_ID]; &BUILTIN_PROGRAM_KEYS } @@ -3059,69 +3056,141 @@ fn parse_hot_vote_instruction_data( return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())); } - let instruction_result: std::result::Result = bincode::deserialize(data); - let instruction = match instruction_result { - Ok(instruction) => instruction, - Err(_) => { - match try_parse_historical_tower_sync_instruction_data( - data, - slot_to_block_id, - vote_hashes, - ) { - Ok(Some(parsed)) => return Ok(parsed), - Ok(None) | Err(_) => { - return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())); - } - } - } - }; + if let Ok(Some(parsed)) = + try_parse_compact_vote_instruction_data(data, slot_to_block_id, vote_hashes) + { + return Ok(parsed); + } + + match try_parse_historical_tower_sync_instruction_data(data, slot_to_block_id, vote_hashes) { + Ok(Some(parsed)) => Ok(parsed), + Ok(None) | Err(_) => Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())), + } +} + +struct CompactVoteStateUpdateWire { + root: Option, + lockout_offsets: Vec, + last_slot: Option, + hash: [u8; 32], + timestamp: Option, +} + +fn read_compact_vote_state_update( + cursor: &mut VoteInstructionCursor<'_>, +) -> Result { + let raw_root = cursor.read_u64_le()?; + let root = (raw_root != u64::MAX).then_some(raw_root); + let lockout_len = cursor.read_short_vec_len()?; + anyhow::ensure!( + lockout_len <= 31, + "vote lockout history length {lockout_len} exceeds MAX_LOCKOUT_HISTORY" + ); + let mut lockout_offsets = Vec::with_capacity(lockout_len); + let mut slot = root.unwrap_or_default(); + let mut last_slot = None; + for _ in 0..lockout_len { + let offset = cursor.read_var_u64()?; + let confirmation_count = cursor.read_u8()?; + slot = slot + .checked_add(offset) + .context("vote lockout slot overflow")?; + lockout_offsets.push(ArchiveV2VoteLockoutOffset { + offset, + confirmation_count, + }); + last_slot = Some(slot); + } + let hash = cursor.read_pubkey()?; + let timestamp = cursor.read_option_i64_le()?; + Ok(CompactVoteStateUpdateWire { + root, + lockout_offsets, + last_slot, + hash, + timestamp, + }) +} - let parsed = match instruction { - VoteInstruction::CompactUpdateVoteState(update) => { - let update = - match archive_vote_state_update_from_solana(&update, slot_to_block_id, vote_hashes) - { - Ok(update) => update, - Err(_) => return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())), - }; +fn compact_wire_vote_update( + wire: CompactVoteStateUpdateWire, + slot_to_block_id: &GxHashMap, + vote_hashes: &mut VoteHashRegistryBuilder, +) -> Result<(ArchiveV2VoteStateUpdate, Option)> { + let hash = vote_hashes.ref_bank_hash(wire.last_slot, wire.hash, slot_to_block_id)?; + Ok(( + ArchiveV2VoteStateUpdate { + root: wire.root, + lockout_offsets: wire.lockout_offsets, + hash, + timestamp: wire.timestamp, + }, + wire.last_slot, + )) +} + +fn try_parse_compact_vote_instruction_data( + data: &[u8], + slot_to_block_id: &GxHashMap, + vote_hashes: &mut VoteHashRegistryBuilder, +) -> Result> { + if data.len() < 4 { + return Ok(None); + } + let mut cursor = VoteInstructionCursor::new(data); + let variant = cursor.read_u32_le()?; + let parsed = match variant { + 12 => { + let wire = read_compact_vote_state_update(&mut cursor)?; + cursor.ensure_eof()?; + let (update, _) = compact_wire_vote_update(wire, slot_to_block_id, vote_hashes)?; ArchiveV2HotInstructionData::VoteCompactUpdateVoteState(update) } - VoteInstruction::CompactUpdateVoteStateSwitch(update, switch_proof_hash) => { - let update = - match archive_vote_state_update_from_solana(&update, slot_to_block_id, vote_hashes) - { - Ok(update) => update, - Err(_) => return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())), - }; - let switch_proof_hash = vote_hashes.ref_aux_hash(switch_proof_hash.to_bytes()); + 13 => { + let wire = read_compact_vote_state_update(&mut cursor)?; + let switch_proof_hash = cursor.read_pubkey()?; + cursor.ensure_eof()?; + let (update, _) = compact_wire_vote_update(wire, slot_to_block_id, vote_hashes)?; + let switch_proof_hash = vote_hashes.ref_aux_hash(switch_proof_hash); ArchiveV2HotInstructionData::VoteCompactUpdateVoteStateSwitch { update, switch_proof_hash, } } - VoteInstruction::TowerSync(tower) => { - let tower = match archive_tower_sync_from_solana(&tower, slot_to_block_id, vote_hashes) - { - Ok(tower) => tower, - Err(_) => return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())), - }; - ArchiveV2HotInstructionData::VoteTowerSync(tower) + 14 => { + let wire = read_compact_vote_state_update(&mut cursor)?; + let block_id = cursor.read_pubkey()?; + cursor.ensure_eof()?; + let (update, last_slot) = + compact_wire_vote_update(wire, slot_to_block_id, vote_hashes)?; + let block_id_hash = + vote_hashes.ref_block_id_hash(last_slot, block_id, slot_to_block_id)?; + ArchiveV2HotInstructionData::VoteTowerSync(ArchiveV2VoteTowerSync { + update, + block_id_hash, + }) } - VoteInstruction::TowerSyncSwitch(tower, switch_proof_hash) => { - let tower = match archive_tower_sync_from_solana(&tower, slot_to_block_id, vote_hashes) - { - Ok(tower) => tower, - Err(_) => return Ok(ArchiveV2HotInstructionData::UnknownVote(data.to_vec())), - }; - let switch_proof_hash = vote_hashes.ref_aux_hash(switch_proof_hash.to_bytes()); + 15 => { + let wire = read_compact_vote_state_update(&mut cursor)?; + let block_id = cursor.read_pubkey()?; + let switch_proof_hash = cursor.read_pubkey()?; + cursor.ensure_eof()?; + let (update, last_slot) = + compact_wire_vote_update(wire, slot_to_block_id, vote_hashes)?; + let block_id_hash = + vote_hashes.ref_block_id_hash(last_slot, block_id, slot_to_block_id)?; + let switch_proof_hash = vote_hashes.ref_aux_hash(switch_proof_hash); ArchiveV2HotInstructionData::VoteTowerSyncSwitch { - tower, + tower: ArchiveV2VoteTowerSync { + update, + block_id_hash, + }, switch_proof_hash, } } - _ => ArchiveV2HotInstructionData::Raw(data.to_vec()), + _ => return Ok(None), }; - Ok(parsed) + Ok(Some(parsed)) } fn try_parse_historical_tower_sync_instruction_data( @@ -3456,55 +3525,6 @@ fn try_parse_hot_system_instruction_data_inner( Ok(Some(parsed)) } -fn archive_tower_sync_from_solana( - tower: &SolanaTowerSync, - slot_to_block_id: &GxHashMap, - vote_hashes: &mut VoteHashRegistryBuilder, -) -> Result { - let (update, last_slot) = archive_vote_state_update_from_parts( - tower.root, - tower.lockouts.iter().map(|lockout| { - Ok(( - lockout.slot(), - u8::try_from(lockout.confirmation_count()) - .context("vote confirmation count exceeds u8::MAX")?, - )) - }), - tower.hash.to_bytes(), - tower.timestamp, - slot_to_block_id, - vote_hashes, - )?; - let block_id_hash = - vote_hashes.ref_block_id_hash(last_slot, tower.block_id.to_bytes(), slot_to_block_id)?; - Ok(ArchiveV2VoteTowerSync { - update, - block_id_hash, - }) -} - -fn archive_vote_state_update_from_solana( - update: &SolanaVoteStateUpdate, - slot_to_block_id: &GxHashMap, - vote_hashes: &mut VoteHashRegistryBuilder, -) -> Result { - Ok(archive_vote_state_update_from_parts( - update.root, - update.lockouts.iter().map(|lockout| { - Ok(( - lockout.slot(), - u8::try_from(lockout.confirmation_count()) - .context("vote confirmation count exceeds u8::MAX")?, - )) - }), - update.hash.to_bytes(), - update.timestamp, - slot_to_block_id, - vote_hashes, - )? - .0) -} - fn archive_vote_state_update_from_parts( root: Option, lockouts: I, @@ -3571,6 +3591,46 @@ impl<'a> VoteInstructionCursor<'a> { Ok(()) } + fn read_u8(&mut self) -> Result { + Ok(self.read_array::<1>()?[0]) + } + + fn read_short_vec_len(&mut self) -> Result { + let mut len = 0usize; + for i in 0..3 { + let byte = self.read_u8()?; + if i == 2 && byte > 0x03 { + anyhow::bail!("short_vec length overflows u16"); + } + if i > 0 && byte == 0 { + anyhow::bail!("non-canonical short_vec encoding"); + } + len |= usize::from(byte & 0x7f) << (7 * i); + if byte & 0x80 == 0 { + return Ok(len); + } + } + anyhow::bail!("short_vec length exceeds 3 bytes") + } + + fn read_var_u64(&mut self) -> Result { + let mut value = 0u64; + for i in 0..10 { + let byte = self.read_u8()?; + if i == 9 && byte > 1 { + anyhow::bail!("varint overflows u64"); + } + if i > 0 && byte == 0 { + anyhow::bail!("non-canonical varint encoding"); + } + value |= u64::from(byte & 0x7f) << (7 * i); + if byte & 0x80 == 0 { + return Ok(value); + } + } + anyhow::bail!("varint exceeds 10 bytes") + } + fn read_u32_le(&mut self) -> Result { let bytes = self.read_array::<4>()?; Ok(u32::from_le_bytes(bytes)) @@ -4521,15 +4581,15 @@ fn trim_hot_reusable_vec(buf: &mut Vec) { } fn vote_program_id_bytes() -> [u8; 32] { - solana_pubkey::pubkey!("Vote111111111111111111111111111111111111111").to_bytes() + VOTE_PROGRAM_ID } fn compute_budget_program_id_bytes() -> [u8; 32] { - solana_pubkey::pubkey!("ComputeBudget111111111111111111111111111111").to_bytes() + COMPUTE_BUDGET_PROGRAM_ID } fn system_program_id_bytes() -> [u8; 32] { - solana_pubkey::pubkey!("11111111111111111111111111111111").to_bytes() + SYSTEM_PROGRAM_ID } const LIVE_PUBKEY_RUN_READER_BUFFER_SIZE: usize = 64 << 10; @@ -4559,3 +4619,156 @@ pub(crate) fn load_blockhash_registry_plain(path: &Path) -> Result } Ok(hashes) } + +#[cfg(test)] +mod vote_parser_tests { + use super::*; + use blockzilla_compact_v2_reader::signed_message::{ + InstructionDataEncoding, reconstruct_instruction_data_candidates, + }; + + fn round_trip_compact(expected: ArchiveV2HotInstructionData) { + let candidates = reconstruct_instruction_data_candidates(&expected, None).unwrap(); + let bytes = candidates[0].bytes.as_ref(); + let slot_to_block_id = GxHashMap::with_hasher(GxBuildHasher::default()); + let mut vote_hashes = VoteHashRegistryBuilder::default(); + let parsed = + parse_hot_vote_instruction_data(bytes, &slot_to_block_id, &mut vote_hashes).unwrap(); + assert_eq!( + wincode::serialize(&parsed).unwrap(), + wincode::serialize(&expected).unwrap() + ); + } + + #[test] + fn parses_all_four_compact_vote_variants_matching_reconstructor() { + let update_with_root = ArchiveV2VoteStateUpdate { + root: Some(1_000), + lockout_offsets: vec![ + ArchiveV2VoteLockoutOffset { + offset: 1, + confirmation_count: 3, + }, + ArchiveV2VoteLockoutOffset { + offset: 300, + confirmation_count: 2, + }, + ArchiveV2VoteLockoutOffset { + offset: 100_000, + confirmation_count: 1, + }, + ], + hash: ArchiveV2VoteHashRef::Raw([0x11; 32]), + timestamp: Some(1_700_000_000), + }; + let update_no_root = ArchiveV2VoteStateUpdate { + root: None, + lockout_offsets: vec![ArchiveV2VoteLockoutOffset { + offset: 42, + confirmation_count: 1, + }], + hash: ArchiveV2VoteHashRef::Raw([0x22; 32]), + timestamp: None, + }; + round_trip_compact(ArchiveV2HotInstructionData::VoteCompactUpdateVoteState( + update_with_root.clone(), + )); + round_trip_compact(ArchiveV2HotInstructionData::VoteCompactUpdateVoteState( + update_no_root.clone(), + )); + round_trip_compact( + ArchiveV2HotInstructionData::VoteCompactUpdateVoteStateSwitch { + update: update_with_root.clone(), + switch_proof_hash: ArchiveV2VoteHashRef::Raw([0x33; 32]), + }, + ); + round_trip_compact(ArchiveV2HotInstructionData::VoteTowerSync( + ArchiveV2VoteTowerSync { + update: update_with_root.clone(), + block_id_hash: ArchiveV2VoteHashRef::Raw([0x44; 32]), + }, + )); + round_trip_compact(ArchiveV2HotInstructionData::VoteTowerSyncSwitch { + tower: ArchiveV2VoteTowerSync { + update: update_no_root, + block_id_hash: ArchiveV2VoteHashRef::Raw([0x55; 32]), + }, + switch_proof_hash: ArchiveV2VoteHashRef::Raw([0x66; 32]), + }); + } + + #[test] + fn parses_historical_tower_sync_and_rejects_trailing_or_noncanonical_bytes() { + let expected = ArchiveV2HotInstructionData::VoteTowerSyncSwitch { + tower: ArchiveV2VoteTowerSync { + update: ArchiveV2VoteStateUpdate { + root: Some(500), + lockout_offsets: vec![ArchiveV2VoteLockoutOffset { + offset: 7, + confirmation_count: 2, + }], + hash: ArchiveV2VoteHashRef::Raw([0x77; 32]), + timestamp: Some(12345), + }, + block_id_hash: ArchiveV2VoteHashRef::Raw([0x88; 32]), + }, + switch_proof_hash: ArchiveV2VoteHashRef::Raw([0x99; 32]), + }; + let candidates = reconstruct_instruction_data_candidates(&expected, None).unwrap(); + let historical = candidates + .iter() + .find(|c| c.encoding == InstructionDataEncoding::VoteTowerHistorical) + .expect("historical TowerSync candidate"); + let slot_to_block_id = GxHashMap::with_hasher(GxBuildHasher::default()); + let mut vote_hashes = VoteHashRegistryBuilder::default(); + let parsed = parse_hot_vote_instruction_data( + historical.bytes.as_ref(), + &slot_to_block_id, + &mut vote_hashes, + ) + .unwrap(); + assert_eq!( + wincode::serialize(&parsed).unwrap(), + wincode::serialize(&expected).unwrap() + ); + + // Trailing byte must preserve raw bytes as UnknownVote without mutating vote_hashes. + let mut with_trailing = candidates[0].bytes.to_vec(); + with_trailing.push(0x00); + let mut untouched_hashes = VoteHashRegistryBuilder::default(); + let parsed = parse_hot_vote_instruction_data( + &with_trailing, + &slot_to_block_id, + &mut untouched_hashes, + ) + .unwrap(); + assert!(matches!( + parsed, + ArchiveV2HotInstructionData::UnknownVote(ref raw) if raw == &with_trailing + )); + assert_eq!(untouched_hashes.bank_hash_raw, 0); + assert_eq!(untouched_hashes.block_id_raw, 0); + assert!(untouched_hashes.rows.is_empty()); + + // Non-canonical varint (trailing 0x00 continuation byte) must fall back to UnknownVote. + let mut non_canonical = Vec::new(); + non_canonical.extend_from_slice(&12u32.to_le_bytes()); + non_canonical.extend_from_slice(&u64::MAX.to_le_bytes()); + non_canonical.push(1); // 1 lockout + non_canonical.extend_from_slice(&[0x80, 0x00]); // non-canonical varint 0 + non_canonical.push(1); // confirmation_count + non_canonical.extend_from_slice(&[0xaa; 32]); + non_canonical.push(0); // timestamp = None + let parsed = parse_hot_vote_instruction_data( + &non_canonical, + &slot_to_block_id, + &mut untouched_hashes, + ) + .unwrap(); + assert!(matches!( + parsed, + ArchiveV2HotInstructionData::UnknownVote(ref raw) if raw == &non_canonical + )); + assert_eq!(untouched_hashes.bank_hash_raw, 0); + } +} diff --git a/blockzilla/cli/src/archive_v2/execution_canary.rs b/blockzilla/cli/src/archive_v2/execution_canary.rs index b10c7521..c6906ac9 100644 --- a/blockzilla/cli/src/archive_v2/execution_canary.rs +++ b/blockzilla/cli/src/archive_v2/execution_canary.rs @@ -695,8 +695,8 @@ pub(super) mod tests { epoch: 0, start_slot: 41, end_slot_exclusive: 43, - genesis_hash: bs58::encode([1; 32]).into_string(), - node_identity: bs58::encode([2; 32]).into_string(), + genesis_hash: blockzilla_primitives::encode_pubkey_base58(&[1; 32]), + node_identity: blockzilla_primitives::encode_pubkey_base58(&[2; 32]), source_receipt_sha256: "a".repeat(64), coverage_receipt_sha256: "b".repeat(64), rpc_response_sha256: "c".repeat(64), @@ -944,7 +944,7 @@ pub(super) mod tests { wrong.source_receipt_sha256 = "f".repeat(64); assert!(validate_provenance(&root, &wrong).is_err()); let mut wrong = r.clone(); - wrong.node_identity = bs58::encode([9; 32]).into_string(); + wrong.node_identity = blockzilla_primitives::encode_pubkey_base58(&[9; 32]); assert!(validate_provenance(&root, &wrong).is_err()); let mut wrong = r; wrong.blocks[0].slot = 41; diff --git a/blockzilla/cli/src/compare_sdk_rpc.rs b/blockzilla/cli/src/compare_sdk_rpc.rs index b4ee05d2..e6ace98a 100644 --- a/blockzilla/cli/src/compare_sdk_rpc.rs +++ b/blockzilla/cli/src/compare_sdk_rpc.rs @@ -3,10 +3,12 @@ use std::{collections::BTreeMap, fs::File, io::Read, path::PathBuf, time::Duration}; use anyhow::{Context, Result, bail, ensure}; +use blockzilla_compact_v2_reader::HttpJsonClient; use clap::Args; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; use sha2::{Digest, Sha256}; +use url::Url; const MAX_JSON_BYTES: u64 = 64 * 1024 * 1024; const MAX_BLOCKS: usize = 1000; @@ -17,7 +19,7 @@ pub(crate) struct CompareSdkRpcArgs { pub input: PathBuf, /// JSON-RPC endpoint used for finalized getBlock reads. #[arg(long, default_value = "http://127.0.0.1:8899")] - pub rpc_url: reqwest::Url, + pub rpc_url: Url, /// Save the successful comparison report to a new file. #[arg(long)] pub report: Option, @@ -343,26 +345,16 @@ fn compare( Ok(report) } -fn fetch_rpc( - client: &reqwest::blocking::Client, - url: &reqwest::Url, - slot: u64, -) -> Result { +fn fetch_rpc(client: &HttpJsonClient, slot: u64) -> Result { let body = json!({"jsonrpc":"2.0","id":1,"method":"getBlock","params":[slot,{ "commitment":"finalized","encoding":"json","transactionDetails":"full","rewards":false,"maxSupportedTransactionVersion":1 }]}); - let response = client - .post(url.clone()) - .header("Content-Type", "application/json") - .body(serde_json::to_vec(&body)?) - .send() - .map_err(|e| anyhow::anyhow!(e.without_url()))?; - ensure!( - response.status().is_success(), - "RPC HTTP status {}", - response.status() - ); - let envelope: Value = serde_json::from_slice(&bounded_json(response)?)?; + let payload = serde_json::to_vec(&body)?; + let (status, response_bytes) = client + .post_json_bounded(&payload, MAX_JSON_BYTES as usize) + .map_err(|e| anyhow::anyhow!("{e}"))?; + ensure!((200..300).contains(&status), "RPC HTTP status {status}"); + let envelope: Value = serde_json::from_slice(&response_bytes)?; ensure!( envelope["jsonrpc"] == "2.0" && envelope["id"] == 1, "Invalid RPC response envelope" @@ -405,13 +397,10 @@ fn run_with_output(args: CompareSdkRpcArgs, output: &mut impl std::io::Write) -> .iter() .map(|byte| format!("{byte:02x}")) .collect(); - let client = reqwest::blocking::Client::builder() - .timeout(Duration::from_secs(args.timeout_seconds)) - .redirect(reqwest::redirect::Policy::none()) - .build()?; - let report = compare(capture, digest, |slot| { - fetch_rpc(&client, &args.rpc_url, slot) - })?; + let timeout = Duration::from_secs(args.timeout_seconds); + let client = HttpJsonClient::new(&args.rpc_url, timeout.min(Duration::from_secs(10)), timeout) + .map_err(|e| anyhow::anyhow!("{e}"))?; + let report = compare(capture, digest, |slot| fetch_rpc(&client, slot))?; let mut bytes = serde_json::to_vec_pretty(&report)?; bytes.push(b'\n'); if let Some(path) = args.report { @@ -575,7 +564,7 @@ mod tests { } } - fn server(body: Value, status: &str) -> (reqwest::Url, std::thread::JoinHandle<()>) { + fn server(body: Value, status: &str) -> (Url, std::thread::JoinHandle<()>) { use std::{ io::{BufRead, BufReader, Write}, net::TcpListener, @@ -655,11 +644,9 @@ mod tests { ), ] { let (url, server) = server(body, status); - let client = reqwest::blocking::Client::builder() - .no_proxy() - .build() - .unwrap(); - let result = fetch_rpc(&client, &url, 42); + let client = + HttpJsonClient::new(&url, Duration::from_secs(5), Duration::from_secs(5)).unwrap(); + let result = fetch_rpc(&client, 42); assert_eq!(result.is_ok(), ok); if let Err(error) = result { assert!(!format!("{error:#}").contains("not-logged")); diff --git a/blockzilla/cli/src/main.rs b/blockzilla/cli/src/main.rs index 2ae0d1bf..992d7096 100644 --- a/blockzilla/cli/src/main.rs +++ b/blockzilla/cli/src/main.rs @@ -34,7 +34,7 @@ struct Cli { #[derive(Subcommand)] enum Commands { - /// Stream an archive epoch as ordered JSON block summaries. + /// Stream an archive epoch as ordered JSON block summaries or throughput summary. Stream(stream::StreamArgs), /// Export recorded token balances from an archive epoch. TokenDump(token_dump::TokenDumpArgs), @@ -45,7 +45,7 @@ enum Commands { /// Show the admitted identity and range of an archive epoch. Inspect { #[command(flatten)] - source: stream::EpochSourceArgs, + source: stream::ArchiveSourceArgs, }, /// Compare an SDK capture with finalized JSON-RPC blocks. CompareSdkRpc(compare_sdk_rpc::CompareSdkRpcArgs), @@ -176,6 +176,79 @@ mod cli_tests { assert!(matches!(cli.command, Commands::TokenDump(_))); } + #[test] + fn unified_stream_and_inspect_commands_validate_flags() { + let cli = Cli::try_parse_from([ + "blockzilla", + "stream", + "--epoch", + "800", + "--output", + "summary", + "--decode", + "full", + "--threads", + "128", + "--net-workers", + "320", + "--first-block", + "10", + "--max-blocks", + "25", + "--plain", + ]) + .unwrap(); + let Commands::Stream(args) = cli.command else { + panic!("wrong command"); + }; + assert_eq!(args.source.epoch, 800); + assert_eq!(args.output, stream::StreamOutput::Summary); + assert_eq!(args.decode, Some(stream::StreamDecodeLevel::Full)); + assert_eq!(args.scan.threads, Some(128)); + assert_eq!(args.scan.net_workers, Some(320)); + assert_eq!(args.scan.first_block, 10); + assert_eq!(args.scan.max_blocks.map(|n| n.get()), Some(25)); + assert!(args.plain); + + // Private S3-compatible bucket signing works with direct HTTPS streaming too. + let cli = Cli::try_parse_from([ + "blockzilla", + "stream", + "--epoch", + "800", + "--archive-url", + "https://example.r2.cloudflarestorage.com/bucket/epoch-800", + "--s3-region", + "auto", + "--no-cache", + ]) + .unwrap(); + let Commands::Stream(args) = cli.command else { + panic!("wrong command"); + }; + assert_eq!(args.source.s3_region.as_deref(), Some("auto")); + assert!(args.no_cache); + + // `inspect` accepts archive location flags and rejects unused scan flags. + assert!(Cli::try_parse_from(["blockzilla", "inspect", "--epoch", "800"]).is_ok()); + for flag in [ + "--threads", + "--net-workers", + "--max-blocks", + "--first-block", + "--read-concurrency", + ] { + assert!( + Cli::try_parse_from(["blockzilla", "inspect", "--epoch", "800", flag, "4"]) + .is_err(), + "inspect should reject {flag}" + ); + } + + // `firehose` was merged into `blockzilla stream`. + assert!(Cli::try_parse_from(["blockzilla", "firehose", "--epoch", "800"]).is_err()); + } + #[test] fn removed_application_and_source_commands_are_not_core_commands() { for command in [ diff --git a/blockzilla/cli/src/progress.rs b/blockzilla/cli/src/progress.rs index ba921dbe..eb2a56c8 100644 --- a/blockzilla/cli/src/progress.rs +++ b/blockzilla/cli/src/progress.rs @@ -8,7 +8,12 @@ use std::{ path::{Path, PathBuf}, time::{Duration, Instant, SystemTime, UNIX_EPOCH}, }; -use tracing::info; + +macro_rules! info { + ($($arg:tt)*) => { + eprintln!("INFO {}", format_args!($($arg)*)); + }; +} pub(crate) fn file_nonempty(path: &Path) -> bool { std::fs::metadata(path) diff --git a/blockzilla/cli/src/stream.rs b/blockzilla/cli/src/stream.rs index 627e3ede..cd18f0d1 100644 --- a/blockzilla/cli/src/stream.rs +++ b/blockzilla/cli/src/stream.rs @@ -1,41 +1,86 @@ -//! User-facing epoch scan. Archive discovery, cache binding, and ordered -//! decoding stay in the dedicated Compact V2 reader. +//! User-facing epoch streaming and shared archive source arguments. +//! +//! Supports both cached `CompactV2Archive` scans (local or remote) and direct +//! zero-disk-cache ordered HTTPS streaming via [`run_epoch_firehose`]. -use std::{io::Write, num::NonZeroU32, path::PathBuf, time::Instant}; +use std::{ + io::{self, BufWriter, IsTerminal, Write}, + num::NonZeroU32, + path::PathBuf, + sync::{ + Arc, + atomic::{AtomicUsize, Ordering}, + }, + thread, + time::{Duration, Instant}, +}; use anyhow::{Context, Result}; -use blockzilla_compact_v2_reader::archive::{ - ArchiveInstructionSource, BlockSink, BlockView, CompactV2Archive, CompactV2LocalDescriptor, - CompactV2ParallelScanConfig, QueryError, QueryResult, ScanRequest, +use blockzilla_compact_v2_reader::{ + HttpObjectPathLayout, NetworkInputConfig, S3Credentials, S3SigV4Signer, SourceError, + archive::{ + ArchiveInstructionSource, BlockSink, BlockView, CompactV2Archive, CompactV2LocalDescriptor, + CompactV2ParallelScanConfig, QueryError, QueryResult, ScanRequest, + }, + firehose::{ + DEFAULT_FOUNDATION_ARCHIVE_BASE, FirehoseConfig, FirehoseDecodeLevel, run_epoch_firehose, + }, }; -use clap::Args; -use serde::Serialize; +use clap::{Args, ValueEnum}; -#[derive(Args, Debug)] -pub(crate) struct StreamArgs { - #[command(flatten)] - pub source: EpochSourceArgs, +const STDOUT_BUFFER_BYTES: usize = 256 * 1024; +const SMALL_STREAM_FLUSH_LIMIT: u64 = 64; + +/// Output mode for `blockzilla stream`. +#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] +pub(crate) enum StreamOutput { + /// Emit one ordered JSON block summary per line on stdout. + Jsonl, + /// Verify and decode blocks with live progress bars and print a throughput summary box. + Summary, } +/// Per-block decode depth when streaming directly over HTTPS (`--no-cache` or `--output summary`). +#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] +pub(crate) enum StreamDecodeLevel { + /// Decompress zstd, parse wincode, and decode every transaction message, + /// typed metadata, top-level instruction, and inner CPI instruction. + Full, + /// Decompress zstd, parse wincode, and iterate every transaction row. + Block, +} + +/// Shared archive location options used by `stream`, `token-dump`, and `inspect`. #[derive(Args, Debug)] -pub(crate) struct EpochSourceArgs { - /// Epoch to read from the public Foundation archive. +pub(crate) struct ArchiveSourceArgs { + /// Epoch to read. Defaults to the public Foundation Compact V2 archive. #[arg(long)] pub epoch: u64, - /// Compatible HTTPS archive origin. Omit it to read the public Foundation bucket. + /// Compatible HTTPS archive origin (`/compact-v2//`). #[arg(long, env = "BLOCKZILLA_ORIGIN", conflicts_with = "archive_dir")] pub origin: Option, - /// Public HTTPS epoch directory. Omit `--archive-url` and `--origin` to read - /// `https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004/epoch-`. - #[arg(long, env = "BLOCKZILLA_ARCHIVE_URL", conflicts_with_all = ["origin", "archive_dir"])] + /// Full HTTPS epoch directory URL, such as `https://archive.example.com/epoch-800`. + #[arg( + long, + env = "BLOCKZILLA_ARCHIVE_URL", + conflicts_with_all = ["origin", "archive_dir"] + )] pub archive_url: Option, + /// Base URL holding `epoch-` directories. Defaults to the public Foundation R2 archive. + #[arg( + long, + env = "BLOCKZILLA_ARCHIVE_BASE", + default_value = DEFAULT_FOUNDATION_ARCHIVE_BASE, + conflicts_with_all = ["origin", "archive_url", "archive_dir"] + )] + pub archive_base: String, /// Sign requests to --archive-url for a private S3-compatible bucket in this /// region (`auto` for Cloudflare R2). Credentials come from /// AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and the optional /// AWS_SESSION_TOKEN. #[arg(long, requires = "archive_url")] pub s3_region: Option, - /// Cache directory. Relative paths are resolved from the current directory. + /// Cache directory for cached reads. Relative paths are resolved from the current directory. #[arg(long, default_value = ".blockzilla-cache")] pub cache_root: PathBuf, /// Read this local epoch directory instead of the HTTPS source. @@ -44,13 +89,21 @@ pub(crate) struct EpochSourceArgs { /// Stable ID for a local archive build. Change it when you replace that build. #[arg(long, requires = "archive_dir")] pub source_id: Option, +} + +/// Shared scan concurrency and range options used by `stream` and `token-dump`. +#[derive(Args, Debug)] +pub(crate) struct ScanArgs { /// Concurrent block reads for --archive-dir. Use several on a NAS or disk /// array; 1 reads one range at a time. #[arg(long, default_value_t = 1, requires = "archive_dir", value_parser = clap::value_parser!(u16).range(1..=64))] pub read_concurrency: u16, - /// Decode workers (1 through 64). - #[arg(long, default_value_t = 4, value_parser = clap::value_parser!(u16).range(1..=64))] - pub threads: u16, + /// Decode worker threads (1 through 128). Defaults from host CPUs. + #[arg(long, value_parser = clap::value_parser!(u16).range(1..=128))] + pub threads: Option, + /// Concurrent HTTP stream/prefetch workers (1 through 512). Defaults from host CPUs. + #[arg(long, value_parser = clap::value_parser!(u16).range(1..=512))] + pub net_workers: Option, /// First block row to read. Use the next row after a saved checkpoint to /// resume a stream. #[arg(long, default_value_t = 0)] @@ -60,12 +113,135 @@ pub(crate) struct EpochSourceArgs { pub max_blocks: Option, } -#[derive(Serialize)] -struct BlockSummary { +#[derive(Args, Debug)] +pub(crate) struct StreamArgs { + #[command(flatten)] + pub source: ArchiveSourceArgs, + #[command(flatten)] + pub scan: ScanArgs, + /// Output format: `jsonl` block lines on stdout, or `summary` throughput & verification report. + #[arg(long, value_enum, default_value_t = StreamOutput::Jsonl)] + pub output: StreamOutput, + /// Decode depth for direct HTTPS streaming (defaults to `full` for `summary`, `block` for `jsonl`). + #[arg(long, value_enum)] + pub decode: Option, + /// Stream directly from HTTPS without writing a local disk cache (default for `--output summary` over HTTPS). + #[arg(long, conflicts_with = "archive_dir")] + pub no_cache: bool, + /// Target compressed HTTP range segment size in MiB (direct HTTPS streaming). + #[arg(long, default_value_t = 280, value_parser = clap::value_parser!(u16).range(32..=1024))] + pub segment_mb: u16, + /// Incremental frame-aligned sub-batch size in MiB (direct HTTPS streaming). + #[arg(long, default_value_t = 8, value_parser = clap::value_parser!(u16).range(1..=64))] + pub sub_batch_mb: u16, + /// Disable ANSI live progress bars and print periodic plain log lines. + #[arg(long)] + pub plain: bool, +} + +impl ArchiveSourceArgs { + pub(crate) fn resolved_epoch_url(&self) -> String { + if let Some(url) = &self.archive_url { + url.clone() + } else { + format!( + "{}/epoch-{}", + self.archive_base.trim_end_matches('/'), + self.epoch + ) + } + } +} + +impl ScanArgs { + pub(crate) fn resolved_threads(&self) -> usize { + self.threads.map(usize::from).unwrap_or_else(|| { + thread::available_parallelism() + .map(usize::from) + .unwrap_or(4) + .clamp(4, 96) + }) + } + + pub(crate) fn resolved_cached_net_workers(&self) -> usize { + self.net_workers + .map(|w| usize::from(w).min(256)) + .unwrap_or_else(|| (self.resolved_threads() * 2).clamp(16, 128)) + } +} + +/// Parallel scan settings for the selected source. With `--read-concurrency` +/// above 1, a local archive keeps that many block reads in flight. +pub(crate) fn parallel_scan_config( + source: &ArchiveSourceArgs, + scan: &ScanArgs, +) -> CompactV2ParallelScanConfig { + let decode_workers = scan.resolved_threads(); + if source.archive_dir.is_some() { + let mut config = CompactV2ParallelScanConfig::new(decode_workers); + if scan.read_concurrency > 1 + && let Some(input) = config.network_input.as_mut() + { + input.workers = usize::from(scan.read_concurrency); + } + return config; + } + let net_workers = scan.resolved_cached_net_workers(); + let max_buffer_bytes = + (net_workers * 32 * 1024 * 1024).clamp(256 * 1024 * 1024, 4 * 1024 * 1024 * 1024); + CompactV2ParallelScanConfig::new(decode_workers).with_network_input(Some(NetworkInputConfig { + workers: net_workers, + range_bytes: 16 * 1024 * 1024, + max_buffer_bytes, + })) +} + +fn write_block_summary_line( + output: &mut W, epoch: u64, block_ordinal: u32, slot: u64, transactions: u64, +) -> std::io::Result<()> { + writeln!( + output, + "{{\"epoch\":{epoch},\"block_ordinal\":{block_ordinal},\"slot\":{slot},\"transactions\":{transactions}}}" + ) +} + +fn fmt_u64(n: u64) -> String { + let s = n.to_string(); + let bytes = s.as_bytes(); + let mut out = String::with_capacity(s.len() + s.len() / 3); + for (i, &b) in bytes.iter().enumerate() { + if i > 0 && (bytes.len() - i).is_multiple_of(3) { + out.push(','); + } + out.push(b as char); + } + out +} + +fn fmt_tps(tps: f64) -> String { + if tps >= 1_000_000.0 { + format!("{:.2}M tx/s", tps / 1_000_000.0) + } else if tps >= 1_000.0 { + format!("{:.1}K tx/s", tps / 1_000.0) + } else { + format!("{:.0} tx/s", tps) + } +} + +fn progress_bar(frac: f64, width: usize) -> String { + let filled = ((frac.clamp(0.0, 1.0) * width as f64).round() as usize).min(width); + let mut bar = String::with_capacity(width * 3); + for _ in 0..filled { + bar.push('█'); + } + for _ in filled..width { + bar.push('░'); + } + bar } struct JsonSink { @@ -73,6 +249,8 @@ struct JsonSink { started: Instant, last_report: Instant, expected_blocks: u64, + flush_every_block: bool, + emit_jsonl: bool, blocks: u64, transactions: u64, } @@ -84,19 +262,25 @@ impl BlockSink for JsonSink { .map_or(block.transactions.len() as u64, |counts| { counts.transactions }); - let row = BlockSummary { - epoch: block.header.epoch, - block_ordinal: block.header.block_ordinal, - slot: block.header.slot, - transactions, - }; - serde_json::to_writer(&mut self.output, &row).map_err(QueryError::sink)?; - self.output.write_all(b"\n").map_err(QueryError::sink)?; - // Make the completed block visible immediately to a downstream pipe. - self.output.flush().map_err(QueryError::sink)?; + if self.emit_jsonl { + write_block_summary_line( + &mut self.output, + block.header.epoch, + block.header.block_ordinal, + block.header.slot, + transactions, + ) + .map_err(QueryError::sink)?; + if self.flush_every_block { + self.output.flush().map_err(QueryError::sink)?; + } + } self.blocks += 1; self.transactions += transactions; if self.last_report.elapsed().as_secs() >= 3 { + if self.emit_jsonl { + self.output.flush().map_err(QueryError::sink)?; + } eprintln!( "Read {}/{} blocks, {} transactions in {:.1}s", self.blocks, @@ -110,74 +294,57 @@ impl BlockSink for JsonSink { } } -pub(crate) fn open(args: &EpochSourceArgs) -> Result { +pub(crate) fn open(args: &ArchiveSourceArgs) -> Result { + open_with_read_concurrency(args, 1) +} + +pub(crate) fn open_with_read_concurrency( + args: &ArchiveSourceArgs, + read_concurrency: usize, +) -> Result { eprintln!("Opening epoch {}...", args.epoch); let archive = if let Some(root) = &args.archive_dir { - let root = std::fs::canonicalize(&root) + let root = std::fs::canonicalize(root) .with_context(|| format!("Cannot open archive directory {}", root.display()))?; let source_id = args .source_id .as_deref() .context("Local reads require --source-id")?; let descriptor = CompactV2LocalDescriptor::mainnet(args.epoch, source_id)?; - CompactV2Archive::open_local_with_read_concurrency( - root, - descriptor, - usize::from(args.read_concurrency), - )? + CompactV2Archive::open_local_with_read_concurrency(root, descriptor, read_concurrency)? } else { let cache_root = if args.cache_root.is_absolute() { args.cache_root.clone() } else { std::env::current_dir()?.join(&args.cache_root) }; - if let Some(epoch_url) = &args.archive_url { + if let Some(origin) = &args.origin { + eprintln!("Source: {origin}\nPreparing archive index and key registry..."); + CompactV2Archive::open(origin, args.epoch, cache_root) + .with_context(|| format!("Cannot open epoch {} at {origin}", args.epoch))? + } else { + let epoch_url = args.resolved_epoch_url(); eprintln!("Source: {epoch_url}\nPreparing archive index and key registry..."); match &args.s3_region { Some(region) => { - let signer = blockzilla_compact_v2_reader::S3SigV4Signer::new( - blockzilla_compact_v2_reader::S3Credentials::from_env()?, - region.as_str(), - )?; + let signer = S3SigV4Signer::new(S3Credentials::from_env()?, region.as_str())?; CompactV2Archive::open_signed_epoch_url( - epoch_url, + &epoch_url, args.epoch, cache_root, - std::sync::Arc::new(signer), + Arc::new(signer), ) } - None => CompactV2Archive::open_epoch_url(epoch_url, args.epoch, cache_root), + None => CompactV2Archive::open_epoch_url(&epoch_url, args.epoch, cache_root), } .with_context(|| format!("Cannot open epoch {} at {epoch_url}", args.epoch))? - } else if let Some(origin) = args.origin.as_deref() { - eprintln!("Source: {origin}\nPreparing archive index and key registry..."); - CompactV2Archive::open(origin, args.epoch, cache_root) - .with_context(|| format!("Cannot open epoch {} at {origin}", args.epoch))? - } else { - let epoch_url = blockzilla::public_epoch_url(args.epoch); - eprintln!("Source: {epoch_url}\nPreparing archive index and key registry..."); - CompactV2Archive::open_epoch_url(&epoch_url, args.epoch, cache_root) - .with_context(|| format!("Cannot open epoch {} at {epoch_url}", args.epoch))? } }; Ok(archive) } -/// Parallel scan settings for the selected source. With `--read-concurrency` -/// above 1, a local archive keeps that many block reads in flight. -pub(crate) fn parallel_config(args: &EpochSourceArgs) -> CompactV2ParallelScanConfig { - let mut config = CompactV2ParallelScanConfig::new(usize::from(args.threads)); - if args.archive_dir.is_some() - && args.read_concurrency > 1 - && let Some(input) = config.network_input.as_mut() - { - input.workers = usize::from(args.read_concurrency); - } - config -} - -pub(crate) fn request(archive: &CompactV2Archive, args: &EpochSourceArgs) -> Result { - Ok(match (args.first_block, args.max_blocks) { +pub(crate) fn request(archive: &CompactV2Archive, scan: &ScanArgs) -> Result { + Ok(match (scan.first_block, scan.max_blocks) { (0, None) => ScanRequest::all(), (first_block, limit) => ScanRequest::bounded( archive.bounded_range(first_block, limit.unwrap_or(NonZeroU32::MAX))?, @@ -185,11 +352,340 @@ pub(crate) fn request(archive: &CompactV2Archive, args: &EpochSourceArgs) -> Res }) } +fn build_firehose_config(args: &StreamArgs, is_tty: bool) -> Result { + let mut config = FirehoseConfig::foundation_epoch(args.source.epoch); + if let Some(origin) = &args.source.origin { + config.epoch_url = format!("{}/compact-v2", origin.trim_end_matches('/')); + config.object_path_layout = HttpObjectPathLayout::FlatEpoch; + } else { + config.epoch_url = args.source.resolved_epoch_url(); + config.object_path_layout = HttpObjectPathLayout::FlatObjects; + } + if let Some(region) = &args.source.s3_region { + let signer = S3SigV4Signer::new(S3Credentials::from_env()?, region.as_str())?; + config.signer = Some(Arc::new(signer)); + } + if let Some(nw) = args.scan.net_workers { + config.net_workers = usize::from(nw); + } + if let Some(dw) = args.scan.threads { + config.decode_workers = usize::from(dw); + } + config.segment_bytes = usize::from(args.segment_mb) * 1024 * 1024; + config.sub_batch_bytes = usize::from(args.sub_batch_mb) * 1024 * 1024; + let default_decode = match args.output { + StreamOutput::Summary => StreamDecodeLevel::Full, + StreamOutput::Jsonl => StreamDecodeLevel::Block, + }; + config.decode_level = match args.decode.unwrap_or(default_decode) { + StreamDecodeLevel::Full => FirehoseDecodeLevel::Full, + StreamDecodeLevel::Block => FirehoseDecodeLevel::Block, + }; + config.first_block = args.scan.first_block; + config.max_blocks = args.scan.max_blocks.map(NonZeroU32::get); + config.progress_interval = match args.output { + StreamOutput::Summary if is_tty => Duration::from_millis(100), + StreamOutput::Summary => Duration::from_secs(2), + StreamOutput::Jsonl => Duration::from_secs(3), + }; + Ok(config) +} + +fn run_direct_https_stream(args: &StreamArgs) -> Result<()> { + let is_summary = args.output == StreamOutput::Summary; + let is_tty = is_summary && !args.plain && io::stdout().is_terminal(); + let config = build_firehose_config(args, is_tty)?; + + if is_summary { + let level_label = match config.decode_level { + FirehoseDecodeLevel::Full => "full (zstd + wincode + every tx msg/meta/ix/cpi)", + FirehoseDecodeLevel::Block => "block (zstd + wincode + every tx row)", + }; + if is_tty { + println!("\x1b[1;36m⚡ BLOCKZILLA STREAM\x1b[0m — Cold-Start Ordered Epoch Stream"); + } else { + println!("BLOCKZILLA STREAM — Cold-Start Ordered Epoch Stream"); + } + println!(" Source : {}", config.epoch_url); + println!( + " Config : epoch={} · nw={} ({} MiB segs / {} MiB chunks) · dw={} · decode={}", + config.epoch, + config.net_workers, + args.segment_mb, + args.sub_batch_mb, + config.decode_workers, + level_label + ); + } else { + eprintln!( + "Streaming epoch {} directly from {} (no disk cache).", + args.source.epoch, config.epoch_url + ); + } + + let flush_every_block = args + .scan + .max_blocks + .is_some_and(|limit| u64::from(limit.get()) <= SMALL_STREAM_FLUSH_LIMIT); + let stdout = io::stdout(); + let mut json_out = + (!is_summary).then(|| BufWriter::with_capacity(STDOUT_BUFFER_BYTES, stdout.lock())); + let printed_lines = AtomicUsize::new(0); + + let report = run_epoch_firehose( + &config, + |idx| { + if is_summary { + println!( + " Index : {} blocks · {} txs · {:.2} GiB zstd · downloaded & verified in {:.0} ms (included in total)", + fmt_u64(idx.blocks), + fmt_u64(idx.transactions), + idx.compressed_bytes as f64 / (1024.0 * 1024.0 * 1024.0), + idx.elapsed.as_secs_f64() * 1_000.0, + ); + println!(); + } else { + eprintln!( + "Streaming {} blocks ({} transactions). JSON summaries go to stdout.", + idx.blocks, idx.transactions + ); + } + }, + |p| { + let secs = p.elapsed.as_secs_f64().max(0.001); + let frac_ord = (p.ordered_blocks as f64) / (p.total_blocks.max(1) as f64); + let frac_dec = (p.decoded_blocks as f64) / (p.total_blocks.max(1) as f64); + let ord_tps = p.ordered_transactions as f64 / secs; + let dec_tps = p.decoded_transactions as f64 / secs; + let gbps = (p.wire_bytes as f64) * 8.0 / 1e9 / secs; + let mib_s = (p.wire_bytes as f64) / (1024.0 * 1024.0) / secs; + let dec_gibs = (p.ordered_decoded_bytes as f64) / (1024.0 * 1024.0 * 1024.0) / secs; + + if !is_summary { + if !p.is_final { + eprintln!( + "Read {}/{} blocks, {} transactions in {:.1}s ({:.2} Gbps)", + p.ordered_blocks, p.total_blocks, p.ordered_transactions, secs, gbps, + ); + } + return; + } + if is_tty { + let prev = printed_lines.swap(3, Ordering::Relaxed); + if prev > 0 { + print!("\x1b[{prev}A"); + } + print!( + "\x1b[2K Ordered : [\x1b[32m{}\x1b[0m] {:5.1}% {:>9} / {} blks \x1b[1;32m{:>12}\x1b[0m\n", + progress_bar(frac_ord, 28), + frac_ord * 100.0, + fmt_u64(p.ordered_blocks), + fmt_u64(p.total_blocks), + fmt_tps(ord_tps), + ); + print!( + "\x1b[2K Decoded : [\x1b[36m{}\x1b[0m] {:5.1}% {:>9} / {} blks \x1b[1;36m{:>12}\x1b[0m\n", + progress_bar(frac_dec, 28), + frac_dec * 100.0, + fmt_u64(p.decoded_blocks), + fmt_u64(p.total_blocks), + fmt_tps(dec_tps), + ); + print!( + "\x1b[2K Wire : \x1b[1;33m{:5.2} Gbps\x1b[0m ({:6.1} MiB/s) · dec {:4.2} GiB/s · ix {:>11} · streams {:>3} · hedges {:>3} · retries {:>2} · {:5.1}s\n", + gbps, + mib_s, + dec_gibs, + fmt_u64(p.ordered_instructions), + p.active_streams, + p.hedges, + p.retries, + secs, + ); + let _ = io::stdout().flush(); + } else if !p.is_final { + println!( + " [{:5.1}s] ord={:5.1}% ({:>12}) dec={:5.1}% ({:>12}) | {:5.2} Gbps ({:6.1} MiB/s) | streams={} hedges={} retries={}", + secs, + frac_ord * 100.0, + fmt_tps(ord_tps), + frac_dec * 100.0, + fmt_tps(dec_tps), + gbps, + mib_s, + p.active_streams, + p.hedges, + p.retries, + ); + } + }, + |block| { + if let Some(output) = json_out.as_mut() { + write_block_summary_line( + output, + args.source.epoch, + block.block_ordinal, + block.slot, + block.transactions, + ) + .map_err(|source| SourceError::Io { + object: "stdout".into(), + source, + })?; + if flush_every_block { + output.flush().map_err(|source| SourceError::Io { + object: "stdout".into(), + source, + })?; + } + } + Ok(()) + }, + )?; + + if let Some(mut output) = json_out { + output.flush()?; + eprintln!( + "Stream complete: {} blocks, {} transactions in {:.1}s", + report.blocks, + report.transactions, + report.total_elapsed.as_secs_f64(), + ); + return Ok(()); + } + + let total_secs = report.total_elapsed.as_secs_f64().max(0.001); + let stream_secs = report.stream_elapsed.as_secs_f64().max(0.001); + let cold_tps = report.transactions as f64 / total_secs; + let stream_tps = report.transactions as f64 / stream_secs; + let blk_s = report.blocks as f64 / total_secs; + let ix_s = report.instructions as f64 / total_secs; + let wire_mib_s = (report.wire_bytes as f64) / (1024.0 * 1024.0) / total_secs; + let wire_gbps = (report.wire_bytes as f64) * 8.0 / 1e9 / total_secs; + let stream_gbps = (report.stream_wire_bytes as f64) * 8.0 / 1e9 / stream_secs; + let dec_gibs = (report.decoded_bytes as f64) / (1024.0 * 1024.0 * 1024.0) / total_secs; + + let (b_cyan, b_green, b_yellow, reset) = if is_tty { + ("\x1b[1;36m", "\x1b[1;32m", "\x1b[1;33m", "\x1b[0m") + } else { + ("", "", "", "") + }; + + let row = |plain: String, colored: Option| { + let pad = 74usize.saturating_sub(plain.chars().count()); + let body = colored.unwrap_or(plain); + println!( + "{b_cyan}║{reset} {body}{} {b_cyan}║{reset}", + " ".repeat(pad) + ); + }; + + let title = format!( + "BLOCKZILLA COLD-START EPOCH {} — FULL STREAM & DECODE COMPLETE", + report.epoch + ); + let r_tps_cold = format!( + "TPS (cold, incl. index) : {:>14} tx/s ({} blk/s)", + fmt_u64(cold_tps.round() as u64), + fmt_u64(blk_s.round() as u64), + ); + let r_tps_cold_c = format!( + "{b_green}TPS (cold, incl. index) : {:>14} tx/s{reset} ({} blk/s)", + fmt_u64(cold_tps.round() as u64), + fmt_u64(blk_s.round() as u64), + ); + let r_tps_stream = format!( + "TPS (stream + decode) : {:>14} tx/s ({} ix/s)", + fmt_u64(stream_tps.round() as u64), + fmt_u64(ix_s.round() as u64), + ); + let r_net = format!( + "Network Throughput : {:>6.2} Gbps ({:.1} MiB/s · stream {:.2} Gbps)", + wire_gbps, wire_mib_s, stream_gbps, + ); + let r_net_c = format!( + "{b_yellow}Network Throughput : {:>6.2} Gbps{reset} ({:.1} MiB/s · stream {:.2} Gbps)", + wire_gbps, wire_mib_s, stream_gbps, + ); + let r_dec = format!( + "Decoded Throughput : {:>6.2} GiB/s ({:.2} GiB zstd -> {:.2} GiB raw)", + dec_gibs, + report.compressed_bytes as f64 / (1024.0 * 1024.0 * 1024.0), + report.decoded_bytes as f64 / (1024.0 * 1024.0 * 1024.0), + ); + let r_time = format!( + "Total Time (cold) : {:>6.2}s (index: {:.0}ms + stream/dec: {:.2}s)", + total_secs, + report.index.elapsed.as_secs_f64() * 1_000.0, + stream_secs, + ); + let r_counts = format!( + "Blocks / Transactions : {} blks · {} txs", + fmt_u64(report.blocks), + fmt_u64(report.transactions), + ); + let r_ixs = format!( + "Instructions (CPI) : {} ix ({} inner CPI)", + fmt_u64(report.instructions), + fmt_u64(report.inner_instructions), + ); + let r_order = format!( + "Block Order : STRICT GLOBAL MONOTONIC OK ({} / {})", + fmt_u64(report.blocks), + fmt_u64(report.index.blocks), + ); + let r_order_c = format!( + "Block Order : {b_green}STRICT GLOBAL MONOTONIC OK{reset} ({} / {})", + fmt_u64(report.blocks), + fmt_u64(report.index.blocks), + ); + let r_http = format!( + "HTTP Stats : {} GETs · {} hedges · {} retries · chk {:04x}", + report.get_requests, + report.hedges, + report.retries, + report.checksum & 0xffff, + ); + + println!(); + println!( + "{b_cyan}╔══════════════════════════════════════════════════════════════════════════════╗{reset}" + ); + row(title, None); + println!( + "{b_cyan}╠══════════════════════════════════════════════════════════════════════════════╣{reset}" + ); + row(r_tps_cold, Some(r_tps_cold_c)); + row(r_tps_stream, None); + row(r_net, Some(r_net_c)); + row(r_dec, None); + println!( + "{b_cyan}╠══════════════════════════════════════════════════════════════════════════════╣{reset}" + ); + row(r_time, None); + row(r_counts, None); + row(r_ixs, None); + row(r_order, Some(r_order_c)); + row(r_http, None); + println!( + "{b_cyan}╚══════════════════════════════════════════════════════════════════════════════╝{reset}" + ); + + Ok(()) +} + pub(crate) fn run(args: StreamArgs) -> Result<()> { + let use_direct_https = args.source.archive_dir.is_none() + && (args.no_cache || args.output == StreamOutput::Summary); + if use_direct_https { + return run_direct_https_stream(&args); + } + let started = Instant::now(); - let args = args.source; - let mut archive = open(&args)?; - let request = request(&archive, &args)? + let emit_jsonl = args.output == StreamOutput::Jsonl; + let mut archive = + open_with_read_concurrency(&args.source, usize::from(args.scan.read_concurrency))?; + let request = request(&archive, &args.scan)? .without_instructions() .without_primary_signatures() .without_required_signers() @@ -199,17 +695,28 @@ pub(crate) fn run(args: StreamArgs) -> Result<()> { .map_or(u64::from(archive.identity().block_count), |range| { u64::from(range.block_count.get()) }); - eprintln!("Streaming {expected_blocks} blocks. JSON summaries go to stdout."); - let stdout = std::io::stdout(); + if emit_jsonl { + eprintln!("Streaming {expected_blocks} blocks. JSON summaries go to stdout."); + } else { + eprintln!("Scanning {expected_blocks} local archive blocks..."); + } + let stdout = io::stdout(); let mut sink = JsonSink { - output: stdout.lock(), + output: BufWriter::with_capacity(STDOUT_BUFFER_BYTES, stdout.lock()), started, last_report: Instant::now(), expected_blocks, + flush_every_block: expected_blocks <= SMALL_STREAM_FLUSH_LIMIT, + emit_jsonl, blocks: 0, transactions: 0, }; - let receipt = archive.scan_ordered_parallel(&request, &mut sink, parallel_config(&args))?; + let receipt = archive.scan_ordered_parallel( + &request, + &mut sink, + parallel_scan_config(&args.source, &args.scan), + )?; + sink.output.flush()?; archive.verify_local_unchanged()?; anyhow::ensure!( receipt.scan.blocks == expected_blocks @@ -217,12 +724,21 @@ pub(crate) fn run(args: StreamArgs) -> Result<()> { && receipt.scan.transactions == sink.transactions, "Stream counts do not match the selected archive rows", ); - eprintln!( - "Stream complete: {} blocks, {} transactions in {:.1}s", - receipt.scan.blocks, - receipt.scan.transactions, - started.elapsed().as_secs_f64(), - ); + let secs = started.elapsed().as_secs_f64().max(0.001); + if emit_jsonl { + eprintln!( + "Stream complete: {} blocks, {} transactions in {:.1}s", + receipt.scan.blocks, receipt.scan.transactions, secs, + ); + } else { + println!( + "Stream complete: {} blocks, {} transactions in {:.2}s ({} tx/s)", + fmt_u64(receipt.scan.blocks), + fmt_u64(receipt.scan.transactions), + secs, + fmt_u64((receipt.scan.transactions as f64 / secs).round() as u64), + ); + } Ok(()) } @@ -239,6 +755,8 @@ mod tests { started: now, last_report: now, expected_blocks: 1, + flush_every_block: true, + emit_jsonl: true, blocks: 0, transactions: 0, }; diff --git a/blockzilla/cli/src/token_dump.rs b/blockzilla/cli/src/token_dump.rs index 04c54ef2..b3ce24c3 100644 --- a/blockzilla/cli/src/token_dump.rs +++ b/blockzilla/cli/src/token_dump.rs @@ -2,61 +2,25 @@ use std::{ io::{self, BufWriter, Write}, - num::NonZeroU32, - path::PathBuf, time::Instant, }; use anyhow::{Context, Result}; use blockzilla_compact_v2_reader::archive::{ - ArchiveInstructionSource, BlockSink, BlockView, CompactV2Archive, CompactV2LocalDescriptor, - CompactV2ParallelScanConfig, QueryError, QueryResult, ScanRequest, + ArchiveInstructionSource, BlockSink, BlockView, QueryError, QueryResult, }; use blockzilla_model::{ExecutionStatus, TokenBalanceCoverage, TokenBalanceSide}; use clap::Args; use sha2::{Digest, Sha256}; +use crate::stream::{self, ArchiveSourceArgs, ScanArgs}; + #[derive(Args, Debug)] pub(crate) struct TokenDumpArgs { - /// Epoch to read from the public Foundation archive. - #[arg(long)] - pub epoch: u64, - /// Compatible HTTPS archive origin. Omit it to read the public Foundation bucket. - #[arg(long, env = "BLOCKZILLA_ORIGIN", conflicts_with = "archive_dir")] - pub origin: Option, - /// Public HTTPS epoch directory. Omit `--archive-url` and `--origin` to read - /// `https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004/epoch-`. - #[arg(long, env = "BLOCKZILLA_ARCHIVE_URL", conflicts_with_all = ["origin", "archive_dir"])] - pub archive_url: Option, - /// Sign requests to --archive-url for a private S3-compatible bucket in this - /// region (`auto` for Cloudflare R2). Credentials come from - /// AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and the optional - /// AWS_SESSION_TOKEN. - #[arg(long, requires = "archive_url")] - pub s3_region: Option, - /// Cache directory. Relative paths are resolved from the current directory. - #[arg(long, default_value = ".blockzilla-cache")] - pub cache_root: PathBuf, - /// Read this local epoch directory instead of the HTTPS source. - #[arg(long, requires = "source_id")] - pub archive_dir: Option, - /// Stable ID for a local archive build. Change it when you replace that build. - #[arg(long, requires = "archive_dir")] - pub source_id: Option, - /// Concurrent block reads for --archive-dir. Use several on a NAS or disk - /// array; 1 reads one range at a time. - #[arg(long, default_value_t = 1, requires = "archive_dir", value_parser = clap::value_parser!(u16).range(1..=64))] - pub read_concurrency: u16, - /// Decode workers (1 through 64). - #[arg(long, default_value_t = 4, value_parser = clap::value_parser!(u16).range(1..=64))] - pub threads: u16, - /// First block row to read. Use the next row after a saved checkpoint to - /// resume a dump. - #[arg(long, default_value_t = 0)] - pub first_block: u32, - /// Read at most this many block rows. Omit to read all admitted rows. - #[arg(long)] - pub max_blocks: Option, + #[command(flatten)] + pub source: ArchiveSourceArgs, + #[command(flatten)] + pub scan: ScanArgs, /// Select one base58 mint. Unknown mint identities remain visible as null. #[arg(long, value_parser = parse_mint)] pub mint: Option<[u8; 32]>, @@ -222,83 +186,11 @@ impl BlockSink for TokenSink { } } -fn open(args: &TokenDumpArgs) -> Result { - eprintln!("Opening epoch {}...", args.epoch); - let archive = if let Some(root) = &args.archive_dir { - let root = std::fs::canonicalize(&root) - .with_context(|| format!("Cannot open archive directory {}", root.display()))?; - let source_id = args - .source_id - .as_deref() - .context("Local reads require --source-id")?; - let descriptor = CompactV2LocalDescriptor::mainnet(args.epoch, source_id)?; - CompactV2Archive::open_local_with_read_concurrency( - root, - descriptor, - usize::from(args.read_concurrency), - )? - } else { - let cache_root = if args.cache_root.is_absolute() { - args.cache_root.clone() - } else { - std::env::current_dir()?.join(&args.cache_root) - }; - if let Some(epoch_url) = &args.archive_url { - eprintln!("Source: {epoch_url}\nPreparing archive index and key registry..."); - match &args.s3_region { - Some(region) => { - let signer = blockzilla_compact_v2_reader::S3SigV4Signer::new( - blockzilla_compact_v2_reader::S3Credentials::from_env()?, - region.as_str(), - )?; - CompactV2Archive::open_signed_epoch_url( - epoch_url, - args.epoch, - cache_root, - std::sync::Arc::new(signer), - ) - } - None => CompactV2Archive::open_epoch_url(epoch_url, args.epoch, cache_root), - } - .with_context(|| format!("Cannot open epoch {} at {epoch_url}", args.epoch))? - } else if let Some(origin) = args.origin.as_deref() { - eprintln!("Source: {origin}\nPreparing archive index and key registry..."); - CompactV2Archive::open(origin, args.epoch, cache_root) - .with_context(|| format!("Cannot open epoch {} at {origin}", args.epoch))? - } else { - let epoch_url = blockzilla::public_epoch_url(args.epoch); - eprintln!("Source: {epoch_url}\nPreparing archive index and key registry..."); - CompactV2Archive::open_epoch_url(&epoch_url, args.epoch, cache_root) - .with_context(|| format!("Cannot open epoch {} at {epoch_url}", args.epoch))? - } - }; - Ok(archive) -} - -fn parallel_config(args: &TokenDumpArgs) -> CompactV2ParallelScanConfig { - let mut config = CompactV2ParallelScanConfig::new(usize::from(args.threads)); - if args.archive_dir.is_some() - && args.read_concurrency > 1 - && let Some(input) = config.network_input.as_mut() - { - input.workers = usize::from(args.read_concurrency); - } - config -} - -fn request(archive: &CompactV2Archive, args: &TokenDumpArgs) -> Result { - Ok(match (args.first_block, args.max_blocks) { - (0, None) => ScanRequest::all(), - (first_block, limit) => ScanRequest::bounded( - archive.bounded_range(first_block, limit.unwrap_or(NonZeroU32::MAX))?, - ), - }) -} - pub(crate) fn run(args: TokenDumpArgs) -> Result<()> { let started = Instant::now(); - let mut archive = open(&args)?; - let request = request(&archive, &args)? + let mut archive = + stream::open_with_read_concurrency(&args.source, usize::from(args.scan.read_concurrency))?; + let request = stream::request(&archive, &args.scan)? .without_instructions() .without_required_signers(); let request = match args.mint { @@ -316,7 +208,11 @@ pub(crate) fn run(args: TokenDumpArgs) -> Result<()> { &source_id, ); let receipt = archive - .scan_ordered_parallel(&request, &mut sink, parallel_config(&args)) + .scan_ordered_parallel( + &request, + &mut sink, + stream::parallel_scan_config(&args.source, &args.scan), + ) .context("Token dump stopped; output can contain an incomplete prefix")?; sink.output.flush().context("flush token dump output")?; archive.verify_local_unchanged()?; @@ -407,10 +303,18 @@ mod tests { key[..(seed % 4) as usize].fill(0); key }; - let text = |key: Option<[u8; 32]>| key.map(|key| bs58::encode(key).into_string()); - let signature_text = |signature: Option<[u8; 64]>| { - signature.map(|signature| bs58::encode(signature).into_string()) + let encode_32 = |key: [u8; 32]| { + let mut out = [0u8; five8::BASE58_ENCODED_32_MAX_LEN]; + let len = five8::encode_32(&key, &mut out) as usize; + String::from_utf8(out[..len].to_vec()).unwrap() }; + let encode_64 = |sig: [u8; 64]| { + let mut out = [0u8; five8::BASE58_ENCODED_64_MAX_LEN]; + let len = five8::encode_64(&sig, &mut out) as usize; + String::from_utf8(out[..len].to_vec()).unwrap() + }; + let text = |key: Option<[u8; 32]>| key.map(encode_32); + let signature_text = |signature: Option<[u8; 64]>| signature.map(encode_64); for source_id in ["source-test", "a\"b\\c\u{1}"] { let mut sink = TokenSink::new(Vec::new(), source_id); let mut expected = Vec::new(); @@ -506,7 +410,12 @@ mod tests { let row: serde_json::Value = serde_json::from_slice(&sink.output).unwrap(); assert_eq!(row["amount"], u64::MAX.to_string()); assert_eq!(row["mint"], serde_json::Value::Null); - assert_eq!(row["signature"], bs58::encode([5; 64]).into_string()); + let mut expected_sig = [0u8; five8::BASE58_ENCODED_64_MAX_LEN]; + let expected_sig_len = five8::encode_64(&[5; 64], &mut expected_sig) as usize; + assert_eq!( + row["signature"], + std::str::from_utf8(&expected_sig[..expected_sig_len]).unwrap() + ); assert_eq!(row["execution_status"], "failed"); assert_eq!(row["balance_index"], 9); assert_eq!(row["account_index"], 4); @@ -539,8 +448,10 @@ mod tests { assert!(parse_mint("bad!").is_err()); assert!(parse_mint("1").is_err()); assert!(parse_mint(&"1".repeat(33)).is_err()); + let mut max_key = [0u8; five8::BASE58_ENCODED_32_MAX_LEN]; + let max_key_len = five8::encode_32(&[255; 32], &mut max_key) as usize; assert_eq!( - parse_mint(&bs58::encode([255; 32]).into_string()).unwrap(), + parse_mint(std::str::from_utf8(&max_key[..max_key_len]).unwrap()).unwrap(), [255; 32] ); assert_eq!( diff --git a/blockzilla/get-block/Cargo.toml b/blockzilla/get-block/Cargo.toml index bd11f0f8..734097ba 100644 --- a/blockzilla/get-block/Cargo.toml +++ b/blockzilla/get-block/Cargo.toml @@ -42,7 +42,7 @@ worker = [ "dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:worker", - "dep:solana-signature", + "dep:ed25519-dalek", "dep:thiserror", ] @@ -71,7 +71,7 @@ sha2 = { version = "0.11.0", default-features = false } wasm-bindgen = { version = "0.2.128", optional = true } wasm-bindgen-futures = { version = "0.4.78", optional = true } worker = { version = "0.8.5", features = ["http"], optional = true } -solana-signature = { version = "3.4.1", features = ["verify"], optional = true } +ed25519-dalek = { version = "3.0.0", default-features = false, features = ["fast"], optional = true } thiserror = { version = "2.0.20", optional = true } wincode = "=0.6.1" zstd = { version = "0.14.0", default-features = false, optional = true } diff --git a/blockzilla/get-block/resolver/Cargo.lock b/blockzilla/get-block/resolver/Cargo.lock index de629beb..85a8f6dc 100644 --- a/blockzilla/get-block/resolver/Cargo.lock +++ b/blockzilla/get-block/resolver/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -110,17 +92,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "aws-lc-rs" version = "1.19.0" @@ -208,12 +179,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.2" @@ -240,7 +205,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -266,7 +231,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -276,15 +241,13 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-get-block" -version = "0.2.0" +version = "0.3.0" dependencies = [ "base64", "blockzilla-archive-v2", @@ -302,40 +265,37 @@ dependencies = [ [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] @@ -349,7 +309,7 @@ dependencies = [ "blockzilla-bank-stream-v2", "blockzilla-get-block", "blockzilla-primitives", - "clap 4.6.9", + "clap", "five8", "hex", "hivezilla-stream", @@ -370,14 +330,9 @@ dependencies = [ [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] @@ -398,30 +353,6 @@ dependencies = [ "wincode", ] -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.10", -] - [[package]] name = "bs58" version = "0.5.1" @@ -484,21 +415,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.6.9" @@ -518,7 +434,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -620,12 +536,6 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - [[package]] name = "crypto-common" version = "0.2.2" @@ -654,7 +564,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.119", ] @@ -715,19 +625,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.3" @@ -777,39 +674,18 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" - [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -946,17 +822,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -966,22 +831,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -990,7 +846,7 @@ version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1019,15 +875,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hex" version = "0.4.3" @@ -1045,7 +892,7 @@ dependencies = [ "blockzilla-stream-decoder", "bs58", "bytes", - "clap 4.6.9", + "clap", "futures-util", "hyper-util", "libc", @@ -1104,15 +951,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.15" @@ -1315,15 +1153,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" -[[package]] -name = "itertools" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.19" @@ -1429,15 +1258,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.35" @@ -1482,27 +1302,6 @@ name = "minicbor" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7244eafd1e09e7c4e33043881997aa6ab6dffff3ed2cee3395a278980481d6e" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" @@ -1515,22 +1314,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -1549,64 +1332,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", -] - [[package]] name = "pastey" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.34.0", - "env_logger", - "log", - "nom", -] - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -1643,25 +1380,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "prettyplease" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" -dependencies = [ - "proc-macro2", - "syn 3.0.10", -] - -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -1671,136 +1389,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef0b569d1d907ab3a28596aee62cf1f61dacb0529a4bedcd8e7460e2d5228b4" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e4d69d0fa3e7f6f9cf6b53a0e83e4fc99ba3586f65ce166cff30bd13bb4ad2" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 3.0.10", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad9c5423459fa2f729b8d9235fab810aa29628b171467744fc86d21460ad70d" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "prost-types" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29a7c4c7a84cef41a53d338a2d10d4f1b043ea5c3dde26db22ee2c9c1b1c75b" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8760a25b6ff9c620324822737e468478fa092234190d2e449760344354896ed9" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fa2624782ca04cd44f51554566717377acd240e4c0016d757dd74fccc9324f" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2417e9817fa237dab803ad4dda7357a111656e242959cc6b8f9a1a583367d42" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d189c34636356a46a7ed3188233dc8a88c431278cc54d4a19b096a2d270e985" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171e39f1e846e5f322ced1ac3b8d4cd3a3833ca24b6e5d58b3632574fe6204fa" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873cdcc097593432086661aa432b8078f1cd87bfb02847c332e98ae2c119e966" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb72df001783b8297847fe8f5f874ee400fd742c843d60583e8c23d96977c7f" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04652167eca899dda05f32f5481adeaf25c623a98ce2fc146a001cc59a2add7" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "263a3f48f01e7309e857138bd47f785585b4a005e8e56c6d2824ce91195999c3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quinn" version = "0.11.12" @@ -1919,44 +1507,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "regex" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" - [[package]] name = "reqwest" version = "0.13.5" @@ -2028,7 +1578,7 @@ version = "0.40.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3" dependencies = [ - "bitflags 2.13.2", + "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -2058,7 +1608,7 @@ version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ - "bitflags 2.13.2", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -2180,19 +1730,13 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "security-framework" version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -2352,59 +1896,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "solana-address" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451294fdd4dde59ae27213695e2333eaaa39035e1f099f68644d2aa3ca0e2edd" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-define-syscall" -version = "5.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8506988b0997022c4f2801985d9c4dccfb18c16e6a38f30390a47d54efeca805" - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b8ba5d677d77a76d557b59ce7ecf9a8578743089cb25c73990752c5f005885" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - [[package]] name = "sqlite-wasm-rs" version = "0.5.5" @@ -2423,12 +1914,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -2496,24 +1981,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.21" @@ -2601,36 +2068,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml_datetime" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.25.20+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e76360e201d6dbd6583e17795ba71a88f47365a9139c8450a7979c32303b8e73" -dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.1.6+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6769c452d71ba30696c6b37770c439a9cc9110f47f7d5cdbeda79840ef5ea31" -dependencies = [ - "winnow", -] - [[package]] name = "tower" version = "0.5.3" @@ -2653,7 +2090,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.13.2", + "bitflags", "bytes", "futures-util", "http", @@ -2721,12 +2158,6 @@ version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "untrusted" version = "0.9.0" @@ -2772,12 +2203,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "voracious_radix_sort" version = "1.2.2" @@ -2909,22 +2334,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.11" @@ -2934,12 +2343,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "wincode" version = "0.6.1" @@ -3053,15 +2456,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" -dependencies = [ - "memchr", -] - [[package]] name = "writeable" version = "0.6.4" @@ -3091,26 +2485,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.8.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed43f3060383c64b000f3c630550aebdfa9d3b76d48de32390483dd2cc7e0865" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5cbd820fe3e35fb38c83b6dc7e6b1618bc46e0cd10073ae94e8d52dc468d8b9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "zerofrom" version = "0.1.8" diff --git a/blockzilla/ledger-archive/Cargo.lock b/blockzilla/ledger-archive/Cargo.lock index 6b6ecf2a..a26d2104 100644 --- a/blockzilla/ledger-archive/Cargo.lock +++ b/blockzilla/ledger-archive/Cargo.lock @@ -319,15 +319,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -647,17 +638,6 @@ dependencies = [ "url", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.5.1" @@ -925,7 +905,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -939,7 +919,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -949,59 +929,51 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey 4.4.0", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey 4.4.0", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey 4.4.0", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2 0.9.12", "ph", - "solana-pubkey 4.4.0", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", "prost", - "prost-build", - "protoc-bin-vendored", "quick-protobuf", "serde", "wincode", @@ -1304,21 +1276,6 @@ dependencies = [ "libc", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width 0.1.14", - "vec_map", -] - [[package]] name = "clap" version = "4.6.10" @@ -1338,7 +1295,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -1430,7 +1387,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", - "unicode-width 0.2.3", + "unicode-width", "windows-sys 0.59.0", ] @@ -1442,7 +1399,7 @@ checksum = "e96a4956774c13c126a8b5af4daa79384f4d826534c95a02d76afb39e2ab64e3" dependencies = [ "encode_unicode", "libc", - "unicode-width 0.2.3", + "unicode-width", "windows-sys 0.61.2", ] @@ -1692,7 +1649,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.119", ] @@ -1705,7 +1662,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 3.0.10", ] @@ -1971,19 +1928,6 @@ dependencies = [ "syn 3.0.10", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.3" @@ -2404,17 +2348,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -2477,15 +2410,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.5.3" @@ -2500,7 +2424,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hivezilla-ledger-archive" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", @@ -2510,7 +2434,7 @@ dependencies = [ "blockzilla-solana-wire", "bs58", "chrono", - "clap 4.6.10", + "clap", "hex", "reqwest 0.13.5", "serde", @@ -2617,15 +2541,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.15" @@ -2901,7 +2816,7 @@ checksum = "9433806cd6b4ec1aba79c021c7e4c58fb4c3b9977c085062e611ac929998fb0c" dependencies = [ "console 0.16.6", "portable-atomic", - "unicode-width 0.2.3", + "unicode-width", "unit-prefix", "web-time", ] @@ -3327,21 +3242,6 @@ name = "minicbor" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7244eafd1e09e7c4e33043881997aa6ab6dffff3ed2cee3395a278980481d6e" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] [[package]] name = "minimal-lexical" @@ -3526,7 +3426,7 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "hermit-abi 0.5.3", + "hermit-abi", "libc", ] @@ -3704,18 +3604,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.34.0", - "env_logger", - "log", - "nom", -] - [[package]] name = "pbkdf2" version = "0.11.0" @@ -4014,70 +3902,6 @@ dependencies = [ "autotools", ] -[[package]] -name = "protoc-bin-vendored" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8760a25b6ff9c620324822737e468478fa092234190d2e449760344354896ed9" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fa2624782ca04cd44f51554566717377acd240e4c0016d757dd74fccc9324f" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2417e9817fa237dab803ad4dda7357a111656e242959cc6b8f9a1a583367d42" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d189c34636356a46a7ed3188233dc8a88c431278cc54d4a19b096a2d270e985" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171e39f1e846e5f322ced1ac3b8d4cd3a3833ca24b6e5d58b3632574fe6204fa" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873cdcc097593432086661aa432b8078f1cd87bfb02847c332e98ae2c119e966" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb72df001783b8297847fe8f5f874ee400fd742c843d60583e8c23d96977c7f" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04652167eca899dda05f32f5481adeaf25c623a98ce2fc146a001cc59a2add7" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "263a3f48f01e7309e857138bd47f785585b4a005e8e56c6d2824ce91195999c3" - [[package]] name = "pulldown-cmark" version = "0.13.6" @@ -4118,12 +3942,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quick-protobuf" version = "0.8.1" @@ -8067,12 +7885,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -8184,30 +7996,12 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width 0.1.14", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -8580,12 +8374,6 @@ version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "unicode-width" version = "0.2.3" @@ -8672,12 +8460,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.5" diff --git a/blockzilla/ledger-archive/Cargo.toml b/blockzilla/ledger-archive/Cargo.toml index 5f49454f..46855eec 100644 --- a/blockzilla/ledger-archive/Cargo.toml +++ b/blockzilla/ledger-archive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hivezilla-ledger-archive" -version = "0.2.0" +version = "0.3.0" edition = "2024" rust-version = "1.98.1" license = "MIT" diff --git a/crates/blockzilla-live-format/Cargo.toml b/crates/blockzilla-live-format/Cargo.toml index aac0d0aa..5285d613 100644 --- a/crates/blockzilla-live-format/Cargo.toml +++ b/crates/blockzilla-live-format/Cargo.toml @@ -17,13 +17,13 @@ known-program-logs = [ ] [dependencies] -blockzilla-archive-v2 = { path = "../compact-v2/blockzilla-archive-v2", default-features = false, version = "0.2.0" } -blockzilla-compact = { path = "../compact-v2/blockzilla-compact", default-features = false, version = "0.2.0" } +blockzilla-archive-v2 = { path = "../compact-v2/blockzilla-archive-v2", default-features = false, version = "0.3.0" } +blockzilla-compact = { path = "../compact-v2/blockzilla-compact", default-features = false, version = "0.3.0" } serde = { version = "1.0.229", features = ["derive"] } wincode = { version = "=0.6.1", features = ["derive"] } [dev-dependencies] -blockzilla-primitives = { path = "../blockzilla-primitives", version = "0.2.0" } +blockzilla-primitives = { path = "../blockzilla-primitives", version = "0.3.0" } [lints] workspace = true diff --git a/crates/blockzilla-model/Cargo.toml b/crates/blockzilla-model/Cargo.toml index 0992fa15..e9c07e83 100644 --- a/crates/blockzilla-model/Cargo.toml +++ b/crates/blockzilla-model/Cargo.toml @@ -10,7 +10,7 @@ description = "Source-neutral ordered query API for Blockzilla archive formats" [dependencies] serde = { version = "1.0.229", features = ["derive"] } -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } thiserror = "2.0.20" [dev-dependencies] diff --git a/crates/blockzilla-model/src/model.rs b/crates/blockzilla-model/src/model.rs index 82c49c11..3fa28175 100644 --- a/crates/blockzilla-model/src/model.rs +++ b/crates/blockzilla-model/src/model.rs @@ -165,7 +165,7 @@ pub struct CanonicalTransaction { } impl CanonicalTransaction { - fn validate(&self, expected_tx_index: u32) -> Result<()> { + pub(crate) fn validate(&self, expected_tx_index: u32) -> Result<()> { if self.header.tx_index != expected_tx_index { return Err(Error::InvalidTransaction(format!( "transaction index is {}, expected {expected_tx_index}", diff --git a/crates/blockzilla-primitives/Cargo.toml b/crates/blockzilla-primitives/Cargo.toml index 969c74d4..553df439 100644 --- a/crates/blockzilla-primitives/Cargo.toml +++ b/crates/blockzilla-primitives/Cargo.toml @@ -11,8 +11,8 @@ description = "Shared key, string-table and LEB128 framing primitives" [dependencies] anyhow = "1.0.104" +five8 = "1.0.0" serde = { version = "1.0.229", features = ["derive"] } -solana-pubkey = "4.2.1" wincode = { version = "=0.6.1", features = ["derive"] } [lints] diff --git a/crates/blockzilla-primitives/src/primitives/pubkey.rs b/crates/blockzilla-primitives/src/primitives/pubkey.rs index 84578916..b6f2cde6 100644 --- a/crates/blockzilla-primitives/src/primitives/pubkey.rs +++ b/crates/blockzilla-primitives/src/primitives/pubkey.rs @@ -1,13 +1,51 @@ use core::mem::MaybeUninit; use serde::{Deserialize, Serialize}; -use solana_pubkey::Pubkey; use wincode::{ ReadResult, SchemaRead, SchemaWrite, WriteResult, config::ConfigCore, io::{Reader, Writer}, }; +/// Well-known Solana program IDs in raw 32-byte form. +pub const SYSTEM_PROGRAM_ID: [u8; 32] = [0; 32]; +pub const COMPUTE_BUDGET_PROGRAM_ID: [u8; 32] = [ + 3, 6, 70, 111, 229, 33, 23, 50, 255, 236, 173, 186, 114, 195, 155, 231, 188, 140, 229, 187, + 197, 247, 18, 107, 44, 67, 155, 58, 64, 0, 0, 0, +]; +pub const VOTE_PROGRAM_ID: [u8; 32] = [ + 7, 97, 72, 29, 53, 116, 116, 187, 124, 77, 118, 36, 235, 211, 189, 179, 216, 53, 94, 115, 209, + 16, 67, 252, 13, 163, 83, 128, 0, 0, 0, 0, +]; +pub const SPL_TOKEN_PROGRAM_ID: [u8; 32] = [ + 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, + 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169, +]; +pub const ASSOCIATED_TOKEN_PROGRAM_ID: [u8; 32] = [ + 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, + 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89, +]; +pub const TOKEN_2022_PROGRAM_ID: [u8; 32] = [ + 6, 221, 246, 225, 238, 117, 143, 222, 24, 66, 93, 188, 228, 108, 205, 218, 182, 26, 252, 77, + 131, 185, 13, 39, 254, 189, 249, 40, 216, 161, 139, 252, +]; + +/// Encode a 32-byte public key as canonical base58. +#[inline] +pub fn encode_pubkey_base58(bytes: &[u8; 32]) -> String { + let mut buf = [0u8; five8::BASE58_ENCODED_32_MAX_LEN]; + let len = five8::encode_32(bytes, &mut buf) as usize; + String::from_utf8(buf[..len].to_vec()).expect("five8 alphabet is ASCII") +} + +/// Decode a canonical base58 32-byte public key. +#[inline] +pub fn decode_pubkey_base58(s: &str) -> Option<[u8; 32]> { + let mut bytes = [0u8; 32]; + five8::decode_32(s, &mut bytes).ok()?; + Some(bytes) +} + /// Resolves one-based public-key registry identifiers. /// /// Implementations can keep keys in memory or read one 32-byte record from an @@ -51,8 +89,9 @@ impl CompactPubkey { } #[inline] - pub fn to_pubkey(self, resolver: &R) -> Option { - self.resolve(resolver).map(Pubkey::new_from_array) + pub fn to_base58(self, resolver: &R) -> Option { + self.resolve(resolver) + .map(|bytes| encode_pubkey_base58(&bytes)) } } @@ -151,6 +190,36 @@ mod tests { wincode::config::deserialize_exact(&bytes, leb128_config()).unwrap(); assert_eq!(decoded, CompactPubkey::raw(pubkey)); } + + #[test] + fn known_program_id_constants_round_trip_base58() { + for (bytes, expected) in [ + (SYSTEM_PROGRAM_ID, "11111111111111111111111111111111"), + ( + COMPUTE_BUDGET_PROGRAM_ID, + "ComputeBudget111111111111111111111111111111", + ), + ( + VOTE_PROGRAM_ID, + "Vote111111111111111111111111111111111111111", + ), + ( + SPL_TOKEN_PROGRAM_ID, + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + ), + ( + ASSOCIATED_TOKEN_PROGRAM_ID, + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", + ), + ( + TOKEN_2022_PROGRAM_ID, + "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", + ), + ] { + assert_eq!(encode_pubkey_base58(&bytes), expected); + assert_eq!(decode_pubkey_base58(expected), Some(bytes)); + } + } } pub trait PubkeyCompactor { diff --git a/crates/blockzilla-solana-wire/Cargo.toml b/crates/blockzilla-solana-wire/Cargo.toml index 28ba0d00..8ecf3f9b 100644 --- a/crates/blockzilla-solana-wire/Cargo.toml +++ b/crates/blockzilla-solana-wire/Cargo.toml @@ -9,24 +9,20 @@ description = "Shared Solana transaction, execution metadata and source metadata publish = ["crates-io"] [features] -default = [] +default = ["protobuf"] +protobuf = ["dep:prost", "dep:quick-protobuf"] zstd-native = ["dep:zstd"] zstd-wasm = ["dep:ruzstd"] [dependencies] -minicbor = { version = "2.3.0", features = ["full"] } -prost = "0.14.4" -quick-protobuf = "0.8.1" +minicbor = { version = "2.3.0", default-features = false, features = ["alloc"] } +prost = { version = "0.14.4", optional = true } +quick-protobuf = { version = "0.8.1", optional = true } serde = { version = "1.0.229", features = ["derive"] } wincode = { version = "=0.6.1", features = ["derive"] } -zstd = { version = "0.14.0", optional = true } +zstd = { version = "0.14.0", default-features = false, optional = true } ruzstd = { version = "0.9.0", optional = true } -[build-dependencies] -pb-rs = "0.10.0" -prost-build = "0.14.4" -protoc-bin-vendored = "3.2.0" - [dev-dependencies] serde_json = "1.0.151" diff --git a/crates/blockzilla-solana-wire/build.rs b/crates/blockzilla-solana-wire/build.rs deleted file mode 100644 index 6f1491a9..00000000 --- a/crates/blockzilla-solana-wire/build.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::error::Error; -use std::path::PathBuf; - -fn main() -> Result<(), Box> { - println!("cargo:rerun-if-changed=src/confirmed_block.proto"); - - let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").expect("OUT_DIR is set")); - let manifest_dir = - PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")); - let proto = manifest_dir.join("src/confirmed_block.proto"); - let proto_dir = manifest_dir.join("src"); - let protos = [proto]; - let includes = [proto_dir]; - - let mut prost = prost_build::Config::new(); - if std::env::var_os("PROTOC").is_none() { - prost.protoc_executable(protoc_bin_vendored::protoc_bin_path()?); - } - prost.protoc_arg("--experimental_allow_proto3_optional"); - prost.compile_protos(&protos, &includes)?; - - let quick_out_dir = out_dir.join("quick-protobuf"); - std::fs::create_dir_all(&quick_out_dir)?; - - let config = pb_rs::ConfigBuilder::new(&protos, None, Some(&quick_out_dir), &includes) - .expect("quick-protobuf config") - .build(); - pb_rs::types::FileDescriptor::run(&config).expect("quick-protobuf codegen"); - - Ok(()) -} diff --git a/crates/blockzilla-solana-wire/src/generated/quick_protobuf/mod.rs b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/mod.rs new file mode 100644 index 00000000..445c23d4 --- /dev/null +++ b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/mod.rs @@ -0,0 +1,3 @@ +// Pre-generated by pb-rs from src/confirmed_block.proto (avoids build-time codegen deps). +#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod solana; diff --git a/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/mod.rs b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/mod.rs new file mode 100644 index 00000000..7e2d960e --- /dev/null +++ b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/mod.rs @@ -0,0 +1,2 @@ +// Automatically generated mod.rs +pub mod storage; diff --git a/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/ConfirmedBlock.rs b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/ConfirmedBlock.rs new file mode 100644 index 00000000..61bf91fc --- /dev/null +++ b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/ConfirmedBlock.rs @@ -0,0 +1,925 @@ +// Automatically generated rust module for 'confirmed_block.proto' file + +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(unused_imports)] +#![allow(unknown_lints)] +#![allow(clippy::all)] +#![cfg_attr(rustfmt, rustfmt_skip)] + + +use std::borrow::Cow; +use quick_protobuf::{MessageInfo, MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result}; +use quick_protobuf::sizeofs::*; +use super::super::super::*; + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum RewardType { + Unspecified = 0, + Fee = 1, + Rent = 2, + Staking = 3, + Voting = 4, +} + +impl Default for RewardType { + fn default() -> Self { + RewardType::Unspecified + } +} + +impl From for RewardType { + fn from(i: i32) -> Self { + match i { + 0 => RewardType::Unspecified, + 1 => RewardType::Fee, + 2 => RewardType::Rent, + 3 => RewardType::Staking, + 4 => RewardType::Voting, + _ => Self::default(), + } + } +} + +impl<'a> From<&'a str> for RewardType { + fn from(s: &'a str) -> Self { + match s { + "Unspecified" => RewardType::Unspecified, + "Fee" => RewardType::Fee, + "Rent" => RewardType::Rent, + "Staking" => RewardType::Staking, + "Voting" => RewardType::Voting, + _ => Self::default(), + } + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct ConfirmedBlock<'a> { + pub previous_blockhash: Cow<'a, str>, + pub blockhash: Cow<'a, str>, + pub parent_slot: u64, + pub transactions: Vec>, + pub rewards: Vec>, + pub block_time: Option, + pub block_height: Option, + pub num_partitions: Option, +} + +impl<'a> MessageRead<'a> for ConfirmedBlock<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.previous_blockhash = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(18) => msg.blockhash = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(24) => msg.parent_slot = r.read_uint64(bytes)?, + Ok(34) => msg.transactions.push(r.read_message::(bytes)?), + Ok(42) => msg.rewards.push(r.read_message::(bytes)?), + Ok(50) => msg.block_time = Some(r.read_message::(bytes)?), + Ok(58) => msg.block_height = Some(r.read_message::(bytes)?), + Ok(66) => msg.num_partitions = Some(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for ConfirmedBlock<'a> { + fn get_size(&self) -> usize { + 0 + + if self.previous_blockhash == "" { 0 } else { 1 + sizeof_len((&self.previous_blockhash).len()) } + + if self.blockhash == "" { 0 } else { 1 + sizeof_len((&self.blockhash).len()) } + + if self.parent_slot == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.parent_slot) as u64) } + + self.transactions.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.rewards.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.block_time.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + self.block_height.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + self.num_partitions.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.previous_blockhash != "" { w.write_with_tag(10, |w| w.write_string(&**&self.previous_blockhash))?; } + if self.blockhash != "" { w.write_with_tag(18, |w| w.write_string(&**&self.blockhash))?; } + if self.parent_slot != 0u64 { w.write_with_tag(24, |w| w.write_uint64(*&self.parent_slot))?; } + for s in &self.transactions { w.write_with_tag(34, |w| w.write_message(s))?; } + for s in &self.rewards { w.write_with_tag(42, |w| w.write_message(s))?; } + if let Some(ref s) = self.block_time { w.write_with_tag(50, |w| w.write_message(s))?; } + if let Some(ref s) = self.block_height { w.write_with_tag(58, |w| w.write_message(s))?; } + if let Some(ref s) = self.num_partitions { w.write_with_tag(66, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct ConfirmedTransaction<'a> { + pub transaction: Option>, + pub meta: Option>, +} + +impl<'a> MessageRead<'a> for ConfirmedTransaction<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.transaction = Some(r.read_message::(bytes)?), + Ok(18) => msg.meta = Some(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for ConfirmedTransaction<'a> { + fn get_size(&self) -> usize { + 0 + + self.transaction.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + self.meta.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if let Some(ref s) = self.transaction { w.write_with_tag(10, |w| w.write_message(s))?; } + if let Some(ref s) = self.meta { w.write_with_tag(18, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct Transaction<'a> { + pub signatures: Vec>, + pub message: Option>, +} + +impl<'a> MessageRead<'a> for Transaction<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.signatures.push(r.read_bytes(bytes).map(Cow::Borrowed)?), + Ok(18) => msg.message = Some(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for Transaction<'a> { + fn get_size(&self) -> usize { + 0 + + self.signatures.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + self.message.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + for s in &self.signatures { w.write_with_tag(10, |w| w.write_bytes(&**s))?; } + if let Some(ref s) = self.message { w.write_with_tag(18, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct Message<'a> { + pub header: Option, + pub account_keys: Vec>, + pub recent_blockhash: Cow<'a, [u8]>, + pub instructions: Vec>, + pub versioned: bool, + pub address_table_lookups: Vec>, + pub config: Option, +} + +impl<'a> MessageRead<'a> for Message<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.header = Some(r.read_message::(bytes)?), + Ok(18) => msg.account_keys.push(r.read_bytes(bytes).map(Cow::Borrowed)?), + Ok(26) => msg.recent_blockhash = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(34) => msg.instructions.push(r.read_message::(bytes)?), + Ok(40) => msg.versioned = r.read_bool(bytes)?, + Ok(50) => msg.address_table_lookups.push(r.read_message::(bytes)?), + Ok(58) => msg.config = Some(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for Message<'a> { + fn get_size(&self) -> usize { + 0 + + self.header.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + self.account_keys.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + if self.recent_blockhash == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.recent_blockhash).len()) } + + self.instructions.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + if self.versioned == false { 0 } else { 1 + sizeof_varint(*(&self.versioned) as u64) } + + self.address_table_lookups.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.config.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if let Some(ref s) = self.header { w.write_with_tag(10, |w| w.write_message(s))?; } + for s in &self.account_keys { w.write_with_tag(18, |w| w.write_bytes(&**s))?; } + if self.recent_blockhash != Cow::Borrowed(b"") { w.write_with_tag(26, |w| w.write_bytes(&**&self.recent_blockhash))?; } + for s in &self.instructions { w.write_with_tag(34, |w| w.write_message(s))?; } + if self.versioned != false { w.write_with_tag(40, |w| w.write_bool(*&self.versioned))?; } + for s in &self.address_table_lookups { w.write_with_tag(50, |w| w.write_message(s))?; } + if let Some(ref s) = self.config { w.write_with_tag(58, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct TransactionConfig { + pub priority_fee: u64, + pub compute_unit_limit: u32, + pub loaded_accounts_data_size_limit: u32, + pub heap_size: u32, +} + +impl<'a> MessageRead<'a> for TransactionConfig { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.priority_fee = r.read_uint64(bytes)?, + Ok(16) => msg.compute_unit_limit = r.read_uint32(bytes)?, + Ok(24) => msg.loaded_accounts_data_size_limit = r.read_uint32(bytes)?, + Ok(32) => msg.heap_size = r.read_uint32(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for TransactionConfig { + fn get_size(&self) -> usize { + 0 + + if self.priority_fee == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.priority_fee) as u64) } + + if self.compute_unit_limit == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.compute_unit_limit) as u64) } + + if self.loaded_accounts_data_size_limit == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.loaded_accounts_data_size_limit) as u64) } + + if self.heap_size == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.heap_size) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.priority_fee != 0u64 { w.write_with_tag(8, |w| w.write_uint64(*&self.priority_fee))?; } + if self.compute_unit_limit != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.compute_unit_limit))?; } + if self.loaded_accounts_data_size_limit != 0u32 { w.write_with_tag(24, |w| w.write_uint32(*&self.loaded_accounts_data_size_limit))?; } + if self.heap_size != 0u32 { w.write_with_tag(32, |w| w.write_uint32(*&self.heap_size))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct MessageHeader { + pub num_required_signatures: u32, + pub num_readonly_signed_accounts: u32, + pub num_readonly_unsigned_accounts: u32, +} + +impl<'a> MessageRead<'a> for MessageHeader { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.num_required_signatures = r.read_uint32(bytes)?, + Ok(16) => msg.num_readonly_signed_accounts = r.read_uint32(bytes)?, + Ok(24) => msg.num_readonly_unsigned_accounts = r.read_uint32(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for MessageHeader { + fn get_size(&self) -> usize { + 0 + + if self.num_required_signatures == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.num_required_signatures) as u64) } + + if self.num_readonly_signed_accounts == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.num_readonly_signed_accounts) as u64) } + + if self.num_readonly_unsigned_accounts == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.num_readonly_unsigned_accounts) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.num_required_signatures != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.num_required_signatures))?; } + if self.num_readonly_signed_accounts != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.num_readonly_signed_accounts))?; } + if self.num_readonly_unsigned_accounts != 0u32 { w.write_with_tag(24, |w| w.write_uint32(*&self.num_readonly_unsigned_accounts))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct MessageAddressTableLookup<'a> { + pub account_key: Cow<'a, [u8]>, + pub writable_indexes: Cow<'a, [u8]>, + pub readonly_indexes: Cow<'a, [u8]>, +} + +impl<'a> MessageRead<'a> for MessageAddressTableLookup<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.account_key = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(18) => msg.writable_indexes = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(26) => msg.readonly_indexes = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for MessageAddressTableLookup<'a> { + fn get_size(&self) -> usize { + 0 + + if self.account_key == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.account_key).len()) } + + if self.writable_indexes == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.writable_indexes).len()) } + + if self.readonly_indexes == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.readonly_indexes).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.account_key != Cow::Borrowed(b"") { w.write_with_tag(10, |w| w.write_bytes(&**&self.account_key))?; } + if self.writable_indexes != Cow::Borrowed(b"") { w.write_with_tag(18, |w| w.write_bytes(&**&self.writable_indexes))?; } + if self.readonly_indexes != Cow::Borrowed(b"") { w.write_with_tag(26, |w| w.write_bytes(&**&self.readonly_indexes))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct TransactionStatusMeta<'a> { + pub err: Option>, + pub fee: u64, + pub pre_balances: Vec, + pub post_balances: Vec, + pub inner_instructions: Vec>, + pub inner_instructions_none: bool, + pub log_messages: Vec>, + pub log_messages_none: bool, + pub pre_token_balances: Vec>, + pub post_token_balances: Vec>, + pub rewards: Vec>, + pub loaded_writable_addresses: Vec>, + pub loaded_readonly_addresses: Vec>, + pub return_data: Option>, + pub return_data_none: bool, + pub compute_units_consumed: u64, + pub cost_units: u64, +} + +impl<'a> MessageRead<'a> for TransactionStatusMeta<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.err = Some(r.read_message::(bytes)?), + Ok(16) => msg.fee = r.read_uint64(bytes)?, + Ok(26) => msg.pre_balances = r.read_packed(bytes, |r, bytes| Ok(r.read_uint64(bytes)?))?, + Ok(34) => msg.post_balances = r.read_packed(bytes, |r, bytes| Ok(r.read_uint64(bytes)?))?, + Ok(42) => msg.inner_instructions.push(r.read_message::(bytes)?), + Ok(80) => msg.inner_instructions_none = r.read_bool(bytes)?, + Ok(50) => msg.log_messages.push(r.read_string(bytes).map(Cow::Borrowed)?), + Ok(88) => msg.log_messages_none = r.read_bool(bytes)?, + Ok(58) => msg.pre_token_balances.push(r.read_message::(bytes)?), + Ok(66) => msg.post_token_balances.push(r.read_message::(bytes)?), + Ok(74) => msg.rewards.push(r.read_message::(bytes)?), + Ok(98) => msg.loaded_writable_addresses.push(r.read_bytes(bytes).map(Cow::Borrowed)?), + Ok(106) => msg.loaded_readonly_addresses.push(r.read_bytes(bytes).map(Cow::Borrowed)?), + Ok(114) => msg.return_data = Some(r.read_message::(bytes)?), + Ok(120) => msg.return_data_none = r.read_bool(bytes)?, + Ok(128) => msg.compute_units_consumed = r.read_uint64(bytes)?, + Ok(136) => msg.cost_units = r.read_uint64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for TransactionStatusMeta<'a> { + fn get_size(&self) -> usize { + 0 + + self.err.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + if self.fee == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.fee) as u64) } + + if self.pre_balances.is_empty() { 0 } else { 1 + sizeof_len(self.pre_balances.iter().map(|s| sizeof_varint(*(s) as u64)).sum::()) } + + if self.post_balances.is_empty() { 0 } else { 1 + sizeof_len(self.post_balances.iter().map(|s| sizeof_varint(*(s) as u64)).sum::()) } + + self.inner_instructions.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + if self.inner_instructions_none == false { 0 } else { 1 + sizeof_varint(*(&self.inner_instructions_none) as u64) } + + self.log_messages.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + if self.log_messages_none == false { 0 } else { 1 + sizeof_varint(*(&self.log_messages_none) as u64) } + + self.pre_token_balances.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.post_token_balances.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.rewards.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.loaded_writable_addresses.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + self.loaded_readonly_addresses.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + self.return_data.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + if self.return_data_none == false { 0 } else { 1 + sizeof_varint(*(&self.return_data_none) as u64) } + + if self.compute_units_consumed == 0u64 { 0 } else { 2 + sizeof_varint(*(&self.compute_units_consumed) as u64) } + + if self.cost_units == 0u64 { 0 } else { 2 + sizeof_varint(*(&self.cost_units) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if let Some(ref s) = self.err { w.write_with_tag(10, |w| w.write_message(s))?; } + if self.fee != 0u64 { w.write_with_tag(16, |w| w.write_uint64(*&self.fee))?; } + w.write_packed_with_tag(26, &self.pre_balances, |w, m| w.write_uint64(*m), &|m| sizeof_varint(*(m) as u64))?; + w.write_packed_with_tag(34, &self.post_balances, |w, m| w.write_uint64(*m), &|m| sizeof_varint(*(m) as u64))?; + for s in &self.inner_instructions { w.write_with_tag(42, |w| w.write_message(s))?; } + if self.inner_instructions_none != false { w.write_with_tag(80, |w| w.write_bool(*&self.inner_instructions_none))?; } + for s in &self.log_messages { w.write_with_tag(50, |w| w.write_string(&**s))?; } + if self.log_messages_none != false { w.write_with_tag(88, |w| w.write_bool(*&self.log_messages_none))?; } + for s in &self.pre_token_balances { w.write_with_tag(58, |w| w.write_message(s))?; } + for s in &self.post_token_balances { w.write_with_tag(66, |w| w.write_message(s))?; } + for s in &self.rewards { w.write_with_tag(74, |w| w.write_message(s))?; } + for s in &self.loaded_writable_addresses { w.write_with_tag(98, |w| w.write_bytes(&**s))?; } + for s in &self.loaded_readonly_addresses { w.write_with_tag(106, |w| w.write_bytes(&**s))?; } + if let Some(ref s) = self.return_data { w.write_with_tag(114, |w| w.write_message(s))?; } + if self.return_data_none != false { w.write_with_tag(120, |w| w.write_bool(*&self.return_data_none))?; } + if self.compute_units_consumed != 0u64 { w.write_with_tag(128, |w| w.write_uint64(*&self.compute_units_consumed))?; } + if self.cost_units != 0u64 { w.write_with_tag(136, |w| w.write_uint64(*&self.cost_units))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct TransactionError<'a> { + pub err: Cow<'a, [u8]>, +} + +impl<'a> MessageRead<'a> for TransactionError<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.err = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for TransactionError<'a> { + fn get_size(&self) -> usize { + 0 + + if self.err == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.err).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.err != Cow::Borrowed(b"") { w.write_with_tag(10, |w| w.write_bytes(&**&self.err))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct InnerInstructions<'a> { + pub index: u32, + pub instructions: Vec>, +} + +impl<'a> MessageRead<'a> for InnerInstructions<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.index = r.read_uint32(bytes)?, + Ok(18) => msg.instructions.push(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for InnerInstructions<'a> { + fn get_size(&self) -> usize { + 0 + + if self.index == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.index) as u64) } + + self.instructions.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.index != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.index))?; } + for s in &self.instructions { w.write_with_tag(18, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct InnerInstruction<'a> { + pub program_id_index: u32, + pub accounts: Cow<'a, [u8]>, + pub data: Cow<'a, [u8]>, + pub stack_height: u32, +} + +impl<'a> MessageRead<'a> for InnerInstruction<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.program_id_index = r.read_uint32(bytes)?, + Ok(18) => msg.accounts = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(26) => msg.data = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(32) => msg.stack_height = r.read_uint32(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for InnerInstruction<'a> { + fn get_size(&self) -> usize { + 0 + + if self.program_id_index == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.program_id_index) as u64) } + + if self.accounts == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.accounts).len()) } + + if self.data == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.data).len()) } + + if self.stack_height == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.stack_height) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.program_id_index != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.program_id_index))?; } + if self.accounts != Cow::Borrowed(b"") { w.write_with_tag(18, |w| w.write_bytes(&**&self.accounts))?; } + if self.data != Cow::Borrowed(b"") { w.write_with_tag(26, |w| w.write_bytes(&**&self.data))?; } + if self.stack_height != 0u32 { w.write_with_tag(32, |w| w.write_uint32(*&self.stack_height))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct CompiledInstruction<'a> { + pub program_id_index: u32, + pub accounts: Cow<'a, [u8]>, + pub data: Cow<'a, [u8]>, +} + +impl<'a> MessageRead<'a> for CompiledInstruction<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.program_id_index = r.read_uint32(bytes)?, + Ok(18) => msg.accounts = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(26) => msg.data = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for CompiledInstruction<'a> { + fn get_size(&self) -> usize { + 0 + + if self.program_id_index == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.program_id_index) as u64) } + + if self.accounts == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.accounts).len()) } + + if self.data == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.data).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.program_id_index != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.program_id_index))?; } + if self.accounts != Cow::Borrowed(b"") { w.write_with_tag(18, |w| w.write_bytes(&**&self.accounts))?; } + if self.data != Cow::Borrowed(b"") { w.write_with_tag(26, |w| w.write_bytes(&**&self.data))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct TokenBalance<'a> { + pub account_index: u32, + pub mint: Cow<'a, str>, + pub ui_token_amount: Option>, + pub owner: Cow<'a, str>, + pub program_id: Cow<'a, str>, +} + +impl<'a> MessageRead<'a> for TokenBalance<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.account_index = r.read_uint32(bytes)?, + Ok(18) => msg.mint = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(26) => msg.ui_token_amount = Some(r.read_message::(bytes)?), + Ok(34) => msg.owner = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(42) => msg.program_id = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for TokenBalance<'a> { + fn get_size(&self) -> usize { + 0 + + if self.account_index == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.account_index) as u64) } + + if self.mint == "" { 0 } else { 1 + sizeof_len((&self.mint).len()) } + + self.ui_token_amount.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + + if self.owner == "" { 0 } else { 1 + sizeof_len((&self.owner).len()) } + + if self.program_id == "" { 0 } else { 1 + sizeof_len((&self.program_id).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.account_index != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.account_index))?; } + if self.mint != "" { w.write_with_tag(18, |w| w.write_string(&**&self.mint))?; } + if let Some(ref s) = self.ui_token_amount { w.write_with_tag(26, |w| w.write_message(s))?; } + if self.owner != "" { w.write_with_tag(34, |w| w.write_string(&**&self.owner))?; } + if self.program_id != "" { w.write_with_tag(42, |w| w.write_string(&**&self.program_id))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct UiTokenAmount<'a> { + pub ui_amount: f64, + pub decimals: u32, + pub amount: Cow<'a, str>, + pub ui_amount_string: Cow<'a, str>, +} + +impl<'a> MessageRead<'a> for UiTokenAmount<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(9) => msg.ui_amount = r.read_double(bytes)?, + Ok(16) => msg.decimals = r.read_uint32(bytes)?, + Ok(26) => msg.amount = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(34) => msg.ui_amount_string = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for UiTokenAmount<'a> { + fn get_size(&self) -> usize { + 0 + + if self.ui_amount == 0f64 { 0 } else { 1 + 8 } + + if self.decimals == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.decimals) as u64) } + + if self.amount == "" { 0 } else { 1 + sizeof_len((&self.amount).len()) } + + if self.ui_amount_string == "" { 0 } else { 1 + sizeof_len((&self.ui_amount_string).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.ui_amount != 0f64 { w.write_with_tag(9, |w| w.write_double(*&self.ui_amount))?; } + if self.decimals != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.decimals))?; } + if self.amount != "" { w.write_with_tag(26, |w| w.write_string(&**&self.amount))?; } + if self.ui_amount_string != "" { w.write_with_tag(34, |w| w.write_string(&**&self.ui_amount_string))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct ReturnData<'a> { + pub program_id: Cow<'a, [u8]>, + pub data: Cow<'a, [u8]>, +} + +impl<'a> MessageRead<'a> for ReturnData<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.program_id = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(18) => msg.data = r.read_bytes(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for ReturnData<'a> { + fn get_size(&self) -> usize { + 0 + + if self.program_id == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.program_id).len()) } + + if self.data == Cow::Borrowed(b"") { 0 } else { 1 + sizeof_len((&self.data).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.program_id != Cow::Borrowed(b"") { w.write_with_tag(10, |w| w.write_bytes(&**&self.program_id))?; } + if self.data != Cow::Borrowed(b"") { w.write_with_tag(18, |w| w.write_bytes(&**&self.data))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct Reward<'a> { + pub pubkey: Cow<'a, str>, + pub lamports: i64, + pub post_balance: u64, + pub reward_type: solana::storage::ConfirmedBlock::RewardType, + pub commission: Cow<'a, str>, +} + +impl<'a> MessageRead<'a> for Reward<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.pubkey = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(16) => msg.lamports = r.read_int64(bytes)?, + Ok(24) => msg.post_balance = r.read_uint64(bytes)?, + Ok(32) => msg.reward_type = r.read_enum(bytes)?, + Ok(42) => msg.commission = r.read_string(bytes).map(Cow::Borrowed)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for Reward<'a> { + fn get_size(&self) -> usize { + 0 + + if self.pubkey == "" { 0 } else { 1 + sizeof_len((&self.pubkey).len()) } + + if self.lamports == 0i64 { 0 } else { 1 + sizeof_varint(*(&self.lamports) as u64) } + + if self.post_balance == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.post_balance) as u64) } + + if self.reward_type == solana::storage::ConfirmedBlock::RewardType::Unspecified { 0 } else { 1 + sizeof_varint(*(&self.reward_type) as u64) } + + if self.commission == "" { 0 } else { 1 + sizeof_len((&self.commission).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.pubkey != "" { w.write_with_tag(10, |w| w.write_string(&**&self.pubkey))?; } + if self.lamports != 0i64 { w.write_with_tag(16, |w| w.write_int64(*&self.lamports))?; } + if self.post_balance != 0u64 { w.write_with_tag(24, |w| w.write_uint64(*&self.post_balance))?; } + if self.reward_type != solana::storage::ConfirmedBlock::RewardType::Unspecified { w.write_with_tag(32, |w| w.write_enum(*&self.reward_type as i32))?; } + if self.commission != "" { w.write_with_tag(42, |w| w.write_string(&**&self.commission))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct Rewards<'a> { + pub rewards: Vec>, + pub num_partitions: Option, +} + +impl<'a> MessageRead<'a> for Rewards<'a> { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.rewards.push(r.read_message::(bytes)?), + Ok(18) => msg.num_partitions = Some(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl<'a> MessageWrite for Rewards<'a> { + fn get_size(&self) -> usize { + 0 + + self.rewards.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::() + + self.num_partitions.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size())) + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + for s in &self.rewards { w.write_with_tag(10, |w| w.write_message(s))?; } + if let Some(ref s) = self.num_partitions { w.write_with_tag(18, |w| w.write_message(s))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct UnixTimestamp { + pub timestamp: i64, +} + +impl<'a> MessageRead<'a> for UnixTimestamp { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.timestamp = r.read_int64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for UnixTimestamp { + fn get_size(&self) -> usize { + 0 + + if self.timestamp == 0i64 { 0 } else { 1 + sizeof_varint(*(&self.timestamp) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.timestamp != 0i64 { w.write_with_tag(8, |w| w.write_int64(*&self.timestamp))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct BlockHeight { + pub block_height: u64, +} + +impl<'a> MessageRead<'a> for BlockHeight { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.block_height = r.read_uint64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for BlockHeight { + fn get_size(&self) -> usize { + 0 + + if self.block_height == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.block_height) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.block_height != 0u64 { w.write_with_tag(8, |w| w.write_uint64(*&self.block_height))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct NumPartitions { + pub num_partitions: u64, +} + +impl<'a> MessageRead<'a> for NumPartitions { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.num_partitions = r.read_uint64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for NumPartitions { + fn get_size(&self) -> usize { + 0 + + if self.num_partitions == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.num_partitions) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.num_partitions != 0u64 { w.write_with_tag(8, |w| w.write_uint64(*&self.num_partitions))?; } + Ok(()) + } +} + diff --git a/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/mod.rs b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/mod.rs new file mode 100644 index 00000000..460bb736 --- /dev/null +++ b/crates/blockzilla-solana-wire/src/generated/quick_protobuf/solana/storage/mod.rs @@ -0,0 +1,2 @@ +// Automatically generated mod.rs +pub mod ConfirmedBlock; diff --git a/crates/blockzilla-solana-wire/src/generated/solana.storage.confirmed_block.rs b/crates/blockzilla-solana-wire/src/generated/solana.storage.confirmed_block.rs new file mode 100644 index 00000000..bff56653 --- /dev/null +++ b/crates/blockzilla-solana-wire/src/generated/solana.storage.confirmed_block.rs @@ -0,0 +1,253 @@ +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfirmedBlock { + #[prost(string, tag = "1")] + pub previous_blockhash: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub blockhash: ::prost::alloc::string::String, + #[prost(uint64, tag = "3")] + pub parent_slot: u64, + #[prost(message, repeated, tag = "4")] + pub transactions: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "5")] + pub rewards: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "6")] + pub block_time: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub block_height: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub num_partitions: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConfirmedTransaction { + #[prost(message, optional, tag = "1")] + pub transaction: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub meta: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Transaction { + #[prost(bytes = "vec", repeated, tag = "1")] + pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(message, optional, tag = "2")] + pub message: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(message, optional, tag = "1")] + pub header: ::core::option::Option, + #[prost(bytes = "vec", repeated, tag = "2")] + pub account_keys: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "3")] + pub recent_blockhash: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "4")] + pub instructions: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "5")] + pub versioned: bool, + #[prost(message, repeated, tag = "6")] + pub address_table_lookups: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "7")] + pub config: ::core::option::Option, +} +/// Transaction v1 (SIMD-0385) carries its compute budget in the message header +/// rather than as ComputeBudget instructions. Field numbers match +/// solana-rpc/superbank#75 so this stays wire-compatible with the ecosystem. +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct TransactionConfig { + #[prost(uint64, optional, tag = "1")] + pub priority_fee: ::core::option::Option, + #[prost(uint32, optional, tag = "2")] + pub compute_unit_limit: ::core::option::Option, + #[prost(uint32, optional, tag = "3")] + pub loaded_accounts_data_size_limit: ::core::option::Option, + #[prost(uint32, optional, tag = "4")] + pub heap_size: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct MessageHeader { + #[prost(uint32, tag = "1")] + pub num_required_signatures: u32, + #[prost(uint32, tag = "2")] + pub num_readonly_signed_accounts: u32, + #[prost(uint32, tag = "3")] + pub num_readonly_unsigned_accounts: u32, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct MessageAddressTableLookup { + #[prost(bytes = "vec", tag = "1")] + pub account_key: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + pub writable_indexes: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub readonly_indexes: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionStatusMeta { + #[prost(message, optional, tag = "1")] + pub err: ::core::option::Option, + #[prost(uint64, tag = "2")] + pub fee: u64, + #[prost(uint64, repeated, tag = "3")] + pub pre_balances: ::prost::alloc::vec::Vec, + #[prost(uint64, repeated, tag = "4")] + pub post_balances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "5")] + pub inner_instructions: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "10")] + pub inner_instructions_none: bool, + #[prost(string, repeated, tag = "6")] + pub log_messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(bool, tag = "11")] + pub log_messages_none: bool, + #[prost(message, repeated, tag = "7")] + pub pre_token_balances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "8")] + pub post_token_balances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "9")] + pub rewards: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", repeated, tag = "12")] + pub loaded_writable_addresses: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", repeated, tag = "13")] + pub loaded_readonly_addresses: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(message, optional, tag = "14")] + pub return_data: ::core::option::Option, + #[prost(bool, tag = "15")] + pub return_data_none: bool, + #[prost(uint64, optional, tag = "16")] + pub compute_units_consumed: ::core::option::Option, + #[prost(uint64, optional, tag = "17")] + pub cost_units: ::core::option::Option, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct TransactionError { + #[prost(bytes = "vec", tag = "1")] + pub err: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InnerInstructions { + #[prost(uint32, tag = "1")] + pub index: u32, + #[prost(message, repeated, tag = "2")] + pub instructions: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct InnerInstruction { + #[prost(uint32, tag = "1")] + pub program_id_index: u32, + #[prost(bytes = "vec", tag = "2")] + pub accounts: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub data: ::prost::alloc::vec::Vec, + #[prost(uint32, optional, tag = "4")] + pub stack_height: ::core::option::Option, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CompiledInstruction { + #[prost(uint32, tag = "1")] + pub program_id_index: u32, + #[prost(bytes = "vec", tag = "2")] + pub accounts: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub data: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TokenBalance { + #[prost(uint32, tag = "1")] + pub account_index: u32, + #[prost(string, tag = "2")] + pub mint: ::prost::alloc::string::String, + #[prost(message, optional, tag = "3")] + pub ui_token_amount: ::core::option::Option, + #[prost(string, tag = "4")] + pub owner: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub program_id: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UiTokenAmount { + #[prost(double, tag = "1")] + pub ui_amount: f64, + #[prost(uint32, tag = "2")] + pub decimals: u32, + #[prost(string, tag = "3")] + pub amount: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub ui_amount_string: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ReturnData { + #[prost(bytes = "vec", tag = "1")] + pub program_id: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + pub data: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct Reward { + #[prost(string, tag = "1")] + pub pubkey: ::prost::alloc::string::String, + #[prost(int64, tag = "2")] + pub lamports: i64, + #[prost(uint64, tag = "3")] + pub post_balance: u64, + #[prost(enumeration = "RewardType", tag = "4")] + pub reward_type: i32, + #[prost(string, tag = "5")] + pub commission: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Rewards { + #[prost(message, repeated, tag = "1")] + pub rewards: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub num_partitions: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct UnixTimestamp { + #[prost(int64, tag = "1")] + pub timestamp: i64, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct BlockHeight { + #[prost(uint64, tag = "1")] + pub block_height: u64, +} +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct NumPartitions { + #[prost(uint64, tag = "1")] + pub num_partitions: u64, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum RewardType { + Unspecified = 0, + Fee = 1, + Rent = 2, + Staking = 3, + Voting = 4, +} +impl RewardType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "Unspecified", + Self::Fee => "Fee", + Self::Rent => "Rent", + Self::Staking => "Staking", + Self::Voting => "Voting", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Unspecified" => Some(Self::Unspecified), + "Fee" => Some(Self::Fee), + "Rent" => Some(Self::Rent), + "Staking" => Some(Self::Staking), + "Voting" => Some(Self::Voting), + _ => None, + } + } +} diff --git a/crates/blockzilla-solana-wire/src/lib.rs b/crates/blockzilla-solana-wire/src/lib.rs index 973f5677..ee7f8b52 100644 --- a/crates/blockzilla-solana-wire/src/lib.rs +++ b/crates/blockzilla-solana-wire/src/lib.rs @@ -5,22 +5,20 @@ //! by the separate source adapter. pub mod blockmarker; +#[cfg(feature = "protobuf")] mod convert_metadata; +#[cfg(feature = "protobuf")] pub mod metadata_decoder; pub mod short_vec; pub mod slot_meta; pub mod stored_transaction; pub mod versioned_transaction; -pub mod confirmed_block { - include!(concat!( - env!("OUT_DIR"), - "/solana.storage.confirmed_block.rs" - )); -} +#[cfg(feature = "protobuf")] +#[path = "generated/solana.storage.confirmed_block.rs"] +pub mod confirmed_block; +#[cfg(feature = "protobuf")] #[doc(hidden)] -pub mod confirmed_block_borrowed { - #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] - include!(concat!(env!("OUT_DIR"), "/quick-protobuf/mod.rs")); -} +#[path = "generated/quick_protobuf/mod.rs"] +pub mod confirmed_block_borrowed; diff --git a/crates/blockzilla-solana-wire/src/stored_transaction/status_meta.rs b/crates/blockzilla-solana-wire/src/stored_transaction/status_meta.rs index f040588e..5f79daf3 100644 --- a/crates/blockzilla-solana-wire/src/stored_transaction/status_meta.rs +++ b/crates/blockzilla-solana-wire/src/stored_transaction/status_meta.rs @@ -7,6 +7,7 @@ use wincode::io::Reader; use wincode::{SchemaRead, containers, len::BincodeLen}; use crate::stored_transaction::StoredTransactionError; +#[cfg(feature = "protobuf")] use crate::{confirmed_block, convert_metadata}; #[derive(SchemaRead, Clone)] @@ -117,6 +118,7 @@ pub struct StoredTransactionStatusMeta { pub cost_units: OptionEof, } +#[cfg(feature = "protobuf")] impl From for confirmed_block::TransactionStatusMeta { fn from(m: StoredTransactionStatusMeta) -> Self { convert_metadata::stored_meta_to_proto(m) @@ -145,6 +147,7 @@ pub struct StoredTransactionStatusMetaLegacyLogs { pub cost_units: OptionEof, } +#[cfg(feature = "protobuf")] impl From for confirmed_block::TransactionStatusMeta { fn from(m: StoredTransactionStatusMetaLegacyLogs) -> Self { let v1 = StoredTransactionStatusMeta { diff --git a/crates/blockzilla-solana-wire/src/stored_transaction/status_meta_v2.rs b/crates/blockzilla-solana-wire/src/stored_transaction/status_meta_v2.rs index c15a754e..bfad55b5 100644 --- a/crates/blockzilla-solana-wire/src/stored_transaction/status_meta_v2.rs +++ b/crates/blockzilla-solana-wire/src/stored_transaction/status_meta_v2.rs @@ -1,5 +1,6 @@ use wincode::{SchemaRead, containers, len::BincodeLen}; +#[cfg(feature = "protobuf")] use crate::{confirmed_block, convert_metadata, stored_transaction::StoredTransactionStatusMeta}; use super::{ @@ -28,6 +29,7 @@ pub struct StoredTransactionStatusMetaV2 { pub cost_units: OptionEof, } +#[cfg(feature = "protobuf")] impl From for confirmed_block::TransactionStatusMeta { fn from(m: StoredTransactionStatusMetaV2) -> Self { let v1 = StoredTransactionStatusMeta { diff --git a/crates/compact-v2/blockzilla-archive-v2/Cargo.toml b/crates/compact-v2/blockzilla-archive-v2/Cargo.toml index f362e45d..2097b0c9 100644 --- a/crates/compact-v2/blockzilla-archive-v2/Cargo.toml +++ b/crates/compact-v2/blockzilla-archive-v2/Cargo.toml @@ -20,14 +20,14 @@ known-program-logs = [ known-drift = ["blockzilla-program-logs/known-drift"] [dependencies] -blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.2.0" } -blockzilla-compact = { path = "../blockzilla-compact", default-features = false, version = "0.2.0" } -blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, version = "0.2.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.3.0" } +blockzilla-compact = { path = "../blockzilla-compact", default-features = false, version = "0.3.0" } +blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, version = "0.3.0" } anyhow = "1.0.104" serde = { version = "1.0.229", features = ["derive"] } -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } wincode = { version = "=0.6.1", features = ["derive"] } -blockzilla-solana-wire = { path = "../../blockzilla-solana-wire", version = "0.2.0", default-features = false } +blockzilla-solana-wire = { path = "../../blockzilla-solana-wire", version = "0.3.0", default-features = false } [lints] workspace = true diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/Cargo.toml b/crates/compact-v2/blockzilla-compact-v2-reader/Cargo.toml index d6fe4c63..24242bf1 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/Cargo.toml +++ b/crates/compact-v2/blockzilla-compact-v2-reader/Cargo.toml @@ -18,30 +18,30 @@ http = ["dep:blockzilla-source-http", "dep:blockzilla-source-cache", "dep:url"] [dependencies] # The reader must decode known-program log variants, including in isolated builds. -blockzilla-archive-v2 = { path = "../blockzilla-archive-v2", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-compact = { path = "../blockzilla-compact", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-primitives = { path = "../../blockzilla-primitives", default-features = false, version = "0.2.0" } -blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-registry = { path = "../blockzilla-registry", default-features = false, version = "0.2.0" } +blockzilla-archive-v2 = { path = "../blockzilla-archive-v2", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-compact = { path = "../blockzilla-compact", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", default-features = false, version = "0.3.0" } +blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-registry = { path = "../blockzilla-registry", default-features = false, version = "0.3.0" } url = { version = "2.5.8", optional = true } -blockzilla-source = { version = "0.2.0", path = "../../source/blockzilla-source" } -blockzilla-source-local = { version = "0.2.0", path = "../../source/blockzilla-source-local" } -blockzilla-source-http = { version = "0.2.0", path = "../../source/blockzilla-source-http", optional = true } -blockzilla-source-cache = { version = "0.2.0", path = "../../source/blockzilla-source-cache", optional = true } +blockzilla-source = { version = "0.3.0", path = "../../source/blockzilla-source" } +blockzilla-source-local = { version = "0.3.0", path = "../../source/blockzilla-source-local" } +blockzilla-source-http = { version = "0.3.0", path = "../../source/blockzilla-source-http", optional = true } +blockzilla-source-cache = { version = "0.3.0", path = "../../source/blockzilla-source-cache", optional = true } anyhow = "1.0.104" -blockzilla-model = { version = "0.2.0", path = "../../blockzilla-model" } +blockzilla-model = { version = "0.3.0", path = "../../blockzilla-model" } +ed25519-dalek = { version = "3.0.0", default-features = false, features = ["fast"] } rayon = "1.12.0" serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } smallvec = "1.16.0" -solana-signature = { version = "3.4.1", features = ["verify"] } thiserror = "2.0.20" wincode = { version = "=0.6.1", features = ["derive", "smallvec"] } -zstd = "0.14.0" +zstd = { version = "0.14.0", default-features = false } [dev-dependencies] -ed25519-dalek = "3.0.0" +five8 = "1.0.0" tempfile = "3.27.0" [[test]] @@ -61,5 +61,9 @@ required-features = ["http"] name = "read_epoch" required-features = ["http"] +[[example]] +name = "epoch_firehose" +required-features = ["http"] + [lints] workspace = true diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/README.md b/crates/compact-v2/blockzilla-compact-v2-reader/README.md index c691ded2..c6f0590e 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/README.md +++ b/crates/compact-v2/blockzilla-compact-v2-reader/README.md @@ -43,3 +43,25 @@ The reader must never be the slowest stage of an indexer. To get this: For example, the token dump example reads 1,000 epoch-200 blocks (676,169 transactions, 222,326 rows) from a local copy in 0.15 s with 8 workers. The first version, with a sequential scan and one write per row, took 1.6-2.1 s. + +## Zero-cache HTTPS firehose + +With the `http` feature enabled, `firehose::stream_epoch_firehose` streams a +Compact V2 epoch directly over HTTPS with zero local disk cache. It downloads +and validates `archive-v2-blocks.index` in memory using the reader's index +validator, opens long-lived ETag-pinned `HttpRangeStream` segments over +`archive-v2-blocks.zstd` with straggler work-stealing and tail hedging, runs +your per-block projector across worker threads (`FirehoseBorrowedBlock` -> +`FirehoseProjectedBlock`), and delivers results in strict global ascending +slot order. + +`firehose::run_epoch_firehose` wraps `stream_epoch_firehose` with +`project_block_summary` for verified per-block counts. `FirehoseConfig` +supports custom epoch URLs, `first_block` and `max_blocks` bounds, and optional +`HttpRequestSigner` credentials (such as `S3SigV4Signer`) for private buckets. +See `examples/epoch_firehose.rs` for a minimal custom projector: + +```sh +RUSTFLAGS="-C target-cpu=native" cargo run --release -p blockzilla-compact-v2-reader \ + --features http --example epoch_firehose -- 800 50 +``` diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/examples/epoch_firehose.rs b/crates/compact-v2/blockzilla-compact-v2-reader/examples/epoch_firehose.rs new file mode 100644 index 00000000..ba8b3f85 --- /dev/null +++ b/crates/compact-v2/blockzilla-compact-v2-reader/examples/epoch_firehose.rs @@ -0,0 +1,84 @@ +//! Minimal SDK example showing a custom parallel block projection over the +//! ordered HTTPS Compact V2 firehose. +//! +//! Run from the workspace root: +//! RUSTFLAGS="-C target-cpu=native" cargo run --release -p blockzilla-compact-v2-reader \ +//! --features http --example epoch_firehose -- 800 50 + +use std::{error::Error, time::Duration}; + +use blockzilla_compact_v2_reader::firehose::{ + FirehoseConfig, FirehoseDecodeLevel, FirehoseProjectedBlock, project_block_summary, + stream_epoch_firehose, +}; + +fn main() -> Result<(), Box> { + let mut args = std::env::args().skip(1); + let epoch: u64 = args.next().as_deref().unwrap_or("800").parse()?; + let max_blocks: Option = args.next().map(|v| v.parse()).transpose()?; + + let mut config = FirehoseConfig::foundation_epoch(epoch); + config.max_blocks = max_blocks; + config.progress_interval = Duration::from_secs(2); + + let mut max_txs_in_block = (0u64, 0u64); + let report = stream_epoch_firehose( + &config, + |idx| { + eprintln!( + "Index ready: {} blocks, {} txs ({:.0} ms)", + idx.blocks, + idx.transactions, + idx.elapsed.as_secs_f64() * 1_000.0 + ); + }, + |p| { + if !p.is_final { + let secs = p.elapsed.as_secs_f64().max(0.001); + eprintln!( + "[{secs:5.1}s] ordered={}/{} ({:.2}M tx/s, {:.2} Gbps)", + p.ordered_blocks, + p.total_blocks, + p.ordered_transactions as f64 / secs / 1e6, + p.wire_bytes as f64 * 8.0 / 1e9 / secs, + ); + } + }, + // Runs in parallel across decode workers on each borrowed Compact V2 block. + |borrowed| { + let summary = project_block_summary(borrowed, FirehoseDecodeLevel::Full)?; + Ok(FirehoseProjectedBlock { + block_ordinal: summary.block_ordinal, + slot: summary.slot, + transactions: summary.transactions, + instructions: summary.instructions, + inner_instructions: summary.inner_instructions, + decoded_bytes: summary.decoded_bytes, + checksum: summary.checksum, + value: borrowed.block.header.parent_slot, + }) + }, + // Runs in strict global ascending slot order on the consumer thread. + |projected| { + if projected.transactions > max_txs_in_block.1 { + max_txs_in_block = (projected.slot, projected.transactions); + } + let _parent_slot: u64 = projected.value; + Ok(()) + }, + )?; + + let secs = report.total_elapsed.as_secs_f64().max(0.001); + println!( + "epoch={} blocks={} txs={} ix={} cold_tps={:.0} wire_gbps={:.2} busiest_slot={} ({} txs)", + report.epoch, + report.blocks, + report.transactions, + report.instructions, + report.transactions as f64 / secs, + report.wire_bytes as f64 * 8.0 / 1e9 / secs, + max_txs_in_block.0, + max_txs_in_block.1, + ); + Ok(()) +} diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/examples/read_epoch.rs b/crates/compact-v2/blockzilla-compact-v2-reader/examples/read_epoch.rs index 1a64e012..381d0211 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/examples/read_epoch.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/examples/read_epoch.rs @@ -11,7 +11,12 @@ use std::{error::Error, num::NonZeroU32}; use blockzilla_compact_v2_reader::archive::{ ArchiveInstructionSourceExt, CompactV2Archive, ExecutionStatus, ScanRequest, }; -use solana_signature::Signature; + +fn encode_signature(bytes: &[u8; 64]) -> String { + let mut buf = [0u8; five8::BASE58_ENCODED_64_MAX_LEN]; + let len = five8::encode_64(bytes, &mut buf) as usize; + String::from_utf8(buf[..len].to_vec()).expect("five8 alphabet is ASCII") +} const ARCHIVE_BASE: &str = "https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004"; @@ -39,7 +44,7 @@ fn main() -> Result<(), Box> { }; let signature = tx .primary_signature - .map(|bytes| Signature::from(*bytes).to_string()) + .map(encode_signature) .unwrap_or_default(); println!( "slot={} tx={} {status} instructions={} {signature}", diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/archive.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/archive.rs index a0f4cd29..38e98d18 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/src/archive.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/archive.rs @@ -309,6 +309,31 @@ impl RangeSource for CompactV2HttpObjectSet { self.cache .read_range_into_slice(object, offset, destination) } + + fn read_range_into_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + cancelled: &std::sync::atomic::AtomicBool, + ) -> std::result::Result<(), SourceError> { + self.require_object(object)?; + self.cache + .read_range_into_cancellable(object, offset, length, destination, cancelled) + } + + fn read_range_into_slice_cancellable( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + cancelled: &std::sync::atomic::AtomicBool, + ) -> std::result::Result<(), SourceError> { + self.require_object(object)?; + self.cache + .read_range_into_slice_cancellable(object, offset, destination, cancelled) + } } impl CompactV2HttpObjectSet { @@ -581,11 +606,14 @@ impl CompactV2Archive { // source's own request concurrency. Each range is written and checked // as before, so the cache files are identical. let download_concurrency = http.recommended_read_concurrency(); - let cache = CachedHttpRangeSource::with_parallel_options( + let cache = CachedHttpRangeSource::with_pinned_identities_and_parallel_options( http, &generation_cache, &cached_objects, - HttpRangeCacheOptions::default(), + HttpRangeCacheOptions { + download_range_bytes: 16 << 20, + ..HttpRangeCacheOptions::default() + }, download_concurrency, ) .map_err(Error::RangeSource)?; diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/compact_query.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/compact_query.rs index ae7058d9..207bd2fd 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/src/compact_query.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/compact_query.rs @@ -227,6 +227,14 @@ impl CompactV2ParallelScanConfig { self.full_registry_min_transactions = transactions; self } + + pub const fn with_network_input( + mut self, + network_input: Option, + ) -> Self { + self.network_input = network_input; + self + } } impl Default for CompactV2ParallelScanConfig { diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/firehose.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/firehose.rs new file mode 100644 index 00000000..109928b4 --- /dev/null +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/firehose.rs @@ -0,0 +1,1544 @@ +//! Cold-start ordered Compact V2 epoch firehose over HTTPS. +//! +//! Downloads and validates `archive-v2-blocks.index` directly into memory using +//! the reader's canonical index validator, partitions `archive-v2-blocks.zstd` +//! across long-lived ETag-pinned HTTP `206` range streams ([`HttpRangeStream`]), +//! yields frame-aligned sub-batches incrementally with continuous straggler +//! work-stealing and exact-offset tail hedging, runs a caller-supplied +//! per-block projection across worker threads, and delivers projected blocks in +//! strict global ascending slot order. + +use std::{ + fmt, + sync::{ + Arc, Condvar, Mutex, + atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, + mpsc::{Receiver, SyncSender, sync_channel}, + }, + thread, + time::{Duration, Instant}, +}; + +use blockzilla_archive_v2::{ + ArchiveV2HotBlockIndexRow, BorrowedArchiveV2HotBlockBlobWithoutRewards, + deserialize_archive_v2_hot_block_blob_borrowed_current_without_rewards, +}; +use blockzilla_model::BlockCounts; + +use crate::{ + CompactV2MessageSchema, CompactV2MetadataSchema, HttpObjectPathLayout, HttpRangeSource, + HttpRangeSourceOptions, HttpRequestSigner, OpenOptions, RangeSource, SourceError, + count_projection::{CountMetadata, count_transaction}, + manifest::{BLOCK_INDEX_FILE, BLOCKS_FILE, REGISTRY_FILE}, + reader::parse_and_validate_index, +}; + +/// Public Solana Foundation Compact V2 archive object base URL. +/// +/// Append `/epoch-` for flat epoch object directories. +pub const DEFAULT_FOUNDATION_ARCHIVE_BASE: &str = + "https://pub-97348740d6ef467aa2f1b4b62daa98dc.r2.dev/compact-v2/blockzilla-20261004"; + +const MAINNET_SLOTS_PER_EPOCH: u64 = 432_000; + +/// How deeply each block is decoded by [`run_epoch_firehose`]. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum FirehoseDecodeLevel { + /// Decompress zstd, parse the wincode block blob, and decode every + /// transaction's Legacy/V0 message, typed metadata, top-level instructions, + /// and inner CPI instructions. + Full, + /// Decompress zstd, parse the wincode block blob, and iterate every + /// transaction row without decoding inner message/metadata lanes. + Block, +} + +/// Configuration for [`stream_epoch_firehose`] and [`run_epoch_firehose`]. +#[derive(Clone)] +pub struct FirehoseConfig { + pub epoch: u64, + pub epoch_url: String, + pub object_path_layout: HttpObjectPathLayout, + pub allow_insecure_http: bool, + /// Optional request signer (for example [`crate::S3SigV4Signer`]) for + /// private S3-compatible buckets. Redacted in `Debug`. + pub signer: Option>, + pub net_workers: usize, + pub decode_workers: usize, + pub segment_bytes: usize, + pub sub_batch_bytes: usize, + pub decode_level: FirehoseDecodeLevel, + /// Zero-based first block row to stream. + pub first_block: u32, + pub max_blocks: Option, + pub progress_interval: Duration, +} + +impl fmt::Debug for FirehoseConfig { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter + .debug_struct("FirehoseConfig") + .field("epoch", &self.epoch) + .field("epoch_url", &self.epoch_url) + .field("object_path_layout", &self.object_path_layout) + .field("allow_insecure_http", &self.allow_insecure_http) + .field("signer", &self.signer.as_ref().map(|_| "")) + .field("net_workers", &self.net_workers) + .field("decode_workers", &self.decode_workers) + .field("segment_bytes", &self.segment_bytes) + .field("sub_batch_bytes", &self.sub_batch_bytes) + .field("decode_level", &self.decode_level) + .field("first_block", &self.first_block) + .field("max_blocks", &self.max_blocks) + .field("progress_interval", &self.progress_interval) + .finish() + } +} + +impl FirehoseConfig { + /// Build a high-throughput default configuration targeting the public + /// Foundation Compact V2 archive for `epoch`. + pub fn foundation_epoch(epoch: u64) -> Self { + let cpus = thread::available_parallelism() + .map(usize::from) + .unwrap_or(16); + Self { + epoch, + epoch_url: format!("{DEFAULT_FOUNDATION_ARCHIVE_BASE}/epoch-{epoch}"), + object_path_layout: HttpObjectPathLayout::FlatObjects, + allow_insecure_http: false, + signer: None, + net_workers: (cpus * 2).clamp(32, 320), + decode_workers: (cpus * 3 / 4).clamp(4, 96), + segment_bytes: 280 * 1024 * 1024, + sub_batch_bytes: 8 * 1024 * 1024, + decode_level: FirehoseDecodeLevel::Full, + first_block: 0, + max_blocks: None, + progress_interval: Duration::from_millis(100), + } + } + + /// Validate bounds before opening remote connections. + pub fn validate(&self) -> Result<(), SourceError> { + if self.epoch_url.trim().is_empty() { + return Err(SourceError::Protocol( + "firehose epoch URL must not be empty".into(), + )); + } + if self.net_workers == 0 || self.net_workers > 512 { + return Err(SourceError::Protocol(format!( + "firehose net_workers {} must be in 1..=512", + self.net_workers + ))); + } + if self.decode_workers == 0 || self.decode_workers > 256 { + return Err(SourceError::Protocol(format!( + "firehose decode_workers {} must be in 1..=256", + self.decode_workers + ))); + } + if self.sub_batch_bytes < 64 * 1024 || self.sub_batch_bytes > 64 * 1024 * 1024 { + return Err(SourceError::Protocol(format!( + "firehose sub_batch_bytes {} must be in 64 KiB..=64 MiB", + self.sub_batch_bytes + ))); + } + if self.segment_bytes < self.sub_batch_bytes || self.segment_bytes > 1024 * 1024 * 1024 { + return Err(SourceError::Protocol(format!( + "firehose segment_bytes {} must be >= sub_batch_bytes and <= 1 GiB", + self.segment_bytes + ))); + } + if let Some(0) = self.max_blocks { + return Err(SourceError::Protocol( + "firehose max_blocks must be greater than zero".into(), + )); + } + Ok(()) + } +} + +/// Verified metadata emitted once the remote block index finishes loading. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct FirehoseIndexInfo { + pub blocks: u64, + pub transactions: u64, + pub compressed_bytes: u64, + pub elapsed: Duration, +} + +/// Borrowed Compact V2 block passed to a parallel projector in [`stream_epoch_firehose`]. +/// +/// The underlying decompression buffer is reused by the decode worker once the +/// projector returns; extract any owned data into `T` inside [`FirehoseProjectedBlock`]. +pub struct FirehoseBorrowedBlock<'a> { + pub block_ordinal: u32, + pub row: &'a ArchiveV2HotBlockIndexRow, + pub block: BorrowedArchiveV2HotBlockBlobWithoutRewards<'a>, + pub registry_entries: u32, +} + +/// Verified per-block projection delivered in strict global ascending slot order. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct FirehoseProjectedBlock { + pub block_ordinal: u32, + pub slot: u64, + pub transactions: u64, + pub instructions: u64, + pub inner_instructions: u64, + pub decoded_bytes: u64, + pub checksum: u64, + pub value: T, +} + +/// Verified per-block summary delivered by [`run_epoch_firehose`]. +pub type FirehoseBlockSummary = FirehoseProjectedBlock<()>; + +/// Live progress snapshot reported periodically during a firehose run. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct FirehoseProgress { + pub elapsed: Duration, + pub total_blocks: u64, + pub ordered_blocks: u64, + pub ordered_transactions: u64, + pub ordered_instructions: u64, + pub decoded_blocks: u64, + pub decoded_transactions: u64, + pub ordered_decoded_bytes: u64, + pub wire_bytes: u64, + pub active_streams: usize, + pub hedges: u64, + pub retries: u64, + pub is_final: bool, +} + +/// Completed cold-start firehose summary. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FirehoseReport { + pub epoch: u64, + pub epoch_url: String, + pub index: FirehoseIndexInfo, + pub total_elapsed: Duration, + pub stream_elapsed: Duration, + pub blocks: u64, + pub transactions: u64, + pub instructions: u64, + pub inner_instructions: u64, + pub compressed_bytes: u64, + pub decoded_bytes: u64, + pub wire_bytes: u64, + pub stream_wire_bytes: u64, + pub get_requests: u64, + pub hedges: u64, + pub retries: u64, + pub checksum: u64, +} + +fn download_index_parallel( + http: &HttpRangeSource, + index_bytes_len: usize, +) -> Result, SourceError> { + let mut buf = vec![0u8; index_bytes_len]; + let chunks = 12usize.min((index_bytes_len / (1 << 20)).max(1)); + let chunk_size = index_bytes_len.div_ceil(chunks); + thread::scope(|scope| -> Result<(), SourceError> { + let mut handles = Vec::with_capacity(chunks); + let mut rest = buf.as_mut_slice(); + let mut offset = 0u64; + while !rest.is_empty() { + let take = chunk_size.min(rest.len()); + let (slice, next) = rest.split_at_mut(take); + rest = next; + let cur_offset = offset; + offset += take as u64; + handles.push(scope.spawn(move || -> Result<(), SourceError> { + let winner = Arc::new(AtomicBool::new(false)); + let cancel_a = Arc::new(AtomicBool::new(false)); + let cancel_b = Arc::new(AtomicBool::new(false)); + let (tx, rx) = sync_channel::, SourceError>>(2); + + let http_a = http.clone(); + let tx_a = tx.clone(); + let w_a = Arc::clone(&winner); + let ca = Arc::clone(&cancel_a); + let cb = Arc::clone(&cancel_b); + thread::spawn(move || { + let mut out = Vec::with_capacity(take); + let res = http_a + .read_range_into_cancellable( + BLOCK_INDEX_FILE, + cur_offset, + take, + &mut out, + &ca, + ) + .map(|()| out); + if res.is_ok() && !w_a.swap(true, Ordering::AcqRel) { + cb.store(true, Ordering::Release); + } + let _ = tx_a.send(res); + }); + + match rx.recv_timeout(Duration::from_millis(250)) { + Ok(Ok(bytes)) => { + cancel_b.store(true, Ordering::Release); + slice.copy_from_slice(&bytes); + Ok(()) + } + Ok(Err(_first_err)) => { + let mut out = Vec::with_capacity(take); + http.read_range_into(BLOCK_INDEX_FILE, cur_offset, take, &mut out)?; + slice.copy_from_slice(&out); + Ok(()) + } + Err(_) => { + let http_b = http.clone(); + let tx_b = tx.clone(); + let w_b = Arc::clone(&winner); + let ca = Arc::clone(&cancel_a); + let cb = Arc::clone(&cancel_b); + thread::spawn(move || { + let mut out = Vec::with_capacity(take); + let res = http_b + .read_range_into_cancellable( + BLOCK_INDEX_FILE, + cur_offset, + take, + &mut out, + &cb, + ) + .map(|()| out); + if res.is_ok() && !w_b.swap(true, Ordering::AcqRel) { + ca.store(true, Ordering::Release); + } + let _ = tx_b.send(res); + }); + drop(tx); + let mut last_err = None; + while let Ok(res) = rx.recv() { + match res { + Ok(bytes) => { + cancel_a.store(true, Ordering::Release); + cancel_b.store(true, Ordering::Release); + slice.copy_from_slice(&bytes); + return Ok(()); + } + Err(e) => last_err = Some(e), + } + } + Err(last_err.unwrap_or_else(|| { + SourceError::Protocol("index chunk download failed".into()) + })) + } + } + })); + } + for h in handles { + h.join() + .map_err(|_| SourceError::Protocol("index download worker panicked".into()))??; + } + Ok(()) + })?; + Ok(buf) +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +struct SubBatchPlan { + row_start: usize, + row_end: usize, + offset: u64, + len: usize, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +struct SegmentPlan { + sub_start: usize, + sub_end: usize, +} + +fn build_plans( + rows: &[ArchiveV2HotBlockIndexRow], + sub_batch_bytes: usize, + segment_bytes: usize, +) -> (Vec, Vec) { + let mut subs = Vec::new(); + let mut start = 0usize; + while start < rows.len() { + let first_offset = rows[start].compressed_offset; + let mut end = start; + let mut len = 0usize; + while end < rows.len() { + let next_len = len + rows[end].compressed_len as usize; + if end > start && next_len > sub_batch_bytes { + break; + } + len = next_len; + end += 1; + } + subs.push(SubBatchPlan { + row_start: start, + row_end: end, + offset: first_offset, + len, + }); + start = end; + } + + let mut segments = Vec::new(); + let mut s_start = 0usize; + while s_start < subs.len() { + let mut s_end = s_start; + let mut seg_len = 0usize; + while s_end < subs.len() { + let next_len = seg_len + subs[s_end].len; + if s_end > s_start && next_len > segment_bytes { + break; + } + seg_len = next_len; + s_end += 1; + } + segments.push(SegmentPlan { + sub_start: s_start, + sub_end: s_end, + }); + s_start = s_end; + } + (subs, segments) +} + +struct SegmentState { + claimed: bool, + next_sub: usize, + sub_start: usize, + sub_end: usize, + owner_gen: u64, + active_streams: Vec<(u64, Arc)>, + last_progress: Instant, + hedges_on_current_sub: u32, +} + +struct CoordinatorState { + segments: Vec, + next_unclaimed: usize, + completed_subs: usize, + total_subs: usize, + recent_sub_ms: [u64; 64], + recent_len: usize, + recent_pos: usize, + error: Option, +} + +impl CoordinatorState { + fn record_sub_ms(&mut self, d: Duration) { + let ms = d.as_millis().min(u64::MAX as u128) as u64; + self.recent_sub_ms[self.recent_pos] = ms; + self.recent_pos = (self.recent_pos + 1) % self.recent_sub_ms.len(); + if self.recent_len < self.recent_sub_ms.len() { + self.recent_len += 1; + } + } + + fn median_sub_ms(&self) -> Option { + if self.recent_len < 16 { + return None; + } + let mut sample = [0u64; 64]; + sample[..self.recent_len].copy_from_slice(&self.recent_sub_ms[..self.recent_len]); + sample[..self.recent_len].sort_unstable(); + Some(sample[self.recent_len / 2]) + } + + fn cancel_all(&mut self) { + for seg in &mut self.segments { + for (_, flag) in seg.active_streams.drain(..) { + flag.store(true, Ordering::Release); + } + } + } + + fn pick_work( + &mut self, + now: Instant, + ordered_frontier_sub: usize, + ) -> Option<(usize, usize, usize, u64, Arc, bool)> { + if self.error.is_some() || self.completed_subs >= self.total_subs { + return None; + } + // 1. Claim any unclaimed segment first. + while self.next_unclaimed < self.segments.len() { + let idx = self.next_unclaimed; + self.next_unclaimed += 1; + let seg = &mut self.segments[idx]; + if !seg.claimed && seg.next_sub < seg.sub_end { + seg.claimed = true; + seg.owner_gen += 1; + let stream_gen = seg.owner_gen; + let flag = Arc::new(AtomicBool::new(false)); + seg.active_streams.push((stream_gen, Arc::clone(&flag))); + seg.last_progress = now; + seg.hedges_on_current_sub = 0; + return Some((idx, seg.next_sub, seg.sub_end, stream_gen, flag, false)); + } + } + // 2. Immediately resume any incomplete segment that lost its stream. + for (idx, seg) in self.segments.iter_mut().enumerate() { + if seg.next_sub < seg.sub_end && seg.active_streams.is_empty() { + seg.owner_gen += 1; + let stream_gen = seg.owner_gen; + let flag = Arc::new(AtomicBool::new(false)); + seg.active_streams.push((stream_gen, Arc::clone(&flag))); + seg.last_progress = now; + seg.hedges_on_current_sub = 0; + return Some((idx, seg.next_sub, seg.sub_end, stream_gen, flag, false)); + } + } + // 2b. Prioritize hedging the exact segment blocking ordered delivery. + for (idx, seg) in self.segments.iter_mut().enumerate() { + if seg.next_sub <= ordered_frontier_sub + && ordered_frontier_sub < seg.sub_end + && seg.next_sub < seg.sub_end + && seg.hedges_on_current_sub < 6 + { + let thresh = if seg.next_sub == seg.sub_start { + 900u64 + } else { + 450u64 + }; + let elapsed_ms = + now.saturating_duration_since(seg.last_progress).as_millis() as u64; + if elapsed_ms >= thresh { + seg.owner_gen += 1; + let stream_gen = seg.owner_gen; + let flag = Arc::new(AtomicBool::new(false)); + seg.active_streams.push((stream_gen, Arc::clone(&flag))); + seg.last_progress = now; + seg.hedges_on_current_sub += 1; + return Some((idx, seg.next_sub, seg.sub_end, stream_gen, flag, true)); + } + break; + } + } + // 3. Continuous work-stealing on the longest remaining segment. + let remaining_segs = self + .segments + .iter() + .filter(|s| s.next_sub < s.sub_end) + .count(); + let min_split_subs = if remaining_segs <= 48 { 2 } else { 4 }; + if self.segments.len() < 700 && self.completed_subs >= 64 { + let split_target = self + .segments + .iter() + .enumerate() + .filter(|(_, s)| { + let started_or_slow = s.next_sub > s.sub_start + || now.saturating_duration_since(s.last_progress) + >= Duration::from_millis(1_500); + s.sub_end.saturating_sub(s.next_sub) >= min_split_subs && started_or_slow + }) + .max_by_key(|(_, s)| { + let rem = s.sub_end - s.next_sub; + let frontier_bonus = + if s.next_sub <= ordered_frontier_sub && ordered_frontier_sub < s.sub_end { + 20 + } else { + 0 + }; + rem + frontier_bonus + }) + .map(|(idx, _)| idx); + if let Some(idx) = split_target { + let (mid, old_end) = { + let seg = &mut self.segments[idx]; + let mid = seg.next_sub + (seg.sub_end - seg.next_sub) / 2; + let old_end = seg.sub_end; + seg.sub_end = mid; + (mid, old_end) + }; + let new_idx = self.segments.len(); + let flag = Arc::new(AtomicBool::new(false)); + self.segments.push(SegmentState { + claimed: true, + next_sub: mid, + sub_start: mid, + sub_end: old_end, + owner_gen: 1, + active_streams: vec![(1, Arc::clone(&flag))], + last_progress: now, + hedges_on_current_sub: 0, + }); + self.next_unclaimed = self.segments.len(); + return Some((new_idx, mid, old_end, 1, flag, false)); + } + } + // 4. Exact-offset tail hedging for stalling or final-chunk stragglers. + let med = self.median_sub_ms().unwrap_or(240); + let (max_hedges, ttfb_thresh_ms, stream_thresh_ms) = if remaining_segs <= 8 { + (12u32, 550u64, 240u64) + } else if remaining_segs <= 24 { + (8u32, 750u64, 320u64) + } else if remaining_segs <= 48 { + (5u32, 950u64, 400u64) + } else { + ( + 3u32, + med.saturating_mul(5).clamp(1_300, 3_000), + med.saturating_mul(3).clamp(550, 1_500), + ) + }; + for (idx, seg) in self.segments.iter_mut().enumerate() { + if seg.next_sub >= seg.sub_end || seg.hedges_on_current_sub >= max_hedges { + continue; + } + let thresh = if seg.next_sub == seg.sub_start { + ttfb_thresh_ms + } else { + stream_thresh_ms + }; + let elapsed_ms = now.saturating_duration_since(seg.last_progress).as_millis() as u64; + if elapsed_ms >= thresh { + seg.owner_gen += 1; + let stream_gen = seg.owner_gen; + let flag = Arc::new(AtomicBool::new(false)); + seg.active_streams.push((stream_gen, Arc::clone(&flag))); + seg.last_progress = now; + seg.hedges_on_current_sub += 1; + return Some((idx, seg.next_sub, seg.sub_end, stream_gen, flag, true)); + } + } + None + } +} + +struct OrderedSubSlots { + slots: Vec>>>>, + ready_notify: (Mutex, Condvar), +} + +impl OrderedSubSlots { + fn new(total_subs: usize) -> Self { + Self { + slots: (0..total_subs).map(|_| Mutex::new(None)).collect(), + ready_notify: (Mutex::new(0), Condvar::new()), + } + } + + fn publish(&self, sub_id: usize, blocks: Vec>) { + *self.slots[sub_id].lock().unwrap() = Some(blocks); + let mut count = self.ready_notify.0.lock().unwrap(); + *count += 1; + self.ready_notify.1.notify_one(); + } + + fn take_ordered( + &self, + sub_id: usize, + cancelled: &AtomicBool, + ) -> Option>> { + loop { + if let Some(blocks) = self.slots[sub_id].lock().unwrap().take() { + return Some(blocks); + } + if cancelled.load(Ordering::Acquire) { + return None; + } + let guard = self.ready_notify.0.lock().unwrap(); + if let Some(blocks) = self.slots[sub_id].lock().unwrap().take() { + return Some(blocks); + } + if cancelled.load(Ordering::Acquire) { + return None; + } + let _ = self + .ready_notify + .1 + .wait_timeout(guard, Duration::from_millis(20)) + .unwrap(); + } + } +} + +fn lane_slice(lane: &[u8], offset: u32, len: u32) -> Result<&[u8], SourceError> { + let start = offset as usize; + let end = start + .checked_add(len as usize) + .ok_or_else(|| SourceError::Protocol("lane slice overflow".into()))?; + lane.get(start..end).ok_or_else(|| { + SourceError::Protocol(format!( + "lane slice {start}..{end} out of bounds {}", + lane.len() + )) + }) +} + +/// Default per-block projector used by [`run_epoch_firehose`]. +pub fn project_block_summary( + borrowed: &FirehoseBorrowedBlock<'_>, + decode_level: FirehoseDecodeLevel, +) -> Result { + let row = borrowed.row; + let msg_lane = borrowed.block.message_bytes; + let meta_lane = borrowed.block.metadata_bytes; + let mut blk_txs = 0u64; + let mut blk_ixs = 0u64; + let mut blk_inner = 0u64; + let mut chk = 0u64; + + match decode_level { + FirehoseDecodeLevel::Full => { + let mut counts = BlockCounts::default(); + for tx_row in borrowed.block.tx_rows() { + let msg = lane_slice(msg_lane, tx_row.message_offset, tx_row.message_len)?; + let meta = lane_slice(meta_lane, tx_row.metadata_offset, tx_row.metadata_len)?; + count_transaction( + &mut counts, + tx_row.flags, + usize::from(tx_row.signature_count), + msg, + CountMetadata::Full(meta), + CompactV2MessageSchema::Current, + CompactV2MetadataSchema::CurrentTypedError, + borrowed.registry_entries, + ) + .map_err(|e| SourceError::Protocol(format!("slot {} tx decode: {e}", row.slot)))?; + } + blk_txs = counts.transactions; + blk_ixs = counts.instructions; + blk_inner = counts.recorded_inner_instructions; + chk = blk_txs ^ (blk_ixs << 17) ^ row.slot; + } + FirehoseDecodeLevel::Block => { + for tx_row in borrowed.block.tx_rows() { + blk_txs += 1; + chk = chk + .wrapping_add(u64::from(tx_row.flags)) + .wrapping_add(u64::from(tx_row.message_len)) + .wrapping_add(u64::from(tx_row.metadata_len)); + } + } + } + + Ok(FirehoseBlockSummary { + block_ordinal: borrowed.block_ordinal, + slot: row.slot, + transactions: blk_txs, + instructions: blk_ixs, + inner_instructions: blk_inner, + decoded_bytes: u64::from(row.uncompressed_len), + checksum: chk, + value: (), + }) +} + +/// Stream a Compact V2 epoch over HTTPS with a caller-supplied parallel block +/// projector `project_block`, delivering projected results in strict global +/// ascending slot order (`slot > prev_slot`). +/// +/// The returned `total_elapsed` starts before the first remote metadata request +/// and includes downloading and validating `archive-v2-blocks.index`. +pub fn stream_epoch_firehose( + config: &FirehoseConfig, + mut on_index: FIndex, + on_progress: FProgress, + project_block: FProject, + mut on_block: FBlock, +) -> Result +where + T: Send, + FIndex: FnMut(&FirehoseIndexInfo), + FProgress: Fn(&FirehoseProgress) + Send + Sync, + FProject: Fn(&FirehoseBorrowedBlock<'_>) -> Result, SourceError> + + Send + + Sync, + FBlock: FnMut(FirehoseProjectedBlock) -> Result<(), SourceError>, +{ + config.validate()?; + let t0 = Instant::now(); + + let http_options = HttpRangeSourceOptions { + allow_insecure_http: config.allow_insecure_http, + object_path_layout: config.object_path_layout, + ..HttpRangeSourceOptions::default() + }; + let http = match &config.signer { + Some(signer) => HttpRangeSource::with_signer( + &config.epoch_url, + config.epoch, + Arc::clone(signer), + http_options, + )?, + None => HttpRangeSource::with_options(&config.epoch_url, config.epoch, None, http_options)?, + }; + + // Phase 1: Overlap blocks/registry HEADs with full in-RAM parallel download of block index. + let (index_raw, blocks_id, registry_id) = thread::scope(|scope| -> Result<_, SourceError> { + let h_blk = scope.spawn(|| http.strong_identity(BLOCKS_FILE)); + let h_reg = scope.spawn(|| http.strong_identity(REGISTRY_FILE)); + let index_id = http.strong_identity(BLOCK_INDEX_FILE)?; + let raw = download_index_parallel(&http, index_id.length as usize)?; + let blk = h_blk + .join() + .map_err(|_| SourceError::Protocol("blocks HEAD worker panicked".into()))??; + let reg = h_reg + .join() + .map_err(|_| SourceError::Protocol("registry HEAD worker panicked".into()))??; + Ok((raw, blk, reg)) + })?; + + if registry_id.length % 32 != 0 { + return Err(SourceError::Protocol( + "registry.bin length is not a multiple of 32 bytes".into(), + )); + } + let registry_entries = u32::try_from(registry_id.length / 32) + .map_err(|_| SourceError::Protocol("registry entry count overflows u32".into()))?; + let epoch_first_slot = config + .epoch + .checked_mul(MAINNET_SLOTS_PER_EPOCH) + .ok_or_else(|| SourceError::Protocol("epoch first slot overflows u64".into()))?; + let (index, _total_signatures) = parse_and_validate_index( + &index_raw, + blocks_id.length, + config.epoch, + MAINNET_SLOTS_PER_EPOCH, + epoch_first_slot, + &OpenOptions::default(), + ) + .map_err(|e| SourceError::Protocol(format!("invalid block index: {e}")))?; + + let first_block_ordinal = config.first_block; + let start_row = first_block_ordinal as usize; + if start_row > index.rows.len() || (start_row == index.rows.len() && start_row > 0) { + return Err(SourceError::Protocol(format!( + "first_block {} is outside 0..{}", + config.first_block, + index.rows.len() + ))); + } + let end_row = match config.max_blocks { + Some(limit) => start_row + .saturating_add(limit as usize) + .min(index.rows.len()), + None => index.rows.len(), + }; + let selected_rows = &index.rows[start_row..end_row]; + + let total_blocks = selected_rows.len() as u64; + let total_txs_expected: u64 = selected_rows.iter().map(|r| u64::from(r.tx_count)).sum(); + let total_compressed: u64 = selected_rows + .iter() + .map(|r| u64::from(r.compressed_len)) + .sum(); + let index_info = FirehoseIndexInfo { + blocks: total_blocks, + transactions: total_txs_expected, + compressed_bytes: total_compressed, + elapsed: t0.elapsed(), + }; + on_index(&index_info); + + if selected_rows.is_empty() { + let total_elapsed = t0.elapsed(); + let io_final = http.stats(); + return Ok(FirehoseReport { + epoch: config.epoch, + epoch_url: config.epoch_url.clone(), + index: index_info, + total_elapsed, + stream_elapsed: Duration::ZERO, + blocks: 0, + transactions: 0, + instructions: 0, + inner_instructions: 0, + compressed_bytes: 0, + decoded_bytes: 0, + wire_bytes: io_final.returned_body_bytes, + stream_wire_bytes: 0, + get_requests: io_final.get_requests, + hedges: 0, + retries: http.retry_stats().total(), + checksum: 0, + }); + } + + // Respect caller segment_bytes on large epochs so spare workers can steal & + // hedge stragglers; auto-shrink on small epochs (<16 GiB). + let auto_seg = if total_compressed < 16 * 1024 * 1024 * 1024 { + ((total_compressed / config.net_workers.max(1) as u64) as usize) + .clamp(32 * 1024 * 1024, config.segment_bytes) + } else { + config.segment_bytes.max(32 * 1024 * 1024) + }; + let (subs, segments) = build_plans(selected_rows, config.sub_batch_bytes, auto_seg); + let total_subs = subs.len(); + // Always keep at least 4 workers (bounded by config.net_workers) so small + // bounded runs (e.g. --max-blocks 5) still have spare workers to hedge a + // slow/throttled R2 edge stream immediately. + let active_net_workers = config.net_workers.min(total_subs.max(4)); + + let seg_states: Vec = segments + .iter() + .map(|s| SegmentState { + claimed: false, + next_sub: s.sub_start, + sub_start: s.sub_start, + sub_end: s.sub_end, + owner_gen: 0, + active_streams: Vec::new(), + last_progress: Instant::now(), + hedges_on_current_sub: 0, + }) + .collect(); + + let coord = Mutex::new(CoordinatorState { + segments: seg_states, + next_unclaimed: 0, + completed_subs: 0, + total_subs, + recent_sub_ms: [0; 64], + recent_len: 0, + recent_pos: 0, + error: None, + }); + + let ordered_slots = OrderedSubSlots::::new(total_subs); + let global_cancelled = AtomicBool::new(false); + let active_http_streams = AtomicUsize::new(0); + let hedges_triggered = AtomicU64::new(0); + let ordered_frontier_sub = AtomicUsize::new(0); + let decoded_blocks = AtomicU64::new(0); + let decoded_txs = AtomicU64::new(0); + let decoded_ixs = AtomicU64::new(0); + let ordered_blocks = AtomicU64::new(0); + let ordered_txs = AtomicU64::new(0); + let ordered_ixs = AtomicU64::new(0); + let ordered_inner_ixs = AtomicU64::new(0); + let ordered_decoded_bytes = AtomicU64::new(0); + let ordered_checksum = AtomicU64::new(0); + let finished = AtomicBool::new(false); + + let max_sub_bytes = subs + .iter() + .map(|s| s.len) + .max() + .unwrap_or(config.sub_batch_bytes); + let queue_cap = 512usize.min(total_subs.max(1)); + let (decode_tx, decode_rx): (SyncSender<(usize, Vec)>, Receiver<(usize, Vec)>) = + sync_channel(queue_cap); + let (free_tx, free_rx): (SyncSender>, Receiver>) = sync_channel(queue_cap); + let decode_rx = Mutex::new(decode_rx); + let free_rx = Mutex::new(free_rx); + + let stream_start = Instant::now(); + let io_before_stream = http.stats(); + + let rows_ref = selected_rows; + let subs_ref = &subs; + let coord_ref = &coord; + let ordered_ref = &ordered_slots; + let http_ref = &http; + let progress_interval = config.progress_interval; + let on_progress_ref = &on_progress; + let project_block_ref = &project_block; + + let run_result: Result<(Duration, Duration), SourceError> = thread::scope(|scope| { + // 1. Live telemetry thread. + let progress_handle = { + let finished = &finished; + let ordered_blocks = &ordered_blocks; + let ordered_txs = &ordered_txs; + let ordered_ixs = &ordered_ixs; + let ordered_decoded_bytes = &ordered_decoded_bytes; + let decoded_blocks = &decoded_blocks; + let decoded_txs = &decoded_txs; + let active_http_streams = &active_http_streams; + let hedges_triggered = &hedges_triggered; + scope.spawn(move || { + let emit = |is_final: bool| { + let st = http_ref.stats(); + let snap = FirehoseProgress { + elapsed: t0.elapsed(), + total_blocks, + ordered_blocks: ordered_blocks.load(Ordering::Relaxed), + ordered_transactions: ordered_txs.load(Ordering::Relaxed), + ordered_instructions: ordered_ixs.load(Ordering::Relaxed), + decoded_blocks: decoded_blocks.load(Ordering::Relaxed), + decoded_transactions: decoded_txs.load(Ordering::Relaxed), + ordered_decoded_bytes: ordered_decoded_bytes.load(Ordering::Relaxed), + wire_bytes: st.returned_body_bytes, + active_streams: if is_final { + 0 + } else { + active_http_streams.load(Ordering::Relaxed) + }, + hedges: hedges_triggered.load(Ordering::Relaxed), + retries: http_ref.retry_stats().total(), + is_final, + }; + on_progress_ref(&snap); + }; + if !progress_interval.is_zero() { + while !finished.load(Ordering::Acquire) { + thread::sleep(progress_interval); + if finished.load(Ordering::Acquire) { + break; + } + emit(false); + } + if ordered_blocks.load(Ordering::Relaxed) == total_blocks { + emit(true); + } + } + }) + }; + + // 2. Decode and parallel projection worker pool. + let mut decode_handles = Vec::with_capacity(config.decode_workers); + for w in 0..config.decode_workers { + let decode_rx = &decode_rx; + let free_tx = free_tx.clone(); + let global_cancelled = &global_cancelled; + let decoded_blocks = &decoded_blocks; + let decoded_txs = &decoded_txs; + let decoded_ixs = &decoded_ixs; + decode_handles.push( + thread::Builder::new() + .name(format!("firehose-dec-{w}")) + .spawn_scoped(scope, move || -> Result<(), SourceError> { + let mut decompressor = zstd::bulk::Decompressor::new() + .map_err(|e| SourceError::Protocol(format!("zstd decompressor: {e}")))?; + let mut decompressed: Vec = Vec::with_capacity(8 * 1024 * 1024); + loop { + let item = { + let rx = decode_rx.lock().unwrap(); + rx.recv().ok() + }; + let Some((sub_id, compressed_buf)) = item else { + break; + }; + if global_cancelled.load(Ordering::Acquire) { + break; + } + let sub = subs_ref[sub_id]; + let mut out = Vec::with_capacity(sub.row_end - sub.row_start); + let mut sub_txs = 0u64; + let mut sub_ixs = 0u64; + for (offset_in_sub, row) in + rows_ref[sub.row_start..sub.row_end].iter().enumerate() + { + let block_ordinal = + first_block_ordinal + (sub.row_start + offset_in_sub) as u32; + let rel = (row.compressed_offset - sub.offset) as usize; + let frame = &compressed_buf[rel..rel + row.compressed_len as usize]; + let unc_len = row.uncompressed_len as usize; + if decompressed.len() < unc_len { + decompressed.resize(unc_len, 0); + } + let actual = decompressor + .decompress_to_buffer(frame, &mut decompressed[..unc_len]) + .map_err(|e| { + SourceError::Protocol(format!("slot {} zstd: {e}", row.slot)) + })?; + if actual != unc_len { + return Err(SourceError::Protocol(format!( + "slot {} zstd len {} != expected {}", + row.slot, actual, unc_len + ))); + } + let block = deserialize_archive_v2_hot_block_blob_borrowed_current_without_rewards( + &decompressed[..unc_len], + ) + .map_err(|e| { + SourceError::Protocol(format!("slot {} wincode: {e}", row.slot)) + })?; + if block.header.slot != row.slot { + return Err(SourceError::Protocol(format!( + "slot mismatch {} != {}", + block.header.slot, row.slot + ))); + } + let borrowed = FirehoseBorrowedBlock { + block_ordinal, + row, + block, + registry_entries, + }; + let projected = project_block_ref(&borrowed)?; + if projected.slot != row.slot { + return Err(SourceError::Protocol(format!( + "projected slot {} != index slot {}", + projected.slot, row.slot + ))); + } + if projected.transactions != u64::from(row.tx_count) { + return Err(SourceError::Protocol(format!( + "slot {} tx_count {} != index {}", + row.slot, projected.transactions, row.tx_count + ))); + } + sub_txs += projected.transactions; + sub_ixs += projected.instructions; + out.push(projected); + } + let _ = free_tx.try_send(compressed_buf); + decoded_blocks.fetch_add(out.len() as u64, Ordering::Relaxed); + decoded_txs.fetch_add(sub_txs, Ordering::Relaxed); + decoded_ixs.fetch_add(sub_ixs, Ordering::Relaxed); + ordered_ref.publish(sub_id, out); + } + Ok(()) + }) + .map_err(|e| SourceError::Protocol(format!("spawn decode worker: {e}")))?, + ); + } + drop(free_tx); + + // 3. Streaming HTTP range workers. + let mut net_handles = Vec::with_capacity(active_net_workers); + for w in 0..active_net_workers { + let decode_tx = decode_tx.clone(); + let free_rx = &free_rx; + let global_cancelled = &global_cancelled; + let active_http_streams = &active_http_streams; + let hedges_triggered = &hedges_triggered; + let ordered_frontier_sub = &ordered_frontier_sub; + net_handles.push( + thread::Builder::new() + .name(format!("firehose-net-{w}")) + .spawn_scoped(scope, move || -> Result<(), String> { + loop { + if global_cancelled.load(Ordering::Acquire) { + break; + } + let work = { + let mut c = coord_ref.lock().unwrap(); + if c.error.is_some() || c.completed_subs >= c.total_subs { + break; + } + c.pick_work( + Instant::now(), + ordered_frontier_sub.load(Ordering::Relaxed), + ) + }; + let Some(( + seg_idx, + start_sub, + planned_end_sub, + my_gen, + my_cancel, + is_hedge, + )) = work + else { + thread::sleep(Duration::from_millis(15)); + continue; + }; + if is_hedge { + hedges_triggered.fetch_add(1, Ordering::Relaxed); + } + let req_offset = subs_ref[start_sub].offset; + let last_sub = subs_ref[planned_end_sub - 1]; + let req_end = last_sub.offset + last_sub.len as u64; + let req_len = (req_end - req_offset) as usize; + + active_http_streams.fetch_add(1, Ordering::Relaxed); + let open_res = http_ref.open_range_stream_cancellable( + BLOCKS_FILE, + req_offset, + req_len, + Some(&my_cancel), + ); + let mut stream = match open_res { + Ok(s) => s, + Err(err) => { + active_http_streams.fetch_sub(1, Ordering::Relaxed); + if my_cancel.load(Ordering::Acquire) + || global_cancelled.load(Ordering::Acquire) + { + continue; + } + let mut c = coord_ref.lock().unwrap(); + let seg = &mut c.segments[seg_idx]; + seg.active_streams.retain(|(g, _)| *g != my_gen); + if seg.active_streams.is_empty() + && seg.next_sub < seg.sub_end + && matches!( + err, + SourceError::Protocol(_) + | SourceError::NotFound(_) + | SourceError::OutOfBounds { .. } + ) + { + c.error = Some(err.to_string()); + c.cancel_all(); + global_cancelled.store(true, Ordering::Release); + break; + } + continue; + } + }; + + for sub_id in start_sub..planned_end_sub { + if my_cancel.load(Ordering::Acquire) + || global_cancelled.load(Ordering::Acquire) + { + break; + } + { + let c = coord_ref.lock().unwrap(); + if sub_id >= c.segments[seg_idx].sub_end { + break; + } + } + let sub_len = subs_ref[sub_id].len; + let mut buf = free_rx + .lock() + .unwrap() + .try_recv() + .unwrap_or_else(|_| Vec::with_capacity(max_sub_bytes)); + let sub_t0 = Instant::now(); + if stream + .read_chunk_into_vec(sub_len, &mut buf, Some(&my_cancel)) + .is_err() + { + break; + } + let sub_dt = sub_t0.elapsed(); + let (won, seg_done) = { + let mut c = coord_ref.lock().unwrap(); + let seg = &mut c.segments[seg_idx]; + if sub_id < seg.next_sub || sub_id >= seg.sub_end { + (false, sub_id >= seg.sub_end) + } else if sub_id == seg.next_sub { + seg.next_sub += 1; + seg.last_progress = Instant::now(); + seg.hedges_on_current_sub = 0; + seg.active_streams.retain(|(g, flag)| { + if *g < my_gen { + flag.store(true, Ordering::Release); + false + } else { + true + } + }); + let done = seg.next_sub >= seg.sub_end; + if done { + for (_, flag) in seg.active_streams.drain(..) { + flag.store(true, Ordering::Release); + } + } + c.completed_subs += 1; + if sub_id > start_sub { + c.record_sub_ms(sub_dt); + } + (true, done) + } else { + (false, false) + } + }; + if !won { + break; + } + if decode_tx.send((sub_id, buf)).is_err() { + break; + } + if seg_done { + break; + } + } + + { + let mut c = coord_ref.lock().unwrap(); + c.segments[seg_idx] + .active_streams + .retain(|(g, _)| *g != my_gen); + } + active_http_streams.fetch_sub(1, Ordering::Relaxed); + } + Ok(()) + }) + .map_err(|e| SourceError::Protocol(format!("spawn net worker: {e}")))?, + ); + } + drop(decode_tx); + + // 4. Strict global block-order consumer on current thread. + let mut prev_slot: Option = None; + let mut consume_err: Option = None; + for sub_id in 0..total_subs { + let Some(blocks) = ordered_ref.take_ordered(sub_id, &global_cancelled) else { + break; + }; + let block_count = blocks.len() as u64; + let mut batch_txs = 0u64; + let mut batch_ixs = 0u64; + let mut batch_inner = 0u64; + let mut batch_dec = 0u64; + let mut batch_chk = 0u64; + for b in blocks { + if let Some(prev) = prev_slot + && b.slot <= prev + { + consume_err = Some(SourceError::Protocol(format!( + "out-of-order slot {} after {}", + b.slot, prev + ))); + global_cancelled.store(true, Ordering::Release); + coord_ref.lock().unwrap().cancel_all(); + break; + } + prev_slot = Some(b.slot); + batch_txs += b.transactions; + batch_ixs += b.instructions; + batch_inner += b.inner_instructions; + batch_dec += b.decoded_bytes; + batch_chk ^= b.checksum; + if let Err(err) = on_block(b) { + consume_err = Some(err); + global_cancelled.store(true, Ordering::Release); + coord_ref.lock().unwrap().cancel_all(); + break; + } + } + if consume_err.is_some() { + break; + } + ordered_blocks.fetch_add(block_count, Ordering::Relaxed); + ordered_txs.fetch_add(batch_txs, Ordering::Relaxed); + ordered_ixs.fetch_add(batch_ixs, Ordering::Relaxed); + ordered_inner_ixs.fetch_add(batch_inner, Ordering::Relaxed); + ordered_decoded_bytes.fetch_add(batch_dec, Ordering::Relaxed); + ordered_checksum.fetch_xor(batch_chk, Ordering::Relaxed); + ordered_frontier_sub.store(sub_id + 1, Ordering::Relaxed); + } + + let delivery_total_elapsed = t0.elapsed(); + let delivery_stream_elapsed = stream_start.elapsed(); + coord_ref.lock().unwrap().cancel_all(); + finished.store(true, Ordering::Release); + let _ = progress_handle.join(); + + let mut first_err = consume_err.or_else(|| { + coord_ref + .lock() + .unwrap() + .error + .clone() + .map(SourceError::Protocol) + }); + for h in net_handles { + match h.join() { + Ok(Ok(())) => {} + Ok(Err(e)) if first_err.is_none() => first_err = Some(SourceError::Protocol(e)), + Err(_) if first_err.is_none() => { + first_err = Some(SourceError::Protocol("net worker panicked".into())) + } + _ => {} + } + } + for h in decode_handles { + match h.join() { + Ok(Ok(())) => {} + Ok(Err(e)) if first_err.is_none() => first_err = Some(e), + Err(_) if first_err.is_none() => { + first_err = Some(SourceError::Protocol("decode worker panicked".into())) + } + _ => {} + } + } + match first_err { + Some(e) => Err(e), + None => Ok((delivery_total_elapsed, delivery_stream_elapsed)), + } + }); + + let (total_elapsed, stream_elapsed) = run_result?; + let final_blocks = ordered_blocks.load(Ordering::Relaxed); + let final_txs = ordered_txs.load(Ordering::Relaxed); + if final_blocks != total_blocks { + return Err(SourceError::Protocol(format!( + "incomplete ordered delivery: {} != {}", + final_blocks, total_blocks + ))); + } + if final_txs != total_txs_expected { + return Err(SourceError::Protocol(format!( + "transaction count mismatch: {} != {}", + final_txs, total_txs_expected + ))); + } + + let io_final = http.stats(); + let wire_bytes = io_final.returned_body_bytes; + let stream_wire_bytes = wire_bytes.saturating_sub(io_before_stream.returned_body_bytes); + + Ok(FirehoseReport { + epoch: config.epoch, + epoch_url: config.epoch_url.clone(), + index: index_info, + total_elapsed, + stream_elapsed, + blocks: final_blocks, + transactions: final_txs, + instructions: ordered_ixs.load(Ordering::Relaxed), + inner_instructions: ordered_inner_ixs.load(Ordering::Relaxed), + compressed_bytes: total_compressed, + decoded_bytes: ordered_decoded_bytes.load(Ordering::Relaxed), + wire_bytes, + stream_wire_bytes, + get_requests: io_final.get_requests, + hedges: hedges_triggered.load(Ordering::Relaxed), + retries: http.retry_stats().total(), + checksum: ordered_checksum.load(Ordering::Relaxed), + }) +} + +/// Run a cold-start ordered HTTPS firehose over a Compact V2 epoch, producing +/// verified per-block counts via [`project_block_summary`]. +pub fn run_epoch_firehose( + config: &FirehoseConfig, + on_index: FIndex, + on_progress: FProgress, + mut on_block: FBlock, +) -> Result +where + FIndex: FnMut(&FirehoseIndexInfo), + FProgress: Fn(&FirehoseProgress) + Send + Sync, + FBlock: FnMut(&FirehoseBlockSummary) -> Result<(), SourceError>, +{ + let decode_level = config.decode_level; + stream_epoch_firehose( + config, + on_index, + on_progress, + move |borrowed| project_block_summary(borrowed, decode_level), + move |summary| on_block(&summary), + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use blockzilla_archive_v2::{ARCHIVE_V2_HOT_INDEX_MAGIC, ARCHIVE_V2_HOT_INDEX_VERSION}; + + #[test] + fn foundation_config_validates_and_rejects_zero_limits() { + let mut cfg = FirehoseConfig::foundation_epoch(800); + cfg.validate().unwrap(); + assert!(cfg.epoch_url.ends_with("/epoch-800")); + + cfg.net_workers = 0; + assert!(cfg.validate().is_err()); + + let mut cfg = FirehoseConfig::foundation_epoch(800); + cfg.max_blocks = Some(0); + assert!(cfg.validate().is_err()); + } + + #[test] + fn build_plans_packs_frame_aligned_sub_batches_and_segments() { + let rows: Vec = (0..10u64) + .map(|i| ArchiveV2HotBlockIndexRow { + block_id: i as u32, + slot: 1000 + i, + compressed_offset: i * 100, + compressed_len: 100, + uncompressed_len: 300, + tx_count: 5, + first_tx_ordinal: i * 5, + first_signature_ordinal: i * 5, + signature_count: 5, + }) + .collect(); + let (subs, segs) = build_plans(&rows, 250, 500); + assert_eq!(subs.len(), 5); + assert_eq!( + subs[0], + SubBatchPlan { + row_start: 0, + row_end: 2, + offset: 0, + len: 200 + } + ); + assert_eq!( + subs[4], + SubBatchPlan { + row_start: 8, + row_end: 10, + offset: 800, + len: 200 + } + ); + assert_eq!(segs.len(), 3); + assert_eq!( + segs[0], + SegmentPlan { + sub_start: 0, + sub_end: 2 + } + ); + assert_eq!( + segs[1], + SegmentPlan { + sub_start: 2, + sub_end: 4 + } + ); + assert_eq!( + segs[2], + SegmentPlan { + sub_start: 4, + sub_end: 5 + } + ); + } + + #[test] + fn shared_index_validator_checks_magic_slot_order_and_ordinals() { + let mut raw = Vec::new(); + raw.extend_from_slice(ARCHIVE_V2_HOT_INDEX_MAGIC); + raw.extend_from_slice(&ARCHIVE_V2_HOT_INDEX_VERSION.to_le_bytes()); + raw.extend_from_slice(&0u16.to_le_bytes()); + raw.extend_from_slice(&2u64.to_le_bytes()); + raw.extend_from_slice(&350u64.to_le_bytes()); + raw.extend_from_slice(&1i32.to_le_bytes()); + raw.extend_from_slice(&0u32.to_le_bytes()); + for (idx, (off, len)) in [(0u64, 150u32), (150u64, 200u32)].into_iter().enumerate() { + raw.extend_from_slice(&(idx as u32).to_le_bytes()); + raw.extend_from_slice(&(500 + idx as u64).to_le_bytes()); + raw.extend_from_slice(&off.to_le_bytes()); + raw.extend_from_slice(&len.to_le_bytes()); + raw.extend_from_slice(&400u32.to_le_bytes()); + raw.extend_from_slice(&3u32.to_le_bytes()); + raw.extend_from_slice(&(idx as u64 * 3).to_le_bytes()); + raw.extend_from_slice(&(idx as u64 * 3).to_le_bytes()); + raw.extend_from_slice(&3u32.to_le_bytes()); + } + let (parsed, total_sigs) = parse_and_validate_index( + &raw, + 350, + 0, + MAINNET_SLOTS_PER_EPOCH, + 0, + &OpenOptions::default(), + ) + .unwrap(); + assert_eq!(parsed.rows.len(), 2); + assert_eq!(parsed.blob_file_bytes, 350); + assert_eq!(total_sigs, 6); + + raw[0] = b'X'; + assert!( + parse_and_validate_index( + &raw, + 350, + 0, + MAINNET_SLOTS_PER_EPOCH, + 0, + &OpenOptions::default() + ) + .is_err() + ); + } +} diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/lib.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/lib.rs index 59a3627f..93affc4a 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/src/lib.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/lib.rs @@ -17,6 +17,8 @@ pub mod descriptor; mod error; mod finalized_block; #[cfg(feature = "http")] +pub mod firehose; +#[cfg(feature = "http")] mod http; #[cfg(feature = "http")] mod http_cache; @@ -68,9 +70,10 @@ pub use error::{Error, Result, SourceError}; pub use finalized_block::FinalizedArchiveBlock; #[cfg(feature = "http")] pub use http::{ - HttpObjectIdentity, HttpObjectPathLayout, HttpRangeSource, HttpRangeSourceOptions, - HttpRangeSourceStats, HttpRequestSigner, HttpRequestToSign, HttpRetryPolicy, HttpRetryStats, - S3Credentials, S3PayloadHash, S3SigV4Signer, + HttpJsonClient, HttpObjectIdentity, HttpObjectPathLayout, HttpRangeSource, + HttpRangeSourceOptions, HttpRangeSourceStats, HttpRangeStream, HttpRequestSigner, + HttpRequestToSign, HttpRetryPolicy, HttpRetryStats, S3Credentials, S3PayloadHash, + S3SigV4Signer, }; #[cfg(feature = "http")] pub use http_cache::{ diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/reader.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/reader.rs index 8eb0230d..acbd9ed5 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/src/reader.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/reader.rs @@ -118,21 +118,21 @@ pub struct RecycledBlockStats { pub decompressed_buffer_capacity: usize, } -pub const MAX_ORDERED_PARALLEL_DECODE_WORKERS: usize = 64; +pub const MAX_ORDERED_PARALLEL_DECODE_WORKERS: usize = 128; pub const MAX_ORDERED_PARALLEL_COMPRESSED_BUFFERS: usize = 16; pub const MAX_ORDERED_PARALLEL_BLOCKS_PER_BATCH: usize = 65_536; /// Hard bound for caller-owned transaction projections retained in one batch. pub const MAX_ORDERED_PARALLEL_TRANSACTIONS_PER_BATCH: u64 = 65_536; pub const MAX_ORDERED_PARALLEL_UNCOMPRESSED_BATCH_BYTES: usize = 1024 * 1024 * 1024; -pub const MAX_ORDERED_PARALLEL_RETAINED_DECOMPRESSED_BYTES: usize = 1024 * 1024 * 1024; +pub const MAX_ORDERED_PARALLEL_RETAINED_DECOMPRESSED_BYTES: usize = 4 * 1024 * 1024 * 1024; /// Largest [`NetworkInputConfig::workers`] value. /// /// An object store with a high time to first byte needs many range requests /// in flight. `max_buffer_bytes` still limits the compressed memory: the /// reader starts at most `max_buffer_bytes / largest_range` workers. -pub const MAX_NETWORK_INPUT_WORKERS: usize = 64; +pub const MAX_NETWORK_INPUT_WORKERS: usize = 256; /// Largest [`NetworkInputConfig::max_buffer_bytes`] value. -pub const MAX_NETWORK_INPUT_BUFFER_BYTES: usize = 1024 * 1024 * 1024; +pub const MAX_NETWORK_INPUT_BUFFER_BYTES: usize = 16 * 1024 * 1024 * 1024; static NEXT_READER_ID: AtomicU64 = AtomicU64::new(1); @@ -4148,7 +4148,7 @@ fn hash_source_file( Ok(hex_lower(&hasher.finalize())) } -fn parse_and_validate_index( +pub(crate) fn parse_and_validate_index( bytes: &[u8], blocks_size: u64, epoch: u64, @@ -7595,8 +7595,8 @@ mod tests { ..NetworkInputConfig::default() }) }; - assert_eq!(MAX_NETWORK_INPUT_WORKERS, 64); - for count in [1, 8, 16, 17, 63, MAX_NETWORK_INPUT_WORKERS] { + assert_eq!(MAX_NETWORK_INPUT_WORKERS, 256); + for count in [1, 8, 16, 17, 63, 64, 128, MAX_NETWORK_INPUT_WORKERS] { assert!( validate_ordered_parallel_config(workers(count)).is_ok(), "{count}" @@ -7610,7 +7610,7 @@ mod tests { max_buffer_bytes, }) }; - assert_eq!(MAX_NETWORK_INPUT_BUFFER_BYTES, 1024 * 1024 * 1024); + assert_eq!(MAX_NETWORK_INPUT_BUFFER_BYTES, 16 * 1024 * 1024 * 1024); assert!(validate_ordered_parallel_config(budget(MAX_NETWORK_INPUT_BUFFER_BYTES)).is_ok()); for invalid in [ workers(0), @@ -7627,7 +7627,7 @@ mod tests { #[test] fn network_window_keeps_sixty_four_requests_in_flight_in_row_order() { - const WORKERS: usize = MAX_NETWORK_INPUT_WORKERS; + const WORKERS: usize = 64; // The fixture epoch has 100 slots. More blocks than workers make a // second wave of requests. const BLOCKS: usize = 96; diff --git a/crates/compact-v2/blockzilla-compact-v2-reader/src/signed_message.rs b/crates/compact-v2/blockzilla-compact-v2-reader/src/signed_message.rs index cdf240a6..84da8118 100644 --- a/crates/compact-v2/blockzilla-compact-v2-reader/src/signed_message.rs +++ b/crates/compact-v2/blockzilla-compact-v2-reader/src/signed_message.rs @@ -14,7 +14,7 @@ use blockzilla_archive_v2::{ ArchiveV2VoteTowerSync, }; use blockzilla_compact::CompactMessageHeader; -use solana_signature::Signature; +use ed25519_dalek::{Signature as Ed25519Signature, VerifyingKey}; use thiserror::Error; const VERSIONED_MESSAGE_PREFIX: u8 = 0x80; @@ -401,6 +401,14 @@ pub fn verify_ed25519_signatures( verify_ed25519_signatures_from(signed_message, signer_pubkeys, signatures, 0) } +fn verify_ed25519_signature(signer: &[u8; 32], signature: &[u8; 64], message: &[u8]) -> bool { + let Ok(verifying_key) = VerifyingKey::from_bytes(signer) else { + return false; + }; + let signature = Ed25519Signature::from_bytes(signature); + verifying_key.verify_strict(message, &signature).is_ok() +} + fn verify_ed25519_signatures_from( signed_message: &[u8], signer_pubkeys: &[[u8; 32]], @@ -413,7 +421,7 @@ fn verify_ed25519_signatures_from( .enumerate() .skip(first_unverified) { - if !Signature::from(*signature).verify(signer, signed_message) { + if !verify_ed25519_signature(signer, signature, signed_message) { return Err(SignedMessageError::SignatureVerificationFailed { signer_index }); } } @@ -448,8 +456,7 @@ pub fn select_signed_message_candidate_ed25519( let first_signer = signer_pubkeys .first() .ok_or(SignedMessageError::NoSignatures)?; - let first_signature = Signature::from(*first_signature); - // `Signature::verify` uses `ed25519_dalek::VerifyingKey::verify_strict`, + // `verify_ed25519_signature` uses `ed25519_dalek::VerifyingKey::verify_strict`, // which rejects weak/small-order public keys, small-order R points, and // non-canonical scalars. In the prime-order subgroup, one `(signer, sig)` // pair cannot verify two distinct messages without a SHA-512 mod-L @@ -467,7 +474,7 @@ pub fn select_signed_message_candidate_ed25519( message, max_combinations, distinct_candidates, - |signed_message| first_signature.verify(first_signer, signed_message), + |signed_message| verify_ed25519_signature(first_signer, first_signature, signed_message), )?; verify_ed25519_signatures_from(&selected.signed_message, signer_pubkeys, signatures, 1)?; Ok(selected) diff --git a/crates/compact-v2/blockzilla-compact/Cargo.toml b/crates/compact-v2/blockzilla-compact/Cargo.toml index 5a916ccd..a59f71f6 100644 --- a/crates/compact-v2/blockzilla-compact/Cargo.toml +++ b/crates/compact-v2/blockzilla-compact/Cargo.toml @@ -10,22 +10,22 @@ autobins = false description = "Compact record model: blocks, transactions, metadata and logs" [features] -default = ["known-program-logs"] +default = ["known-program-logs", "protobuf"] known-program-logs = ["blockzilla-program-logs/known-program-logs"] +protobuf = ["dep:prost", "blockzilla-solana-wire/protobuf"] [dependencies] -blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.2.0" } -blockzilla-registry = { path = "../blockzilla-registry", version = "0.2.0" } -blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, version = "0.2.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.3.0" } +blockzilla-registry = { path = "../blockzilla-registry", version = "0.3.0" } +blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, version = "0.3.0" } anyhow = "1.0.104" data-encoding = "2.11.1" heapless = { version = "0.9.3", features = ["serde"] } -prost = "0.14.4" +prost = { version = "0.14.4", optional = true } serde = { version = "1.0.229", features = ["derive"] } -solana-pubkey = "4.2.1" wincode = { version = "=0.6.1", features = ["derive"] } -blockzilla-solana-wire = { path = "../../blockzilla-solana-wire", version = "0.2.0", default-features = false } -blockzilla-log-parser = { path = "../../parser/blockzilla-log-parser", version = "0.2.0" } +blockzilla-solana-wire = { path = "../../blockzilla-solana-wire", version = "0.3.0", default-features = false } +blockzilla-log-parser = { path = "../../parser/blockzilla-log-parser", version = "0.3.0" } [lints] workspace = true diff --git a/crates/compact-v2/blockzilla-compact/src/compact/log.rs b/crates/compact-v2/blockzilla-compact/src/compact/log.rs index 4ff99dee..faaf1c62 100644 --- a/crates/compact-v2/blockzilla-compact/src/compact/log.rs +++ b/crates/compact-v2/blockzilla-compact/src/compact/log.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeMap, str::FromStr}; +use std::collections::BTreeMap; use blockzilla_log_parser::{ FailedReason, ParsedLogLine, classify_failed_reason, parse_custom_program_error_reason, @@ -6,11 +6,12 @@ use blockzilla_log_parser::{ }; use data_encoding::BASE64; use serde::{Deserialize, Serialize}; -use solana_pubkey::Pubkey; use wincode::{SchemaRead, SchemaWrite}; -use blockzilla_primitives::{CompactPubkey, PubkeyCompactor, PubkeyResolver}; -use blockzilla_primitives::{DataId, ProgramId, StrId, StringTable}; +use blockzilla_primitives::{ + CompactPubkey, DataId, ProgramId, PubkeyCompactor, PubkeyResolver, StrId, StringTable, + decode_pubkey_base58, +}; use blockzilla_program_logs::{self as program_logs, ProgramLog, system_program}; use blockzilla_registry::KeyIndex; @@ -974,8 +975,8 @@ fn could_be_system_program_log(line: &str) -> bool { } #[inline] -fn pid_to_pubkey(resolver: &R, pid: ProgramId) -> Pubkey { - pid.to_pubkey(resolver) +fn pid_to_pubkey(resolver: &R, pid: ProgramId) -> String { + pid.to_base58(resolver) .unwrap_or_else(|| panic!("log.rs: ProgramId cannot be resolved: pid={pid:?}")) } @@ -1138,7 +1139,7 @@ where }); } ParsedLogLine::UnknownProgram { program } => { - if Pubkey::from_str(program).is_ok() { + if decode_pubkey_base58(program).is_some() { events.push(LogEvent::UnknownProgram { program: st.push(program), }); @@ -1149,7 +1150,7 @@ where } } ParsedLogLine::UnknownAccount { account } => { - if Pubkey::from_str(account).is_ok() { + if decode_pubkey_base58(account).is_some() { events.push(LogEvent::UnknownAccount { account: st.push(account), }); @@ -1856,12 +1857,13 @@ pub fn render_logs( #[cfg(test)] mod tests { use super::*; + use blockzilla_primitives::encode_pubkey_base58; use blockzilla_registry::KeyStore; fn key_index(keys: &[&str]) -> KeyIndex { KeyIndex::build( keys.iter() - .map(|key| *Pubkey::from_str(key).unwrap().as_array()) + .map(|key| decode_pubkey_base58(key).unwrap()) .collect(), ) } @@ -1870,7 +1872,7 @@ mod tests { KeyStore { keys: keys .iter() - .map(|key| *Pubkey::from_str(key).unwrap().as_array()) + .map(|key| decode_pubkey_base58(key).unwrap()) .collect(), } } @@ -1984,8 +1986,7 @@ mod tests { #[test] fn system_debug_address_logs_are_structured() { - let addr_pk = Pubkey::new_from_array([7; 32]); - let addr = addr_pk.to_string(); + let addr = encode_pubkey_base58(&[7; 32]); let index = key_index(&[addr.as_str(), CB_PK]); let store = key_store(&[addr.as_str(), CB_PK]); let line = @@ -2024,8 +2025,7 @@ mod tests { #[test] fn top_level_stake_and_loader_lines_are_structured() { - let program_pk = Pubkey::new_from_array([9; 32]); - let program = program_pk.to_string(); + let program = encode_pubkey_base58(&[9; 32]); let index = key_index(&[program.as_str(), CB_PK]); let store = key_store(&[program.as_str(), CB_PK]); let lines = vec![ @@ -2049,8 +2049,7 @@ mod tests { #[test] fn historical_bpf_loader_lines_are_structured_and_round_trip() { - let program_pk = Pubkey::new_from_array([10; 32]); - let program = program_pk.to_string(); + let program = encode_pubkey_base58(&[10; 32]); let index = key_index(&[program.as_str(), CB_PK]); let store = key_store(&[program.as_str(), CB_PK]); let lines = vec![ @@ -2114,7 +2113,7 @@ mod tests { fn raw_official_program_lines_use_active_program_context() { let stake = program_logs::stake::STR_ID; let loader = program_logs::loader_v3::STR_ID; - let deployed_pk = Pubkey::new_from_array([8; 32]).to_string(); + let deployed_pk = encode_pubkey_base58(&[8; 32]); let index = key_index(&[stake, loader, deployed_pk.as_str(), CB_PK]); let store = key_store(&[stake, loader, deployed_pk.as_str(), CB_PK]); let lines = vec![ @@ -2212,7 +2211,7 @@ mod tests { #[test] fn runtime_privilege_escalation_is_structured() { - let account = Pubkey::new_from_array([3; 32]).to_string(); + let account = encode_pubkey_base58(&[3; 32]); let index = key_index(&[account.as_str(), CB_PK]); let store = key_store(&[account.as_str(), CB_PK]); let lines = vec![ @@ -2240,7 +2239,7 @@ mod tests { #[test] fn no_active_program_official_plain_lines_still_get_binary_forms() { - let deployed_pk = Pubkey::new_from_array([11; 32]).to_string(); + let deployed_pk = encode_pubkey_base58(&[11; 32]); let index = key_index(&[deployed_pk.as_str(), CB_PK]); let store = key_store(&[deployed_pk.as_str(), CB_PK]); let lines = vec![ diff --git a/crates/compact-v2/blockzilla-compact/src/compact/meta.rs b/crates/compact-v2/blockzilla-compact/src/compact/meta.rs index 1a371b94..37a6bd2f 100644 --- a/crates/compact-v2/blockzilla-compact/src/compact/meta.rs +++ b/crates/compact-v2/blockzilla-compact/src/compact/meta.rs @@ -1,20 +1,12 @@ -use anyhow::{Context, Result}; -use blockzilla_solana_wire::metadata_decoder::{ - InnerInstructionVisit, ReturnDataVisit, TokenBalanceVisit, TransactionStatusMetaVisitor, - visit_protobuf_transaction_status_meta, -}; +use anyhow::Result; use blockzilla_solana_wire::stored_transaction::{ InstructionError as StoredInstructionError, StoredTransactionError, }; -use prost::Message; use serde::{Deserialize, Serialize}; -use solana_pubkey::Pubkey; -use std::str::FromStr; use wincode::{SchemaRead, SchemaWrite}; -use crate::{CompactLogReuse, CompactLogStream}; +use crate::CompactLogStream; use blockzilla_primitives::CompactPubkey; -use blockzilla_registry::KeyIndex; #[derive(Debug, Serialize, Deserialize, SchemaRead, SchemaWrite)] pub struct CompactMetaV1 { @@ -379,1192 +371,1211 @@ pub struct CompactReward { pub commission: Option, } -/// Reusable allocation storage for protobuf metadata compaction. -/// -/// Keep one value per worker. After the compact metadata has been encoded or -/// otherwise consumed, pass it to [`Self::recycle`]. A later decode can then -/// reuse its top-level vectors, inner-instruction vectors, return-data buffer, -/// and compact-log storage without synchronization. -#[derive(Debug)] -pub struct CompactMetaReuse { - pre_balances: Vec, - post_balances: Vec, - inner_instructions: Vec, - inner_instruction_lists: Vec>, - inner_instruction_accounts: Vec>, - inner_instruction_data: Vec>, - log_message_ranges: Vec<(usize, usize)>, - pre_token_balances: Vec, - post_token_balances: Vec, - rewards: Vec, - loaded_writable_addresses: Vec, - loaded_readonly_addresses: Vec, - return_data: Vec, - logs: CompactLogReuse, - max_retained_buffer_bytes: usize, -} - -/// Default limit for one retained metadata buffer. -/// -/// The limit applies to each top-level vector. A nested vector pool is also -/// discarded if its total retained capacity exceeds this limit. -pub const DEFAULT_COMPACT_META_MAX_RETAINED_BUFFER_BYTES: usize = 1024 * 1024; - -impl Default for CompactMetaReuse { - fn default() -> Self { - Self::with_max_retained_buffer_bytes(DEFAULT_COMPACT_META_MAX_RETAINED_BUFFER_BYTES) +#[cfg(feature = "protobuf")] +mod protobuf_meta { + use super::*; + use anyhow::Context; + use blockzilla_primitives::decode_pubkey_base58; + use blockzilla_registry::KeyIndex; + use blockzilla_solana_wire::metadata_decoder::{ + InnerInstructionVisit, ReturnDataVisit, TokenBalanceVisit, TransactionStatusMetaVisitor, + visit_protobuf_transaction_status_meta, + }; + use prost::Message; + + use crate::CompactLogReuse; + + /// Reusable allocation storage for protobuf metadata compaction. + /// + /// Keep one value per worker. After the compact metadata has been encoded or + /// otherwise consumed, pass it to [`Self::recycle`]. A later decode can then + /// reuse its top-level vectors, inner-instruction vectors, return-data buffer, + /// and compact-log storage without synchronization. + #[derive(Debug)] + pub struct CompactMetaReuse { + pre_balances: Vec, + post_balances: Vec, + inner_instructions: Vec, + inner_instruction_lists: Vec>, + inner_instruction_accounts: Vec>, + inner_instruction_data: Vec>, + log_message_ranges: Vec<(usize, usize)>, + pre_token_balances: Vec, + post_token_balances: Vec, + rewards: Vec, + loaded_writable_addresses: Vec, + loaded_readonly_addresses: Vec, + return_data: Vec, + logs: CompactLogReuse, + max_retained_buffer_bytes: usize, } -} -impl CompactMetaReuse { - pub fn new() -> Self { - Self::default() - } + /// Default limit for one retained metadata buffer. + /// + /// The limit applies to each top-level vector. A nested vector pool is also + /// discarded if its total retained capacity exceeds this limit. + pub const DEFAULT_COMPACT_META_MAX_RETAINED_BUFFER_BYTES: usize = 1024 * 1024; - pub fn with_max_retained_buffer_bytes(max_retained_buffer_bytes: usize) -> Self { - Self { - pre_balances: Vec::new(), - post_balances: Vec::new(), - inner_instructions: Vec::new(), - inner_instruction_lists: Vec::new(), - inner_instruction_accounts: Vec::new(), - inner_instruction_data: Vec::new(), - log_message_ranges: Vec::new(), - pre_token_balances: Vec::new(), - post_token_balances: Vec::new(), - rewards: Vec::new(), - loaded_writable_addresses: Vec::new(), - loaded_readonly_addresses: Vec::new(), - return_data: Vec::new(), - logs: CompactLogReuse::with_max_retained_buffer_bytes(max_retained_buffer_bytes), - max_retained_buffer_bytes, + impl Default for CompactMetaReuse { + fn default() -> Self { + Self::with_max_retained_buffer_bytes(DEFAULT_COMPACT_META_MAX_RETAINED_BUFFER_BYTES) } } - /// Returns already-consumed compact metadata to this reuse slot. - pub fn recycle(&mut self, mut meta: CompactMetaV1) { - retain_meta_vec( - &mut self.pre_balances, - meta.pre_balances, - self.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.post_balances, - meta.post_balances, - self.max_retained_buffer_bytes, - ); - if let Some(inner_instructions) = meta.inner_instructions.take() { - self.recycle_inner_instructions(inner_instructions); + impl CompactMetaReuse { + pub fn new() -> Self { + Self::default() } - if let Some(logs) = meta.logs.take() { - self.logs.recycle(logs); + + pub fn with_max_retained_buffer_bytes(max_retained_buffer_bytes: usize) -> Self { + Self { + pre_balances: Vec::new(), + post_balances: Vec::new(), + inner_instructions: Vec::new(), + inner_instruction_lists: Vec::new(), + inner_instruction_accounts: Vec::new(), + inner_instruction_data: Vec::new(), + log_message_ranges: Vec::new(), + pre_token_balances: Vec::new(), + post_token_balances: Vec::new(), + rewards: Vec::new(), + loaded_writable_addresses: Vec::new(), + loaded_readonly_addresses: Vec::new(), + return_data: Vec::new(), + logs: CompactLogReuse::with_max_retained_buffer_bytes(max_retained_buffer_bytes), + max_retained_buffer_bytes, + } } - retain_meta_vec( - &mut self.pre_token_balances, - meta.pre_token_balances, - self.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.post_token_balances, - meta.post_token_balances, - self.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.rewards, - meta.rewards, - self.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.loaded_writable_addresses, - meta.loaded_writable_addresses, - self.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.loaded_readonly_addresses, - meta.loaded_readonly_addresses, - self.max_retained_buffer_bytes, - ); - if let Some(return_data) = meta.return_data.take() { + + /// Returns already-consumed compact metadata to this reuse slot. + pub fn recycle(&mut self, mut meta: CompactMetaV1) { + retain_meta_vec( + &mut self.pre_balances, + meta.pre_balances, + self.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.post_balances, + meta.post_balances, + self.max_retained_buffer_bytes, + ); + if let Some(inner_instructions) = meta.inner_instructions.take() { + self.recycle_inner_instructions(inner_instructions); + } + if let Some(logs) = meta.logs.take() { + self.logs.recycle(logs); + } + retain_meta_vec( + &mut self.pre_token_balances, + meta.pre_token_balances, + self.max_retained_buffer_bytes, + ); retain_meta_vec( - &mut self.return_data, - return_data.data, + &mut self.post_token_balances, + meta.post_token_balances, self.max_retained_buffer_bytes, ); + retain_meta_vec( + &mut self.rewards, + meta.rewards, + self.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.loaded_writable_addresses, + meta.loaded_writable_addresses, + self.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.loaded_readonly_addresses, + meta.loaded_readonly_addresses, + self.max_retained_buffer_bytes, + ); + if let Some(return_data) = meta.return_data.take() { + retain_meta_vec( + &mut self.return_data, + return_data.data, + self.max_retained_buffer_bytes, + ); + } } - } - /// Total capacity, in bytes, currently retained by this reuse slot. - pub fn retained_capacity_bytes(&self) -> usize { - let inner_list_bytes = meta_vec_pool_bytes(&self.inner_instruction_lists); - let inner_account_bytes = meta_vec_pool_bytes(&self.inner_instruction_accounts); - let inner_data_bytes = meta_vec_pool_bytes(&self.inner_instruction_data); - - meta_vec_bytes(&self.pre_balances) - .saturating_add(meta_vec_bytes(&self.post_balances)) - .saturating_add(meta_vec_bytes(&self.inner_instructions)) - .saturating_add(inner_list_bytes) - .saturating_add(inner_account_bytes) - .saturating_add(inner_data_bytes) - .saturating_add(meta_vec_bytes(&self.log_message_ranges)) - .saturating_add(meta_vec_bytes(&self.pre_token_balances)) - .saturating_add(meta_vec_bytes(&self.post_token_balances)) - .saturating_add(meta_vec_bytes(&self.rewards)) - .saturating_add(meta_vec_bytes(&self.loaded_writable_addresses)) - .saturating_add(meta_vec_bytes(&self.loaded_readonly_addresses)) - .saturating_add(meta_vec_bytes(&self.return_data)) - .saturating_add(self.logs.retained_capacity_bytes()) - } + /// Total capacity, in bytes, currently retained by this reuse slot. + pub fn retained_capacity_bytes(&self) -> usize { + let inner_list_bytes = meta_vec_pool_bytes(&self.inner_instruction_lists); + let inner_account_bytes = meta_vec_pool_bytes(&self.inner_instruction_accounts); + let inner_data_bytes = meta_vec_pool_bytes(&self.inner_instruction_data); + + meta_vec_bytes(&self.pre_balances) + .saturating_add(meta_vec_bytes(&self.post_balances)) + .saturating_add(meta_vec_bytes(&self.inner_instructions)) + .saturating_add(inner_list_bytes) + .saturating_add(inner_account_bytes) + .saturating_add(inner_data_bytes) + .saturating_add(meta_vec_bytes(&self.log_message_ranges)) + .saturating_add(meta_vec_bytes(&self.pre_token_balances)) + .saturating_add(meta_vec_bytes(&self.post_token_balances)) + .saturating_add(meta_vec_bytes(&self.rewards)) + .saturating_add(meta_vec_bytes(&self.loaded_writable_addresses)) + .saturating_add(meta_vec_bytes(&self.loaded_readonly_addresses)) + .saturating_add(meta_vec_bytes(&self.return_data)) + .saturating_add(self.logs.retained_capacity_bytes()) + } - fn recycle_inner_instructions( - &mut self, - mut inner_instructions: Vec, - ) { - for group in inner_instructions.drain(..) { - let mut instructions = group.instructions; - for instruction in instructions.drain(..) { + fn recycle_inner_instructions( + &mut self, + mut inner_instructions: Vec, + ) { + for group in inner_instructions.drain(..) { + let mut instructions = group.instructions; + for instruction in instructions.drain(..) { + retain_meta_vec_in_pool( + &mut self.inner_instruction_accounts, + instruction.accounts, + self.max_retained_buffer_bytes, + ); + retain_meta_vec_in_pool( + &mut self.inner_instruction_data, + instruction.data, + self.max_retained_buffer_bytes, + ); + } retain_meta_vec_in_pool( - &mut self.inner_instruction_accounts, - instruction.accounts, - self.max_retained_buffer_bytes, - ); - retain_meta_vec_in_pool( - &mut self.inner_instruction_data, - instruction.data, + &mut self.inner_instruction_lists, + instructions, self.max_retained_buffer_bytes, ); } - retain_meta_vec_in_pool( + retain_meta_vec( + &mut self.inner_instructions, + inner_instructions, + self.max_retained_buffer_bytes, + ); + trim_meta_vec_pool( &mut self.inner_instruction_lists, - instructions, + self.max_retained_buffer_bytes, + ); + trim_meta_vec_pool( + &mut self.inner_instruction_accounts, + self.max_retained_buffer_bytes, + ); + trim_meta_vec_pool( + &mut self.inner_instruction_data, self.max_retained_buffer_bytes, ); } - retain_meta_vec( - &mut self.inner_instructions, - inner_instructions, - self.max_retained_buffer_bytes, - ); - trim_meta_vec_pool( - &mut self.inner_instruction_lists, - self.max_retained_buffer_bytes, - ); - trim_meta_vec_pool( - &mut self.inner_instruction_accounts, - self.max_retained_buffer_bytes, - ); - trim_meta_vec_pool( - &mut self.inner_instruction_data, - self.max_retained_buffer_bytes, - ); - } -} - -#[inline] -fn meta_vec_bytes(values: &Vec) -> usize { - values.capacity().saturating_mul(std::mem::size_of::()) -} - -#[inline] -fn retain_meta_vec(slot: &mut Vec, mut values: Vec, max_bytes: usize) { - values.clear(); - if meta_vec_bytes(&values) > max_bytes { - return; - } - if values.capacity() > slot.capacity() { - *slot = values; } -} -#[inline] -fn retain_meta_vec_in_pool(pool: &mut Vec>, mut values: Vec, max_bytes: usize) { - values.clear(); - if meta_vec_bytes(&values) <= max_bytes { - pool.push(values); + #[inline] + fn meta_vec_bytes(values: &Vec) -> usize { + values.capacity().saturating_mul(std::mem::size_of::()) } -} -#[inline] -fn trim_meta_vec_pool(pool: &mut Vec>, max_bytes: usize) { - if meta_vec_pool_bytes(pool) > max_bytes { - *pool = Vec::new(); + #[inline] + fn retain_meta_vec(slot: &mut Vec, mut values: Vec, max_bytes: usize) { + values.clear(); + if meta_vec_bytes(&values) > max_bytes { + return; + } + if values.capacity() > slot.capacity() { + *slot = values; + } } -} - -#[inline] -fn meta_vec_pool_bytes(pool: &Vec>) -> usize { - pool.iter().fold(meta_vec_bytes(pool), |total, values| { - total.saturating_add(meta_vec_bytes(values)) - }) -} - -pub fn compact_meta_from_proto( - meta: &blockzilla_solana_wire::confirmed_block::TransactionStatusMeta, - index: &KeyIndex, -) -> Result { - let err = meta - .err - .as_ref() - .map(|e| CompactTransactionError::from_stored_wincode_bytes(&e.err)) - .transpose()?; - - let loaded_writable_addresses = meta - .loaded_writable_addresses - .iter() - .map(|a| index.compact(a.as_slice().try_into().unwrap())) - .collect(); - let loaded_readonly_addresses = meta - .loaded_readonly_addresses - .iter() - .map(|a| index.compact(a.as_slice().try_into().unwrap())) - .collect(); - - let inner_instructions = if meta.inner_instructions_none { - None - } else { - Some( - meta.inner_instructions - .iter() - .map(|ii| CompactInnerInstructions { - index: ii.index, - instructions: ii - .instructions - .iter() - .map(|ix| CompactInnerInstruction { - program_id_index: ix.program_id_index, - accounts: ix.accounts.to_vec(), - data: ix.data.to_vec(), - stack_height: ix.stack_height, - }) - .collect(), - }) - .collect(), - ) - }; - - let logs = if meta.log_messages_none { - None - } else { - Some(crate::log::parse_logs(&meta.log_messages, index)) - }; - - let pre_token_balances = meta - .pre_token_balances - .iter() - .map(|tb| compact_token_balance(tb, index)) - .collect::>>()?; - - let post_token_balances = meta - .post_token_balances - .iter() - .map(|tb| compact_token_balance(tb, index)) - .collect::>>()?; - - let rewards = meta - .rewards - .iter() - .map(|rw| compact_reward(rw, index)) - .collect::>>()?; - - let return_data = if meta.return_data_none { - None - } else { - meta.return_data - .as_ref() - .map(|rd| -> Result { - Ok(CompactReturnData { - program_id: index.compact(rd.program_id.as_slice().try_into().unwrap()), - data: rd.data.clone(), - }) - }) - .transpose()? - }; - - Ok(CompactMetaV1 { - err, - - fee: meta.fee, - pre_balances: meta.pre_balances.to_vec(), - post_balances: meta.post_balances.to_vec(), - - inner_instructions, - logs, - - pre_token_balances, - post_token_balances, - - rewards, - - loaded_writable_addresses, - loaded_readonly_addresses, - - return_data, - - compute_units_consumed: meta.compute_units_consumed, - cost_units: meta.cost_units, - }) -} - -pub fn compact_meta_from_protobuf_visit(bytes: &[u8], index: &KeyIndex) -> Result { - let mut reuse = CompactMetaReuse::new(); - compact_meta_from_protobuf_visit_reusing(bytes, index, &mut reuse) -} -/// Compacts protobuf metadata with caller-owned reusable allocation storage. -/// -/// The returned metadata owns its vectors. Call [`CompactMetaReuse::recycle`] -/// after the metadata has been encoded or otherwise consumed. -pub fn compact_meta_from_protobuf_visit_reusing( - bytes: &[u8], - index: &KeyIndex, - reuse: &mut CompactMetaReuse, -) -> Result { - let mut visitor = CompactMetaVisitor::new(bytes, index, reuse); - visit_protobuf_transaction_status_meta(bytes, &mut visitor) - .map_err(|err| anyhow::anyhow!("protobuf visit: {err}"))?; - visitor.finish() -} - -const BALANCES_RESERVE: usize = 32; -const INNER_INSTRUCTION_GROUPS_RESERVE: usize = 4; -const INNER_INSTRUCTIONS_PER_GROUP_RESERVE: usize = 4; -const LOG_MESSAGES_RESERVE: usize = 16; -const TOKEN_BALANCES_RESERVE: usize = 8; -const REWARDS_RESERVE: usize = 1; -const LOADED_ADDRESSES_RESERVE: usize = 8; - -#[inline] -fn reserve_on_first(values: &mut Vec, additional: usize) { - if values.capacity() == 0 { - values.reserve(additional); + #[inline] + fn retain_meta_vec_in_pool(pool: &mut Vec>, mut values: Vec, max_bytes: usize) { + values.clear(); + if meta_vec_bytes(&values) <= max_bytes { + pool.push(values); + } } -} -struct CompactMetaVisitor<'index, 'metadata, 'reuse> { - metadata: &'metadata [u8], - index: &'index KeyIndex, - reuse: &'reuse mut CompactMetaReuse, - err: Option, - fee: u64, - pre_balances: Vec, - post_balances: Vec, - inner_instructions: Vec, - inner_instructions_none: bool, - log_message_ranges: Vec<(usize, usize)>, - log_messages_none: bool, - pre_token_balances: Vec, - post_token_balances: Vec, - rewards: Vec, - loaded_writable_addresses: Vec, - loaded_readonly_addresses: Vec, - return_data_program_id: Option, - return_data: Vec, - return_data_none: bool, - compute_units_consumed: Option, - cost_units: Option, - error: Option, -} - -impl<'index, 'metadata, 'reuse> CompactMetaVisitor<'index, 'metadata, 'reuse> { - fn new( - metadata: &'metadata [u8], - index: &'index KeyIndex, - reuse: &'reuse mut CompactMetaReuse, - ) -> Self { - let pre_balances = std::mem::take(&mut reuse.pre_balances); - let post_balances = std::mem::take(&mut reuse.post_balances); - let inner_instructions = std::mem::take(&mut reuse.inner_instructions); - let log_message_ranges = std::mem::take(&mut reuse.log_message_ranges); - let pre_token_balances = std::mem::take(&mut reuse.pre_token_balances); - let post_token_balances = std::mem::take(&mut reuse.post_token_balances); - let rewards = std::mem::take(&mut reuse.rewards); - let loaded_writable_addresses = std::mem::take(&mut reuse.loaded_writable_addresses); - let loaded_readonly_addresses = std::mem::take(&mut reuse.loaded_readonly_addresses); - let return_data = std::mem::take(&mut reuse.return_data); - - Self { - metadata, - index, - reuse, - err: None, - fee: 0, - pre_balances, - post_balances, - inner_instructions, - inner_instructions_none: false, - log_message_ranges, - log_messages_none: false, - pre_token_balances, - post_token_balances, - rewards, - loaded_writable_addresses, - loaded_readonly_addresses, - return_data_program_id: None, - return_data, - return_data_none: false, - compute_units_consumed: None, - cost_units: None, - error: None, + #[inline] + fn trim_meta_vec_pool(pool: &mut Vec>, max_bytes: usize) { + if meta_vec_pool_bytes(pool) > max_bytes { + *pool = Vec::new(); } } - fn record_error(&mut self, err: anyhow::Error) { - if self.error.is_none() { - self.error = Some(err); - } + #[inline] + fn meta_vec_pool_bytes(pool: &Vec>) -> usize { + pool.iter().fold(meta_vec_bytes(pool), |total, values| { + total.saturating_add(meta_vec_bytes(values)) + }) } - fn finish(&mut self) -> Result { - if let Some(err) = self.error.take() { - return Err(err); - } + pub fn compact_meta_from_proto( + meta: &blockzilla_solana_wire::confirmed_block::TransactionStatusMeta, + index: &KeyIndex, + ) -> Result { + let err = meta + .err + .as_ref() + .map(|e| CompactTransactionError::from_stored_wincode_bytes(&e.err)) + .transpose()?; + + let loaded_writable_addresses = meta + .loaded_writable_addresses + .iter() + .map(|a| index.compact(a.as_slice().try_into().unwrap())) + .collect(); + let loaded_readonly_addresses = meta + .loaded_readonly_addresses + .iter() + .map(|a| index.compact(a.as_slice().try_into().unwrap())) + .collect(); - let inner_instructions = if self.inner_instructions_none { + let inner_instructions = if meta.inner_instructions_none { None } else { - Some(std::mem::take(&mut self.inner_instructions)) + Some( + meta.inner_instructions + .iter() + .map(|ii| CompactInnerInstructions { + index: ii.index, + instructions: ii + .instructions + .iter() + .map(|ix| CompactInnerInstruction { + program_id_index: ix.program_id_index, + accounts: ix.accounts.to_vec(), + data: ix.data.to_vec(), + stack_height: ix.stack_height, + }) + .collect(), + }) + .collect(), + ) }; - let logs = if self.log_messages_none { + + let logs = if meta.log_messages_none { None } else { - let metadata = self.metadata; - let lines = self.log_message_ranges.iter().map(|&(start, end)| { - std::str::from_utf8(&metadata[start..end]) - .expect("protobuf visitor supplied valid utf-8 log text") - }); - Some(crate::log::parse_log_iter_with_compactor_reusing( - lines, - self.log_message_ranges.len(), - self.index, - None, - &mut self.reuse.logs, - )) + Some(crate::log::parse_logs(&meta.log_messages, index)) }; - let return_data = if self.return_data_none { + + let pre_token_balances = meta + .pre_token_balances + .iter() + .map(|tb| compact_token_balance(tb, index)) + .collect::>>()?; + + let post_token_balances = meta + .post_token_balances + .iter() + .map(|tb| compact_token_balance(tb, index)) + .collect::>>()?; + + let rewards = meta + .rewards + .iter() + .map(|rw| compact_reward(rw, index)) + .collect::>>()?; + + let return_data = if meta.return_data_none { None } else { - self.return_data_program_id - .take() - .map(|program_id| CompactReturnData { - program_id, - data: std::mem::take(&mut self.return_data), + meta.return_data + .as_ref() + .map(|rd| -> Result { + Ok(CompactReturnData { + program_id: index.compact(rd.program_id.as_slice().try_into().unwrap()), + data: rd.data.clone(), + }) }) + .transpose()? }; Ok(CompactMetaV1 { - err: self.err.take(), - fee: self.fee, - pre_balances: std::mem::take(&mut self.pre_balances), - post_balances: std::mem::take(&mut self.post_balances), + err, + + fee: meta.fee, + pre_balances: meta.pre_balances.to_vec(), + post_balances: meta.post_balances.to_vec(), + inner_instructions, logs, - pre_token_balances: std::mem::take(&mut self.pre_token_balances), - post_token_balances: std::mem::take(&mut self.post_token_balances), - rewards: std::mem::take(&mut self.rewards), - loaded_writable_addresses: std::mem::take(&mut self.loaded_writable_addresses), - loaded_readonly_addresses: std::mem::take(&mut self.loaded_readonly_addresses), + + pre_token_balances, + post_token_balances, + + rewards, + + loaded_writable_addresses, + loaded_readonly_addresses, + return_data, - compute_units_consumed: self.compute_units_consumed, - cost_units: self.cost_units, + + compute_units_consumed: meta.compute_units_consumed, + cost_units: meta.cost_units, }) } -} -impl Drop for CompactMetaVisitor<'_, '_, '_> { - fn drop(&mut self) { - self.reuse - .recycle_inner_instructions(std::mem::take(&mut self.inner_instructions)); - retain_meta_vec( - &mut self.reuse.pre_balances, - std::mem::take(&mut self.pre_balances), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.post_balances, - std::mem::take(&mut self.post_balances), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.log_message_ranges, - std::mem::take(&mut self.log_message_ranges), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.pre_token_balances, - std::mem::take(&mut self.pre_token_balances), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.post_token_balances, - std::mem::take(&mut self.post_token_balances), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.rewards, - std::mem::take(&mut self.rewards), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.loaded_writable_addresses, - std::mem::take(&mut self.loaded_writable_addresses), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.loaded_readonly_addresses, - std::mem::take(&mut self.loaded_readonly_addresses), - self.reuse.max_retained_buffer_bytes, - ); - retain_meta_vec( - &mut self.reuse.return_data, - std::mem::take(&mut self.return_data), - self.reuse.max_retained_buffer_bytes, - ); + pub fn compact_meta_from_protobuf_visit( + bytes: &[u8], + index: &KeyIndex, + ) -> Result { + let mut reuse = CompactMetaReuse::new(); + compact_meta_from_protobuf_visit_reusing(bytes, index, &mut reuse) } -} -impl<'index, 'metadata, 'reuse> TransactionStatusMetaVisitor<'metadata> - for CompactMetaVisitor<'index, 'metadata, 'reuse> -{ - #[inline] - fn wants_status_error(&self) -> bool { - true + /// Compacts protobuf metadata with caller-owned reusable allocation storage. + /// + /// The returned metadata owns its vectors. Call [`CompactMetaReuse::recycle`] + /// after the metadata has been encoded or otherwise consumed. + pub fn compact_meta_from_protobuf_visit_reusing( + bytes: &[u8], + index: &KeyIndex, + reuse: &mut CompactMetaReuse, + ) -> Result { + let mut visitor = CompactMetaVisitor::new(bytes, index, reuse); + visit_protobuf_transaction_status_meta(bytes, &mut visitor) + .map_err(|err| anyhow::anyhow!("protobuf visit: {err}"))?; + visitor.finish() } - #[inline] - fn wants_pre_balances(&self) -> bool { - true - } + const BALANCES_RESERVE: usize = 32; + const INNER_INSTRUCTION_GROUPS_RESERVE: usize = 4; + const INNER_INSTRUCTIONS_PER_GROUP_RESERVE: usize = 4; + const LOG_MESSAGES_RESERVE: usize = 16; + const TOKEN_BALANCES_RESERVE: usize = 8; + const REWARDS_RESERVE: usize = 1; + const LOADED_ADDRESSES_RESERVE: usize = 8; #[inline] - fn wants_post_balances(&self) -> bool { - true + fn reserve_on_first(values: &mut Vec, additional: usize) { + if values.capacity() == 0 { + values.reserve(additional); + } } - #[inline] - fn wants_inner_instructions(&self) -> bool { - true + struct CompactMetaVisitor<'index, 'metadata, 'reuse> { + metadata: &'metadata [u8], + index: &'index KeyIndex, + reuse: &'reuse mut CompactMetaReuse, + err: Option, + fee: u64, + pre_balances: Vec, + post_balances: Vec, + inner_instructions: Vec, + inner_instructions_none: bool, + log_message_ranges: Vec<(usize, usize)>, + log_messages_none: bool, + pre_token_balances: Vec, + post_token_balances: Vec, + rewards: Vec, + loaded_writable_addresses: Vec, + loaded_readonly_addresses: Vec, + return_data_program_id: Option, + return_data: Vec, + return_data_none: bool, + compute_units_consumed: Option, + cost_units: Option, + error: Option, } - #[inline] - fn wants_log_messages(&self) -> bool { - true - } + impl<'index, 'metadata, 'reuse> CompactMetaVisitor<'index, 'metadata, 'reuse> { + fn new( + metadata: &'metadata [u8], + index: &'index KeyIndex, + reuse: &'reuse mut CompactMetaReuse, + ) -> Self { + let pre_balances = std::mem::take(&mut reuse.pre_balances); + let post_balances = std::mem::take(&mut reuse.post_balances); + let inner_instructions = std::mem::take(&mut reuse.inner_instructions); + let log_message_ranges = std::mem::take(&mut reuse.log_message_ranges); + let pre_token_balances = std::mem::take(&mut reuse.pre_token_balances); + let post_token_balances = std::mem::take(&mut reuse.post_token_balances); + let rewards = std::mem::take(&mut reuse.rewards); + let loaded_writable_addresses = std::mem::take(&mut reuse.loaded_writable_addresses); + let loaded_readonly_addresses = std::mem::take(&mut reuse.loaded_readonly_addresses); + let return_data = std::mem::take(&mut reuse.return_data); + + Self { + metadata, + index, + reuse, + err: None, + fee: 0, + pre_balances, + post_balances, + inner_instructions, + inner_instructions_none: false, + log_message_ranges, + log_messages_none: false, + pre_token_balances, + post_token_balances, + rewards, + loaded_writable_addresses, + loaded_readonly_addresses, + return_data_program_id: None, + return_data, + return_data_none: false, + compute_units_consumed: None, + cost_units: None, + error: None, + } + } - #[inline] - fn wants_pre_token_balances(&self) -> bool { - true - } + fn record_error(&mut self, err: anyhow::Error) { + if self.error.is_none() { + self.error = Some(err); + } + } - #[inline] - fn wants_post_token_balances(&self) -> bool { - true - } + fn finish(&mut self) -> Result { + if let Some(err) = self.error.take() { + return Err(err); + } - #[inline] - fn wants_rewards(&self) -> bool { - true + let inner_instructions = if self.inner_instructions_none { + None + } else { + Some(std::mem::take(&mut self.inner_instructions)) + }; + let logs = if self.log_messages_none { + None + } else { + let metadata = self.metadata; + let lines = self.log_message_ranges.iter().map(|&(start, end)| { + std::str::from_utf8(&metadata[start..end]) + .expect("protobuf visitor supplied valid utf-8 log text") + }); + Some(crate::log::parse_log_iter_with_compactor_reusing( + lines, + self.log_message_ranges.len(), + self.index, + None, + &mut self.reuse.logs, + )) + }; + let return_data = if self.return_data_none { + None + } else { + self.return_data_program_id + .take() + .map(|program_id| CompactReturnData { + program_id, + data: std::mem::take(&mut self.return_data), + }) + }; + + Ok(CompactMetaV1 { + err: self.err.take(), + fee: self.fee, + pre_balances: std::mem::take(&mut self.pre_balances), + post_balances: std::mem::take(&mut self.post_balances), + inner_instructions, + logs, + pre_token_balances: std::mem::take(&mut self.pre_token_balances), + post_token_balances: std::mem::take(&mut self.post_token_balances), + rewards: std::mem::take(&mut self.rewards), + loaded_writable_addresses: std::mem::take(&mut self.loaded_writable_addresses), + loaded_readonly_addresses: std::mem::take(&mut self.loaded_readonly_addresses), + return_data, + compute_units_consumed: self.compute_units_consumed, + cost_units: self.cost_units, + }) + } } - #[inline] - fn wants_loaded_addresses(&self) -> bool { - true + impl Drop for CompactMetaVisitor<'_, '_, '_> { + fn drop(&mut self) { + self.reuse + .recycle_inner_instructions(std::mem::take(&mut self.inner_instructions)); + retain_meta_vec( + &mut self.reuse.pre_balances, + std::mem::take(&mut self.pre_balances), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.post_balances, + std::mem::take(&mut self.post_balances), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.log_message_ranges, + std::mem::take(&mut self.log_message_ranges), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.pre_token_balances, + std::mem::take(&mut self.pre_token_balances), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.post_token_balances, + std::mem::take(&mut self.post_token_balances), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.rewards, + std::mem::take(&mut self.rewards), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.loaded_writable_addresses, + std::mem::take(&mut self.loaded_writable_addresses), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.loaded_readonly_addresses, + std::mem::take(&mut self.loaded_readonly_addresses), + self.reuse.max_retained_buffer_bytes, + ); + retain_meta_vec( + &mut self.reuse.return_data, + std::mem::take(&mut self.return_data), + self.reuse.max_retained_buffer_bytes, + ); + } } - #[inline] - fn wants_return_data(&self) -> bool { - true - } + impl<'index, 'metadata, 'reuse> TransactionStatusMetaVisitor<'metadata> + for CompactMetaVisitor<'index, 'metadata, 'reuse> + { + #[inline] + fn wants_status_error(&self) -> bool { + true + } - #[inline] - fn status_error(&mut self, err: &'metadata [u8]) { - match CompactTransactionError::from_stored_wincode_bytes(err) { - Ok(err) => self.err = Some(err), - Err(err) => self.record_error(err), + #[inline] + fn wants_pre_balances(&self) -> bool { + true } - } - #[inline] - fn fee(&mut self, fee: u64) { - self.fee = fee; - } + #[inline] + fn wants_post_balances(&self) -> bool { + true + } - #[inline] - fn pre_balance(&mut self, _index: usize, lamports: u64) { - reserve_on_first(&mut self.pre_balances, BALANCES_RESERVE); - self.pre_balances.push(lamports); - } + #[inline] + fn wants_inner_instructions(&self) -> bool { + true + } - #[inline] - fn post_balance(&mut self, _index: usize, lamports: u64) { - reserve_on_first(&mut self.post_balances, BALANCES_RESERVE); - self.post_balances.push(lamports); - } + #[inline] + fn wants_log_messages(&self) -> bool { + true + } - #[inline] - fn inner_instruction(&mut self, instruction: InnerInstructionVisit<'metadata>) { - if self - .inner_instructions - .last() - .is_none_or(|group| group.index != instruction.outer_instruction_index) - { - reserve_on_first( - &mut self.inner_instructions, - INNER_INSTRUCTION_GROUPS_RESERVE, - ); - let mut instructions = self - .reuse - .inner_instruction_lists - .pop() - .unwrap_or_else(|| Vec::with_capacity(INNER_INSTRUCTIONS_PER_GROUP_RESERVE)); - instructions.clear(); - self.inner_instructions.push(CompactInnerInstructions { - index: instruction.outer_instruction_index, - instructions, - }); + #[inline] + fn wants_pre_token_balances(&self) -> bool { + true } - let Some(group) = self.inner_instructions.last_mut() else { - return; - }; - let mut accounts = self - .reuse - .inner_instruction_accounts - .pop() - .unwrap_or_default(); - accounts.clear(); - accounts.extend_from_slice(instruction.accounts); - let mut data = self.reuse.inner_instruction_data.pop().unwrap_or_default(); - data.clear(); - data.extend_from_slice(instruction.data); - group.instructions.push(CompactInnerInstruction { - program_id_index: instruction.program_id_index, - accounts, - data, - stack_height: instruction.stack_height, - }); - } + #[inline] + fn wants_post_token_balances(&self) -> bool { + true + } - #[inline] - fn inner_instructions_none(&mut self, none: bool) { - self.inner_instructions_none = none; - } + #[inline] + fn wants_rewards(&self) -> bool { + true + } - #[inline] - fn log_message(&mut self, message: &'metadata str) { - reserve_on_first(&mut self.log_message_ranges, LOG_MESSAGES_RESERVE); - if message.is_empty() { - self.log_message_ranges.push((0, 0)); - return; + #[inline] + fn wants_loaded_addresses(&self) -> bool { + true } - let metadata_start = self.metadata.as_ptr() as usize; - let message_start = message.as_ptr() as usize; - let Some(start) = message_start.checked_sub(metadata_start) else { - self.record_error(anyhow::anyhow!( - "protobuf log text is outside the metadata input" - )); - return; - }; - let Some(end) = start.checked_add(message.len()) else { - self.record_error(anyhow::anyhow!("protobuf log text range overflow")); - return; - }; - if end > self.metadata.len() { - self.record_error(anyhow::anyhow!( - "protobuf log text is outside the metadata input" - )); - return; + #[inline] + fn wants_return_data(&self) -> bool { + true } - self.log_message_ranges.push((start, end)); - } - #[inline] - fn log_messages_none(&mut self, none: bool) { - self.log_messages_none = none; - } + #[inline] + fn status_error(&mut self, err: &'metadata [u8]) { + match CompactTransactionError::from_stored_wincode_bytes(err) { + Ok(err) => self.err = Some(err), + Err(err) => self.record_error(err), + } + } - #[inline] - fn pre_token_balance(&mut self, balance: TokenBalanceVisit<'metadata>) { - reserve_on_first(&mut self.pre_token_balances, TOKEN_BALANCES_RESERVE); - match compact_token_balance_visit(balance, self.index) { - Ok(balance) => self.pre_token_balances.push(balance), - Err(err) => self.record_error(err), + #[inline] + fn fee(&mut self, fee: u64) { + self.fee = fee; } - } - #[inline] - fn post_token_balance(&mut self, balance: TokenBalanceVisit<'metadata>) { - reserve_on_first(&mut self.post_token_balances, TOKEN_BALANCES_RESERVE); - match compact_token_balance_visit(balance, self.index) { - Ok(balance) => self.post_token_balances.push(balance), - Err(err) => self.record_error(err), + #[inline] + fn pre_balance(&mut self, _index: usize, lamports: u64) { + reserve_on_first(&mut self.pre_balances, BALANCES_RESERVE); + self.pre_balances.push(lamports); } - } - #[inline] - fn reward_raw(&mut self, bytes: &'metadata [u8]) { - reserve_on_first(&mut self.rewards, REWARDS_RESERVE); - match blockzilla_solana_wire::confirmed_block::Reward::decode(bytes) - .map_err(anyhow::Error::from) - .and_then(|reward| compact_reward(&reward, self.index)) - { - Ok(reward) => self.rewards.push(reward), - Err(err) => self.record_error(err), + #[inline] + fn post_balance(&mut self, _index: usize, lamports: u64) { + reserve_on_first(&mut self.post_balances, BALANCES_RESERVE); + self.post_balances.push(lamports); } - } - #[inline] - fn loaded_writable_address(&mut self, address: &'metadata [u8]) { - reserve_on_first( - &mut self.loaded_writable_addresses, - LOADED_ADDRESSES_RESERVE, - ); - match address.try_into() { - Ok(address) => self - .loaded_writable_addresses - .push(self.index.compact(address)), - Err(_) => self.record_error(anyhow::anyhow!( - "invalid writable loaded address len {}", - address.len() - )), + #[inline] + fn inner_instruction(&mut self, instruction: InnerInstructionVisit<'metadata>) { + if self + .inner_instructions + .last() + .is_none_or(|group| group.index != instruction.outer_instruction_index) + { + reserve_on_first( + &mut self.inner_instructions, + INNER_INSTRUCTION_GROUPS_RESERVE, + ); + let mut instructions = + self.reuse.inner_instruction_lists.pop().unwrap_or_else(|| { + Vec::with_capacity(INNER_INSTRUCTIONS_PER_GROUP_RESERVE) + }); + instructions.clear(); + self.inner_instructions.push(CompactInnerInstructions { + index: instruction.outer_instruction_index, + instructions, + }); + } + + let Some(group) = self.inner_instructions.last_mut() else { + return; + }; + let mut accounts = self + .reuse + .inner_instruction_accounts + .pop() + .unwrap_or_default(); + accounts.clear(); + accounts.extend_from_slice(instruction.accounts); + let mut data = self.reuse.inner_instruction_data.pop().unwrap_or_default(); + data.clear(); + data.extend_from_slice(instruction.data); + group.instructions.push(CompactInnerInstruction { + program_id_index: instruction.program_id_index, + accounts, + data, + stack_height: instruction.stack_height, + }); } - } - #[inline] - fn loaded_readonly_address(&mut self, address: &'metadata [u8]) { - reserve_on_first( - &mut self.loaded_readonly_addresses, - LOADED_ADDRESSES_RESERVE, - ); - match address.try_into() { - Ok(address) => self - .loaded_readonly_addresses - .push(self.index.compact(address)), - Err(_) => self.record_error(anyhow::anyhow!( - "invalid readonly loaded address len {}", - address.len() - )), + #[inline] + fn inner_instructions_none(&mut self, none: bool) { + self.inner_instructions_none = none; } - } - #[inline] - fn return_data(&mut self, return_data: ReturnDataVisit<'metadata>) { - match return_data.program_id.try_into() { - Ok(program_id) => { - self.return_data_program_id = Some(self.index.compact(program_id)); - self.return_data.clear(); - self.return_data.extend_from_slice(return_data.data); + #[inline] + fn log_message(&mut self, message: &'metadata str) { + reserve_on_first(&mut self.log_message_ranges, LOG_MESSAGES_RESERVE); + if message.is_empty() { + self.log_message_ranges.push((0, 0)); + return; } - Err(_) => self.record_error(anyhow::anyhow!( - "invalid return data program id len {}", - return_data.program_id.len() - )), - } - } - #[inline] - fn return_data_none(&mut self, none: bool) { - self.return_data_none = none; - } + let metadata_start = self.metadata.as_ptr() as usize; + let message_start = message.as_ptr() as usize; + let Some(start) = message_start.checked_sub(metadata_start) else { + self.record_error(anyhow::anyhow!( + "protobuf log text is outside the metadata input" + )); + return; + }; + let Some(end) = start.checked_add(message.len()) else { + self.record_error(anyhow::anyhow!("protobuf log text range overflow")); + return; + }; + if end > self.metadata.len() { + self.record_error(anyhow::anyhow!( + "protobuf log text is outside the metadata input" + )); + return; + } + self.log_message_ranges.push((start, end)); + } - #[inline] - fn compute_units_consumed(&mut self, units: u64) { - self.compute_units_consumed = Some(units); - } + #[inline] + fn log_messages_none(&mut self, none: bool) { + self.log_messages_none = none; + } - #[inline] - fn cost_units(&mut self, units: u64) { - self.cost_units = Some(units); - } -} + #[inline] + fn pre_token_balance(&mut self, balance: TokenBalanceVisit<'metadata>) { + reserve_on_first(&mut self.pre_token_balances, TOKEN_BALANCES_RESERVE); + match compact_token_balance_visit(balance, self.index) { + Ok(balance) => self.pre_token_balances.push(balance), + Err(err) => self.record_error(err), + } + } -#[inline] -fn compact_pubkey_optional(index: &KeyIndex, s: &str) -> Option { - if s.is_empty() { - return None; - } - index.compact_str(s) -} + #[inline] + fn post_token_balance(&mut self, balance: TokenBalanceVisit<'metadata>) { + reserve_on_first(&mut self.post_token_balances, TOKEN_BALANCES_RESERVE); + match compact_token_balance_visit(balance, self.index) { + Ok(balance) => self.post_token_balances.push(balance), + Err(err) => self.record_error(err), + } + } -fn compact_token_balance( - tb: &blockzilla_solana_wire::confirmed_block::TokenBalance, - index: &KeyIndex, -) -> Result { - let mint = compact_pubkey_optional(index, &tb.mint); - let owner = compact_pubkey_optional(index, &tb.owner); - let program_id = compact_pubkey_optional(index, &tb.program_id); - - let (amount, decimals) = match &tb.ui_token_amount { - None => (0u64, 0u8), - Some(uta) => { - let amount = uta - .amount - .parse::() - .context("parse token amount u64")?; - (amount, uta.decimals as u8) + #[inline] + fn reward_raw(&mut self, bytes: &'metadata [u8]) { + reserve_on_first(&mut self.rewards, REWARDS_RESERVE); + match blockzilla_solana_wire::confirmed_block::Reward::decode(bytes) + .map_err(anyhow::Error::from) + .and_then(|reward| compact_reward(&reward, self.index)) + { + Ok(reward) => self.rewards.push(reward), + Err(err) => self.record_error(err), + } } - }; - Ok(CompactTokenBalance { - account_index: tb.account_index, - mint, - owner, - program_id, - amount, - decimals, - }) -} + #[inline] + fn loaded_writable_address(&mut self, address: &'metadata [u8]) { + reserve_on_first( + &mut self.loaded_writable_addresses, + LOADED_ADDRESSES_RESERVE, + ); + match address.try_into() { + Ok(address) => self + .loaded_writable_addresses + .push(self.index.compact(address)), + Err(_) => self.record_error(anyhow::anyhow!( + "invalid writable loaded address len {}", + address.len() + )), + } + } -fn compact_token_balance_visit( - tb: TokenBalanceVisit<'_>, - index: &KeyIndex, -) -> Result { - let mint = compact_pubkey_optional(index, tb.mint); - let owner = compact_pubkey_optional(index, tb.owner); - let program_id = compact_pubkey_optional(index, tb.program_id); - - let (amount, decimals) = match tb.ui_token_amount { - None => (0u64, 0u8), - Some(uta) => { - let amount = uta - .amount - .parse::() - .context("parse token amount u64")?; - (amount, uta.decimals as u8) + #[inline] + fn loaded_readonly_address(&mut self, address: &'metadata [u8]) { + reserve_on_first( + &mut self.loaded_readonly_addresses, + LOADED_ADDRESSES_RESERVE, + ); + match address.try_into() { + Ok(address) => self + .loaded_readonly_addresses + .push(self.index.compact(address)), + Err(_) => self.record_error(anyhow::anyhow!( + "invalid readonly loaded address len {}", + address.len() + )), + } } - }; - Ok(CompactTokenBalance { - account_index: tb.account_index, - mint, - owner, - program_id, - amount, - decimals, - }) -} + #[inline] + fn return_data(&mut self, return_data: ReturnDataVisit<'metadata>) { + match return_data.program_id.try_into() { + Ok(program_id) => { + self.return_data_program_id = Some(self.index.compact(program_id)); + self.return_data.clear(); + self.return_data.extend_from_slice(return_data.data); + } + Err(_) => self.record_error(anyhow::anyhow!( + "invalid return data program id len {}", + return_data.program_id.len() + )), + } + } -fn compact_reward( - rw: &blockzilla_solana_wire::confirmed_block::Reward, - index: &KeyIndex, -) -> Result { - let pk = Pubkey::from_str(&rw.pubkey) - .context("reward pubkey parse")? - .to_bytes(); - let commission = rw.commission.parse::().ok(); - - Ok(CompactReward { - pubkey: index.compact(&pk), - lamports: rw.lamports, - post_balance: rw.post_balance, - reward_type: rw.reward_type, - commission, - }) -} + #[inline] + fn return_data_none(&mut self, none: bool) { + self.return_data_none = none; + } -#[cfg(test)] -mod tests { - use super::*; - use blockzilla_solana_wire::confirmed_block::{ - InnerInstruction, InnerInstructions, ReturnData, Reward, TokenBalance, - TransactionStatusMeta, UiTokenAmount, - }; + #[inline] + fn compute_units_consumed(&mut self, units: u64) { + self.compute_units_consumed = Some(units); + } - fn assert_protobuf_visitor_matches_owned(meta: &TransactionStatusMeta, index: &KeyIndex) { - let expected = compact_meta_from_proto(meta, index).expect("compact owned metadata"); - let protobuf = meta.encode_to_vec(); - let actual = compact_meta_from_protobuf_visit(&protobuf, index) - .expect("compact borrowed protobuf metadata"); + #[inline] + fn cost_units(&mut self, units: u64) { + self.cost_units = Some(units); + } + } - assert_eq!( - wincode::serialize(&actual).expect("serialize borrowed compact metadata"), - wincode::serialize(&expected).expect("serialize owned compact metadata") - ); + #[inline] + fn compact_pubkey_optional(index: &KeyIndex, s: &str) -> Option { + if s.is_empty() { + return None; + } + index.compact_str(s) } - fn representative_log_metadata() -> (TransactionStatusMeta, KeyIndex) { - const SYSTEM: &str = "11111111111111111111111111111111"; - const COMPUTE_BUDGET: &str = "ComputeBudget111111111111111111111111111111"; - const TOKEN: &str = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; - - let system = Pubkey::from_str(SYSTEM).unwrap().to_bytes(); - let compute_budget = Pubkey::from_str(COMPUTE_BUDGET).unwrap().to_bytes(); - let token = Pubkey::from_str(TOKEN).unwrap().to_bytes(); - let index = KeyIndex::build(vec![system, compute_budget, token]); - - let log_messages = vec![ - format!("Program {COMPUTE_BUDGET} invoke [1]"), - "Program log: Instruction: RequestUnits".to_owned(), - format!("Program {COMPUTE_BUDGET} consumed 150 of 200000 compute units"), - format!("Program {COMPUTE_BUDGET} success"), - format!("Program {SYSTEM} invoke [1]"), - "Transfer: insufficient lamports 3, need 5".to_owned(), - "Program data: AQID BAU=".to_owned(), - format!("Program return: {SYSTEM} AQID"), - "Program log: an unstructured payload".to_owned(), - "plain runtime text".to_owned(), - format!("Program {SYSTEM} success"), - ]; - - let meta = TransactionStatusMeta { - fee: 5_000, - pre_balances: (0..40).map(|value| value * 10).collect(), - post_balances: (0..40).map(|value| value * 10 + 1).collect(), - inner_instructions: vec![InnerInstructions { - index: 2, - instructions: vec![ - InnerInstruction { - program_id_index: 3, - accounts: vec![0, 1, 2], - data: vec![9, 8, 7], - stack_height: Some(2), - }, - InnerInstruction { - program_id_index: 4, - accounts: vec![3, 4], - data: vec![6, 5], - stack_height: None, - }, - ], - }], - inner_instructions_none: false, - log_messages, - log_messages_none: false, - pre_token_balances: vec![TokenBalance { - account_index: 1, - mint: TOKEN.to_owned(), - ui_token_amount: Some(UiTokenAmount { - ui_amount: 42.0, - decimals: 6, - amount: "42000000".to_owned(), - ui_amount_string: "42".to_owned(), - }), - owner: SYSTEM.to_owned(), - program_id: TOKEN.to_owned(), - }], - post_token_balances: vec![TokenBalance { - account_index: 1, - mint: TOKEN.to_owned(), - ui_token_amount: Some(UiTokenAmount { - ui_amount: 43.0, - decimals: 6, - amount: "43000000".to_owned(), - ui_amount_string: "43".to_owned(), - }), - owner: SYSTEM.to_owned(), - program_id: TOKEN.to_owned(), - }], - rewards: vec![Reward { - pubkey: SYSTEM.to_owned(), - lamports: 50, - post_balance: 1_000, - reward_type: 1, - commission: "7".to_owned(), - }], - loaded_writable_addresses: vec![system.to_vec(), token.to_vec()], - loaded_readonly_addresses: vec![compute_budget.to_vec()], - return_data: Some(ReturnData { - program_id: system.to_vec(), - data: vec![1, 2, 3, 4], - }), - return_data_none: false, - compute_units_consumed: Some(123_456), - cost_units: Some(123_999), - ..TransactionStatusMeta::default() + fn compact_token_balance( + tb: &blockzilla_solana_wire::confirmed_block::TokenBalance, + index: &KeyIndex, + ) -> Result { + let mint = compact_pubkey_optional(index, &tb.mint); + let owner = compact_pubkey_optional(index, &tb.owner); + let program_id = compact_pubkey_optional(index, &tb.program_id); + + let (amount, decimals) = match &tb.ui_token_amount { + None => (0u64, 0u8), + Some(uta) => { + let amount = uta + .amount + .parse::() + .context("parse token amount u64")?; + (amount, uta.decimals as u8) + } }; - (meta, index) - } - #[test] - fn compact_transaction_error_decodes_stored_wincode_bytes() { - let bytes = wincode::serialize(&StoredTransactionError::InstructionError( - 0, - StoredInstructionError::Custom(0), - )) - .expect("serialize stored transaction error"); - - let compact = CompactTransactionError::from_stored_wincode_bytes(&bytes) - .expect("decode stored transaction error"); - - assert!(matches!( - compact, - CompactTransactionError::InstructionError(0, CompactInstructionError::Custom(0)) - )); + Ok(CompactTokenBalance { + account_index: tb.account_index, + mint, + owner, + program_id, + amount, + decimals, + }) } - #[test] - fn compact_transaction_error_rejects_trailing_stored_wincode_bytes() { - let mut bytes = wincode::serialize(&StoredTransactionError::InstructionError( - 0, - StoredInstructionError::Custom(0), - )) - .expect("serialize stored transaction error"); - bytes.push(0xaa); + fn compact_token_balance_visit( + tb: TokenBalanceVisit<'_>, + index: &KeyIndex, + ) -> Result { + let mint = compact_pubkey_optional(index, tb.mint); + let owner = compact_pubkey_optional(index, tb.owner); + let program_id = compact_pubkey_optional(index, tb.program_id); + + let (amount, decimals) = match tb.ui_token_amount { + None => (0u64, 0u8), + Some(uta) => { + let amount = uta + .amount + .parse::() + .context("parse token amount u64")?; + (amount, uta.decimals as u8) + } + }; - assert!(CompactTransactionError::from_stored_wincode_bytes(&bytes).is_err()); + Ok(CompactTokenBalance { + account_index: tb.account_index, + mint, + owner, + program_id, + amount, + decimals, + }) } - #[test] - fn compact_transaction_error_decodes_legacy_unit_borsh_io_error() { - let bytes = [ - 8, 0, 0, 0, // StoredTransactionError::InstructionError - 7, // instruction index - 44, 0, 0, 0, // StoredInstructionError::BorshIoError as old unit variant - ]; - - let compact = CompactTransactionError::from_stored_wincode_bytes(&bytes) - .expect("decode legacy stored transaction error"); - - assert!(matches!( - compact, - CompactTransactionError::InstructionError( - 7, - CompactInstructionError::BorshIoError(ref message) - ) if message.is_empty() - )); + fn compact_reward( + rw: &blockzilla_solana_wire::confirmed_block::Reward, + index: &KeyIndex, + ) -> Result { + let pk = decode_pubkey_base58(&rw.pubkey).context("reward pubkey parse")?; + let commission = rw.commission.parse::().ok(); + + Ok(CompactReward { + pubkey: index.compact(&pk), + lamports: rw.lamports, + post_balance: rw.post_balance, + reward_type: rw.reward_type, + commission, + }) } - #[test] - fn borrowed_log_visitor_is_byte_identical_to_owned_metadata_compaction() { - let (meta, index) = representative_log_metadata(); - assert_protobuf_visitor_matches_owned(&meta, &index); - } + #[cfg(test)] + mod tests { + use super::*; + use blockzilla_solana_wire::confirmed_block::{ + InnerInstruction, InnerInstructions, ReturnData, Reward, TokenBalance, + TransactionStatusMeta, UiTokenAmount, + }; - #[test] - fn borrowed_log_visitor_preserves_none_and_empty_log_semantics() { - let (mut meta, index) = representative_log_metadata(); - meta.log_messages_none = true; - assert_protobuf_visitor_matches_owned(&meta, &index); + fn assert_protobuf_visitor_matches_owned(meta: &TransactionStatusMeta, index: &KeyIndex) { + let expected = compact_meta_from_proto(meta, index).expect("compact owned metadata"); + let protobuf = meta.encode_to_vec(); + let actual = compact_meta_from_protobuf_visit(&protobuf, index) + .expect("compact borrowed protobuf metadata"); - meta.log_messages.clear(); - meta.log_messages_none = false; - assert_protobuf_visitor_matches_owned(&meta, &index); - } + assert_eq!( + wincode::serialize(&actual).expect("serialize borrowed compact metadata"), + wincode::serialize(&expected).expect("serialize owned compact metadata") + ); + } - #[test] - fn metadata_reuse_preserves_output_and_reuses_nested_allocations() { - let (meta, index) = representative_log_metadata(); - let protobuf = meta.encode_to_vec(); - let expected = - compact_meta_from_protobuf_visit(&protobuf, &index).expect("compact expected metadata"); - let expected_bytes = wincode::serialize(&expected).expect("serialize expected metadata"); - let mut reuse = CompactMetaReuse::new(); + fn representative_log_metadata() -> (TransactionStatusMeta, KeyIndex) { + const SYSTEM: &str = "11111111111111111111111111111111"; + const COMPUTE_BUDGET: &str = "ComputeBudget111111111111111111111111111111"; + const TOKEN: &str = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + + let system = decode_pubkey_base58(SYSTEM).unwrap(); + let compute_budget = decode_pubkey_base58(COMPUTE_BUDGET).unwrap(); + let token = decode_pubkey_base58(TOKEN).unwrap(); + let index = KeyIndex::build(vec![system, compute_budget, token]); + + let log_messages = vec![ + format!("Program {COMPUTE_BUDGET} invoke [1]"), + "Program log: Instruction: RequestUnits".to_owned(), + format!("Program {COMPUTE_BUDGET} consumed 150 of 200000 compute units"), + format!("Program {COMPUTE_BUDGET} success"), + format!("Program {SYSTEM} invoke [1]"), + "Transfer: insufficient lamports 3, need 5".to_owned(), + "Program data: AQID BAU=".to_owned(), + format!("Program return: {SYSTEM} AQID"), + "Program log: an unstructured payload".to_owned(), + "plain runtime text".to_owned(), + format!("Program {SYSTEM} success"), + ]; + + let meta = TransactionStatusMeta { + fee: 5_000, + pre_balances: (0..40).map(|value| value * 10).collect(), + post_balances: (0..40).map(|value| value * 10 + 1).collect(), + inner_instructions: vec![InnerInstructions { + index: 2, + instructions: vec![ + InnerInstruction { + program_id_index: 3, + accounts: vec![0, 1, 2], + data: vec![9, 8, 7], + stack_height: Some(2), + }, + InnerInstruction { + program_id_index: 4, + accounts: vec![3, 4], + data: vec![6, 5], + stack_height: None, + }, + ], + }], + inner_instructions_none: false, + log_messages, + log_messages_none: false, + pre_token_balances: vec![TokenBalance { + account_index: 1, + mint: TOKEN.to_owned(), + ui_token_amount: Some(UiTokenAmount { + ui_amount: 42.0, + decimals: 6, + amount: "42000000".to_owned(), + ui_amount_string: "42".to_owned(), + }), + owner: SYSTEM.to_owned(), + program_id: TOKEN.to_owned(), + }], + post_token_balances: vec![TokenBalance { + account_index: 1, + mint: TOKEN.to_owned(), + ui_token_amount: Some(UiTokenAmount { + ui_amount: 43.0, + decimals: 6, + amount: "43000000".to_owned(), + ui_amount_string: "43".to_owned(), + }), + owner: SYSTEM.to_owned(), + program_id: TOKEN.to_owned(), + }], + rewards: vec![Reward { + pubkey: SYSTEM.to_owned(), + lamports: 50, + post_balance: 1_000, + reward_type: 1, + commission: "7".to_owned(), + }], + loaded_writable_addresses: vec![system.to_vec(), token.to_vec()], + loaded_readonly_addresses: vec![compute_budget.to_vec()], + return_data: Some(ReturnData { + program_id: system.to_vec(), + data: vec![1, 2, 3, 4], + }), + return_data_none: false, + compute_units_consumed: Some(123_456), + cost_units: Some(123_999), + ..TransactionStatusMeta::default() + }; + (meta, index) + } - let first = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) - .expect("first reusable metadata decode"); - assert_eq!( - wincode::serialize(&first).expect("serialize first reusable metadata"), - expected_bytes - ); - let pre_balances_ptr = first.pre_balances.as_ptr(); - let inner_instructions = first - .inner_instructions - .as_ref() - .expect("representative inner instructions"); - let inner_groups_ptr = inner_instructions.as_ptr(); - let inner_list_ptr = inner_instructions[0].instructions.as_ptr(); - let mut account_ptrs = inner_instructions[0] - .instructions - .iter() - .map(|instruction| instruction.accounts.as_ptr() as usize) - .collect::>(); - account_ptrs.sort_unstable(); - let mut data_ptrs = inner_instructions[0] - .instructions - .iter() - .map(|instruction| instruction.data.as_ptr() as usize) - .collect::>(); - data_ptrs.sort_unstable(); - let log_events_ptr = first - .logs - .as_ref() - .expect("representative logs") - .events - .as_ptr(); - let return_data_ptr = first - .return_data - .as_ref() - .expect("representative return data") - .data - .as_ptr(); - let log_range_ptr = reuse.log_message_ranges.as_ptr(); - reuse.recycle(first); - assert!(reuse.retained_capacity_bytes() > 0); - - let second = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) - .expect("second reusable metadata decode"); - assert_eq!( - wincode::serialize(&second).expect("serialize second reusable metadata"), - expected_bytes - ); - assert_eq!(second.pre_balances.as_ptr(), pre_balances_ptr); - let second_inner = second - .inner_instructions - .as_ref() - .expect("second representative inner instructions"); - assert_eq!(second_inner.as_ptr(), inner_groups_ptr); - assert_eq!(second_inner[0].instructions.as_ptr(), inner_list_ptr); - let mut second_account_ptrs = second_inner[0] - .instructions - .iter() - .map(|instruction| instruction.accounts.as_ptr() as usize) - .collect::>(); - second_account_ptrs.sort_unstable(); - assert_eq!(second_account_ptrs, account_ptrs); - let mut second_data_ptrs = second_inner[0] - .instructions - .iter() - .map(|instruction| instruction.data.as_ptr() as usize) - .collect::>(); - second_data_ptrs.sort_unstable(); - assert_eq!(second_data_ptrs, data_ptrs); - assert_eq!( - second.logs.as_ref().expect("second logs").events.as_ptr(), - log_events_ptr - ); - assert_eq!( - second + #[test] + fn compact_transaction_error_decodes_stored_wincode_bytes() { + let bytes = wincode::serialize(&StoredTransactionError::InstructionError( + 0, + StoredInstructionError::Custom(0), + )) + .expect("serialize stored transaction error"); + + let compact = CompactTransactionError::from_stored_wincode_bytes(&bytes) + .expect("decode stored transaction error"); + + assert!(matches!( + compact, + CompactTransactionError::InstructionError(0, CompactInstructionError::Custom(0)) + )); + } + + #[test] + fn compact_transaction_error_rejects_trailing_stored_wincode_bytes() { + let mut bytes = wincode::serialize(&StoredTransactionError::InstructionError( + 0, + StoredInstructionError::Custom(0), + )) + .expect("serialize stored transaction error"); + bytes.push(0xaa); + + assert!(CompactTransactionError::from_stored_wincode_bytes(&bytes).is_err()); + } + + #[test] + fn compact_transaction_error_decodes_legacy_unit_borsh_io_error() { + let bytes = [ + 8, 0, 0, 0, // StoredTransactionError::InstructionError + 7, // instruction index + 44, 0, 0, 0, // StoredInstructionError::BorshIoError as old unit variant + ]; + + let compact = CompactTransactionError::from_stored_wincode_bytes(&bytes) + .expect("decode legacy stored transaction error"); + + assert!(matches!( + compact, + CompactTransactionError::InstructionError( + 7, + CompactInstructionError::BorshIoError(ref message) + ) if message.is_empty() + )); + } + + #[test] + fn borrowed_log_visitor_is_byte_identical_to_owned_metadata_compaction() { + let (meta, index) = representative_log_metadata(); + assert_protobuf_visitor_matches_owned(&meta, &index); + } + + #[test] + fn borrowed_log_visitor_preserves_none_and_empty_log_semantics() { + let (mut meta, index) = representative_log_metadata(); + meta.log_messages_none = true; + assert_protobuf_visitor_matches_owned(&meta, &index); + + meta.log_messages.clear(); + meta.log_messages_none = false; + assert_protobuf_visitor_matches_owned(&meta, &index); + } + + #[test] + fn metadata_reuse_preserves_output_and_reuses_nested_allocations() { + let (meta, index) = representative_log_metadata(); + let protobuf = meta.encode_to_vec(); + let expected = compact_meta_from_protobuf_visit(&protobuf, &index) + .expect("compact expected metadata"); + let expected_bytes = + wincode::serialize(&expected).expect("serialize expected metadata"); + let mut reuse = CompactMetaReuse::new(); + + let first = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) + .expect("first reusable metadata decode"); + assert_eq!( + wincode::serialize(&first).expect("serialize first reusable metadata"), + expected_bytes + ); + let pre_balances_ptr = first.pre_balances.as_ptr(); + let inner_instructions = first + .inner_instructions + .as_ref() + .expect("representative inner instructions"); + let inner_groups_ptr = inner_instructions.as_ptr(); + let inner_list_ptr = inner_instructions[0].instructions.as_ptr(); + let mut account_ptrs = inner_instructions[0] + .instructions + .iter() + .map(|instruction| instruction.accounts.as_ptr() as usize) + .collect::>(); + account_ptrs.sort_unstable(); + let mut data_ptrs = inner_instructions[0] + .instructions + .iter() + .map(|instruction| instruction.data.as_ptr() as usize) + .collect::>(); + data_ptrs.sort_unstable(); + let log_events_ptr = first + .logs + .as_ref() + .expect("representative logs") + .events + .as_ptr(); + let return_data_ptr = first .return_data .as_ref() - .expect("second return data") + .expect("representative return data") .data - .as_ptr(), - return_data_ptr - ); - assert_eq!(reuse.log_message_ranges.as_ptr(), log_range_ptr); - } - - #[test] - fn metadata_reuse_discards_oversized_buffers() { - let (meta, index) = representative_log_metadata(); - let protobuf = meta.encode_to_vec(); - let mut reuse = CompactMetaReuse::with_max_retained_buffer_bytes(32); - let compact = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) - .expect("compact metadata"); - - reuse.recycle(compact); - - assert_eq!(reuse.pre_balances.capacity(), 0); - assert_eq!(reuse.post_balances.capacity(), 0); - assert!( - reuse - .inner_instruction_lists - .iter() - .all(|values| meta_vec_bytes(values) <= 32) - ); - assert!(meta_vec_pool_bytes(&reuse.inner_instruction_lists) <= 32); - assert!( - reuse - .inner_instruction_accounts + .as_ptr(); + let log_range_ptr = reuse.log_message_ranges.as_ptr(); + reuse.recycle(first); + assert!(reuse.retained_capacity_bytes() > 0); + + let second = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) + .expect("second reusable metadata decode"); + assert_eq!( + wincode::serialize(&second).expect("serialize second reusable metadata"), + expected_bytes + ); + assert_eq!(second.pre_balances.as_ptr(), pre_balances_ptr); + let second_inner = second + .inner_instructions + .as_ref() + .expect("second representative inner instructions"); + assert_eq!(second_inner.as_ptr(), inner_groups_ptr); + assert_eq!(second_inner[0].instructions.as_ptr(), inner_list_ptr); + let mut second_account_ptrs = second_inner[0] + .instructions .iter() - .all(|values| meta_vec_bytes(values) <= 32) - ); - assert!(meta_vec_pool_bytes(&reuse.inner_instruction_accounts) <= 32); - assert!( - reuse - .inner_instruction_data + .map(|instruction| instruction.accounts.as_ptr() as usize) + .collect::>(); + second_account_ptrs.sort_unstable(); + assert_eq!(second_account_ptrs, account_ptrs); + let mut second_data_ptrs = second_inner[0] + .instructions .iter() - .all(|values| meta_vec_bytes(values) <= 32) - ); - assert!(meta_vec_pool_bytes(&reuse.inner_instruction_data) <= 32); + .map(|instruction| instruction.data.as_ptr() as usize) + .collect::>(); + second_data_ptrs.sort_unstable(); + assert_eq!(second_data_ptrs, data_ptrs); + assert_eq!( + second.logs.as_ref().expect("second logs").events.as_ptr(), + log_events_ptr + ); + assert_eq!( + second + .return_data + .as_ref() + .expect("second return data") + .data + .as_ptr(), + return_data_ptr + ); + assert_eq!(reuse.log_message_ranges.as_ptr(), log_range_ptr); + } + + #[test] + fn metadata_reuse_discards_oversized_buffers() { + let (meta, index) = representative_log_metadata(); + let protobuf = meta.encode_to_vec(); + let mut reuse = CompactMetaReuse::with_max_retained_buffer_bytes(32); + let compact = compact_meta_from_protobuf_visit_reusing(&protobuf, &index, &mut reuse) + .expect("compact metadata"); + + reuse.recycle(compact); + + assert_eq!(reuse.pre_balances.capacity(), 0); + assert_eq!(reuse.post_balances.capacity(), 0); + assert!( + reuse + .inner_instruction_lists + .iter() + .all(|values| meta_vec_bytes(values) <= 32) + ); + assert!(meta_vec_pool_bytes(&reuse.inner_instruction_lists) <= 32); + assert!( + reuse + .inner_instruction_accounts + .iter() + .all(|values| meta_vec_bytes(values) <= 32) + ); + assert!(meta_vec_pool_bytes(&reuse.inner_instruction_accounts) <= 32); + assert!( + reuse + .inner_instruction_data + .iter() + .all(|values| meta_vec_bytes(values) <= 32) + ); + assert!(meta_vec_pool_bytes(&reuse.inner_instruction_data) <= 32); + } } } + +#[cfg(feature = "protobuf")] +pub use protobuf_meta::*; diff --git a/crates/compact-v2/blockzilla-registry/Cargo.toml b/crates/compact-v2/blockzilla-registry/Cargo.toml index 73febae2..855ba6fa 100644 --- a/crates/compact-v2/blockzilla-registry/Cargo.toml +++ b/crates/compact-v2/blockzilla-registry/Cargo.toml @@ -10,11 +10,9 @@ autobins = false description = "Pubkey registry, MPHF key index and blockhash registry" [dependencies] -blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.2.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.3.0" } anyhow = "1.0.104" -five8 = "1.0.0" memmap2 = "0.9.11" -solana-pubkey = "4.2.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] gxhash = "3.5.0" diff --git a/crates/compact-v2/blockzilla-registry/src/registry.rs b/crates/compact-v2/blockzilla-registry/src/registry.rs index aa26d058..1e0994d0 100644 --- a/crates/compact-v2/blockzilla-registry/src/registry.rs +++ b/crates/compact-v2/blockzilla-registry/src/registry.rs @@ -1,10 +1,13 @@ use anyhow::{Context, Result}; -use blockzilla_primitives::PubkeyCompactor; +use blockzilla_primitives::{ + ASSOCIATED_TOKEN_PROGRAM_ID, COMPUTE_BUDGET_PROGRAM_ID, CompactPubkey, PubkeyCompactor, + PubkeyResolver, SPL_TOKEN_PROGRAM_ID, SYSTEM_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, + VOTE_PROGRAM_ID, decode_pubkey_base58, +}; #[cfg(not(target_arch = "wasm32"))] use memmap2::MmapOptions; #[cfg(not(target_arch = "wasm32"))] use ph::fmph; -use solana_pubkey::Pubkey; #[cfg(target_arch = "wasm32")] use std::collections::HashMap; #[cfg(not(target_arch = "wasm32"))] @@ -13,15 +16,12 @@ use std::io::{Cursor, Seek, SeekFrom}; use std::os::unix::fs::FileExt as _; #[cfg(all(not(target_arch = "wasm32"), windows))] use std::os::windows::fs::FileExt as _; -use std::str::FromStr; use std::{ fs::File, io::{BufReader, BufWriter, Read, Write}, path::Path, }; -use blockzilla_primitives::{CompactPubkey, PubkeyResolver}; - const KEY_INDEX_MAGIC: &[u8; 8] = b"BZKIDX1!"; const KEY_INDEX_VERSION: u16 = 2; const KEY_INDEX_HEADER_LEN: usize = 8 + 2 + 2 + 8; @@ -113,42 +113,23 @@ pub struct RawPubkeyCompactor; impl PubkeyCompactor for RawPubkeyCompactor { #[inline] fn compact_str(&self, k: &str) -> Option { - let bytes = known_raw_pubkey(k).or_else(|| decode_pubkey_base58_32(k))?; + let bytes = known_raw_pubkey(k).or_else(|| decode_pubkey_base58(k))?; Some(CompactPubkey::raw(bytes)) } } -#[inline] -fn decode_pubkey_base58_32(k: &str) -> Option<[u8; 32]> { - let mut bytes = [0u8; 32]; - five8::decode_32(k, &mut bytes).ok()?; - Some(bytes) -} - #[inline] fn known_raw_pubkey(k: &str) -> Option<[u8; 32]> { - let pk = match k { - "11111111111111111111111111111111" => { - solana_pubkey::pubkey!("11111111111111111111111111111111") - } - "ComputeBudget111111111111111111111111111111" => { - solana_pubkey::pubkey!("ComputeBudget111111111111111111111111111111") - } - "Vote111111111111111111111111111111111111111" => { - solana_pubkey::pubkey!("Vote111111111111111111111111111111111111111") - } - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" => { - solana_pubkey::pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") - } - "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" => { - solana_pubkey::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL") - } - "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" => { - solana_pubkey::pubkey!("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb") - } + let bytes = match k { + "11111111111111111111111111111111" => SYSTEM_PROGRAM_ID, + "ComputeBudget111111111111111111111111111111" => COMPUTE_BUDGET_PROGRAM_ID, + "Vote111111111111111111111111111111111111111" => VOTE_PROGRAM_ID, + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" => SPL_TOKEN_PROGRAM_ID, + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" => ASSOCIATED_TOKEN_PROGRAM_ID, + "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" => TOKEN_2022_PROGRAM_ID, _ => return None, }; - Some(pk.to_bytes()) + Some(bytes) } impl KeyIndex { @@ -350,13 +331,13 @@ impl KeyIndex { /// Lookup from base58 string. pub fn lookup_str(&self, k: &str) -> Option { - let pk = Pubkey::from_str(k).ok()?; - self.lookup(pk.as_array()) + let bytes = decode_pubkey_base58(k)?; + self.lookup(&bytes) } pub fn compact_str(&self, k: &str) -> Option { - let pk = Pubkey::from_str(k).ok()?; - Some(self.compact(pk.as_array())) + let bytes = decode_pubkey_base58(k)?; + Some(self.compact(&bytes)) } } diff --git a/crates/parser/blockzilla-program-logs/Cargo.toml b/crates/parser/blockzilla-program-logs/Cargo.toml index a5bcd1f1..29f89a54 100644 --- a/crates/parser/blockzilla-program-logs/Cargo.toml +++ b/crates/parser/blockzilla-program-logs/Cargo.toml @@ -27,10 +27,9 @@ known-raydium-amm = [] known-static-programs = [] [dependencies] -blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.2.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", version = "0.3.0" } data-encoding = "2.11.1" serde = { version = "1.0.229", features = ["derive"] } -solana-pubkey = "4.2.1" wincode = { version = "=0.6.1", features = ["derive"] } [lints] diff --git a/crates/parser/blockzilla-program-logs/src/program_logs/system_program.rs b/crates/parser/blockzilla-program-logs/src/program_logs/system_program.rs index 882918e6..03ba2cbe 100644 --- a/crates/parser/blockzilla-program-logs/src/program_logs/system_program.rs +++ b/crates/parser/blockzilla-program-logs/src/program_logs/system_program.rs @@ -1,5 +1,4 @@ use serde::{Deserialize, Serialize}; -use solana_pubkey::Pubkey; use wincode::{SchemaRead, SchemaWrite}; use blockzilla_primitives::StrId; @@ -202,8 +201,8 @@ fn parse_u64_commas(s: &str) -> Option { } #[inline] -fn pubkey_id_to_pubkey(resolver: &R, id: PubkeyId) -> Pubkey { - id.to_pubkey(resolver) +fn pubkey_id_to_string(resolver: &R, id: PubkeyId) -> String { + id.to_base58(resolver) .unwrap_or_else(|| panic!("SystemProgramLog: PubkeyId cannot be resolved: id={id:?}")) } @@ -214,7 +213,7 @@ fn pubkey_or_string_to_string( resolver: &R, ) -> String { match v { - PubkeyOrString::Pubkey(id) => pubkey_id_to_pubkey(resolver, id).to_string(), + PubkeyOrString::Pubkey(id) => pubkey_id_to_string(resolver, id), PubkeyOrString::Text(sid) => st.resolve(sid).to_string(), } } @@ -573,7 +572,7 @@ impl SystemProgramLog { derived_addr, } => format!( "Create: address {} does not match derived address {}", - pubkey_id_to_pubkey(resolver, *provided_addr), + pubkey_id_to_string(resolver, *provided_addr), pubkey_or_string_to_string(*derived_addr, st, resolver), ), @@ -582,7 +581,7 @@ impl SystemProgramLog { derived_addr, } => format!( "Transfer: 'from' address {} does not match derived address {}", - pubkey_id_to_pubkey(resolver, *provided_addr), + pubkey_id_to_string(resolver, *provided_addr), pubkey_or_string_to_string(*derived_addr, st, resolver), ), @@ -630,7 +629,7 @@ impl SystemProgramLog { Self::TransferFromMustSign { from } => format!( "Transfer: `from` account {} must sign", - pubkey_id_to_pubkey(resolver, *from), + pubkey_id_to_string(resolver, *from), ), Self::TransferInsufficient { have, need } => { diff --git a/crates/parser/blockzilla-program-logs/src/program_logs/token_2022.rs b/crates/parser/blockzilla-program-logs/src/program_logs/token_2022.rs index d99a20c2..9d8ca197 100644 --- a/crates/parser/blockzilla-program-logs/src/program_logs/token_2022.rs +++ b/crates/parser/blockzilla-program-logs/src/program_logs/token_2022.rs @@ -634,8 +634,7 @@ impl Token2022Log { #[inline] fn pubkey_id_to_string(resolver: &R, id: PubkeyId) -> String { - id.to_pubkey(resolver) - .map(|pubkey| pubkey.to_string()) + id.to_base58(resolver) .unwrap_or_else(|| format!("")) } diff --git a/crates/reader/blockzilla-read-sdk/Cargo.toml b/crates/reader/blockzilla-read-sdk/Cargo.toml index 126c01d7..883d8149 100644 --- a/crates/reader/blockzilla-read-sdk/Cargo.toml +++ b/crates/reader/blockzilla-read-sdk/Cargo.toml @@ -11,30 +11,33 @@ autobins = false [features] default = [] -http = ["dep:reqwest", "dep:url"] +http = ["dep:blockzilla-source", "dep:blockzilla-source-http", "dep:url"] [dependencies] -blockzilla-archive-v2 = { path = "../../compact-v2/blockzilla-archive-v2", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-compact = { path = "../../compact-v2/blockzilla-compact", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-primitives = { path = "../../blockzilla-primitives", default-features = false, version = "0.2.0" } -blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, features = ["known-program-logs"], version = "0.2.0" } -blockzilla-registry = { path = "../../compact-v2/blockzilla-registry", default-features = false, version = "0.2.0" } +blockzilla-archive-v2 = { path = "../../compact-v2/blockzilla-archive-v2", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-compact = { path = "../../compact-v2/blockzilla-compact", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-primitives = { path = "../../blockzilla-primitives", default-features = false, version = "0.3.0" } +blockzilla-program-logs = { path = "../../parser/blockzilla-program-logs", default-features = false, features = ["known-program-logs"], version = "0.3.0" } +blockzilla-registry = { path = "../../compact-v2/blockzilla-registry", default-features = false, version = "0.3.0" } rayon = "1.12.0" rustix = { version = "1.1.4", features = ["fs"] } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" -sha2 = "0.11.0" +sha2 = { version = "0.11.0", default-features = false } smallvec = "1.16.0" -solana-pubkey = "4.2.1" thiserror = "2.0.20" wincode = { version = "=0.6.1", features = ["derive"] } -zstd = "0.14.0" +zstd = { version = "0.14.0", default-features = false } -[dependencies.reqwest] -version = "0.13.4" +[dependencies.blockzilla-source] +version = "0.3.0" +path = "../../source/blockzilla-source" +optional = true + +[dependencies.blockzilla-source-http] +version = "0.3.0" +path = "../../source/blockzilla-source-http" optional = true -default-features = false -features = ["blocking", "rustls"] [dependencies.url] version = "2.5.8" diff --git a/crates/reader/blockzilla-read-sdk/src/http.rs b/crates/reader/blockzilla-read-sdk/src/http.rs index 2cc3ba93..a8275311 100644 --- a/crates/reader/blockzilla-read-sdk/src/http.rs +++ b/crates/reader/blockzilla-read-sdk/src/http.rs @@ -1,16 +1,14 @@ -use std::{fmt, io::Read, time::Duration}; +use std::{fmt, time::Duration}; -use reqwest::{ - StatusCode, - blocking::{Client, RequestBuilder, Response}, - header::{ACCEPT_ENCODING, AUTHORIZATION, CONTENT_LENGTH, CONTENT_RANGE, HeaderValue, RANGE}, - redirect, +use blockzilla_source::RangeSource as SharedRangeSource; +use blockzilla_source_http::{ + HttpObjectPathLayout, HttpRangeSource as SharedHttpRangeSource, + HttpRangeSourceOptions as SharedHttpRangeSourceOptions, }; use url::Url; use crate::{ SourceError, - manifest::{GENERATION_MANIFEST_FILE, validate_object_name}, source::{RangeSource, SourceResult}, }; @@ -39,30 +37,16 @@ impl Default for HttpRangeSourceOptions { /// Blocking HTTP Range source for the Blockzilla read gateway. /// -/// The secret is held only as an already-redacted header value. `Debug` never -/// prints it. Redirects and ambient HTTP proxies are disabled so a bearer token -/// cannot be forwarded to a different origin. +/// Delegates all transport, ETag pinning, retries, and origin enforcement to +/// `blockzilla-source-http` so archive HTTP client logic lives in one place. #[derive(Clone)] pub struct HttpRangeSource { - client: Client, - base_url: Url, - epoch: u64, - authorization: Option, - max_manifest_bytes: usize, + inner: SharedHttpRangeSource, } impl fmt::Debug for HttpRangeSource { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter - .debug_struct("HttpRangeSource") - .field("base_url", &self.base_url) - .field("epoch", &self.epoch) - .field( - "authorization", - &self.authorization.as_ref().map(|_| ""), - ) - .field("max_manifest_bytes", &self.max_manifest_bytes) - .finish() + fmt::Debug::fmt(&self.inner, formatter) } } @@ -86,193 +70,36 @@ impl HttpRangeSource { bearer_token: Option<&str>, options: HttpRangeSourceOptions, ) -> SourceResult { - let mut base_url = Url::parse(base_url.as_ref()) - .map_err(|error| SourceError::Protocol(format!("invalid gateway URL: {error}")))?; - if !base_url.username().is_empty() - || base_url.password().is_some() - || base_url.query().is_some() - || base_url.fragment().is_some() - { - return Err(SourceError::Protocol( - "gateway URL must not contain credentials, a query, or a fragment".into(), - )); - } - if base_url.host_str().is_none() { - return Err(SourceError::Protocol( - "gateway URL must have an origin".into(), - )); - } - match base_url.scheme() { - "https" => {} - "http" if options.allow_insecure_http => {} - "http" => { - return Err(SourceError::Protocol( - "cleartext HTTP is disabled; explicitly enable it only for local development" - .into(), - )); - } - scheme => { - return Err(SourceError::Protocol(format!( - "unsupported gateway URL scheme {scheme}" - ))); - } - } - if options.max_manifest_bytes == 0 { - return Err(SourceError::Protocol( - "max_manifest_bytes must be non-zero".into(), - )); - } - // A base ending with a file-looking segment is still treated as a path - // prefix. Gateway route components are appended, never URL-joined. - if !base_url.path().ends_with('/') { - let path = format!("{}/", base_url.path()); - base_url.set_path(&path); - } - - let authorization = match bearer_token { - Some("") => { - return Err(SourceError::Protocol("bearer token is empty".into())); - } - Some(token) => Some(HeaderValue::from_str(&format!("Bearer {token}")).map_err( - |_| SourceError::Protocol("bearer token contains invalid header bytes".into()), - )?), - None => None, - }; - let client = Client::builder() - .connect_timeout(options.connect_timeout) - .timeout(options.request_timeout) - .redirect(redirect::Policy::none()) - .no_proxy() - .build() - .map_err(|error| SourceError::Protocol(format!("build HTTP range client: {error}")))?; - Ok(Self { - client, - base_url, - epoch, - authorization, + let shared = SharedHttpRangeSourceOptions { + connect_timeout: options.connect_timeout, + request_timeout: options.request_timeout, max_manifest_bytes: options.max_manifest_bytes, - }) + allow_insecure_http: options.allow_insecure_http, + object_path_layout: HttpObjectPathLayout::GatewayV1, + }; + let inner = SharedHttpRangeSource::with_options(base_url, epoch, bearer_token, shared) + .map_err(map_source_error)?; + Ok(Self { inner }) } pub fn base_url(&self) -> &Url { - &self.base_url + self.inner.base_url() } pub fn epoch(&self) -> u64 { - self.epoch - } - - fn object_url(&self, object: &str) -> SourceResult { - validate_object_name(object).map_err(|_| SourceError::InvalidName(object.to_owned()))?; - let mut url = self.base_url.clone(); - { - let mut path = url.path_segments_mut().map_err(|_| { - SourceError::Protocol("gateway URL cannot accept path segments".into()) - })?; - path.pop_if_empty(); - path.push("v1"); - path.push("epochs"); - path.push(&self.epoch.to_string()); - if object == GENERATION_MANIFEST_FILE { - path.push("manifest"); - } else { - path.push("files"); - path.push(object); - } - } - Ok(url) - } - - fn authorize(&self, request: RequestBuilder) -> RequestBuilder { - match &self.authorization { - Some(value) => request.header(AUTHORIZATION, value.clone()), - None => request, - } - } - - fn check_origin(&self, response: &Response) -> SourceResult<()> { - if response.url().origin() != self.base_url.origin() { - return Err(SourceError::Protocol( - "gateway response crossed origin".into(), - )); - } - Ok(()) - } - - fn full_manifest_into( - &self, - expected_length: usize, - destination: &mut Vec, - ) -> SourceResult<()> { - if expected_length > self.max_manifest_bytes { - return Err(SourceError::Protocol(format!( - "manifest is {expected_length} bytes, above the {} byte limit", - self.max_manifest_bytes - ))); - } - let url = self.object_url(GENERATION_MANIFEST_FILE)?; - let mut response = self - .authorize( - self.client - .get(url) - .header(ACCEPT_ENCODING, HeaderValue::from_static("identity")), - ) - .send() - .map_err(sanitize_http_error)?; - self.check_origin(&response)?; - if response.status() != StatusCode::OK { - return Err(SourceError::Protocol(format!( - "manifest GET returned HTTP {}", - response.status() - ))); - } - enforce_content_length(&response, expected_length)?; - read_bounded_into( - &mut response, - expected_length, - GENERATION_MANIFEST_FILE, - destination, - ) + self.inner.epoch() } } impl RangeSource for HttpRangeSource { fn size(&self, object: &str) -> SourceResult> { - let url = self.object_url(object)?; - let response = self - .authorize( - self.client - .head(url) - .header(ACCEPT_ENCODING, HeaderValue::from_static("identity")), - ) - .send() - .map_err(sanitize_http_error)?; - self.check_origin(&response)?; - if response.status() == StatusCode::NOT_FOUND { - return Ok(None); - } - if response.status() != StatusCode::OK { - return Err(SourceError::Protocol(format!( - "HEAD for {object} returned HTTP {}", - response.status() - ))); - } - let value = response.headers().get(CONTENT_LENGTH).ok_or_else(|| { - SourceError::Protocol(format!("HEAD for {object} omitted Content-Length")) - })?; - let value = value.to_str().map_err(|_| { - SourceError::Protocol(format!("HEAD for {object} has invalid Content-Length")) - })?; - let size = value.parse::().map_err(|_| { - SourceError::Protocol(format!("HEAD for {object} has invalid Content-Length")) - })?; - Ok(Some(size)) + self.inner.size(object).map_err(map_source_error) } fn read_range(&self, object: &str, offset: u64, length: usize) -> SourceResult> { - let mut bytes = Vec::new(); - self.read_range_into(object, offset, length, &mut bytes)?; - Ok(bytes) + self.inner + .read_range(object, offset, length) + .map_err(map_source_error) } fn read_range_into( @@ -282,151 +109,45 @@ impl RangeSource for HttpRangeSource { length: usize, destination: &mut Vec, ) -> SourceResult<()> { - if length == 0 { - let size = self - .size(object)? - .ok_or_else(|| SourceError::NotFound(object.to_owned()))?; - if offset > size { - return Err(SourceError::OutOfBounds { - object: object.to_owned(), - offset, - length, - size, - }); - } - destination.clear(); - return Ok(()); - } - if object == GENERATION_MANIFEST_FILE { - if offset != 0 { - return Err(SourceError::Protocol( - "manifest only supports a complete bounded GET".into(), - )); - } - return self.full_manifest_into(length, destination); - } - - let length_u64 = u64::try_from(length).map_err(|_| { - SourceError::Protocol("requested HTTP range length does not fit u64".into()) - })?; - let end_exclusive = offset - .checked_add(length_u64) - .ok_or_else(|| SourceError::Protocol(format!("range overflow for {object}")))?; - let end_inclusive = end_exclusive - 1; - let url = self.object_url(object)?; - let mut response = self - .authorize( - self.client - .get(url) - .header(ACCEPT_ENCODING, HeaderValue::from_static("identity")) - .header(RANGE, format!("bytes={offset}-{end_inclusive}")), - ) - .send() - .map_err(sanitize_http_error)?; - self.check_origin(&response)?; - if response.status() != StatusCode::PARTIAL_CONTENT { - return Err(SourceError::Protocol(format!( - "range GET for {object} returned HTTP {}, expected 206", - response.status() - ))); - } - enforce_content_length(&response, length)?; - let content_range = response.headers().get(CONTENT_RANGE).ok_or_else(|| { - SourceError::Protocol(format!("range GET for {object} omitted Content-Range")) - })?; - let content_range = content_range.to_str().map_err(|_| { - SourceError::Protocol(format!("range GET for {object} has invalid Content-Range")) - })?; - let (actual_start, actual_end, total) = - parse_content_range(content_range).ok_or_else(|| { - SourceError::Protocol(format!( - "range GET for {object} has malformed Content-Range" - )) - })?; - if actual_start != offset || actual_end != end_inclusive || end_exclusive > total { - return Err(SourceError::Protocol(format!( - "range GET for {object} returned an unexpected Content-Range" - ))); - } - read_bounded_into(&mut response, length, object, destination) - } -} - -fn enforce_content_length(response: &Response, expected: usize) -> SourceResult<()> { - if let Some(value) = response.headers().get(CONTENT_LENGTH) { - let value = value - .to_str() - .ok() - .and_then(|value| value.parse::().ok()) - .ok_or_else(|| SourceError::Protocol("invalid Content-Length".into()))?; - if value != expected as u64 { - return Err(SourceError::Protocol(format!( - "response Content-Length is {value}, expected {expected}" - ))); - } + self.inner + .read_range_into(object, offset, length, destination) + .map_err(map_source_error) } - Ok(()) } -fn read_bounded_into( - response: &mut impl Read, - expected: usize, - object: &str, - destination: &mut Vec, -) -> SourceResult<()> { - let bound = u64::try_from(expected) - .unwrap_or(u64::MAX) - .saturating_add(1); - destination.clear(); - let initial_capacity = expected.min(8 * 1024 * 1024); - if destination.capacity() < initial_capacity { - destination.reserve(initial_capacity); - } - response - .take(bound) - .read_to_end(destination) - .map_err(|source| SourceError::Io { - object: object.to_owned(), - source, - })?; - if destination.len() != expected { - return Err(SourceError::ShortRead { - object: object.to_owned(), +fn map_source_error(error: blockzilla_source::SourceError) -> SourceError { + match error { + blockzilla_source::SourceError::InvalidName(name) => SourceError::InvalidName(name), + blockzilla_source::SourceError::Io { object, source } => SourceError::Io { object, source }, + blockzilla_source::SourceError::NotFound(name) => SourceError::NotFound(name), + blockzilla_source::SourceError::ShortRead { + object, expected, - actual: destination.len(), - }); + actual, + } => SourceError::ShortRead { + object, + expected, + actual, + }, + blockzilla_source::SourceError::OutOfBounds { + object, + offset, + length, + size, + } => SourceError::OutOfBounds { + object, + offset, + length, + size, + }, + blockzilla_source::SourceError::Protocol(message) => SourceError::Protocol(message), } - Ok(()) -} - -fn parse_content_range(value: &str) -> Option<(u64, u64, u64)> { - let value = value.strip_prefix("bytes ")?; - let (range, total) = value.split_once('/')?; - let (start, end) = range.split_once('-')?; - let start = start.parse().ok()?; - let end = end.parse().ok()?; - let total = total.parse().ok()?; - (start <= end && end < total).then_some((start, end, total)) -} - -fn sanitize_http_error(error: reqwest::Error) -> SourceError { - // reqwest errors can contain a URL but do not include request headers. Keep - // the message generic anyway so credentials can never become diagnostic data. - SourceError::Protocol(format!("HTTP request failed ({})", error.without_url())) } #[cfg(test)] mod tests { use super::*; - #[test] - fn parses_strict_content_range() { - assert_eq!(parse_content_range("bytes 5-9/100"), Some((5, 9, 100))); - assert_eq!(parse_content_range("bytes 9-5/100"), None); - assert_eq!(parse_content_range("bytes 5-100/100"), None); - assert_eq!(parse_content_range("bytes 5-9/*"), None); - } - #[test] fn debug_redacts_bearer_token() { let options = HttpRangeSourceOptions { @@ -444,17 +165,4 @@ mod tests { assert!(!rendered.contains("highly-secret-token")); assert!(rendered.contains("")); } - - #[test] - fn bounded_read_reuses_destination_capacity() { - let mut destination = Vec::with_capacity(64); - destination.extend_from_slice(b"old bytes"); - let allocation = destination.as_ptr(); - let mut response = std::io::Cursor::new(b"new bytes"); - - read_bounded_into(&mut response, 9, "object.bin", &mut destination).unwrap(); - - assert_eq!(destination, b"new bytes"); - assert_eq!(destination.as_ptr(), allocation); - } } diff --git a/crates/reader/blockzilla-read-sdk/src/metadata_wire_profile.rs b/crates/reader/blockzilla-read-sdk/src/metadata_wire_profile.rs index dc850343..cab76ab9 100644 --- a/crates/reader/blockzilla-read-sdk/src/metadata_wire_profile.rs +++ b/crates/reader/blockzilla-read-sdk/src/metadata_wire_profile.rs @@ -12,6 +12,7 @@ use blockzilla_archive_v2::{ ARCHIVE_V2_DECODE_PREALLOCATION_LIMIT_BYTES, ARCHIVE_V2_TX_FLAG_HAS_ERROR, ARCHIVE_V2_TX_FLAG_HAS_METADATA, ARCHIVE_V2_TX_FLAG_METADATA_RAW_FALLBACK, ArchiveV2WireIdentityVisitor, ArchiveV2WireRewriteLimits, + archive_v2_historical_source_metadata_can_try_current_only, rewrite_archive_v2_successful_metadata_wire, }; pub use blockzilla_archive_v2::{ @@ -22,7 +23,10 @@ use blockzilla_compact::{ CompactInnerInstructions, CompactLogStream, CompactMetaV1, CompactReturnData, CompactReward, CompactTokenBalance, CompactTransactionError, }; -use blockzilla_primitives::{CompactPubkey, bounded_wincode_leb128_config, wincode_leb128_config}; +use blockzilla_primitives::{ + CompactPubkey, bounded_historical_source_wincode_leb128_config, bounded_wincode_leb128_config, + wincode_leb128_config, +}; use serde::{Deserialize, Serialize}; use wincode::{SchemaRead, SchemaWrite}; @@ -142,15 +146,15 @@ pub enum ArchiveV2MetadataProfileAdmission { pub enum ArchiveV2MetadataSchemaClassification { /// `err=None`; current and historical wire layouts are identical. NoError, - /// Only the canonical current typed-error record is valid. + /// Only the current typed-error grammar accepts the record under the selected policy. CurrentOnly, - /// Only the canonical historical raw-error record is valid. + /// Only the historical raw-error grammar accepts the record under the selected policy. LegacyOnly, - /// Both canonical grammars decode to the same current semantic value. + /// Both grammars decode to the same current semantic value under the selected policy. BothEqual, - /// Both canonical grammars decode but produce different semantic values. + /// Both grammars decode but produce different semantic values under the selected policy. BothDifferent, - /// Neither canonical grammar accepts the complete record. + /// Neither grammar accepts the complete record under the selected policy. Invalid, /// The hot transaction row declares opaque metadata bytes. RawFallback, @@ -268,7 +272,33 @@ impl ArchiveV2MetadataSchemaClassifier { pub fn classify(&mut self, input: &[u8]) -> ArchiveV2MetadataSchemaClassification { match input.first().copied() { Some(0) => self.classify_no_error(input), - Some(1) => self.classify_present_error(input), + Some(1) => self.classify_present_error( + input, + bounded_wincode_leb128_config::(), + true, + ), + _ => ArchiveV2MetadataSchemaClassification::Invalid, + } + } + + /// Classify a historical input using the read SDK's padded integer rules. + /// Publication and target verification must use the strict classifier. + pub fn classify_historical_source( + &mut self, + input: &[u8], + ) -> ArchiveV2MetadataSchemaClassification { + let config = bounded_historical_source_wincode_leb128_config::< + ARCHIVE_V2_DECODE_PREALLOCATION_LIMIT_BYTES, + >(); + match input.first().copied() { + Some(0) if input.len() <= ARCHIVE_V2_DECODE_PREALLOCATION_LIMIT_BYTES => { + if wincode::config::deserialize_exact::(input, config).is_ok() { + ArchiveV2MetadataSchemaClassification::NoError + } else { + ArchiveV2MetadataSchemaClassification::Invalid + } + } + Some(1) => self.classify_present_error(input, config, false), _ => ArchiveV2MetadataSchemaClassification::Invalid, } } @@ -296,13 +326,20 @@ impl ArchiveV2MetadataSchemaClassifier { } } - fn classify_present_error(&mut self, input: &[u8]) -> ArchiveV2MetadataSchemaClassification { + fn classify_present_error( + &mut self, + input: &[u8], + config: C, + require_canonical: bool, + ) -> ArchiveV2MetadataSchemaClassification { if input.len() > ARCHIVE_V2_DECODE_PREALLOCATION_LIMIT_BYTES { return ArchiveV2MetadataSchemaClassification::Invalid; } - let current_valid = self.decode_canonical_current(input); - let legacy_valid = self.decode_canonical_legacy(input); + let current_valid = self.decode_current(input, config, require_canonical); + let legacy_valid = (!current_valid + || !archive_v2_historical_source_metadata_can_try_current_only(input)) + && self.decode_legacy(input, config, require_canonical); match (current_valid, legacy_valid) { (true, false) => ArchiveV2MetadataSchemaClassification::CurrentOnly, (false, true) => ArchiveV2MetadataSchemaClassification::LegacyOnly, @@ -314,12 +351,15 @@ impl ArchiveV2MetadataSchemaClassifier { } } - fn decode_canonical_current(&mut self, input: &[u8]) -> bool { + fn decode_current( + &mut self, + input: &[u8], + config: C, + require_canonical: bool, + ) -> bool { self.current_canonical.clear(); - let Ok(value) = wincode::config::deserialize_exact::( - input, - bounded_wincode_leb128_config::(), - ) else { + let Ok(value) = wincode::config::deserialize_exact::(input, config) + else { return false; }; if value.err.is_none() @@ -332,25 +372,30 @@ impl ArchiveV2MetadataSchemaClassifier { { return false; } - self.current_canonical == input + !require_canonical || self.current_canonical == input } - fn decode_canonical_legacy(&mut self, input: &[u8]) -> bool { + fn decode_legacy( + &mut self, + input: &[u8], + config: C, + require_canonical: bool, + ) -> bool { self.legacy_canonical.clear(); - let Ok(value) = wincode::config::deserialize_exact::( - input, - bounded_wincode_leb128_config::(), - ) else { + let Ok(value) = + wincode::config::deserialize_exact::(input, config) + else { return false; }; if value.err.is_none() - || wincode::config::serialize_into( - &mut self.legacy_canonical, - &value, - wincode_leb128_config(), - ) - .is_err() - || self.legacy_canonical != input + || require_canonical + && (wincode::config::serialize_into( + &mut self.legacy_canonical, + &value, + wincode_leb128_config(), + ) + .is_err() + || self.legacy_canonical != input) { return false; } @@ -797,6 +842,33 @@ mod tests { ); } + #[test] + fn historical_source_classifier_admits_padding_and_rejects_divergent_decodes() { + let mut classifier = ArchiveV2MetadataSchemaClassifier::default(); + let divergent = [ + 1, 4, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ]; + let mut padded = divergent.to_vec(); + padded.splice(7..8, [0x82, 0]); + assert_eq!( + classifier.classify_historical_source(&padded), + ArchiveV2MetadataSchemaClassification::BothDifferent + ); + + let mut metadata = current_metadata(None); + metadata.fee = 5; + let mut success = wincode::config::serialize(&metadata, wincode_leb128_config()).unwrap(); + success.splice(1..2, [success[1] | 0x80, 0]); + assert_eq!( + classifier.classify(&success), + ArchiveV2MetadataSchemaClassification::Invalid + ); + assert_eq!( + classifier.classify_historical_source(&success), + ArchiveV2MetadataSchemaClassification::NoError + ); + } + #[test] fn warmed_common_path_reuses_its_wire_buffer() { let bytes = diff --git a/crates/reader/blockzilla-read-sdk/src/wire_profile_audit.rs b/crates/reader/blockzilla-read-sdk/src/wire_profile_audit.rs index 91908818..cf7269e3 100644 --- a/crates/reader/blockzilla-read-sdk/src/wire_profile_audit.rs +++ b/crates/reader/blockzilla-read-sdk/src/wire_profile_audit.rs @@ -114,11 +114,9 @@ pub fn audit_full_generation_wire_profile( } let projector = reader.message_projector(); - let system_program = solana_pubkey::pubkey!("11111111111111111111111111111111").to_bytes(); - let compute_budget_program = - solana_pubkey::pubkey!("ComputeBudget111111111111111111111111111111").to_bytes(); - let vote_program = - solana_pubkey::pubkey!("Vote111111111111111111111111111111111111111").to_bytes(); + let system_program = blockzilla_primitives::SYSTEM_PROGRAM_ID; + let compute_budget_program = blockzilla_primitives::COMPUTE_BUDGET_PROGRAM_ID; + let vote_program = blockzilla_primitives::VOTE_PROGRAM_ID; let known_programs = reader.compile_pubkey_filter([system_program, compute_budget_program, vote_program])?; let mut audit = FullGenerationWireProfileAudit::default(); diff --git a/crates/source/blockzilla-source-cache/Cargo.toml b/crates/source/blockzilla-source-cache/Cargo.toml index 052f1ed8..5db48c4a 100644 --- a/crates/source/blockzilla-source-cache/Cargo.toml +++ b/crates/source/blockzilla-source-cache/Cargo.toml @@ -9,8 +9,8 @@ repository.workspace = true description = "Persistent HTTP object cache" [dependencies] -blockzilla-source = { version = "0.2.0", path = "../blockzilla-source" } -blockzilla-source-http = { version = "0.2.0", path = "../blockzilla-source-http" } +blockzilla-source = { version = "0.3.0", path = "../blockzilla-source" } +blockzilla-source-http = { version = "0.3.0", path = "../blockzilla-source-http" } rustix = { version = "1.1.4", features = ["fs", "process"] } [dev-dependencies] diff --git a/crates/source/blockzilla-source-cache/src/lib.rs b/crates/source/blockzilla-source-cache/src/lib.rs index 428192fb..77dee417 100644 --- a/crates/source/blockzilla-source-cache/src/lib.rs +++ b/crates/source/blockzilla-source-cache/src/lib.rs @@ -244,6 +244,27 @@ impl CachedHttpRangeSource { ) } + /// Open the cache using strong identities already pinned on `http` (falling + /// back to fresh HEADs only for unpinned objects), and use concurrent range + /// requests for cold objects. + pub fn with_pinned_identities_and_parallel_options( + http: HttpRangeSource, + cache_root: impl AsRef, + objects: &[&str], + options: HttpRangeCacheOptions, + download_concurrency: usize, + ) -> SourceResult { + Self::open_internal( + http, + cache_root, + objects, + options, + download_concurrency, + true, + |_| {}, + ) + } + /// Open the cache and report all planned cold bytes before the first body /// GET. Every configured object has completed its fresh identity HEAD when /// `report_plan` runs. @@ -271,16 +292,69 @@ impl CachedHttpRangeSource { options: HttpRangeCacheOptions, download_concurrency: usize, report_plan: impl FnOnce(HttpRangeCachePlan), + ) -> SourceResult { + Self::open_internal( + http, + cache_root, + objects, + options, + download_concurrency, + false, + report_plan, + ) + } + + fn open_internal( + http: HttpRangeSource, + cache_root: impl AsRef, + objects: &[&str], + options: HttpRangeCacheOptions, + download_concurrency: usize, + reuse_pinned_identities: bool, + report_plan: impl FnOnce(HttpRangeCachePlan), ) -> SourceResult { validate_options(objects, options, download_concurrency)?; let directory = CacheDirectory::open_existing(cache_root.as_ref())?; let http_before = http.stats(); let counters = Arc::new(CacheCounters::default()); + + let resolved_identities: Vec> = + if objects.len() <= 1 { + objects + .iter() + .map(|object| resolve_object_identity(&http, object, reuse_pinned_identities)) + .collect() + } else { + thread::scope(|scope| { + let handles: Vec<_> = objects + .iter() + .map(|&object| { + let http = &http; + scope.spawn(move || { + resolve_object_identity(http, object, reuse_pinned_identities) + }) + }) + .collect(); + handles + .into_iter() + .map(|handle| { + handle.join().unwrap_or_else(|_| { + Err(protocol("cache identity probe worker panicked")) + }) + }) + .collect() + }) + }; + let mut identities = Vec::with_capacity(objects.len()); let mut configured_cache_bytes = 0_u64; let mut configured_disk_bytes = 0_u64; - for object in objects { - let identity = http.strong_identity(object)?; + let mut identity_head_requests = 0_u64; + for (object, resolved) in objects.iter().zip(resolved_identities) { + let (identity, issued_head) = resolved?; + if issued_head { + identity_head_requests += 1; + } let header = CacheHeader::new(&http, object, &identity)?.encode()?; let disk_bytes = (header.len() as u64) .checked_add(identity.length) @@ -351,24 +425,43 @@ impl CachedHttpRangeSource { counters.hits.store(cache_hits, Ordering::Relaxed); let mut entries = HashMap::with_capacity(planned.len()); - for planned in planned { - let entry = match planned.existing { - Some(entry) => entry, - None => download_entry( + let mut cold = Vec::new(); + for item in planned { + match item.existing { + Some(entry) => { + entries.insert(item.object, entry); + } + None => cold.push(item), + } + } + if cold.len() <= 1 || download_concurrency <= 1 { + for item in cold { + let entry = download_entry( &http, &directory, - &planned.object, - &planned.identity, - &planned.header, + &item.object, + &item.identity, + &item.header, ColdDownloadOptions { cache: options, concurrency: download_concurrency, }, counters.as_ref(), - )?, - }; - let object = planned.object; - entries.insert(object, entry); + )?; + entries.insert(item.object, entry); + } + } else { + download_entries_parallel( + &http, + &directory, + cold, + ColdDownloadOptions { + cache: options, + concurrency: download_concurrency, + }, + counters.as_ref(), + &mut entries, + )?; } directory.sync()?; Ok(Self { @@ -379,7 +472,7 @@ impl CachedHttpRangeSource { configured_disk_bytes, planned_download_bytes, planned_disk_bytes, - identity_head_requests: objects.len() as u64, + identity_head_requests, http_before, }) } @@ -559,6 +652,42 @@ impl RangeSource for CachedHttpRangeSource { .read_range_into(object, offset, length, destination), } } + + fn read_range_into_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + cancelled: &std::sync::atomic::AtomicBool, + ) -> SourceResult<()> { + match self.entries.get(object) { + Some(entry) => self.read_cached_into(object, entry, offset, length, destination), + None => self.http.read_range_into_cancellable( + object, + offset, + length, + destination, + cancelled, + ), + } + } + + fn read_range_into_slice_cancellable( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + cancelled: &std::sync::atomic::AtomicBool, + ) -> SourceResult<()> { + match self.entries.get(object) { + Some(entry) => self.read_cached_slice(object, entry, offset, destination), + None => { + self.http + .read_range_into_slice_cancellable(object, offset, destination, cancelled) + } + } + } } fn validate_options( @@ -690,6 +819,201 @@ fn download_entry( Ok(entry) } +fn resolve_object_identity( + http: &HttpRangeSource, + object: &str, + reuse_pinned_identities: bool, +) -> SourceResult<(HttpObjectIdentity, bool)> { + if reuse_pinned_identities && let Some(identity) = http.pinned_strong_identity(object)? { + return Ok((identity, false)); + } + Ok((http.strong_identity(object)?, true)) +} + +fn download_entries_parallel( + http: &HttpRangeSource, + directory: &CacheDirectory, + cold: Vec, + options: ColdDownloadOptions, + counters: &CacheCounters, + entries: &mut HashMap, +) -> SourceResult<()> { + struct PreparedDownload<'a> { + object: String, + final_name: String, + identity: HttpObjectIdentity, + payload_offset: u64, + expected_file_length: u64, + temporary_name: String, + temporary: File, + temporary_identity: (u64, u64), + guard: OwnedTemporary<'a>, + } + + struct RangeTask { + entry_idx: usize, + offset: u64, + length: usize, + } + + let mut prepared = Vec::with_capacity(cold.len()); + let mut tasks = Vec::new(); + let range_bytes = options.cache.download_range_bytes as u64; + + for (entry_idx, item) in cold.into_iter().enumerate() { + let final_name = final_name(http.epoch(), &item.object); + let (temporary_name, mut temporary, temporary_identity) = + directory.create_private_temporary(&final_name)?; + let guard = OwnedTemporary { + directory, + name: temporary_name.clone(), + identity: temporary_identity, + armed: true, + }; + temporary + .write_all(&item.header) + .map_err(|source| cache_io(&item.object, source))?; + let payload_offset = item.header.len() as u64; + let expected_file_length = payload_offset + .checked_add(item.identity.length) + .ok_or_else(|| protocol(format!("cache file length overflow for {}", item.object)))?; + temporary + .set_len(expected_file_length) + .map_err(|source| cache_io(&item.object, source))?; + let mut offset = 0_u64; + while offset < item.identity.length { + let length = usize::try_from((item.identity.length - offset).min(range_bytes)) + .map_err(|_| { + protocol(format!( + "cache range length does not fit usize for {}", + item.object + )) + })?; + tasks.push(RangeTask { + entry_idx, + offset, + length, + }); + offset += length as u64; + } + prepared.push(PreparedDownload { + object: item.object, + final_name, + identity: item.identity, + payload_offset, + expected_file_length, + temporary_name, + temporary, + temporary_identity, + guard, + }); + } + + if !tasks.is_empty() { + let max_task_len = tasks.iter().map(|t| t.length).max().unwrap_or(0); + let worker_count = options.concurrency.min(tasks.len()).max(1); + let next_task = std::sync::atomic::AtomicUsize::new(0); + let prepared_ref = &prepared; + let tasks_ref = &tasks; + thread::scope(|scope| { + let mut workers = Vec::with_capacity(worker_count); + for _ in 0..worker_count { + workers.push(scope.spawn(|| -> SourceResult<()> { + let mut bytes = Vec::with_capacity(max_task_len); + loop { + let idx = next_task.fetch_add(1, Ordering::Relaxed); + let Some(task) = tasks_ref.get(idx) else { + return Ok(()); + }; + let target = &prepared_ref[task.entry_idx]; + http.read_range_into(&target.object, task.offset, task.length, &mut bytes)?; + if bytes.len() != task.length { + return Err(SourceError::ShortRead { + object: target.object.clone(), + expected: task.length, + actual: bytes.len(), + }); + } + let file_offset = target + .payload_offset + .checked_add(task.offset) + .ok_or_else(|| { + protocol(format!( + "cache file offset overflow for {}", + target.object + )) + })?; + write_all_at(&target.temporary, &bytes, file_offset, &target.object)?; + } + })); + } + let mut result = Ok(()); + for worker in workers { + let worker_result = worker + .join() + .map_err(|_| protocol("cache download worker panicked"))?; + if result.is_ok() { + result = worker_result; + } + } + result + })?; + } + + for mut target in prepared { + counters + .cold_network_body_bytes + .fetch_add(target.identity.length, Ordering::Relaxed); + target + .temporary + .sync_all() + .map_err(|source| cache_io(&target.object, source))?; + if target + .temporary + .metadata() + .map_err(|source| cache_io(&target.object, source))? + .len() + != target.expected_file_length + { + return Err(protocol(format!( + "completed cache temporary has the wrong length for {}", + target.object + ))); + } + let published = directory.link_no_replace( + &target.temporary_name, + &target.final_name, + target.temporary_identity, + &target.object, + )?; + let file = if published { + directory + .open_regular_optional(&target.final_name)? + .ok_or_else(|| { + protocol(format!( + "published cache file disappeared for {}", + target.object + )) + })? + } else { + directory + .open_regular_optional(&target.final_name)? + .ok_or_else(|| { + protocol(format!( + "racing cache file disappeared for {}", + target.object + )) + })? + }; + target.guard.cleanup()?; + directory.sync()?; + let entry = validate_cache_file(http, &target.object, &target.identity, file)?; + counters.downloads.fetch_add(1, Ordering::Relaxed); + entries.insert(target.object, entry); + } + Ok(()) +} + fn download_object_ranges( http: &HttpRangeSource, object: &str, @@ -699,13 +1023,20 @@ fn download_object_ranges( options: HttpRangeCacheOptions, download_concurrency: usize, ) -> SourceResult<()> { + if object_length == 0 { + return Ok(()); + } let range_bytes = options.download_range_bytes as u64; + let chunk_count = usize::try_from(object_length.div_ceil(range_bytes)).unwrap_or(usize::MAX); + let worker_count = download_concurrency.min(chunk_count).max(1); + let per_worker_cap = + usize::try_from(object_length.min(range_bytes)).unwrap_or(options.download_range_bytes); let next_offset = AtomicU64::new(0); thread::scope(|scope| { - let mut workers = Vec::with_capacity(download_concurrency); - for _ in 0..download_concurrency { + let mut workers = Vec::with_capacity(worker_count); + for _ in 0..worker_count { workers.push(scope.spawn(|| -> SourceResult<()> { - let mut bytes = Vec::with_capacity(options.download_range_bytes); + let mut bytes = Vec::with_capacity(per_worker_cap); loop { let offset = next_offset.fetch_add(range_bytes, Ordering::Relaxed); if offset >= object_length { @@ -1848,4 +2179,47 @@ mod tests { assert_eq!(requests.len(), 1); assert_eq!(requests[0].method, "HEAD"); } + + #[test] + fn pinned_identities_skip_duplicate_heads_and_download_multiple_objects_in_parallel() { + let server = TestServer::start([ + ("one.bin", (0_u8..30).collect(), "\"one-v1\""), + ("two.bin", (100_u8..125).collect(), "\"two-v1\""), + ]); + let http = server.source(); + // Pre-pin both objects as NetworkObjectInventory::discover does. + http.strong_identity("one.bin").unwrap(); + http.strong_identity("two.bin").unwrap(); + server.clear_requests(); + + let directory = cache_tempdir(); + let cache = CachedHttpRangeSource::with_pinned_identities_and_parallel_options( + http, + directory.path(), + &["one.bin", "two.bin"], + HttpRangeCacheOptions { + download_range_bytes: 8, + max_cached_object_bytes: 1024, + max_configured_cache_bytes: 4096, + }, + 4, + ) + .unwrap(); + let requests = server.requests(); + assert_eq!( + requests.iter().filter(|r| r.method == "HEAD").count(), + 0, + "pinned strong identities should not trigger duplicate HEADs" + ); + assert_eq!(cache.stats().identity_head_requests, 0); + assert_eq!(cache.stats().cache_downloads, 2); + assert_eq!( + cache.read_range("one.bin", 0, 30).unwrap(), + (0_u8..30).collect::>() + ); + assert_eq!( + cache.read_range("two.bin", 0, 25).unwrap(), + (100_u8..125).collect::>() + ); + } } diff --git a/crates/source/blockzilla-source-http/Cargo.toml b/crates/source/blockzilla-source-http/Cargo.toml index 870daccb..373d98f1 100644 --- a/crates/source/blockzilla-source-http/Cargo.toml +++ b/crates/source/blockzilla-source-http/Cargo.toml @@ -9,9 +9,12 @@ repository.workspace = true description = "HTTP byte ranges with pinned object identities" [dependencies] -blockzilla-source = { version = "0.2.0", path = "../blockzilla-source" } -reqwest = { version = "0.13.4", default-features = false, features = ["blocking", "rustls"] } -sha2 = "0.11.0" +blockzilla-source = { version = "0.3.0", path = "../blockzilla-source" } +httparse = "1.10.1" +rustls = { version = "0.23.43", default-features = false, features = ["ring", "std", "tls12"] } +rustls-pki-types = "1.15.1" +rustls-platform-verifier = "0.7.0" +sha2 = { version = "0.11.0", default-features = false } url = "2.5.8" [lints] diff --git a/crates/source/blockzilla-source-http/README.md b/crates/source/blockzilla-source-http/README.md index f8c56d1a..e9db1b64 100644 --- a/crates/source/blockzilla-source-http/README.md +++ b/crates/source/blockzilla-source-http/README.md @@ -71,5 +71,21 @@ signed headers are `host`, `range` when present, and each `x-amz-*` header session token). `Debug` output and errors never contain the secret key or the session token. -HTTP sources recommend up to eight concurrent reads. Each format reader applies -its own input-buffer limit; this hint does not create threads in this crate. +## Transport and streaming ranges + +`HttpRangeSource` uses a direct pooled synchronous HTTP/1.1 + `rustls` transport +with no async runtime, no redirects, and no ambient proxy forwarding. Caller +threads perform TCP I/O and TLS decryption on their own cores and read +fixed-length bodies straight into caller-owned slices. + +- `open_range_stream_cancellable` opens one ETag-pinned `206 Partial Content` + `HttpRangeStream` so callers can stream large contiguous ranges incrementally + and recycle the keep-alive connection when drained. +- `read_range_into_cancellable` and `read_range_into_slice_cancellable` support + prompt cancellation for hedged range reads. +- `HttpJsonClient` reuses the same origin-pinned transport for bounded JSON POST + requests. + +HTTP sources recommend between 8 and 32 concurrent reads, scaled to available +CPU cores. Each format reader applies its own input-buffer limit; this hint does +not create threads in this crate. diff --git a/crates/source/blockzilla-source-http/src/lib.rs b/crates/source/blockzilla-source-http/src/lib.rs index d468f0df..67afb40e 100644 --- a/crates/source/blockzilla-source-http/src/lib.rs +++ b/crates/source/blockzilla-source-http/src/lib.rs @@ -3,27 +3,18 @@ mod retry; mod s3; mod signing; +mod transport; use std::{ collections::HashMap, fmt, - io::Read, sync::{ Arc, Mutex, - atomic::{AtomicU64, Ordering}, + atomic::{AtomicBool, AtomicU64, Ordering}, }, time::Duration, }; -use reqwest::{ - Method, StatusCode, - blocking::{Client, Request, Response}, - header::{ - ACCEPT_ENCODING, AUTHORIZATION, CONTENT_LENGTH, CONTENT_RANGE, ETAG, HeaderMap, - HeaderValue, RANGE, - }, - redirect, -}; use url::Url; use blockzilla_source::{RangeSource, SourceError, SourceResult, validate_object_name}; @@ -31,12 +22,18 @@ use blockzilla_source::{RangeSource, SourceError, SourceResult, validate_object_ use retry::RetryCause; pub use retry::{HttpRetryPolicy, HttpRetryStats}; pub use s3::{S3Credentials, S3PayloadHash, S3SigV4Signer}; +use signing::OutgoingHeader; pub use signing::{HttpRequestSigner, HttpRequestToSign}; +pub use transport::HttpJsonClient; +use transport::{ + HttpResponse, OriginTransport, ResponseHead, TransportError, validate_header_value, +}; // Existing archive-gateway route contract; not a dependency on the V2 decoder. const GENERATION_MANIFEST_FILE: &str = "archive-v2-generation.json"; const DEFAULT_MAX_MANIFEST_BYTES: usize = 4 * 1024 * 1024; +const CANCEL_SLEEP_SLICE: Duration = Duration::from_millis(25); /// Exact HTTP work completed by one source and all its clones. /// @@ -152,16 +149,16 @@ impl Default for HttpRangeSourceOptions { /// Blocking HTTP Range source for the Blockzilla read gateway. /// -/// The secret is held only as an already-redacted header value or inside a +/// The secret is held only in a private field redacted in `Debug` or inside a /// request signer. `Debug` never prints either. Redirects and ambient HTTP /// proxies are disabled so a bearer token or a signed request cannot be /// forwarded to a different origin. #[derive(Clone)] pub struct HttpRangeSource { - client: Client, + transport: OriginTransport, base_url: Url, epoch: u64, - authorization: Option, + authorization: Option, signer: Option>, max_manifest_bytes: usize, object_path_layout: HttpObjectPathLayout, @@ -297,20 +294,21 @@ impl HttpRangeSource { Some("") => { return Err(SourceError::Protocol("bearer token is empty".into())); } - Some(token) => Some(HeaderValue::from_str(&format!("Bearer {token}")).map_err( - |_| SourceError::Protocol("bearer token contains invalid header bytes".into()), - )?), + Some(token) => { + let value = format!("Bearer {token}"); + if !validate_header_value(&value) { + return Err(SourceError::Protocol( + "bearer token contains invalid header bytes".into(), + )); + } + Some(value) + } None => None, }; - let client = Client::builder() - .connect_timeout(options.connect_timeout) - .timeout(options.request_timeout) - .redirect(redirect::Policy::none()) - .no_proxy() - .build() - .map_err(|error| SourceError::Protocol(format!("build HTTP range client: {error}")))?; + let transport = + OriginTransport::new(&base_url, options.connect_timeout, options.request_timeout)?; Ok(Self { - client, + transport, base_url, epoch, authorization, @@ -375,6 +373,26 @@ impl HttpRangeSource { .ok_or_else(|| SourceError::NotFound(object.to_owned())) } + /// Return an already-pinned strong identity verified earlier on this source, + /// avoiding a redundant network HEAD request when the caller just probed + /// the same object. + pub fn pinned_strong_identity(&self, object: &str) -> SourceResult> { + validate_object_name(object).map_err(|_| SourceError::InvalidName(object.to_owned()))?; + let objects = self.observed_objects.lock().map_err(|_| { + SourceError::Protocol("HTTP object-identity binding cache is poisoned".into()) + })?; + match objects.get(object) { + Some(ObservedObjectIdentity::Present { + length, + strong_etag: Some(strong_etag), + }) => Ok(Some(HttpObjectIdentity { + length: *length, + strong_etag: strong_etag.clone(), + })), + _ => Ok(None), + } + } + fn record_head_request(&self) { self.counters.head_requests.fetch_add(1, Ordering::Relaxed); } @@ -383,13 +401,13 @@ impl HttpRangeSource { self.counters.get_requests.fetch_add(1, Ordering::Relaxed); } - fn record_retry(&self, method: &Method, cause: RetryCause) { + fn record_retry(&self, method: &str, cause: RetryCause) { let counters = self.counters.as_ref(); let counter = match cause { RetryCause::Transport => &counters.transport_error_retries, RetryCause::RateLimited => &counters.rate_limited_retries, RetryCause::ServerError => { - if *method == Method::GET { + if method == "GET" { counters .server_error_retries .fetch_add(1, Ordering::Relaxed); @@ -483,38 +501,40 @@ impl HttpRangeSource { require_strong_etag: bool, ) -> SourceResult> { let url = self.object_url(object)?; - self.request_with_retry(Method::HEAD, &url, None, |response| { - self.head_response_identity(&response, object, require_strong_etag) + self.request_with_retry("HEAD", object, &url, None, None, |response| { + self.head_response_identity(&response.head, object, require_strong_etag) .map_err(AttemptError::Final) }) } fn head_response_identity( &self, - response: &Response, + head: &ResponseHead, object: &str, require_strong_etag: bool, ) -> SourceResult> { - if response.status() == StatusCode::NOT_FOUND { + if head.status == 404 { self.bind_object_absence(object)?; return Ok(None); } - if response.status() != StatusCode::OK { + if head.status != 200 { return Err(SourceError::Protocol(format!( "HEAD for {object} returned HTTP {}", - response.status() + head.status_display() ))); } - let value = response.headers().get(CONTENT_LENGTH).ok_or_else(|| { - SourceError::Protocol(format!("HEAD for {object} omitted Content-Length")) - })?; - let value = value.to_str().map_err(|_| { - SourceError::Protocol(format!("HEAD for {object} has invalid Content-Length")) - })?; - let length = value.parse::().map_err(|_| { + let value = head + .header_str("content-length") + .ok_or_else(|| { + SourceError::Protocol(format!("HEAD for {object} omitted Content-Length")) + })? + .map_err(|_| { + SourceError::Protocol(format!("HEAD for {object} has invalid Content-Length")) + })?; + let length = value.trim().parse::().map_err(|_| { SourceError::Protocol(format!("HEAD for {object} has invalid Content-Length")) })?; - let strong_etag = strong_etag(response.headers(), object)?; + let strong_etag = strong_etag(head, object)?; if require_strong_etag && strong_etag.is_none() { return Err(SourceError::Protocol(format!( "HEAD for {object} requires one exact strong ETag" @@ -564,17 +584,22 @@ impl HttpRangeSource { /// read and sign the complete request. fn send_once( &self, - method: &Method, + method: &str, + object: &str, url: &Url, - range: Option<&HeaderValue>, - ) -> Result { - let mut headers = HeaderMap::with_capacity(8); - headers.insert(ACCEPT_ENCODING, HeaderValue::from_static("identity")); + range: Option<&str>, + cancelled: Option<&AtomicBool>, + ) -> Result { + if is_cancelled(cancelled) { + return Err(SendError::Final(cancelled_io_error(object))); + } + let mut headers = Vec::with_capacity(8); + headers.push(OutgoingHeader::new("accept-encoding", "identity", false)); if let Some(range) = range { - headers.insert(RANGE, range.clone()); + headers.push(OutgoingHeader::new("range", range, false)); } if let Some(value) = &self.authorization { - headers.insert(AUTHORIZATION, value.clone()); + headers.push(OutgoingHeader::new("authorization", value.as_str(), true)); } if let Some(signer) = &self.signer { signer @@ -585,20 +610,20 @@ impl HttpRangeSource { }) .map_err(SendError::Final)?; } - let mut request = Request::new(method.clone(), url.clone()); - *request.headers_mut() = headers; - if *method == Method::HEAD { + if method == "HEAD" { self.record_head_request(); } else { self.record_get_request(); } - self.client.execute(request).map_err(|error| { - if is_transient_transport_error(&error) { - SendError::Transport(error) - } else { - SendError::Final(sanitize_http_error(error)) - } - }) + self.transport + .send_request_headers_cancellable(method, url.path(), &headers, None, cancelled) + .map_err(|error| match error { + TransportError::Cancelled => SendError::Final(cancelled_io_error(object)), + TransportError::Transport(io_error) => SendError::Transport(io_error), + TransportError::Protocol(message) => { + SendError::Final(SourceError::Protocol(message)) + } + }) } /// Send one call with the retry policy. `handle` checks each response @@ -613,10 +638,12 @@ impl HttpRangeSource { /// the result. fn request_with_retry( &self, - method: Method, + method: &str, + object: &str, url: &Url, - range: Option<&HeaderValue>, - mut handle: impl FnMut(Response) -> Result, + range: Option<&str>, + cancelled: Option<&AtomicBool>, + mut handle: impl FnMut(HttpResponse) -> Result, ) -> SourceResult { let policy = self.retry_policy; let mut body_attempt = 0_u32; @@ -625,17 +652,23 @@ impl HttpRangeSource { // Response retries done in this body attempt. let mut retry = 0_u32; let response = loop { + if is_cancelled(cancelled) { + return Err(cancelled_io_error(object)); + } let can_retry = retry.saturating_add(1) < policy.max_attempts; - let (cause, delay) = match self.send_once(&method, url, range) { + let (cause, delay) = match self.send_once(method, object, url, range, cancelled) { Err(SendError::Final(error)) => return Err(error), - Err(SendError::Transport(_)) if can_retry => { + Err(SendError::Transport(_)) if can_retry && !is_cancelled(cancelled) => { (RetryCause::Transport, policy.backoff(retry)) } - Err(SendError::Transport(error)) => return Err(sanitize_http_error(error)), + Err(SendError::Transport(error)) => { + return Err( + TransportError::Transport(error).into_source_error(Some(object)) + ); + } Ok(response) => { - self.check_origin(&response)?; - let status_retry = if can_retry { - policy.status_retry(&response, retry) + let status_retry = if can_retry && !is_cancelled(cancelled) { + policy.status_retry(&response.head, retry) } else { None }; @@ -652,18 +685,16 @@ impl HttpRangeSource { } } }; - if !delay.is_zero() { - std::thread::sleep(delay); - } - self.record_retry(&method, cause); + sleep_cancellable(delay, object, cancelled)?; + self.record_retry(method, cause); retry += 1; }; match handle(response) { Ok(value) => return Ok(value), - Err(AttemptError::Body(_)) if can_retry_body => { + Err(AttemptError::Body(_)) if can_retry_body && !is_cancelled(cancelled) => { // Start over at the original offset, at once. A partial // body never enters a cache. - self.record_retry(&method, RetryCause::IncompleteBody); + self.record_retry(method, RetryCause::IncompleteBody); body_attempt += 1; } Err(AttemptError::Body(error) | AttemptError::Final(error)) => return Err(error), @@ -671,15 +702,6 @@ impl HttpRangeSource { } } - fn check_origin(&self, response: &Response) -> SourceResult<()> { - if response.url().origin() != self.base_url.origin() { - return Err(SourceError::Protocol( - "gateway response crossed origin".into(), - )); - } - Ok(()) - } - fn full_manifest(&self, expected_length: usize) -> SourceResult> { if expected_length > self.max_manifest_bytes { return Err(SourceError::Protocol(format!( @@ -688,44 +710,52 @@ impl HttpRangeSource { ))); } let url = self.object_url(GENERATION_MANIFEST_FILE)?; - self.request_with_retry(Method::GET, &url, None, |mut response| { - self.check_manifest_response(&response, expected_length) - .map_err(AttemptError::Final)?; - let mut bytes = Vec::new(); - let result = read_bounded_into( - &mut response, - expected_length, - GENERATION_MANIFEST_FILE, - &mut bytes, - ); - self.record_returned_body(bytes.len()); - result.map_err(|error| body_attempt_error(error, expected_length))?; - Ok(bytes) - }) + self.request_with_retry( + "GET", + GENERATION_MANIFEST_FILE, + &url, + None, + None, + |mut response| { + self.check_manifest_response(&response.head, expected_length) + .map_err(AttemptError::Final)?; + let mut bytes = Vec::new(); + let mut body_bytes = 0usize; + let result = response.read_exact_into_vec( + expected_length, + GENERATION_MANIFEST_FILE, + &mut bytes, + &mut body_bytes, + ); + self.record_returned_body(body_bytes); + result.map_err(|error| body_attempt_error(error, expected_length))?; + Ok(bytes) + }, + ) } fn check_manifest_response( &self, - response: &Response, + head: &ResponseHead, expected_length: usize, ) -> SourceResult<()> { - if response.status() == StatusCode::NOT_FOUND { + if head.status == 404 { self.bind_object_absence(GENERATION_MANIFEST_FILE)?; return Err(SourceError::NotFound(GENERATION_MANIFEST_FILE.to_owned())); } - if response.status() != StatusCode::OK { + if head.status != 200 { return Err(SourceError::Protocol(format!( "manifest GET returned HTTP {}", - response.status() + head.status_display() ))); } - let response_etag = strong_etag(response.headers(), GENERATION_MANIFEST_FILE)?; + let response_etag = strong_etag(head, GENERATION_MANIFEST_FILE)?; self.bind_object_identity( GENERATION_MANIFEST_FILE, expected_length as u64, response_etag.as_deref(), )?; - enforce_content_length(response, expected_length) + enforce_content_length(head, expected_length) } /// Read one exact range with the retry policy. `read_body` fills the @@ -736,7 +766,8 @@ impl HttpRangeSource { object: &str, offset: u64, length: usize, - mut read_body: impl FnMut(&mut Response) -> (SourceResult<()>, usize), + cancelled: Option<&AtomicBool>, + mut read_body: impl FnMut(&mut HttpResponse) -> (SourceResult<()>, usize), ) -> SourceResult<()> { debug_assert!(length != 0); debug_assert!(object != GENERATION_MANIFEST_FILE); @@ -748,57 +779,65 @@ impl HttpRangeSource { .ok_or_else(|| SourceError::Protocol(format!("range overflow for {object}")))?; let end_inclusive = end_exclusive - 1; let url = self.object_url(object)?; - let range = HeaderValue::from_str(&format!("bytes={offset}-{end_inclusive}")) - .map_err(|_| SourceError::Protocol(format!("invalid range header for {object}")))?; - self.request_with_retry(Method::GET, &url, Some(&range), |mut response| { - self.check_range_response( - &response, - object, - offset, - end_inclusive, - end_exclusive, - length, - ) - .map_err(AttemptError::Final)?; - let (result, body_bytes) = read_body(&mut response); - self.record_returned_body(body_bytes); - result.map_err(|error| body_attempt_error(error, length)) - }) + let range = format!("bytes={offset}-{end_inclusive}"); + self.request_with_retry( + "GET", + object, + &url, + Some(&range), + cancelled, + |mut response| { + self.check_range_response( + &response.head, + object, + offset, + end_inclusive, + end_exclusive, + length, + ) + .map_err(AttemptError::Final)?; + let (result, body_bytes) = read_body(&mut response); + self.record_returned_body(body_bytes); + result.map_err(|error| body_attempt_error(error, length)) + }, + ) } fn check_range_response( &self, - response: &Response, + head: &ResponseHead, object: &str, offset: u64, end_inclusive: u64, end_exclusive: u64, length: usize, ) -> SourceResult<()> { - if response.status() == StatusCode::NOT_FOUND { + if head.status == 404 { self.bind_object_absence(object)?; return Err(SourceError::NotFound(object.to_owned())); } - if response.status() != StatusCode::PARTIAL_CONTENT { + if head.status != 206 { return Err(SourceError::Protocol(format!( "range GET for {object} returned HTTP {}, expected 206", - response.status() + head.status_display() ))); } - enforce_content_length(response, length)?; - let content_range = response.headers().get(CONTENT_RANGE).ok_or_else(|| { - SourceError::Protocol(format!("range GET for {object} omitted Content-Range")) - })?; - let content_range = content_range.to_str().map_err(|_| { - SourceError::Protocol(format!("range GET for {object} has invalid Content-Range")) - })?; - let (actual_start, actual_end, total) = - parse_content_range(content_range).ok_or_else(|| { + enforce_content_length(head, length)?; + let content_range = head + .header_str("content-range") + .ok_or_else(|| { + SourceError::Protocol(format!("range GET for {object} omitted Content-Range")) + })? + .map_err(|_| { + SourceError::Protocol(format!("range GET for {object} has invalid Content-Range")) + })?; + let (actual_start, actual_end, total) = parse_content_range(content_range.trim()) + .ok_or_else(|| { SourceError::Protocol(format!( "range GET for {object} has malformed Content-Range" )) })?; - let response_etag = strong_etag(response.headers(), object)?; + let response_etag = strong_etag(head, object)?; self.bind_object_identity(object, total, response_etag.as_deref())?; if actual_start != offset || actual_end != end_inclusive || end_exclusive > total { return Err(SourceError::Protocol(format!( @@ -807,60 +846,14 @@ impl HttpRangeSource { } Ok(()) } -} - -/// One failed attempt. -enum AttemptError { - /// Stop the call with this error. - Final(SourceError), - /// A body read error or a body that ended early. The policy can retry it. - Body(SourceError), -} -enum SendError { - /// A transport failure before a response. The policy can retry it. - Transport(reqwest::Error), - /// A request that cannot be built or signed, or a permanent failure. - Final(SourceError), -} - -fn body_attempt_error(error: SourceError, expected: usize) -> AttemptError { - if is_incomplete_range_body(&error, expected) { - AttemptError::Body(error) - } else { - AttemptError::Final(error) - } -} - -/// Connect failures, timeouts, and resets or closed connections before a -/// response are transient. Request-build errors are not. -fn is_transient_transport_error(error: &reqwest::Error) -> bool { - !error.is_builder() && (error.is_request() || error.is_connect() || error.is_timeout()) -} - -impl RangeSource for HttpRangeSource { - fn recommended_read_concurrency(&self) -> usize { - 8 - } - - fn size(&self, object: &str) -> SourceResult> { - Ok(self - .head_identity(object, false)? - .map(|identity| identity.length)) - } - - fn read_range(&self, object: &str, offset: u64, length: usize) -> SourceResult> { - let mut bytes = Vec::new(); - self.read_range_into(object, offset, length, &mut bytes)?; - Ok(bytes) - } - - fn read_range_into( + fn read_range_into_internal( &self, object: &str, offset: u64, length: usize, destination: &mut Vec, + cancelled: Option<&AtomicBool>, ) -> SourceResult<()> { if length == 0 { let size = self @@ -888,17 +881,25 @@ impl RangeSource for HttpRangeSource { } // A retry starts over at the original offset. The next response // repeats all range and object-identity checks. - self.read_range_attempts(object, offset, length, |response| { - let result = read_bounded_into(response, length, object, destination); - (result, destination.len()) + self.read_range_attempts(object, offset, length, cancelled, |response| { + let mut body_bytes = 0usize; + let result = response.read_exact_into_vec_cancellable( + length, + object, + destination, + &mut body_bytes, + cancelled, + ); + (result, body_bytes) }) } - fn read_range_into_slice( + fn read_range_into_slice_internal( &self, object: &str, offset: u64, destination: &mut [u8], + cancelled: Option<&AtomicBool>, ) -> SourceResult<()> { let length = destination.len(); if length == 0 { @@ -925,16 +926,265 @@ impl RangeSource for HttpRangeSource { destination.copy_from_slice(&bytes); return Ok(()); } - self.read_range_attempts(object, offset, length, |response| { - let mut body_bytes = 0_usize; - let result = read_bounded_into_slice(response, destination, object, &mut body_bytes); + self.read_range_attempts(object, offset, length, cancelled, |response| { + let mut body_bytes = 0usize; + let result = response.read_exact_into_slice_cancellable( + destination, + object, + &mut body_bytes, + cancelled, + ); (result, body_bytes) }) } + + /// Open one ETag-pinned streaming `206 Partial Content` range response so + /// large contiguous slices can be streamed incrementally without waiting + /// for the entire range to buffer or incurring per-chunk HTTP round trips. + pub fn open_range_stream_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + cancelled: Option<&AtomicBool>, + ) -> SourceResult { + if length == 0 { + return Err(SourceError::Protocol(format!( + "streaming range length for {object} must be non-zero" + ))); + } + if object == GENERATION_MANIFEST_FILE { + return Err(SourceError::Protocol( + "streaming range reads do not support the generation manifest".into(), + )); + } + let length_u64 = u64::try_from(length).map_err(|_| { + SourceError::Protocol("requested HTTP range length does not fit u64".into()) + })?; + let end_exclusive = offset + .checked_add(length_u64) + .ok_or_else(|| SourceError::Protocol(format!("range overflow for {object}")))?; + let end_inclusive = end_exclusive - 1; + let url = self.object_url(object)?; + let range = format!("bytes={offset}-{end_inclusive}"); + let response = + self.request_with_retry("GET", object, &url, Some(&range), cancelled, |response| { + self.check_range_response( + &response.head, + object, + offset, + end_inclusive, + end_exclusive, + length, + ) + .map_err(AttemptError::Final)?; + Ok(response) + })?; + Ok(HttpRangeStream { + source: self.clone(), + object: object.to_owned(), + response, + remaining: length, + }) + } +} + +/// Active ETag-pinned HTTP `206 Partial Content` range stream that yields +/// caller-sized chunks incrementally from one open keep-alive TLS connection. +pub struct HttpRangeStream { + source: HttpRangeSource, + object: String, + response: HttpResponse, + remaining: usize, +} + +impl HttpRangeStream { + pub fn remaining(&self) -> usize { + self.remaining + } + + /// Read the next exact `destination.len()` bytes directly into `destination`. + pub fn read_chunk_exact( + &mut self, + destination: &mut [u8], + cancelled: Option<&AtomicBool>, + ) -> SourceResult<()> { + let len = destination.len(); + if len > self.remaining { + return Err(SourceError::ShortRead { + object: self.object.clone(), + expected: len, + actual: self.remaining, + }); + } + let mut body_bytes = 0usize; + let result = self.response.read_stream_chunk_cancellable( + destination, + &self.object, + &mut body_bytes, + cancelled, + ); + self.source.record_returned_body(body_bytes); + result?; + self.remaining -= len; + Ok(()) + } + + /// Read the next exact `length` bytes into a reusable `Vec` without + /// re-zeroing already initialized storage. + pub fn read_chunk_into_vec( + &mut self, + length: usize, + destination: &mut Vec, + cancelled: Option<&AtomicBool>, + ) -> SourceResult<()> { + if destination.capacity() < length { + destination + .try_reserve_exact(length.saturating_sub(destination.len())) + .map_err(|error| { + SourceError::Protocol(format!( + "cannot reserve {length} stream chunk bytes for {}: {error}", + self.object + )) + })?; + } + if destination.len() < length { + destination.resize(length, 0); + } else { + destination.truncate(length); + } + self.read_chunk_exact(&mut destination[..length], cancelled) + } +} + +/// One failed attempt. +enum AttemptError { + /// Stop the call with this error. + Final(SourceError), + /// A body read error or a body that ended early. The policy can retry it. + Body(SourceError), +} + +enum SendError { + /// A transport failure before a response. The policy can retry it. + Transport(std::io::Error), + /// A request that cannot be built or signed, cancelled, or a protocol failure. + Final(SourceError), +} + +fn body_attempt_error(error: SourceError, expected: usize) -> AttemptError { + if is_incomplete_range_body(&error, expected) { + AttemptError::Body(error) + } else { + AttemptError::Final(error) + } } -fn strong_etag(headers: &HeaderMap, object: &str) -> SourceResult> { - let mut values = headers.get_all(ETAG).iter(); +#[inline] +fn is_cancelled(cancelled: Option<&AtomicBool>) -> bool { + cancelled.is_some_and(|flag| flag.load(Ordering::Acquire)) +} + +fn cancelled_io_error(object: &str) -> SourceError { + SourceError::Io { + object: object.to_owned(), + source: std::io::Error::new( + std::io::ErrorKind::Interrupted, + "HTTP range request cancelled", + ), + } +} + +fn sleep_cancellable( + delay: Duration, + object: &str, + cancelled: Option<&AtomicBool>, +) -> SourceResult<()> { + if delay.is_zero() { + return Ok(()); + } + let Some(flag) = cancelled else { + std::thread::sleep(delay); + return Ok(()); + }; + let deadline = std::time::Instant::now() + delay; + loop { + if flag.load(Ordering::Acquire) { + return Err(cancelled_io_error(object)); + } + let Some(remaining) = deadline.checked_duration_since(std::time::Instant::now()) else { + return Ok(()); + }; + if remaining.is_zero() { + return Ok(()); + } + std::thread::sleep(remaining.min(CANCEL_SLEEP_SLICE)); + } +} + +impl RangeSource for HttpRangeSource { + fn recommended_read_concurrency(&self) -> usize { + std::thread::available_parallelism() + .map(usize::from) + .unwrap_or(8) + .clamp(8, 32) + } + + fn size(&self, object: &str) -> SourceResult> { + Ok(self + .head_identity(object, false)? + .map(|identity| identity.length)) + } + + fn read_range(&self, object: &str, offset: u64, length: usize) -> SourceResult> { + let mut bytes = Vec::new(); + self.read_range_into(object, offset, length, &mut bytes)?; + Ok(bytes) + } + + fn read_range_into( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + ) -> SourceResult<()> { + self.read_range_into_internal(object, offset, length, destination, None) + } + + fn read_range_into_slice( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + ) -> SourceResult<()> { + self.read_range_into_slice_internal(object, offset, destination, None) + } + + fn read_range_into_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + cancelled: &AtomicBool, + ) -> SourceResult<()> { + self.read_range_into_internal(object, offset, length, destination, Some(cancelled)) + } + + fn read_range_into_slice_cancellable( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + cancelled: &AtomicBool, + ) -> SourceResult<()> { + self.read_range_into_slice_internal(object, offset, destination, Some(cancelled)) + } +} + +fn strong_etag(head: &ResponseHead, object: &str) -> SourceResult> { + let mut values = head.header_values("etag"); let Some(value) = values.next() else { return Ok(None); }; @@ -943,9 +1193,13 @@ fn strong_etag(headers: &HeaderMap, object: &str) -> SourceResult "response for {object} has multiple ETag fields" ))); } - let value = value.to_str().map_err(|_| { - SourceError::Protocol(format!("response for {object} has a non-ASCII ETag")) - })?; + let value = std::str::from_utf8(value) + .ok() + .filter(|s| s.is_ascii()) + .ok_or_else(|| { + SourceError::Protocol(format!("response for {object} has a non-ASCII ETag")) + })? + .trim(); let (weak, opaque) = match value.strip_prefix("W/") { Some(opaque) => (true, opaque), None => (false, value), @@ -965,12 +1219,11 @@ fn strong_etag(headers: &HeaderMap, object: &str) -> SourceResult Ok((!weak).then(|| value.to_owned())) } -fn enforce_content_length(response: &Response, expected: usize) -> SourceResult<()> { - if let Some(value) = response.headers().get(CONTENT_LENGTH) { +fn enforce_content_length(head: &ResponseHead, expected: usize) -> SourceResult<()> { + if let Some(value) = head.header_str("content-length") { let value = value - .to_str() .ok() - .and_then(|value| value.parse::().ok()) + .and_then(|value| value.trim().parse::().ok()) .ok_or_else(|| SourceError::Protocol("invalid Content-Length".into()))?; if value != expected as u64 { return Err(SourceError::Protocol(format!( @@ -985,7 +1238,7 @@ fn is_incomplete_range_body(error: &SourceError, expected: usize) -> bool { match error { // This branch only receives errors produced while reading an already // validated response body. It includes transport timeouts, resets, and - // reqwest's IncompleteBody/UnexpectedEof error. + // unexpected EOFs. SourceError::Io { .. } => true, SourceError::ShortRead { expected: actual_expected, @@ -996,87 +1249,6 @@ fn is_incomplete_range_body(error: &SourceError, expected: usize) -> bool { } } -fn read_bounded_into( - response: &mut Response, - expected: usize, - object: &str, - destination: &mut Vec, -) -> SourceResult<()> { - let allocation = expected.checked_add(1).ok_or_else(|| { - SourceError::Protocol(format!("response allocation bound overflows for {object}")) - })?; - destination.clear(); - if destination.capacity() < allocation { - destination.try_reserve_exact(allocation).map_err(|error| { - SourceError::Protocol(format!( - "cannot reserve {allocation} bounded response bytes for {object}: {error}" - )) - })?; - } - let bound = u64::try_from(expected) - .unwrap_or(u64::MAX) - .saturating_add(1); - response - .take(bound) - .read_to_end(destination) - .map_err(|source| SourceError::Io { - object: object.to_owned(), - source, - })?; - if destination.len() != expected { - return Err(SourceError::ShortRead { - object: object.to_owned(), - expected, - actual: destination.len(), - }); - } - Ok(()) -} - -fn read_bounded_into_slice( - response: &mut Response, - destination: &mut [u8], - object: &str, - body_bytes: &mut usize, -) -> SourceResult<()> { - let expected = destination.len(); - let mut read = 0_usize; - *body_bytes = 0; - while read < expected { - let count = response - .read(&mut destination[read..]) - .map_err(|source| SourceError::Io { - object: object.to_owned(), - source, - })?; - if count == 0 { - return Err(SourceError::ShortRead { - object: object.to_owned(), - expected, - actual: read, - }); - } - read += count; - *body_bytes = read; - } - let mut extra = [0_u8; 1]; - let extra = response - .read(&mut extra) - .map_err(|source| SourceError::Io { - object: object.to_owned(), - source, - })?; - *body_bytes = read.saturating_add(extra); - if extra != 0 { - return Err(SourceError::ShortRead { - object: object.to_owned(), - expected, - actual: expected.saturating_add(extra), - }); - } - Ok(()) -} - fn parse_content_range(value: &str) -> Option<(u64, u64, u64)> { let value = value.strip_prefix("bytes ")?; let (range, total) = value.split_once('/')?; @@ -1087,16 +1259,13 @@ fn parse_content_range(value: &str) -> Option<(u64, u64, u64)> { (start <= end && end < total).then_some((start, end, total)) } -fn sanitize_http_error(error: reqwest::Error) -> SourceError { - // reqwest errors can contain a URL but do not include request headers. - // Remove the URL so credentials can never become diagnostic data. Keep the - // message generic anyway: the text is the same as before the retry policy. - SourceError::Protocol(format!("HTTP request failed ({})", error.without_url())) -} - #[cfg(test)] mod tests { - use std::{io::Write as _, net::TcpListener, thread}; + use std::{ + io::{Read as _, Write as _}, + net::TcpListener, + thread, + }; use super::*; @@ -1396,19 +1565,42 @@ mod tests { #[test] fn server_error_retry_is_bounded_and_does_not_retry_protocol_errors() { for (response, attempts) in [ - (&b"HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], 3), - (&b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 100\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], 1), - (&b"HTTP/1.1 412 Precondition Failed\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], 1), - (&b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 2-3/4\r\nConnection: close\r\n\r\ncd"[..], 1), + ( + &b"HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], + 3, + ), + ( + &b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 100\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], + 1, + ), + ( + &b"HTTP/1.1 412 Precondition Failed\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"[..], + 1, + ), + ( + &b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 2-3/4\r\nConnection: close\r\n\r\ncd"[..], + 1, + ), ] { let (base_url, server) = serve_once( vec!["GET /gateway/v1/epochs/7/files/thing.bin HTTP/1.1"; attempts], vec![response; attempts], ); - let source = HttpRangeSource::with_options(base_url, 7, None, HttpRangeSourceOptions { - allow_insecure_http: true, ..HttpRangeSourceOptions::default() - }).unwrap(); - assert!(source.read_range_into_slice("thing.bin", 1, &mut [0; 2]).is_err()); + let source = HttpRangeSource::with_options( + base_url, + 7, + None, + HttpRangeSourceOptions { + allow_insecure_http: true, + ..HttpRangeSourceOptions::default() + }, + ) + .unwrap(); + assert!( + source + .read_range_into_slice("thing.bin", 1, &mut [0; 2]) + .is_err() + ); assert_eq!(source.stats().get_requests, attempts as u64); assert_eq!(source.stats().server_error_retries, (attempts - 1) as u64); assert_eq!(source.stats().returned_body_bytes, 0); @@ -2009,7 +2201,9 @@ mod tests { #[test] fn rate_limited_retry_honours_retry_after_zero() { let (base_url, server) = serve_replies(vec![ - Reply::Send(b"HTTP/1.1 429 Too Many Requests\r\nRetry-After: 0\r\nContent-Length: 4\r\nConnection: close\r\n\r\nslow"), + Reply::Send( + b"HTTP/1.1 429 Too Many Requests\r\nRetry-After: 0\r\nContent-Length: 4\r\nConnection: close\r\n\r\nslow", + ), Reply::Send(RANGE_BC), ]); let source = HttpRangeSource::with_options( @@ -2040,7 +2234,9 @@ mod tests { #[test] fn retry_after_waits_up_to_the_cap_and_longer_or_dated_values_fail_at_once() { let (base_url, server) = serve_replies(vec![ - Reply::Send(b"HTTP/1.1 429 Too Many Requests\r\nRetry-After: 1\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"), + Reply::Send( + b"HTTP/1.1 429 Too Many Requests\r\nRetry-After: 1\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + ), Reply::Send(RANGE_BC), ]); let source = @@ -2079,7 +2275,7 @@ mod tests { let cases: [(Vec, &str, HttpRetryStats); 5] = [ ( vec![Reply::Close; 4], - "HTTP request failed (error sending request)", + "HTTP request failed (", HttpRetryStats { transport_error_retries: 3, ..HttpRetryStats::default() @@ -2104,7 +2300,7 @@ mod tests { // The connection closes before Content-Length is reached. ( vec![Reply::Send(SHORT_BODY); 4], - "I/O error for thing.bin: request or response body error", + "short range read for thing.bin: got 1 bytes, expected 2", HttpRetryStats { incomplete_body_retries: 3, ..HttpRetryStats::default() @@ -2145,10 +2341,11 @@ mod tests { ) .unwrap(); let error = source.size("thing.bin").unwrap_err().to_string(); - assert_eq!( - error, - "remote source protocol error: HTTP request failed (error sending request)" + assert!( + error.starts_with("remote source protocol error: HTTP request failed ("), + "{error}" ); + assert!(!error.contains(&address.to_string()), "{error}"); assert_eq!(source.stats().head_requests, 4); assert_eq!(source.retry_stats().transport_error_retries, 3); } @@ -2156,9 +2353,13 @@ mod tests { #[test] fn transport_retry_keeps_the_pinned_identity() { let (base_url, server) = serve_replies(vec![ - Reply::Send(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n"), + Reply::Send( + b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n", + ), Reply::Close, - Reply::Send(b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 1-2/4\r\nETag: \"v2\"\r\nConnection: close\r\n\r\nbc"), + Reply::Send( + b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 1-2/4\r\nETag: \"v2\"\r\nConnection: close\r\n\r\nbc", + ), ]); let source = HttpRangeSource::with_options(base_url, 7, None, fast_retry_options(3)).unwrap(); @@ -2175,11 +2376,21 @@ mod tests { fn head_and_manifest_calls_retry_transient_failures() { let (base_url, server) = serve_replies(vec![ Reply::Close, - Reply::Send(b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 0\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"), - Reply::Send(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n"), - Reply::Send(b"HTTP/1.1 429 Too Many Requests\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"), - Reply::Send(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\nte"), - Reply::Send(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\ntest"), + Reply::Send( + b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 0\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + ), + Reply::Send( + b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n", + ), + Reply::Send( + b"HTTP/1.1 429 Too Many Requests\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + ), + Reply::Send( + b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\nte", + ), + Reply::Send( + b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\ntest", + ), ]); let source = HttpRangeSource::with_options(base_url, 7, None, fast_retry_options(3)).unwrap(); @@ -2223,9 +2434,8 @@ mod tests { HttpRangeSource::with_options(base_url, 7, None, fast_retry_options(1)).unwrap(); let error = source.read_range("thing.bin", 1, 2).unwrap_err(); assert!( - error - .to_string() - .contains("HTTP request failed (error sending request)") + error.to_string().contains("HTTP request failed ("), + "{error}" ); assert_eq!(source.stats().get_requests, 1); assert_eq!(source.retry_stats().total(), 0); @@ -2249,8 +2459,12 @@ mod tests { const SECRET: &str = "r2-test-secret-key"; const TOKEN: &str = "r2-test-session/token+value="; let (base_url, server) = serve_replies(vec![ - Reply::Send(b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n"), - Reply::Send(b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 0\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"), + Reply::Send( + b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\n", + ), + Reply::Send( + b"HTTP/1.1 503 Service Unavailable\r\nRetry-After: 0\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + ), Reply::Send(RANGE_BC), ]); let credentials = S3Credentials::new( @@ -2395,4 +2609,178 @@ mod tests { assert_eq!(source.stats().requests(), 0); assert_eq!(source.retry_stats().total(), 0); } + + #[test] + fn keep_alive_reuses_single_tcp_connection_and_reconnects_when_stale() { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let address = listener.local_addr().unwrap(); + let server = thread::spawn(move || { + // Connection 1 serves HEAD + GET over keep-alive, then closes idle. + let (mut stream, _) = listener.accept().unwrap(); + let mut buf = [0u8; 1024]; + for response in [ + &b"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nETag: \"v1\"\r\nConnection: keep-alive\r\n\r\n"[..], + &b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 0-1/4\r\nETag: \"v1\"\r\nConnection: keep-alive\r\n\r\nab"[..], + ] { + let mut req = Vec::new(); + while !req.windows(4).any(|w| w == b"\r\n\r\n") { + let n = stream.read(&mut buf).unwrap(); + assert_ne!(n, 0); + req.extend_from_slice(&buf[..n]); + } + stream.write_all(response).unwrap(); + } + drop(stream); + + // Connection 2 handles transparent reconnect after idle close. + let (mut stream2, _) = listener.accept().unwrap(); + let mut req = Vec::new(); + while !req.windows(4).any(|w| w == b"\r\n\r\n") { + let n = stream2.read(&mut buf).unwrap(); + assert_ne!(n, 0); + req.extend_from_slice(&buf[..n]); + } + stream2 + .write_all( + b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nContent-Range: bytes 2-3/4\r\nETag: \"v1\"\r\nConnection: close\r\n\r\ncd", + ) + .unwrap(); + }); + + let source = HttpRangeSource::with_options( + format!("http://{address}/gateway"), + 7, + None, + HttpRangeSourceOptions { + allow_insecure_http: true, + ..HttpRangeSourceOptions::default() + }, + ) + .unwrap(); + assert_eq!(source.strong_identity("thing.bin").unwrap().length, 4); + assert_eq!( + source.pinned_strong_identity("thing.bin").unwrap(), + Some(HttpObjectIdentity { + length: 4, + strong_etag: "\"v1\"".into(), + }) + ); + assert_eq!(source.read_range("thing.bin", 0, 2).unwrap(), b"ab"); + // Give the server thread a brief moment to close the idle socket so + // the third request exercises transparent stale-connection recovery. + thread::sleep(Duration::from_millis(20)); + assert_eq!(source.read_range("thing.bin", 2, 2).unwrap(), b"cd"); + assert_eq!(source.stats().head_requests, 1); + assert_eq!(source.stats().get_requests, 2); + assert_eq!(source.stats().returned_body_bytes, 4); + server.join().unwrap(); + } + + #[test] + fn rejects_conflicting_transfer_encoding_and_content_length() { + let (base_url, server) = serve_once( + vec!["GET /gateway/v1/epochs/7/files/thing.bin HTTP/1.1"], + vec![ + b"HTTP/1.1 206 Partial Content\r\nContent-Length: 2\r\nTransfer-Encoding: chunked\r\nContent-Range: bytes 0-1/4\r\nConnection: close\r\n\r\n2\r\nab\r\n0\r\n\r\n", + ], + ); + let source = HttpRangeSource::with_options( + base_url, + 7, + None, + HttpRangeSourceOptions { + allow_insecure_http: true, + ..HttpRangeSourceOptions::default() + }, + ) + .unwrap(); + let error = source.read_range("thing.bin", 0, 2).unwrap_err(); + assert!(error.to_string().contains("Transfer-Encoding")); + server.join().unwrap(); + } + + #[test] + fn cancellable_range_read_aborts_immediately_when_flag_is_set() { + let source = HttpRangeSource::with_options( + "http://127.0.0.1:9", + 7, + None, + HttpRangeSourceOptions { + allow_insecure_http: true, + ..HttpRangeSourceOptions::default() + }, + ) + .unwrap(); + let cancelled = AtomicBool::new(true); + let mut buf = Vec::new(); + let err = source + .read_range_into_cancellable("thing.bin", 0, 16, &mut buf, &cancelled) + .unwrap_err(); + assert!(matches!( + err, + SourceError::Io { source, .. } if source.kind() == std::io::ErrorKind::Interrupted + )); + assert_eq!(source.stats().get_requests, 0); + } + + #[test] + fn streaming_range_yields_exact_chunks_and_recycles_connection() { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let address = listener.local_addr().unwrap(); + let server = thread::spawn(move || { + // One keep-alive TCP connection serves an 8-byte streamed range and + // then immediately handles a follow-up 4-byte range once drained. + let (mut stream, _) = listener.accept().unwrap(); + let mut buf = [0u8; 1024]; + for response in [ + &b"HTTP/1.1 206 Partial Content\r\nContent-Length: 8\r\nContent-Range: bytes 0-7/16\r\nETag: \"v1\"\r\nConnection: keep-alive\r\n\r\nabcdefgh"[..], + &b"HTTP/1.1 206 Partial Content\r\nContent-Length: 4\r\nContent-Range: bytes 8-11/16\r\nETag: \"v1\"\r\nConnection: close\r\n\r\nijkl"[..], + ] { + let mut req = Vec::new(); + while !req.windows(4).any(|w| w == b"\r\n\r\n") { + let n = stream.read(&mut buf).unwrap(); + assert_ne!(n, 0); + req.extend_from_slice(&buf[..n]); + } + stream.write_all(response).unwrap(); + } + }); + + let source = HttpRangeSource::with_options( + format!("http://{address}/gateway"), + 7, + None, + HttpRangeSourceOptions { + allow_insecure_http: true, + ..HttpRangeSourceOptions::default() + }, + ) + .unwrap(); + + let cancelled = AtomicBool::new(false); + let mut range_stream = source + .open_range_stream_cancellable("thing.bin", 0, 8, Some(&cancelled)) + .unwrap(); + assert_eq!(range_stream.remaining(), 8); + + let mut chunk = Vec::new(); + range_stream + .read_chunk_into_vec(4, &mut chunk, Some(&cancelled)) + .unwrap(); + assert_eq!(chunk, b"abcd"); + assert_eq!(range_stream.remaining(), 4); + + range_stream + .read_chunk_into_vec(4, &mut chunk, Some(&cancelled)) + .unwrap(); + assert_eq!(chunk, b"efgh"); + assert_eq!(range_stream.remaining(), 0); + + // Draining the stream returned the keep-alive connection to the pool, so + // this second request completes on the same accepted TCP connection. + assert_eq!(source.read_range("thing.bin", 8, 4).unwrap(), b"ijkl"); + assert_eq!(source.stats().get_requests, 2); + assert_eq!(source.stats().returned_body_bytes, 12); + server.join().unwrap(); + } } diff --git a/crates/source/blockzilla-source-http/src/retry.rs b/crates/source/blockzilla-source-http/src/retry.rs index 73c9e9bf..b90bf1e8 100644 --- a/crates/source/blockzilla-source-http/src/retry.rs +++ b/crates/source/blockzilla-source-http/src/retry.rs @@ -2,10 +2,10 @@ use std::time::Duration; -use reqwest::{StatusCode, blocking::Response, header::RETRY_AFTER}; - use blockzilla_source::{SourceError, SourceResult}; +use crate::transport::ResponseHead; + /// Bounded retry policy for transient HTTP failures. /// /// The source sends a new request for one HEAD or GET after these causes: @@ -79,25 +79,22 @@ impl HttpRetryPolicy { /// longer wait than the cap. pub(crate) fn status_retry( &self, - response: &Response, + head: &ResponseHead, retry: u32, ) -> Option<(RetryCause, Duration)> { - let cause = match response.status() { - StatusCode::TOO_MANY_REQUESTS => RetryCause::RateLimited, - StatusCode::INTERNAL_SERVER_ERROR - | StatusCode::BAD_GATEWAY - | StatusCode::SERVICE_UNAVAILABLE - | StatusCode::GATEWAY_TIMEOUT => RetryCause::ServerError, + let cause = match head.status { + 429 => RetryCause::RateLimited, + 500 | 502 | 503 | 504 => RetryCause::ServerError, _ => return None, }; let backoff = self.backoff(retry); - match response.headers().get(RETRY_AFTER) { + match head.header_str("retry-after") { None => Some((cause, backoff)), Some(value) => { // Do not retry earlier than a server asks. Long waits, dates // and invalid values fail normally. They do not block this SDK // call for an unbounded interval. - let seconds = value.to_str().ok()?.parse::().ok()?; + let seconds = value.ok()?.trim().parse::().ok()?; let requested = Duration::from_secs(seconds); (requested <= self.max_backoff).then(|| (cause, backoff.max(requested))) } diff --git a/crates/source/blockzilla-source-http/src/s3.rs b/crates/source/blockzilla-source-http/src/s3.rs index ec535f0e..ed325a0d 100644 --- a/crates/source/blockzilla-source-http/src/s3.rs +++ b/crates/source/blockzilla-source-http/src/s3.rs @@ -243,7 +243,7 @@ impl S3SigV4Signer { } } let canonical = CanonicalRequest { - method: method.as_str(), + method, uri: canonical_uri(url), query: canonical_query(url), headers, @@ -525,16 +525,26 @@ fn protocol(message: impl Into) -> SourceError { mod tests { use std::{collections::HashMap, time::Duration}; - use reqwest::{ - Method, - header::{HeaderMap, HeaderValue, RANGE}, - }; - use super::*; + use crate::signing::OutgoingHeader; const EXAMPLE_ACCESS_KEY_ID: &str = "AKIAIOSFODNN7EXAMPLE"; const EXAMPLE_SECRET: &str = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"; + fn header_value<'a>(headers: &'a [OutgoingHeader], name: &str) -> Option<&'a str> { + headers + .iter() + .find(|header| header.name == name) + .map(|header| header.value.as_str()) + } + + fn header_is_sensitive(headers: &[OutgoingHeader], name: &str) -> bool { + headers + .iter() + .find(|header| header.name == name) + .is_some_and(|header| header.sensitive) + } + fn hex_bytes(text: &str) -> Vec { (0..text.len()) .step_by(2) @@ -595,14 +605,12 @@ mod tests { let signer = S3SigV4Signer::new(credentials, "us-east-1") .unwrap() .with_payload_hash(S3PayloadHash::EmptyBody); - let method = Method::GET; let url = Url::parse("https://examplebucket.s3.amazonaws.com/test.txt").unwrap(); - let mut headers = HeaderMap::new(); - headers.insert(RANGE, HeaderValue::from_static("bytes=0-9")); + let mut headers = vec![OutgoingHeader::new("range", "bytes=0-9", false)]; signer .sign_at( &mut HttpRequestToSign { - method: &method, + method: "GET", url: &url, headers: &mut headers, }, @@ -610,19 +618,24 @@ mod tests { ) .unwrap(); - assert_eq!(headers["x-amz-date"], "20130524T000000Z"); assert_eq!( - headers["x-amz-content-sha256"], - "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + header_value(&headers, "x-amz-date"), + Some("20130524T000000Z") + ); + assert_eq!( + header_value(&headers, "x-amz-content-sha256"), + Some("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") ); - assert!(headers.get("x-amz-security-token").is_none()); + assert!(header_value(&headers, "x-amz-security-token").is_none()); assert_eq!( - headers["authorization"], - "AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request, \ - SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, \ - Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41" + header_value(&headers, "authorization"), + Some( + "AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request, \ + SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, \ + Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41" + ) ); - assert!(headers["authorization"].is_sensitive()); + assert!(header_is_sensitive(&headers, "authorization")); // The intermediate canonical request and its hash are also in the // AWS documentation. @@ -665,35 +678,41 @@ mod tests { ) .unwrap(); let signer = S3SigV4Signer::for_r2(credentials); - let method = Method::HEAD; let url = Url::parse( "https://account.r2.cloudflarestorage.com/solana-archive-data/epoch%20200/a+b.bin", ) .unwrap(); - let mut headers = HeaderMap::new(); - headers.insert( - reqwest::header::ACCEPT_ENCODING, - HeaderValue::from_static("identity"), - ); + let mut headers = vec![OutgoingHeader::new("accept-encoding", "identity", false)]; signer .sign_at( &mut HttpRequestToSign { - method: &method, + method: "HEAD", url: &url, headers: &mut headers, }, UNIX_EPOCH + Duration::from_secs(1_795_609_496), ) .unwrap(); - assert_eq!(headers["x-amz-date"], "20261125T122456Z"); - assert_eq!(headers["x-amz-content-sha256"], "UNSIGNED-PAYLOAD"); - assert_eq!(headers["x-amz-security-token"], "session/token+example="); - assert_eq!(headers["accept-encoding"], "identity"); assert_eq!( - headers["authorization"], - "AWS4-HMAC-SHA256 Credential=0123456789abcdef0123456789abcdef/20261125/auto/s3/aws4_request, \ - SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, \ - Signature=558542bf343c18496a727fe459bc0d4b0db24f1bfeae57a4987371d3508f795a" + header_value(&headers, "x-amz-date"), + Some("20261125T122456Z") + ); + assert_eq!( + header_value(&headers, "x-amz-content-sha256"), + Some("UNSIGNED-PAYLOAD") + ); + assert_eq!( + header_value(&headers, "x-amz-security-token"), + Some("session/token+example=") + ); + assert_eq!(header_value(&headers, "accept-encoding"), Some("identity")); + assert_eq!( + header_value(&headers, "authorization"), + Some( + "AWS4-HMAC-SHA256 Credential=0123456789abcdef0123456789abcdef/20261125/auto/s3/aws4_request, \ + SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, \ + Signature=558542bf343c18496a727fe459bc0d4b0db24f1bfeae57a4987371d3508f795a" + ) ); } diff --git a/crates/source/blockzilla-source-http/src/signing.rs b/crates/source/blockzilla-source-http/src/signing.rs index 7285ec3f..35ee93ce 100644 --- a/crates/source/blockzilla-source-http/src/signing.rs +++ b/crates/source/blockzilla-source-http/src/signing.rs @@ -1,15 +1,52 @@ //! Request-signing hook for private object stores. -use reqwest::{ - Method, - header::{ - CONNECTION, CONTENT_LENGTH, HOST, HeaderMap, HeaderName, HeaderValue, TRANSFER_ENCODING, - }, -}; +use std::fmt; + use url::Url; use blockzilla_source::{SourceError, SourceResult}; +use crate::transport::validate_header_value; + +const FORBIDDEN_SIGNER_HEADERS: [&str; 4] = + ["host", "content-length", "transfer-encoding", "connection"]; + +/// One outgoing HTTP header, keeping lower-case field names and marking +/// signer-supplied values as sensitive. +#[derive(Clone)] +pub(crate) struct OutgoingHeader { + pub(crate) name: String, + pub(crate) value: String, + pub(crate) sensitive: bool, +} + +impl fmt::Debug for OutgoingHeader { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter + .debug_struct("OutgoingHeader") + .field("name", &self.name) + .field( + "value", + &if self.sensitive { + "" + } else { + self.value.as_str() + }, + ) + .finish() + } +} + +impl OutgoingHeader { + pub(crate) fn new(name: impl Into, value: impl Into, sensitive: bool) -> Self { + Self { + name: name.into(), + value: value.into(), + sensitive, + } + } +} + /// Adds authentication to each request that an /// [`HttpRangeSource`](crate::HttpRangeSource) sends. /// @@ -31,15 +68,15 @@ pub trait HttpRequestSigner: Send + Sync { /// URL authority: the host, and the port only when it is not the default port /// of the scheme. pub struct HttpRequestToSign<'a> { - pub(crate) method: &'a Method, + pub(crate) method: &'a str, pub(crate) url: &'a Url, - pub(crate) headers: &'a mut HeaderMap, + pub(crate) headers: &'a mut Vec, } impl HttpRequestToSign<'_> { /// The method in upper case, for example `GET` or `HEAD`. pub fn method(&self) -> &str { - self.method.as_str() + self.method } /// The exact URL that the source sends. @@ -50,7 +87,10 @@ impl HttpRequestToSign<'_> { /// The first value of one header, if it is present and is visible ASCII. /// The name is not case-sensitive. pub fn header(&self, name: &str) -> Option<&str> { - self.headers.get(name)?.to_str().ok() + self.headers + .iter() + .find(|header| header.name.eq_ignore_ascii_case(name)) + .map(|header| header.value.as_str()) } /// All header fields, with lower-case names. A name with more than one @@ -58,47 +98,87 @@ impl HttpRequestToSign<'_> { pub fn headers(&self) -> impl Iterator { self.headers .iter() - .map(|(name, value)| (name.as_str(), value.as_bytes())) + .map(|header| (header.name.as_str(), header.value.as_bytes())) } /// Add one header, or replace all values of the header with this name. /// /// The value is marked as sensitive. Errors do not contain the value. pub fn set_header(&mut self, name: &str, value: &str) -> SourceResult<()> { - let name = HeaderName::from_bytes(name.as_bytes()).map_err(|_| { - SourceError::Protocol("request signer used an invalid header name".into()) - })?; - if [HOST, CONTENT_LENGTH, TRANSFER_ENCODING, CONNECTION].contains(&name) { + if !is_valid_header_name(name) { + return Err(SourceError::Protocol( + "request signer used an invalid header name".into(), + )); + } + let lower = name.to_ascii_lowercase(); + if FORBIDDEN_SIGNER_HEADERS.contains(&lower.as_str()) { + return Err(SourceError::Protocol(format!( + "request signer cannot set the {lower} header" + ))); + } + if !validate_header_value(value) { return Err(SourceError::Protocol(format!( - "request signer cannot set the {name} header" + "request signer used an invalid value for the {lower} header" ))); } - let mut value = HeaderValue::from_str(value).map_err(|_| { - SourceError::Protocol(format!( - "request signer used an invalid value for the {name} header" - )) - })?; - value.set_sensitive(true); - self.headers.insert(name, value); + let mut replaced = false; + let mut index = 0usize; + while index < self.headers.len() { + if self.headers[index].name == lower { + if !replaced { + self.headers[index].value = value.to_owned(); + self.headers[index].sensitive = true; + replaced = true; + index += 1; + } else { + self.headers.remove(index); + } + } else { + index += 1; + } + } + if !replaced { + self.headers.push(OutgoingHeader::new(lower, value, true)); + } Ok(()) } } +/// Validate an HTTP header token name per RFC 7230 Section 3.2.6. +fn is_valid_header_name(name: &str) -> bool { + !name.is_empty() + && name.bytes().all(|byte| { + byte.is_ascii_alphanumeric() + || matches!( + byte, + b'!' | b'#' + | b'$' + | b'%' + | b'&' + | b'\'' + | b'*' + | b'+' + | b'-' + | b'.' + | b'^' + | b'_' + | b'`' + | b'|' + | b'~' + ) + }) +} + #[cfg(test)] mod tests { use super::*; #[test] fn signer_view_reads_and_sets_headers_without_echoing_values() { - let method = Method::GET; let url = Url::parse("https://example.test/bucket/key").unwrap(); - let mut headers = HeaderMap::new(); - headers.insert( - reqwest::header::RANGE, - HeaderValue::from_static("bytes=0-9"), - ); + let mut headers = vec![OutgoingHeader::new("range", "bytes=0-9", false)]; let mut request = HttpRequestToSign { - method: &method, + method: "GET", url: &url, headers: &mut headers, }; @@ -122,6 +202,11 @@ mod tests { assert!(!error.to_string().contains("secret-value")); let error = request.set_header("bad name", "value").unwrap_err(); assert!(error.to_string().contains("invalid header name")); - assert!(headers.get("x-custom").unwrap().is_sensitive()); + let custom = headers + .iter() + .find(|header| header.name == "x-custom") + .unwrap(); + assert!(custom.sensitive); + assert!(!format!("{custom:?}").contains("two")); } } diff --git a/crates/source/blockzilla-source-http/src/transport.rs b/crates/source/blockzilla-source-http/src/transport.rs new file mode 100644 index 00000000..cbf2f0b9 --- /dev/null +++ b/crates/source/blockzilla-source-http/src/transport.rs @@ -0,0 +1,1745 @@ +//! Direct pooled synchronous HTTP/1.1 (+ rustls) transport. +//! +//! Designed for high-throughput parallel byte-range streaming without an async +//! runtime (`tokio`/`hyper`). Each caller thread performs TCP I/O and TLS +//! decryption natively on its own CPU core, reading fixed-length response +//! bodies directly into caller-owned slices with zero extra copies. + +use std::{ + fmt, + io::{self, Read, Write}, + net::{SocketAddr, TcpStream, ToSocketAddrs}, + sync::{ + Arc, Mutex, OnceLock, + atomic::{AtomicBool, AtomicUsize, Ordering}, + }, + time::{Duration, Instant}, +}; + +use blockzilla_source::{SourceError, SourceResult}; +use rustls_pki_types::ServerName; +use rustls_platform_verifier::BuilderVerifierExt; +use url::Url; + +const CONN_BUF_BYTES: usize = 8 * 1024; +const MAX_RESPONSE_HEADER_BYTES: usize = 64 * 1024; +const MAX_RESPONSE_HEADERS: usize = 128; +const MAX_IDLE_CONNS: usize = 384; +const MAX_IDLE_AGE: Duration = Duration::from_secs(60); +const DNS_CACHE_TTL: Duration = Duration::from_secs(60); +const READ_STALL_TIMEOUT: Duration = Duration::from_secs(10); +const CANCEL_POLL_INTERVAL: Duration = Duration::from_millis(100); +const MAX_CHUNK_LINE_BYTES: usize = 1024; +const MAX_TRAILER_BYTES: usize = 16 * 1024; + +static SHARED_TLS_CONFIG: OnceLock, String>> = OnceLock::new(); + +fn shared_tls_config() -> SourceResult> { + let cached = SHARED_TLS_CONFIG.get_or_init(|| { + let provider = Arc::new(rustls::crypto::ring::default_provider()); + let config = rustls::ClientConfig::builder_with_provider(provider) + .with_safe_default_protocol_versions() + .map_err(|error| format!("configure TLS protocol versions: {error}"))? + .with_platform_verifier() + .map_err(|error| format!("initialize platform TLS verifier: {error}"))? + .with_no_client_auth(); + Ok(Arc::new(config)) + }); + match cached { + Ok(config) => Ok(Arc::clone(config)), + Err(message) => Err(SourceError::Protocol(format!( + "build HTTP range client: {message}" + ))), + } +} + +/// Validated origin endpoint. Connections are strictly pinned to this `(host, port)`. +#[derive(Clone)] +pub(crate) struct OriginTransport { + pool: Arc, +} + +impl fmt::Debug for OriginTransport { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter + .debug_struct("OriginTransport") + .field( + "scheme", + &if self.pool.tls.is_some() { + "https" + } else { + "http" + }, + ) + .field("host", &self.pool.host_header) + .field("port", &self.pool.port) + .finish() + } +} + +struct CachedAddrs { + addrs: Vec, + resolved_at: Instant, +} + +struct IdleConn { + conn: PooledConn, + returned_at: Instant, +} + +struct ConnPool { + host_connect: String, + host_header: String, + port: u16, + tls: Option>, + connect_timeout: Duration, + request_timeout: Duration, + dns: Mutex>, + next_addr: AtomicUsize, + idle: Mutex>, +} + +enum TransportStream { + Plain(TcpStream), + Tls(Box>), +} + +impl TransportStream { + #[inline] + fn tcp(&self) -> &TcpStream { + match self { + Self::Plain(stream) => stream, + Self::Tls(stream) => stream.get_ref(), + } + } + + fn set_deadline(&self, deadline: Instant, cancellable: bool) -> io::Result<()> { + let remaining = deadline + .checked_duration_since(Instant::now()) + .ok_or_else(|| io::Error::new(io::ErrorKind::TimedOut, "HTTP request timed out"))?; + let read_cap = if cancellable { + CANCEL_POLL_INTERVAL + } else { + READ_STALL_TIMEOUT + }; + let read_timeout = remaining.min(read_cap).max(Duration::from_millis(1)); + let write_timeout = remaining + .min(READ_STALL_TIMEOUT) + .max(Duration::from_millis(1)); + let tcp = self.tcp(); + tcp.set_read_timeout(Some(read_timeout))?; + tcp.set_write_timeout(Some(write_timeout))?; + Ok(()) + } +} + +impl Read for TransportStream { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + match self { + Self::Plain(stream) => stream.read(buf), + Self::Tls(stream) => stream.read(buf), + } + } +} + +impl Write for TransportStream { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + match self { + Self::Plain(stream) => stream.write(buf), + Self::Tls(stream) => stream.write(buf), + } + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + match self { + Self::Plain(stream) => stream.flush(), + Self::Tls(stream) => stream.flush(), + } + } +} + +struct PooledConn { + stream: TransportStream, + buf: Box<[u8; CONN_BUF_BYTES]>, + pos: usize, + filled: usize, +} + +impl PooledConn { + fn new(stream: TransportStream) -> Self { + Self { + stream, + buf: Box::new([0u8; CONN_BUF_BYTES]), + pos: 0, + filled: 0, + } + } + + #[inline] + fn buffered(&self) -> &[u8] { + &self.buf[self.pos..self.filled] + } + + #[inline] + fn consume(&mut self, amount: usize) { + self.pos += amount; + if self.pos == self.filled { + self.pos = 0; + self.filled = 0; + } + } + + fn fill_buf_once(&mut self) -> io::Result { + if self.pos == self.filled { + self.pos = 0; + self.filled = 0; + } else if self.pos > 0 && self.filled == self.buf.len() { + let remaining = self.filled - self.pos; + self.buf.copy_within(self.pos..self.filled, 0); + self.pos = 0; + self.filled = remaining; + } + loop { + match self.stream.read(&mut self.buf[self.filled..]) { + Ok(n) => { + self.filled += n; + return Ok(n); + } + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) => return Err(error), + } + } + } + + fn read_line_crlf(&mut self, max_len: usize) -> io::Result> { + let mut line = Vec::new(); + loop { + if let Some(rel_nl) = self.buffered().iter().position(|&b| b == b'\n') { + let take = rel_nl + 1; + if line.len() + take > max_len { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "HTTP line exceeds maximum length", + )); + } + line.extend_from_slice(&self.buffered()[..take]); + self.consume(take); + if !line.ends_with(b"\r\n") { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "HTTP line missing CRLF terminator", + )); + } + line.truncate(line.len() - 2); + return Ok(line); + } + if !self.buffered().is_empty() { + if line.len() + self.buffered().len() > max_len { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "HTTP line exceeds maximum length", + )); + } + line.extend_from_slice(self.buffered()); + self.pos = 0; + self.filled = 0; + } + let n = self.fill_buf_once()?; + if n == 0 { + return Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + "unexpected EOF reading HTTP line", + )); + } + } + } + + fn read_exact_buffered(&mut self, dst: &mut [u8]) -> io::Result { + let mut read = 0usize; + while read < dst.len() { + if self.pos < self.filled { + let avail = self.filled - self.pos; + let take = avail.min(dst.len() - read); + dst[read..read + take].copy_from_slice(&self.buf[self.pos..self.pos + take]); + self.consume(take); + read += take; + continue; + } + match self.stream.read(&mut dst[read..]) { + Ok(0) => return Ok(read), + Ok(n) => read += n, + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) => return Err(error), + } + } + Ok(read) + } + + fn read_some_buffered(&mut self, dst: &mut [u8]) -> io::Result { + if dst.is_empty() { + return Ok(0); + } + if self.pos < self.filled { + let avail = self.filled - self.pos; + let take = avail.min(dst.len()); + dst[..take].copy_from_slice(&self.buf[self.pos..self.pos + take]); + self.consume(take); + return Ok(take); + } + loop { + match self.stream.read(dst) { + Ok(n) => return Ok(n), + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) => return Err(error), + } + } + } +} + +impl ConnPool { + fn resolve(&self, force_refresh: bool) -> io::Result> { + if !force_refresh { + let cache = self + .dns + .lock() + .map_err(|_| io::Error::other("DNS cache poisoned"))?; + if let Some(entry) = cache.as_ref() + && entry.resolved_at.elapsed() < DNS_CACHE_TTL + && !entry.addrs.is_empty() + { + return Ok(entry.addrs.clone()); + } + } + let addrs: Vec = (self.host_connect.as_str(), self.port) + .to_socket_addrs()? + .collect(); + if addrs.is_empty() { + return Err(io::Error::new( + io::ErrorKind::AddrNotAvailable, + "host resolved to no addresses", + )); + } + let mut cache = self + .dns + .lock() + .map_err(|_| io::Error::other("DNS cache poisoned"))?; + *cache = Some(CachedAddrs { + addrs: addrs.clone(), + resolved_at: Instant::now(), + }); + Ok(addrs) + } + + fn connect_tcp(&self) -> io::Result { + let mut last_error = None; + for force_refresh in [false, true] { + let addrs = match self.resolve(force_refresh) { + Ok(addrs) => addrs, + Err(error) => { + last_error = Some(error); + if force_refresh { + break; + } + continue; + } + }; + let start = self.next_addr.fetch_add(1, Ordering::Relaxed) % addrs.len(); + for offset in 0..addrs.len() { + let addr = addrs[(start + offset) % addrs.len()]; + match TcpStream::connect_timeout(&addr, self.connect_timeout) { + Ok(tcp) => { + let _ = tcp.set_nodelay(true); + return Ok(tcp); + } + Err(error) => last_error = Some(error), + } + } + // If we already resolved fresh, don't retry a second time. + if force_refresh { + break; + } + } + Err(last_error.unwrap_or_else(|| io::Error::other("TCP connect failed"))) + } + + fn connect_fresh(&self, deadline: Instant, cancellable: bool) -> io::Result { + let tcp = self.connect_tcp()?; + let stream = if let Some(tls) = &self.tls { + let server_name = ServerName::try_from(self.host_connect.clone()) + .map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error))?; + let conn = rustls::ClientConnection::new(Arc::clone(tls), server_name) + .map_err(io::Error::other)?; + let stream = TransportStream::Tls(Box::new(rustls::StreamOwned::new(conn, tcp))); + stream.set_deadline(deadline, cancellable)?; + stream + } else { + let stream = TransportStream::Plain(tcp); + stream.set_deadline(deadline, cancellable)?; + stream + }; + Ok(PooledConn::new(stream)) + } + + fn checkout(&self, deadline: Instant, cancellable: bool) -> io::Result<(PooledConn, bool)> { + let now = Instant::now(); + while let Some(entry) = { + let mut idle = self + .idle + .lock() + .map_err(|_| io::Error::other("connection pool poisoned"))?; + idle.pop() + } { + if now.saturating_duration_since(entry.returned_at) <= MAX_IDLE_AGE { + if entry + .conn + .stream + .set_deadline(deadline, cancellable) + .is_ok() + { + return Ok((entry.conn, true)); + } + } + } + Ok((self.connect_fresh(deadline, cancellable)?, false)) + } + + fn checkin(&self, conn: PooledConn) { + debug_assert_eq!(conn.pos, conn.filled); + if let Ok(mut idle) = self.idle.lock() { + if idle.len() < MAX_IDLE_CONNS { + idle.push(IdleConn { + conn, + returned_at: Instant::now(), + }); + } + } + } +} + +/// Parsed HTTP/1.1 response status and raw headers. +pub(crate) struct ResponseHead { + pub status: u16, + headers: Vec<(String, Vec)>, +} + +impl ResponseHead { + pub(crate) fn header_bytes(&self, name: &str) -> Option<&[u8]> { + self.headers + .iter() + .find(|(header_name, _)| header_name.eq_ignore_ascii_case(name)) + .map(|(_, value)| value.as_slice()) + } + + pub(crate) fn header_values<'a>( + &'a self, + name: &'a str, + ) -> impl Iterator + 'a { + self.headers + .iter() + .filter(move |(header_name, _)| header_name.eq_ignore_ascii_case(name)) + .map(|(_, value)| value.as_slice()) + } + + pub(crate) fn header_str(&self, name: &str) -> Option> { + self.header_bytes(name).map(std::str::from_utf8) + } + + pub(crate) fn status_display(&self) -> String { + match http_status_reason(self.status) { + Some(reason) => format!("{} {reason}", self.status), + None => self.status.to_string(), + } + } +} + +fn http_status_reason(status: u16) -> Option<&'static str> { + match status { + 200 => Some("OK"), + 204 => Some("No Content"), + 206 => Some("Partial Content"), + 304 => Some("Not Modified"), + 400 => Some("Bad Request"), + 401 => Some("Unauthorized"), + 403 => Some("Forbidden"), + 404 => Some("Not Found"), + 412 => Some("Precondition Failed"), + 416 => Some("Range Not Satisfiable"), + 429 => Some("Too Many Requests"), + 500 => Some("Internal Server Error"), + 502 => Some("Bad Gateway"), + 503 => Some("Service Unavailable"), + 504 => Some("Gateway Timeout"), + _ => None, + } +} + +/// Error returned while establishing a connection, sending a request, or +/// parsing response headers. +pub(crate) enum TransportError { + Cancelled, + /// Transient transport failure before a response (connect refusal, reset, + /// EOF before headers, timeout). Eligible for `HttpRetryPolicy` retry. + Transport(io::Error), + /// Non-retryable protocol or framing violation. + Protocol(String), +} + +impl TransportError { + pub(crate) fn into_source_error(self, object: Option<&str>) -> SourceError { + match self { + Self::Cancelled => match object { + Some(object) => SourceError::Io { + object: object.to_owned(), + source: io::Error::new(io::ErrorKind::Interrupted, "HTTP request cancelled"), + }, + None => sanitize_transport_io_error(io::Error::new( + io::ErrorKind::Interrupted, + "HTTP request cancelled", + )), + }, + Self::Transport(error) => sanitize_transport_io_error(error), + Self::Protocol(message) => SourceError::Protocol(message), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum BodyFraming { + Empty, + ContentLength(u64), + Chunked, + UntilEof, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum ChunkState { + SizeLine, + Data(u64), + DataCrlf, + Done, +} + +/// Active HTTP/1.1 response owning its underlying connection until body completion. +/// +/// Dropping a response before its body completes closes the connection rather +/// than returning an unsynchronized stream to the keep-alive pool. +pub(crate) struct HttpResponse { + pub head: ResponseHead, + conn: Option, + pool: Arc, + framing: BodyFraming, + keep_alive: bool, + remaining: u64, + chunk_state: ChunkState, + deadline: Instant, +} + +impl HttpResponse { + #[inline] + fn check_deadline(&mut self) -> io::Result<()> { + if Instant::now() >= self.deadline { + self.conn = None; + return Err(io::Error::new( + io::ErrorKind::TimedOut, + "HTTP request timed out", + )); + } + Ok(()) + } + + fn recycle_if_clean(&mut self) { + if self.keep_alive + && let Some(conn) = self.conn.take() + && conn.pos == conn.filled + { + self.pool.checkin(conn); + } else { + self.conn = None; + } + } + + /// Read the next exact `destination.len()` bytes from an open fixed-length + /// streaming response, recycling the keep-alive connection once `remaining` + /// reaches zero. + pub(crate) fn read_stream_chunk_cancellable( + &mut self, + destination: &mut [u8], + object: &str, + body_bytes: &mut usize, + cancelled: Option<&AtomicBool>, + ) -> SourceResult<()> { + let expected = destination.len(); + *body_bytes = 0; + if expected == 0 { + return Ok(()); + } + let BodyFraming::ContentLength(_) = self.framing else { + return Err(SourceError::Protocol(format!( + "streaming range response for {object} is not fixed Content-Length" + ))); + }; + if (expected as u64) > self.remaining { + self.conn = None; + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: self.remaining as usize, + }); + } + let Some(conn) = self.conn.as_mut() else { + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: 0, + }); + }; + let mut read = 0usize; + let mut iterations = 0u32; + let mut last_progress = Instant::now(); + while read < expected { + if cancelled.is_some_and(|c| c.load(Ordering::Relaxed)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range stream cancelled", + ), + }); + } + if conn.pos < conn.filled { + let avail = conn.filled - conn.pos; + let take = avail.min(expected - read); + destination[read..read + take] + .copy_from_slice(&conn.buf[conn.pos..conn.pos + take]); + conn.consume(take); + read += take; + *body_bytes = read; + last_progress = Instant::now(); + continue; + } + iterations = iterations.wrapping_add(1); + if iterations.is_multiple_of(32) && Instant::now() >= self.deadline { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new(io::ErrorKind::TimedOut, "HTTP range stream timed out"), + }); + } + match conn.stream.read(&mut destination[read..]) { + Ok(0) => { + self.conn = None; + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: read, + }); + } + Ok(n) => { + read += n; + *body_bytes = read; + last_progress = Instant::now(); + } + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range stream cancelled", + ), + }); + } + if Instant::now() >= self.deadline + || last_progress.elapsed() >= READ_STALL_TIMEOUT + { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::TimedOut, + "HTTP range stream stalled", + ), + }); + } + continue; + } + Err(source) => { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source, + }); + } + } + } + self.remaining -= expected as u64; + if self.remaining == 0 { + self.recycle_if_clean(); + } + Ok(()) + } + + /// Read an exact `expected` byte body directly into `destination` without + /// extra buffering or copies on the fixed-length fast path. + pub(crate) fn read_exact_into_slice( + &mut self, + destination: &mut [u8], + object: &str, + body_bytes: &mut usize, + ) -> SourceResult<()> { + self.read_exact_into_slice_cancellable(destination, object, body_bytes, None) + } + + pub(crate) fn read_exact_into_slice_cancellable( + &mut self, + destination: &mut [u8], + object: &str, + body_bytes: &mut usize, + cancelled: Option<&AtomicBool>, + ) -> SourceResult<()> { + let expected = destination.len(); + *body_bytes = 0; + + if let BodyFraming::ContentLength(content_len) = self.framing { + if content_len == expected as u64 { + if expected == 0 { + self.recycle_if_clean(); + return Ok(()); + } + let Some(conn) = self.conn.as_mut() else { + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: 0, + }); + }; + let mut read = 0usize; + let mut iterations = 0u32; + let mut last_progress = Instant::now(); + while read < expected { + if cancelled.is_some_and(|c| c.load(Ordering::Relaxed)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range request cancelled", + ), + }); + } + if conn.pos < conn.filled { + let avail = conn.filled - conn.pos; + let take = avail.min(expected - read); + destination[read..read + take] + .copy_from_slice(&conn.buf[conn.pos..conn.pos + take]); + conn.consume(take); + read += take; + *body_bytes = read; + last_progress = Instant::now(); + continue; + } + iterations = iterations.wrapping_add(1); + if iterations.is_multiple_of(32) && Instant::now() >= self.deadline { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::TimedOut, + "HTTP request timed out", + ), + }); + } + match conn.stream.read(&mut destination[read..]) { + Ok(0) => { + self.conn = None; + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: read, + }); + } + Ok(n) => { + read += n; + *body_bytes = read; + last_progress = Instant::now(); + } + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range request cancelled", + ), + }); + } + if Instant::now() >= self.deadline + || last_progress.elapsed() >= READ_STALL_TIMEOUT + { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::TimedOut, + "HTTP body read stalled", + ), + }); + } + continue; + } + Err(source) => { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source, + }); + } + } + } + self.remaining = 0; + self.recycle_if_clean(); + return Ok(()); + } + } + + // General path: chunked, EOF-delimited, empty, or mismatched Content-Length. + let mut read = 0usize; + let mut last_progress = Instant::now(); + while read < expected { + if cancelled.is_some_and(|c| c.load(Ordering::Relaxed)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range request cancelled", + ), + }); + } + let n = match self.read(&mut destination[read..]) { + Ok(n) => { + last_progress = Instant::now(); + n + } + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::Interrupted, + "HTTP range request cancelled", + ), + }); + } + if Instant::now() >= self.deadline + || last_progress.elapsed() >= READ_STALL_TIMEOUT + { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source: io::Error::new( + io::ErrorKind::TimedOut, + "HTTP body read stalled", + ), + }); + } + continue; + } + Err(source) => { + self.conn = None; + return Err(SourceError::Io { + object: object.to_owned(), + source, + }); + } + }; + if n == 0 { + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: read, + }); + } + read += n; + *body_bytes = read; + } + let mut extra = [0u8; 1]; + let extra = self.read(&mut extra).map_err(|source| { + self.conn = None; + SourceError::Io { + object: object.to_owned(), + source, + } + })?; + *body_bytes = read.saturating_add(extra); + if extra != 0 { + self.conn = None; + return Err(SourceError::ShortRead { + object: object.to_owned(), + expected, + actual: expected.saturating_add(extra), + }); + } + Ok(()) + } + + /// Read an exact `expected` byte body into a reusable `Vec`, preserving + /// initialized storage across calls so reused buffers are never re-zeroed. + pub(crate) fn read_exact_into_vec( + &mut self, + expected: usize, + object: &str, + destination: &mut Vec, + body_bytes: &mut usize, + ) -> SourceResult<()> { + self.read_exact_into_vec_cancellable(expected, object, destination, body_bytes, None) + } + + pub(crate) fn read_exact_into_vec_cancellable( + &mut self, + expected: usize, + object: &str, + destination: &mut Vec, + body_bytes: &mut usize, + cancelled: Option<&AtomicBool>, + ) -> SourceResult<()> { + *body_bytes = 0; + let allocation = expected.checked_add(1).ok_or_else(|| { + SourceError::Protocol(format!("response allocation bound overflows for {object}")) + })?; + if destination.capacity() < allocation { + let additional = allocation.saturating_sub(destination.len()); + destination.try_reserve_exact(additional).map_err(|error| { + SourceError::Protocol(format!( + "cannot reserve {allocation} bounded response bytes for {object}: {error}" + )) + })?; + } + // Keep initialized storage intact across repeated same-size range reads + // so reused 16/32 MiB buffers aren't needlessly memset to zero. + if destination.len() < expected { + destination.resize(expected, 0); + } else { + destination.truncate(expected); + } + let result = self.read_exact_into_slice_cancellable( + &mut destination[..expected], + object, + body_bytes, + cancelled, + ); + if result.is_err() { + destination.truncate((*body_bytes).min(expected)); + } + result + } + + /// Read a response body up to `max_bytes` (used by bounded JSON POST helper). + pub(crate) fn read_bounded_to_vec(&mut self, max_bytes: usize) -> SourceResult> { + if let BodyFraming::ContentLength(len) = self.framing { + if len > max_bytes as u64 { + self.conn = None; + return Err(SourceError::Protocol(format!( + "response body exceeds {max_bytes} byte limit" + ))); + } + let expected = len as usize; + let mut out = Vec::new(); + let mut read = 0usize; + if expected > 0 { + out.try_reserve_exact(expected).map_err(|error| { + SourceError::Protocol(format!( + "cannot reserve {expected} bounded response bytes: {error}" + )) + })?; + out.resize(expected, 0); + self.read_exact_into_slice(&mut out, "response", &mut read)?; + } else { + self.recycle_if_clean(); + } + return Ok(out); + } + let mut out = Vec::new(); + let mut chunk = [0u8; 16 * 1024]; + loop { + let n = self.read(&mut chunk).map_err(|source| { + self.conn = None; + SourceError::Io { + object: "response".into(), + source, + } + })?; + if n == 0 { + break; + } + if out.len().saturating_add(n) > max_bytes { + self.conn = None; + return Err(SourceError::Protocol(format!( + "response body exceeds {max_bytes} byte limit" + ))); + } + out.extend_from_slice(&chunk[..n]); + } + Ok(out) + } +} + +impl Read for HttpResponse { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + if buf.is_empty() { + return Ok(0); + } + self.check_deadline()?; + match self.framing { + BodyFraming::Empty => { + self.recycle_if_clean(); + Ok(0) + } + BodyFraming::ContentLength(_) => { + if self.remaining == 0 { + self.recycle_if_clean(); + return Ok(0); + } + let Some(conn) = self.conn.as_mut() else { + return Ok(0); + }; + let max = (self.remaining as usize).min(buf.len()); + let n = conn.read_some_buffered(&mut buf[..max])?; + if n == 0 { + self.conn = None; + return Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + "truncated Content-Length HTTP response body", + )); + } + self.remaining -= n as u64; + if self.remaining == 0 { + self.recycle_if_clean(); + } + Ok(n) + } + BodyFraming::UntilEof => { + let Some(conn) = self.conn.as_mut() else { + return Ok(0); + }; + let n = conn.read_some_buffered(buf)?; + if n == 0 { + self.conn = None; + } + Ok(n) + } + BodyFraming::Chunked => { + loop { + match self.chunk_state { + ChunkState::Done => { + self.recycle_if_clean(); + return Ok(0); + } + ChunkState::SizeLine => { + let Some(conn) = self.conn.as_mut() else { + return Ok(0); + }; + let line = conn.read_line_crlf(MAX_CHUNK_LINE_BYTES)?; + let size_hex = line + .split(|&b| b == b';') + .next() + .unwrap_or(&[]) + .trim_ascii(); + let size_str = std::str::from_utf8(size_hex).map_err(|_| { + io::Error::new(io::ErrorKind::InvalidData, "non-UTF8 chunk size") + })?; + let size = u64::from_str_radix(size_str, 16).map_err(|_| { + io::Error::new(io::ErrorKind::InvalidData, "invalid chunk size") + })?; + if size == 0 { + // Consume optional trailer headers up to empty CRLF line. + let mut trailer_bytes = 0usize; + loop { + let trailer = conn.read_line_crlf(MAX_CHUNK_LINE_BYTES)?; + if trailer.is_empty() { + break; + } + trailer_bytes += trailer.len() + 2; + if trailer_bytes > MAX_TRAILER_BYTES { + self.conn = None; + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "HTTP chunk trailers exceed limit", + )); + } + } + self.chunk_state = ChunkState::Done; + self.recycle_if_clean(); + return Ok(0); + } + self.chunk_state = ChunkState::Data(size); + } + ChunkState::Data(rem) => { + let Some(conn) = self.conn.as_mut() else { + return Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + "truncated chunked HTTP body", + )); + }; + let want = (rem as usize).min(buf.len()); + let n = conn.read_some_buffered(&mut buf[..want])?; + if n == 0 { + self.conn = None; + return Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + "truncated chunked HTTP body", + )); + } + let next_rem = rem - n as u64; + self.chunk_state = if next_rem == 0 { + ChunkState::DataCrlf + } else { + ChunkState::Data(next_rem) + }; + return Ok(n); + } + ChunkState::DataCrlf => { + let Some(conn) = self.conn.as_mut() else { + return Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + "missing chunk CRLF terminator", + )); + }; + let mut crlf = [0u8; 2]; + let n = conn.read_exact_buffered(&mut crlf)?; + if n != 2 || crlf != *b"\r\n" { + self.conn = None; + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "invalid chunk CRLF terminator", + )); + } + self.chunk_state = ChunkState::SizeLine; + } + } + } + } + } + } +} + +impl OriginTransport { + pub(crate) fn new( + base_url: &Url, + connect_timeout: Duration, + request_timeout: Duration, + ) -> SourceResult { + let host_raw = base_url + .host_str() + .ok_or_else(|| SourceError::Protocol("gateway URL must have an origin".into()))?; + let is_https = match base_url.scheme() { + "https" => true, + "http" => false, + scheme => { + return Err(SourceError::Protocol(format!( + "unsupported gateway URL scheme {scheme}" + ))); + } + }; + let port = base_url + .port_or_known_default() + .ok_or_else(|| SourceError::Protocol("gateway URL has no valid port".into()))?; + let default_port = if is_https { 443 } else { 80 }; + let host_header = if port == default_port { + host_raw.to_owned() + } else { + format!("{host_raw}:{port}") + }; + let host_connect = host_raw + .trim_start_matches('[') + .trim_end_matches(']') + .to_owned(); + let tls = if is_https { + Some(shared_tls_config()?) + } else { + None + }; + Ok(Self { + pool: Arc::new(ConnPool { + host_connect, + host_header, + port, + tls, + connect_timeout, + request_timeout, + dns: Mutex::new(None), + next_addr: AtomicUsize::new(0), + idle: Mutex::new(Vec::new()), + }), + }) + } + + pub(crate) fn send_request( + &self, + method: &str, + request_target: &str, + authorization: Option<&str>, + extra_headers: &[(&str, &str)], + body: Option<&[u8]>, + ) -> SourceResult { + let mut headers = Vec::with_capacity(2 + extra_headers.len()); + headers.push(crate::signing::OutgoingHeader::new( + "accept-encoding", + "identity", + false, + )); + if let Some(auth) = authorization { + headers.push(crate::signing::OutgoingHeader::new( + "authorization", + auth, + true, + )); + } + for &(name, value) in extra_headers { + headers.push(crate::signing::OutgoingHeader::new(name, value, false)); + } + self.send_request_headers_cancellable(method, request_target, &headers, body, None) + .map_err(|error| error.into_source_error(None)) + } + + pub(crate) fn send_request_headers_cancellable( + &self, + method: &str, + request_target: &str, + headers: &[crate::signing::OutgoingHeader], + body: Option<&[u8]>, + cancelled: Option<&AtomicBool>, + ) -> Result { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(TransportError::Cancelled); + } + if request_target.is_empty() + || request_target + .bytes() + .any(|byte| byte <= 0x20 || byte == 0x7f) + { + return Err(TransportError::Protocol( + "HTTP request target contains invalid bytes".into(), + )); + } + let mut wire = Vec::with_capacity(256 + request_target.len()); + let _ = write!( + wire, + "{method} {request_target} HTTP/1.1\r\nHost: {}\r\nConnection: keep-alive\r\n", + self.pool.host_header + ); + for header in headers { + let _ = write!(wire, "{}: {}\r\n", header.name, header.value); + } + if let Some(payload) = body { + let _ = write!(wire, "Content-Length: {}\r\n", payload.len()); + } + wire.extend_from_slice(b"\r\n"); + + let cancellable = cancelled.is_some(); + let deadline = Instant::now() + self.pool.request_timeout; + for retry in 0..2 { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(TransportError::Cancelled); + } + let (mut conn, reused) = if retry == 0 { + self.pool + .checkout(deadline, cancellable) + .map_err(TransportError::Transport)? + } else { + ( + self.pool + .connect_fresh(deadline, cancellable) + .map_err(TransportError::Transport)?, + false, + ) + }; + + let write_result = (|| -> io::Result<()> { + write_all_cancellable(&mut conn.stream, &wire, deadline, cancelled)?; + if let Some(payload) = body + && !payload.is_empty() + { + write_all_cancellable(&mut conn.stream, payload, deadline, cancelled)?; + } + Ok(()) + })(); + + if let Err(error) = write_result { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(TransportError::Cancelled); + } + if reused && retry == 0 { + continue; + } + return Err(TransportError::Transport(error)); + } + + match read_response_head(&mut conn, deadline, cancelled) { + Ok((head, version)) => { + let is_head = method.eq_ignore_ascii_case("HEAD"); + let (framing, keep_alive) = + parse_framing_and_keep_alive(&head, version, is_head).map_err(|error| { + TransportError::Protocol(match error { + SourceError::Protocol(message) => message, + other => other.to_string(), + }) + })?; + let remaining = match framing { + BodyFraming::ContentLength(len) => len, + _ => 0, + }; + let mut response = HttpResponse { + head, + conn: Some(conn), + pool: Arc::clone(&self.pool), + framing, + keep_alive, + remaining, + chunk_state: ChunkState::SizeLine, + deadline, + }; + if matches!(framing, BodyFraming::Empty) { + response.recycle_if_clean(); + } + return Ok(response); + } + Err(ReadHeadError::Cancelled) => { + return Err(TransportError::Cancelled); + } + Err(ReadHeadError::RetryableIo(error)) => { + if reused && retry == 0 { + continue; + } + return Err(TransportError::Transport(error)); + } + Err(ReadHeadError::Protocol(message)) => { + return Err(TransportError::Protocol(message)); + } + } + } + unreachable!("stale keep-alive reconnect loop always returns") + } +} + +fn write_all_cancellable( + stream: &mut TransportStream, + mut data: &[u8], + deadline: Instant, + cancelled: Option<&AtomicBool>, +) -> io::Result<()> { + let mut last_progress = Instant::now(); + while !data.is_empty() { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(io::Error::new( + io::ErrorKind::Interrupted, + "HTTP request cancelled", + )); + } + match stream.write(data) { + Ok(0) => { + return Err(io::Error::new( + io::ErrorKind::WriteZero, + "failed to write whole HTTP request", + )); + } + Ok(n) => { + data = &data[n..]; + last_progress = Instant::now(); + } + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(io::Error::new( + io::ErrorKind::Interrupted, + "HTTP request cancelled", + )); + } + if Instant::now() >= deadline || last_progress.elapsed() >= READ_STALL_TIMEOUT { + return Err(io::Error::new( + io::ErrorKind::TimedOut, + "HTTP request write timed out", + )); + } + continue; + } + Err(error) => return Err(error), + } + } + loop { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(io::Error::new( + io::ErrorKind::Interrupted, + "HTTP request cancelled", + )); + } + match stream.flush() { + Ok(()) => return Ok(()), + Err(error) if error.kind() == io::ErrorKind::Interrupted => continue, + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(io::Error::new( + io::ErrorKind::Interrupted, + "HTTP request cancelled", + )); + } + if Instant::now() >= deadline || last_progress.elapsed() >= READ_STALL_TIMEOUT { + return Err(io::Error::new( + io::ErrorKind::TimedOut, + "HTTP request flush timed out", + )); + } + continue; + } + Err(error) => return Err(error), + } + } +} + +enum ReadHeadError { + Cancelled, + RetryableIo(io::Error), + Protocol(String), +} + +fn find_header_end(bytes: &[u8]) -> Option { + bytes + .windows(4) + .position(|window| window == b"\r\n\r\n") + .map(|pos| pos + 4) +} + +fn read_response_head( + conn: &mut PooledConn, + deadline: Instant, + cancelled: Option<&AtomicBool>, +) -> Result<(ResponseHead, u8), ReadHeadError> { + let mut header_bytes = Vec::with_capacity(512); + loop { + header_bytes.clear(); + let mut received_any = false; + let mut last_progress = Instant::now(); + let header_end = loop { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(ReadHeadError::Cancelled); + } + if !conn.buffered().is_empty() { + received_any = true; + last_progress = Instant::now(); + if header_bytes.is_empty() { + if let Some(end) = find_header_end(conn.buffered()) { + let slice = &conn.buffered()[..end]; + if slice.len() > MAX_RESPONSE_HEADER_BYTES { + return Err(ReadHeadError::Protocol( + "HTTP response headers exceed 64 KiB limit".into(), + )); + } + header_bytes.extend_from_slice(slice); + conn.consume(end); + break header_bytes.len(); + } + } + let buffered = conn.buffered(); + let prev_len = header_bytes.len(); + header_bytes.extend_from_slice(buffered); + let search_start = prev_len.saturating_sub(3); + if let Some(rel_end) = find_header_end(&header_bytes[search_start..]) { + let total_end = search_start + rel_end; + if total_end > MAX_RESPONSE_HEADER_BYTES { + return Err(ReadHeadError::Protocol( + "HTTP response headers exceed 64 KiB limit".into(), + )); + } + let used_from_buf = total_end - prev_len; + conn.consume(used_from_buf); + header_bytes.truncate(total_end); + break total_end; + } + let len = buffered.len(); + conn.consume(len); + if header_bytes.len() > MAX_RESPONSE_HEADER_BYTES { + return Err(ReadHeadError::Protocol( + "HTTP response headers exceed 64 KiB limit".into(), + )); + } + } + match conn.fill_buf_once() { + Ok(0) => { + let error = io::Error::new( + io::ErrorKind::UnexpectedEof, + "connection closed before HTTP response headers completed", + ); + return Err(if !received_any { + ReadHeadError::RetryableIo(error) + } else { + ReadHeadError::Protocol(format!("HTTP request failed ({})", error.kind())) + }); + } + Ok(_) => { + last_progress = Instant::now(); + } + Err(error) + if matches!( + error.kind(), + io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut + ) => + { + if cancelled.is_some_and(|c| c.load(Ordering::Acquire)) { + return Err(ReadHeadError::Cancelled); + } + if Instant::now() >= deadline || last_progress.elapsed() >= READ_STALL_TIMEOUT { + let timeout = io::Error::new( + io::ErrorKind::TimedOut, + "HTTP response headers timed out", + ); + return Err(if !received_any { + ReadHeadError::RetryableIo(timeout) + } else { + ReadHeadError::Protocol(format!( + "HTTP request failed ({})", + timeout.kind() + )) + }); + } + continue; + } + Err(error) => { + return Err(if !received_any { + ReadHeadError::RetryableIo(error) + } else { + ReadHeadError::Protocol(format!("HTTP request failed ({})", error.kind())) + }); + } + } + }; + + let mut parsed_headers = [httparse::EMPTY_HEADER; MAX_RESPONSE_HEADERS]; + let mut parsed = httparse::Response::new(&mut parsed_headers); + let status = parsed.parse(&header_bytes[..header_end]).map_err(|error| { + ReadHeadError::Protocol(format!("malformed HTTP response headers: {error}")) + })?; + if !matches!(status, httparse::Status::Complete(n) if n == header_end) { + return Err(ReadHeadError::Protocol( + "incomplete HTTP response headers".into(), + )); + } + let code = parsed + .code + .ok_or_else(|| ReadHeadError::Protocol("HTTP response missing status code".into()))?; + let version = parsed + .version + .ok_or_else(|| ReadHeadError::Protocol("HTTP response missing HTTP version".into()))?; + // Skip 1xx interim informational responses (e.g. 100 Continue, 103 Early Hints). + if (100..200).contains(&code) && code != 101 { + continue; + } + let mut headers = Vec::with_capacity(parsed.headers.len()); + for header in parsed.headers.iter() { + headers.push((header.name.to_owned(), header.value.to_vec())); + } + return Ok(( + ResponseHead { + status: code, + headers, + }, + version, + )); + } +} + +fn parse_framing_and_keep_alive( + head: &ResponseHead, + version: u8, + is_head_request: bool, +) -> SourceResult<(BodyFraming, bool)> { + let mut connection_close = false; + let mut connection_keep_alive = false; + for raw in head.header_values("connection") { + if let Ok(value) = std::str::from_utf8(raw) { + for token in value.split(',') { + let token = token.trim(); + if token.eq_ignore_ascii_case("close") { + connection_close = true; + } else if token.eq_ignore_ascii_case("keep-alive") { + connection_keep_alive = true; + } + } + } + } + let mut keep_alive = match version { + 1 => !connection_close, + 0 => connection_keep_alive && !connection_close, + _ => false, + }; + + let has_transfer_encoding = head.header_values("transfer-encoding").next().is_some(); + let has_content_length = head.header_values("content-length").next().is_some(); + + if is_head_request || matches!(head.status, 204 | 304) || (100..200).contains(&head.status) { + return Ok((BodyFraming::Empty, keep_alive)); + } + + if has_transfer_encoding { + if has_content_length { + return Err(SourceError::Protocol( + "HTTP response contains both Transfer-Encoding and Content-Length".into(), + )); + } + let mut codings = Vec::new(); + for raw in head.header_values("transfer-encoding") { + let value = std::str::from_utf8(raw).map_err(|_| { + SourceError::Protocol("HTTP response has non-UTF8 Transfer-Encoding".into()) + })?; + for token in value.split(',') { + let token = token.trim(); + if !token.is_empty() { + codings.push(token); + } + } + } + if codings.len() == 1 && codings[0].eq_ignore_ascii_case("chunked") { + return Ok((BodyFraming::Chunked, keep_alive)); + } + return Err(SourceError::Protocol( + "HTTP response uses an unsupported Transfer-Encoding".into(), + )); + } + + if has_content_length { + let mut agreed: Option = None; + for raw in head.header_values("content-length") { + let value = std::str::from_utf8(raw) + .map_err(|_| SourceError::Protocol("invalid Content-Length".into()))?; + for part in value.split(',') { + let parsed = part + .trim() + .parse::() + .map_err(|_| SourceError::Protocol("invalid Content-Length".into()))?; + if let Some(prev) = agreed { + if prev != parsed { + return Err(SourceError::Protocol( + "conflicting Content-Length headers".into(), + )); + } + } else { + agreed = Some(parsed); + } + } + } + let length = + agreed.ok_or_else(|| SourceError::Protocol("invalid Content-Length".into()))?; + return Ok((BodyFraming::ContentLength(length), keep_alive)); + } + + keep_alive = false; + Ok((BodyFraming::UntilEof, keep_alive)) +} + +fn sanitize_transport_io_error(error: io::Error) -> SourceError { + // Never include URLs, query parameters, or credentials in error diagnostics. + SourceError::Protocol(format!("HTTP request failed ({})", error.kind())) +} + +/// Validate a header value according to RFC 7230 field-value rules (no CR/LF or NUL). +pub(crate) fn validate_header_value(value: &str) -> bool { + value + .bytes() + .all(|byte| byte == b'\t' || (0x20..=0x7e).contains(&byte)) +} + +/// Reusable bounded JSON HTTP/1.1 (+ TLS) POST client over the same direct +/// transport (no redirects, no ambient proxies, never logs URLs in errors). +#[derive(Clone, Debug)] +pub struct HttpJsonClient { + transport: OriginTransport, + request_target: String, +} + +impl HttpJsonClient { + pub fn new( + url: &Url, + connect_timeout: Duration, + request_timeout: Duration, + ) -> SourceResult { + if !matches!(url.scheme(), "http" | "https") + || !url.username().is_empty() + || url.password().is_some() + || url.fragment().is_some() + || url.host_str().is_none() + { + return Err(SourceError::Protocol( + "HTTP JSON endpoint must be an http(s) URL without credentials or a fragment" + .into(), + )); + } + let transport = OriginTransport::new(url, connect_timeout, request_timeout)?; + let mut request_target = url.path().to_owned(); + if request_target.is_empty() { + request_target.push('/'); + } + if let Some(query) = url.query() { + request_target.push('?'); + request_target.push_str(query); + } + Ok(Self { + transport, + request_target, + }) + } + + /// Send one `application/json` POST request without following redirects and + /// return `(status_code, response_body)` capped at `max_response_bytes`. + pub fn post_json_bounded( + &self, + body: &[u8], + max_response_bytes: usize, + ) -> SourceResult<(u16, Vec)> { + let mut response = self.transport.send_request( + "POST", + &self.request_target, + None, + &[("Content-Type", "application/json")], + Some(body), + )?; + let status = response.head.status; + if !(200..300).contains(&status) { + return Ok((status, Vec::new())); + } + let bytes = response.read_bounded_to_vec(max_response_bytes)?; + Ok((status, bytes)) + } +} diff --git a/crates/source/blockzilla-source-local/Cargo.toml b/crates/source/blockzilla-source-local/Cargo.toml index ccd9b595..847d89b7 100644 --- a/crates/source/blockzilla-source-local/Cargo.toml +++ b/crates/source/blockzilla-source-local/Cargo.toml @@ -9,7 +9,7 @@ repository.workspace = true description = "Local and pinned immutable byte sources" [dependencies] -blockzilla-source = { version = "0.2.0", path = "../blockzilla-source" } +blockzilla-source = { version = "0.3.0", path = "../blockzilla-source" } rustix = { version = "1.1.4", features = ["fs", "process"] } serde = { version = "1.0.229", features = ["derive"] } diff --git a/crates/source/blockzilla-source/src/lib.rs b/crates/source/blockzilla-source/src/lib.rs index 842730c5..b3028765 100644 --- a/crates/source/blockzilla-source/src/lib.rs +++ b/crates/source/blockzilla-source/src/lib.rs @@ -2,7 +2,7 @@ pub mod input_budget; -use std::sync::Arc; +use std::sync::{Arc, atomic::AtomicBool}; use thiserror::Error; pub type SourceResult = std::result::Result; @@ -75,6 +75,33 @@ pub trait RangeSource: Send + Sync { Ok(()) } + /// Read an exact range into reusable caller-owned storage, stopping early + /// when `cancelled` becomes `true`. + fn read_range_into_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + cancelled: &AtomicBool, + ) -> SourceResult<()> { + let _ = cancelled; + self.read_range_into(object, offset, length, destination) + } + + /// Read an exact range into an already initialized destination slice, + /// stopping early when `cancelled` becomes `true`. + fn read_range_into_slice_cancellable( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + cancelled: &AtomicBool, + ) -> SourceResult<()> { + let _ = cancelled; + self.read_range_into_slice(object, offset, destination) + } + fn read_all_bounded(&self, object: &str, max_length: usize) -> SourceResult> { let size = self .size(object)? @@ -126,6 +153,27 @@ impl RangeSource for Arc { ) -> SourceResult<()> { (**self).read_range_into_slice(object, offset, destination) } + + fn read_range_into_cancellable( + &self, + object: &str, + offset: u64, + length: usize, + destination: &mut Vec, + cancelled: &AtomicBool, + ) -> SourceResult<()> { + (**self).read_range_into_cancellable(object, offset, length, destination, cancelled) + } + + fn read_range_into_slice_cancellable( + &self, + object: &str, + offset: u64, + destination: &mut [u8], + cancelled: &AtomicBool, + ) -> SourceResult<()> { + (**self).read_range_into_slice_cancellable(object, offset, destination, cancelled) + } } #[derive(Debug, Error)] diff --git a/zillastream/capture-core/Cargo.lock b/zillastream/capture-core/Cargo.lock index 25beba57..52c0ba33 100644 --- a/zillastream/capture-core/Cargo.lock +++ b/zillastream/capture-core/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.104" @@ -32,35 +14,12 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "binout" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -87,7 +46,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -113,7 +72,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -123,88 +82,54 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] -[[package]] -name = "borsh" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88b7ea17d208c4193f2c1e6de3c35fe71f98c96982d5ced308bdcc749ff6e1f" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f347189c62a579b8cd5f80714efa178f52e461dc2e6d701d264f5ff22e566c" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "bs58" version = "0.5.1" @@ -250,27 +175,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "const-oid" version = "0.10.2" @@ -321,12 +225,6 @@ version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.2.1" @@ -355,7 +253,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.117", ] @@ -399,25 +297,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - [[package]] name = "errno" version = "0.3.10" @@ -461,33 +340,12 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -514,17 +372,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -534,22 +381,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -558,7 +396,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -581,30 +419,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.10" @@ -620,25 +434,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "indexmap" -version = "2.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" -dependencies = [ - "equivalent", - "hashbrown 0.17.0", -] - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.9" @@ -687,22 +482,6 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" - [[package]] name = "memchr" version = "2.6.3" @@ -723,44 +502,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "minimal-lexical" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c64630dcdd71f1a64c435f54885086a0de5d6a12d104d69b165fb7d5286d677" - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - -[[package]] -name = "nom" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1" -dependencies = [ - "memchr", - "minimal-lexical", - "version_check", -] [[package]] name = "once_cell" @@ -768,58 +509,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.0", -] - [[package]] name = "pastey" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap", - "env_logger", - "log", - "nom", -] - -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.1", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -841,25 +536,6 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.106" @@ -869,136 +545,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.117", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quote" version = "1.0.45" @@ -1034,44 +580,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" - [[package]] name = "rsqlite-vfs" version = "0.1.1" @@ -1088,7 +596,7 @@ version = "0.40.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3" dependencies = [ - "bitflags 2.13.1", + "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -1103,7 +611,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1116,12 +624,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "seedable_hash" version = "0.2.3" @@ -1194,59 +696,6 @@ version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" -[[package]] -name = "solana-address" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01332a01c0a3098404d55a724c8d9a92aed4a50fe40a7dd0c7a51e29274c14de" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-define-syscall" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8209ece2bd9f1450e672858ffc0e5c8c786ff6916d2a862b126dd0128f380f" - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f71b7a414de2ced1071f015834e9be581592d013432adbd06d02e4af11eba9" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - [[package]] name = "sqlite-wasm-rs" version = "0.5.5" @@ -1265,12 +714,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -1312,24 +755,6 @@ dependencies = [ "windows-sys 0.61.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.19" @@ -1365,23 +790,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.19.0" @@ -1394,30 +802,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "voracious_radix_sort" version = "1.2.0" @@ -1472,37 +862,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "wincode" version = "0.6.1" @@ -1540,7 +899,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -1552,67 +911,34 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1625,86 +951,33 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" -dependencies = [ - "memchr", -] - -[[package]] -name = "zerocopy" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "zillastream-capture-core" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", diff --git a/zillastream/capture-core/Cargo.toml b/zillastream/capture-core/Cargo.toml index 79e03e6f..c6525199 100644 --- a/zillastream/capture-core/Cargo.toml +++ b/zillastream/capture-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zillastream-capture-core" -version = "0.2.0" +version = "0.3.0" edition = "2024" rust-version = "1.97.1" license = "MIT" diff --git a/zillastream/geyser-plugin/Cargo.lock b/zillastream/geyser-plugin/Cargo.lock index 44203482..45b1b383 100644 --- a/zillastream/geyser-plugin/Cargo.lock +++ b/zillastream/geyser-plugin/Cargo.lock @@ -151,15 +151,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -262,17 +253,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -378,7 +358,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -404,7 +384,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -414,60 +394,50 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey 4.3.0", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey 4.3.0", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey 4.3.0", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey 4.3.0", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] @@ -655,21 +625,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.6.7" @@ -689,7 +644,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -815,12 +770,6 @@ version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.1.6" @@ -897,7 +846,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.117", ] @@ -1025,19 +974,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -1125,12 +1061,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "flate2" version = "1.1.9" @@ -1304,17 +1234,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -1379,15 +1298,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.5.1" @@ -1396,14 +1306,14 @@ checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08" [[package]] name = "hivezilla-direct-agave" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", "blockzilla-bank-stream-v2", "blockzilla-compact", "blockzilla-primitives", - "clap 4.6.7", + "clap", "libc", "rusqlite", "serde", @@ -1462,15 +1372,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.10" @@ -1836,27 +1737,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "minimal-lexical" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c64630dcdd71f1a64c435f54885086a0de5d6a12d104d69b165fb7d5286d677" [[package]] name = "miniz_oxide" @@ -1879,12 +1759,6 @@ dependencies = [ "windows-sys 0.61.0", ] -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - [[package]] name = "nix" version = "0.31.3" @@ -1897,17 +1771,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nom" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1" -dependencies = [ - "memchr", - "minimal-lexical", - "version_check", -] - [[package]] name = "num-derive" version = "0.4.2" @@ -1935,7 +1798,7 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "hermit-abi 0.5.1", + "hermit-abi", "libc", ] @@ -2005,18 +1868,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.33.3", - "env_logger", - "log", - "nom", -] - [[package]] name = "pbkdf2" version = "0.11.0" @@ -2032,17 +1883,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.1", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -2092,16 +1932,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -2120,136 +1950,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.117", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quinn" version = "0.11.11" @@ -4570,12 +4270,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -4660,24 +4354,6 @@ dependencies = [ "windows-sys 0.61.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -4893,12 +4569,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "unreachable" version = "1.0.0" @@ -4950,12 +4620,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -5113,15 +4777,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -5453,7 +5108,7 @@ dependencies = [ [[package]] name = "zillastream-capture-core" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-archive-v2", @@ -5470,7 +5125,7 @@ dependencies = [ [[package]] name = "zillastream-geyser-plugin" -version = "0.2.0" +version = "0.3.0" dependencies = [ "agave-geyser-plugin-interface", "anyhow", diff --git a/zillastream/geyser-plugin/Cargo.toml b/zillastream/geyser-plugin/Cargo.toml index 618e7e90..ede373c8 100644 --- a/zillastream/geyser-plugin/Cargo.toml +++ b/zillastream/geyser-plugin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zillastream-geyser-plugin" -version = "0.2.0" +version = "0.3.0" edition = "2024" rust-version = "1.97.1" license = "MIT" diff --git a/zillastream/relay/Cargo.lock b/zillastream/relay/Cargo.lock index 9e3f8cd7..953764d7 100644 --- a/zillastream/relay/Cargo.lock +++ b/zillastream/relay/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "1.0.0" @@ -110,17 +92,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "aws-lc-rs" version = "1.18.1" @@ -208,12 +179,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.2" @@ -240,7 +205,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -266,7 +231,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -276,60 +241,50 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] @@ -350,30 +305,6 @@ dependencies = [ "wincode", ] -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.6", -] - [[package]] name = "bs58" version = "0.5.1" @@ -436,21 +367,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.6.7" @@ -470,7 +386,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -572,12 +488,6 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - [[package]] name = "crypto-common" version = "0.2.2" @@ -606,7 +516,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.119", ] @@ -667,19 +577,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -729,39 +626,18 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -898,17 +774,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -918,22 +783,13 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -942,7 +798,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -971,15 +827,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hivezilla-stream" version = "0.1.0" @@ -991,7 +838,7 @@ dependencies = [ "blockzilla-stream-decoder", "bs58", "bytes", - "clap 4.6.7", + "clap", "futures-util", "hyper-util", "libc", @@ -1051,15 +898,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.15" @@ -1262,15 +1100,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -1376,15 +1205,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.34" @@ -1429,27 +1249,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" @@ -1462,22 +1261,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -1496,64 +1279,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", -] - [[package]] name = "pastey" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap 2.34.0", - "env_logger", - "log", - "nom", -] - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -1590,25 +1327,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.119", -] - -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -1618,136 +1336,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.119", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quinn" version = "0.11.12" @@ -1866,44 +1454,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "regex" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" - [[package]] name = "reqwest" version = "0.13.5" @@ -1976,7 +1526,7 @@ version = "0.40.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3" dependencies = [ - "bitflags 2.13.2", + "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -2006,7 +1556,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.2", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -2128,19 +1678,13 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "security-framework" version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -2300,59 +1844,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "solana-address" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451294fdd4dde59ae27213695e2333eaaa39035e1f099f68644d2aa3ca0e2edd" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-define-syscall" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8209ece2bd9f1450e672858ffc0e5c8c786ff6916d2a862b126dd0128f380f" - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b8ba5d677d77a76d557b59ce7ecf9a8578743089cb25c73990752c5f005885" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - [[package]] name = "sqlite-wasm-rs" version = "0.5.5" @@ -2371,12 +1862,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -2444,24 +1929,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.21" @@ -2549,36 +2016,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml_datetime" -version = "1.1.2+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.25.17+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" -dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.1.5+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" -dependencies = [ - "winnow", -] - [[package]] name = "tower" version = "0.5.3" @@ -2601,7 +2038,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.13.2", + "bitflags", "bytes", "futures-util", "http", @@ -2669,12 +2106,6 @@ version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "untrusted" version = "0.9.0" @@ -2711,12 +2142,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "voracious_radix_sort" version = "1.2.0" @@ -2848,22 +2273,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.11" @@ -2873,12 +2282,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "wincode" version = "0.6.1" @@ -2992,15 +2395,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" -dependencies = [ - "memchr", -] - [[package]] name = "writeable" version = "0.6.4" @@ -3030,26 +2424,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.8.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "zerofrom" version = "0.1.8" diff --git a/zillastream/relay/decoder/Cargo.lock b/zillastream/relay/decoder/Cargo.lock index 45529769..d8e058df 100644 --- a/zillastream/relay/decoder/Cargo.lock +++ b/zillastream/relay/decoder/Cargo.lock @@ -2,24 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.104" @@ -32,35 +14,12 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "binout" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff5fa7be63dbf62cca511b0e64e4b869ebc68f2b99d65fb1aa127771c5b7cd0d" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" - [[package]] name = "bitm" version = "0.5.2" @@ -81,7 +40,7 @@ dependencies = [ [[package]] name = "blockzilla-archive-v2" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-compact", @@ -107,7 +66,7 @@ dependencies = [ [[package]] name = "blockzilla-compact" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-log-parser", @@ -117,60 +76,50 @@ dependencies = [ "blockzilla-solana-wire", "data-encoding", "heapless", - "prost", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-log-parser" -version = "0.2.0" +version = "0.3.0" [[package]] name = "blockzilla-primitives" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", + "five8", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-program-logs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "blockzilla-primitives", "data-encoding", "serde", - "solana-pubkey", "wincode", ] [[package]] name = "blockzilla-registry" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "blockzilla-primitives", - "five8", "gxhash", "memmap2", "ph", - "solana-pubkey", ] [[package]] name = "blockzilla-solana-wire" -version = "0.2.0" +version = "0.3.0" dependencies = [ "minicbor", - "pb-rs", - "prost", - "prost-build", - "protoc-bin-vendored", - "quick-protobuf", "serde", "wincode", ] @@ -191,30 +140,6 @@ dependencies = [ "wincode", ] -[[package]] -name = "borsh" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" -dependencies = [ - "borsh-derive", - "bytes", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 3.0.6", -] - [[package]] name = "bs58" version = "0.5.1" @@ -242,27 +167,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" -[[package]] -name = "cfg_aliases" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "const-oid" version = "0.10.2" @@ -303,12 +207,6 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - [[package]] name = "crypto-common" version = "0.2.2" @@ -337,7 +235,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.119", ] @@ -381,41 +279,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "errno" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "fastrand" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" - [[package]] name = "five8" version = "1.0.0" @@ -425,33 +288,12 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8_const" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0f1728185f277989ca573a402716ae0beaaea3f76a8ff87ef9dd8fb19436c5" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059c31d7d36c43fe39d89e55711858b4da8be7eb6dabac23c7289b1a19489406" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "gxhash" version = "3.5.0" @@ -461,17 +303,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - [[package]] name = "hash32" version = "0.3.1" @@ -481,21 +312,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash", -] - -[[package]] -name = "hashbrown" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" - [[package]] name = "heapless" version = "0.9.3" @@ -507,30 +323,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "hybrid-array" version = "0.4.15" @@ -546,25 +338,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "indexmap" -version = "2.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" -dependencies = [ - "equivalent", - "hashbrown 0.17.1", -] - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -577,27 +350,6 @@ version = "0.2.190" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" -[[package]] -name = "linux-raw-sys" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" - -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" - [[package]] name = "memchr" version = "2.8.3" @@ -618,72 +370,6 @@ name = "minicbor" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69" -dependencies = [ - "half", - "minicbor-derive", -] - -[[package]] -name = "minicbor-derive" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f5ad8dfe10176465fe33f19ecfcf08783ba66630fdb40b2e4542547c1046f0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "once_cell" -version = "1.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" - -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", -] [[package]] name = "pastey" @@ -691,29 +377,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" -[[package]] -name = "pb-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a34df9c65b596152598001c0fe3393379ec2db03ae30b9985659422e2607e" -dependencies = [ - "clap", - "env_logger", - "log", - "nom", -] - -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", -] - [[package]] name = "ph" version = "0.11.0" @@ -729,25 +392,6 @@ dependencies = [ "voracious_radix_sort", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.119", -] - -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -757,136 +401,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.119", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "prost-types" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" -dependencies = [ - "prost", -] - -[[package]] -name = "protoc-bin-vendored" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" -dependencies = [ - "protoc-bin-vendored-linux-aarch_64", - "protoc-bin-vendored-linux-ppcle_64", - "protoc-bin-vendored-linux-s390_64", - "protoc-bin-vendored-linux-x86_32", - "protoc-bin-vendored-linux-x86_64", - "protoc-bin-vendored-macos-aarch_64", - "protoc-bin-vendored-macos-x86_64", - "protoc-bin-vendored-win32", -] - -[[package]] -name = "protoc-bin-vendored-linux-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" - -[[package]] -name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" - -[[package]] -name = "protoc-bin-vendored-linux-s390_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" - -[[package]] -name = "protoc-bin-vendored-linux-x86_32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" - -[[package]] -name = "protoc-bin-vendored-linux-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" - -[[package]] -name = "protoc-bin-vendored-macos-aarch_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" - -[[package]] -name = "protoc-bin-vendored-macos-x86_64" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" - -[[package]] -name = "protoc-bin-vendored-win32" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - [[package]] name = "quote" version = "1.0.47" @@ -916,57 +430,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.13.2", -] - -[[package]] -name = "regex" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" - -[[package]] -name = "rustix" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" -dependencies = [ - "bitflags 2.13.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustversion" version = "1.0.23" @@ -982,12 +445,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "seedable_hash" version = "0.2.3" @@ -1048,77 +505,12 @@ dependencies = [ "digest", ] -[[package]] -name = "smallvec" -version = "1.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" - -[[package]] -name = "solana-address" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451294fdd4dde59ae27213695e2333eaaa39035e1f099f68644d2aa3ca0e2edd" -dependencies = [ - "borsh", - "five8", - "five8_const", - "serde", - "solana-atomic-u64", - "solana-define-syscall", - "solana-program-error", - "solana-sanitize", - "wincode", -] - -[[package]] -name = "solana-atomic-u64" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085db4906d89324cef2a30840d59eaecf3d4231c560ec7c9f6614a93c652f501" -dependencies = [ - "parking_lot", -] - -[[package]] -name = "solana-define-syscall" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8209ece2bd9f1450e672858ffc0e5c8c786ff6916d2a862b126dd0128f380f" - -[[package]] -name = "solana-program-error" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f04fa578707b3612b095f0c8e19b66a1233f7c42ca8082fcb3b745afcc0add6" - -[[package]] -name = "solana-pubkey" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b8ba5d677d77a76d557b59ce7ecf9a8578743089cb25c73990752c5f005885" -dependencies = [ - "solana-address", -] - -[[package]] -name = "solana-sanitize" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09694a0fc14e5ffb18f9b7b7c0f15ecb6eac5b5610bf76a1853459d19daf9" - [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -1147,36 +539,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" -dependencies = [ - "fastrand", - "once_cell", - "rustix", - "windows-sys", -] - -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "2.0.21" @@ -1203,36 +565,6 @@ version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" -[[package]] -name = "toml_datetime" -version = "1.1.1+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.25.15+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614" -dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" -dependencies = [ - "winnow", -] - [[package]] name = "twox-hash" version = "2.1.4" @@ -1251,18 +583,6 @@ version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "voracious_radix_sort" version = "1.2.0" @@ -1272,37 +592,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "wincode" version = "0.6.1" @@ -1328,50 +617,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "winnow" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" -dependencies = [ - "memchr", -] - -[[package]] -name = "zerocopy" -version = "0.8.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df92bf3d9227be3d53173901ddbffac2babc27ae50f397776ffd6dc33f800cb" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac4f328cf2f05d084e496c3e9c3f33ed0a183656a16e1fcec4d464d8373aec82" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "zmij" version = "1.0.23"