Bump compute budget for neon evm (#17700) (#18522)

(cherry picked from commit 2867584985)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2021-07-09 09:12:31 -07:00
committed by GitHub
parent 5d0e1d62d5
commit 8b87d86358
6 changed files with 29 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ use solana_sdk::{
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::Clock,
entrypoint::SUCCESS,
entrypoint::{HEAP_LENGTH, SUCCESS},
feature_set::{add_missing_program_error_mappings, upgradeable_close_instruction},
ic_logger_msg, ic_msg,
instruction::InstructionError,
@@ -139,10 +139,6 @@ fn check_loader_id(id: &Pubkey) -> bool {
|| bpf_loader_upgradeable::check_id(id)
}
/// Default program heap size, allocators
/// are expected to enforce this
const DEFAULT_HEAP_SIZE: usize = 32 * 1024;
/// Create the BPF virtual machine
pub fn create_vm<'a>(
loader_id: &'a Pubkey,
@@ -150,7 +146,11 @@ pub fn create_vm<'a>(
parameter_bytes: &mut [u8],
invoke_context: &'a mut dyn InvokeContext,
) -> Result<EbpfVm<'a, BpfError, ThisInstructionMeter>, EbpfError<BpfError>> {
let heap = AlignedMemory::new_with_size(DEFAULT_HEAP_SIZE, HOST_ALIGN);
let bpf_compute_budget = invoke_context.get_bpf_compute_budget();
let heap = AlignedMemory::new_with_size(
bpf_compute_budget.heap_size.unwrap_or(HEAP_LENGTH),
HOST_ALIGN,
);
let heap_region = MemoryRegion::new_from_slice(heap.as_slice(), MM_HEAP_START, 0, true);
let mut vm = EbpfVm::new(program, parameter_bytes, &[heap_region])?;
syscalls::bind_syscall_context_objects(loader_id, &mut vm, invoke_context, heap)?;