Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.
version: '2'
run:
go: '1.26.3'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this as well

go: '1.26.4'
tests: true
linters:
default: none
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ─── BUILDER STAGE ───────────────────────────────────────────────────────────────
FROM golang:1.26.3-alpine AS builder
FROM golang:1.26.4-alpine AS builder

ARG BOR_DIR=/var/lib/bor/
ENV BOR_DIR=$BOR_DIR
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.26.3-alpine AS builder
FROM golang:1.26.4-alpine AS builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

Expand Down
2 changes: 1 addition & 1 deletion cmd/keeper/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ethereum/go-ethereum/cmd/keeper

go 1.26.3
go 1.26.4

require (
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260104020744-7268a54d0358
Expand Down
14 changes: 12 additions & 2 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/filtermaps"
Expand Down Expand Up @@ -527,9 +528,18 @@ func (b *EthAPIBackend) FeeHistory(ctx context.Context, blockCount uint64, lastB
return b.gpo.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
}

func (b *EthAPIBackend) BaseFee(ctx context.Context) *big.Int {
header := b.CurrentHeader()
if b.ChainConfig().IsLondon(new(big.Int).Add(header.Number, common.Big1)) {
return eip1559.CalcBaseFee(b.ChainConfig(), header)
}
return nil
Comment thread
wjmelements marked this conversation as resolved.
}

func (b *EthAPIBackend) BlobBaseFee(ctx context.Context) *big.Int {
if excess := b.CurrentHeader().ExcessBlobGas; excess != nil && b.ChainConfig().BlobScheduleConfig != nil {
return eip4844.CalcBlobFee(b.ChainConfig(), b.CurrentHeader())
header := b.CurrentHeader()
if header.ExcessBlobGas != nil && b.ChainConfig().BlobScheduleConfig != nil {
return eip4844.CalcBlobFee(b.ChainConfig(), header)
}
return nil
}
Expand Down
110 changes: 110 additions & 0 deletions eth/api_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,116 @@ func TestRelayMethodWiring(t *testing.T) {
})
}

func TestBaseFee(t *testing.T) {
t.Run("LondonActive", func(t *testing.T) {
b := initBackend(false)
defer b.eth.blockchain.Stop()
if b.BaseFee(t.Context()) == nil {
t.Fatal("expected non-nil BaseFee when London is active")
}
})

t.Run("LondonTransitionBlock", func(t *testing.T) {
// LondonBlock = 1 so the genesis block (number 0) is the pre-London
// parent of the first London block. IsLondon(0) is false, but
// IsLondon(0+1) is true, so BaseFee must return InitialBaseFee.
config := *params.NonActivatedConfig
config.HomesteadBlock = big.NewInt(0)
config.EIP150Block = big.NewInt(0)
config.EIP155Block = big.NewInt(0)
config.EIP158Block = big.NewInt(0)
config.ByzantiumBlock = big.NewInt(0)
config.ConstantinopleBlock = big.NewInt(0)
config.PetersburgBlock = big.NewInt(0)
config.IstanbulBlock = big.NewInt(0)
config.BerlinBlock = big.NewInt(0)
config.LondonBlock = big.NewInt(1)
db := rawdb.NewMemoryDatabase()
genesis := &core.Genesis{
Config: &config,
Difficulty: big.NewInt(1),
}
chain, err := core.NewBlockChain(db, genesis, ethash.NewFaker(), nil)
require.NoError(t, err)
defer chain.Stop()
b := &EthAPIBackend{eth: &Ethereum{blockchain: chain}}
got := b.BaseFee(t.Context())
if got == nil {
t.Fatal("expected InitialBaseFee at London transition block, got nil")
}
expected := new(big.Int).SetUint64(params.InitialBaseFee)
if got.Cmp(expected) != 0 {
t.Fatalf("expected BaseFee %v, got %v", expected, got)
}
})

t.Run("PreLondon", func(t *testing.T) {
// NonActivatedConfig has no LondonBlock — IsLondon always returns false.
db := rawdb.NewMemoryDatabase()
genesis := &core.Genesis{
Config: params.NonActivatedConfig,
Difficulty: big.NewInt(1),
}
chain, err := core.NewBlockChain(db, genesis, ethash.NewFaker(), nil)
require.NoError(t, err)
defer chain.Stop()
b := &EthAPIBackend{eth: &Ethereum{blockchain: chain}}
if b.BaseFee(t.Context()) != nil {
t.Fatal("expected nil BaseFee when London is inactive")
}
})
}

