ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.1k forks source link

Beacon attester #1191

Closed mkalinin closed 5 years ago

mkalinin commented 5 years ago

Abstract

Implement attestation logic and attester service.

Requirements

Main source of requirements should be the spec. Attestation is a process of signing off on a segment of canonical chain. Attestation service is a service that triggers attestation logic in a specific slot that validator is assigned to, its functionality should be pretty similar to ProposerService. There was a reasonable suggestion to use AttestationRecord for single attestation in the way it would be used for aggregated signature, with only one bit set in a bitfield and a signature that is aggregated with nothing.

AttesterService should produce an attestation after block with slot number that attester is assigned to has been imported. Attestation awaiting should be cancelled If block with that slot number does not occur in 2 * CYCLE_LENGTH slots or its slot number becomes less than number of last finalized slot.

AttesterService should start producing an attestation at Genesis.timestamp + slot * SLOT_DURATION + SLOT_DURATION / 2 where slot is a number of slot that attester is assigned to. And it should attest to the head of canonical chain, whatever block it will be.

One more thing that should be kept in mind is a way service is linked with committees, it's described in Per block processing section:

Verify that the parent.slot_number % len(get_shards_and_committees_for_slot(crystallized_state, parent.slot_number)[0].committee)'th attester in get_shards_and_committees_for_slot(crystallized_state, parent.slot_number)[0] is part of the first (ie. item 0 in the array) AttestationRecord object; this attester can be considered to be the proposer of the parent block. In general, when a block is produced, it is broadcasted at the network layer along with the attestation from its proposer.

Basically, it reads about proposer only but other validators from mentioned committee must attest in that slot.

mkalinin commented 5 years ago

Implemented in https://github.com/ethereum/ethereumj/pull/1210