From 4a58f52d8077e562363b077f18fdd4716e867a9c Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 6 Feb 2024 13:15:42 -0700 Subject: [PATCH 1/4] Make inactive_stake consistent --- rpc/src/rpc.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 5cc5b82344e0d1..815fe5085543d2 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -1786,16 +1786,10 @@ impl JsonRpcRequestProcessor { } else { StakeActivationState::Inactive }; - let inactive_stake = match stake_activation_state { - StakeActivationState::Activating => activating, - StakeActivationState::Active => 0, - StakeActivationState::Deactivating => stake_account - .lamports() - .saturating_sub(effective + rent_exempt_reserve), - StakeActivationState::Inactive => { - stake_account.lamports().saturating_sub(rent_exempt_reserve) - } - }; + let inactive_stake = stake_account + .lamports() + .saturating_sub(effective) + .saturating_sub(rent_exempt_reserve); Ok(RpcStakeActivation { state: stake_activation_state, active: effective, From c0563e42fc6c403f38e705cb05241fbf9107b986 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 7 Feb 2024 10:54:19 -0700 Subject: [PATCH 2/4] Add rpc_deprecated_v1_18 module --- rpc/src/rpc.rs | 13 +++++++++++++ rpc/src/rpc_service.rs | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 815fe5085543d2..acdd33fdffc29c 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4076,6 +4076,19 @@ fn rpc_perf_sample_from_perf_sample(slot: u64, sample: PerfSample) -> RpcPerfSam } } +pub mod rpc_deprecated_v1_18 { + use super::*; + #[rpc] + pub trait DeprecatedV1_18 { + type Metadata; + } + + pub struct DeprecatedV1_18Impl; + impl DeprecatedV1_18 for DeprecatedV1_18Impl { + type Metadata = JsonRpcRequestProcessor; + } +} + // RPC methods deprecated in v1.8 pub mod rpc_deprecated_v1_9 { #![allow(deprecated)] diff --git a/rpc/src/rpc_service.rs b/rpc/src/rpc_service.rs index 8597394f102325..d8791ab6c3bf6b 100644 --- a/rpc/src/rpc_service.rs +++ b/rpc/src/rpc_service.rs @@ -6,8 +6,9 @@ use { max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, rpc::{ - rpc_accounts::*, rpc_accounts_scan::*, rpc_bank::*, rpc_deprecated_v1_7::*, - rpc_deprecated_v1_9::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *, + rpc_accounts::*, rpc_accounts_scan::*, rpc_bank::*, rpc_deprecated_v1_18::*, + rpc_deprecated_v1_7::*, rpc_deprecated_v1_9::*, rpc_full::*, rpc_minimal::*, + rpc_obsolete_v1_7::*, *, }, rpc_cache::LargestAccountsCache, rpc_health::*, @@ -510,6 +511,7 @@ impl JsonRpcService { io.extend_with(rpc_full::FullImpl.to_delegate()); io.extend_with(rpc_deprecated_v1_7::DeprecatedV1_7Impl.to_delegate()); io.extend_with(rpc_deprecated_v1_9::DeprecatedV1_9Impl.to_delegate()); + io.extend_with(rpc_deprecated_v1_18::DeprecatedV1_18Impl.to_delegate()); } if obsolete_v1_7_api { io.extend_with(rpc_obsolete_v1_7::ObsoleteV1_7Impl.to_delegate()); From 18bd63c5a71d630e8e8dd83bf526c7f9f990514d Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 7 Feb 2024 10:55:17 -0700 Subject: [PATCH 3/4] Move get_stake_activation to deprecated list --- rpc/src/rpc.rs | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index acdd33fdffc29c..3abf0f8daff03a 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -2976,14 +2976,6 @@ pub mod rpc_accounts { block: Slot, ) -> Result>; - #[rpc(meta, name = "getStakeActivation")] - fn get_stake_activation( - &self, - meta: Self::Metadata, - pubkey_str: String, - config: Option, - ) -> Result; - // SPL Token-specific RPC endpoints // See https://github.com/solana-labs/solana-program-library/releases/tag/token-v2.0.0 for // program details @@ -3056,20 +3048,6 @@ pub mod rpc_accounts { Ok(meta.get_block_commitment(block)) } - fn get_stake_activation( - &self, - meta: Self::Metadata, - pubkey_str: String, - config: Option, - ) -> Result { - debug!( - "get_stake_activation rpc request received: {:?}", - pubkey_str - ); - let pubkey = verify_pubkey(&pubkey_str)?; - meta.get_stake_activation(&pubkey, config) - } - fn get_token_account_balance( &self, meta: Self::Metadata, @@ -4081,11 +4059,34 @@ pub mod rpc_deprecated_v1_18 { #[rpc] pub trait DeprecatedV1_18 { type Metadata; + + // DEPRECATED + #[rpc(meta, name = "getStakeActivation")] + fn get_stake_activation( + &self, + meta: Self::Metadata, + pubkey_str: String, + config: Option, + ) -> Result; } pub struct DeprecatedV1_18Impl; impl DeprecatedV1_18 for DeprecatedV1_18Impl { type Metadata = JsonRpcRequestProcessor; + + fn get_stake_activation( + &self, + meta: Self::Metadata, + pubkey_str: String, + config: Option, + ) -> Result { + debug!( + "get_stake_activation rpc request received: {:?}", + pubkey_str + ); + let pubkey = verify_pubkey(&pubkey_str)?; + meta.get_stake_activation(&pubkey, config) + } } } From 51039cb9ad8db3ac665ec21b3525bccb5ed0b727 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 7 Feb 2024 10:55:27 -0700 Subject: [PATCH 4/4] Fix typo --- rpc/src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 3abf0f8daff03a..78869d4ad9a9c1 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -4090,7 +4090,7 @@ pub mod rpc_deprecated_v1_18 { } } -// RPC methods deprecated in v1.8 +// RPC methods deprecated in v1.9 pub mod rpc_deprecated_v1_9 { #![allow(deprecated)] use super::*;