// Copyright 2020 Prysmatic Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

package ethereum.eth.service;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";

import "proto/eth/v1/validator.proto";
import "proto/eth/v2/ssz.proto";
import "proto/eth/v2/validator.proto";

option csharp_namespace = "Ethereum.Eth.Service";
option go_package = "github.com/prysmaticlabs/prysm/v4/proto/eth/service";
option java_multiple_files = true;
option java_outer_classname = "ValidatorServiceProto";
option java_package = "org.ethereum.eth.service";
option php_namespace = "Ethereum\\Eth\\Service";

// Beacon chain validator API
//
// The beacon chain validator API is a set of endpoints to be used by validators for performing their roles.
//
// This service is defined in the upstream Ethereum consensus APIs repository (beacon-apis/apis/validator).
service BeaconValidator {
  // ProduceBlockV2 requests the beacon node to produce a valid unsigned beacon block,
  // which can then be signed by a proposer and submitted.
  //
  // HTTP response usage:
  //  - 200: Successful response
  //  - 400: Invalid block production request
  //  - 500: Beacon node internal error
  //  - 503: Beacon node is currently syncing, try again later
  //
  // Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.3.0#/Validator/produceBlockV2
  rpc ProduceBlockV2(v1.ProduceBlockRequest) returns (v2.ProduceBlockResponseV2) {
    option (google.api.http) = { get: "/internal/eth/v2/validator/blocks/{slot}" };
  }

  // ProduceBlockV2 requests the beacon node to produce a valid unsigned beacon block,
  // which can then be signed by a proposer and submitted.
  //
  // The produced block is in SSZ form.
  //
  // HTTP response usage:
  //  - 200: Successful response
  //  - 400: Invalid block production request
  //  - 500: Beacon node internal error
  //  - 503: Beacon node is currently syncing, try again later
  //
  // Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.3.0#/Validator/produceBlockV2
  rpc ProduceBlockV2SSZ(v1.ProduceBlockRequest) returns (v2.SSZContainer) {
    option (google.api.http) = { get: "/internal/eth/v2/validator/blocks/{slot}/ssz" };
  }

  // ProduceBlindedBlock requests the beacon node to produce a valid unsigned blinded beacon block,
  // which can then be signed by a proposer and submitted.
  //
  // Metadata in the response indicates the type of block produced, and the supported types of block
  // will be added to as forks progress.
  //
  // Pre-Bellatrix, this endpoint will return a regular block.
  // HTTP response usage:
  //  - 200: Successful response
  //  - 400: Invalid block production request
  //  - 500: Beacon node internal error
  //  - 503: Beacon node is currently syncing, try again later
  //
  // Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.3.0#/Validator/produceBlindedBlock
  rpc ProduceBlindedBlock(v1.ProduceBlockRequest) returns (v2.ProduceBlindedBlockResponse) {
    option (google.api.http) = { get: "/internal/eth/v1/validator/blinded_blocks/{slot}" };
  }

  // ProduceBlindedBlock requests the beacon node to produce a valid unsigned blinded beacon block,
  // which can then be signed by a proposer and submitted.
  //
  // The produced block is in SSZ form.
  //
  // Metadata in the response indicates the type of block produced, and the supported types of block
  // will be added to as forks progress.
  //
  // Pre-Bellatrix, this endpoint will return a regular block.
  // HTTP response usage:
  //  - 200: Successful response
  //  - 400: Invalid block production request
  //  - 500: Beacon node internal error
  //  - 503: Beacon node is currently syncing, try again later
  //
  // Spec: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.3.0#/Validator/produceBlindedBlock
  rpc ProduceBlindedBlockSSZ(v1.ProduceBlockRequest) returns (v2.SSZContainer) {
    option (google.api.http) = { get: "/internal/eth/v1/validator/blinded_blocks/{slot}/ssz" };
  }
}
