Skip to content

Commit

Permalink
Merge pull request #2620 from OffchainLabs/disable-jit-preimage-valid…
Browse files Browse the repository at this point in the history
…ation

Disable preimage validation in JIT
  • Loading branch information
PlasmaPower authored Sep 5, 2024
2 parents c22d297 + d798a96 commit 2db3c70
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions arbitrator/jit/src/wavmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::{
};
use arbutil::{Color, PreimageType};
use caller_env::{GuestPtr, MemAccess};
use sha2::Sha256;
use sha3::{Digest, Keccak256};
use std::{
io,
io::{BufReader, BufWriter, ErrorKind},
Expand Down Expand Up @@ -170,19 +168,25 @@ pub fn resolve_preimage_impl(
error!("Missing requested preimage for hash {hash_hex} in {name}")
};

// Check if preimage rehashes to the provided hash. Exclude blob preimages
let calculated_hash: [u8; 32] = match preimage_type {
PreimageType::Keccak256 => Keccak256::digest(preimage).into(),
PreimageType::Sha2_256 => Sha256::digest(preimage).into(),
PreimageType::EthVersionedHash => *hash,
};
if calculated_hash != *hash {
error!(
"Calculated hash {} of preimage {} does not match provided hash {}",
hex::encode(calculated_hash),
hex::encode(preimage),
hex::encode(*hash)
);
#[cfg(debug_assertions)]
{
use sha2::Sha256;
use sha3::{Digest, Keccak256};

// Check if preimage rehashes to the provided hash. Exclude blob preimages
let calculated_hash: [u8; 32] = match preimage_type {
PreimageType::Keccak256 => Keccak256::digest(preimage).into(),
PreimageType::Sha2_256 => Sha256::digest(preimage).into(),
PreimageType::EthVersionedHash => *hash,
};
if calculated_hash != *hash {
error!(
"Calculated hash {} of preimage {} does not match provided hash {}",
hex::encode(calculated_hash),
hex::encode(preimage),
hex::encode(*hash)
);
}
}

if offset % 32 != 0 {
Expand Down

0 comments on commit 2db3c70

Please sign in to comment.