partial altair merge (#2735)
* partial altair merge * exclude still-in-flux sync committee data structures from partial merge * undo the remaining sync_committee mention
This commit is contained in:
parent
f9cd98702e
commit
38ce948647
|
@ -14,9 +14,10 @@ import
|
|||
chronicles, chronos, metrics,
|
||||
stew/results,
|
||||
# Internals
|
||||
../spec/datatypes/[phase0, altair],
|
||||
../spec/[
|
||||
beaconstate, state_transition_block,
|
||||
datatypes, crypto, digest, forkedbeaconstate_helpers, helpers, network,
|
||||
crypto, digest, forkedbeaconstate_helpers, helpers, network,
|
||||
signatures],
|
||||
../consensus_object_pools/[
|
||||
spec_cache, blockchain_dag, block_quarantine, spec_cache,
|
||||
|
@ -28,6 +29,7 @@ import
|
|||
./batch_validation
|
||||
|
||||
from libp2p/protocols/pubsub/pubsub import ValidationResult
|
||||
|
||||
export ValidationResult
|
||||
|
||||
logScope:
|
||||
|
@ -69,12 +71,12 @@ func check_attestation_block(
|
|||
ok()
|
||||
|
||||
func check_propagation_slot_range(
|
||||
data: AttestationData, wallTime: BeaconTime):
|
||||
msgSlot: Slot, wallTime: BeaconTime):
|
||||
Result[void, (ValidationResult, cstring)] =
|
||||
let
|
||||
futureSlot = (wallTime + MAXIMUM_GOSSIP_CLOCK_DISPARITY).toSlot()
|
||||
|
||||
if not futureSlot.afterGenesis or data.slot > futureSlot.slot:
|
||||
if not futureSlot.afterGenesis or msgSlot > futureSlot.slot:
|
||||
return err((ValidationResult.Ignore, cstring(
|
||||
"Attestation slot in the future")))
|
||||
|
||||
|
@ -88,7 +90,7 @@ func check_propagation_slot_range(
|
|||
const ATTESTATION_PROPAGATION_SLOT_RANGE = 28
|
||||
|
||||
if pastSlot.afterGenesis and
|
||||
data.slot + ATTESTATION_PROPAGATION_SLOT_RANGE < pastSlot.slot:
|
||||
msgSlot + ATTESTATION_PROPAGATION_SLOT_RANGE < pastSlot.slot:
|
||||
return err((ValidationResult.Ignore, cstring(
|
||||
"Attestation slot in the past")))
|
||||
|
||||
|
@ -202,7 +204,7 @@ proc validateAttestation*(
|
|||
# >= attestation.data.slot (a client MAY queue future attestations for
|
||||
# processing at the appropriate slot).
|
||||
block:
|
||||
let v = check_propagation_slot_range(attestation.data, wallTime) # [IGNORE]
|
||||
let v = check_propagation_slot_range(attestation.data.slot, wallTime) # [IGNORE]
|
||||
if v.isErr():
|
||||
return err(v.error)
|
||||
|
||||
|
@ -366,7 +368,7 @@ proc validateAggregate*(
|
|||
# MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. aggregate.data.slot +
|
||||
# ATTESTATION_PROPAGATION_SLOT_RANGE >= current_slot >= aggregate.data.slot
|
||||
block:
|
||||
let v = check_propagation_slot_range(aggregate.data, wallTime) # [IGNORE]
|
||||
let v = check_propagation_slot_range(aggregate.data.slot, wallTime) # [IGNORE]
|
||||
if v.isErr():
|
||||
return err(v.error)
|
||||
|
||||
|
@ -523,7 +525,8 @@ proc validateAggregate*(
|
|||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#beacon_block
|
||||
proc isValidBeaconBlock*(
|
||||
dag: ChainDAGRef, quarantine: QuarantineRef,
|
||||
signed_beacon_block: SignedBeaconBlock, wallTime: BeaconTime,
|
||||
signed_beacon_block: phase0.SignedBeaconBlock | altair.SignedBeaconBlock,
|
||||
wallTime: BeaconTime,
|
||||
flags: UpdateFlags):
|
||||
Result[void, (ValidationResult, BlockError)] =
|
||||
logScope:
|
||||
|
|
|
@ -40,6 +40,7 @@ import
|
|||
../validators/keystore_management,
|
||||
./eth2_discovery, ./peer_pool, ./libp2p_json_serialization
|
||||
|
||||
from ../spec/datatypes/phase0 import nil
|
||||
from ../spec/datatypes/altair import nil
|
||||
|
||||
when chronicles.enabledLogLevel == LogLevel.TRACE:
|
||||
|
@ -84,7 +85,7 @@ type
|
|||
seenTable: Table[PeerID, SeenItem]
|
||||
connWorkers: seq[Future[void]]
|
||||
connTable: HashSet[PeerID]
|
||||
forkId: ENRForkID
|
||||
forkId*: ENRForkID
|
||||
forkDigests*: ForkDigestsRef
|
||||
rng*: ref BrHmacDrbgContext
|
||||
peers*: Table[PeerID, Peer]
|
||||
|
@ -212,8 +213,8 @@ type
|
|||
NetRes*[T] = Result[T, Eth2NetworkingError]
|
||||
## This is type returned from all network requests
|
||||
|
||||
func phase0metadata*(node: Eth2Node): MetaData =
|
||||
MetaData(
|
||||
func phase0metadata*(node: Eth2Node): phase0.MetaData =
|
||||
phase0.MetaData(
|
||||
seq_number: node.metadata.seq_number,
|
||||
attnets: node.metadata.attnets)
|
||||
|
||||
|
@ -903,11 +904,11 @@ proc queryRandom*(d: Eth2DiscoveryProtocol, forkId: ENRForkID,
|
|||
## Perform a discovery query for a random target matching the eth2 field
|
||||
## (forkId) and matching at least one of the attestation subnets.
|
||||
let nodes = await d.queryRandom()
|
||||
let eth2Field = SSZ.encode(forkId)
|
||||
let sszForkId = SSZ.encode(forkId)
|
||||
|
||||
var filtered: seq[PeerAddr]
|
||||
for n in nodes:
|
||||
if n.record.contains(("eth2", eth2Field)):
|
||||
if n.record.contains(("eth2", sszForkId)):
|
||||
let res = n.record.tryGet("attnets", seq[byte])
|
||||
|
||||
if res.isSome():
|
||||
|
|
|
@ -49,8 +49,8 @@ const
|
|||
PARTICIPATION_FLAG_WEIGHTS* =
|
||||
[TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#misc
|
||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-beta.1/specs/altair/validator.md#misc
|
||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
|
||||
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/setup.py#L473
|
||||
|
|
|
@ -413,11 +413,6 @@ type
|
|||
withdrawable_epoch*: Epoch ##\
|
||||
## When validator can withdraw or transfer funds
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#metadata
|
||||
MetaData* = object
|
||||
seq_number*: uint64
|
||||
attnets*: BitArray[ATTESTATION_SUBNET_COUNT]
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#eth2-field
|
||||
ENRForkID* = object
|
||||
fork_digest*: ForkDigest
|
||||
|
|
|
@ -116,6 +116,11 @@ type
|
|||
|
||||
body*: BeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#metadata
|
||||
MetaData* = object
|
||||
seq_number*: uint64
|
||||
attnets*: BitArray[ATTESTATION_SUBNET_COUNT]
|
||||
|
||||
SigVerifiedBeaconBlock* = object
|
||||
## A BeaconBlock that contains verified signatures
|
||||
## but that has not been verified for state transition
|
||||
|
|
|
@ -41,6 +41,12 @@ template epoch*(slot: Slot): Epoch =
|
|||
template isEpoch*(slot: Slot): bool =
|
||||
(slot mod SLOTS_PER_EPOCH) == 0
|
||||
|
||||
template syncCommitteePeriod*(epoch: Epoch): uint64 =
|
||||
epoch div EPOCHS_PER_SYNC_COMMITTEE_PERIOD
|
||||
|
||||
template syncCommitteePeriod*(slot: Slot): uint64 =
|
||||
epoch(slot) div EPOCHS_PER_SYNC_COMMITTEE_PERIOD
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
|
||||
func compute_start_slot_at_epoch*(epoch: Epoch): Slot =
|
||||
## Return the start slot of ``epoch``.
|
||||
|
|
Loading…
Reference in New Issue