syntax = "proto3";

package sentinel;

option go_package = "./sentinel;sentinel";

import "types/types.proto";

message EmptyMessage {}

enum GossipType {
    // Lightclient gossip
    LightClientFinalityUpdateGossipType = 0;
    LightClientOptimisticUpdateGossipType = 1;
    // Legacy gossip
    BeaconBlockGossipType = 2;
    
    // Global gossip topics.
    AggregateAndProofGossipType = 3;
    VoluntaryExitGossipType = 4;
    ProposerSlashingGossipType = 5;
    AttesterSlashingGossipType = 6;
}

message GossipData {
    bytes data = 1; // SSZ encoded data
    GossipType type = 2;
}

message Status {
    uint32 fork_digest = 1; // 4 bytes can be repressented in uint32.
    types.H256 finalized_root = 2;
    uint64 finalized_epoch = 3;
    types.H256 head_root = 4;
    uint64 head_slot = 5;
}

message PeerCount {
    uint64 amount = 1;
}

message RequestData {
    bytes data = 1; // SSZ encoded data
    string topic = 2;
}

message ResponseData {
    bytes data = 1; // prefix-stripped SSZ encoded data
    bool error = 2; // did the peer encounter an error
}

service Sentinel {
    rpc SubscribeGossip(EmptyMessage) returns (stream GossipData);
    rpc SendRequest(RequestData) returns (ResponseData);
    rpc SetStatus(Status) returns(EmptyMessage); // Set status for peer filtering.
    rpc GetPeers(EmptyMessage) returns (PeerCount);
}
