diff --git a/beacon_chain/consensus_object_pools/block_pools_types.nim b/beacon_chain/consensus_object_pools/block_pools_types.nim index 0c3741636..b91c5246d 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types.nim @@ -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 diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 95ffff6ac..9964053d9 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -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) diff --git a/beacon_chain/consensus_object_pools/vanity_logs/blink-version.ans b/beacon_chain/consensus_object_pools/vanity_logs/bellatrix/blink.ans similarity index 100% rename from beacon_chain/consensus_object_pools/vanity_logs/blink-version.ans rename to beacon_chain/consensus_object_pools/vanity_logs/bellatrix/blink.ans diff --git a/beacon_chain/consensus_object_pools/vanity_logs/color-version.ans b/beacon_chain/consensus_object_pools/vanity_logs/bellatrix/color.ans similarity index 100% rename from beacon_chain/consensus_object_pools/vanity_logs/color-version.ans rename to beacon_chain/consensus_object_pools/vanity_logs/bellatrix/color.ans diff --git a/beacon_chain/consensus_object_pools/vanity_logs/text-version.txt b/beacon_chain/consensus_object_pools/vanity_logs/bellatrix/mono.txt similarity index 100% rename from beacon_chain/consensus_object_pools/vanity_logs/text-version.txt rename to beacon_chain/consensus_object_pools/vanity_logs/bellatrix/mono.txt diff --git a/beacon_chain/consensus_object_pools/vanity_logs/capella/blink.ans b/beacon_chain/consensus_object_pools/vanity_logs/capella/blink.ans new file mode 100644 index 000000000..cc5bec8ae --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/capella/blink.ans @@ -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  `$$$':$ :$ diff --git a/beacon_chain/consensus_object_pools/vanity_logs/capella/color.ans b/beacon_chain/consensus_object_pools/vanity_logs/capella/color.ans new file mode 100644 index 000000000..3e3ac5ae9 --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/capella/color.ans @@ -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  `$$$':$ :$ diff --git a/beacon_chain/consensus_object_pools/vanity_logs/capella/mono.txt b/beacon_chain/consensus_object_pools/vanity_logs/capella/mono.txt new file mode 100644 index 000000000..0d59d295a --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/capella/mono.txt @@ -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 `$$$' $ :$ diff --git a/beacon_chain/consensus_object_pools/vanity_logs/pandas.nim b/beacon_chain/consensus_object_pools/vanity_logs/pandas.nim deleted file mode 100644 index ce3756fd6..000000000 --- a/beacon_chain/consensus_object_pools/vanity_logs/pandas.nim +++ /dev/null @@ -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 diff --git a/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim new file mode 100644 index 000000000..0d2dcc4b5 --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim @@ -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") diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index a8d292c86..1e5a80aab 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -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,