Skip to content

Commit 7a6cc69

Browse files
authored
show vanity logs on compounding activation of known validators (#6882)
1 parent 67ac6fc commit 7a6cc69

File tree

4 files changed

+55
-27
lines changed

4 files changed

+55
-27
lines changed

beacon_chain/consensus_object_pools/blockchain_dag.nim

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ proc loadExecutionBlockHash*(
23222322
23232323
from std/packedsets import PackedSet, incl, items
23242324
2325-
func getValidatorChangeStatuses(
2325+
func getBlsToExecutionChangeStatuses(
23262326
state: ForkedHashedBeaconState, vis: openArray[ValidatorIndex]):
23272327
PackedSet[ValidatorIndex] =
23282328
var res: PackedSet[ValidatorIndex]
@@ -2338,6 +2338,7 @@ func checkBlsToExecutionChanges(
23382338
# Within each fork, BLS_WITHDRAWAL_PREFIX to ETH1_ADDRESS_WITHDRAWAL_PREFIX
23392339
# and never ETH1_ADDRESS_WITHDRAWAL_PREFIX to BLS_WITHDRAWAL_PREFIX. Latter
23402340
# can still happen via reorgs.
2341+
#
23412342
# Cases:
23422343
# 1) unchanged (BLS_WITHDRAWAL_PREFIX or ETH1_ADDRESS_WITHDRAWAL_PREFIX) from
23432344
# old to new head.
@@ -2352,7 +2353,25 @@ func checkBlsToExecutionChanges(
23522353
# Since it tracks head, it's possible reorgs trigger reporting the same
23532354
# validator indices multiple times; this is fine.
23542355
withState(state):
2355-
anyIt( vis, forkyState.data.validators[it].has_eth1_withdrawal_credential)
2356+
anyIt(vis, forkyState.data.validators[it].has_eth1_withdrawal_credential)
2357+
2358+
func getCompoundingStatuses(
2359+
state: ForkedHashedBeaconState, vis: openArray[ValidatorIndex]):
2360+
PackedSet[ValidatorIndex] =
2361+
var res: PackedSet[ValidatorIndex]
2362+
withState(state):
2363+
for vi in vis:
2364+
if forkyState.data.validators[vi].withdrawal_credentials.data[0] !=
2365+
COMPOUNDING_WITHDRAWAL_PREFIX:
2366+
res.incl vi
2367+
res
2368+
2369+
func checkCompoundingChanges(
2370+
state: ForkedHashedBeaconState, vis: PackedSet[ValidatorIndex]): bool =
2371+
# Since it tracks head, it's possible reorgs trigger reporting the same
2372+
# validator indices multiple times; this is fine.
2373+
withState(state):
2374+
anyIt(vis, forkyState.data.validators[it].has_compounding_withdrawal_credential)
23562375

23572376
proc updateHead*(
23582377
dag: ChainDAGRef, newHead: BlockRef, quarantine: var Quarantine,
@@ -2393,7 +2412,9 @@ proc updateHead*(
23932412
lastHeadStateRoot = getStateRoot(dag.headState)
23942413
lastHeadMergeComplete = dag.headState.is_merge_transition_complete()
23952414
lastHeadKind = dag.headState.kind
2396-
lastKnownValidatorsChangeStatuses = getValidatorChangeStatuses(
2415+
lastKnownValidatorsChangeStatuses = getBlsToExecutionChangeStatuses(
2416+
dag.headState, knownValidators)
2417+
lastKnownCompoundingChangeStatuses = getCompoundingStatuses(
23972418
dag.headState, knownValidators)
23982419

23992420
# Start off by making sure we have the right state - updateState will try
@@ -2437,6 +2458,11 @@ proc updateHead*(
24372458
dag.headState, lastKnownValidatorsChangeStatuses):
24382459
dag.vanityLogs.onKnownBlsToExecutionChange()
24392460

2461+
if dag.vanityLogs.onKnownCompoundingChange != nil and
2462+
checkCompoundingChanges(
2463+
dag.headState, lastKnownCompoundingChangeStatuses):
2464+
dag.vanityLogs.onKnownCompoundingChange()
2465+
24402466
dag.db.putHeadBlock(newHead.root)
24412467

24422468
updateBeaconMetrics(dag.headState, dag.head.bid, cache)

beacon_chain/consensus_object_pools/consensus_manager.nim

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2018-2024 Status Research & Development GmbH
2+
# Copyright (c) 2018-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -221,23 +221,17 @@ proc updateExecutionClientHead*(
221221

222222
func getKnownValidatorsForBlsChangeTracking(
223223
self: ConsensusManager, newHead: BlockRef): seq[ValidatorIndex] =
224-
# Ensure that large nodes won't be overloaded by a nice-to-have, but
224+
# Ensure that large nodes won't be overwhelmed by a nice-to-have, but
225225
# inessential cosmetic feature.
226-
const MAX_CHECKED_INDICES = 64
227-
228-
if newHead.bid.slot.epoch >= self.dag.cfg.CAPELLA_FORK_EPOCH:
229-
var res = newSeqOfCap[ValidatorIndex](min(
230-
len(self.actionTracker.knownValidators), MAX_CHECKED_INDICES))
231-
for vi in self.actionTracker.knownValidators.keys():
232-
res.add vi
233-
if res.len >= MAX_CHECKED_INDICES:
234-
break
235-
res
236-
else:
237-
# It is not possible for any BLS to execution changes, for any validator,
238-
# to have been yet processed.
239-
# https://github.com/nim-lang/Nim/issues/19802
240-
(static(@[]))
226+
const MAX_CHECKED_INDICES = 32
227+
228+
var res = newSeqOfCap[ValidatorIndex](min(
229+
len(self.actionTracker.knownValidators), MAX_CHECKED_INDICES))
230+
for vi in self.actionTracker.knownValidators.keys():
231+
res.add vi
232+
if res.len >= MAX_CHECKED_INDICES:
233+
break
234+
res
241235
242236
proc updateHead*(self: var ConsensusManager, newHead: BlockRef) =
243237
## Trigger fork choice and update the DAG with the new head block

beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# beacon_chain
2-
# Copyright (c) 2022-2024 Status Research & Development GmbH
2+
# Copyright (c) 2022-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
66
# at your option. This file may not be copied, modified, or distributed except according to those terms.
77

88
{.push raises: [].}
99

10-
import
11-
std/os,
12-
chronicles
10+
import chronicles
11+
12+
from std/os import `/`
1313

1414
type
1515
LogProc = proc() {.gcsafe, raises: [].}
@@ -38,6 +38,10 @@ type
3838
# in case of chain reorgs around the upgrade.
3939
onUpgradeToElectra*: LogProc
4040

41+
# Gets displayed on a change to compounding for a validator known to the
42+
# known in a head block.
43+
onKnownCompoundingChange*: LogProc
44+
4145
# Created by https://beatscribe.com (beatscribe#1008 on Discord)
4246
# These need to be the main body of the log not to be reformatted or escaped.
4347

beacon_chain/nimbus_beacon_node.nim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,17 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
151151
onUpgradeToCapella: capellaColor,
152152
onKnownBlsToExecutionChange: capellaBlink,
153153
onUpgradeToDeneb: denebColor,
154-
onUpgradeToElectra: electraColor)
154+
onUpgradeToElectra: electraColor,
155+
onKnownCompoundingChange: electraBlink)
155156
of StdoutLogKind.NoColors:
156157
VanityLogs(
157158
onMergeTransitionBlock: bellatrixMono,
158159
onFinalizedMergeTransitionBlock: bellatrixMono,
159160
onUpgradeToCapella: capellaMono,
160161
onKnownBlsToExecutionChange: capellaMono,
161162
onUpgradeToDeneb: denebMono,
162-
onUpgradeToElectra: electraMono)
163+
onUpgradeToElectra: electraMono,
164+
onKnownCompoundingChange: electraMono)
163165
of StdoutLogKind.Json, StdoutLogKind.None:
164166
VanityLogs(
165167
onMergeTransitionBlock:
@@ -173,7 +175,9 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
173175
onUpgradeToDeneb:
174176
(proc() = notice "🐟 Proto-Danksharding is ON 🐟"),
175177
onUpgradeToElectra:
176-
(proc() = notice "🦒 Compounding is ON 🦒"))
178+
(proc() = notice "🦒 Compounding is available 🦒"),
179+
onKnownCompoundingChange:
180+
(proc() = notice "🦒 Compounding is activated 🦒"))
177181

178182
func getVanityMascot(consensusFork: ConsensusFork): string =
179183
case consensusFork

0 commit comments

Comments
 (0)