func TestBlobBaseFee(t *testing.T) {
t.Run("CancunActive", func(t *testing.T) {
// MergedTestChainConfig has Cancun at block 0 with a BlobScheduleConfig.
// Genesis sets ExcessBlobGas = new(uint64) so the guard passes.
b := initBackend(false)
defer b.eth.blockchain.Stop()
if b.BlobBaseFee(t.Context()) == nil {
t.Fatal("expected non-nil BlobBaseFee when Cancun is active")
}
})

t.Run("NoExcessBlobGas", func(t *testing.T) {
// AllEthashProtocolChanges has London at block 0 but no CancunBlock.
// Genesis therefore leaves ExcessBlobGas nil, so BlobBaseFee must return nil.
db := rawdb.NewMemoryDatabase()
genesis := &core.Genesis{
Config: params.AllEthashProtocolChanges,
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(1),
}
chain, err := core.NewBlockChain(db, genesis, ethash.NewFaker(), nil)
require.NoError(t, err)
defer chain.Stop()
b := &EthAPIBackend{eth: &Ethereum{blockchain: chain}}
if b.BlobBaseFee(t.Context()) != nil {
t.Fatal("expected nil BlobBaseFee when ExcessBlobGas is nil")
}
})

t.Run("NoBlobScheduleConfig", func(t *testing.T) {
// Cancun active but BlobScheduleConfig nil: ExcessBlobGas is set by genesis
// (not nil), but the guard short-circuits before calling CalcBlobFee.
db := rawdb.NewMemoryDatabase()
config := *params.MergedTestChainConfig
config.BlobScheduleConfig = nil
genesis := &core.Genesis{
Config: &config,
Difficulty: common.Big0,
BaseFee: big.NewInt(params.InitialBaseFee),
}
chain, err := core.NewBlockChain(db, genesis, beacon.New(ethash.NewFaker()), nil)
require.NoError(t, err)
defer chain.Stop()
b := &EthAPIBackend{eth: &Ethereum{blockchain: chain}}
if b.BlobBaseFee(t.Context()) != nil {
t.Fatal("expected nil BlobBaseFee when BlobScheduleConfig is nil")
}
})
}

// TestRelayGracefulShutdownOnStop verifies that the relay shutdown path in
// Ethereum.Stop() completes promptly and doesn't hang or panic.
func TestRelayGracefulShutdownOnStop(t *testing.T) {
Expand Down
22 changes: 18 additions & 4 deletions eth/filters/IBackend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/ethereum/go-ethereum

// Note: Change the go image version in Dockerfile if you change this.
go 1.26.3
go 1.26.4

require (
github.com/0xPolygon/crand v1.0.3
Expand Down
5 changes: 5 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func (api *EthereumAPI) BlobBaseFee(ctx context.Context) *hexutil.Big {
return (*hexutil.Big)(api.b.BlobBaseFee(ctx))
}

// BaseFee returns the base fee of the next block.
func (api *EthereumAPI) BaseFee(ctx context.Context) *hexutil.Big {
return (*hexutil.Big)(api.b.BaseFee(ctx))
}

// 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 peers. In case it is synchronizing:
// - startingBlock: block number this node started to synchronize from
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ func (b testBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBloc
return nil, nil, nil, nil, nil, nil, nil
}
func (b testBackend) BlobBaseFee(ctx context.Context) *big.Int { return new(big.Int) }
func (b testBackend) BaseFee(ctx context.Context) *big.Int { return new(big.Int) }
func (b testBackend) ChainDb() ethdb.Database { return b.db }
func (b testBackend) AccountManager() *accounts.Manager { return b.accman }
func (b testBackend) ExtRPCEnabled() bool { return false }
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Backend interface {
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)
BlobBaseFee(ctx context.Context) *big.Int
BaseFee(ctx context.Context) *big.Int
ChainDb() ethdb.Database
AccountManager() *accounts.Manager
ExtRPCEnabled() bool
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/transaction_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func (b *backendMock) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
return big.NewInt(42), nil
}
func (b *backendMock) BlobBaseFee(ctx context.Context) *big.Int { return big.NewInt(42) }
func (b *backendMock) BaseFee(ctx context.Context) *big.Int { return big.NewInt(0) }

func (b *backendMock) CurrentHeader() *types.Header { return b.current }
func (b *backendMock) ChainConfig() *params.ChainConfig { return b.config }
Expand Down
Loading