Skip to content

Commit 9fff27e

Browse files
authored
fix(api): change gas_price to use pending block (#1082)
* fix(api): change gas_price to use pending block
1 parent c88cc48 commit 9fff27e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

internal/ethapi/api.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)
6868
if err != nil {
6969
return nil, err
7070
}
71-
if head := s.b.CurrentHeader(); head.BaseFee != nil {
72-
tipcap.Add(tipcap, head.BaseFee)
71+
pendingBlock, _ := s.b.PendingBlockAndReceipts()
72+
if pendingBlock != nil && pendingBlock.BaseFee() != nil {
73+
tipcap.Add(tipcap, pendingBlock.BaseFee())
7374
}
7475
return (*hexutil.Big)(tipcap), err
7576
}

internal/ethapi/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type Backend interface {
6363
BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
6464
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
6565
BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
66+
PendingBlockAndReceipts() (*types.Block, types.Receipts)
6667
StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
6768
StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
6869
StateAt(root common.Hash) (*state.StateDB, error)

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 7 // Minor version component of the current release
27-
VersionPatch = 24 // Patch version component of the current release
27+
VersionPatch = 25 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)