@@ -611,7 +611,7 @@ type CallArgs struct {
611611 Data hexutil.Bytes `json:"data"`
612612}
613613
614- func (s * PublicBlockChainAPI ) doCall (ctx context.Context , args CallArgs , blockNr rpc.BlockNumber , vmCfg vm.Config ) ([]byte , uint64 , bool , error ) {
614+ func (s * PublicBlockChainAPI ) doCall (ctx context.Context , args CallArgs , blockNr rpc.BlockNumber , vmCfg vm.Config , timeout time. Duration ) ([]byte , uint64 , bool , error ) {
615615 defer func (start time.Time ) { log .Debug ("Executing EVM call finished" , "runtime" , time .Since (start )) }(time .Now ())
616616
617617 state , header , err := s .b .StateAndHeaderByNumber (ctx , blockNr )
@@ -630,7 +630,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
630630 // Set default gas & gas price if none were set
631631 gas , gasPrice := uint64 (args .Gas ), args .GasPrice .ToInt ()
632632 if gas == 0 {
633- gas = 50000000
633+ gas = math . MaxUint64 / 2
634634 }
635635 if gasPrice .Sign () == 0 {
636636 gasPrice = new (big.Int ).SetUint64 (defaultGasPrice )
@@ -642,14 +642,14 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
642642 // Setup context so it may be cancelled the call has completed
643643 // or, in case of unmetered gas, setup a context with a timeout.
644644 var cancel context.CancelFunc
645- if vmCfg . DisableGasMetering {
646- ctx , cancel = context .WithTimeout (ctx , time . Second * 5 )
645+ if timeout > 0 {
646+ ctx , cancel = context .WithTimeout (ctx , timeout )
647647 } else {
648648 ctx , cancel = context .WithCancel (ctx )
649649 }
650650 // Make sure the context is cancelled when the call has completed
651651 // this makes sure resources are cleaned up.
652- defer func () { cancel () } ()
652+ defer cancel ()
653653
654654 // Get a new instance of the EVM.
655655 evm , vmError , err := s .b .GetEVM (ctx , msg , state , header , vmCfg )
@@ -676,7 +676,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
676676// Call executes the given transaction on the state for the given block number.
677677// It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
678678func (s * PublicBlockChainAPI ) Call (ctx context.Context , args CallArgs , blockNr rpc.BlockNumber ) (hexutil.Bytes , error ) {
679- result , _ , _ , err := s .doCall (ctx , args , blockNr , vm.Config {DisableGasMetering : true } )
679+ result , _ , _ , err := s .doCall (ctx , args , blockNr , vm.Config {}, 5 * time . Second )
680680 return (hexutil .Bytes )(result ), err
681681}
682682
@@ -705,7 +705,7 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (h
705705 executable := func (gas uint64 ) bool {
706706 args .Gas = hexutil .Uint64 (gas )
707707
708- _ , _ , failed , err := s .doCall (ctx , args , rpc .PendingBlockNumber , vm.Config {})
708+ _ , _ , failed , err := s .doCall (ctx , args , rpc .PendingBlockNumber , vm.Config {}, 0 )
709709 if err != nil || failed {
710710 return false
711711 }
0 commit comments