Bump compute budget (#11864)

* Bump compute budget

* nudge
This commit is contained in:
Jack May
2020-08-26 14:48:51 -07:00
committed by GitHub
parent 5c7080c1f4
commit ea179ad762
7 changed files with 150 additions and 65 deletions

View File

@@ -50,7 +50,7 @@ impl<E> DecodeError<E> for BPFLoaderError {
}
/// Errors returned by functions the BPF Loader registers with the vM
#[derive(Debug, Error)]
#[derive(Debug, Error, PartialEq)]
pub enum BPFError {
#[error("{0}")]
VerifierError(#[from] VerifierError),
@@ -253,9 +253,10 @@ pub fn process_instruction(
mod tests {
use super::*;
use rand::Rng;
use solana_runtime::message_processor::ThisInvokeContext;
use solana_sdk::{
account::Account,
entrypoint_native::{ComputeMeter, Logger, ProcessInstruction},
entrypoint_native::{ComputeBudget, Logger, ProcessInstruction},
instruction::CompiledInstruction,
message::Message,
rent::Rent,
@@ -332,6 +333,9 @@ mod tests {
fn is_cross_program_supported(&self) -> bool {
true
}
fn get_compute_budget(&self) -> ComputeBudget {
ComputeBudget::default()
}
fn get_compute_meter(&self) -> Rc<RefCell<dyn ComputeMeter>> {
Rc::new(RefCell::new(self.compute_meter.clone()))
}
@@ -562,6 +566,29 @@ mod tests {
)
);
// Case: limited budget
let program_id = Pubkey::default();
let mut invoke_context = ThisInvokeContext::new(
&program_id,
Rent::default(),
vec![],
vec![],
None,
true,
ComputeBudget {
max_units: 1,
log_units: 100,
log_64_units: 100,
create_program_address_units: 1500,
invoke_units: 1000,
max_invoke_depth: 2,
},
);
assert_eq!(
Err(InstructionError::Custom(194969602)),
process_instruction(&bpf_loader::id(), &keyed_accounts, &[], &mut invoke_context)
);
// Case: With duplicate accounts
let duplicate_key = Pubkey::new_rand();
let parameter_account = Account::new_ref(1, 0, &program_id);