Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call original_bytes_slice in check_against_code_hash #1809

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/evm/src/evm/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a, C: sov_modules_api::Context> EvmDb<'a, C> {
code: &Bytecode,
code_hash: &B256,
) -> Result<(), DBError> {
if *code_hash != keccak256(code.original_bytes()) {
if *code_hash != keccak256(code.original_byte_slice()) {
return Err(DBError::CodeHashMismatch);
}
Ok(())
Expand Down
8 changes: 4 additions & 4 deletions crates/evm/src/tests/fork_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ fn test_offchain_contract_storage_evm() {
.get_code_inner(contract_addr, None, &mut working_set, fork_fn)
.unwrap();

assert_eq!(genesis_cont_evm_code.original_bytes(), code);
assert_eq!(*genesis_cont_evm_code.original_byte_slice(), code);

let offchain_code = evm
.offchain_code
Expand Down Expand Up @@ -785,7 +785,7 @@ fn test_offchain_contract_storage_evm() {
)
.unwrap();

assert_eq!(code, evm_code.original_bytes());
assert_eq!(code, *evm_code.original_byte_slice());

// Deploy contract in fork1
evm.begin_soft_confirmation_hook(&soft_confirmation_info, &mut working_set);
Expand Down Expand Up @@ -858,13 +858,13 @@ fn test_offchain_contract_storage_evm() {
let code = evm
.get_code_inner(new_contract_address, None, &mut working_set, fork_fn)
.unwrap();
assert_eq!(code, offchain_code.unwrap().original_bytes());
assert_eq!(code, *offchain_code.unwrap().original_byte_slice());

// Also try to get code of a contract deployed in genesis fork and expect it to exist as well
let code = evm
.get_code_inner(contract_addr, None, &mut working_set, fork_fn)
.unwrap();
assert_eq!(code, genesis_cont_evm_code.original_bytes());
assert_eq!(code, *genesis_cont_evm_code.original_byte_slice());

// Now I should be able to read the contract from offchain storage
let contract_info = evm.accounts.get(&contract_addr, &mut working_set);
Expand Down
Loading