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

fix(levm): internal error on precompiles #1514

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion crates/vm/levm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::account::Account;
use bytes::Bytes;
use ethrex_core::{types::Log, Address};
use ethrex_core::{types::Log, Address, H160};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use thiserror;
Expand Down Expand Up @@ -176,6 +176,8 @@ pub enum InternalError {
UndefinedState(i32), // This error is temporarily for things that cause an undefined state.
#[error("Invalid precompile address. Tried to execute a precompile that does not exist.")]
InvalidPrecompileAddress,
#[error("Precompile not implemented: {0}")]
PrecompileNotImplemented(u64),
}

#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions crates/vm/levm/src/opcode_handlers/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
self, max_message_call_gas, CALLCODE_POSITIVE_VALUE_STIPEND, CALL_POSITIVE_VALUE_STIPEND,
},
memory::{self, calculate_memory_size},
precompiles::is_precompile,
vm::{address_to_word, word_to_address, VM},
Account,
};
Expand Down
5 changes: 5 additions & 0 deletions crates/vm/levm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ impl VM {
);

if is_precompile(&current_call_frame.code_address) {
//TODO: Remove this when implementing precompiles
return Err(VMError::Internal(InternalError::PrecompileNotImplemented(
current_call_frame.code_address.to_low_u64_be(),
)));

let precompile_result = execute_precompile(current_call_frame);

match precompile_result {
Expand Down
Loading