Fix TRACE chronicles_log_level (#451)

This commit is contained in:
Mamy Ratsimbazafy 2019-09-23 17:00:10 +02:00 committed by GitHub
parent b100ceef56
commit a7a1f78499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 31 deletions

View File

@ -35,7 +35,8 @@
import # TODO - cleanup imports
algorithm, collections/sets, chronicles, math, options, sequtils, sets, tables,
../extras, ../ssz, ../beacon_node_types,
beaconstate, crypto, datatypes, digest, helpers, validator
beaconstate, crypto, datatypes, digest, helpers, validator,
state_transition_helpers
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/specs/core/0_beacon-chain.md#block-header
proc process_block_header*(
@ -263,14 +264,6 @@ proc processAttesterSlashings(state: var BeaconState, blck: BeaconBlock,
return false
return true
func get_attesting_indices(
state: BeaconState, attestations: openarray[PendingAttestation],
stateCache: var StateCache): HashSet[ValidatorIndex] =
result = initSet[ValidatorIndex]()
for a in attestations:
result = result.union(get_attesting_indices(
state, a.data, a.aggregation_bits, stateCache))
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#attestations
proc processAttestations*(
state: var BeaconState, blck: BeaconBlock, flags: UpdateFlags,

View File

@ -36,18 +36,14 @@ import # TODO - cleanup imports
algorithm, math, options, sequtils, tables,
stew/[bitseqs, bitops2], chronicles, json_serialization/std/sets,
../extras, ../ssz, ../beacon_node_types,
beaconstate, crypto, datatypes, digest, helpers, validator
beaconstate, crypto, datatypes, digest, helpers, validator,
state_transition_helpers
# Logging utilities
# --------------------------------------------------------
logScope: topics = "consens"
# TODO: gather all logging utilities
# from crypto, digest, etc in a single file
func shortLog(x: Checkpoint): string =
"(epoch: " & $x.epoch & ", root: \"" & shortLog(x.root) & "\")"
# Spec
# --------------------------------------------------------
@ -81,22 +77,6 @@ func get_matching_head_attestations(state: BeaconState, epoch: Epoch):
get_block_root_at_slot(state, get_attestation_data_slot(state, it.data))
)
func get_attesting_indices(
state: BeaconState, attestations: openarray[PendingAttestation],
stateCache: var StateCache): HashSet[ValidatorIndex] =
result = initSet[ValidatorIndex]()
for a in attestations:
result = result.union(get_attesting_indices(
state, a.data, a.aggregation_bits, stateCache))
func get_unslashed_attesting_indices*(
state: BeaconState, attestations: openarray[PendingAttestation],
stateCache: var StateCache): HashSet[ValidatorIndex] =
result = get_attesting_indices(state, attestations, stateCache)
for index in result:
if state.validators[index].slashed:
result.excl index
func get_attesting_balance(
state: BeaconState, attestations: seq[PendingAttestation],
stateCache: var StateCache): Gwei =

View File

@ -0,0 +1,40 @@
# beacon_chain
# Copyright (c) 2018-2019 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import
# Standard library
sets,
# Internals
./datatypes, ./digest, ./beaconstate
# Logging utilities
# --------------------------------------------------------
# TODO: gather all logging utilities
# from crypto, digest, etc in a single file
func shortLog*(x: Checkpoint): string =
"(epoch: " & $x.epoch & ", root: \"" & shortLog(x.root) & "\")"
# Helpers used in epoch transition and trace-level block transition
# --------------------------------------------------------
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/specs/core/0_beacon-chain.md#helper-functions-1
func get_attesting_indices*(
state: BeaconState, attestations: openarray[PendingAttestation],
stateCache: var StateCache): HashSet[ValidatorIndex] =
result = initSet[ValidatorIndex]()
for a in attestations:
result = result.union(get_attesting_indices(
state, a.data, a.aggregation_bits, stateCache))
func get_unslashed_attesting_indices*(
state: BeaconState, attestations: openarray[PendingAttestation],
stateCache: var StateCache): HashSet[ValidatorIndex] =
result = get_attesting_indices(state, attestations, stateCache)
for index in result:
if state.validators[index].slashed:
result.excl index