eth,internal/ethapi: remove error return value from blob base fee getter

This commit is contained in:
lightclient 2024-03-07 07:31:53 -07:00 committed by Felix Lange
parent 396424c795
commit d107899598
5 changed files with 18 additions and 22 deletions

View file

@ -366,13 +366,11 @@ 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) { func (b *EthAPIBackend) BlobBaseFee(ctx context.Context) *big.Int {
if excessBlobGas := b.CurrentHeader().ExcessBlobGas; excessBlobGas != nil { if excess := b.CurrentHeader().ExcessBlobGas; excess != nil {
blobBaseFee := eip4844.CalcBlobFee(*excessBlobGas) return eip4844.CalcBlobFee(*excess)
return blobBaseFee, nil
} else {
return nil, nil
} }
return nil
} }
func (b *EthAPIBackend) ChainDb() ethdb.Database { func (b *EthAPIBackend) ChainDb() ethdb.Database {

View file

@ -137,9 +137,8 @@ func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecim
} }
// BlobBaseFee returns the base fee for blob gas at the current head. // BlobBaseFee returns the base fee for blob gas at the current head.
func (s *EthereumAPI) BlobBaseFee(ctx context.Context) (*hexutil.Big, error) { func (s *EthereumAPI) BlobBaseFee(ctx context.Context) *hexutil.Big {
blobBaseFee, err := s.b.BlobBaseFee(ctx) return (*hexutil.Big)(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

View file

@ -472,7 +472,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, []*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, []*big.Int, []float64, error) {
return nil, nil, nil, nil, nil, nil, nil return nil, nil, nil, nil, nil, nil, nil
} }
func (b testBackend) BlobBaseFee(ctx context.Context) (*big.Int, error) { return big.NewInt(0), nil } func (b testBackend) BlobBaseFee(ctx context.Context) *big.Int { return new(big.Int) }
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 }

View file

@ -45,7 +45,7 @@ type Backend interface {
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, []*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) BlobBaseFee(ctx context.Context) *big.Int
ChainDb() ethdb.Database ChainDb() ethdb.Database
AccountManager() *accounts.Manager AccountManager() *accounts.Manager
ExtRPCEnabled() bool ExtRPCEnabled() bool

View file

@ -314,6 +314,8 @@ func (b *backendMock) setFork(fork string) error {
func (b *backendMock) SuggestGasTipCap(ctx context.Context) (*big.Int, error) { func (b *backendMock) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
return big.NewInt(42), nil return big.NewInt(42), nil
} }
func (b *backendMock) BlobBaseFee(ctx context.Context) *big.Int { return big.NewInt(42) }
func (b *backendMock) CurrentHeader() *types.Header { return b.current } func (b *backendMock) CurrentHeader() *types.Header { return b.current }
func (b *backendMock) ChainConfig() *params.ChainConfig { return b.config } func (b *backendMock) ChainConfig() *params.ChainConfig { return b.config }
@ -322,9 +324,6 @@ 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, []*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, []*big.Int, []float64, error) {
return nil, nil, nil, nil, nil, nil, nil return nil, nil, 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 }