diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1de7bb4d..7c096b23 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -20,7 +20,7 @@ jobs: - name: Install Linux Packages run: | sudo apt-get update -y - sudo apt-get install libssl-dev openssl -y + sudo apt-get install libssl-dev openssl protobuf-compiler -y - uses: actions/checkout@v4 diff --git a/.github/workflows/clippy_test.yml b/.github/workflows/clippy_test.yml index 625a9515..31617818 100644 --- a/.github/workflows/clippy_test.yml +++ b/.github/workflows/clippy_test.yml @@ -20,7 +20,7 @@ jobs: - name: Install Linux Packages run: | sudo apt-get update -y - sudo apt-get install libssl-dev openssl -y + sudo apt-get install libssl-dev openssl protobuf-compiler -y - uses: actions/checkout@v4 diff --git a/Cargo.lock b/Cargo.lock index 2dea1211..2732f4e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,7 +490,7 @@ dependencies = [ "axum-core", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "itoa", @@ -516,7 +516,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "mime", @@ -577,7 +577,7 @@ dependencies = [ [[package]] name = "bench" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "bincode", @@ -600,7 +600,7 @@ dependencies = [ "solana-rpc-client-api", "solana-sdk", "solana-transaction-status", - "spl-memo 4.0.4", + "spl-memo 4.0.0", "tokio", "tracing", "tracing-subscriber", @@ -1300,7 +1300,7 @@ dependencies = [ [[package]] name = "custom-tpu-send-transactions" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "bincode", @@ -1862,27 +1862,19 @@ dependencies = [ [[package]] name = "geyser-grpc-connector" -version = "2.0.0" -source = "git+https://github.com/blockworks-foundation/geyser-grpc-connector.git?branch=2.0.16#214886a27da719807fbc3cbdbf7fb717bc280e7e" +version = "0.11.0+yellowstone.2.0.0" +source = "git+https://github.com/blockworks-foundation/geyser-grpc-connector.git?tag=v0.11.0+yellowstone.2.0.0+solana.2.0#78d33f3d3c55d0af6d0c02e4e0de8317f93c5c54" dependencies = [ "anyhow", "async-stream", - "base64 0.21.7", - "bincode", - "clap 4.5.21", - "csv", - "dashmap", - "derive_more", "futures", "itertools 0.10.5", "log", - "lz4_flex", "merge-streams", - "regex", "solana-sdk", "tokio", - "tonic 0.12.3", - "tonic-health 0.12.3", + "tonic", + "tonic-health", "tracing", "url", "yellowstone-grpc-client", @@ -1982,7 +1974,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http 1.2.0", "indexmap 2.6.0", "slab", "tokio", @@ -2120,9 +2112,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -2147,7 +2139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -2158,7 +2150,7 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] @@ -2221,7 +2213,7 @@ dependencies = [ "futures-channel", "futures-util", "h2 0.4.7", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "httparse", "httpdate", @@ -2283,7 +2275,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "hyper 1.5.1", "pin-project-lite", @@ -2479,9 +2471,9 @@ dependencies = [ [[package]] name = "index_list" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e6ba961c14e98151cd6416dd3685efe786a94c38bc1a535c06ceff0a1600813" +checksum = "fa38453685e5fe724fd23ff6c1a158c1e2ca21ce0c2718fa11e96e70e99fd4de" [[package]] name = "indexmap" @@ -2565,15 +2557,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.13" @@ -2907,7 +2890,7 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lite-rpc" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-channel", @@ -3002,15 +2985,6 @@ dependencies = [ "libc", ] -[[package]] -name = "lz4_flex" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" -dependencies = [ - "twox-hash", -] - [[package]] name = "matchers" version = "0.1.0" @@ -3505,16 +3479,6 @@ dependencies = [ "base64 0.13.1", ] -[[package]] -name = "pem" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" -dependencies = [ - "base64 0.22.1", - "serde", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -3777,22 +3741,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" -dependencies = [ - "bytes", - "prost-derive 0.12.6", -] - -[[package]] -name = "prost" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" dependencies = [ "bytes", - "prost-derive 0.13.3", + "prost-derive 0.13.4", ] [[package]] @@ -3819,20 +3773,19 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" +checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "bytes", "heck 0.5.0", - "itertools 0.13.0", + "itertools 0.12.1", "log", "multimap 0.10.0", "once_cell", "petgraph", "prettyplease 0.2.25", - "prost 0.13.3", - "prost-types 0.13.3", + "prost 0.13.4", + "prost-types 0.13.4", "regex", "syn 2.0.89", "tempfile", @@ -3853,9 +3806,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", "itertools 0.12.1", @@ -3864,19 +3817,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "prost-derive" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" -dependencies = [ - "anyhow", - "itertools 0.13.0", - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "prost-types" version = "0.11.9" @@ -3888,11 +3828,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" dependencies = [ - "prost 0.13.3", + "prost 0.13.4", ] [[package]] @@ -4095,13 +4035,12 @@ dependencies = [ [[package]] name = "rcgen" -version = "0.13.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" +checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ - "pem 3.0.4", - "ring 0.17.8", - "rustls-pki-types", + "pem", + "ring 0.16.20", "time", "yasna", ] @@ -4346,9 +4285,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.18" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -5078,7 +5017,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-accounts" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5119,7 +5058,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-accounts-on-demand" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5162,7 +5101,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-address-lookup-tables" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5200,7 +5139,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-benchrunner-service" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5231,7 +5170,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-blockstore" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5265,7 +5204,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-cluster-endpoints" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-channel", @@ -5301,14 +5240,14 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "tonic-health 0.10.2", + "tonic-health", "tracing", "yellowstone-grpc-proto", ] [[package]] name = "solana-lite-rpc-core" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", @@ -5343,7 +5282,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-prioritization-fees" -version = "0.2.4" +version = "0.3.0" dependencies = [ "dashmap", "itertools 0.10.5", @@ -5442,7 +5381,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-services" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-channel", @@ -5482,7 +5421,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-util" -version = "0.2.4" +version = "0.3.0" dependencies = [ "anyhow", "async-channel", @@ -6000,7 +5939,7 @@ dependencies = [ "libc", "log", "nix", - "pem 1.1.1", + "pem", "percentage", "quinn", "quinn-proto", @@ -6338,9 +6277,9 @@ dependencies = [ [[package]] name = "spl-memo" -version = "4.0.4" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49f49f95f2d02111ded31696ab38a081fab623d4c76bd4cb074286db4560836" +checksum = "f0f180b03318c3dbab3ef4e1e4d46d5211ae3c780940dd0a28695aba4b59a75a" dependencies = [ "solana-program 1.18.26", ] @@ -6866,12 +6805,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.18", - "rustls-pki-types", + "rustls 0.23.19", "tokio", ] @@ -6967,27 +6905,6 @@ dependencies = [ "winnow 0.6.20", ] -[[package]] -name = "tonic" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" -dependencies = [ - "async-trait", - "base64 0.21.7", - "bytes", - "http 0.2.12", - "http-body 0.4.6", - "percent-encoding", - "pin-project", - "prost 0.12.6", - "tokio", - "tokio-stream", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tonic" version = "0.12.3" @@ -6999,9 +6916,8 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "flate2", "h2 0.4.7", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -7009,12 +6925,12 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost 0.13.3", + "prost 0.13.4", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "socket2", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tokio-stream", "tower 0.4.13", "tower-layer", @@ -7030,25 +6946,12 @@ checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease 0.2.25", "proc-macro2", - "prost-build 0.13.3", - "prost-types 0.13.3", + "prost-build 0.13.4", + "prost-types 0.13.4", "quote", "syn 2.0.89", ] -[[package]] -name = "tonic-health" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f80db390246dfb46553481f6024f0082ba00178ea495dbb99e70ba9a4fafb5e1" -dependencies = [ - "async-stream", - "prost 0.12.6", - "tokio", - "tokio-stream", - "tonic 0.10.2", -] - [[package]] name = "tonic-health" version = "0.12.3" @@ -7056,10 +6959,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1eaf34ddb812120f5c601162d5429933c9b527d901ab0e7f930d3147e33a09b2" dependencies = [ "async-stream", - "prost 0.13.3", + "prost 0.13.4", "tokio", "tokio-stream", - "tonic 0.12.3", + "tonic", ] [[package]] @@ -7247,16 +7150,6 @@ dependencies = [ "webpki-roots 0.24.0", ] -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "static_assertions", -] - [[package]] name = "typenum" version = "1.17.0" @@ -7872,8 +7765,8 @@ dependencies = [ "bytes", "futures", "thiserror", - "tonic 0.12.3", - "tonic-health 0.12.3", + "tonic", + "tonic-health", "yellowstone-grpc-proto", ] @@ -7884,12 +7777,12 @@ source = "git+https://github.com/rpcpool/yellowstone-grpc.git?tag=v2.0.0+solana. dependencies = [ "anyhow", "bincode", - "prost 0.13.3", + "prost 0.13.4", "protobuf-src", "solana-account-decoder", "solana-sdk", "solana-transaction-status", - "tonic 0.12.3", + "tonic", "tonic-build", ] diff --git a/Cargo.toml b/Cargo.toml index d2eaa551..dbf72a3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,13 +21,26 @@ members = [ ] [workspace.package] -version = "0.2.4" +version = "0.3.0" authors = ["gmgalactus ", "GroovieGermanikus "] repository = "https://github.com/blockworks-foundation/lite-rpc" license = "AGPL" edition = "2021" [workspace.dependencies] + +solana-lite-rpc-services = { path = "services", version="0.3.0" } +solana-lite-rpc-core = { path = "core", version="0.3.0" } +solana-lite-rpc-util = { path = "util", version="0.3.0" } +solana-lite-rpc-cluster-endpoints = { path = "cluster-endpoints", version="0.3.0" } +solana-lite-rpc-blockstore = { path = "blockstore", version="0.3.0" } +solana-lite-rpc-stakevote = { path = "stake_vote", version="0.3.0" } +solana-lite-rpc-prioritization-fees = { path = "prioritization_fees", version="0.3.0" } +solana-lite-rpc-address-lookup-tables = { path = "address-lookup-tables", version="0.3.0" } +solana-lite-rpc-accounts = { path = "accounts", version = "0.3.0"} +solana-lite-rpc-accounts-on-demand = { path = "accounts-on-demand", version = "0.3.0"} +bench = { path = "bench", version="0.3.0" } + solana-sdk = "~2.0.16" solana-rpc-client = "~2.0.16" solana-rpc-client-api = "~2.0.16" @@ -42,6 +55,11 @@ solana-ledger = "~2.0.16" solana-program = "~2.0.16" solana-accounts-db = "~2.0.16" solana-address-lookup-table-program = "~2.0.16" + +yellowstone-grpc-proto = { git = "https://github.com/rpcpool/yellowstone-grpc.git", tag = "v2.0.0+solana.2.0.16" } +geyser-grpc-connector = { git = "https://github.com/blockworks-foundation/geyser-grpc-connector.git", tag = "v0.11.0+yellowstone.2.0.0+solana.2.0" } + + itertools = "0.10.5" rangetools = "0.1.4" serde = { version = "1.0.160", features = ["derive"] } @@ -51,6 +69,7 @@ bs58 = "0.4.0" base64 = "0.21.0" borsh = "0.10.3" thiserror = "1.0.40" +async-trait = "0.1.68" futures = "0.3.28" futures-util = "0.3.28" bytes = "1.4.0" @@ -71,31 +90,13 @@ dotenv = "0.15.0" async-channel = "1.8.0" merge-streams = "0.1.2" jemallocator = "0.5" - quinn = "0.10.2" quinn-proto = "0.10.5" rustls = { version = "0.21.7", default-features = false, features = ["quic"] } -rcgen = "0.13.1" - -solana-lite-rpc-services = {path = "services", version="0.2.4"} -solana-lite-rpc-core = {path = "core", version="0.2.4"} -solana-lite-rpc-util = {path = "util", version="0.2.4"} -solana-lite-rpc-cluster-endpoints = {path = "cluster-endpoints", version="0.2.4"} -solana-lite-rpc-blockstore = {path = "blockstore", version="0.2.4"} -solana-lite-rpc-stakevote = {path = "stake_vote", version="0.2.4"} -solana-lite-rpc-prioritization-fees = {path = "prioritization_fees", version="0.2.4"} -solana-lite-rpc-address-lookup-tables = {path = "address-lookup-tables", version="0.2.4"} -solana-lite-rpc-accounts = {path = "accounts", version = "0.2.4"} -solana-lite-rpc-accounts-on-demand = {path = "accounts-on-demand", version = "0.2.4"} -bench = { path = "bench", version="0.2.4" } - -yellowstone-grpc-proto = { git = "https://github.com/rpcpool/yellowstone-grpc.git", tag = "v2.0.0+solana.2.0.16" } -geyser-grpc-connector = { git = "https://github.com/blockworks-foundation/geyser-grpc-connector.git", branch = "2.0.16" } # FIXME use tag instead of branch - - -async-trait = "0.1.68" -tonic-health = "0.10" +tonic = "0.12" +tonic-health = "0.12" +rcgen = "0.9.3" [patch.crates-io.curve25519-dalek] git = "https://github.com/anza-xyz/curve25519-dalek.git" -rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464" \ No newline at end of file +rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464" diff --git a/Dockerfile b/Dockerfile index 1e9e42c5..e949214a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax = docker/dockerfile:1.2 -FROM rust:1.75.0 as base +FROM rust:1.81.0 as base RUN cargo install cargo-chef@0.1.62 --locked RUN rustup component add rustfmt RUN apt-get update && apt-get install -y clang cmake ssh diff --git a/Dockerfile-benchrunner b/Dockerfile-benchrunner index 866eb7d0..64035b8f 100644 --- a/Dockerfile-benchrunner +++ b/Dockerfile-benchrunner @@ -1,5 +1,5 @@ # syntax = docker/dockerfile:1.2 -FROM rust:1.75.0 as base +FROM rust:1.81.0 as base RUN cargo install cargo-chef@0.1.62 --locked RUN rustup component add rustfmt RUN apt-get update && apt-get install -y clang cmake ssh diff --git a/accounts-on-demand/Cargo.toml b/accounts-on-demand/Cargo.toml index 21219332..d16e4591 100644 --- a/accounts-on-demand/Cargo.toml +++ b/accounts-on-demand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-accounts-on-demand" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Library which implements accounts on demand service in lite-rpc. Whenever account is not available it will fetch from rpc and create a geyser stream to update it automatically." rust-version = "1.73.0" diff --git a/accounts/Cargo.toml b/accounts/Cargo.toml index a0635736..aa1b8b3b 100644 --- a/accounts/Cargo.toml +++ b/accounts/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-accounts" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Library which implements accounts in lite-rpc" rust-version = "1.73.0" diff --git a/accounts/src/account_service.rs b/accounts/src/account_service.rs index ce5cba91..6e386863 100644 --- a/accounts/src/account_service.rs +++ b/accounts/src/account_service.rs @@ -2,7 +2,7 @@ use std::{str::FromStr, sync::Arc}; use anyhow::bail; use itertools::Itertools; -use prometheus::{IntGauge, opts, register_int_gauge}; +use prometheus::{opts, register_int_gauge, IntGauge}; use solana_account_decoder::{UiAccount, UiDataSliceConfig}; use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_rpc_client_api::{ @@ -12,15 +12,15 @@ use solana_rpc_client_api::{ use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, slot_history::Slot}; use tokio::sync::broadcast::Sender; +use solana_lite_rpc_core::types::BlockInfoStream; use solana_lite_rpc_core::{ - AnyhowJoinHandle, commitment_utils::Commitment, structures::{ account_data::{AccountData, AccountNotificationMessage, AccountStream}, account_filter::AccountFilters, }, + AnyhowJoinHandle, }; -use solana_lite_rpc_core::types::BlockInfoStream; use crate::account_store_interface::{AccountLoadingError, AccountStorageInterface}; @@ -191,9 +191,11 @@ impl AccountService { loop { match blockinfo_stream.recv().await { Ok(block_info) => { - let commitment = Commitment::from(block_info.commitment_config); - let updated_accounts = this.account_store.process_slot_data(block_info.slot, commitment).await; + let updated_accounts = this + .account_store + .process_slot_data(block_info.slot, commitment) + .await; match commitment { Commitment::Processed => {} Commitment::Confirmed => { diff --git a/accounts/src/account_store_interface.rs b/accounts/src/account_store_interface.rs index 7ef4019f..a74d2095 100644 --- a/accounts/src/account_store_interface.rs +++ b/accounts/src/account_store_interface.rs @@ -10,7 +10,7 @@ pub enum AccountLoadingError { AccountNotFound, ConfigDoesnotContainRequiredFilters, OperationTimeOut, - FailedToSpawnTask(String) + FailedToSpawnTask(String), } #[async_trait] diff --git a/accounts/src/inmemory_account_store.rs b/accounts/src/inmemory_account_store.rs index 065366b6..d2dbfb14 100644 --- a/accounts/src/inmemory_account_store.rs +++ b/accounts/src/inmemory_account_store.rs @@ -92,10 +92,12 @@ impl AccountDataByCommitment { .unwrap_or(true); let mut updated = false; - if !self.processed_accounts.contains_key(&data.updated_slot) { + + if let std::collections::btree_map::Entry::Vacant(e) = + self.processed_accounts.entry(data.updated_slot) + { // processed not present for the slot - self.processed_accounts - .insert(data.updated_slot, data.clone()); + e.insert(data.clone()); updated = true; } diff --git a/accounts/src/lib.rs b/accounts/src/lib.rs index 3a786c83..1df87f31 100644 --- a/accounts/src/lib.rs +++ b/accounts/src/lib.rs @@ -2,4 +2,4 @@ pub mod account_service; pub mod account_store_interface; pub mod inmemory_account_store; -pub mod store; \ No newline at end of file +pub mod store; diff --git a/accounts/src/store/accounts_db.rs b/accounts/src/store/accounts_db.rs index 233418ec..0d692da8 100644 --- a/accounts/src/store/accounts_db.rs +++ b/accounts/src/store/accounts_db.rs @@ -1,12 +1,16 @@ -use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::Arc; use async_trait::async_trait; use itertools::Itertools; use solana_accounts_db::accounts::Accounts; -use solana_accounts_db::accounts_db::{AccountsDb as SolanaAccountsDb, AccountsDbConfig, AccountShrinkThreshold, CreateAncientStorage}; +use solana_accounts_db::accounts_db::{ + AccountShrinkThreshold, AccountsDb as SolanaAccountsDb, AccountsDbConfig, CreateAncientStorage, +}; use solana_accounts_db::accounts_file::StorageAccess; -use solana_accounts_db::accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig, IndexLimitMb}; +use solana_accounts_db::accounts_index::{ + AccountSecondaryIndexes, AccountsIndexConfig, IndexLimitMb, +}; use solana_accounts_db::ancestors::Ancestors; use solana_accounts_db::partitioned_rewards::TestPartitionedEpochRewards; use solana_rpc_client_api::filter::RpcFilterType; @@ -16,10 +20,10 @@ use solana_sdk::genesis_config::ClusterType; use solana_sdk::pubkey::Pubkey; use solana_sdk::transaction_context::TransactionAccount; -use Commitment::{Confirmed, Finalized}; use solana_lite_rpc_core::commitment_utils::Commitment; use solana_lite_rpc_core::commitment_utils::Commitment::Processed; use solana_lite_rpc_core::structures::account_data::AccountData; +use Commitment::{Confirmed, Finalized}; use crate::account_store_interface::{AccountLoadingError, AccountStorageInterface}; @@ -103,19 +107,30 @@ impl AccountStorageInterface for AccountsDb { async fn initilize_or_update_account(&self, account_data: AccountData) { let shared_data = account_data.account.to_account_shared_data(); let account_to_store = [(&account_data.pubkey, &shared_data)]; - self.accounts.store_accounts_cached((account_data.updated_slot, account_to_store.as_slice())); + self.accounts + .store_accounts_cached((account_data.updated_slot, account_to_store.as_slice())); } - async fn get_account(&self, account_pk: Pubkey, commitment: Commitment) -> Result, AccountLoadingError> { + async fn get_account( + &self, + account_pk: Pubkey, + commitment: Commitment, + ) -> Result, AccountLoadingError> { let ancestors = self.get_ancestors_from_commitment(commitment); - Ok( - self.accounts - .load_with_fixed_root(&ancestors, &account_pk) - .map(|(shared_data, slot)| Self::convert_to_account_data(account_pk, slot, shared_data)) - ) + Ok(self + .accounts + .load_with_fixed_root(&ancestors, &account_pk) + .map(|(shared_data, slot)| { + Self::convert_to_account_data(account_pk, slot, shared_data) + })) } - async fn get_program_accounts(&self, program_pubkey: Pubkey, account_filter: Option>, commitment: Commitment) -> Option> { + async fn get_program_accounts( + &self, + program_pubkey: Pubkey, + account_filter: Option>, + commitment: Commitment, + ) -> Option> { let slot = self.get_slot_from_commitment(commitment); let filter = |data: &AccountSharedData| { @@ -125,23 +140,24 @@ impl AccountStorageInterface for AccountsDb { match filter { RpcFilterType::DataSize(size) => data.data().len() == *size as usize, RpcFilterType::Memcmp(cmp) => cmp.bytes_match(data.data()), - RpcFilterType::TokenAccountState => unimplemented!() // FIXME + RpcFilterType::TokenAccountState => unimplemented!(), // FIXME } }) } - None => true + None => true, } }; - let transaction_accounts: Vec = self.accounts.load_by_program_slot(slot, Some(&program_pubkey)) + let transaction_accounts: Vec = self + .accounts + .load_by_program_slot(slot, Some(&program_pubkey)) .into_iter() .filter(|ta| filter(&ta.1)) .collect(); - let result = transaction_accounts .into_iter() - .map(|ta| { Self::convert_to_account_data(ta.0, slot, ta.1) }) + .map(|ta| Self::convert_to_account_data(ta.0, slot, ta.1)) .collect_vec(); if result.is_empty() { @@ -151,7 +167,6 @@ impl AccountStorageInterface for AccountsDb { } } - async fn process_slot_data(&self, slot: Slot, commitment: Commitment) -> Vec { if commitment == Finalized { self.accounts.add_root(slot); @@ -190,10 +205,17 @@ impl AccountStorageInterface for AccountsDb { } } - assert!(self.processed_slot.load(Ordering::Relaxed) >= self.confirmed_slot.load(Ordering::Relaxed)); - assert!(self.confirmed_slot.load(Ordering::Relaxed) >= self.finalised_slot.load(Ordering::Relaxed)); + assert!( + self.processed_slot.load(Ordering::Relaxed) + >= self.confirmed_slot.load(Ordering::Relaxed) + ); + assert!( + self.confirmed_slot.load(Ordering::Relaxed) + >= self.finalised_slot.load(Ordering::Relaxed) + ); - self.accounts.load_all(&Ancestors::from(vec![slot]), slot, false) + self.accounts + .load_all(&Ancestors::from(vec![slot]), slot, false) .unwrap() .into_iter() .filter(|(_, _, updated_slot)| *updated_slot == slot) @@ -207,7 +229,7 @@ impl AccountsDb { match commitment { Processed => self.processed_slot.load(Ordering::Relaxed), Confirmed => self.confirmed_slot.load(Ordering::Relaxed), - Finalized => self.finalised_slot.load(Ordering::Relaxed) + Finalized => self.finalised_slot.load(Ordering::Relaxed), } } @@ -216,7 +238,11 @@ impl AccountsDb { Ancestors::from(vec![slot]) } - fn convert_to_account_data(pk: Pubkey, slot: Slot, shared_data: AccountSharedData) -> AccountData { + fn convert_to_account_data( + pk: Pubkey, + slot: Slot, + shared_data: AccountSharedData, + ) -> AccountData { AccountData { pubkey: pk, account: Arc::new(Account { @@ -284,9 +310,12 @@ mod tests { ti.process_slot_data(4, Confirmed).await; ti.process_slot_data(3, Finalized).await; - ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)).await; - ti.initilize_or_update_account(create_account_data(4, ak, pk, 20)).await; - ti.initilize_or_update_account(create_account_data(3, ak, pk, 30)).await; + ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)) + .await; + ti.initilize_or_update_account(create_account_data(4, ak, pk, 20)) + .await; + ti.initilize_or_update_account(create_account_data(3, ak, pk, 30)) + .await; let processed = ti.get_account(ak, Processed).await.unwrap().unwrap(); assert_eq!(processed.updated_slot, 5); @@ -308,9 +337,10 @@ mod tests { let pk = Pubkey::from_str("HZGMUF6kdCUK6nuc3TdNR6X5HNdGtg5HmVQ8cV2pRiHE").unwrap(); let ak = Pubkey::from_str("6rRiMihF7UdJz25t5QvS7PgP9yzfubN7TBRv26ZBVAhE").unwrap(); - ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)).await; + ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)) + .await; -// Slot = Processed + // Slot = Processed ti.process_slot_data(5, Processed).await; let processed = ti.get_account(ak, Processed).await.unwrap().unwrap(); @@ -323,7 +353,7 @@ mod tests { let finalized = ti.get_account(ak, Finalized).await.unwrap(); assert_eq!(finalized, None); -// Slot = Confirmed + // Slot = Confirmed ti.process_slot_data(5, Confirmed).await; let processed = ti.get_account(ak, Processed).await.unwrap().unwrap(); @@ -337,7 +367,7 @@ mod tests { let finalized = ti.get_account(ak, Finalized).await.unwrap(); assert_eq!(finalized, None); -// Slot = Finalized + // Slot = Finalized ti.process_slot_data(5, Finalized).await; let processed = ti.get_account(ak, Processed).await.unwrap().unwrap(); @@ -377,19 +407,37 @@ mod tests { ti.process_slot_data(4, Confirmed).await; ti.process_slot_data(3, Finalized).await; - ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)).await; - ti.initilize_or_update_account(create_account_data(4, ak, pk, 20)).await; - ti.initilize_or_update_account(create_account_data(3, ak, pk, 30)).await; - - let processed = ti.get_program_accounts(pk, None, Processed).await.unwrap().pop().unwrap(); + ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)) + .await; + ti.initilize_or_update_account(create_account_data(4, ak, pk, 20)) + .await; + ti.initilize_or_update_account(create_account_data(3, ak, pk, 30)) + .await; + + let processed = ti + .get_program_accounts(pk, None, Processed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(processed.updated_slot, 5); assert_eq!(processed.account.lamports, 10); - let confirmed = ti.get_program_accounts(pk, None, Confirmed).await.unwrap().pop().unwrap(); + let confirmed = ti + .get_program_accounts(pk, None, Confirmed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(confirmed.updated_slot, 4); assert_eq!(confirmed.account.lamports, 20); - let finalized = ti.get_program_accounts(pk, None, Finalized).await.unwrap().pop().unwrap(); + let finalized = ti + .get_program_accounts(pk, None, Finalized) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(finalized.updated_slot, 3); assert_eq!(finalized.account.lamports, 30); } @@ -401,12 +449,18 @@ mod tests { let pk = Pubkey::from_str("HZGMUF6kdCUK6nuc3TdNR6X5HNdGtg5HmVQ8cV2pRiHE").unwrap(); let ak = Pubkey::from_str("6rRiMihF7UdJz25t5QvS7PgP9yzfubN7TBRv26ZBVAhE").unwrap(); - ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)).await; + ti.initilize_or_update_account(create_account_data(5, ak, pk, 10)) + .await; -// Slot = Processed + // Slot = Processed ti.process_slot_data(5, Processed).await; - let processed = ti.get_program_accounts(pk, None, Processed).await.unwrap().pop().unwrap(); + let processed = ti + .get_program_accounts(pk, None, Processed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(processed.updated_slot, 5); assert_eq!(processed.account.lamports, 10); @@ -416,32 +470,57 @@ mod tests { let finalized = ti.get_program_accounts(pk, None, Finalized).await; assert_eq!(finalized, None); -// Slot = Confirmed + // Slot = Confirmed ti.process_slot_data(5, Confirmed).await; - let processed = ti.get_program_accounts(pk, None, Processed).await.unwrap().pop().unwrap(); + let processed = ti + .get_program_accounts(pk, None, Processed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(processed.updated_slot, 5); assert_eq!(processed.account.lamports, 10); - let confirmed = ti.get_program_accounts(pk, None, Confirmed).await.unwrap().pop().unwrap(); + let confirmed = ti + .get_program_accounts(pk, None, Confirmed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(confirmed.updated_slot, 5); assert_eq!(confirmed.account.lamports, 10); let finalized = ti.get_program_accounts(pk, None, Finalized).await; assert_eq!(finalized, None); -// Slot = Finalized + // Slot = Finalized ti.process_slot_data(5, Finalized).await; - let processed = ti.get_program_accounts(pk, None, Processed).await.unwrap().pop().unwrap(); + let processed = ti + .get_program_accounts(pk, None, Processed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(processed.updated_slot, 5); assert_eq!(processed.account.lamports, 10); - let confirmed = ti.get_program_accounts(pk, None, Confirmed).await.unwrap().pop().unwrap(); + let confirmed = ti + .get_program_accounts(pk, None, Confirmed) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(confirmed.updated_slot, 5); assert_eq!(confirmed.account.lamports, 10); - let finalized = ti.get_program_accounts(pk, None, Finalized).await.unwrap().pop().unwrap(); + let finalized = ti + .get_program_accounts(pk, None, Finalized) + .await + .unwrap() + .pop() + .unwrap(); assert_eq!(finalized.updated_slot, 5); assert_eq!(finalized.account.lamports, 10); } @@ -455,10 +534,25 @@ mod tests { let ak2 = Pubkey::from_str("5VsPdDtqyFw6BmxrTZXKfnTLZy3TgzVA2MA1vZKAfddw").unwrap(); ti.process_slot_data(5, Processed).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak1, pk, Vec::from("abc"))).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak2, pk, Vec::from("abcdef"))).await; - - let mut result = ti.get_program_accounts(pk, Some(vec![RpcFilterType::DataSize(3)]), Processed).await.unwrap(); + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak1, + pk, + Vec::from("abc"), + )) + .await; + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak2, + pk, + Vec::from("abcdef"), + )) + .await; + + let mut result = ti + .get_program_accounts(pk, Some(vec![RpcFilterType::DataSize(3)]), Processed) + .await + .unwrap(); assert_eq!(result.len(), 1); let result = result.pop().unwrap(); assert_eq!(result.pubkey, ak1); @@ -475,10 +569,32 @@ mod tests { let ak2 = Pubkey::from_str("5VsPdDtqyFw6BmxrTZXKfnTLZy3TgzVA2MA1vZKAfddw").unwrap(); ti.process_slot_data(5, Processed).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak1, pk, Vec::from("abc"))).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak2, pk, Vec::from("abcdef"))).await; - - let mut result = ti.get_program_accounts(pk, Some(vec![RpcFilterType::Memcmp(Memcmp::new_raw_bytes(1, Vec::from("bcdef")))]), Processed).await.unwrap(); + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak1, + pk, + Vec::from("abc"), + )) + .await; + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak2, + pk, + Vec::from("abcdef"), + )) + .await; + + let mut result = ti + .get_program_accounts( + pk, + Some(vec![RpcFilterType::Memcmp(Memcmp::new_raw_bytes( + 1, + Vec::from("bcdef"), + ))]), + Processed, + ) + .await + .unwrap(); assert_eq!(result.len(), 1); let result = result.pop().unwrap(); assert_eq!(result.pubkey, ak2); @@ -495,13 +611,32 @@ mod tests { let ak2 = Pubkey::from_str("5VsPdDtqyFw6BmxrTZXKfnTLZy3TgzVA2MA1vZKAfddw").unwrap(); ti.process_slot_data(5, Processed).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak1, pk, Vec::from("abc"))).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak2, pk, Vec::from("abcdef"))).await; - - let mut result = ti.get_program_accounts(pk, Some(vec![ - RpcFilterType::DataSize(6), - RpcFilterType::Memcmp(Memcmp::new_raw_bytes(1, Vec::from("bcdef"))), - ]), Processed).await.unwrap(); + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak1, + pk, + Vec::from("abc"), + )) + .await; + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak2, + pk, + Vec::from("abcdef"), + )) + .await; + + let mut result = ti + .get_program_accounts( + pk, + Some(vec![ + RpcFilterType::DataSize(6), + RpcFilterType::Memcmp(Memcmp::new_raw_bytes(1, Vec::from("bcdef"))), + ]), + Processed, + ) + .await + .unwrap(); assert_eq!(result.len(), 1); let result = result.pop().unwrap(); @@ -510,7 +645,6 @@ mod tests { assert_eq!(result.account.data, Vec::from("abcdef")); } - #[tokio::test] async fn contradicting_filter() { let ti = AccountsDb::new_for_testing(); @@ -520,13 +654,31 @@ mod tests { let ak2 = Pubkey::from_str("5VsPdDtqyFw6BmxrTZXKfnTLZy3TgzVA2MA1vZKAfddw").unwrap(); ti.process_slot_data(5, Processed).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak1, pk, Vec::from("abc"))).await; - ti.initilize_or_update_account(create_account_data_with_data(5, ak2, pk, Vec::from("abcdef"))).await; - - let result = ti.get_program_accounts(pk, Some(vec![ - RpcFilterType::Memcmp(Memcmp::new_raw_bytes(0, Vec::from("a"))), - RpcFilterType::Memcmp(Memcmp::new_raw_bytes(0, Vec::from("b"))), - ]), Processed).await; + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak1, + pk, + Vec::from("abc"), + )) + .await; + ti.initilize_or_update_account(create_account_data_with_data( + 5, + ak2, + pk, + Vec::from("abcdef"), + )) + .await; + + let result = ti + .get_program_accounts( + pk, + Some(vec![ + RpcFilterType::Memcmp(Memcmp::new_raw_bytes(0, Vec::from("a"))), + RpcFilterType::Memcmp(Memcmp::new_raw_bytes(0, Vec::from("b"))), + ]), + Processed, + ) + .await; assert_eq!(result, None); } } @@ -611,7 +763,8 @@ mod tests { let result = ti.process_slot_data(3, Processed).await; assert_eq!(result.len(), 0); - ti.initilize_or_update_account(create_account_data(3, ak, pk, 10)).await; + ti.initilize_or_update_account(create_account_data(3, ak, pk, 10)) + .await; let result = ti.process_slot_data(3, Confirmed).await; assert_eq!(result.len(), 0); @@ -627,7 +780,8 @@ mod tests { let pk = Pubkey::from_str("HZGMUF6kdCUK6nuc3TdNR6X5HNdGtg5HmVQ8cV2pRiHE").unwrap(); let ak = Pubkey::from_str("6rRiMihF7UdJz25t5QvS7PgP9yzfubN7TBRv26ZBVAhE").unwrap(); - ti.initilize_or_update_account(create_account_data(3, ak, pk, 10)).await; + ti.initilize_or_update_account(create_account_data(3, ak, pk, 10)) + .await; ti.process_slot_data(3, Finalized).await; let result = ti.process_slot_data(4, Finalized).await; @@ -655,7 +809,6 @@ pub fn create_account_data( } } - pub fn create_account_data_with_data( updated_slot: Slot, ak: Pubkey, @@ -673,4 +826,4 @@ pub fn create_account_data_with_data( }), updated_slot, } -} \ No newline at end of file +} diff --git a/accounts/src/store/mod.rs b/accounts/src/store/mod.rs index 8c921f69..67556a1b 100644 --- a/accounts/src/store/mod.rs +++ b/accounts/src/store/mod.rs @@ -1,3 +1,3 @@ pub use accounts_db::AccountsDb; -mod accounts_db; \ No newline at end of file +mod accounts_db; diff --git a/address-lookup-tables/Cargo.toml b/address-lookup-tables/Cargo.toml index 1d34b6f2..0d57c2bf 100644 --- a/address-lookup-tables/Cargo.toml +++ b/address-lookup-tables/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-address-lookup-tables" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Library to save and update address lookup tables in lite-rpc" rust-version = "1.73.0" diff --git a/address-lookup-tables/src/address_lookup_table_store.rs b/address-lookup-tables/src/address_lookup_table_store.rs index e0e28d33..4f359a73 100644 --- a/address-lookup-tables/src/address_lookup_table_store.rs +++ b/address-lookup-tables/src/address_lookup_table_store.rs @@ -170,17 +170,11 @@ impl AddressLookupTableStore { } pub async fn get_accounts(&self, alt: &Pubkey, accounts: &[u8]) -> Vec { - match self - .get_accounts_in_address_lookup_table(alt, accounts) + self.get_accounts_in_address_lookup_table(alt, accounts) .await - { - Some(x) => x, - None => { - // forget alt for now, start loading it for next blocks - // loading should be on its way - vec![] - } - } + // fallback to empty vec; forget alt for now, start loading it for next blocks + // loading should be on its way + .unwrap_or_default() } pub fn serialize_binary(&self) -> Vec { diff --git a/bench/Cargo.toml b/bench/Cargo.toml index ebd586a7..3a501f3d 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bench" -version = "0.2.4" +version = "0.3.0" edition = "2021" [[bin]] diff --git a/benchrunner-service/Cargo.toml b/benchrunner-service/Cargo.toml index 6949df82..0c5c6668 100644 --- a/benchrunner-service/Cargo.toml +++ b/benchrunner-service/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "solana-lite-rpc-benchrunner-service" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Service for running recurring benchmarks" rust-version = "1.73.0" diff --git a/blockstore/Cargo.toml b/blockstore/Cargo.toml index 2e5c6846..a6cf8f33 100644 --- a/blockstore/Cargo.toml +++ b/blockstore/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-blockstore" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "History implementations used by solana lite rpc" rust-version = "1.75.0" diff --git a/blockstore/examples/bench_postgres_simple_select.rs b/blockstore/examples/bench_postgres_simple_select.rs index 268c0696..ee070aad 100644 --- a/blockstore/examples/bench_postgres_simple_select.rs +++ b/blockstore/examples/bench_postgres_simple_select.rs @@ -27,7 +27,7 @@ pub async fn main() -> anyhow::Result<()> { } async fn parallel_queries(pg_session_config: PostgresSessionConfig) { - let many_sessions = vec![ + let many_sessions = [ PostgresSession::new(pg_session_config.clone()) .await .unwrap(), diff --git a/cluster-endpoints/Cargo.toml b/cluster-endpoints/Cargo.toml index 2c0619e3..a7a8b914 100644 --- a/cluster-endpoints/Cargo.toml +++ b/cluster-endpoints/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-cluster-endpoints" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Core classes and methods used by solana lite rpc" rust-version = "1.75.0" diff --git a/cluster-endpoints/src/grpc/grpc_accounts_streaming.rs b/cluster-endpoints/src/grpc/grpc_accounts_streaming.rs index 4f52721a..dc4a7f5b 100644 --- a/cluster-endpoints/src/grpc/grpc_accounts_streaming.rs +++ b/cluster-endpoints/src/grpc/grpc_accounts_streaming.rs @@ -7,8 +7,10 @@ use std::{ time::Duration, }; +use geyser_grpc_connector::yellowstone_grpc_util::{ + connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig, +}; use geyser_grpc_connector::{GeyserGrpcClient, GrpcSourceConfig}; -use geyser_grpc_connector::yellowstone_grpc_util::{connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig}; use itertools::Itertools; use solana_lite_rpc_core::{ commitment_utils::Commitment, diff --git a/cluster-endpoints/src/grpc_multiplex.rs b/cluster-endpoints/src/grpc_multiplex.rs index e3197ebe..a3f8d73c 100644 --- a/cluster-endpoints/src/grpc_multiplex.rs +++ b/cluster-endpoints/src/grpc_multiplex.rs @@ -332,7 +332,8 @@ pub fn create_grpc_multiplex_blocks_subscription( let mut startup_completed = false; const MAX_ALLOWED_CLEANUP_WITHOUT_RECV: u8 = 12; // 12*5 = 60s without recving data 'recv_loop: loop { - debug!("channel capacities:\nprocessed_block_sender={}, \ + debug!( + "channel capacities:\nprocessed_block_sender={}, \ \nblock_info_sender_processed={}, \ \nblock_info_sender_confirmed={}, \ \nblock_info_sender_finalized={}", diff --git a/core/Cargo.toml b/core/Cargo.toml index dd62a55f..92aa5ef1 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-core" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Core classes and methods used by solana lite rpc" rust-version = "1.75.0" diff --git a/lite-rpc/Cargo.toml b/lite-rpc/Cargo.toml index 0ad19bb2..5a0b391e 100644 --- a/lite-rpc/Cargo.toml +++ b/lite-rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lite-rpc" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "A lite version of solana rpc to send and confirm transactions" rust-version = "1.73.0" diff --git a/lite-rpc/src/cli.rs b/lite-rpc/src/cli.rs index aabec40a..0843f2d5 100644 --- a/lite-rpc/src/cli.rs +++ b/lite-rpc/src/cli.rs @@ -1,8 +1,8 @@ -use std::{env, time::Duration}; use std::borrow::Cow; use std::fmt::{Debug, Display, Formatter}; use std::net::SocketAddr; use std::str::FromStr; +use std::{env, time::Duration}; use anyhow::Context; use clap::Parser; @@ -11,11 +11,11 @@ use solana_rpc_client_api::client_error::reqwest::Url; use solana_lite_rpc_services::quic_connection_utils::QuicConnectionParameters; +use crate::postgres_logger::{self, PostgresSessionConfig}; use crate::{ DEFAULT_FANOUT_SIZE, DEFAULT_GRPC_ADDR, DEFAULT_RETRY_TIMEOUT, DEFAULT_RPC_ADDR, DEFAULT_WS_ADDR, MAX_RETRIES, }; -use crate::postgres_logger::{self, PostgresSessionConfig}; #[derive(Parser, Debug, Clone)] #[command(author, version, about, long_about = None)] diff --git a/lite-rpc/src/main.rs b/lite-rpc/src/main.rs index 2c908245..7e88e99f 100644 --- a/lite-rpc/src/main.rs +++ b/lite-rpc/src/main.rs @@ -13,17 +13,17 @@ use solana_sdk::signer::Signer; use tokio::io::AsyncReadExt; use tokio::sync::mpsc; use tokio::sync::RwLock; -use tracing_subscriber::EnvFilter; use tracing_subscriber::fmt::format::FmtSpan; +use tracing_subscriber::EnvFilter; use lite_rpc::bridge::LiteBridge; use lite_rpc::bridge_pubsub::LitePubSubBridge; use lite_rpc::cli::Config; -use lite_rpc::DEFAULT_MAX_NUMBER_OF_TXS_IN_QUEUE; use lite_rpc::postgres_logger; use lite_rpc::postgres_logger::PostgresLogger; use lite_rpc::service_spawner::ServiceSpawner; use lite_rpc::start_server::start_servers; +use lite_rpc::DEFAULT_MAX_NUMBER_OF_TXS_IN_QUEUE; use solana_lite_rpc_accounts::account_service::AccountService; use solana_lite_rpc_accounts::account_store_interface::AccountStorageInterface; use solana_lite_rpc_accounts::inmemory_account_store::InmemoryAccountStore; @@ -42,7 +42,6 @@ use solana_lite_rpc_cluster_endpoints::grpc_subscription::create_grpc_subscripti use solana_lite_rpc_cluster_endpoints::json_rpc_leaders_getter::JsonRpcLeaderGetter; use solana_lite_rpc_cluster_endpoints::json_rpc_subscription::create_json_rpc_polling_subscription; use solana_lite_rpc_cluster_endpoints::rpc_polling::poll_blocks::NUM_PARALLEL_TASKS_DEFAULT; -use solana_lite_rpc_core::AnyhowJoinHandle; use solana_lite_rpc_core::keypair_loader::load_identity_keypair; use solana_lite_rpc_core::stores::{ block_information_store::{BlockInformation, BlockInformationStore}, @@ -51,14 +50,15 @@ use solana_lite_rpc_core::stores::{ subscription_store::SubscriptionStore, tx_store::TxStore, }; +use solana_lite_rpc_core::structures::account_filter::AccountFilters; +use solana_lite_rpc_core::structures::leaderschedule::CalculatedSchedule; use solana_lite_rpc_core::structures::{ epoch::EpochCache, identity_stakes::IdentityStakes, notifications::NotificationSender, }; -use solana_lite_rpc_core::structures::account_filter::AccountFilters; -use solana_lite_rpc_core::structures::leaderschedule::CalculatedSchedule; use solana_lite_rpc_core::traits::address_lookup_table_interface::AddressLookupTableInterface; use solana_lite_rpc_core::types::BlockStream; use solana_lite_rpc_core::utils::wait_till_block_of_commitment_is_recieved; +use solana_lite_rpc_core::AnyhowJoinHandle; use solana_lite_rpc_prioritization_fees::account_prio_service::AccountPrioService; use solana_lite_rpc_prioritization_fees::start_block_priofees_task; use solana_lite_rpc_services::data_caching_service::DataCachingService; @@ -196,7 +196,7 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc) -> anyhow: blockinfo_notifier.resubscribe(), CommitmentConfig::finalized(), ) - .await; + .await; info!("Got finalized block info: {:?}", finalized_block_info.slot); let (epoch_data, _current_epoch_info) = EpochCache::bootstrap_epoch(&rpc_client).await?; @@ -205,7 +205,8 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc) -> anyhow: BlockInformationStore::new(BlockInformation::from_block_info(&finalized_block_info)); let accounts_service = if let Some(account_stream) = processed_account_stream { - let accounts_storage: Arc = if use_accounts_db.unwrap_or(false) { + let accounts_storage: Arc = if use_accounts_db.unwrap_or(false) + { Arc::new(AccountsDb::new()) } else { Arc::new(InmemoryAccountStore::new()) @@ -227,10 +228,7 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc) -> anyhow: accounts_storage }; - let account_service = AccountService::new( - account_storage, - account_notification_sender, - ); + let account_service = AccountService::new(account_storage, account_notification_sender); account_service.process_account_stream( account_stream.resubscribe(), @@ -331,7 +329,7 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc) -> anyhow: leader_schedule, data_cache.clone(), ) - .await?; + .await?; let tx_sender = TxSender::new(data_cache.clone(), tpu_service.clone()); let tx_replayer = TransactionReplayer::new(tpu_service.clone(), data_cache.clone(), retry_after); diff --git a/prioritization_fees/Cargo.toml b/prioritization_fees/Cargo.toml index b65f6334..84859b9d 100644 --- a/prioritization_fees/Cargo.toml +++ b/prioritization_fees/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-prioritization-fees" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Expose priority fees stats per block via RPC and WebSocket" diff --git a/quic-forward-proxy-integration-test/tests/quic_proxy_tpu_integrationtest.rs b/quic-forward-proxy-integration-test/tests/quic_proxy_tpu_integrationtest.rs index a5a36c15..a97c6fb6 100644 --- a/quic-forward-proxy-integration-test/tests/quic_proxy_tpu_integrationtest.rs +++ b/quic-forward-proxy-integration-test/tests/quic_proxy_tpu_integrationtest.rs @@ -20,9 +20,10 @@ use solana_streamer::packet::PacketBatch; use solana_streamer::quic::StreamStats; use solana_streamer::streamer::StakedNodes; use std::collections::{HashMap, HashSet}; -use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}; +use std::net::{SocketAddr, UdpSocket}; use itertools::Itertools; +use solana_streamer::tls_certificates::new_dummy_x509_certificate; use std::str::FromStr; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, RwLock}; @@ -422,13 +423,11 @@ async fn solana_quic_streamer_start() { // keypair to derive the server tls certificate let keypair = Keypair::new(); // gossip_host is used in the server certificate - let gossip_host = "127.0.0.1".parse().unwrap(); let SpawnNonBlockingServerResult { stats, thread, .. } = solana_streamer::nonblocking::quic::spawn_server( "test-quic-server", sock.try_clone().unwrap(), &keypair, - gossip_host, sender, exit.clone(), 1, @@ -436,6 +435,7 @@ async fn solana_quic_streamer_start() { 10, 10, 9999, // max_streams_per_ms + 10, Duration::from_millis(1000), Duration::from_millis(1000), ) @@ -466,11 +466,7 @@ async fn start_literpc_client_direct_mode( // (String, Vec) (signature, transaction) let (sender, _) = tokio::sync::broadcast::channel(MAXIMUM_TRANSACTIONS_IN_QUEUE); let broadcast_sender = Arc::new(sender); - let (certificate, key) = new_self_signed_tls_certificate( - literpc_validator_identity.as_ref(), - IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), - ) - .expect("Failed to initialize QUIC connection certificates"); + let (certificate, key) = new_dummy_x509_certificate(literpc_validator_identity.as_ref()); let tpu_connection_manager = TpuConnectionManager::new(certificate, key, fanout_slots as usize).await; @@ -567,11 +563,7 @@ async fn start_literpc_client_proxy_mode( // (String, Vec) (signature, transaction) let (sender, _) = tokio::sync::broadcast::channel(MAXIMUM_TRANSACTIONS_IN_QUEUE); let broadcast_sender = Arc::new(sender); - let (certificate, key) = new_self_signed_tls_certificate( - validator_identity.as_ref(), - IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), - ) - .expect("Failed to initialize QUIC connection certificates"); + let (certificate, key) = new_dummy_x509_certificate(validator_identity.as_ref()); let quic_proxy_connection_manager = QuicProxyConnectionManager::new(certificate, key, forward_proxy_address).await; @@ -706,14 +698,12 @@ impl SolanaQuicStreamer { let exit = Arc::new(AtomicBool::new(false)); // keypair to derive the server tls certificate let keypair = Keypair::new(); - // gossip_host is used in the server certificate - let gossip_host = "127.0.0.1".parse().unwrap(); + let SpawnNonBlockingServerResult { stats, thread, .. } = solana_streamer::nonblocking::quic::spawn_server( "test-quic-server", udp_socket.try_clone().unwrap(), &keypair, - gossip_host, sender, exit.clone(), MAX_QUIC_CONNECTIONS_PER_PEER, @@ -721,6 +711,7 @@ impl SolanaQuicStreamer { 10, 10, 9999, // max_streams_per_ms + 10, Duration::from_millis(1000), Duration::from_millis(1000), ) diff --git a/quic-forward-proxy/src/outbound/tx_forward.rs b/quic-forward-proxy/src/outbound/tx_forward.rs index 23859470..1bc86881 100644 --- a/quic-forward-proxy/src/outbound/tx_forward.rs +++ b/quic-forward-proxy/src/outbound/tx_forward.rs @@ -14,12 +14,13 @@ use quinn::{ use solana_lite_rpc_core::network_utils::apply_gso_workaround; use solana_sdk::quic::QUIC_MAX_TIMEOUT; use solana_streamer::nonblocking::quic::ALPN_TPU_PROTOCOL_ID; + +use solana_streamer::tls_certificates::new_dummy_x509_certificate; use std::collections::HashMap; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::{Duration, Instant}; -use solana_streamer::tls_certificates::new_dummy_x509_certificate; use tokio::sync::mpsc::Receiver; use tokio::sync::RwLock; @@ -267,7 +268,9 @@ async fn new_endpoint_with_validator_identity(validator_identity: ValidatorIdent validator_identity ); // the counterpart of this function is get_remote_pubkey+get_pubkey_from_tls_certificate - let (certificate, key) = new_dummy_x509_certificate(&validator_identity.get_keypair_for_tls() ); + let (certificate, key) = + new_dummy_x509_certificate(validator_identity.get_keypair_for_tls().as_ref()); + create_tpu_client_endpoint(certificate, key) } diff --git a/quic-forward-proxy/tests/proxy_request_format.rs b/quic-forward-proxy/tests/proxy_request_format.rs index 6bc4628d..2b6665d5 100644 --- a/quic-forward-proxy/tests/proxy_request_format.rs +++ b/quic-forward-proxy/tests/proxy_request_format.rs @@ -1,17 +1,21 @@ -use solana_lite_rpc_quic_forward_proxy::proxy_request_format::TpuForwardingRequest; +use std::str::FromStr; + +use solana_sdk::address_lookup_table::program::id; +use solana_sdk::instruction::{AccountMeta, Instruction}; use solana_sdk::pubkey::Pubkey; -use solana_sdk::signature::{Keypair, Signer}; use solana_sdk::transaction::Transaction; -use std::str::FromStr; + +use solana_lite_rpc_quic_forward_proxy::proxy_request_format::TpuForwardingRequest; #[test] fn roundtrip() { - let payer = Keypair::from_base58_string( - "rKiJ7H5UUp3JR18kNyTF1XPuwPKHEM7gMLWHZPWP5djrW1vSjfwjhvJrevxF9MPmUmN9gJMLHZdLMgc9ao78eKr", - ); - let payer_pubkey = payer.pubkey(); + let payer_pubkey = Pubkey::from_str("Bm8rtweCQ19ksNebrLY92H7x4bCaeDJSSmEeWqkdCeop").unwrap(); - let memo_ix = spl_memo::build_memo("Hello world".as_bytes(), &[&payer_pubkey]); + let memo_ix = Instruction { + program_id: id(), + accounts: vec![AccountMeta::new_readonly(payer_pubkey, true)], + data: Vec::new(), + }; let tx = Transaction::new_with_payer(&[memo_ix], Some(&payer_pubkey)); diff --git a/services/Cargo.toml b/services/Cargo.toml index 47b09909..2f6e21b3 100644 --- a/services/Cargo.toml +++ b/services/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-services" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Services used by solana lite rpc" rust-version = "1.73.0" diff --git a/stake_vote/Cargo.toml b/stake_vote/Cargo.toml index 84811433..68407faa 100644 --- a/stake_vote/Cargo.toml +++ b/stake_vote/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-stakevote" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "History implementations used by solana lite rpc" rust-version = "1.75.0" diff --git a/util/Cargo.toml b/util/Cargo.toml index b00e5ea7..901f676a 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-util" -version = "0.2.4" +version = "0.3.0" edition = "2021" description = "Utility for non-domain functions" rust-version = "1.73.0"