From 5011454041f9d25827e0c6e0140e26c44181dc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=BF=97=E5=BC=BA?= <652732310@qq.com> Date: Wed, 9 Feb 2022 17:35:02 +0800 Subject: [PATCH 1/2] EstimateGas should use LatestBlockNumber by default --- internal/ethapi/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 04e63f38ea92..b66b8c5d00b0 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1115,7 +1115,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr // EstimateGas returns an estimate of the amount of gas needed to execute the // given transaction against the current pending block. func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { - bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) + bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) if blockNrOrHash != nil { bNrOrHash = *blockNrOrHash } From dded3532dfee62e91445bdae2279ec5e661c8825 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 11 May 2023 11:05:31 +0200 Subject: [PATCH 2/2] graphql: default to use latest for gas estimation --- graphql/graphql.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql/graphql.go b/graphql/graphql.go index ac80304f8750..1ac439753d90 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1150,8 +1150,8 @@ func (p *Pending) Call(ctx context.Context, args struct { func (p *Pending) EstimateGas(ctx context.Context, args struct { Data ethapi.TransactionArgs }) (hexutil.Uint64, error) { - pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) - return ethapi.DoEstimateGas(ctx, p.r.backend, args.Data, pendingBlockNr, p.r.backend.RPCGasCap()) + latestBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) + return ethapi.DoEstimateGas(ctx, p.r.backend, args.Data, latestBlockNr, p.r.backend.RPCGasCap()) } // Resolver is the top-level object in the GraphQL hierarchy.