syntax = "proto3";
package ethereum.beacon.p2p.v1;

import "eth/v1alpha1/attestation.proto";
import "eth/v1alpha1/beacon_block.proto";
import "eth/v1alpha1/validator.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";

message BeaconState {
  // Versioning [1001-2000]
  uint64 genesis_time = 1001;
  bytes genesis_validators_root = 1002 [(gogoproto.moretags) = "ssz-size:\"32\""];
  uint64 slot = 1003;
  Fork fork = 1004;

  // History [2001-3000]
  ethereum.eth.v1alpha1.BeaconBlockHeader latest_block_header = 2001;
  repeated bytes block_roots = 2002 [(gogoproto.moretags) = "ssz-size:\"block_roots.size\""];
  repeated bytes state_roots = 2003 [(gogoproto.moretags) = "ssz-size:\"state_roots.size\""];
  repeated bytes historical_roots = 2004 [(gogoproto.moretags) = "ssz-size:\"?,32\" ssz-max:\"16777216\""];

  // Eth1 [3001-4000]
  ethereum.eth.v1alpha1.Eth1Data eth1_data = 3001;
  repeated ethereum.eth.v1alpha1.Eth1Data eth1_data_votes = 3002 [(gogoproto.moretags) = "ssz-max:\"eth1_data_votes.size\""];
  uint64 eth1_deposit_index = 3003;

  // Registry [4001-5000]
  repeated ethereum.eth.v1alpha1.Validator validators = 4001 [(gogoproto.moretags) = "ssz-max:\"1099511627776\""];
  repeated uint64 balances = 4002 [(gogoproto.moretags) = "ssz-max:\"1099511627776\""];

  // Randomness [5001-6000]
  repeated bytes randao_mixes = 5001 [(gogoproto.moretags) = "ssz-size:\"randao_mixes.size\""];

  // Slashings [6001-7000]
  repeated uint64 slashings = 6001 [(gogoproto.moretags) = "ssz-size:\"slashings.size\""];

  // Attestations [7001-8000]
  repeated PendingAttestation previous_epoch_attestations = 7001 [(gogoproto.moretags) = "ssz-max:\"previous_epoch_attestations.max\""];
  repeated PendingAttestation current_epoch_attestations = 7002 [(gogoproto.moretags) = "ssz-max:\"current_epoch_attestations.max\""];

  // Finality [8001-9000]
  // Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
  bytes justification_bits = 8001 [(gogoproto.moretags) = "ssz-size:\"1\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
  ethereum.eth.v1alpha1.Checkpoint previous_justified_checkpoint = 8002;
  ethereum.eth.v1alpha1.Checkpoint current_justified_checkpoint = 8003;
  ethereum.eth.v1alpha1.Checkpoint finalized_checkpoint = 8004;
}

message Fork {
  bytes previous_version = 1 [(gogoproto.moretags) = "ssz-size:\"4\""];
  bytes current_version = 2 [(gogoproto.moretags) = "ssz-size:\"4\""];
  uint64 epoch = 3;
}

message PendingAttestation {
  // Bitfield representation of validator indices that have voted exactly
  // the same vote and have been aggregated into this attestation.
  bytes aggregation_bits = 1 [(gogoproto.moretags) = "ssz-max:\"2048\"", (gogoproto.casttype) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];
  ethereum.eth.v1alpha1.AttestationData data = 2;
  // The difference of when attestation gets created and get included on chain.
  uint64 inclusion_delay = 3;
  // The proposer who included the attestation in the block.
  uint64 proposer_index = 4;
}

message HistoricalBatch {
  repeated bytes block_roots = 1 [(gogoproto.moretags) = "ssz-size:\"block_roots.size\""];
  repeated bytes state_roots = 2 [(gogoproto.moretags) = "ssz-size:\"state_roots.size\""];
}

// The state summary object is defined for summarizing a state
// of a given slot. The summary facilitates regeneration of a
// specific state to allow easy playback using pre-saved state
// and blocks.
message StateSummary {
  // The slot of the state.
  uint64 slot = 1;
  // The block root of the state.
  bytes root = 2;
}

message SigningData {
  // The root of the object being signed.
  bytes object_root = 1 [(gogoproto.moretags) = "ssz-size:\"32\""];
  // The domain for the particular object being signed.
  bytes domain = 2 [(gogoproto.moretags) = "ssz-size:\"32\""];
}

message ForkData {
  // The current version of the fork.
  bytes current_version = 4 [(gogoproto.moretags) = "ssz-size:\"4\""];
  // The genesis validators root of the fork.
  bytes genesis_validators_root = 2 [(gogoproto.moretags) = "ssz-size:\"32\""];
}

message SignedAggregateAndProof {
  // The aggregated and proof from the aggregator.
  ethereum.eth.v1alpha1.AggregateAttestationAndProof message = 1;
  // The signature of the aggregator signing the aggregated and proof object.
  bytes signature = 2 [(gogoproto.moretags) = "ssz-size:\"96\""];
}
