Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions beacon/blsync/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2025 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package blsync

import (
"net/http"
)

func (c *Client) NewAPIServer() func(mux *http.ServeMux, maxResponseSize int) {
return func(mux *http.ServeMux, maxResponseSize int) {}
}
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ func signer(c *cli.Context) error {

srv := rpc.NewServer()
srv.SetBatchLimits(node.DefaultConfig.BatchRequestLimit, node.DefaultConfig.BatchResponseMaxSize)
err := node.RegisterApis(rpcAPI, []string{"account"}, srv)
err := node.RegisterRpcAPIs(rpcAPI, []string{"account"}, srv)
if err != nil {
utils.Fatalf("Could not register API: %w", err)
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ func makeFullNode(ctx *cli.Context) *node.Node {
srv.RegisterName("engine", catalyst.NewConsensusAPI(eth))
blsyncer := blsync.NewClient(utils.MakeBeaconLightConfig(ctx))
blsyncer.SetEngineRPC(rpc.DialInProc(srv))
if eth != nil {
eth.Blsync = blsyncer
}
stack.RegisterLifecycle(blsyncer)
} else {
// Launch the engine API for interacting with external consensus client.
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (*eth.EthAPIBac
if err != nil {
Fatalf("Failed to register the Ethereum service: %v", err)
}
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
stack.RegisterRpcAPIs(tracers.APIs(backend.APIBackend))
return backend.APIBackend, backend
}

Expand All @@ -2042,7 +2042,7 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
LogCacheSize: ethcfg.FilterLogCacheSize,
LogQueryLimit: ethcfg.LogQueryLimit,
})
stack.RegisterAPIs([]rpc.API{{
stack.RegisterRpcAPIs([]rpc.API{{
Namespace: "eth",
Service: filters.NewFilterAPI(filterSystem),
}})
Expand Down
5 changes: 5 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/beacon/blsync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
Expand Down Expand Up @@ -431,6 +432,10 @@ func (b *EthAPIBackend) BlobBaseFee(ctx context.Context) *big.Int {
return nil
}

func (b *EthAPIBackend) Blsync() *blsync.Client {
return b.eth.Blsync
}

func (b *EthAPIBackend) ChainDb() ethdb.Database {
return b.eth.ChainDb()
}
Expand Down
23 changes: 19 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/beacon/blsync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
Expand All @@ -50,6 +51,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/internal/restapi"
"github.com/ethereum/go-ethereum/internal/shutdowncheck"
"github.com/ethereum/go-ethereum/internal/version"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -59,6 +61,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rest"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
gethversion "github.com/ethereum/go-ethereum/version"
Expand Down Expand Up @@ -113,6 +116,8 @@ type Ethereum struct {

APIBackend *EthAPIBackend

Blsync *blsync.Client

miner *miner.Miner
gasPrice *big.Int

Expand Down Expand Up @@ -346,7 +351,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
eth.miner.SetPrioAddresses(config.TxPool.Locals)

eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
eth.APIBackend = &EthAPIBackend{
extRPCEnabled: stack.Config().ExtRPCEnabled(),
allowUnprotectedTxs: stack.Config().AllowUnprotectedTxs,
eth: eth,
}
if eth.APIBackend.allowUnprotectedTxs {
log.Info("Unprotected transactions allowed")
}
Expand All @@ -356,7 +365,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, networkID)

// Register the backend on the node
stack.RegisterAPIs(eth.APIs())
stack.RegisterRpcAPIs(eth.RpcAPIs())
stack.RegisterRestAPIs(eth.RestAPIs())
stack.RegisterProtocols(eth.Protocols())
stack.RegisterLifecycle(eth)

Expand All @@ -383,9 +393,9 @@ func makeExtraData(extra []byte) []byte {
return extra
}

// APIs return the collection of RPC services the ethereum package offers.
// RpcAPIs return the collection of RPC services the ethereum package offers.
// NOTE, some of these services probably need to be moved to somewhere else.
func (s *Ethereum) APIs() []rpc.API {
func (s *Ethereum) RpcAPIs() []rpc.API {
apis := ethapi.GetAPIs(s.APIBackend)

// Append all the local APIs and return
Expand All @@ -409,6 +419,11 @@ func (s *Ethereum) APIs() []rpc.API {
}...)
}

// RestAPIs return the collection of REST API services the ethereum package offers.
func (s *Ethereum) RestAPIs() []rest.API {
return restapi.GetAPIs(s.APIBackend)
}

func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
s.blockchain.ResetWithGenesisBlock(gb)
}
Expand Down
2 changes: 1 addition & 1 deletion eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
// Register adds the engine API to the full node.
func Register(stack *node.Node, backend *eth.Ethereum) error {
log.Warn("Engine API enabled", "protocol", "eth")
stack.RegisterAPIs([]rpc.API{
stack.RegisterRpcAPIs([]rpc.API{
{
Namespace: "engine",
Service: NewConsensusAPI(backend),
Expand Down
2 changes: 1 addition & 1 deletion eth/catalyst/simulated_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (c *SimulatedBeacon) AdjustTime(adjustment time.Duration) error {
// stack.
func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) {
api := newSimulatedBeaconAPI(sim)
stack.RegisterAPIs([]rpc.API{
stack.RegisterRpcAPIs([]rpc.API{
{
Namespace: "dev",
Service: api,
Expand Down
2 changes: 1 addition & 1 deletion eth/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Register(stack *node.Node, backend *eth.Ethereum, target common.Hash, exitW
closed: make(chan struct{}),
exitWhenSynced: exitWhenSynced,
}
stack.RegisterAPIs(s.APIs())
stack.RegisterRpcAPIs(s.APIs())
stack.RegisterLifecycle(s)
return s, nil
}
Expand Down
4 changes: 2 additions & 2 deletions ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block, []common.Hash) {
if err != nil {
t.Fatalf("can't create new ethereum service: %v", err)
}
n.RegisterAPIs(tracers.APIs(ethservice.APIBackend))
n.RegisterRpcAPIs(tracers.APIs(ethservice.APIBackend))

filterSystem := filters.NewFilterSystem(ethservice.APIBackend, filters.Config{})
n.RegisterAPIs([]rpc.API{{
n.RegisterRpcAPIs([]rpc.API{{
Namespace: "eth",
Service: filters.NewFilterAPI(filterSystem),
}})
Expand Down
2 changes: 1 addition & 1 deletion ethclient/simulated/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func newWithNode(stack *node.Node, conf *eth.Config, blockPeriod uint64) (*Backe
}
// Register the filter system
filterSystem := filters.NewFilterSystem(backend.APIBackend, filters.Config{})
stack.RegisterAPIs([]rpc.API{{
stack.RegisterRpcAPIs([]rpc.API{{
Namespace: "eth",
Service: filters.NewFilterAPI(filterSystem),
}})
Expand Down
51 changes: 51 additions & 0 deletions internal/restapi/backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2025 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package restapi

import (
"context"

"github.com/ethereum/go-ethereum/beacon/blsync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rest"
"github.com/ethereum/go-ethereum/rpc"
)

type Backend interface {
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
ChainConfig() *params.ChainConfig
Blsync() *blsync.Client
}

func GetAPIs(apiBackend Backend) []rest.API {
apis := []rest.API{
{
Namespace: "exec",
Register: NewExecutionRestAPI(apiBackend),
},
}
if apiBackend.Blsync() != nil {
apis = append(apis, rest.API{
Namespace: "beacon",
Register: apiBackend.Blsync().NewAPIServer(),
})
}
return apis
}
Loading
Loading