@@ -611,7 +611,7 @@ type CallArgs struct {
611
611
Data hexutil.Bytes `json:"data"`
612
612
}
613
613
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 ) {
615
615
defer func (start time.Time ) { log .Debug ("Executing EVM call finished" , "runtime" , time .Since (start )) }(time .Now ())
616
616
617
617
state , header , err := s .b .StateAndHeaderByNumber (ctx , blockNr )
@@ -630,7 +630,7 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
630
630
// Set default gas & gas price if none were set
631
631
gas , gasPrice := uint64 (args .Gas ), args .GasPrice .ToInt ()
632
632
if gas == 0 {
633
- gas = 50000000
633
+ gas = math . MaxUint64 / 2
634
634
}
635
635
if gasPrice .Sign () == 0 {
636
636
gasPrice = new (big.Int ).SetUint64 (defaultGasPrice )
@@ -642,14 +642,14 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
642
642
// Setup context so it may be cancelled the call has completed
643
643
// or, in case of unmetered gas, setup a context with a timeout.
644
644
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 )
647
647
} else {
648
648
ctx , cancel = context .WithCancel (ctx )
649
649
}
650
650
// Make sure the context is cancelled when the call has completed
651
651
// this makes sure resources are cleaned up.
652
- defer func () { cancel () } ()
652
+ defer cancel ()
653
653
654
654
// Get a new instance of the EVM.
655
655
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
676
676
// Call executes the given transaction on the state for the given block number.
677
677
// It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
678
678
func (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 )
680
680
return (hexutil .Bytes )(result ), err
681
681
}
682
682
@@ -705,7 +705,7 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (h
705
705
executable := func (gas uint64 ) bool {
706
706
args .Gas = hexutil .Uint64 (gas )
707
707
708
- _ , _ , failed , err := s .doCall (ctx , args , rpc .PendingBlockNumber , vm.Config {})
708
+ _ , _ , failed , err := s .doCall (ctx , args , rpc .PendingBlockNumber , vm.Config {}, 0 )
709
709
if err != nil || failed {
710
710
return false
711
711
}
0 commit comments