Skip to content

Commit 3a4a3d0

Browse files
authored
Merge pull request #20261 from holiman/less_querying
internal/ethapi: don't query wallets at every execution of gas estimation
2 parents b7ba944 + 51c3290 commit 3a4a3d0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎internal/ethapi/api.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,18 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
906906
}
907907
cap = hi
908908

909+
// Set sender address or use a default if none specified
910+
if args.From == nil {
911+
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
912+
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
913+
args.From = &accounts[0].Address
914+
}
915+
}
916+
}
917+
// Use zero-address if none other is available
918+
if args.From == nil {
919+
args.From = &common.Address{}
920+
}
909921
// Create a helper to check if a gas allowance results in an executable transaction
910922
executable := func(gas uint64) bool {
911923
args.Gas = (*hexutil.Uint64)(&gas)

0 commit comments

Comments
 (0)