-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eth2 API: node endpoints outline (#7522)
* Nodev1 outline * Gaz Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2f6f797
commit 022b09f
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_test") | ||
load("@prysm//tools/go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"node.go", | ||
"server.go", | ||
], | ||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/nodev1", | ||
visibility = ["//beacon-chain:__subpackages__"], | ||
deps = [ | ||
"//beacon-chain/blockchain:go_default_library", | ||
"//beacon-chain/db:go_default_library", | ||
"//beacon-chain/p2p:go_default_library", | ||
"//beacon-chain/sync:go_default_library", | ||
"@com_github_gogo_protobuf//types:go_default_library", | ||
"@com_github_pkg_errors//:go_default_library", | ||
"@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library", | ||
"@org_golang_google_grpc//:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["server_test.go"], | ||
embed = [":go_default_library"], | ||
deps = ["@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package nodev1 | ||
|
||
import ( | ||
"context" | ||
|
||
ptypes "github.com/gogo/protobuf/types" | ||
"github.com/pkg/errors" | ||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1" | ||
) | ||
|
||
// GetIdentity retrieves data about the node's network presence. | ||
func (ns *Server) GetIdentity(ctx context.Context, _ *ptypes.Empty) (*ethpb.IdentityResponse, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
// GetPeer retrieves data about the given peer. | ||
func (ns *Server) GetPeer(ctx context.Context, req *ethpb.PeerRequest) (*ethpb.PeerResponse, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
// ListPeers retrieves data about the node's network peers. | ||
func (ns *Server) ListPeers(ctx context.Context, _ *ptypes.Empty) (*ethpb.PeersResponse, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
// GetVersion requests that the beacon node identify information about its implementation in a | ||
// format similar to a HTTP User-Agent field. | ||
func (ns *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.VersionResponse, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
// GetSyncStatus requests the beacon node to describe if it's currently syncing or not, and | ||
// if it is, what block it is up to. | ||
func (ns *Server) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncingResponse, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
// GetHealth returns node health status in http status codes. Useful for load balancers. | ||
// Response Usage: | ||
// "200": | ||
// description: Node is ready | ||
// "206": | ||
// description: Node is syncing but can serve incomplete data | ||
// "503": | ||
// description: Node not initialized or having issues | ||
func (ns *Server) GetHealth(ctx context.Context, _ *ptypes.Empty) (*ptypes.Empty, error) { | ||
return nil, errors.New("unimplemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Package nodev1 defines a gRPC node service implementation, providing | ||
// useful endpoints for checking a node's sync status, peer info, | ||
// genesis data, and version information. | ||
package nodev1 | ||
|
||
import ( | ||
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/db" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/sync" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// Server defines a server implementation of the gRPC Node service, | ||
// providing RPC endpoints for verifying a beacon node's sync status, genesis and | ||
// version information. | ||
type Server struct { | ||
SyncChecker sync.Checker | ||
Server *grpc.Server | ||
BeaconDB db.ReadOnlyDatabase | ||
PeersFetcher p2p.PeersProvider | ||
PeerManager p2p.PeerManager | ||
GenesisTimeFetcher blockchain.TimeFetcher | ||
GenesisFetcher blockchain.GenesisFetcher | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package nodev1 | ||
|
||
import ( | ||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1" | ||
) | ||
|
||
var _ ethpb.BeaconNodeServer = (*Server)(nil) |