evm-gasometer 0.43.0

Ethereum Virtual Machine
Documentation
1
2
3
4
5
6
7
8
9
10
11
use crate::consts::*;
use evm_core::ExitError;

pub fn memory_gas(a: usize) -> Result<u64, ExitError> {
	let a = a as u64;
	G_MEMORY
		.checked_mul(a)
		.ok_or(ExitError::OutOfGas)?
		.checked_add(a.checked_mul(a).ok_or(ExitError::OutOfGas)? / 512)
		.ok_or(ExitError::OutOfGas)
}