diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 075de91ff2..d12ba63bb8 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -576,7 +576,7 @@ type name: "discv5" .}: bool dumpEnabled* {. - desc: "Write SSZ dumps of blocks, attestations and states to data dir" + desc: "Write SSZ dumps of blocks and states to data dir" defaultValue: false name: "dump" .}: bool diff --git a/beacon_chain/consensus_object_pools/attestation_pool.nim b/beacon_chain/consensus_object_pools/attestation_pool.nim index 9c61e8e159..3722163d0f 100644 --- a/beacon_chain/consensus_object_pools/attestation_pool.nim +++ b/beacon_chain/consensus_object_pools/attestation_pool.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -66,6 +66,10 @@ type ## voted on different states - this map keeps track of each vote keyed by ## getAttestationCandidateKey() + CandidateIdxType {.pure.} = enum + phase0Idx + electraIdx + AttestationPool* = object ## The attestation pool keeps track of all attestations that potentially ## could be added to a block during block production. @@ -198,11 +202,12 @@ proc addForkChoiceVotes( # hopefully the fork choice will heal itself over time. error "Couldn't add attestation to fork choice, bug?", err = v.error() -func candidateIdx(pool: AttestationPool, slot: Slot, - isElectra: bool = false): Opt[int] = +func candidateIdx( + pool: AttestationPool, slot: Slot, candidateIdxType: CandidateIdxType): + Opt[int] = static: doAssert pool.phase0Candidates.len == pool.electraCandidates.len - let poolLength = if isElectra: + let poolLength = if candidateIdxtype == CandidateIdxType.electraIdx: pool.electraCandidates.lenu64 else: pool.phase0Candidates.lenu64 if slot >= pool.startingSlot and @@ -450,7 +455,14 @@ proc addAttestation*( updateCurrent(pool, wallTime.slotOrZero) - let candidateIdx = pool.candidateIdx(attestation.data.slot) + when kind(typeof(attestation)) == ConsensusFork.Electra: + let candidateIdx = pool.candidateIdx( + attestation.data.slot, CandidateIdxType.electraIdx) + elif kind(typeof(attestation)) == ConsensusFork.Phase0: + let candidateIdx = pool.candidateIdx( + attestation.data.slot, CandidateIdxType.phase0Idx) + else: + static: doAssert false if candidateIdx.isNone: debug "Skipping old attestation for block production", startingSlot = pool.startingSlot @@ -540,7 +552,7 @@ func covers*( ## the existing aggregates, making it redundant ## the `var` attestation pool is needed to use `withValue`, else Table becomes ## unusably inefficient - let candidateIdx = pool.candidateIdx(data.slot) + let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.phase0Idx) if candidateIdx.isNone: return false @@ -558,7 +570,7 @@ func covers*( ## the existing aggregates, making it redundant ## the `var` attestation pool is needed to use `withValue`, else Table becomes ## unusably inefficient - let candidateIdx = pool.candidateIdx(data.slot) + let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.electraIdx) if candidateIdx.isNone: return false @@ -593,7 +605,8 @@ iterator attestations*( committee_index: Opt[CommitteeIndex]): phase0.Attestation = let candidateIndices = if slot.isSome(): - let candidateIdx = pool.candidateIdx(slot.get()) + let candidateIdx = pool.candidateIdx( + slot.get(), CandidateIdxType.phase0Idx) if candidateIdx.isSome(): candidateIdx.get() .. candidateIdx.get() else: @@ -622,7 +635,8 @@ iterator electraAttestations*( committee_index: Opt[CommitteeIndex]): electra.Attestation = let candidateIndices = if slot.isSome(): - let candidateIdx = pool.candidateIdx(slot.get(), true) + let candidateIdx = pool.candidateIdx( + slot.get(), CandidateIdxType.electraIdx) if candidateIdx.isSome(): candidateIdx.get() .. candidateIdx.get() else: @@ -795,7 +809,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool, let slot = Slot(maxAttestationSlot - i) - candidateIdx = pool.candidateIdx(slot) + candidateIdx = pool.candidateIdx(slot, CandidateIdxType.phase0Idx) if candidateIdx.isNone(): # Passed the collection horizon - shouldn't happen because it's based on @@ -931,7 +945,7 @@ proc getElectraAttestationsForBlock*( let slot = Slot(maxAttestationSlot - i) - candidateIdx = pool.candidateIdx(slot) + candidateIdx = pool.candidateIdx(slot, CandidateIdxType.electraIdx) if candidateIdx.isNone(): # Passed the collection horizon - shouldn't happen because it's based on @@ -1096,7 +1110,7 @@ func getElectraAggregatedAttestation*( Opt[electra.Attestation] = let - candidateIdx = pool.candidateIdx(slot) + candidateIdx = pool.candidateIdx(slot, CandidateIdxType.electraIdx) if candidateIdx.isNone: return Opt.none(electra.Attestation) @@ -1124,7 +1138,7 @@ func getElectraAggregatedAttestation*( # be used here, because otherwise they wouldn't have the same value. It thus # leaves the cross-committee aggregation for getElectraAttestationsForBlock, # which does do this. - let candidateIdx = pool.candidateIdx(slot) + let candidateIdx = pool.candidateIdx(slot, CandidateIdxType.electraIdx) if candidateIdx.isNone: return Opt.none(electra.Attestation) @@ -1147,7 +1161,7 @@ func getPhase0AggregatedAttestation*( pool: var AttestationPool, slot: Slot, attestation_data_root: Eth2Digest): Opt[phase0.Attestation] = let - candidateIdx = pool.candidateIdx(slot) + candidateIdx = pool.candidateIdx(slot, CandidateIdxType.phase0Idx) if candidateIdx.isNone: return Opt.none(phase0.Attestation) @@ -1168,7 +1182,7 @@ func getPhase0AggregatedAttestation*( ## Select the attestation that has the most votes going for it in the given ## slot/index ## https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#construct-aggregate - let candidateIdx = pool.candidateIdx(slot) + let candidateIdx = pool.candidateIdx(slot, CandidateIdxType.phase0Idx) if candidateIdx.isNone: return Opt.none(phase0.Attestation) diff --git a/beacon_chain/sync/sync_queue.nim b/beacon_chain/sync/sync_queue.nim index 70e3c61bab..6748f65a28 100644 --- a/beacon_chain/sync/sync_queue.nim +++ b/beacon_chain/sync/sync_queue.nim @@ -692,7 +692,7 @@ iterator blocks( proc push*[T](sq: SyncQueue[T], sr: SyncRequest[T]) = ## Push failed request back to queue. let pos = sq.find(sr).valueOr: - debug "Request is no more relevant", request = sr + debug "Request is not relevant anymore", request = sr return sq.del(pos) @@ -768,7 +768,7 @@ proc push*[T]( template findPosition(sq, sr: untyped): SyncPosition = sq.find(sr).valueOr: - debug "Request is no more relevant", + debug "Request is not relevant anymore", request = sr, sync_ident = sq.ident, topics = "syncman" # Request is not in queue anymore, probably reset happened. return @@ -790,7 +790,7 @@ proc push*[T]( let res = await sq.waitForChanges() if res: # SyncQueue reset happen - debug "Request is no more relevant, reset happen", + debug "Request is not relevant anymore, reset has happened", request = sr, sync_ident = sq.ident, topics = "syncman" diff --git a/beacon_chain/validator_client/block_service.nim b/beacon_chain/validator_client/block_service.nim index 1c392a2a8a..5cbb8cc082 100644 --- a/beacon_chain/validator_client/block_service.nim +++ b/beacon_chain/validator_client/block_service.nim @@ -387,7 +387,7 @@ proc addOrReplaceProposers*(vc: ValidatorClientRef, epoch: Epoch, for task in epochDuties.duties: if task notin duties: - # Task is no more relevant, so cancel it. + # Task is not relevant anymore, so cancel it. debug "Cancelling running proposal duty tasks", slot = task.duty.slot, pubkey = shortLog(task.duty.pubkey) diff --git a/docs/the_nimbus_book/src/options.md b/docs/the_nimbus_book/src/options.md index 670bf79557..e2e0711edc 100644 --- a/docs/the_nimbus_book/src/options.md +++ b/docs/the_nimbus_book/src/options.md @@ -116,7 +116,7 @@ The following options are available: keys of the validators what to sign and when) and load the validators in the beacon node itself [=true]. --discv5 Enable Discovery v5 [=true]. - --dump Write SSZ dumps of blocks, attestations and states to data dir [=false]. + --dump Write SSZ dumps of blocks and states to data dir [=false]. --direct-peer The list of privileged, secure and known peers to connect and maintain the connection to. This requires a not random netkey-file. In the multiaddress format like: /ip4/
/tcp/