From e98cfbb570f2272299cb0af5cd283b8fc2833ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Mon, 18 Oct 2021 09:55:41 +0200 Subject: [PATCH] Removes deprecated BpfComputeBudget. (#20728) --- runtime/src/bank.rs | 9 --- runtime/src/message_processor.rs | 7 -- sdk/src/process_instruction.rs | 108 ------------------------------- 3 files changed, 124 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e5b8b885ac..478ef4d78a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -5086,15 +5086,6 @@ impl Bank { self.compute_budget = compute_budget; } - #[allow(deprecated)] - #[deprecated(since = "1.8.0", note = "please use `set_compute_budget` instead")] - pub fn set_bpf_compute_budget( - &mut self, - bpf_compute_budget: Option, - ) { - self.compute_budget = bpf_compute_budget.map(|budget| budget.into()); - } - pub fn hard_forks(&self) -> Arc> { self.hard_forks.clone() } diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index e5f28f51a0..e842fe09af 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -57,8 +57,6 @@ pub struct ThisInvokeContext<'a> { programs: &'a [(Pubkey, ProcessInstructionWithContext)], logger: Rc>, compute_budget: ComputeBudget, - #[allow(deprecated)] - bpf_compute_budget: solana_sdk::process_instruction::BpfComputeBudget, compute_meter: Rc>, executors: Rc>, instruction_recorders: Option<&'a [InstructionRecorder]>, @@ -98,7 +96,6 @@ impl<'a> ThisInvokeContext<'a> { programs, logger: Rc::new(RefCell::new(ThisLogger { log_collector })), compute_budget, - bpf_compute_budget: compute_budget.into(), compute_meter, executors, instruction_recorders, @@ -357,10 +354,6 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> { fn get_logger(&self) -> Rc> { self.logger.clone() } - #[allow(deprecated)] - fn get_bpf_compute_budget(&self) -> &solana_sdk::process_instruction::BpfComputeBudget { - &self.bpf_compute_budget - } fn get_compute_meter(&self) -> Rc> { self.compute_meter.clone() } diff --git a/sdk/src/process_instruction.rs b/sdk/src/process_instruction.rs index 09213ea570..e45da37d47 100644 --- a/sdk/src/process_instruction.rs +++ b/sdk/src/process_instruction.rs @@ -98,10 +98,6 @@ pub trait InvokeContext { fn get_programs(&self) -> &[(Pubkey, ProcessInstructionWithContext)]; /// Get this invocation's logger fn get_logger(&self) -> Rc>; - /// Get this invocation's compute budget - #[allow(deprecated)] - #[deprecated(since = "1.8.0", note = "please use `get_compute_budget` instead")] - fn get_bpf_compute_budget(&self) -> &BpfComputeBudget; /// Get this invocation's compute meter fn get_compute_meter(&self) -> Rc>; /// Loaders may need to do work in order to execute a program. Cache @@ -184,103 +180,6 @@ pub fn get_sysvar( }) } -#[deprecated(since = "1.8.0", note = "please use `ComputeBudget` instead")] -#[derive(Clone, Copy, Debug, PartialEq)] -pub struct BpfComputeBudget { - /// Number of compute units that an instruction is allowed. Compute units - /// are consumed by program execution, resources they use, etc... - pub max_units: u64, - /// Number of compute units consumed by a log_u64 call - pub log_64_units: u64, - /// Number of compute units consumed by a create_program_address call - pub create_program_address_units: u64, - /// Number of compute units consumed by an invoke call (not including the cost incurred by - /// the called program) - pub invoke_units: u64, - /// Maximum cross-program invocation depth allowed - pub max_invoke_depth: usize, - /// Base number of compute units consumed to call SHA256 - pub sha256_base_cost: u64, - /// Incremental number of units consumed by SHA256 (based on bytes) - pub sha256_byte_cost: u64, - /// Maximum BPF to BPF call depth - pub max_call_depth: usize, - /// Size of a stack frame in bytes, must match the size specified in the LLVM BPF backend - pub stack_frame_size: usize, - /// Number of compute units consumed by logging a `Pubkey` - pub log_pubkey_units: u64, - /// Maximum cross-program invocation instruction size - pub max_cpi_instruction_size: usize, - /// Number of account data bytes per conpute unit charged during a cross-program invocation - pub cpi_bytes_per_unit: u64, - /// Base number of compute units consumed to get a sysvar - pub sysvar_base_cost: u64, - /// Number of compute units consumed to call secp256k1_recover - pub secp256k1_recover_cost: u64, - /// Number of compute units consumed to do a syscall without any work - pub syscall_base_cost: u64, - /// Optional program heap region size, if `None` then loader default - pub heap_size: Option, -} -#[allow(deprecated)] -impl From for BpfComputeBudget { - fn from(item: ComputeBudget) -> Self { - BpfComputeBudget { - max_units: item.max_units, - log_64_units: item.log_64_units, - create_program_address_units: item.create_program_address_units, - invoke_units: item.invoke_units, - max_invoke_depth: item.max_invoke_depth, - sha256_base_cost: item.sha256_base_cost, - sha256_byte_cost: item.sha256_byte_cost, - max_call_depth: item.max_call_depth, - stack_frame_size: item.stack_frame_size, - log_pubkey_units: item.log_pubkey_units, - max_cpi_instruction_size: item.max_cpi_instruction_size, - cpi_bytes_per_unit: item.cpi_bytes_per_unit, - sysvar_base_cost: item.sysvar_base_cost, - syscall_base_cost: item.syscall_base_cost, - secp256k1_recover_cost: item.secp256k1_recover_cost, - heap_size: item.heap_size, - } - } -} -#[allow(deprecated)] -impl From for ComputeBudget { - fn from(item: BpfComputeBudget) -> Self { - ComputeBudget { - max_units: item.max_units, - log_64_units: item.log_64_units, - create_program_address_units: item.create_program_address_units, - invoke_units: item.invoke_units, - max_invoke_depth: item.max_invoke_depth, - sha256_base_cost: item.sha256_base_cost, - sha256_byte_cost: item.sha256_byte_cost, - max_call_depth: item.max_call_depth, - stack_frame_size: item.stack_frame_size, - log_pubkey_units: item.log_pubkey_units, - max_cpi_instruction_size: item.max_cpi_instruction_size, - cpi_bytes_per_unit: item.cpi_bytes_per_unit, - sysvar_base_cost: item.sysvar_base_cost, - secp256k1_recover_cost: item.secp256k1_recover_cost, - syscall_base_cost: item.syscall_base_cost, - heap_size: item.heap_size, - } - } -} -#[allow(deprecated)] -impl Default for BpfComputeBudget { - fn default() -> Self { - ComputeBudget::default().into() - } -} -#[allow(deprecated)] -impl BpfComputeBudget { - pub fn new() -> Self { - BpfComputeBudget::default() - } -} - /// Compute meter pub trait ComputeMeter { /// Consume compute units @@ -448,7 +347,6 @@ pub struct MockInvokeContext<'a> { pub invoke_stack: Vec>, pub logger: MockLogger, pub compute_budget: ComputeBudget, - pub bpf_compute_budget: BpfComputeBudget, pub compute_meter: MockComputeMeter, pub programs: Vec<(Pubkey, ProcessInstructionWithContext)>, pub accounts: Vec<(Pubkey, Rc>)>, @@ -466,7 +364,6 @@ impl<'a> MockInvokeContext<'a> { invoke_stack: Vec::with_capacity(compute_budget.max_invoke_depth), logger: MockLogger::default(), compute_budget, - bpf_compute_budget: compute_budget.into(), compute_meter: MockComputeMeter { remaining: std::i64::MAX as u64, }, @@ -573,11 +470,6 @@ impl<'a> InvokeContext for MockInvokeContext<'a> { fn get_logger(&self) -> Rc> { Rc::new(RefCell::new(self.logger.clone())) } - #[allow(deprecated)] - fn get_bpf_compute_budget(&self) -> &BpfComputeBudget { - #[allow(deprecated)] - &self.bpf_compute_budget - } fn get_compute_meter(&self) -> Rc> { Rc::new(RefCell::new(self.compute_meter.clone())) }