// 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.v1alpha1;

import "proto/eth/ext/options.proto";

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

message Attestation {
    // A bitfield representation of validator indices that have voted exactly
    // the same vote and have been aggregated into this attestation.
    bytes aggregation_bits = 1 [(ethereum.eth.ext.ssz_max) = "2048", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];

    AttestationData data = 2;

    // 96 byte BLS aggregate signature.
    bytes signature = 3 [(ethereum.eth.ext.ssz_size) = "96"];
}

message AggregateAttestationAndProof {
    // The aggregator index that submitted this aggregated attestation and proof.
    uint64 aggregator_index = 1  [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.ValidatorIndex"];

    // The aggregated attestation that was submitted.
    Attestation aggregate = 3;

    // 96 byte selection proof signed by the aggregator, which is the signature of the slot to aggregate.
    bytes selection_proof = 2 [(ethereum.eth.ext.ssz_size) = "96"];
}

message SignedAggregateAttestationAndProof {
    // The aggregated attestation and selection proof itself.
    AggregateAttestationAndProof message = 1;

    // 96 byte BLS aggregate signature signed by the aggregator over the message.
    bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"];
}

message AttestationData {
    // Attestation data includes information on Casper the Friendly Finality Gadget's votes
    // See: https://arxiv.org/pdf/1710.09437.pdf

    // Slot of the attestation attesting for.
    uint64 slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"];

    // The committee index that submitted this attestation.
    uint64 committee_index = 2  [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.CommitteeIndex"];

    // 32 byte root of the LMD GHOST block vote.
    bytes beacon_block_root = 3 [(ethereum.eth.ext.ssz_size) = "32"];

    // The most recent justified checkpoint in the beacon state
    Checkpoint source = 4;

    // The checkpoint attempting to be justified for the current epoch and its epoch boundary block
    Checkpoint target = 5;
}

message Checkpoint {
    // A checkpoint is every epoch's first slot. The goal of Casper FFG
    // is to link the check points together for justification and finalization.

    // Epoch the checkpoint references.
    uint64 epoch = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Epoch"];

    // Block root of the checkpoint references.
    bytes root = 2 [(ethereum.eth.ext.ssz_size) = "32"];
}
