Skip to content

Commit

Permalink
remove legacy cu
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Jun 12, 2024
1 parent ad4e97f commit e4a751f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 45 deletions.
18 changes: 1 addition & 17 deletions cluster-endpoints/src/grpc_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use solana_lite_rpc_core::{
use solana_sdk::program_utils::limited_deserialize;
use solana_sdk::vote::instruction::VoteInstruction;
use solana_sdk::{
borsh0_10::try_from_slice_unchecked,
commitment_config::CommitmentConfig,
compute_budget::{self, ComputeBudgetInstruction},
hash::Hash,
Expand Down Expand Up @@ -216,18 +215,15 @@ pub fn from_grpc_block_update(

fn map_compute_budget_instructions(message: &VersionedMessage) -> (Option<u32>, Option<u64>) {
let cu_requested_cell: OnceCell<u32> = OnceCell::new();
let legacy_cu_requested_cell: OnceCell<u32> = OnceCell::new();

let prioritization_fees_cell: OnceCell<u64> = OnceCell::new();
let legacy_prio_fees_cell: OnceCell<u64> = OnceCell::new();

for compute_budget_ins in message.instructions().iter().filter(|instruction| {
instruction
.program_id(message.static_account_keys())

Check warning on line 222 in cluster-endpoints/src/grpc_subscription.rs

View workflow job for this annotation

GitHub Actions / lite-rpc full build

Diff in /home/runner/work/lite-rpc/lite-rpc/cluster-endpoints/src/grpc_subscription.rs
.eq(&compute_budget::id())
}) {
if let Ok(budget_ins) =
try_from_slice_unchecked::<ComputeBudgetInstruction>(compute_budget_ins.data.as_slice())
solana_sdk::borsh1::try_from_slice_unchecked::<ComputeBudgetInstruction>(compute_budget_ins.data.as_slice())
{
match budget_ins {
// aka cu requested
Expand All @@ -242,16 +238,6 @@ fn map_compute_budget_instructions(message: &VersionedMessage) -> (Option<u32>,
.set(price)
.expect("prioritization_fees must be set only once");
}
// legacy
ComputeBudgetInstruction::RequestUnitsDeprecated {
units,
additional_fee,
} => {
let _ = legacy_cu_requested_cell.set(units);
if additional_fee > 0 {
let _ = legacy_prio_fees_cell.set(((units * 1000) / additional_fee) as u64);
};
}
_ => {
trace!("skip compute budget instruction");
}
Expand All @@ -261,11 +247,9 @@ fn map_compute_budget_instructions(message: &VersionedMessage) -> (Option<u32>,

let cu_requested = cu_requested_cell
.get()
.or(legacy_cu_requested_cell.get())
.cloned();
let prioritization_fees = prioritization_fees_cell
.get()
.or(legacy_prio_fees_cell.get())
.cloned();
(cu_requested, prioritization_fees)
}
Expand Down
24 changes: 1 addition & 23 deletions cluster-endpoints/src/rpc_polling/poll_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use solana_lite_rpc_core::{
AnyhowJoinHandle,
};
use solana_rpc_client_api::config::RpcBlockConfig;
use solana_sdk::borsh0_10::try_from_slice_unchecked;
use solana_sdk::borsh1::try_from_slice_unchecked;
use solana_sdk::compute_budget::ComputeBudgetInstruction;
use solana_sdk::program_utils::limited_deserialize;
use solana_sdk::reward_type::RewardType;
Expand Down Expand Up @@ -222,21 +222,6 @@ pub fn from_ui_block(
_ => None,
};

let legacy_compute_budget = tx.message.instructions().iter().find_map(|i| {
if i.program_id(tx.message.static_account_keys())
.eq(&compute_budget::id())
{
if let Ok(ComputeBudgetInstruction::RequestUnitsDeprecated {
units,
additional_fee,
}) = try_from_slice_unchecked(i.data.as_slice())
{
return Some((units, additional_fee));
}
}
None
});

let mut cu_requested = tx.message.instructions().iter().find_map(|i| {

Check warning on line 225 in cluster-endpoints/src/rpc_polling/poll_blocks.rs

View workflow job for this annotation

GitHub Actions / Test lite-rpc against running Validator

variable does not need to be mutable

Check warning on line 225 in cluster-endpoints/src/rpc_polling/poll_blocks.rs

View workflow job for this annotation

GitHub Actions / Test lite-rpc against running Validator

variable does not need to be mutable
if i.program_id(tx.message.static_account_keys())
.eq(&compute_budget::id())
Expand Down Expand Up @@ -264,13 +249,6 @@ pub fn from_ui_block(
None
});

if let Some((units, additional_fee)) = legacy_compute_budget {
cu_requested = Some(units);
if additional_fee > 0 {
prioritization_fees = Some(calc_prioritization_fees(units, additional_fee))
}
};

let blockhash = tx.message.recent_blockhash();

let is_vote_transaction = tx.message.instructions().iter().any(|i| {
Expand Down
2 changes: 1 addition & 1 deletion core/src/structures/identity_stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl IdentityStakes {
if let Some(stakes) = map_of_stakes.get(&self.identity.to_string()) {
let only_stakes = map_of_stakes.iter().map(|x| *x.1).collect_vec();
let identity_stakes = IdentityStakesData {
peer_type: ConnectionPeerType::Staked,
peer_type: ConnectionPeerType::Staked(*stakes), // Staked -> Staked(*stakes) .. not sure if that is correct
stakes: *stakes,
min_stakes: only_stakes.iter().min().map_or(0, |x| *x),
max_stakes: only_stakes.iter().max().map_or(0, |x| *x),
Expand Down
1 change: 0 additions & 1 deletion services/src/tpu_utils/tpu_connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ impl ActiveConnection {

let max_uni_stream_connections = compute_max_allowed_uni_streams(
identity_stakes.peer_type,
identity_stakes.stakes,
identity_stakes.total_stakes,
);
let connection_pool = QuicConnectionPool::new(
Expand Down
4 changes: 1 addition & 3 deletions services/src/transaction_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use solana_lite_rpc_core::{
AnyhowJoinHandle,
};
use solana_sdk::{
borsh0_10::try_from_slice_unchecked,
compute_budget::{self, ComputeBudgetInstruction},
transaction::{Transaction, VersionedTransaction},
};
Expand Down Expand Up @@ -165,8 +164,7 @@ impl TransactionService {
.program_id(tx.message.static_account_keys())

Check warning on line 164 in services/src/transaction_service.rs

View workflow job for this annotation

GitHub Actions / lite-rpc full build

Diff in /home/runner/work/lite-rpc/lite-rpc/services/src/transaction_service.rs
.eq(&compute_budget::id())
{
let ix_which =
try_from_slice_unchecked::<ComputeBudgetInstruction>(ix.data.as_slice());
let ix_which = solana_sdk::borsh1::try_from_slice_unchecked::<ComputeBudgetInstruction>(ix.data.as_slice());
if let Ok(ComputeBudgetInstruction::SetComputeUnitPrice(fees)) = ix_which {
prioritization_fee = fees;
}
Expand Down

0 comments on commit e4a751f

Please sign in to comment.