accounts, internal: fix funding check when estimating gas (#21346)

* internal, accounts: fix funding check when estimate gas

* accounts, internal: address comments
This commit is contained in:
gary rong
2020-07-20 20:52:42 +08:00
committed by GitHub
parent 35ddf36229
commit 43e2e58cbd
2 changed files with 6 additions and 4 deletions

View File

@ -448,7 +448,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
hi = b.pendingBlock.GasLimit()
}
// Recap the highest gas allowance with account's balance.
if call.GasPrice != nil && call.GasPrice.Uint64() != 0 {
if call.GasPrice != nil && call.GasPrice.BitLen() != 0 {
balance := b.pendingState.GetBalance(call.From) // from can't be nil
available := new(big.Int).Set(balance)
if call.Value != nil {
@ -458,7 +458,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
available.Sub(available, call.Value)
}
allowance := new(big.Int).Div(available, call.GasPrice)
if hi > allowance.Uint64() {
if allowance.IsUint64() && hi > allowance.Uint64() {
transfer := call.Value
if transfer == nil {
transfer = new(big.Int)