Skip to content

Commit

Permalink
fix(Interpreter): wrong block number used (bluealloy#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita authored May 27, 2024
1 parent 1b471bd commit af88ee9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ pub fn blockhash<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, ho
gas!(interpreter, gas::BLOCKHASH);
pop_top!(interpreter, number);

let block_number = host.env().block.number;
let Some(hash) = host.block_hash(block_number) else {
let Some(hash) = host.block_hash(*number) else {
interpreter.instruction_result = InstructionResult::FatalExternalError;
return;
};
Expand Down
3 changes: 2 additions & 1 deletion crates/revm/src/db/states/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ impl<DB: Database> Database for State<DB> {
let ret = *entry.insert(self.database.block_hash(number)?);

// prune all hashes that are older then BLOCK_HASH_HISTORY
let last_block = u64num.saturating_sub(BLOCK_HASH_HISTORY as u64);
while let Some(entry) = self.block_hashes.first_entry() {
if *entry.key() < u64num.saturating_sub(BLOCK_HASH_HISTORY as u64) {
if *entry.key() < last_block {
entry.remove();
} else {
break;
Expand Down

0 comments on commit af88ee9

Please sign in to comment.