cleanups: unused and duplicate imports, inconsistent naming conventions, URL updates (#3724)

This commit is contained in:
tersec 2022-06-09 14:30:13 +00:00 committed by GitHub
parent 9750a2a760
commit 65cecc50ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 24 additions and 28 deletions

View File

@ -8,9 +8,6 @@
{.push raises: [Defect].}
import
stew/results,
serialization,
eth/db/kvstore,
./spec/datatypes/[base, altair, bellatrix],
./spec/[eth2_ssz_serialization, eth2_merkleization]

View File

@ -490,7 +490,7 @@ func init(
if participation_bitmap[validator_index] != 0:
# If any flag got set, there was an attestation from this validator.
validator_bits[index_in_committee] = true
result.add((slot, committee_index.uint64), validator_bits)
result[(slot, committee_index.uint64)] = validator_bits
# This treats all types of rewards as equivalent, which isn't ideal
update_attestation_pool_cache(

View File

@ -21,11 +21,11 @@ export
eth2_merkleization, eth2_ssz_serialization,
block_pools_types, results, beacon_chain_db
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#interop-metrics
# https://github.com/ethereum/beacon-metrics/blob/master/metrics.md#interop-metrics
declareGauge beacon_head_root, "Root of the head block of the beacon chain"
declareGauge beacon_head_slot, "Slot of the head block of the beacon chain"
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#interop-metrics
# https://github.com/ethereum/beacon-metrics/blob/master/metrics.md#interop-metrics
declareGauge beacon_finalized_epoch, "Current finalized epoch" # On epoch transition
declareGauge beacon_finalized_root, "Current finalized root" # On epoch transition
declareGauge beacon_current_justified_epoch, "Current justified epoch" # On epoch transition
@ -542,7 +542,7 @@ proc currentSyncCommitteeForPeriod*(
proc updateBeaconMetrics(
state: ForkedHashedBeaconState, bid: BlockId, cache: var StateCache) =
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
# https://github.com/ethereum/beacon-metrics/blob/master/metrics.md#additional-metrics
# both non-negative, so difference can't overflow or underflow int64
beacon_head_root.set(bid.root.toGaugeValue)

View File

@ -352,10 +352,10 @@ proc getPartialState(
false
iterator getBlockIds*(
db: EraDB, historical_roots: openArray[Eth2Digest], startSlot: Slot): BlockId =
db: EraDB, historical_roots: openArray[Eth2Digest], start_slot: Slot): BlockId =
var
state = (ref PartialBeaconState)() # avoid stack overflow
slot = startSlot
slot = start_slot
while true:
# `case` ensures we're on a fork for which the `PartialBeaconState`

View File

@ -11,7 +11,7 @@ import
std/[deques, options, strformat, strutils, sequtils, tables,
typetraits, uri, json],
# Nimble packages:
chronos, json, metrics, chronicles/timings, stint/endians2,
chronos, metrics, chronicles/timings, stint/endians2,
web3, web3/ethtypes as web3Types, web3/ethhexstrings, web3/engine_api,
eth/common/eth_types,
eth/async_utils, stew/[byteutils, objects, shims/hashes],

View File

@ -103,7 +103,7 @@ func init*(T: type ProtoArray,
indices: {node.root: 0}.toTable()
)
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#configuration
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/fork-choice.md#configuration
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance
const PROPOSER_SCORE_BOOST* = 40
func calculateProposerBoost(validatorBalances: openArray[Gwei]): int64 =

View File

@ -330,7 +330,7 @@ proc runForkchoiceUpdated(
# block hash provided by this event is stubbed with
# `0x0000000000000000000000000000000000000000000000000000000000000000`."
# and
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/validator.md#executionpayload
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/validator.md#executionpayload
# notes "`finalized_block_hash` is the hash of the latest finalized execution
# payload (`Hash32()` if none yet finalized)"
if headBlockRoot.isZero:

View File

@ -170,7 +170,7 @@ type
MounterProc* = proc(network: Eth2Node) {.gcsafe, raises: [Defect, CatchableError].}
MessageContentPrinter* = proc(msg: pointer): string {.gcsafe, raises: [Defect].}
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#goodbye
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/p2p-interface.md#goodbye
DisconnectionReason* = enum
# might see other values on the wire!
ClientShutDown = 1

View File

@ -126,7 +126,7 @@ template init(T: type RestServerRef,
res.get()
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#interop-metrics
# https://github.com/ethereum/beacon-metrics/blob/master/metrics.md#interop-metrics
declareGauge beacon_slot, "Latest slot of the beacon chain state"
declareGauge beacon_current_epoch, "Current epoch"

View File

@ -512,7 +512,7 @@ proc is_valid_indexed_attestation*(
# Attestation validation
# ------------------------------------------------------------------------------------------
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/beacon-chain.md#attestations
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
func check_attestation_slot_target*(data: AttestationData): Result[Slot, cstring] =
if not (data.target.epoch == epoch(data.slot)):

View File

@ -126,5 +126,5 @@ proc readValue*(r: var JsonReader, a: var Eth2Digest) {.raises: [Defect, IOError
func toGaugeValue*(hash: Eth2Digest): int64 =
# Only the last 8 bytes are taken into consideration in accordance
# to the ETH2 metrics spec:
# https://github.com/ethereum/eth2.0-metrics/blob/6a79914cb31f7d54858c7dd57eee75b6162ec737/metrics.md#interop-metrics
# https://github.com/ethereum/beacon-metrics/blob/6a79914cb31f7d54858c7dd57eee75b6162ec737/metrics.md#interop-metrics
cast[int64](uint64.fromBytesLE(hash.data.toOpenArray(24, 31)))

View File

@ -1,4 +1,4 @@
# 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).
@ -9,7 +9,6 @@
import
std/strutils, chronicles, metrics,
chronos, chronos/apps/http/httpclient, presto, presto/client,
nimcrypto/utils as ncrutils,
serialization, json_serialization,
json_serialization/std/[options, net, sets],
stew/[results, base10, byteutils],

View File

@ -29,7 +29,7 @@ import nimcrypto/utils as ncrutils
export
results, burnMem, writeValue, readValue
{.localPassc: "-fno-lto".} # no LTO for crypto
{.localPassC: "-fno-lto".} # no LTO for crypto
type
KeystoreMode* = enum

View File

@ -84,13 +84,13 @@ func getAttestationTopic*(forkDigest: ForkDigest,
## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "beacon_attestation_" & $(subnetId) & "/ssz_snappy"
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/altair/p2p-interface.md#topics-and-messages
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/altair/p2p-interface.md#topics-and-messages
func getSyncCommitteeTopic*(forkDigest: ForkDigest,
subcommitteeIdx: SyncSubcommitteeIndex): string =
## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "sync_committee_" & $subcommitteeIdx & "/ssz_snappy"
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/altair/p2p-interface.md#topics-and-messages
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/altair/p2p-interface.md#topics-and-messages
func getSyncCommitteeContributionAndProofTopic*(forkDigest: ForkDigest): string =
## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "sync_committee_contribution_and_proof/ssz_snappy"

View File

@ -1038,23 +1038,23 @@ func process_inactivity_updates*(
proc process_epoch*(
cfg: RuntimeConfig, state: var phase0.BeaconState, flags: UpdateFlags,
cache: var StateCache, info: var phase0.EpochInfo): Result[void, cstring] =
let currentEpoch = get_current_epoch(state)
let current_epoch = get_current_epoch(state)
trace "process_epoch",
current_epoch = currentEpoch
current_epoch
init(info, state)
info.process_attestations(state, cache)
process_justification_and_finalization(state, info.balances, flags)
# state.slot hasn't been incremented yet.
if verifyFinalization in flags and currentEpoch >= 2:
doAssert state.current_justified_checkpoint.epoch + 2 >= currentEpoch
if verifyFinalization in flags and current_epoch >= 2:
doAssert state.current_justified_checkpoint.epoch + 2 >= current_epoch
if verifyFinalization in flags and currentEpoch >= 3:
if verifyFinalization in flags and current_epoch >= 3:
# Rule 2/3/4 finalization results in the most pessimal case. The other
# three finalization rules finalize more quickly as long as the any of
# the finalization rules triggered.
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
doAssert state.finalized_checkpoint.epoch + 3 >= current_epoch
process_rewards_and_penalties(state, info)
? process_registry_updates(cfg, state, cache)
@ -1115,7 +1115,7 @@ proc process_epoch*(
process_inactivity_updates(cfg, state, info) # [New in Altair]
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/beacon-chain.md#process_rewards_and_penalties
process_rewards_and_penalties(cfg, state, info)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/beacon-chain.md#registry-updates