Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpc: deprecate getStakeActivation and make inactive_stake consistent #69

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2991,14 +2985,6 @@ pub mod rpc_accounts {
block: Slot,
) -> 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
// See https://github.com/solana-labs/solana-program-library/releases/tag/token-v2.0.0 for
// program details
Expand Down Expand Up @@ -3071,20 +3057,6 @@ pub mod rpc_accounts {
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(
&self,
meta: Self::Metadata,
Expand Down Expand Up @@ -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 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot I wrote this code before v1.18 was branched. Rather than edit all these 18s, I'm going to propose backporting to v1.18 -- this is very low risk and small in scope, and backporting will allow us to remove this method altogether in v2.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also have been removed in #1886?

Copy link
Author

@CriesofCarrots CriesofCarrots Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveluscher I included that at first, but realized we didn't deprecate the client methods in this PR. Still considering/hoping to remove in v2.0, but need to figure the best way to handle.

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 {
#![allow(deprecated)]
use super::*;
Expand Down
6 changes: 4 additions & 2 deletions rpc/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*,
Expand Down Expand Up @@ -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());
Expand Down
Loading