@@ -119,6 +119,11 @@ pub enum FeeHistoryError {
119119 InvalidBlockRange ,
120120}
121121
122+ #[ derive( Debug ) ]
123+ pub struct ErrDetail {
124+ pub detail : String ,
125+ }
126+
122127/// An error due to invalid transaction
123128#[ derive( thiserror:: Error , Debug ) ]
124129pub enum InvalidTransactionError {
@@ -150,8 +155,8 @@ pub enum InvalidTransactionError {
150155 #[ error( "intrinsic gas too low" ) ]
151156 GasTooLow ,
152157 /// returned if the transaction gas exceeds the limit
153- #[ error( "intrinsic gas too high" ) ]
154- GasTooHigh ,
158+ #[ error( "intrinsic gas too high -- {}" , . 0 . detail ) ]
159+ GasTooHigh ( ErrDetail ) ,
155160 /// Thrown to ensure no one is able to specify a transaction with a tip higher than the total
156161 /// fee cap.
157162 #[ error( "max priority fee per gas higher than max fee per gas" ) ]
@@ -185,8 +190,16 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
185190 InvalidTransactionError :: TipAboveFeeCap
186191 }
187192 InvalidTransaction :: GasPriceLessThanBasefee => InvalidTransactionError :: FeeCapTooLow ,
188- InvalidTransaction :: CallerGasLimitMoreThanBlock => InvalidTransactionError :: GasTooHigh ,
189- InvalidTransaction :: CallGasCostMoreThanGasLimit => InvalidTransactionError :: GasTooHigh ,
193+ InvalidTransaction :: CallerGasLimitMoreThanBlock => {
194+ InvalidTransactionError :: GasTooHigh ( ErrDetail {
195+ detail : String :: from ( "CallerGasLimitMoreThanBlock" ) ,
196+ } )
197+ }
198+ InvalidTransaction :: CallGasCostMoreThanGasLimit => {
199+ InvalidTransactionError :: GasTooHigh ( ErrDetail {
200+ detail : String :: from ( "CallGasCostMoreThanGasLimit" ) ,
201+ } )
202+ }
190203 InvalidTransaction :: RejectCallerWithCode => InvalidTransactionError :: SenderNoEOA ,
191204 InvalidTransaction :: LackOfFundForGasLimit { .. } => {
192205 InvalidTransactionError :: InsufficientFunds
@@ -272,7 +285,15 @@ impl<T: Serialize> ToRpcResponseResult for Result<T> {
272285 data : serde_json:: to_value ( data) . ok ( ) ,
273286 }
274287 }
275- InvalidTransactionError :: GasTooLow | InvalidTransactionError :: GasTooHigh => {
288+ InvalidTransactionError :: GasTooLow => {
289+ // <https://eips.ethereum.org/EIPS/eip-1898>
290+ RpcError {
291+ code : ErrorCode :: ServerError ( -32000 ) ,
292+ message : err. to_string ( ) . into ( ) ,
293+ data : None ,
294+ }
295+ }
296+ InvalidTransactionError :: GasTooHigh ( _) => {
276297 // <https://eips.ethereum.org/EIPS/eip-1898>
277298 RpcError {
278299 code : ErrorCode :: ServerError ( -32000 ) ,
0 commit comments