diff --git a/Cargo.lock b/Cargo.lock index 3a68c3e9..031c95c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -235,7 +235,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.19", ] [[package]] @@ -267,6 +267,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + [[package]] name = "async-compression" version = "0.3.15" @@ -366,14 +377,14 @@ name = "bench" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.1.4", + "clap 4.1.6", "csv", "dirs", "log", "serde", "serde_json", "solana-rpc-client", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "tokio", "tracing-subscriber", ] @@ -515,21 +526,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.17" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - -[[package]] -name = "bstr" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832" +checksum = "5ffdb39cb703212f3c11973452c2861b972f757b021158f3516ba10f2fa8b2c1" dependencies = [ "memchr", "serde", @@ -676,9 +675,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.4" +version = "4.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" dependencies = [ "bitflags", "clap_derive", @@ -743,6 +742,15 @@ dependencies = [ "unreachable", ] +[[package]] +name = "concurrent-queue" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.5" @@ -913,13 +921,12 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.6" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359" dependencies = [ - "bstr 0.2.17", "csv-core", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] @@ -958,9 +965,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" dependencies = [ "cc", "cxxbridge-flags", @@ -970,9 +977,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" dependencies = [ "cc", "codespan-reporting", @@ -985,15 +992,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" [[package]] name = "cxxbridge-macro" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2 1.0.51", "quote 1.0.23", @@ -1002,9 +1009,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" dependencies = [ "darling_core", "darling_macro", @@ -1012,9 +1019,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" dependencies = [ "fnv", "ident_case", @@ -1026,9 +1033,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" dependencies = [ "darling_core", "quote 1.0.23", @@ -1250,9 +1257,9 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91a4ec26efacf4aeff80887a175a419493cb6f8b5480d26387eb0bd038976187" +checksum = "9ea166b3f7dc1032f7866d13f8d8e02c8d87507b61750176b86554964dc6a7bf" dependencies = [ "enum-iterator-derive", ] @@ -1328,9 +1335,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1549,7 +1556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ "aho-corasick", - "bstr 1.2.0", + "bstr", "fnv", "log", "regex", @@ -1683,9 +1690,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856b5cb0902c2b6d65d5fd97dfa30f9b70c7538e770b98eab5ed52d8db923e01" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "histogram" @@ -1725,13 +1732,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.5", + "itoa", ] [[package]] @@ -1778,7 +1785,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.5", + "itoa", "pin-project-lite", "socket2", "tokio", @@ -1921,7 +1928,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" dependencies = [ - "hermit-abi 0.3.0", + "hermit-abi 0.3.1", "io-lifetimes", "rustix", "windows-sys 0.45.0", @@ -1936,12 +1943,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.5" @@ -2242,12 +2243,13 @@ name = "lite-rpc" version = "0.1.0" dependencies = [ "anyhow", + "async-channel", "base64 0.21.0", "bench", "bincode", "bs58", "bytes", - "clap 4.1.4", + "clap 4.1.6", "const_env", "dashmap", "dotenv", @@ -2265,7 +2267,7 @@ dependencies = [ "solana-quic-client", "solana-rpc-client", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-tpu-client", "solana-transaction-status", "solana-version", @@ -2311,9 +2313,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" +checksum = "2af2c65375e552a67fe3829ca63e8a7c27a378a62824594f43b2851d682b5ec2" dependencies = [ "libc", ] @@ -2380,14 +2382,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2562,18 +2564,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" +checksum = "3e0072973714303aa6e3631c7e8e777970cf4bdd25dc4932e41031027b8bcc4e" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" +checksum = "0629cbd6b897944899b1f10496d9c4a7ac5878d45fd61bc22e9e79bfbbc29597" dependencies = [ "proc-macro-crate 1.3.0", "proc-macro2 1.0.51", @@ -2598,9 +2600,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -2744,9 +2746,9 @@ dependencies = [ [[package]] name = "pest" -version = "2.5.4" +version = "2.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab62d2fa33726dbe6321cc97ef96d8cde531e3eeaf858a058de53a8a6d40d8f" +checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660" dependencies = [ "thiserror", "ucd-trie", @@ -3160,7 +3162,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.17", + "time 0.3.19", "yasna", ] @@ -3195,12 +3197,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" version = "0.6.28" @@ -3526,11 +3522,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7434af0dc1cbd59268aa98b4c22c131c0584d2232f6fb166efb993e2832e896a" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ - "itoa 1.0.5", + "itoa", "ryu", "serde", ] @@ -3542,7 +3538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.5", + "itoa", "ryu", "serde", ] @@ -3656,9 +3652,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -3687,9 +3683,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3742,7 +3738,7 @@ dependencies = [ "serde_json", "solana-address-lookup-table-program", "solana-config-program", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "spl-token", "spl-token-2022", "thiserror", @@ -3761,11 +3757,11 @@ dependencies = [ "num-traits", "rustc_version 0.4.0", "serde", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-program 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", + "solana-program 1.15.0", "solana-program-runtime", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", ] @@ -3779,7 +3775,7 @@ dependencies = [ "rpassword", "solana-perf", "solana-remote-wallet", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", "tiny-bip39", "uriparse", @@ -3810,7 +3806,7 @@ dependencies = [ "solana-rpc-client", "solana-rpc-client-api", "solana-rpc-client-nonce-utils", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-streamer", "solana-thin-client", "solana-tpu-client", @@ -3829,41 +3825,7 @@ dependencies = [ "serde", "serde_derive", "solana-program-runtime", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", -] - -[[package]] -name = "solana-frozen-abi" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc55e72b77452b4469a7f46c3526cbddb4a43382370d5c1112dc108569cfe16" -dependencies = [ - "ahash", - "blake3", - "block-buffer 0.9.0", - "bs58", - "bv", - "byteorder", - "cc", - "either", - "generic-array", - "getrandom 0.1.16", - "hashbrown 0.12.3", - "im", - "lazy_static", - "log", - "memmap2", - "once_cell", - "rand_core 0.6.4", - "rustc_version 0.4.0", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "solana-frozen-abi-macro 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle", - "thiserror", + "solana-sdk 1.15.0", ] [[package]] @@ -3894,7 +3856,41 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.6", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi-macro 1.15.0", + "subtle", + "thiserror", +] + +[[package]] +name = "solana-frozen-abi" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f7051cccdf891ac2603cdd295eb651529fe2b678b6b3af60b82dec9a9b3b06" +dependencies = [ + "ahash", + "blake3", + "block-buffer 0.9.0", + "bs58", + "bv", + "byteorder", + "cc", + "either", + "generic-array", + "getrandom 0.1.16", + "hashbrown 0.12.3", + "im", + "lazy_static", + "log", + "memmap2", + "once_cell", + "rand_core 0.6.4", + "rustc_version 0.4.0", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "solana-frozen-abi-macro 1.15.2", "subtle", "thiserror", ] @@ -3902,8 +3898,7 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7084605b674cf344312c3a2a9c0de05126c2ff4d3d77cc6746f236ca3c4cb53" +source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" dependencies = [ "proc-macro2 1.0.51", "quote 1.0.23", @@ -3913,8 +3908,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.15.0" -source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06395428329810ade1d2518a7e75d8a6f02d01fe548aabb60ff1ba6a2eaebbe5" dependencies = [ "proc-macro2 1.0.51", "quote 1.0.23", @@ -3925,8 +3921,7 @@ dependencies = [ [[package]] name = "solana-logger" version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae1169570b4f086a42f340b86b698b8b64dfa0f931f2a4f0f3c5b18195d6711" +source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" dependencies = [ "env_logger", "lazy_static", @@ -3935,8 +3930,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.15.0" -source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170714ca3612e4df75f57c2c14c8ab74654b3b66f668986aeed456cedcf24446" dependencies = [ "env_logger", "lazy_static", @@ -3949,7 +3945,7 @@ version = "1.15.0" source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" dependencies = [ "log", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", ] [[package]] @@ -3962,7 +3958,7 @@ dependencies = [ "lazy_static", "log", "reqwest", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", ] [[package]] @@ -3979,8 +3975,8 @@ dependencies = [ "serde", "serde_derive", "socket2", - "solana-logger 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-logger 1.15.0", + "solana-sdk 1.15.0", "solana-version", "tokio", "url", @@ -4008,64 +4004,10 @@ dependencies = [ "serde", "solana-metrics", "solana-rayon-threadlimit", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-vote-program", ] -[[package]] -name = "solana-program" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3442ab665ded18fd8526213027a2c05035164b7696e7bf535b7c2d7fa75536fe" -dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "array-bytes", - "base64 0.13.1", - "bincode", - "bitflags", - "blake3", - "borsh", - "borsh-derive", - "bs58", - "bv", - "bytemuck", - "cc", - "console_error_panic_hook", - "console_log", - "curve25519-dalek", - "getrandom 0.2.8", - "itertools", - "js-sys", - "lazy_static", - "libc", - "libsecp256k1", - "log", - "memoffset 0.8.0", - "num-bigint 0.4.3", - "num-derive", - "num-traits", - "parking_lot", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rustc_version 0.4.0", - "rustversion", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "sha3 0.10.6", - "solana-frozen-abi 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-frozen-abi-macro 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-sdk-macro 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror", - "tiny-bip39", - "wasm-bindgen", - "zeroize", -] - [[package]] name = "solana-program" version = "1.15.0" @@ -4110,9 +4052,63 @@ dependencies = [ "serde_json", "sha2 0.10.6", "sha3 0.10.6", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-sdk-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", + "solana-sdk-macro 1.15.0", + "thiserror", + "tiny-bip39", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "solana-program" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ae9f0fa7db3a4e90fa0df2723ac8cbc042e579cf109cd0380bc5a8c88bed924" +dependencies = [ + "ark-bn254", + "ark-ec", + "ark-ff", + "array-bytes", + "base64 0.13.1", + "bincode", + "bitflags", + "blake3", + "borsh", + "borsh-derive", + "bs58", + "bv", + "bytemuck", + "cc", + "console_error_panic_hook", + "console_log", + "curve25519-dalek", + "getrandom 0.2.8", + "itertools", + "js-sys", + "lazy_static", + "libc", + "libsecp256k1", + "log", + "memoffset 0.8.0", + "num-bigint 0.4.3", + "num-derive", + "num-traits", + "parking_lot", + "rand 0.7.3", + "rand_chacha 0.2.2", + "rustc_version 0.4.0", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "sha3 0.10.6", + "solana-frozen-abi 1.15.2", + "solana-frozen-abi-macro 1.15.2", + "solana-sdk-macro 1.15.2", "thiserror", "tiny-bip39", "wasm-bindgen", @@ -4137,11 +4133,11 @@ dependencies = [ "rand 0.7.3", "rustc_version 0.4.0", "serde", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", "solana-measure", "solana-metrics", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana_rbpf", "thiserror", ] @@ -4161,7 +4157,7 @@ dependencies = [ "serde_json", "solana-account-decoder", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", "tokio", "tokio-stream", @@ -4189,7 +4185,7 @@ dependencies = [ "solana-metrics", "solana-net-utils", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-streamer", "solana-tpu-client", "thiserror", @@ -4218,7 +4214,7 @@ dependencies = [ "parking_lot", "qstring", "semver 1.0.16", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", "uriparse", ] @@ -4241,7 +4237,7 @@ dependencies = [ "serde_json", "solana-account-decoder", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-transaction-status", "solana-version", "solana-vote-program", @@ -4262,7 +4258,7 @@ dependencies = [ "serde_derive", "serde_json", "solana-account-decoder", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-transaction-status", "solana-version", "spl-token-2022", @@ -4277,63 +4273,10 @@ dependencies = [ "clap 2.34.0", "solana-clap-utils", "solana-rpc-client", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", ] -[[package]] -name = "solana-sdk" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73788ea1793a23a3d24d1d9ed81a64dbbdd02dac058e0e363a604135e351e670" -dependencies = [ - "assert_matches", - "base64 0.13.1", - "bincode", - "bitflags", - "borsh", - "bs58", - "bytemuck", - "byteorder", - "chrono", - "derivation-path", - "digest 0.10.6", - "ed25519-dalek", - "ed25519-dalek-bip32", - "generic-array", - "hmac 0.12.1", - "itertools", - "js-sys", - "lazy_static", - "libsecp256k1", - "log", - "memmap2", - "num-derive", - "num-traits", - "num_enum", - "pbkdf2 0.11.0", - "qstring", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rustc_version 0.4.0", - "rustversion", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "serde_with", - "sha2 0.10.6", - "sha3 0.10.6", - "solana-frozen-abi 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-frozen-abi-macro 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-logger 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-sdk-macro 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror", - "uriparse", - "wasm-bindgen", -] - [[package]] name = "solana-sdk" version = "1.15.0" @@ -4376,11 +4319,64 @@ dependencies = [ "serde_with", "sha2 0.10.6", "sha3 0.10.6", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-logger 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-program 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-sdk-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", + "solana-logger 1.15.0", + "solana-program 1.15.0", + "solana-sdk-macro 1.15.0", + "thiserror", + "uriparse", + "wasm-bindgen", +] + +[[package]] +name = "solana-sdk" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbefda9f9bda78fd9d91ae21c38d9693e94d5979838fb69b70c6addb8dab953f" +dependencies = [ + "assert_matches", + "base64 0.13.1", + "bincode", + "bitflags", + "borsh", + "bs58", + "bytemuck", + "byteorder", + "chrono", + "derivation-path", + "digest 0.10.6", + "ed25519-dalek", + "ed25519-dalek-bip32", + "generic-array", + "hmac 0.12.1", + "itertools", + "js-sys", + "lazy_static", + "libsecp256k1", + "log", + "memmap2", + "num-derive", + "num-traits", + "num_enum", + "pbkdf2 0.11.0", + "qstring", + "rand 0.7.3", + "rand_chacha 0.2.2", + "rustc_version 0.4.0", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "serde_with", + "sha2 0.10.6", + "sha3 0.10.6", + "solana-frozen-abi 1.15.2", + "solana-frozen-abi-macro 1.15.2", + "solana-logger 1.15.2", + "solana-program 1.15.2", + "solana-sdk-macro 1.15.2", "thiserror", "uriparse", "wasm-bindgen", @@ -4389,8 +4385,7 @@ dependencies = [ [[package]] name = "solana-sdk-macro" version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e216372c12c4bd820afd02ab90564472e14e1ff609b6737e9d832749370656" +source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" dependencies = [ "bs58", "proc-macro2 1.0.51", @@ -4401,8 +4396,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.15.0" -source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04daf93c153bdce7f461ad284843c21c63ca621f" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f809319358d5da7c3a0ac08ebf4d87b21170d928dbb7260254e8f3061f7f9e0e" dependencies = [ "bs58", "proc-macro2 1.0.51", @@ -4435,7 +4431,7 @@ dependencies = [ "rustls", "solana-metrics", "solana-perf", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", "tokio", "x509-parser", @@ -4450,7 +4446,7 @@ dependencies = [ "log", "solana-rpc-client", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-tpu-client", ] @@ -4473,7 +4469,7 @@ dependencies = [ "solana-pubsub-client", "solana-rpc-client", "solana-rpc-client-api", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", "tokio", ] @@ -4495,7 +4491,7 @@ dependencies = [ "serde_json", "solana-account-decoder", "solana-address-lookup-table-program", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "spl-associated-token-account", "spl-memo", "spl-token", @@ -4510,7 +4506,7 @@ source = "git+https://github.com/blockworks-foundation/solana?branch=lite_rpc#04 dependencies = [ "async-trait", "solana-net-utils", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "solana-streamer", "solana-tpu-client", "thiserror", @@ -4527,9 +4523,9 @@ dependencies = [ "semver 1.0.16", "serde", "serde_derive", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", + "solana-sdk 1.15.0", ] [[package]] @@ -4544,20 +4540,20 @@ dependencies = [ "rustc_version 0.4.0", "serde", "serde_derive", - "solana-frozen-abi 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", - "solana-frozen-abi-macro 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-frozen-abi 1.15.0", + "solana-frozen-abi-macro 1.15.0", "solana-metrics", - "solana-program 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-program 1.15.0", "solana-program-runtime", - "solana-sdk 1.15.0 (git+https://github.com/blockworks-foundation/solana?branch=lite_rpc)", + "solana-sdk 1.15.0", "thiserror", ] [[package]] name = "solana-zk-token-sdk" -version = "1.15.0" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa4276fd41317c7367f665684410430c8ddae065af6e997b98a26a201ca2c1e" +checksum = "9a290aa32014e007b03f952d5b784433d95636c65a3fb08d19dc5658a450941c" dependencies = [ "aes-gcm-siv", "arrayref", @@ -4577,8 +4573,8 @@ dependencies = [ "serde", "serde_json", "sha3 0.9.1", - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-sdk 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-program 1.15.2", + "solana-sdk 1.15.2", "subtle", "thiserror", "zeroize", @@ -4629,7 +4625,7 @@ dependencies = [ "borsh", "num-derive", "num-traits", - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-program 1.15.2", "spl-token", "spl-token-2022", "thiserror", @@ -4641,7 +4637,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325" dependencies = [ - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-program 1.15.2", ] [[package]] @@ -4655,7 +4651,7 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-program 1.15.2", "thiserror", ] @@ -4670,7 +4666,7 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-program 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "solana-program 1.15.2", "solana-zk-token-sdk", "spl-memo", "spl-token", @@ -4799,10 +4795,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -4819,11 +4816,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "53250a3b3fed8ff8fd988587d8925d26a83ac3845d9e03b220b37f34c2b8d6c2" dependencies = [ - "itoa 1.0.5", + "itoa", "serde", "time-core", "time-macros", @@ -4837,9 +4834,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "a460aeb8de6dcb0f381e1ee05f1cd56fcf5a5f6eb8187ff3d8f0b11078d38b7c" dependencies = [ "time-core", ] @@ -4911,9 +4908,9 @@ dependencies = [ [[package]] name = "tokio-native-tls" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", "tokio", @@ -4956,9 +4953,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", @@ -4983,9 +4980,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", @@ -5530,7 +5527,7 @@ dependencies = [ "oid-registry", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.19", ] [[package]] @@ -5539,7 +5536,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" dependencies = [ - "time 0.3.17", + "time 0.3.19", ] [[package]] @@ -5584,9 +5581,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.6+zstd.1.5.2" +version = "2.0.7+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a3f9792c0c3dc6c165840a75f47ae1f4da402c2d006881129579f6597e801b" +checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 7658c9b8..45ef7c99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ solana-transaction-status = { git = "https://github.com/blockworks-foundation/so solana-version= { git = "https://github.com/blockworks-foundation/solana", branch="lite_rpc" } solana-client= { git = "https://github.com/blockworks-foundation/solana", branch="lite_rpc" } serde = { version = "1.0.152", features = ["derive"] } -serde_json = "1.0.92" +serde_json = "1.0.93" tokio = { version = "1.25.0", features = ["full"]} bincode = "1.3.3" bs58 = "0.4.0" @@ -33,7 +33,7 @@ futures = "0.3.26" bytes = "1.4.0" anyhow = "1.0.69" log = "0.4.17" -clap = { version = "4.1.4", features = ["derive"] } +clap = { version = "4.1.6", features = ["derive"] } dashmap = "5.4.0" const_env = "0.1.2" jsonrpsee = { version = "0.16.2", features = ["macros", "full"] } @@ -43,4 +43,5 @@ native-tls = "0.2.11" postgres-native-tls = "0.5.0" prometheus = "0.13.3" lazy_static = "1.4.0" -dotenv = "0.15.0" \ No newline at end of file +dotenv = "0.15.0" +async-channel = "1.8.0" diff --git a/bench/Cargo.toml b/bench/Cargo.toml index e32a927f..ec70ae91 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -9,9 +9,9 @@ solana-rpc-client = { git = "https://github.com/blockworks-foundation/solana", b log = "0.4.17" anyhow = "1.0.69" serde = "1.0.152" -serde_json = "1.0.92" -csv = "1.1.6" -clap = { version = "4.1.4", features = ["derive"] } +serde_json = "1.0.93" +csv = "1.2.0" +clap = { version = "4.1.6", features = ["derive"] } tokio = { version = "1.25.0", features = ["full", "fs"]} tracing-subscriber = "0.3.16" dirs = "4.0.0" diff --git a/src/tpu_manager.rs b/src/tpu_manager.rs index 48aff2a3..eb5e4ea1 100644 --- a/src/tpu_manager.rs +++ b/src/tpu_manager.rs @@ -63,7 +63,7 @@ impl TpuManager { ws_addr, fanout_slots, error_count: Default::default(), - connection_cache: connection_cache, + connection_cache, }) } @@ -101,7 +101,7 @@ impl TpuManager { Ok(()) } - async fn get_tpu_client(&self) -> Arc { + pub async fn get_tpu_client(&self) -> Arc { self.tpu_client.read().await.clone() } diff --git a/src/workers/tx_sender.rs b/src/workers/tx_sender.rs index 3944f4b9..50dda599 100644 --- a/src/workers/tx_sender.rs +++ b/src/workers/tx_sender.rs @@ -10,7 +10,7 @@ use log::{info, warn}; use prometheus::{register_counter, Counter}; use solana_transaction_status::TransactionStatus; use tokio::{ - sync::{mpsc::UnboundedReceiver, TryAcquireError}, + sync::mpsc::{error::TryRecvError, UnboundedReceiver}, task::JoinHandle, }; @@ -35,8 +35,6 @@ pub struct TxSender { pub txs_sent: Arc>, /// TpuClient to call the tpu port pub tpu_manager: Arc, - - counting_semaphore: Arc, } /// Transaction Properties @@ -60,7 +58,57 @@ impl TxSender { Self { tpu_manager, txs_sent: Default::default(), - counting_semaphore: Arc::new(tokio::sync::Semaphore::new(5)), + } + } + + /// retry enqued_tx(s) + async fn forward_txs( + &self, + sigs_and_slots: Vec<(String, u64)>, + txs: Vec, + postgres: Option, + ) { + assert_eq!(sigs_and_slots.len(), txs.len()); + + if sigs_and_slots.is_empty() { + return; + } + + let tpu_client = self.tpu_manager.clone(); + let txs_sent = self.txs_sent.clone(); + + let quic_response = match tpu_client.try_send_wire_transaction_batch(txs).await { + Ok(_) => { + for (sig, _) in &sigs_and_slots { + txs_sent.insert(sig.to_owned(), TxProps::default()); + } + // metrics + TXS_SENT.inc_by(sigs_and_slots.len() as f64); + + 1 + } + Err(err) => { + warn!("{err}"); + 0 + } + }; + + if let Some(postgres) = postgres { + let forwarded_slot = tpu_client.get_tpu_client().await.estimated_current_slot(); + + for (sig, recent_slot) in sigs_and_slots { + postgres + .send(PostgresMsg::PostgresTx(PostgresTx { + signature: sig.clone(), + recent_slot: recent_slot as i64, + forwarded_slot: forwarded_slot as i64, + processed_slot: None, + cu_consumed: None, + cu_requested: None, + quic_response, + })) + .expect("Error writing to postgres service"); + } } } @@ -72,107 +120,49 @@ impl TxSender { tx_send_interval: Duration, postgres_send: Option, ) -> JoinHandle> { + let (batch_send, batch_recv) = async_channel::unbounded(); + + for _i in 0..5 { + let this = self.clone(); + let batch_recv = batch_recv.clone(); + let postgres_send = postgres_send.clone(); + + tokio::spawn(async move { + while let Ok((sigs_and_slots, txs)) = batch_recv.recv().await { + this.forward_txs(sigs_and_slots, txs, postgres_send.clone()) + .await; + } + }); + } + tokio::spawn(async move { info!( - "Batching tx(s) with batch size of {tx_batch_size} every {} ms", + "Batching tx(s) with batch size of {tx_batch_size} every {}ms", tx_send_interval.as_millis() ); loop { let mut sigs_and_slots = Vec::with_capacity(tx_batch_size); let mut txs = Vec::with_capacity(tx_batch_size); - let mut maybe_permit = None; - let counting_semaphore = self.counting_semaphore.clone(); + while txs.len() <= tx_batch_size { - let res = tokio::time::timeout(tx_send_interval, recv.recv()).await; - match res { - Ok(value) => match value { - Some((sig, tx, slot)) => { - sigs_and_slots.push((sig, slot)); - txs.push(tx); - } - None => { - bail!("Channel Disconnected"); - } - }, + match recv.try_recv() { + Ok((sig, tx, slot)) => { + sigs_and_slots.push((sig, slot)); + txs.push(tx); + } + Err(TryRecvError::Disconnected) => { + bail!("Channel Disconnected"); + } _ => { - let res = counting_semaphore.clone().try_acquire_owned(); - match res { - Ok(permit) => { - maybe_permit = Some(permit); - break; - } - Err(TryAcquireError::Closed) => { - bail!("Semaphone permit error"); - } - Err(TryAcquireError::NoPermits) => { - // No permits continue to fetch transactions and batch them - } - } + break; } } } - assert_eq!(sigs_and_slots.len(), txs.len()); - if sigs_and_slots.is_empty() { - continue; - } + batch_send.send((sigs_and_slots, txs)).await?; - let permit = match maybe_permit { - Some(permit) => permit, - None => { - // get the permit - counting_semaphore.acquire_owned().await.unwrap() - } - }; - - let postgres_send = postgres_send.clone(); - let tpu_client = self.tpu_manager.clone(); - let txs_sent = self.txs_sent.clone(); - tokio::spawn(async move { - let semaphore_permit = permit; - - for (sig, _) in &sigs_and_slots { - txs_sent.insert(sig.to_owned(), TxProps::default()); - } - info!( - "sending {} transactions by tpu size {}", - txs.len(), - txs_sent.len() - ); - let quic_response = { - let _semaphore_permit = semaphore_permit; - match tpu_client.try_send_wire_transaction_batch(txs).await { - Ok(_) => { - // metrics - TXS_SENT.inc_by(sigs_and_slots.len() as f64); - 1 - } - Err(err) => { - warn!("{err}"); - 0 - } - } - }; - - if let Some(postgres) = postgres_send { - let forwarded_slot: u64 = tpu_client.estimated_current_slot().await; - - for (sig, recent_slot) in sigs_and_slots { - postgres - .send(PostgresMsg::PostgresTx(PostgresTx { - signature: sig.clone(), - recent_slot: recent_slot as i64, - forwarded_slot: forwarded_slot as i64, - processed_slot: None, - cu_consumed: None, - cu_requested: None, - quic_response, - })) - .expect("Error writing to postgres service"); - } - } - }); + tokio::time::sleep(tx_send_interval).await; } }) }