mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: bytecode override (#14390)
This commit is contained in:
@ -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),
|
||||
@ -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 |
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user