github.com/prysmaticlabs/prysm@v1.4.4/proto/eth/v1/node.proto (about) 1 // Copyright 2020 Prysmatic Labs. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 syntax = "proto3"; 15 16 package ethereum.eth.v1; 17 18 import "google/api/annotations.proto"; 19 import "google/protobuf/descriptor.proto"; 20 import "google/protobuf/empty.proto"; 21 22 import "proto/eth/ext/options.proto"; 23 24 option csharp_namespace = "Ethereum.Eth.v1"; 25 option go_package = "github.com/prysmaticlabs/prysm/proto/eth/v1"; 26 option java_multiple_files = true; 27 option java_outer_classname = "BeaconNodeProto"; 28 option java_package = "org.ethereum.eth.v1"; 29 option php_namespace = "Ethereum\\Eth\\v1"; 30 31 // Beacon chain node API 32 // 33 // The beacon chain node API is a set of endpoints to query node information. 34 service BeaconNode { 35 // GetIdentity retrieves data about the node's network presence. 36 rpc GetIdentity(google.protobuf.Empty) returns (IdentityResponse) { 37 option (google.api.http) = {get: "/eth/v1/node/identity"}; 38 } 39 40 // ListPeers retrieves data about the node's network peers. 41 rpc ListPeers(PeersRequest) returns (PeersResponse) { 42 option (google.api.http) = {get: "/eth/v1/node/peers"}; 43 } 44 45 // GetPeer retrieves data about the given peer. 46 rpc GetPeer(PeerRequest) returns (PeerResponse) { 47 option (google.api.http) = {get: "/eth/v1/node/peers/{peer_id}"}; 48 } 49 50 // PeerCount retrieves number of known peers. 51 rpc PeerCount(google.protobuf.Empty) returns (PeerCountResponse) { 52 option (google.api.http) = {get: "/eth/v1/node/peer_count"}; 53 } 54 55 // GetSyncStatus requests the beacon node to describe if it's currently syncing or not, and 56 // if it is, what block it is up to. 57 rpc GetSyncStatus(google.protobuf.Empty) returns (SyncingResponse) { 58 option (google.api.http) = {get: "/eth/v1/node/syncing"}; 59 } 60 61 // GetVersion requests that the beacon node identify information about its implementation in a 62 // format similar to a HTTP User-Agent field. 63 rpc GetVersion(google.protobuf.Empty) returns (VersionResponse) { 64 option (google.api.http) = {get: "/eth/v1/node/version"}; 65 } 66 67 // GetHealth returns node health status in http status codes. Useful for load balancers. 68 // Response Usage: 69 // "200": 70 // description: Node is ready 71 // "206": 72 // description: Node is syncing but can serve incomplete data 73 // "503": 74 // description: Node not initialized or having issues 75 rpc GetHealth(google.protobuf.Empty) returns (google.protobuf.Empty) { 76 option (google.api.http) = {get: "/eth/v1/node/health"}; 77 } 78 } 79 80 message IdentityResponse { 81 Identity data = 1; 82 } 83 84 message Identity { 85 // The peer id of the node. 86 string peer_id = 1; 87 // The latest ENR of the node. 88 string enr = 2; 89 // All the p2p multiaddresses of the peer, specified as a full multiaddr. 90 repeated string p2p_addresses = 3; 91 // All the discv5 multiaddresses of the peer, specified as a full multiaddr. 92 repeated string discovery_addresses = 4; 93 // Additional metadata that the node would like to provide. Includes extra networking information. 94 Metadata metadata = 5; 95 } 96 97 message Metadata { 98 // Sequence number starts at 0 used to version the node's metadata. If any other field in the local MetaData changes, 99 // the node MUST increment seq_number by 1. 100 uint64 seq_number = 1; 101 // Attnets is a bitvector representing the node's persistent attestation subnet subscriptions. 102 bytes attnets = 2 [(ethereum.eth.ext.ssz_size) = "8", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector64"]; 103 } 104 105 message PeerRequest { 106 // Peer id of the peer requested. 107 string peer_id = 1; 108 } 109 110 message PeersRequest { 111 // Requested peer states (available values: disconnected, connecting, connected, disconnecting). 112 repeated ConnectionState state = 1; 113 // Requested peer directions (available values: inbound, outbound). 114 repeated PeerDirection direction = 2; 115 } 116 117 message PeerResponse { 118 Peer data = 1; 119 Meta meta = 2; 120 121 message Meta { 122 uint64 count = 1; 123 } 124 } 125 126 message PeersResponse { 127 repeated Peer data = 1; 128 } 129 130 message PeerCountResponse { 131 PeerCount data = 1; 132 133 message PeerCount { 134 // The number of disconnected peers. 135 uint64 disconnected = 1; 136 // The number of connecting peers. 137 uint64 connecting = 2; 138 // The number of connected peers. 139 uint64 connected = 3; 140 // The number of disconnecting peers. 141 uint64 disconnecting = 4; 142 } 143 } 144 145 // Peer provides details of a peer on the network. 146 message Peer { 147 // The peer id of the peer. 148 string peer_id = 1; 149 // The latest ENR of the peer that's in the record. 150 string enr = 2; 151 // The address of the peer, as a full multiaddr, for example: 152 // /ip4/37.221.192.134/tcp/13000/p2p/16Uiu2HAm8maLMjag1TAUM52zPfmLbVMGFdwUAWgoHu1HDQLR6e17 153 string last_seen_p2p_address = 3; 154 // The connection state of the peer at the moment of the request. (e.g. Connecting) 155 ConnectionState state = 4; 156 // The direction of the connection (inbound/outbound). 157 PeerDirection direction = 5; 158 } 159 160 // PeerDirection states the direction of the connection to a peer. 161 enum PeerDirection { 162 INBOUND = 0; 163 OUTBOUND = 1; 164 } 165 166 // ConnectionState states the current status of the peer. 167 enum ConnectionState { 168 DISCONNECTED = 0; 169 CONNECTING = 1; 170 CONNECTED = 2; 171 DISCONNECTING = 3; 172 } 173 174 message VersionResponse { 175 Version data = 1; 176 } 177 178 // Information about the node version. 179 message Version { 180 // A string that uniquely identifies the node and its version. 181 string version = 1; 182 } 183 184 message SyncingResponse { 185 SyncInfo data = 1; 186 } 187 188 message SyncInfo { 189 // A uint64 states the latest head slot of the current node. 190 uint64 head_slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"]; 191 192 // A uint64 indicating how many slots are left for the beacon node sync to complete. 193 uint64 sync_distance = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"]; 194 195 // A bool indicating whether the node is currently syncing or not. 196 bool is_syncing = 3; 197 }