diff --git a/CHANGELOG.md b/CHANGELOG.md index f827a7cb..8244b3e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,16 @@ The minor version will be incremented upon a breaking change and the patch versi ### Features: +## [0.2.4] - 2024-01-29 + +commit : a44923c33414f16fa0f378fb99c22b46de00ef74 + +- prio : Adding prioritization fees library [PR](https://github.com/blockworks-foundation/lite-rpc/pull/274) +- cluster-endpoints : GRPC optimizations [PR](multiples) +- quic : Fixing MTU bug [PR](https://github.com/blockworks-foundation/lite-rpc/pull/293) +- cluster-endpoints : Adding GRPC multiplexing [PR](https://github.com/blockworks-foundation/lite-rpc/pull/255) +- stake-vote : Calculating stake votes and leader schedule in lite-rpc [PR](https://github.com/blockworks-foundation/lite-rpc/pull/244) + ## [0.2.3] - 2023-09-23 commit : 3cdab51676a4b1bfb5b41739a383e30cd8a1c73c @@ -67,4 +77,6 @@ Initial release. - services: Services library - lite-rpc: The lite rpc binary - cluster-endpoints : Cluster endpoints library. -- proxy : Lite-rpc QUIC proxy to act as a forwarder \ No newline at end of file +- proxy : Lite-rpc QUIC proxy to act as a forwarder +- prio : Prioritization fees libarary +- stake-vote : Stake vote library \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 801d2d4d..b8f4fb7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fde6067df7359f2d6335ec1a50c1f8f825801687d10da0cc4c6b08e3f6afd15" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -566,7 +566,7 @@ dependencies = [ [[package]] name = "bench" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "bincode", @@ -806,9 +806,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" dependencies = [ "bytemuck_derive", ] @@ -864,9 +864,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", @@ -874,7 +874,7 @@ dependencies = [ "num-traits 0.2.17", "serde", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -1801,7 +1801,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -1873,7 +1873,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.1.0", + "indexmap 2.2.1", "slab", "tokio", "tokio-util", @@ -2144,9 +2144,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2493,7 +2493,7 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lite-rpc" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-channel", @@ -2929,9 +2929,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ "bitflags 2.4.2", "cfg-if", @@ -2961,9 +2961,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", @@ -3067,7 +3067,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.1", ] [[package]] @@ -3090,18 +3090,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -3256,9 +3256,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -3576,13 +3576,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -3597,9 +3597,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -3900,9 +3900,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] @@ -3918,9 +3918,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -3929,9 +3929,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -4099,9 +4099,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -4182,7 +4182,7 @@ dependencies = [ "dashmap 4.0.2", "futures", "futures-util", - "indexmap 2.1.0", + "indexmap 2.2.1", "indicatif", "log", "quinn", @@ -4228,7 +4228,7 @@ dependencies = [ "bincode", "crossbeam-channel", "futures-util", - "indexmap 2.1.0", + "indexmap 2.2.1", "log", "rand 0.8.5", "rayon", @@ -4284,7 +4284,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-block-priofees" -version = "0.2.3" +version = "0.2.4" dependencies = [ "dashmap 5.5.3", "itertools 0.10.5", @@ -4302,7 +4302,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-cluster-endpoints" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-channel", @@ -4342,7 +4342,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-core" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-trait", @@ -4375,7 +4375,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-history" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-trait", @@ -4488,7 +4488,7 @@ dependencies = [ [[package]] name = "solana-lite-rpc-services" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-channel", @@ -4920,7 +4920,7 @@ dependencies = [ "crossbeam-channel", "futures-util", "histogram", - "indexmap 2.1.0", + "indexmap 2.2.1", "itertools 0.10.5", "libc", "log", @@ -4965,7 +4965,7 @@ dependencies = [ "async-trait", "bincode", "futures-util", - "indexmap 2.1.0", + "indexmap 2.2.1", "indicatif", "log", "rayon", @@ -5712,7 +5712,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "toml_datetime", "winnow", ] @@ -5723,7 +5723,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "toml_datetime", "winnow", ] @@ -6356,9 +6356,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 3d62cbca..948e4596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ members = [ ] [workspace.package] -version = "0.2.3" +version = "0.2.4" authors = ["gmgalactus ", "Aniket Prajapati "] repository = "https://github.com/blockworks-foundation/lite-rpc" license = "AGPL" @@ -65,12 +65,12 @@ quinn = "0.10.2" quinn-proto = "0.10.5" rustls = { version = "0.21.7", default-features = false, features = ["quic"] } -solana-lite-rpc-services = {path = "services", version="0.2.3"} -solana-lite-rpc-core = {path = "core", version="0.2.3"} -solana-lite-rpc-cluster-endpoints = {path = "cluster-endpoints", version="0.2.3"} -solana-lite-rpc-history = {path = "history", version="0.2.3"} -solana-lite-rpc-stakevote = {path = "stake_vote", version="0.2.3"} -solana-lite-rpc-block-priofees = {path = "block_priofees", version="0.2.3"} +solana-lite-rpc-services = {path = "services", version="0.2.4"} +solana-lite-rpc-core = {path = "core", version="0.2.4"} +solana-lite-rpc-cluster-endpoints = {path = "cluster-endpoints", version="0.2.4"} +solana-lite-rpc-history = {path = "history", version="0.2.4"} +solana-lite-rpc-stakevote = {path = "stake_vote", version="0.2.4"} +solana-lite-rpc-block-priofees = {path = "block_priofees", version="0.2.4"} async-trait = "0.1.68" yellowstone-grpc-client = { git = "https://github.com/rpcpool/yellowstone-grpc.git", tag = "v1.12.0+solana.1.17.15" } diff --git a/bench/Cargo.toml b/bench/Cargo.toml index 77fc461d..8443da63 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bench" -version = "0.2.3" +version = "0.2.4" edition = "2021" [dependencies] diff --git a/block_priofees/Cargo.toml b/block_priofees/Cargo.toml index d0bbb0c1..2427b68c 100644 --- a/block_priofees/Cargo.toml +++ b/block_priofees/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-block-priofees" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "Expose priority fees stats per block via RPC and WebSocket" diff --git a/block_priofees/src/stats_calculation.rs b/block_priofees/src/stats_calculation.rs index 95d96955..f409019e 100644 --- a/block_priofees/src/stats_calculation.rs +++ b/block_priofees/src/stats_calculation.rs @@ -26,7 +26,7 @@ pub fn calculate_supp_percentiles( .map(|p| { let prio_fee = { let index = prio_fees_in_block.len() * p / 100; - let cap_index = index.min(prio_fees_in_block.len() - 1); + let cap_index = index.min(prio_fees_in_block.len().saturating_sub(1)); prio_fees_in_block[cap_index].0 }; FeePoint { @@ -45,7 +45,7 @@ pub fn calculate_supp_percentiles( let dist_fee_by_cu = (0..=100) .step_by(p_step) .map(|p| { - if agg < (cu_sum * p) / 100 { + while agg < (cu_sum * p) / 100 { index += 1; agg += prio_fees_in_block[index].1; } @@ -157,6 +157,8 @@ mod tests { let supp_info = calculate_supp_percentiles(&prio_fees_in_block); assert_eq!(supp_info.by_tx[5], 43); assert_eq!(supp_info.by_tx_percentiles[5], 0.25); + assert_eq!(supp_info.by_cu_percentiles[20], 1.0); + assert_eq!(supp_info.by_cu[20], 72); } #[test] @@ -179,6 +181,10 @@ mod tests { assert_eq!(supp_info.by_tx_percentiles[4], 0.20); assert_eq!(supp_info.by_tx[5], 5); + assert_eq!(supp_info.by_cu_percentiles[19], 0.95); + assert_eq!(supp_info.by_cu_percentiles[20], 1.0); + assert_eq!(supp_info.by_cu[19], 10); + assert_eq!(supp_info.by_cu[20], 10); } #[test] diff --git a/cluster-endpoints/Cargo.toml b/cluster-endpoints/Cargo.toml index 7e0a9517..dfc47458 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.3" +version = "0.2.4" edition = "2021" description = "Core classes and methods used by solana lite rpc" rust-version = "1.70.0" diff --git a/cluster-endpoints/src/grpc_leaders_getter.rs b/cluster-endpoints/src/grpc_leaders_getter.rs index da317985..e8e981f1 100644 --- a/cluster-endpoints/src/grpc_leaders_getter.rs +++ b/cluster-endpoints/src/grpc_leaders_getter.rs @@ -66,7 +66,7 @@ impl LeaderFetcherInterface for GrpcLeaderGetter { ); } - let limit = to - from; + let limit = to.saturating_sub(from); let schedule = leader_schedule_data .get_slot_leaders(from, limit, self.epoch_data.get_epoch_schedule()) diff --git a/cluster-endpoints/src/grpc_multiplex.rs b/cluster-endpoints/src/grpc_multiplex.rs index d5892f69..897963df 100644 --- a/cluster-endpoints/src/grpc_multiplex.rs +++ b/cluster-endpoints/src/grpc_multiplex.rs @@ -229,9 +229,9 @@ pub fn create_grpc_multiplex_blocks_subscription( cleanup_without_confirmed_recv_blocks_meta += 1; let size_before = recent_processed_blocks.len(); recent_processed_blocks.retain(|_blockhash, block| { - last_finalized_slot == 0 || block.slot > last_finalized_slot - CLEANUP_SLOTS_BEHIND_FINALIZED + last_finalized_slot == 0 || block.slot > last_finalized_slot.saturating_sub(CLEANUP_SLOTS_BEHIND_FINALIZED) }); - let cnt_cleaned = size_before - recent_processed_blocks.len(); + let cnt_cleaned = size_before.saturating_sub(recent_processed_blocks.len()); if cnt_cleaned > 0 { debug!("cleaned {} processed blocks from cache", cnt_cleaned); } diff --git a/cluster-endpoints/src/json_rpc_leaders_getter.rs b/cluster-endpoints/src/json_rpc_leaders_getter.rs index 207311ed..5b00e7dc 100644 --- a/cluster-endpoints/src/json_rpc_leaders_getter.rs +++ b/cluster-endpoints/src/json_rpc_leaders_getter.rs @@ -47,12 +47,15 @@ impl JsonRpcLeaderGetter { if last_slot_needed >= first_slot_to_fetch { let leaders = self .rpc_client - .get_slot_leaders(first_slot_to_fetch, last_slot_needed - first_slot_to_fetch) + .get_slot_leaders( + first_slot_to_fetch, + last_slot_needed.saturating_sub(first_slot_to_fetch), + ) .await .context("failed to get slot leaders")?; for leader_slot in first_slot_to_fetch..last_slot_needed { - let current_leader = (leader_slot - first_slot_to_fetch) as usize; + let current_leader = (leader_slot.saturating_sub(first_slot_to_fetch)) as usize; let pubkey = leaders[current_leader]; leader_queue.push_back(LeaderData { leader_slot, @@ -71,7 +74,7 @@ impl LeaderFetcherInterface for JsonRpcLeaderGetter { from: solana_sdk::slot_history::Slot, to: solana_sdk::slot_history::Slot, ) -> anyhow::Result> { - if to <= from || to - from > self.leaders_to_cache_count { + if to <= from || to.saturating_sub(from) > self.leaders_to_cache_count { bail!("invalid arguments for get_slot_leaders"); } let schedule = self.leader_schedule.read().await; diff --git a/core/Cargo.toml b/core/Cargo.toml index 146c6276..40eff23e 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-core" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "Core classes and methods used by solana lite rpc" rust-version = "1.70.0" diff --git a/history/Cargo.toml b/history/Cargo.toml index e6cdf361..bbad4e80 100644 --- a/history/Cargo.toml +++ b/history/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-history" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "History implementations used by solana lite rpc" rust-version = "1.70.0" diff --git a/history/examples/bench_postgres_lowlevel.rs b/history/examples/bench_postgres_lowlevel.rs index eb622e47..2325ad25 100644 --- a/history/examples/bench_postgres_lowlevel.rs +++ b/history/examples/bench_postgres_lowlevel.rs @@ -117,7 +117,10 @@ pub async fn main() { let row_count_after = count_rows(session.client.clone()).await; info!("total: {}", row_count_after); - info!("inserted: {}", row_count_after - row_count_before); + info!( + "inserted: {}", + row_count_after.saturating_sub(row_count_before) + ); } async fn count_rows(client: Arc) -> i64 { diff --git a/history/examples/bench_postgres_read_load.rs b/history/examples/bench_postgres_read_load.rs index bd8031c4..08c8e1b1 100644 --- a/history/examples/bench_postgres_read_load.rs +++ b/history/examples/bench_postgres_read_load.rs @@ -57,10 +57,10 @@ pub async fn main() -> anyhow::Result<()> { // ATM we are 4000 slots behind ... // TODO reduce 4000 to 0 - let slot = 234332620; // literpc3 - local - // let slot = 231541684; + let slot: u64 = 234332620; // literpc3 - local + // let slot = 231541684; let delta = 50 + rand::random::() % 100; - let query_slot = slot - delta; + let query_slot = slot.saturating_sub(delta); info!("query slot (-{}): {}", delta, query_slot); let (epoch_cache, _) = &epoch_data; diff --git a/history/src/block_stores/multiple_strategy_block_store.rs b/history/src/block_stores/multiple_strategy_block_store.rs index 5d38aaca..5d2c6fb5 100644 --- a/history/src/block_stores/multiple_strategy_block_store.rs +++ b/history/src/block_stores/multiple_strategy_block_store.rs @@ -63,7 +63,7 @@ impl MultipleStrategyBlockStorage { if let Some(faithful_block_storage) = &self.faithful_block_storage { let faithful_storage_range = faithful_block_storage.get_slot_range(); trace!("Faithful storage range: {:?}", faithful_storage_range); - if lower - faithful_storage_range.end() <= 1 { + if lower.saturating_sub(*faithful_storage_range.end()) <= 1 { // move the lower bound to the left lower = lower.min(*faithful_storage_range.start()); } diff --git a/history/src/block_stores/postgres_block_store.rs b/history/src/block_stores/postgres_block_store.rs index e623ee8d..1b38254d 100644 --- a/history/src/block_stores/postgres_block_store.rs +++ b/history/src/block_stores/postgres_block_store.rs @@ -362,7 +362,7 @@ fn build_assign_permissions_statements(epoch: EpochRef) -> String { } fn div_ceil(a: usize, b: usize) -> usize { - (a + b - 1) / b + (a.saturating_add(b).saturating_sub(1)).saturating_div(b) } impl PostgresBlockStore { diff --git a/history/src/postgres/postgres_transaction.rs b/history/src/postgres/postgres_transaction.rs index 960f89be..cef2d271 100644 --- a/history/src/postgres/postgres_transaction.rs +++ b/history/src/postgres/postgres_transaction.rs @@ -125,7 +125,7 @@ impl PostgresTransaction { if inserted < tx_count { warn!("Some ({}) transactions already existed and where not updated of {} total in schema {schema}", - transactions.len() - inserted, transactions.len(), schema = schema); + transactions.len().saturating_sub(inserted), transactions.len(), schema = schema); } trace!( diff --git a/lite-rpc/Cargo.toml b/lite-rpc/Cargo.toml index f0039942..616006f7 100644 --- a/lite-rpc/Cargo.toml +++ b/lite-rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lite-rpc" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "A lite version of solana rpc to send and confirm transactions" rust-version = "1.70.0" diff --git a/services/Cargo.toml b/services/Cargo.toml index d13b0ddc..97b22b2d 100644 --- a/services/Cargo.toml +++ b/services/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-services" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "Services used by solana lite rpc" rust-version = "1.70.0" diff --git a/stake_vote/Cargo.toml b/stake_vote/Cargo.toml index 07b0813c..796613ca 100644 --- a/stake_vote/Cargo.toml +++ b/stake_vote/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-lite-rpc-stakevote" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "History implementations used by solana lite rpc" rust-version = "1.70.0" diff --git a/stake_vote/src/rpcrequest.rs b/stake_vote/src/rpcrequest.rs index e79b1b2a..41efd759 100644 --- a/stake_vote/src/rpcrequest.rs +++ b/stake_vote/src/rpcrequest.rs @@ -56,7 +56,7 @@ impl RpcRequestData { //avoid clone on the first request if let Some(mut pending_rpc_request) = self.pending_rpc_request.take() { if pending_rpc_request.len() > 1 { - for return_channel in pending_rpc_request.drain(0..pending_rpc_request.len() - 1) { + for return_channel in pending_rpc_request.drain(0..pending_rpc_request.len().saturating_sub(1)) { if return_channel.send(rpc_vote_accounts.clone()).is_err() { log::error!("Vote accounts RPC channel send closed."); } diff --git a/stake_vote/src/vote.rs b/stake_vote/src/vote.rs index a837cd61..9f2f6c25 100644 --- a/stake_vote/src/vote.rs +++ b/stake_vote/src/vote.rs @@ -119,7 +119,7 @@ impl VoteStore { if epoch_credits.len() > MAX_RPC_VOTE_ACCOUNT_INFO_EPOCH_CREDITS_HISTORY { epoch_credits .iter() - .skip(epoch_credits.len() - MAX_RPC_VOTE_ACCOUNT_INFO_EPOCH_CREDITS_HISTORY) + .skip(epoch_credits.len().saturating_sub(MAX_RPC_VOTE_ACCOUNT_INFO_EPOCH_CREDITS_HISTORY)) .cloned() .collect() } else { @@ -260,7 +260,7 @@ pub fn get_rpc_vote_accounts_info( }) .partition(|vote_account_info| { if current_slot >= delinquent_validator_slot_distance { - vote_account_info.last_vote > current_slot - delinquent_validator_slot_distance + vote_account_info.last_vote > current_slot.saturating_sub(delinquent_validator_slot_distance) } else { vote_account_info.last_vote > 0 }