display owl on Capella transition (#4442)

Trigger ANSI art on upgrade to Capella, similar to the merge.
Future extension could log blinking art when user successfully managed
to get BLS to Execution change included into a block for a validator.

Art created by http://beatscribe.com/ (beatscribe#1008 on Discord)
This commit is contained in:
Etan Kissling 2022-12-21 13:30:24 +01:00 committed by GitHub
parent 12b428e3d7
commit 2ac7609259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 160 additions and 36 deletions

View File

@ -25,7 +25,7 @@ import
from ../spec/datatypes/capella import TrustedSignedBeaconBlock
from ../spec/datatypes/eip4844 import TrustedSignedBeaconBlock
from "."/vanity_logs/pandas import VanityLogs
from "."/vanity_logs/vanity_logs import VanityLogs
export
options, sets, tables, hashes, helpers, beacon_chain_db, era_db, block_dag,
@ -211,10 +211,7 @@ type
## full ChainDAG.
vanityLogs*: VanityLogs
## Upon the merge activating, these get displayed, at least once when the
## head becomes post-merge and then when the merge is finalized. If chain
## reorgs happen around the initial merge onMergeTransitionBlock might be
## called several times.
## Logs for celebratory events, typically featuring ANSI art.
# -----------------------------------
# Light client data

View File

@ -1835,6 +1835,7 @@ proc updateHead*(
let
lastHeadStateRoot = getStateRoot(dag.headState)
lastHeadMergeComplete = dag.headState.is_merge_transition_complete()
lastHeadKind = dag.headState.kind
# Start off by making sure we have the right state - updateState will try
# to use existing in-memory states to make this smooth
@ -1856,6 +1857,16 @@ proc updateHead*(
dag.vanityLogs.onMergeTransitionBlock != nil:
dag.vanityLogs.onMergeTransitionBlock()
if dag.headState.kind > lastHeadKind:
case dag.headState.kind
of BeaconStateFork.Phase0 .. BeaconStateFork.Bellatrix:
discard
of BeaconStateFork.Capella:
if dag.vanityLogs.onUpgradeToCapella != nil:
dag.vanityLogs.onUpgradeToCapella()
of BeaconStateFork.EIP4844:
discard
dag.db.putHeadBlock(newHead.root)
updateBeaconMetrics(dag.headState, dag.head.bid, cache)

View File

@ -0,0 +1,31 @@
 ...
 ._. :
   $.. .%_...-  :
 . /{$$$b'   ./$#% < |
 : Q.  $b.  |/$$#% |  |
 :.`|%..  $b__....._____/$$#% .'^ .  |
 : `.%x. %%% %% .%%^  - -- - --+---
 | .)%:% $b%%%%%%%%%%%% .%   . |
| |%%%  ==$$%%%%%X__-=$'x%%%  |
  | d@%% .:::.`. .'.:::. %%% ...|
----+-- - -   :$%%x ::.::.d    ::.:: %%x  :
 |. :$%%% `::'d' .P `::' %%" . ---- - . . :
 |  :$%%%x.  .C'  d' %%";%. :.
 |  .  !%%%% ^  | .P' %Xx . % :
 :  : Q%%%%% `Q :
  :  . .  .: ."$##%. | . .
  .  | :     :d$##%% ^.d$%% . | | :
    || ::     |##%x ^ .$$$%%% . | || ::
  . ||| :::    d##%%%  ^ Q$$%%%%%    - -- ---+||| :::
  ||\\ //::    :$####%% .  Q$$$#%%%   ||\\ //::   .
  |\\\\ ////: - --d$##%%% ^   . Q$$$%%%  .   |\\\\ ////:
  .. \\ // ..   $$#%%%^ ^ Q$$%%x  .  .. \\ // ..
  `::.. ..:;'    .$$$##%% ^ .    $$%%%%  :   `::.. ..:;'
  `:: ::'    .$$BS22#%%% ^ . ~Q$%%%%  .   `:: ::'
 d b.$$$$$.$$$$$ $ 5 $$$b  $$$$b d$$$b d b $  d$$$$ d$$$b $b $
:$..:$..:$....:$..:$mmm$:$..:$:$..:$:$..:$:$..:$:$....:Q..........:$...$:$`$:$.
:$:$:$ :$ :$ :$"":$:$ :$:$""$b:$. :$:$:$:$:$`""$b :$. .$:$ `$$
 `$$$'.$$$$$ :$ :$  :$:$$$P':$ `$ `$$$' `$$$':$$$$$ `$$$P  `$$$':$ :$

View File

@ -0,0 +1,31 @@
 ...
 ._. :
   $.. .%_...-  :
 . /{$$$b'   ./$#% < |
 : Q.  $b.  |/$$#% |  |
 :.`|%..  $b__....._____/$$#% .'^ .  |
 : `.%x. %%% %% .%%^  - -- - --+---
 | .)%:% $b%%%%%%%%%%%% .%   . |
| |%%%  ==$$%%%%%X__-=$'x%%%  |
  | d@%% .:::.`. .'.:::. %%% ...|
----+-- - -   :$%%x ::.::.d    ::.:: %%x  :
 |. :$%%% `::'d' .P `::' %%" . ---- - . . :
 |  :$%%%x.  .C'  d' %%";%. :.
 |  .  !%%%% ^  | .P' %Xx . % :
 :  : Q%%%%% `Q :
  :  . .  .: ."$##%. | . .
  .  | :     :d$##%% ^.d$%% . | | :
    || ::     |##%x ^ .$$$%%% . | || ::
  . ||| :::    d##%%%  ^ Q$$%%%%%    - -- ---+||| :::
  ||\\ //::    :$####%% .  Q$$$#%%%   ||\\ //::   .
  |\\\\ ////: - --d$##%%% ^   . Q$$$%%%  .   |\\\\ ////:
  .. \\ // ..   $$#%%%^ ^ Q$$%%x  .  .. \\ // ..
  `::.. ..:;'    .$$$##%% ^ .    $$%%%%  :   `::.. ..:;'
  `:: ::'    .$$BS22#%%% ^ . ~Q$%%%%  .   `:: ::'
 d b.$$$$$.$$$$$ $ 5 $$$b  $$$$b d$$$b d b $  d$$$$ d$$$b $b $
:$..:$..:$....:$..:$mmm$:$..:$:$..:$:$..:$:$..:$:$....:Q..........:$...$:$`$:$.
:$:$:$ :$ :$ :$"":$:$ :$:$""$b:$. :$:$:$:$:$`""$b :$. .$:$ `$$
 `$$$'.$$$$$ :$ :$  :$:$$$P':$ `$ `$$$' `$$$':$$$$$ `$$$P  `$$$':$ :$

View File

@ -0,0 +1,31 @@
. . .
. _ . :
$.. . %_...- :
. /{$$$b' ./$#% < |
: Q. $b. |/$$#% | |
: . `|%.. $b__....._____/$$#% .'^ . |
: `.%x. %%% %% .%% ^ - -- - --+---
| .)%:% $b%%%%%%%%%%%% .% . |
| |%%% ==$$%%%%%X__-=$'x%%% |
| d@%% .:::.`. .'.:::. %%% . . . |
----+-- - - :$%%x ::.::.d ::.:: %%x :
| . :$%%% `::'d' .P `::' %%" . ---- - . . :
| :$%%%x. .C' d' %%";%. : .
| . !%%%% ^ | .P' %Xx . % :
: : Q%%%%% `Q :
: . . . : ."$##% . | . .
. | : :d$##%% ^ .d$%% . | | :
|| :: |##%x ^ . $$$%%% . | || ::
. ||| ::: d##%%% ^ Q$$%%%%% - -- ---+||| :::
||\\ //:: :$####%% . Q$$$#%%% ||\\ //:: .
|\\\\ ////: - --d$##%%% ^ . Q$$$%%% . |\\\\ ////:
.. \\ // .. $$#%%%^ ^ Q$$%%x . .. \\ // ..
`::.. ..:;' .$$$##%% ^ . $$%%%% : `::.. ..:;'
`:: ::' .$$BS22#%%% ^ . ~Q$%%%% . `:: ::'
d b $$$$$ $$$$$ $ 5 $$$b $$$$b d$$$b d b $ d$$$$ d$$$b $b $
$ $ $ $ $mmm$ $ $ $ $ $ $ $ $ $ Q. $ $ $`$ $
$ $ $ $ $ $"" $ $ $ $""$b $. $ $ $ $ $ `""$b $. .$ $ `$$
`$$$' $$$$$ $ $ $ $$$P' $ `$ `$$$' `$$$' $$$$$ `$$$P `$$$' $ :$

View File

@ -1,24 +0,0 @@
# beacon_chain
# Copyright (c) 2022 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).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronicles
type
VanityLogs* = object
onMergeTransitionBlock*: proc() {.gcsafe, raises: [Defect].}
onFinalizedMergeTransitionBlock*: proc() {.gcsafe, raises: [Defect].}
# Created by http://beatscribe.com/ (beatscribe#1008 on Discord)
# These need to be the main body of the log not to be reformatted or escaped.
proc mono🐼*() = notice "\n" & "text-version.txt".staticRead
proc color🐼*() = notice "\n" & "color-version.ans".staticRead
proc blink🐼*() = notice "\n" & "blink-version.ans".staticRead

View File

@ -0,0 +1,41 @@
# beacon_chain
# Copyright (c) 2022 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).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import
std/os,
chronicles
type
LogProc = proc() {.gcsafe, raises: [Defect].}
VanityLogs* = object
# Upon the merge activating, these get displayed, at least once when the
# head becomes post-merge and then when the merge is finalized. If chain
# reorgs happen around the initial merge onMergeTransitionBlock might be
# called several times.
onMergeTransitionBlock*: LogProc
onFinalizedMergeTransitionBlock*: LogProc
# Gets displayed on upgrade to Capella. May be displayed multiple times
# in case of chain reorgs around the upgrade.
onUpgradeToCapella*: LogProc
# Created by http://beatscribe.com/ (beatscribe#1008 on Discord)
# These need to be the main body of the log not to be reformatted or escaped.
proc mono🐼*() = notice "\n" & staticRead("bellatrix" / "mono.txt")
proc color🐼*() = notice "\n" & staticRead("bellatrix" / "color.ans")
proc blink🐼*() = notice "\n" & staticRead("bellatrix" / "blink.ans")
proc mono🦉*() = notice "\n" & staticRead("capella" / "mono.txt")
proc color🦉*() = notice "\n" & staticRead("capella" / "color.ans")
proc blink🦉*() = notice "\n" & staticRead("capella" / "blink.ans")

View File

@ -17,7 +17,7 @@ import
stew/[byteutils, io2],
eth/p2p/discoveryv5/[enr, random2],
eth/keys,
./consensus_object_pools/vanity_logs/pandas,
./consensus_object_pools/vanity_logs/vanity_logs,
./networking/topic_params,
./rpc/[rest_api, state_ttl_cache],
./spec/datatypes/[altair, bellatrix, phase0],
@ -115,21 +115,27 @@ declareGauge next_action_wait,
logScope: topics = "beacnde"
func getPandas(stdoutKind: StdoutLogKind): VanityLogs =
func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs =
case stdoutKind
of StdoutLogKind.Auto: raiseAssert "inadmissable here"
of StdoutLogKind.Colors:
VanityLogs(
onMergeTransitionBlock: color🐼,
onFinalizedMergeTransitionBlock: blink🐼)
onFinalizedMergeTransitionBlock: blink🐼,
onUpgradeToCapella: color🦉)
of StdoutLogKind.NoColors:
VanityLogs(
onMergeTransitionBlock: mono🐼,
onFinalizedMergeTransitionBlock: mono🐼)
onFinalizedMergeTransitionBlock: mono🐼,
onUpgradeToCapella: mono🦉)
of StdoutLogKind.Json, StdoutLogKind.None:
VanityLogs(
onMergeTransitionBlock: (proc() = notice "🐼 Proof of Stake Activated 🐼"),
onFinalizedMergeTransitionBlock: (proc() = notice "🐼 Proof of Stake Finalized 🐼"))
onMergeTransitionBlock:
(proc() = notice "🐼 Proof of Stake Activated 🐼"),
onFinalizedMergeTransitionBlock:
(proc() = notice "🐼 Proof of Stake Finalized 🐼"),
onUpgradeToCapella:
(proc() = notice "🦉 Withdrowls now available 🦉"))
proc loadChainDag(
config: BeaconNodeConf,
@ -161,7 +167,7 @@ proc loadChainDag(
else: nil
dag = ChainDAGRef.init(
cfg, db, validatorMonitor, extraFlags + chainDagFlags, config.eraDir,
vanityLogs = getPandas(detectTTY(config.logStdout)),
vanityLogs = getVanityLogs(detectTTY(config.logStdout)),
lcDataConfig = LightClientDataConfig(
serve: config.lightClientDataServe,
importMode: config.lightClientDataImportMode,