* 🐼

* rm panda refs outside core module; preprocess text/ANSI artwork sources

* credit artwork to beatscribe
This commit is contained in:
tersec 2022-05-30 08:25:27 +00:00 committed by GitHub
parent bf1763fdef
commit 01534b0431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 179 additions and 16 deletions

View File

@ -19,9 +19,11 @@ import
../validators/validator_monitor,
./block_dag, block_pools_types_light_client
from "."/vanity_logs/pandas import VanityLogs
export
options, sets, tables, hashes, helpers, beacon_chain_db, era_db, block_dag,
block_pools_types_light_client, validator_monitor
block_pools_types_light_client, validator_monitor, VanityLogs
# ChainDAG and types related to forming a DAG of blocks, keeping track of their
# relationships and allowing various forms of lookups
@ -200,6 +202,12 @@ type
## value with other components which don't have access to the
## 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.
# -----------------------------------
# Data to enable light clients to stay in sync with the network

View File

@ -663,7 +663,8 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
onLCFinalityUpdateCb: OnLightClientFinalityUpdateCallback = nil,
onLCOptimisticUpdateCb: OnLightClientOptimisticUpdateCallback = nil,
serveLightClientData = false,
importLightClientData = ImportLightClientData.None): ChainDAGRef =
importLightClientData = ImportLightClientData.None,
vanityLogs = default(VanityLogs)): ChainDAGRef =
# TODO move fork version sanity checking elsewhere?
let forkVersions =
[cfg.GENESIS_FORK_VERSION, cfg.ALTAIR_FORK_VERSION,
@ -705,6 +706,8 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
updateFlags: {verifyFinalization} * updateFlags,
cfg: cfg,
vanityLogs: vanityLogs,
serveLightClientData: serveLightClientData,
importLightClientData: importLightClientData,
@ -1547,8 +1550,16 @@ proc updateHead*(
error "Cannot update head to block without parent"
return
template getHeadStateMergeComplete(): bool =
withState(dag.headState):
when stateFork >= BeaconStateFork.Bellatrix:
is_merge_transition_complete(state.data)
else:
false
let
lastHeadStateRoot = getStateRoot(dag.headState)
lastHeadMergeComplete = getHeadStateMergeComplete()
# Start off by making sure we have the right state - updateState will try
# to use existing in-memory states to make this smooth
@ -1562,8 +1573,12 @@ proc updateHead*(
fatal "Unable to load head state during head update, database corrupt?",
lastHead = shortLog(lastHead)
quit 1
dag.head = newHead
if getHeadStateMergeComplete() and not lastHeadMergeComplete:
dag.vanityLogs.onMergeTransitionBlock()
dag.db.putHeadBlock(newHead.root)
updateBeaconMetrics(dag.headState, dag.head.bid, cache)
@ -1659,6 +1674,10 @@ proc updateHead*(
dag.db.updateFinalizedBlocks(newFinalized)
if oldFinalizedHead.blck.executionBlockRoot.isZero and
not dag.finalizedHead.blck.executionBlockRoot.isZero:
dag.vanityLogs.onFinalizedMergeTransitionBlock()
# Pruning the block dag is required every time the finalized head changes
# in order to clear out blocks that are no longer viable and should
# therefore no longer be considered as part of the chain we're following

View File

@ -0,0 +1,31 @@
.
.: ___
 ` ___ :._ \.\\ ) ) .
\\ .)`\ )\ \ \ ./') / ; ;
)`/  `\/ (''('('/ '` (.__/\
 ./'' dMb  " " " ,mMm   /
  . (  d;::`bmd""""""""""""bd':::`. (' .
. \ {::::;.;;;)  ) .
 ../: } `;;' .:::. .::::. ;.;'  { . \.   .
 `.// \\ {' d'' ::(*): :(*):: \.  `}// \\   ;
)\ . (e`\ /'; \ |:::::' `:::::| ./'{ /' ) /(
` / /' ; \th(.{ } |`::;'______`:::'| { \^/'  / /^'\ \ ,
 ; ( ( (| `)\ \`\' |`" :_ _; "'| ` /' { / ( ( ( ;
 /| `.`\ \`\| `\) ` `b||d' '\`\ \`.\ \.
( `\. \ `\) .  md$n`-_+'`+_-'d$b.'  (/' / ./' )
 \. `\ |  ; .  ...;;;;;;` m `=='m ' ;;;..  .  | /' ./
 ` \. `' .;;;;;:::;:::;::::.......;::::::::::::;;;.   '' ./ .
 ; \ `. .::;::::;:'' """""""""""""""" `:::;:::'.   / ;
 ( \/'/:::::;:::'    . . `:::;:;::\  :  `\/ )
 :  \  ./;:::;::::' mm.   | :  .mm: `::;:;:;:;    . /
  . .'./;;:::Mmmm;;;;;/'::|   || :: |:: \_:::::mmm:::";\  .  b`. .
  /\ ;n  |::::::::;:`"""::;:/   ||| ::: \::::'"""'::;:;;:;:|   ea; /
{ `'i  |::;::::;::::;:;::{   ||\\ //::  };;::;:::;:;;::;::| ' `t'',
 ./ . m'   `::::;::::;::::;:;\  |\\\\ ////:  /::::;:::;::::::::;`;sc(
} b.  .  """mm:::::::::::\_} .. \\ // .. {_::::::::::::mm""" . .  `ri)
/ .:/ us.. .' . """"mmmmPQ._:) `::.. ..:;' (-:::QPmmmm""" .: .  . ; `be
  `' `:: ::'  `"
 QM$Mb .d$b. .d$b. .d$b. .d$b. $$$$$ $\ /$ $: $$ .d$b. $$$$$ $$$$$ $$$b. d$P
 |: d$ $: $$ $b."P $: $$ $: "" [$: [$: Q$:$P $: $$  [$: $P.. $: Q$ .$$;
 Pb"' $: $$ `""b. $$22$ $: mm [$:  [$: Q$P $$$$$ [$: $b"" $: d$ `$:
 |$b `Q$P' `MpM; $: $$ `Q$P' [$: $$$$$ `$' $: $$ [$: $$ETH $$$$' mm

View File

@ -0,0 +1,31 @@
.
.: ___
 ` ___ :._ \.\\ ) ) .
\\ .)`\ )\ \ \ ./') / ; ;
)`/  `\/ (''('('/ '` (.__/\
 ./'' dMb  " " " ,mMm   /
  . (  d;::`bmd""""""""""""bd':::`. (' .
. \ {::::;.;;;)  ) .
 ../: } `;;' .:::. .::::. ;.;'  { . \.   .
 `.// \\ {' d'' ::(*): :(*):: \.  `}// \\   ;
)\ . (e`\ /'; \ |:::::' `:::::| ./'{ /' ) /(
` / /' ; \th(.{ } |`::;'______`:::'| { \^/'  / /^'\ \ ,
 ; ( ( (| `)\ \`\' |`" :_ _; "'| ` /' { / ( ( ( ;
 /| `.`\ \`\| `\) ` `b||d' '\`\ \`.\ \.
( `\. \ `\) .  md$n`-_+'`+_-'d$b.'  (/' / ./' )
 \. `\ |  ; .  ...;;;;;;` m `=='m ' ;;;..  .  | /' ./
 ` \. `' .;;;;;:::;:::;::::.......;::::::::::::;;;.   '' ./ .
 ; \ `. .::;::::;:'' """""""""""""""" `:::;:::'.   / ;
 ( \/'/:::::;:::'    . . `:::;:;::\  :  `\/ )
 :  \  ./;:::;::::' mm.   | :  .mm: `::;:;:;:;    . /
  . .'./;;:::Mmmm;;;;;/'::|   || :: |:: \_:::::mmm:::";\  .  b`. .
  /\ ;n  |::::::::;:`"""::;:/   ||| ::: \::::'"""'::;:;;:;:|   ea; /
{ `'i  |::;::::;::::;:;::{   ||\\ //::  };;::;:::;:;;::;::| ' `t'',
 ./ . m'   `::::;::::;::::;:;\  |\\\\ ////:  /::::;:::;::::::::;`;sc(
} b.  .  """mm:::::::::::\_} .. \\ // .. {_::::::::::::mm""" . .  `ri)
/ .:/ us.. .' . """"mmmmPQ._:) `::.. ..:;' (-:::QPmmmm""" .: .  . ; `be
  `' `:: ::'  `"
 QM$Mb .d$b. .d$b. .d$b. .d$b. $$$$$ $\ /$ $: $$ .d$b. $$$$$ $$$$$ $$$b. d$P
 |: d$ $: $$ $b."P $: $$ $: "" [$: [$: Q$:$P $: $$  [$: $P.. $: Q$ .$$;
 Pb"' $: $$ `""b. $$22$ $: mm [$:  [$: Q$P $$$$$ [$: $b"" $: d$ `$:
 |$b `Q$P' `MpM; $: $$ `Q$P' [$: $$$$$ `$' $: $$ [$: $$ETH $$$$' mm

View File

@ -0,0 +1,38 @@
# 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.
{.push raises: [Defect].}
import chronicles
from ".."/".."/conf import StdoutLogKind
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 "text-version.txt".staticRead
proc color🐼() = notice "color-version.ans".staticRead
proc blink🐼() = notice "blink-version.ans".staticRead
func getPandas*(stdoutKind: StdoutLogKind): VanityLogs =
case stdoutKind
of StdoutLogKind.Auto: raiseAssert "inadmissable here"
of StdoutLogKind.Colors:
VanityLogs(
onMergeTransitionBlock: color🐼,
onFinalizedMergeTransitionBlock: blink🐼)
of StdoutLogKind.NoColors:
VanityLogs(
onMergeTransitionBlock: mono🐼,
onFinalizedMergeTransitionBlock: mono🐼)
of StdoutLogKind.Json, StdoutLogKind.None:
VanityLogs(
onMergeTransitionBlock: (proc() = notice "🐼 Proof of Stake Activated 🐼"),
onFinalizedMergeTransitionBlock: (proc() = notice "🐼 Proof of Stake Finalized 🐼"))

View File

@ -0,0 +1,31 @@
.
. : ___
` ___ :._ \. \\ ) ) .
\\ .)`\ )\ \ \ ./') / ; ;
)`/ `\/ (''('('/ '` (.__/\
. /'' dMb " " " ,mMm /
. ( d;::`bmd""""""""""""bd':::`. (' .
. \ {::::; .;;;) ) .
. ./: } `;;' .:::. .::::. ;.;' { . \. .
`. // \\ {' d'' ::(*): :(*):: \. `}// \\ ;
)\ . (e`\ /'; \ | :::::' `::::: | ./'{ /' ) /(
` / /' ; \th(.{ } | `::;'______`:::' | { \^/' / /^'\ \ ,
; ( ( (| `)\ \`\' | `" :_ _; "' | ` /' { / ( ( ( ;
/| `.`\ \`\| `\) ` `b || d' ' \`\ \`.\ \.
( `\. \ `\) . md$n `-_+'`+_-' d$b. ' (/' / ./' )
\. `\ | ; . ...;;;;;;` m `==' m ' ;;;.. . | /' ./
` \. `' .;;;;;:::;:::;::::.......;::::::::::::;;;. '' ./ .
; \ `. .::;::::;:'' """""""""""""""" `:::;:::'. / ;
( \/' /:::::;:::' . . `:::;:;::\ : `\/ )
: \ . /;:::;::::' mm. | : .mm: `::;:;:;:; . /
. .'. /;;:::Mmmm;;;;;/'::| || :: |:: \_:::::mmm:::";\ . b`. .
/\ ;n |::::::::;:`"""::;:/ ||| ::: \::::'"""'::;:;;:;:| ea; /
{ `'i |::;::::;::::;:;::{ ||\\ //:: };;::;:::;:;;::;::| ' `t'',
./ . m' `::::;::::;::::;:;\ |\\\\ ////: /::::;:::;::::::::;` ;sc(
} b. . """mm:::::::::::\_} .. \\ // .. {_::::::::::::mm""" . . `ri)
/ .:/ us.. .' . """"mmmmPQ._:) `::.. ..:;' (-:::QPmmmm""" .: . . ; `be
`' `:: ::' `"
QM$Mb .d$b. .d$b. .d$b. .d$b. $$$$$ $\ /$ $: $$ .d$b. $$$$$ $$$$$ $$$b. d$P
|: d$ $: $$ $b."P $: $$ $: "" [$: [$: Q$:$P $: $$ [$: $P.. $: Q$ .$$;
Pb"' $: $$ `""b. $$22$ $: mm [$: [$: Q$P $$$$$ [$: $b"" $: d$ `$:
|$b `Q$P' `MpM; $: $$ `Q$P' [$: $$$$$ `$' $: $$ [$: $$ETH $$$$' mm

View File

@ -30,6 +30,8 @@ from
import
TopicParams, validateParameters, init
from consensus_object_pools/vanity_logs/pandas import getPandas
when defined(windows):
import winlean
@ -179,7 +181,8 @@ proc loadChainDag(
onLCFinalityUpdateCb = onLightClientFinalityUpdateCb,
onLCOptimisticUpdateCb = onLightClientOptimisticUpdateCb,
serveLightClientData = config.serveLightClientData.get,
importLightClientData = config.importLightClientData.get)
importLightClientData = config.importLightClientData.get,
vanityLogs = getPandas(detectTTY(config.logStdout)))
databaseGenesisValidatorsRoot =
getStateField(dag.headState, genesis_validators_root)

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-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).
@ -83,6 +83,19 @@ proc updateLogLevel*(logLevel: string) {.raises: [Defect, ValueError].} =
if not setTopicState(topicName, settings.state, settings.logLevel):
warn "Unrecognized logging topic", topic = topicName
proc detectTTY*(stdoutKind: StdoutLogKind): StdoutLogKind =
if stdoutKind == StdoutLogKind.Auto:
if isatty(stdout):
# On a TTY, let's be fancy
StdoutLogKind.Colors
else:
# When there's no TTY, we output no colors because this matches what
# released binaries were doing before auto-detection was around and
# looks decent in systemd-captured journals.
StdoutLogKind.NoColors
else:
stdoutKind
proc setupLogging*(
logLevel: string, stdoutKind: StdoutLogKind, logFile: Option[OutFile]) =
# In the cfg file for nimbus, we create two formats: textlines and json.
@ -135,18 +148,7 @@ proc setupLogging*(
defaultChroniclesStream.outputs[1].writer = fileWriter
let tmp =
if stdoutKind == StdoutLogKind.Auto:
if isatty(stdout):
# On a TTY, let's be fancy
StdoutLogKind.Colors
else:
# When there's no TTY, we output no colors because this matches what
# released binaries were doing before auto-detection was around and
# looks decent in systemd-captured journals.
StdoutLogKind.NoColors
else:
stdoutKind
let tmp = detectTTY(stdoutKind)
case tmp
of StdoutLogKind.Auto: raiseAssert "checked above"