Skip to content

Commit

Permalink
Adding logging to investigate issue with very large eth_estimateGas v…
Browse files Browse the repository at this point in the history
…alue (issue Consensys#461)
  • Loading branch information
SatpalSandhu61 committed Aug 7, 2018
1 parent 25a7096 commit 2f475c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,18 +675,21 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*
)
if (*big.Int)(&args.Gas).Uint64() >= params.TxGas {
hi = (*big.Int)(&args.Gas).Uint64()
log.Info(fmt.Sprintf("======== estimateGas 1: hi = %v", hi))
} else {
// Retrieve the current pending block to act as the gas ceiling
block, err := s.b.BlockByNumber(ctx, rpc.PendingBlockNumber)
if err != nil {
return nil, err
}
hi = block.GasLimit().Uint64()
log.Info(fmt.Sprintf("======== estimateGas 2: hi = %v", hi))
}
for lo+1 < hi {
// Take a guess at the gas, and check transaction validity
mid := (hi + lo) / 2
(*big.Int)(&args.Gas).SetUint64(mid)
log.Info(fmt.Sprintf("======== estimateGas 3: mid = %v", mid))

_, _, failed, err := s.doCall(ctx, args, rpc.PendingBlockNumber, vm.Config{})

Expand All @@ -697,6 +700,7 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*
}
// Otherwise assume the transaction succeeded, lower the gas limit
hi = mid
log.Info(fmt.Sprintf("======== estimateGas 4: set hi = %v", hi))
}
return (*hexutil.Big)(new(big.Int).SetUint64(hi)), nil
}
Expand Down

0 comments on commit 2f475c9

Please sign in to comment.