mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
eth,internal: Add eth_blobBaseFee RPC
This commit is contained in:
parent
82b0dec713
commit
492ca8b76b
5 changed files with 29 additions and 9 deletions
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
|
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/bloombits"
|
"github.com/ethereum/go-ethereum/core/bloombits"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
|
|
@ -365,6 +366,15 @@ func (b *EthAPIBackend) FeeHistory(ctx context.Context, blockCount uint64, lastB
|
||||||
return b.gpo.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
|
return b.gpo.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *EthAPIBackend) BlobBaseFee(ctx context.Context) (*big.Int, error) {
|
||||||
|
if excessBlobGas := b.CurrentHeader().ExcessBlobGas; excessBlobGas != nil {
|
||||||
|
blobBaseFee := eip4844.CalcBlobFee(*excessBlobGas)
|
||||||
|
return blobBaseFee, nil
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) ChainDb() ethdb.Database {
|
func (b *EthAPIBackend) ChainDb() ethdb.Database {
|
||||||
return b.eth.ChainDb()
|
return b.eth.ChainDb()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,11 @@ func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecim
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *EthereumAPI) BlobBaseFee(ctx context.Context) (*hexutil.Big, error) {
|
||||||
|
blobBaseFee, err := s.b.BlobBaseFee(ctx)
|
||||||
|
return (*hexutil.Big)(blobBaseFee), err
|
||||||
|
}
|
||||||
|
|
||||||
// Syncing returns false in case the node is currently not syncing with the network. It can be up-to-date or has not
|
// Syncing returns false in case the node is currently not syncing with the network. It can be up-to-date or has not
|
||||||
// yet received the latest block headers from its pears. In case it is synchronizing:
|
// yet received the latest block headers from its pears. In case it is synchronizing:
|
||||||
// - startingBlock: block number this node started to synchronize from
|
// - startingBlock: block number this node started to synchronize from
|
||||||
|
|
|
||||||
|
|
@ -471,6 +471,7 @@ func (b testBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
func (b testBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
func (b testBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
||||||
return nil, nil, nil, nil, nil
|
return nil, nil, nil, nil, nil
|
||||||
}
|
}
|
||||||
|
func (b testBackend) BlobBaseFee(ctx context.Context) (*big.Int, error) { return big.NewInt(0), nil }
|
||||||
func (b testBackend) ChainDb() ethdb.Database { return b.db }
|
func (b testBackend) ChainDb() ethdb.Database { return b.db }
|
||||||
func (b testBackend) AccountManager() *accounts.Manager { return b.accman }
|
func (b testBackend) AccountManager() *accounts.Manager { return b.accman }
|
||||||
func (b testBackend) ExtRPCEnabled() bool { return false }
|
func (b testBackend) ExtRPCEnabled() bool { return false }
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ type Backend interface {
|
||||||
SyncProgress() ethereum.SyncProgress
|
SyncProgress() ethereum.SyncProgress
|
||||||
|
|
||||||
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
|
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
|
||||||
FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error)
|
FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, []*big.Int, []float64, error)
|
||||||
|
BlobBaseFee(ctx context.Context) (*big.Int, error)
|
||||||
ChainDb() ethdb.Database
|
ChainDb() ethdb.Database
|
||||||
AccountManager() *accounts.Manager
|
AccountManager() *accounts.Manager
|
||||||
ExtRPCEnabled() bool
|
ExtRPCEnabled() bool
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,9 @@ func (b *backendMock) SyncProgress() ethereum.SyncProgress { return ethereum.Syn
|
||||||
func (b *backendMock) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
func (b *backendMock) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
|
||||||
return nil, nil, nil, nil, nil
|
return nil, nil, nil, nil, nil
|
||||||
}
|
}
|
||||||
|
func (b *backendMock) BlobBaseFee(ctx context.Context) (*big.Int, error) {
|
||||||
|
return big.NewInt(42), nil
|
||||||
|
}
|
||||||
func (b *backendMock) ChainDb() ethdb.Database { return nil }
|
func (b *backendMock) ChainDb() ethdb.Database { return nil }
|
||||||
func (b *backendMock) AccountManager() *accounts.Manager { return nil }
|
func (b *backendMock) AccountManager() *accounts.Manager { return nil }
|
||||||
func (b *backendMock) ExtRPCEnabled() bool { return false }
|
func (b *backendMock) ExtRPCEnabled() bool { return false }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue