diff --git a/eth/api_backend.go b/eth/api_backend.go index 5cb8c23e90e2..643f6369df0e 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -74,10 +74,10 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb if number == rpc.LatestBlockNumber { return b.eth.blockchain.CurrentBlock(), nil } - if !b.eth.Merger().TDDReached() && (number == rpc.FinalizedBlockNumber || number == rpc.SafeBlockNumber) { - return nil, errors.New("finalized/safe is not supported on pre-merge network") - } if number == rpc.FinalizedBlockNumber { + if !b.eth.Merger().TDDReached() { + return nil, errors.New("'finalized' tag not supported on pre-merge network") + } block := b.eth.blockchain.CurrentFinalBlock() if block != nil { return block, nil @@ -85,6 +85,9 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb return nil, errors.New("finalized block not found") } if number == rpc.SafeBlockNumber { + if !b.eth.Merger().TDDReached() { + return nil, errors.New("'safe' tag not supported on pre-merge network") + } block := b.eth.blockchain.CurrentSafeBlock() if block != nil { return block, nil @@ -126,14 +129,17 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe header := b.eth.blockchain.CurrentBlock() return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil } - if !b.eth.Merger().TDDReached() && (number == rpc.FinalizedBlockNumber || number == rpc.SafeBlockNumber) { - return nil, errors.New("finalized/safe is not supported on pre-merge network") - } if number == rpc.FinalizedBlockNumber { + if !b.eth.Merger().TDDReached() { + return nil, errors.New("'finalized' tag not supported on pre-merge network") + } header := b.eth.blockchain.CurrentFinalBlock() return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil } if number == rpc.SafeBlockNumber { + if !b.eth.Merger().TDDReached() { + return nil, errors.New("'safe' tag not supported on pre-merge network") + } header := b.eth.blockchain.CurrentSafeBlock() return b.eth.blockchain.GetBlock(header.Hash(), header.Number.Uint64()), nil }