Skip to content

Commit

Permalink
fix: return the correct error in resize_memory (bluealloy#1359)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Apr 29, 2024
1 parent 9ec2248 commit 215a4c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ macro_rules! resize_memory {
.gas
.record_memory($crate::gas::memory_gas(words_num))
{
$interp.instruction_result = $crate::InstructionResult::MemoryLimitOOG;
$interp.instruction_result = $crate::InstructionResult::MemoryOOG;
return $ret;
}
$interp.shared_memory.resize(rounded_size);
Expand Down
5 changes: 3 additions & 2 deletions crates/revm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ mod test {
},
Context, ContextPrecompile, ContextStatefulPrecompile, Evm, InMemoryDB, InnerEvmContext,
};
use revm_interpreter::{Host, Interpreter};
use revm_interpreter::{gas, Host, Interpreter};
use std::{cell::RefCell, rc::Rc, sync::Arc};

/// Custom evm context
Expand Down Expand Up @@ -511,9 +511,10 @@ mod test {
const CUSTOM_INSTRUCTION_COST: u64 = 133;
const INITIAL_TX_GAS: u64 = 21000;
const EXPECTED_RESULT_GAS: u64 = INITIAL_TX_GAS + CUSTOM_INSTRUCTION_COST;

fn custom_instruction(interp: &mut Interpreter, _host: &mut impl Host) {
// just spend some gas
interp.gas.record_cost(CUSTOM_INSTRUCTION_COST);
gas!(interp, CUSTOM_INSTRUCTION_COST);
}

let code = Bytecode::new_raw([0xEF, 0x00].into());
Expand Down

0 comments on commit 215a4c4

Please sign in to comment.