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: bytecode override #14390

Merged
merged 1 commit into from
Feb 11, 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
10 changes: 9 additions & 1 deletion crates/rpc/rpc-eth-types/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ pub enum EthApiError {
/// Evm generic purpose error.
#[error("Revm error: {0}")]
EvmCustom(String),
/// Bytecode override is invalid.
///
/// This can happen if bytecode provided in an
/// [`AccountOverride`](alloy_rpc_types_eth::state::AccountOverride) is malformed, e.g. invalid
/// 7702 bytecode.
#[error("Invalide bytecode: {0}")]
InvalidBytecode(String),
/// Evm precompile error
#[error("Revm precompile error: {0}")]
EvmPrecompile(String),
Expand Down Expand Up @@ -175,7 +182,8 @@ impl From<EthApiError> for jsonrpsee_types::error::ErrorObject<'static> {
EthApiError::Signing(_) |
EthApiError::BothStateAndStateDiffInOverride(_) |
EthApiError::InvalidTracerConfig |
EthApiError::TransactionConversionError => invalid_params_rpc_err(error.to_string()),
EthApiError::TransactionConversionError |
EthApiError::InvalidBytecode(_) => invalid_params_rpc_err(error.to_string()),
EthApiError::InvalidTransaction(err) => err.into(),
EthApiError::PoolError(err) => err.into(),
EthApiError::PrevrandaoNotSet |
Expand Down
5 changes: 4 additions & 1 deletion crates/rpc/rpc-eth-types/src/revm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ where
account_info.nonce = nonce;
}
if let Some(code) = account_override.code {
account_info.code = Some(Bytecode::new_raw(code));
account_info.code = Some(
Bytecode::new_raw_checked(code)
.map_err(|err| EthApiError::InvalidBytecode(err.to_string()))?,
);
}
if let Some(balance) = account_override.balance {
account_info.balance = balance;
Expand Down
Loading