github.com/prysmaticlabs/prysm@v1.4.4/proto/eth/v1/beacon_chain_service.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 import "google/protobuf/timestamp.proto"; 22 23 import "proto/eth/ext/options.proto"; 24 import "proto/eth/v1/attestation.proto"; 25 import "proto/eth/v1/beacon_block.proto"; 26 import "proto/eth/v1/beacon_state.proto"; 27 import "proto/eth/v1/validator.proto"; 28 29 option csharp_namespace = "Ethereum.Eth.v1"; 30 option go_package = "github.com/prysmaticlabs/prysm/proto/eth/v1"; 31 option java_multiple_files = true; 32 option java_outer_classname = "BeaconChainProto"; 33 option java_package = "org.ethereum.eth.v1"; 34 option php_namespace = "Ethereum\\Eth\\v1"; 35 36 // Beacon Chain API 37 // 38 // The config API endpoints can be used to query the beacon chain state and information. Such as spec, current fork, 39 // blocks, and the validator spec. 40 // 41 // This service is defined in the upstream Ethereum consensus APIs repository (eth2.0-APIs/apis/). 42 service BeaconChain { 43 // Beacon state API related endpoints. 44 45 // GetGenesis retrieves details of the chain's genesis which can be used to identify chain. 46 rpc GetGenesis(google.protobuf.Empty) returns (GenesisResponse) { 47 option (google.api.http) = { get: "/eth/v1/beacon/genesis" }; 48 } 49 50 // GetStateRoot calculates HashTreeRoot for state with given 'stateId'. If stateId is root, same value will be returned. 51 rpc GetStateRoot(StateRequest) returns (StateRootResponse) { 52 option (google.api.http) = { 53 get: "/eth/v1/beacon/states/{state_id}/root" 54 }; 55 } 56 57 // GetStateFork returns Fork object for state with given 'stateId'. 58 rpc GetStateFork(StateRequest) returns (StateForkResponse) { 59 option (google.api.http) = { 60 get: "/eth/v1/beacon/states/{state_id}/fork" 61 }; 62 } 63 64 // GetFinalityCheckpoints returns finality checkpoints for state with given 'stateId'. In case finality is 65 // not yet achieved, checkpoint should return epoch 0 and ZERO_HASH as root. 66 rpc GetFinalityCheckpoints(StateRequest) returns (StateFinalityCheckpointResponse) { 67 option (google.api.http) = { 68 get: "/eth/v1/beacon/states/{state_id}/finality_checkpoints" 69 }; 70 } 71 72 // ListValidators returns a filterable list of validators with their balance, status and index. 73 rpc ListValidators(StateValidatorsRequest) returns (StateValidatorsResponse) { 74 option (google.api.http) = { 75 get: "/eth/v1/beacon/states/{state_id}/validators" 76 }; 77 } 78 79 // GetValidator returns a validator specified by state and id or public key along with status and balance. 80 rpc GetValidator(StateValidatorRequest) returns (StateValidatorResponse) { 81 option (google.api.http) = { 82 get: "/eth/v1/beacon/states/{state_id}/validators/{validator_id}" 83 }; 84 } 85 86 // ListValidators returns a filterable list of validator balances. 87 rpc ListValidatorBalances(ValidatorBalancesRequest) returns (ValidatorBalancesResponse) { 88 option (google.api.http) = { 89 get: "/eth/v1/beacon/states/{state_id}/validator_balances" 90 }; 91 } 92 93 // ListCommittees retrieves the committees for the given state at the given epoch. 94 rpc ListCommittees(StateCommitteesRequest) returns (StateCommitteesResponse) { 95 option (google.api.http) = { 96 get: "/eth/v1/beacon/states/{state_id}/committees" 97 }; 98 } 99 100 // Beacon blocks API related endpoints. 101 102 // ListBlockHeaders retrieves block headers matching given query. By default it will fetch current head slot blocks. 103 rpc ListBlockHeaders(BlockHeadersRequest) returns (BlockHeadersResponse) { 104 option (google.api.http) = { 105 get: "/eth/v1/beacon/headers" 106 }; 107 } 108 109 // GetBlockHeader retrieves block header for given block id. 110 rpc GetBlockHeader(BlockRequest) returns (BlockHeaderResponse) { 111 option (google.api.http) = { 112 get: "/eth/v1/beacon/headers/{block_id}" 113 }; 114 } 115 116 // SubmitBlock instructs the beacon node to broadcast a newly signed beacon block to the beacon network, to be 117 // included in the beacon chain. The beacon node is not required to validate the signed BeaconBlock, and a successful 118 // response (20X) only indicates that the broadcast has been successful. The beacon node is expected to integrate the 119 // new block into its state, and therefore validate the block internally, however blocks which fail the validation are 120 // still broadcast but a different status code is returned (202). 121 rpc SubmitBlock(BeaconBlockContainer) returns (google.protobuf.Empty) { 122 option (google.api.http) = { 123 post: "/eth/v1/beacon/blocks" 124 body: "*" 125 }; 126 } 127 128 // GetBlock retrieves block details for given block id. 129 rpc GetBlock(BlockRequest) returns (BlockResponse) { 130 option (google.api.http) = { 131 get: "/eth/v1/beacon/blocks/{block_id}" 132 }; 133 } 134 135 // GetBlockRoot retrieves hashTreeRoot of BeaconBlock/BeaconBlockHeader. 136 rpc GetBlockRoot(BlockRequest) returns (BlockRootResponse) { 137 option (google.api.http) = { 138 get: "/eth/v1/beacon/blocks/{block_id}/root" 139 }; 140 } 141 142 // GetBlockSSZ returns the SSZ-serialized version of block details for given block id. 143 rpc GetBlockSSZ(BlockRequest) returns (BlockSSZResponse) { 144 option (google.api.http) = { 145 get: "/eth/v1/beacon/blocks/{block_id}/ssz" 146 }; 147 } 148 149 // ListBlockAttestations retrieves attestation included in requested block. 150 rpc ListBlockAttestations(BlockRequest) returns (BlockAttestationsResponse) { 151 option (google.api.http) = { 152 get: "/eth/v1/beacon/blocks/{block_id}/attestations" 153 }; 154 } 155 156 // Beacon pools API related endpoints. 157 158 // ListPoolAttestations retrieves attestations known by the node but 159 // not necessarily incorporated into any block. 160 rpc ListPoolAttestations(AttestationsPoolRequest) returns (AttestationsPoolResponse) { 161 option (google.api.http) = { 162 get: "/eth/v1/beacon/pool/attestations" 163 }; 164 } 165 166 // SubmitAttestations submits Attestation objects to node. If attestation passes all validation 167 // constraints, node MUST publish attestation on appropriate subnet. 168 rpc SubmitAttestations(SubmitAttestationsRequest) returns (google.protobuf.Empty) { 169 option (google.api.http) = { 170 post: "/eth/v1/beacon/pool/attestations" 171 body: "*" 172 }; 173 } 174 175 // ListPoolAttesterSlashings retrieves attester slashings known by the node but 176 // not necessarily incorporated into any block. 177 rpc ListPoolAttesterSlashings(google.protobuf.Empty) returns (AttesterSlashingsPoolResponse) { 178 option (google.api.http) = { 179 get: "/eth/v1/beacon/pool/attester_slashings" 180 }; 181 } 182 183 // SubmitAttesterSlashing submits AttesterSlashing object to node's pool and 184 // if passes validation node MUST broadcast it to network. 185 rpc SubmitAttesterSlashing(AttesterSlashing) returns (google.protobuf.Empty) { 186 option (google.api.http) = { 187 post: "/eth/v1/beacon/pool/attester_slashings" 188 body: "*" 189 }; 190 } 191 192 // ListPoolProposerSlashings retrieves proposer slashings known by the node 193 // but not necessarily incorporated into any block. 194 rpc ListPoolProposerSlashings(google.protobuf.Empty) returns (ProposerSlashingPoolResponse) { 195 option (google.api.http) = { 196 get: "/eth/v1/beacon/pool/proposer_slashings" 197 }; 198 } 199 200 // SubmitProposerSlashing submits AttesterSlashing object to node's pool and if 201 // passes validation node MUST broadcast it to network. 202 rpc SubmitProposerSlashing(ProposerSlashing) returns (google.protobuf.Empty) { 203 option (google.api.http) = { 204 post: "/eth/v1/beacon/pool/proposer_slashings" 205 body: "*" 206 }; 207 } 208 209 // ListPoolVoluntaryExits retrieves voluntary exits known by the node but 210 // not necessarily incorporated into any block. 211 rpc ListPoolVoluntaryExits(google.protobuf.Empty) returns (VoluntaryExitsPoolResponse) { 212 option (google.api.http) = { 213 get: "/eth/v1/beacon/pool/voluntary_exits" 214 }; 215 } 216 217 // SubmitVoluntaryExit submits SignedVoluntaryExit object to node's pool 218 // and if passes validation node MUST broadcast it to network. 219 rpc SubmitVoluntaryExit(SignedVoluntaryExit) returns (google.protobuf.Empty) { 220 option (google.api.http) = { 221 post: "/eth/v1/beacon/pool/voluntary_exits" 222 body: "*" 223 }; 224 } 225 226 // Beacon config API related endpoints. 227 228 // GetForkSchedule retrieve all scheduled upcoming forks this node is aware of. 229 rpc GetForkSchedule(google.protobuf.Empty) returns (ForkScheduleResponse) { 230 option (google.api.http) = {get: "/eth/v1/config/fork_schedule"}; 231 } 232 233 // Spec retrieves specification configuration (without Phase 1 params) used on this node. Specification params list 234 // Values are returned with following format: 235 // - any value starting with 0x in the spec is returned as a hex string 236 // - all other values are returned as number 237 rpc GetSpec(google.protobuf.Empty) returns (SpecResponse) { 238 option (google.api.http) = {get: "/eth/v1/config/spec"}; 239 } 240 241 // GetDepositContract retrieves deposit contract address and genesis fork version. 242 rpc GetDepositContract(google.protobuf.Empty) returns (DepositContractResponse) { 243 option (google.api.http) = {get: "/eth/v1/config/deposit_contract"}; 244 } 245 } 246 247 // Beacon State API related messages. 248 249 message GenesisResponse { 250 Genesis data = 1; 251 252 message Genesis { 253 // UTC time specified in the chain start event in the deposit contract. 254 google.protobuf.Timestamp genesis_time = 1; 255 // 32 byte hash tree root of the genesis validator set. 256 bytes genesis_validators_root = 2 [(ethereum.eth.ext.ssz_size) = "32"]; 257 // 4 byte genesis fork version. 258 bytes genesis_fork_version = 3 [(ethereum.eth.ext.ssz_size) = "4"]; 259 } 260 } 261 262 message StateRequest { 263 // The state id which can be any of: "head" (canonical head in node's view), 264 // "genesis", "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>. 265 // Uses the provided state_id for the request. 266 bytes state_id = 1; // TODO: Duck type handling. 267 } 268 269 message StateRootResponse { 270 StateRoot data = 1; 271 272 message StateRoot { 273 // SSZ encoded state root for the requested state. 274 bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"]; 275 } 276 } 277 278 message StateForkResponse { 279 Fork data = 1; 280 } 281 282 message StateFinalityCheckpointResponse { 283 StateFinalityCheckpoint data = 1; 284 285 message StateFinalityCheckpoint { 286 Checkpoint previous_justified = 1; 287 Checkpoint current_justified = 2; 288 Checkpoint finalized = 3; 289 } 290 } 291 292 message StateValidatorsRequest { 293 // The state id which can be any of: "head" (canonical head in node's view), 294 // "genesis", "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>. 295 // Uses the provided state_id for the request. 296 bytes state_id = 1; // TODO: Duck type handling. 297 298 // An array of either hex encoded public keys (with 0x prefix) or validator indexes. 299 repeated bytes id = 2; // TODO: Duck type handling. 300 301 // The status to query validators for, can be one of: pending_initialized, pending_queued, active_ongoing, 302 // active_exiting, active_slashed, exited_unslashed, exited_slashed, withdrawal_possible, 303 // withdrawal_done, active, pending, exited, withdrawal 304 repeated ValidatorStatus status = 3; 305 } 306 307 message ValidatorBalancesRequest { 308 // The state id which can be any of: "head" (canonical head in node's view), 309 // "genesis", "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>. 310 // Uses the provided state_id for the request. 311 bytes state_id = 1; // TODO: Duck type handling. 312 313 // An array of either hex encoded public keys (with 0x prefix) or validator indexes. 314 repeated bytes id = 2; // TODO: Duck type handling. 315 } 316 317 message StateValidatorsResponse { 318 repeated ValidatorContainer data = 1; 319 } 320 321 message ValidatorBalancesResponse { 322 repeated ValidatorBalance data = 1; 323 } 324 325 message ValidatorBalance { 326 // The index of the validator the retrieved balance is for. 327 uint64 index = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.ValidatorIndex"]; 328 329 // The balance of the requested validator. 330 uint64 balance = 2; 331 } 332 333 message StateValidatorRequest { 334 // The state id which can be any of: "head" (canonical head in node's view), 335 // "genesis", "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>. 336 // Uses the provided state_id for the request. 337 bytes state_id = 1; // TODO: Duck type handling. 338 339 // The public key or index for the validator to retrieve information for. 340 bytes validator_id = 2; 341 } 342 343 message StateValidatorResponse { 344 ValidatorContainer data = 1; 345 } 346 347 message StateCommitteesRequest { 348 // The state id which can be any of: "head" (canonical head in node's view), 349 // "genesis", "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>. 350 // Uses the provided state_id for the request. 351 bytes state_id = 1; // TODO: Duck type handling. 352 353 // The epoch to retrieve the committees of. 354 optional uint64 epoch = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Epoch"]; 355 356 // Committee index requested. 357 optional uint64 index = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.CommitteeIndex"]; 358 359 // Committee slot requested. 360 optional uint64 slot = 4 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"]; 361 } 362 363 message StateCommitteesResponse { 364 repeated Committee data = 1; 365 } 366 367 // Beacon Block API related messages. 368 369 message BlockAttestationsResponse { 370 repeated Attestation data = 1; 371 } 372 373 message BlockRootContainer { 374 // 32 byte merkle tree root of the ssz encoded block. 375 bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"]; 376 } 377 378 message BlockRootResponse { 379 BlockRootContainer data = 1; 380 } 381 382 message BlockHeadersRequest { 383 // Beacon chain slot of the requested block. 384 optional uint64 slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"]; 385 386 // 32 byte merkle tree root of the ssz encoded parent block. 387 optional bytes parent_root = 2 [(ethereum.eth.ext.ssz_size) = "32"]; 388 } 389 390 message BlockHeadersResponse { 391 repeated BlockHeaderContainer data = 1; 392 } 393 394 message BlockRequest { 395 // The block identifier. Can be one of: "head" (canonical head in node's view), "genesis", 396 // "finalized", <slot>, <hex encoded blockRoot with 0x prefix>. 397 bytes block_id = 1; 398 } 399 400 message BlockHeaderResponse { 401 BlockHeaderContainer data = 1; 402 } 403 404 message BlockHeaderContainer { 405 // 32 byte merkle tree root of the ssz encoded block. 406 bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"]; 407 408 // Boolean indicating whether the block is canonical. 409 bool canonical = 2; 410 411 // Container for a signed beacon block header. 412 BeaconBlockHeaderContainer header = 3; 413 } 414 415 416 message BeaconBlockHeaderContainer { 417 // The unsigned beacon block header. 418 BeaconBlockHeader message = 1; 419 420 // 96 byte BLS signature from the validator that produced this block header. 421 bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"]; 422 } 423 424 message BlockResponse { 425 BeaconBlockContainer data = 1; 426 } 427 428 message BlockSSZResponse { 429 bytes data = 1; 430 } 431 432 message BeaconBlockContainer { 433 // The unsigned beacon block. 434 BeaconBlock message = 1; 435 436 // 96 byte BLS signature from the validator that produced this block. 437 bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"]; 438 } 439 440 // Beacon Pool related API service. 441 442 message AttestationsPoolRequest { 443 optional uint64 slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"]; 444 optional uint64 committee_index = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.CommitteeIndex"]; 445 } 446 447 message SubmitAttestationsRequest { 448 repeated Attestation data = 1; 449 } 450 451 message AttestationsPoolResponse { 452 repeated Attestation data = 1; 453 } 454 455 message AttesterSlashingsPoolResponse { 456 repeated AttesterSlashing data = 1; 457 } 458 459 message ProposerSlashingPoolResponse { 460 repeated ProposerSlashing data = 1; 461 } 462 463 message VoluntaryExitsPoolResponse { 464 repeated SignedVoluntaryExit data = 1; 465 } 466 467 // Beacon Config API related messages. 468 469 message ForkScheduleResponse { 470 // The fork data used for beacon chain versioning. 471 repeated Fork data = 1; 472 } 473 474 // Spec response is a generic flat map of key values. 475 // Values are returned with following format: 476 // - any value starting with 0x in the spec is returned as a hex string 477 // - all other values are returned as string-number 478 message SpecResponse { 479 map<string, string> data = 1; 480 } 481 482 message DepositContractResponse { 483 DepositContract data = 1; 484 } 485 486 message DepositContract { 487 // The chain_id of the network. 488 uint64 chain_id = 1; 489 490 // The address of the deployed deposit contract in use. 491 string address = 2; 492 }