Rpc: deprecate `getStakeActivation` and make inactive_stake consistent (#69)

* Make inactive_stake consistent

* Add rpc_deprecated_v1_18 module

* Move get_stake_activation to deprecated list

* Fix typo
This commit is contained in:
Tyera 2024-03-04 19:21:30 -07:00 committed by GitHub
parent 6263537bf0
commit 661de5bb76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 35 deletions

View File

@ -1786,16 +1786,10 @@ impl JsonRpcRequestProcessor {
} else { } else {
StakeActivationState::Inactive StakeActivationState::Inactive
}; };
let inactive_stake = match stake_activation_state { let inactive_stake = stake_account
StakeActivationState::Activating => activating, .lamports()
StakeActivationState::Active => 0, .saturating_sub(effective)
StakeActivationState::Deactivating => stake_account .saturating_sub(rent_exempt_reserve);
.lamports()
.saturating_sub(effective + rent_exempt_reserve),
StakeActivationState::Inactive => {
stake_account.lamports().saturating_sub(rent_exempt_reserve)
}
};
Ok(RpcStakeActivation { Ok(RpcStakeActivation {
state: stake_activation_state, state: stake_activation_state,
active: effective, active: effective,
@ -2991,14 +2985,6 @@ pub mod rpc_accounts {
block: Slot, block: Slot,
) -> Result<RpcBlockCommitment<BlockCommitmentArray>>; ) -> Result<RpcBlockCommitment<BlockCommitmentArray>>;
#[rpc(meta, name = "getStakeActivation")]
fn get_stake_activation(
&self,
meta: Self::Metadata,
pubkey_str: String,
config: Option<RpcEpochConfig>,
) -> Result<RpcStakeActivation>;
// SPL Token-specific RPC endpoints // SPL Token-specific RPC endpoints
// See https://github.com/solana-labs/solana-program-library/releases/tag/token-v2.0.0 for // See https://github.com/solana-labs/solana-program-library/releases/tag/token-v2.0.0 for
// program details // program details
@ -3071,20 +3057,6 @@ pub mod rpc_accounts {
Ok(meta.get_block_commitment(block)) Ok(meta.get_block_commitment(block))
} }
fn get_stake_activation(
&self,
meta: Self::Metadata,
pubkey_str: String,
config: Option<RpcEpochConfig>,
) -> Result<RpcStakeActivation> {
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( fn get_token_account_balance(
&self, &self,
meta: Self::Metadata, meta: Self::Metadata,
@ -4091,7 +4063,43 @@ fn rpc_perf_sample_from_perf_sample(slot: u64, sample: PerfSample) -> RpcPerfSam
} }
} }
// RPC methods deprecated in v1.8 pub mod rpc_deprecated_v1_18 {
use super::*;
#[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<RpcEpochConfig>,
) -> Result<RpcStakeActivation>;
}
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<RpcEpochConfig>,
) -> Result<RpcStakeActivation> {
debug!(
"get_stake_activation rpc request received: {:?}",
pubkey_str
);
let pubkey = verify_pubkey(&pubkey_str)?;
meta.get_stake_activation(&pubkey, config)
}
}
}
// RPC methods deprecated in v1.9
pub mod rpc_deprecated_v1_9 { pub mod rpc_deprecated_v1_9 {
#![allow(deprecated)] #![allow(deprecated)]
use super::*; use super::*;

View File

@ -6,8 +6,9 @@ use {
max_slots::MaxSlots, max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::{ rpc::{
rpc_accounts::*, rpc_accounts_scan::*, rpc_bank::*, rpc_deprecated_v1_7::*, rpc_accounts::*, rpc_accounts_scan::*, rpc_bank::*, rpc_deprecated_v1_18::*,
rpc_deprecated_v1_9::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *, rpc_deprecated_v1_7::*, rpc_deprecated_v1_9::*, rpc_full::*, rpc_minimal::*,
rpc_obsolete_v1_7::*, *,
}, },
rpc_cache::LargestAccountsCache, rpc_cache::LargestAccountsCache,
rpc_health::*, rpc_health::*,
@ -510,6 +511,7 @@ impl JsonRpcService {
io.extend_with(rpc_full::FullImpl.to_delegate()); 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_7::DeprecatedV1_7Impl.to_delegate());
io.extend_with(rpc_deprecated_v1_9::DeprecatedV1_9Impl.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 { if obsolete_v1_7_api {
io.extend_with(rpc_obsolete_v1_7::ObsoleteV1_7Impl.to_delegate()); io.extend_with(rpc_obsolete_v1_7::ObsoleteV1_7Impl.to_delegate());