@@ -741,7 +741,7 @@ type CallArgs struct {
741741}
742742
743743// ToMessage converts CallArgs to the Message type used by the core evm
744- func (args * CallArgs ) ToMessage (globalGasCap * big. Int ) types.Message {
744+ func (args * CallArgs ) ToMessage (globalGasCap uint64 ) types.Message {
745745 // Set sender address or use zero address if none specified.
746746 var addr common.Address
747747 if args .From != nil {
@@ -753,9 +753,9 @@ func (args *CallArgs) ToMessage(globalGasCap *big.Int) types.Message {
753753 if args .Gas != nil {
754754 gas = uint64 (* args .Gas )
755755 }
756- if globalGasCap != nil && globalGasCap . Uint64 () < gas {
756+ if globalGasCap != 0 && globalGasCap < gas {
757757 log .Warn ("Caller gas above allowance, capping" , "requested" , gas , "cap" , globalGasCap )
758- gas = globalGasCap . Uint64 ()
758+ gas = globalGasCap
759759 }
760760 gasPrice := new (big.Int )
761761 if args .GasPrice != nil {
@@ -790,7 +790,7 @@ type account struct {
790790 StateDiff * map [common.Hash ]common.Hash `json:"stateDiff"`
791791}
792792
793- func DoCall (ctx context.Context , b Backend , args CallArgs , blockNrOrHash rpc.BlockNumberOrHash , overrides map [common.Address ]account , vmCfg vm.Config , timeout time.Duration , globalGasCap * big. Int ) (* core.ExecutionResult , error ) {
793+ func DoCall (ctx context.Context , b Backend , args CallArgs , blockNrOrHash rpc.BlockNumberOrHash , overrides map [common.Address ]account , vmCfg vm.Config , timeout time.Duration , globalGasCap uint64 ) (* core.ExecutionResult , error ) {
794794 defer func (start time.Time ) { log .Debug ("Executing EVM call finished" , "runtime" , time .Since (start )) }(time .Now ())
795795
796796 state , header , err := b .StateAndHeaderByNumberOrHash (ctx , blockNrOrHash )
@@ -861,7 +861,10 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
861861 if evm .Cancelled () {
862862 return nil , fmt .Errorf ("execution aborted (timeout = %v)" , timeout )
863863 }
864- return result , err
864+ if err != nil {
865+ return result , fmt .Errorf ("err: %w (supplied gas %d)" , err , msg .Gas ())
866+ }
867+ return result , nil
865868}
866869
867870func newRevertError (result * core.ExecutionResult ) * revertError {
@@ -916,7 +919,7 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
916919 return result .Return (), result .Err
917920}
918921
919- func DoEstimateGas (ctx context.Context , b Backend , args CallArgs , blockNrOrHash rpc.BlockNumberOrHash , gasCap * big. Int ) (hexutil.Uint64 , error ) {
922+ func DoEstimateGas (ctx context.Context , b Backend , args CallArgs , blockNrOrHash rpc.BlockNumberOrHash , gasCap uint64 ) (hexutil.Uint64 , error ) {
920923 // Binary search the gas requirement, as it may be higher than the amount used
921924 var (
922925 lo uint64 = params .TxGas - 1
@@ -964,9 +967,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
964967 }
965968 }
966969 // Recap the highest gas allowance with specified gascap.
967- if gasCap != nil && hi > gasCap . Uint64 () {
970+ if gasCap != 0 && hi > gasCap {
968971 log .Warn ("Caller gas above allowance, capping" , "requested" , hi , "cap" , gasCap )
969- hi = gasCap . Uint64 ()
972+ hi = gasCap
970973 }
971974 cap = hi
972975
@@ -976,7 +979,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
976979
977980 result , err := DoCall (ctx , b , args , blockNrOrHash , nil , vm.Config {}, 0 , gasCap )
978981 if err != nil {
979- if err == core .ErrIntrinsicGas {
982+ if errors . Is ( err , core .ErrIntrinsicGas ) {
980983 return true , nil , nil // Special case, raise gas limit
981984 }
982985 return true , nil , err // Bail out
0 commit comments