mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
Merge ba7a0e2565 into dddbaa4bf3
This commit is contained in:
commit
4e6d08fd57
7 changed files with 27 additions and 2 deletions
|
|
@ -456,6 +456,10 @@ func (b *EthAPIBackend) SyncProgress(ctx context.Context) ethereum.SyncProgress
|
||||||
return prog
|
return prog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *EthAPIBackend) ConsensusReady() bool {
|
||||||
|
return b.eth.ConsensusReady()
|
||||||
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
func (b *EthAPIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
return b.gpo.SuggestTipCap(ctx)
|
return b.gpo.SuggestTipCap(ctx)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
|
@ -133,6 +134,19 @@ type Ethereum struct {
|
||||||
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
||||||
|
|
||||||
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
||||||
|
|
||||||
|
clContacted atomic.Bool // Set on first Engine API call (newPayload / FCU)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkCLContacted records that the consensus client has driven this node at
|
||||||
|
// least once; catalyst calls it from its package and so cannot reach the field
|
||||||
|
// directly.
|
||||||
|
func (s *Ethereum) MarkCLContacted() { s.clContacted.Store(true) }
|
||||||
|
|
||||||
|
// ConsensusReady reports whether eth_syncing should be allowed to return false.
|
||||||
|
// True once the consensus client has driven the node at least once.
|
||||||
|
func (s *Ethereum) ConsensusReady() bool {
|
||||||
|
return s.clContacted.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,7 @@ func (api *ConsensusAPI) forkchoiceUpdated(ctx context.Context, update engine.Fo
|
||||||
}
|
}
|
||||||
// Stash away the last update to warn the user if the beacon client goes offline
|
// Stash away the last update to warn the user if the beacon client goes offline
|
||||||
api.lastForkchoiceUpdate.Store(time.Now().Unix())
|
api.lastForkchoiceUpdate.Store(time.Now().Unix())
|
||||||
|
api.eth.MarkCLContacted()
|
||||||
|
|
||||||
// Check whether we have the block yet in our database or not. If not, we'll
|
// Check whether we have the block yet in our database or not. If not, we'll
|
||||||
// need to either trigger a sync, or to reject this forkchoice update for a
|
// need to either trigger a sync, or to reject this forkchoice update for a
|
||||||
|
|
@ -945,6 +946,7 @@ func (api *ConsensusAPI) newPayload(ctx context.Context, params engine.Executabl
|
||||||
}
|
}
|
||||||
// Stash away the last update to warn the user if the beacon client goes offline
|
// Stash away the last update to warn the user if the beacon client goes offline
|
||||||
api.lastNewPayloadUpdate.Store(time.Now().Unix())
|
api.lastNewPayloadUpdate.Store(time.Now().Unix())
|
||||||
|
api.eth.MarkCLContacted()
|
||||||
|
|
||||||
// If we already have the block locally, ignore the entire execution and just
|
// If we already have the block locally, ignore the entire execution and just
|
||||||
// return a fake success.
|
// return a fake success.
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,10 @@ func (api *EthereumAPI) BaseFee(ctx context.Context) *hexutil.Big {
|
||||||
func (api *EthereumAPI) Syncing(ctx context.Context) (interface{}, error) {
|
func (api *EthereumAPI) Syncing(ctx context.Context) (interface{}, error) {
|
||||||
progress := api.b.SyncProgress(ctx)
|
progress := api.b.SyncProgress(ctx)
|
||||||
|
|
||||||
// Return not syncing if the synchronisation already completed
|
// Don't claim "synced" until the CL has driven us at least once (post-merge
|
||||||
if progress.Done() {
|
// nodes with Engine API attached). Backends without a CL report ready
|
||||||
|
// immediately via ConsensusReady. Refs #33687.
|
||||||
|
if progress.Done() && api.b.ConsensusReady() {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
// Otherwise gather the block sync stats
|
// Otherwise gather the block sync stats
|
||||||
|
|
|
||||||
|
|
@ -493,6 +493,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.E
|
||||||
func (b testBackend) SyncProgress(ctx context.Context) ethereum.SyncProgress {
|
func (b testBackend) SyncProgress(ctx context.Context) ethereum.SyncProgress {
|
||||||
return ethereum.SyncProgress{}
|
return ethereum.SyncProgress{}
|
||||||
}
|
}
|
||||||
|
func (b testBackend) ConsensusReady() bool { return true }
|
||||||
func (b testBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
func (b testBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
return big.NewInt(0), nil
|
return big.NewInt(0), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import (
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
// General Ethereum API
|
// General Ethereum API
|
||||||
SyncProgress(ctx context.Context) ethereum.SyncProgress
|
SyncProgress(ctx context.Context) ethereum.SyncProgress
|
||||||
|
ConsensusReady() bool
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,7 @@ func (b *backendMock) ChainConfig() *params.ChainConfig { return b.config }
|
||||||
func (b *backendMock) SyncProgress(ctx context.Context) ethereum.SyncProgress {
|
func (b *backendMock) SyncProgress(ctx context.Context) ethereum.SyncProgress {
|
||||||
return ethereum.SyncProgress{}
|
return ethereum.SyncProgress{}
|
||||||
}
|
}
|
||||||
|
func (b *backendMock) ConsensusReady() bool { return true }
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue