diff --git a/crates/ethereum-rpc/src/lib.rs b/crates/ethereum-rpc/src/lib.rs index 50109f20e..12e1a44e8 100644 --- a/crates/ethereum-rpc/src/lib.rs +++ b/crates/ethereum-rpc/src/lib.rs @@ -14,6 +14,7 @@ pub use gas_price::gas_oracle::GasPriceOracleConfig; use jsonrpsee::types::ErrorObjectOwned; use jsonrpsee::RpcModule; use reth_primitives::{keccak256, BlockNumberOrTag, B256, U256}; +use reth_rpc_types::serde_helpers::U64HexOrNumber; use reth_rpc_types::trace::geth::{ CallConfig, CallFrame, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerConfig, GethDebugTracerType, GethDebugTracingOptions, GethTrace, NoopFrame, @@ -226,13 +227,12 @@ fn register_rpc_methods( info!("eth module: eth_feeHistory"); let mut params = params.sequence(); - let block_count: String = params.next().unwrap(); - let newest_block: BlockNumberOrTag = params.next().unwrap(); + let block_count: U64HexOrNumber = params.next()?; + let newest_block: BlockNumberOrTag = params.next()?; let reward_percentiles: Option> = params.optional_next()?; // convert block count to u64 from hex - let block_count = u64::from_str_radix(&block_count[2..], 16) - .map_err(|e| EthApiError::InvalidParams(e.to_string()))?; + let block_count = block_count.to(); let fee_history = { let mut working_set = WorkingSet::::new(ethereum.storage.clone()); @@ -490,10 +490,10 @@ fn register_rpc_methods( let mut params = parmaeters.sequence(); - let block_hash: B256 = params.next().unwrap(); + let block_hash: B256 = params.next()?; let evm = Evm::::default(); let mut working_set = WorkingSet::::new(ethereum.storage.clone()); - let opts: Option = params.optional_next().unwrap(); + let opts: Option = params.optional_next()?; let block_number = match evm.get_block_number_by_block_hash(block_hash, &mut working_set) { @@ -555,8 +555,8 @@ fn register_rpc_methods( let mut params = parameters.sequence(); - let block_number: BlockNumberOrTag = params.next().unwrap(); - let opts: Option = params.optional_next().unwrap(); + let block_number: BlockNumberOrTag = params.next()?; + let opts: Option = params.optional_next()?; let mut working_set = WorkingSet::::new(ethereum.storage.clone()); let evm = Evm::::default(); @@ -634,7 +634,7 @@ fn register_rpc_methods( .expect("Block number must be set for tx inside block"), ); - let opts: Option = params.optional_next().unwrap(); + let opts: Option = params.optional_next()?; // If opts is None or if opts.tracer is None, then do not check cache or insert cache, just perform the operation // also since this is not cached we need to stop at somewhere, so we add param stop_at @@ -704,8 +704,8 @@ fn register_rpc_methods( let mut params = parameters.sequence(); - let _block_hash: String = params.next().unwrap(); - let _uncle_index_position: String = params.next().unwrap(); + let _block_hash: String = params.next()?; + let _uncle_index_position: String = params.next()?; let res = json!(null); @@ -719,7 +719,7 @@ fn register_rpc_methods( |parameters, ethereum| async move { info!("Full Node: eth_sendRawTransaction"); // send this directly to the sequencer - let data: Bytes = parameters.one().unwrap(); + let data: Bytes = parameters.one()?; // sequencer client should send it let tx_hash = ethereum .sequencer_client @@ -742,7 +742,7 @@ fn register_rpc_methods( "eth_getTransactionByHash", |parameters, ethereum| async move { let mut params = parameters.sequence(); - let hash: B256 = params.next().unwrap(); + let hash: B256 = params.next()?; let mempool_only: Result, ErrorObjectOwned> = params.optional_next(); info!( "Full Node: eth_getTransactionByHash({}, {:?})", diff --git a/crates/sequencer/src/rpc.rs b/crates/sequencer/src/rpc.rs index c1461f69b..1c9da7ff6 100644 --- a/crates/sequencer/src/rpc.rs +++ b/crates/sequencer/src/rpc.rs @@ -68,7 +68,7 @@ pub(crate) fn create_rpc_module( })?; rpc.register_async_method("eth_getTransactionByHash", |parameters, ctx| async move { let mut params = parameters.sequence(); - let hash: B256 = params.next().unwrap(); + let hash: B256 = params.next()?; let mempool_only: Result, ErrorObjectOwned> = params.optional_next(); info!( "Sequencer: eth_getTransactionByHash({}, {:?})", @@ -100,7 +100,7 @@ pub(crate) fn create_rpc_module( "citrea_sendRawDepositTransaction", |parameters, ctx| async move { let mut params = parameters.sequence(); - let deposit: Bytes = params.next().unwrap(); + let deposit: Bytes = params.next()?; info!("Sequencer: citrea_sendRawDepositTransaction"); @@ -125,8 +125,11 @@ pub(crate) fn create_rpc_module( } Err(e) => { tracing::error!("Error processing deposit tx: {:?}", e); + return Err(e); } } + + Ok(()) }, )?; Ok(rpc)