mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-09 12:31:21 +00:00
db1c2d2d82
This is the first PR in support of https://github.com/ledgerwatch/erigon/issues/5824. The phase 0 sepc https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#global-topics specifies 6 global pubsub topics that CL nodes need to handle. This PR implements the `beacob_aggregate_and_proof` topic: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof. The `AggregateAndProof` and `SignedAggregateAndProof` types are defined here: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/validator.md#aggregateandproof. I followed the implementation of `SignedBeaconBlockBellatrix`, which has the following references: 1. cmd/lightclient/cltypes/types.go: defines the struct with relevant SSZ annotations on the fields. 2. cmd/lightclient/cltypes/clone.go: this just returns a reference to an empty object, so not super clear to me if it is necessary: 3. cmd/lightclient/rpc/common.go: this decodes gossip data, switching on the type of gossip message that is received. 4. cmd/lightclient/sentinel/service/service.go: this listens on the pubsub channel and notifies when a packet of the relevant type comes in. 5. cmd/lightclient/sentinel/pubsub.go: this defines the gossip topic struct. 6. cmd/lightclient/lightclient/subscriber.go: this is the lightclient interface for the incoming messages that come from the sentinel.
206 lines
6.6 KiB
Go
206 lines
6.6 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.2.0
|
|
// - protoc v3.14.0
|
|
// source: sentinel.proto
|
|
|
|
package lightrpc
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.32.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion7
|
|
|
|
// SentinelClient is the client API for Sentinel service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
type SentinelClient interface {
|
|
SubscribeGossip(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (Sentinel_SubscribeGossipClient, error)
|
|
SendRequest(ctx context.Context, in *RequestData, opts ...grpc.CallOption) (*ResponseData, error)
|
|
GetPeers(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*PeerCount, error)
|
|
}
|
|
|
|
type sentinelClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewSentinelClient(cc grpc.ClientConnInterface) SentinelClient {
|
|
return &sentinelClient{cc}
|
|
}
|
|
|
|
func (c *sentinelClient) SubscribeGossip(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (Sentinel_SubscribeGossipClient, error) {
|
|
stream, err := c.cc.NewStream(ctx, &Sentinel_ServiceDesc.Streams[0], "/lightrpc.Sentinel/SubscribeGossip", opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x := &sentinelSubscribeGossipClient{stream}
|
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := x.ClientStream.CloseSend(); err != nil {
|
|
return nil, err
|
|
}
|
|
return x, nil
|
|
}
|
|
|
|
type Sentinel_SubscribeGossipClient interface {
|
|
Recv() (*GossipData, error)
|
|
grpc.ClientStream
|
|
}
|
|
|
|
type sentinelSubscribeGossipClient struct {
|
|
grpc.ClientStream
|
|
}
|
|
|
|
func (x *sentinelSubscribeGossipClient) Recv() (*GossipData, error) {
|
|
m := new(GossipData)
|
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (c *sentinelClient) SendRequest(ctx context.Context, in *RequestData, opts ...grpc.CallOption) (*ResponseData, error) {
|
|
out := new(ResponseData)
|
|
err := c.cc.Invoke(ctx, "/lightrpc.Sentinel/SendRequest", in, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *sentinelClient) GetPeers(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*PeerCount, error) {
|
|
out := new(PeerCount)
|
|
err := c.cc.Invoke(ctx, "/lightrpc.Sentinel/GetPeers", in, out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// SentinelServer is the server API for Sentinel service.
|
|
// All implementations must embed UnimplementedSentinelServer
|
|
// for forward compatibility
|
|
type SentinelServer interface {
|
|
SubscribeGossip(*EmptyRequest, Sentinel_SubscribeGossipServer) error
|
|
SendRequest(context.Context, *RequestData) (*ResponseData, error)
|
|
GetPeers(context.Context, *EmptyRequest) (*PeerCount, error)
|
|
mustEmbedUnimplementedSentinelServer()
|
|
}
|
|
|
|
// UnimplementedSentinelServer must be embedded to have forward compatible implementations.
|
|
type UnimplementedSentinelServer struct {
|
|
}
|
|
|
|
func (UnimplementedSentinelServer) SubscribeGossip(*EmptyRequest, Sentinel_SubscribeGossipServer) error {
|
|
return status.Errorf(codes.Unimplemented, "method SubscribeGossip not implemented")
|
|
}
|
|
func (UnimplementedSentinelServer) SendRequest(context.Context, *RequestData) (*ResponseData, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method SendRequest not implemented")
|
|
}
|
|
func (UnimplementedSentinelServer) GetPeers(context.Context, *EmptyRequest) (*PeerCount, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPeers not implemented")
|
|
}
|
|
func (UnimplementedSentinelServer) mustEmbedUnimplementedSentinelServer() {}
|
|
|
|
// UnsafeSentinelServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to SentinelServer will
|
|
// result in compilation errors.
|
|
type UnsafeSentinelServer interface {
|
|
mustEmbedUnimplementedSentinelServer()
|
|
}
|
|
|
|
func RegisterSentinelServer(s grpc.ServiceRegistrar, srv SentinelServer) {
|
|
s.RegisterService(&Sentinel_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Sentinel_SubscribeGossip_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
m := new(EmptyRequest)
|
|
if err := stream.RecvMsg(m); err != nil {
|
|
return err
|
|
}
|
|
return srv.(SentinelServer).SubscribeGossip(m, &sentinelSubscribeGossipServer{stream})
|
|
}
|
|
|
|
type Sentinel_SubscribeGossipServer interface {
|
|
Send(*GossipData) error
|
|
grpc.ServerStream
|
|
}
|
|
|
|
type sentinelSubscribeGossipServer struct {
|
|
grpc.ServerStream
|
|
}
|
|
|
|
func (x *sentinelSubscribeGossipServer) Send(m *GossipData) error {
|
|
return x.ServerStream.SendMsg(m)
|
|
}
|
|
|
|
func _Sentinel_SendRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(RequestData)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(SentinelServer).SendRequest(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: "/lightrpc.Sentinel/SendRequest",
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(SentinelServer).SendRequest(ctx, req.(*RequestData))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Sentinel_GetPeers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(EmptyRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(SentinelServer).GetPeers(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: "/lightrpc.Sentinel/GetPeers",
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(SentinelServer).GetPeers(ctx, req.(*EmptyRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// Sentinel_ServiceDesc is the grpc.ServiceDesc for Sentinel service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var Sentinel_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "lightrpc.Sentinel",
|
|
HandlerType: (*SentinelServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "SendRequest",
|
|
Handler: _Sentinel_SendRequest_Handler,
|
|
},
|
|
{
|
|
MethodName: "GetPeers",
|
|
Handler: _Sentinel_GetPeers_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{
|
|
{
|
|
StreamName: "SubscribeGossip",
|
|
Handler: _Sentinel_SubscribeGossip_Handler,
|
|
ServerStreams: true,
|
|
},
|
|
},
|
|
Metadata: "sentinel.proto",
|
|
}
|