more spec changes
This commit is contained in:
parent
7cf13c22f0
commit
74cb86ec21
|
@ -180,7 +180,7 @@ proc makeAttestation(node: BeaconNode,
|
|||
var attestation = Attestation(
|
||||
data: attestationData,
|
||||
aggregate_signature: validatorSignature,
|
||||
participation_bitfield: participationBitfield)
|
||||
aggregation_bitfield: participationBitfield)
|
||||
|
||||
await node.network.broadcast(topicAttestations, attestation)
|
||||
|
||||
|
@ -384,7 +384,7 @@ proc processBlocks*(node: BeaconNode) =
|
|||
|
||||
node.network.subscribe(topicAttestations) do (a: Attestation):
|
||||
let participants = get_attestation_participants(
|
||||
node.beaconState, a.data, a.participation_bitfield).
|
||||
node.beaconState, a.data, a.aggregation_bitfield).
|
||||
mapIt(shortValidatorKey(node, it))
|
||||
|
||||
info "Attestation received", slot = a.data.slot,
|
||||
|
|
|
@ -46,13 +46,13 @@ proc combine*(tgt: var Attestation, src: Attestation, flags: UpdateFlags) =
|
|||
|
||||
assert tgt.data == src.data
|
||||
|
||||
for i in 0 ..< tgt.participation_bitfield.len:
|
||||
for i in 0 ..< tgt.aggregation_bitfield.len:
|
||||
# TODO:
|
||||
# when BLS signatures are combined, we must ensure that
|
||||
# the same participant key is not included on both sides
|
||||
tgt.participation_bitfield[i] =
|
||||
tgt.participation_bitfield[i] or
|
||||
src.participation_bitfield[i]
|
||||
tgt.aggregation_bitfield[i] =
|
||||
tgt.aggregation_bitfield[i] or
|
||||
src.aggregation_bitfield[i]
|
||||
|
||||
if skipValidation notin flags:
|
||||
tgt.aggregate_signature.combine(src.aggregate_signature)
|
||||
|
@ -194,7 +194,7 @@ func getAttestationVoteCount(pool: AttestationPool, current_slot: int): CountTab
|
|||
for attestation in pool.attestations[slot]:
|
||||
if attestation.isSome:
|
||||
# Increase the block attestation counts by the number of validators aggregated
|
||||
let voteCount = attestation.get.participation_bitfield.getVoteCount()
|
||||
let voteCount = attestation.get.aggregation_bitfield.getVoteCount()
|
||||
result.inc(attestation.get.data.beacon_block_root, voteCount)
|
||||
|
||||
proc lmdGhost*(
|
||||
|
|
|
@ -373,7 +373,7 @@ proc checkAttestation*(
|
|||
|
||||
let
|
||||
participants = get_attestation_participants(
|
||||
state, attestation.data, attestation.participation_bitfield)
|
||||
state, attestation.data, attestation.aggregation_bitfield)
|
||||
group_public_key = bls_aggregate_pubkeys(
|
||||
participants.mapIt(state.validator_registry[it].pubkey))
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
# The latest version can be seen here:
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/master/specs/beacon-chain.md
|
||||
#
|
||||
# How wrong the code is:
|
||||
# https://github.com/ethereum/eth2.0-specs/compare/8116562049ed80ad1823dd62e98a7483ddf1546c...master
|
||||
#
|
||||
# These datatypes are used as specifications for serialization - thus should not
|
||||
# be altered outside of what the spec says. Likewise, they should not be made
|
||||
# `ref` - this can be achieved by wrapping them in higher-level
|
||||
|
@ -78,6 +75,7 @@ const
|
|||
MAX_WITHDRAWALS_PER_EPOCH* = 4 # withdrawals
|
||||
|
||||
# Deposit contract
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md
|
||||
DEPOSIT_CONTRACT_TREE_DEPTH* = 2^5
|
||||
|
||||
MIN_DEPOSIT_AMOUNT* = 2'u64^0 * 10'u64^9 ##\
|
||||
|
@ -93,6 +91,7 @@ const
|
|||
## processing is done
|
||||
|
||||
# Initial values
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#initial-values
|
||||
GENESIS_FORK_VERSION* = 0'u64
|
||||
GENESIS_SLOT* = 2'u64^63
|
||||
GENESIS_EPOCH* = GENESIS_SLOT div EPOCH_LENGTH # slot_to_epoch(GENESIS_SLOT)
|
||||
|
@ -103,6 +102,7 @@ const
|
|||
BLS_WITHDRAWAL_PREFIX_BYTE* = 0'u8
|
||||
|
||||
# Time parameters
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#time-parameters
|
||||
SLOT_DURATION* = 6'u64 ## \
|
||||
## TODO consistent time unit across projects, similar to C++ chrono?
|
||||
|
||||
|
@ -127,18 +127,19 @@ const
|
|||
ETH1_DATA_VOTING_PERIOD* = 2'u64^4 ##\
|
||||
## epochs (~1.7 hours)
|
||||
|
||||
MIN_VALIDATOR_WITHDRAWAL_TIME* = 2'u64^8 ##\
|
||||
MIN_VALIDATOR_WITHDRAWAL_EPOCHS* = 2'u64^8 ##\
|
||||
## epochs (~27 hours)
|
||||
|
||||
# State list lengths
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#state-list-lengths
|
||||
LATEST_BLOCK_ROOTS_LENGTH* = 2'u64^13
|
||||
LATEST_RANDAO_MIXES_LENGTH* = 2'u64^13
|
||||
LATEST_INDEX_ROOTS_LENGTH* = 2'u64^13
|
||||
LATEST_PENALIZED_EXIT_LENGTH* = 8192 # epochs
|
||||
|
||||
# Reward and penalty quotients
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#reward-and-penalty-quotients
|
||||
BASE_REWARD_QUOTIENT* = 2'u64^10 ##\
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#reward-and-penalty-quotients
|
||||
BASE_REWARD_QUOTIENT* = 2'u64^5 ##\
|
||||
## The `BASE_REWARD_QUOTIENT` parameter dictates the per-epoch reward. It
|
||||
## corresponds to ~2.54% annual interest assuming 10 million participating
|
||||
## ETH in every epoch.
|
||||
|
@ -147,11 +148,13 @@ const
|
|||
INACTIVITY_PENALTY_QUOTIENT* = 2'u64^24
|
||||
|
||||
# Status flags
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#status-flags
|
||||
# Could model this with enum, but following spec closely here
|
||||
INITIATED_EXIT* = 1'u64
|
||||
WITHDRAWABLE* = 2'u64
|
||||
|
||||
# Max operations per block
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#max-operations-per-block
|
||||
MAX_PROPOSER_SLASHINGS* = 2^4
|
||||
MAX_ATTESTER_SLASHINGS* = 2^0
|
||||
MAX_ATTESTATIONS* = 2^7
|
||||
|
@ -163,7 +166,7 @@ type
|
|||
SlotNumber* = uint64
|
||||
EpochNumber* = uint64
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#proposerslashing
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#proposerslashing
|
||||
ProposerSlashing* = object
|
||||
proposer_index*: ValidatorIndex
|
||||
proposal_data_1*: ProposalSignedData
|
||||
|
@ -171,38 +174,40 @@ type
|
|||
proposal_data_2*: ProposalSignedData
|
||||
proposal_signature_2*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attesterslashing
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#attesterslashing
|
||||
AttesterSlashing* = object
|
||||
slashable_attestation_1*: SlashableAttestation ## \
|
||||
## First batch of votes
|
||||
slashable_attestation_2*: SlashableAttestation ## \
|
||||
## Second batch of votes
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#slashableattestation
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#slashableattestation
|
||||
SlashableAttestation* = object
|
||||
validator_indices*: seq[uint64] ##\
|
||||
## Validator indices
|
||||
|
||||
custody_bitfield*: seq[byte] ##\
|
||||
## Custody bitfield
|
||||
|
||||
data*: AttestationData ## \
|
||||
## Attestation data
|
||||
|
||||
custody_bitfield*: seq[byte] ##\
|
||||
## Custody bitfield
|
||||
|
||||
aggregate_signature*: ValidatorSig ## \
|
||||
## Aggregate signature
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#attestation
|
||||
Attestation* = object
|
||||
data*: AttestationData
|
||||
participation_bitfield*: seq[byte] ##\
|
||||
aggregation_bitfield*: seq[byte] ##\
|
||||
## The attesters that are represented in the aggregate signature - each
|
||||
## bit represents an index in `ShardCommittee.committee`
|
||||
|
||||
data*: AttestationData
|
||||
custody_bitfield*: seq[byte] ##\
|
||||
## Custody bitfield
|
||||
aggregate_signature*: ValidatorSig ##\
|
||||
## Aggregate signature of the validators in `custody_bitfield`
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#attestationdata
|
||||
AttestationData* = object
|
||||
slot*: uint64
|
||||
shard*: uint64
|
||||
|
@ -224,10 +229,12 @@ type
|
|||
justified_block_root*: Eth2Digest ##\
|
||||
## Hash of last justified beacon block
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#attestationdata
|
||||
AttestationDataAndCustodyBit* = object
|
||||
data*: AttestationData
|
||||
custody_bit: bool
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#deposit
|
||||
Deposit* = object
|
||||
branch*: seq[Eth2Digest] ##\
|
||||
## Branch in the deposit tree
|
||||
|
@ -238,11 +245,13 @@ type
|
|||
deposit_data*: DepositData ##\
|
||||
## Data
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#depositdata
|
||||
DepositData* = object
|
||||
amount*: uint64 ## Value in Gwei
|
||||
timestamp*: uint64 # Timestamp from deposit contract
|
||||
deposit_input*: DepositInput
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#depositinput
|
||||
DepositInput* = object
|
||||
pubkey*: ValidatorPubKey
|
||||
withdrawal_credentials*: Eth2Digest
|
||||
|
|
|
@ -273,7 +273,7 @@ proc processAttestations(
|
|||
state.latest_attestations.add blck.body.attestations.mapIt(
|
||||
PendingAttestation(
|
||||
data: it.data,
|
||||
participation_bitfield: it.participation_bitfield,
|
||||
participation_bitfield: it.aggregation_bitfield,
|
||||
custody_bitfield: it.custody_bitfield,
|
||||
slot_included: state.slot,
|
||||
)
|
||||
|
|
|
@ -212,6 +212,6 @@ proc makeAttestation*(
|
|||
|
||||
Attestation(
|
||||
data: data,
|
||||
participation_bitfield: participation_bitfield,
|
||||
aggregation_bitfield: participation_bitfield,
|
||||
aggregate_signature: sig
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue