mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-19 09:58:03 +00:00
minimize imports, specially for spec - cuts 2/3 of ncli build time (#500)
* minimize imports, specially for spec - cuts 2/3 of ncli build time * ptr_arith->ptrops
This commit is contained in:
parent
700e7d921b
commit
ee5d1c1467
@ -9,11 +9,10 @@ import
|
||||
eth/trie/db, eth/trie/backends/rocksdb_backend, eth/async_utils,
|
||||
|
||||
# Local modules
|
||||
spec/[datatypes, digest, crypto, beaconstate, helpers, validator,
|
||||
state_transition_block, network],
|
||||
spec/[datatypes, digest, crypto, beaconstate, helpers, validator, network],
|
||||
conf, time, state_transition, fork_choice, ssz, beacon_chain_db,
|
||||
validator_pool, extras, attestation_pool, block_pool, eth2_network,
|
||||
beacon_node_types, mainchain_monitor, trusted_state_snapshots, version,
|
||||
beacon_node_types, mainchain_monitor, version,
|
||||
sync_protocol, request_manager, validator_keygen, interop, statusbar
|
||||
|
||||
const
|
||||
|
@ -1,6 +1,6 @@
|
||||
import
|
||||
sets, deques, tables, options,
|
||||
eth/keys, stew/[bitseqs, endians2],
|
||||
stew/[endians2],
|
||||
spec/[datatypes, crypto, digest],
|
||||
beacon_chain_db, conf, mainchain_monitor, eth2_network, time
|
||||
|
||||
@ -263,9 +263,3 @@ proc userValidatorsRange*(d: NetworkMetadata): HSlice[int, int] =
|
||||
|
||||
proc shortLog*(v: AttachedValidator): string = shortLog(v.pubKey)
|
||||
|
||||
proc 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
|
||||
cast[int64](uint64.fromBytes(hash.data[24..31], littleEndian))
|
||||
|
||||
|
@ -61,7 +61,6 @@ proc init*(T: type BlockPool, db: BeaconChainDB): BlockPool =
|
||||
var
|
||||
blocks = {tailRef.root: tailRef}.toTable()
|
||||
latestStateRoot = Option[Eth2Digest]()
|
||||
headStateBlock = tailRef
|
||||
headRef: BlockRef
|
||||
|
||||
if headRoot != tailRoot:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import
|
||||
os, options, strformat,
|
||||
confutils/defs, chronicles/options as chroniclesOptions,
|
||||
spec/[crypto, datatypes], time, version
|
||||
spec/[crypto]
|
||||
|
||||
export
|
||||
defs, enabledLogLevel
|
||||
|
@ -1,8 +1,8 @@
|
||||
import
|
||||
deques, math, options, sequtils, tables,
|
||||
deques, options, sequtils, tables,
|
||||
chronicles,
|
||||
./spec/[beaconstate, datatypes, crypto, digest, helpers, validator], extras,
|
||||
./attestation_pool, ./beacon_node_types, ./beacon_chain_db, ./ssz
|
||||
./spec/[datatypes, crypto, digest, helpers],
|
||||
./attestation_pool, ./beacon_node_types, ./ssz
|
||||
|
||||
proc get_ancestor(blck: BlockRef, slot: Slot): BlockRef =
|
||||
if blck.slot == slot:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import
|
||||
os, ospaths,
|
||||
stew/endians2, stint,
|
||||
./conf, ./extras, ./ssz,
|
||||
./extras, ./ssz,
|
||||
spec/[crypto, datatypes, digest, helpers]
|
||||
|
||||
func get_eth1data_stub*(deposit_count: uint64, current_epoch: Epoch): Eth1Data =
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
import
|
||||
sequtils,
|
||||
stew/[objects, byteutils], hashes, nimcrypto/utils,
|
||||
stew/[endians2, objects, byteutils], hashes, nimcrypto/utils,
|
||||
blscurve, json_serialization,
|
||||
../version, digest,
|
||||
chronicles
|
||||
@ -323,3 +323,9 @@ proc writeValue*(writer: var JsonWriter, value: Signature) {.inline.} =
|
||||
|
||||
proc readValue*(reader: var JsonReader, value: var Signature) {.inline.} =
|
||||
value = Signature.init(reader.readValue(string))
|
||||
|
||||
proc 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
|
||||
cast[int64](uint64.fromBytesLE(hash.data[24..31]))
|
||||
|
@ -18,7 +18,7 @@
|
||||
# types / composition
|
||||
|
||||
import
|
||||
macros, hashes, math, json, strutils, tables,
|
||||
macros, hashes, json, strutils, tables,
|
||||
stew/[byteutils, bitseqs], chronicles, eth/common,
|
||||
../version, ../ssz/types, ./crypto, ./digest
|
||||
|
||||
@ -644,6 +644,6 @@ static:
|
||||
# requires that SHARD_COUNT >= get_committee_count(...)
|
||||
doAssert SHARD_COUNT >= SLOTS_PER_EPOCH, "Shard count should match or exceed number of slots per epoch"
|
||||
|
||||
import nimcrypto, json_serialization
|
||||
import json_serialization
|
||||
export json_serialization
|
||||
export writeValue, readValue
|
||||
|
@ -9,12 +9,7 @@
|
||||
# serialization and spec updates.
|
||||
|
||||
import
|
||||
# Standard library
|
||||
math,
|
||||
# Third-party
|
||||
eth/common,
|
||||
# Internals
|
||||
../crypto, ../digest
|
||||
math
|
||||
|
||||
type
|
||||
Slot* = distinct uint64
|
||||
|
@ -9,12 +9,7 @@
|
||||
# serialization and spec updates.
|
||||
|
||||
import
|
||||
# Standard library
|
||||
math,
|
||||
# Third-party
|
||||
eth/common,
|
||||
# Internals
|
||||
../crypto, ../digest
|
||||
math
|
||||
|
||||
type
|
||||
Slot* = distinct uint64
|
||||
|
@ -33,8 +33,8 @@
|
||||
# now.
|
||||
|
||||
import # TODO - cleanup imports
|
||||
algorithm, collections/sets, chronicles, math, options, sequtils, sets, tables,
|
||||
../extras, ../ssz, ../beacon_node_types, metrics,
|
||||
algorithm, collections/sets, chronicles, options, sequtils, sets, tables,
|
||||
../extras, ../ssz, metrics,
|
||||
beaconstate, crypto, datatypes, digest, helpers, validator,
|
||||
state_transition_helpers
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
import # TODO - cleanup imports
|
||||
algorithm, math, options, sequtils, tables,
|
||||
stew/[bitseqs, bitops2], chronicles, json_serialization/std/sets,
|
||||
metrics, ../extras, ../ssz, ../beacon_node_types,
|
||||
metrics, ../ssz,
|
||||
beaconstate, crypto, datatypes, digest, helpers, validator,
|
||||
state_transition_helpers
|
||||
|
||||
@ -459,7 +459,7 @@ func get_crosslink_deltas*(state: BeaconState, cache: var StateCache):
|
||||
shard = (get_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
crosslink_committee =
|
||||
toSet(get_crosslink_committee(state, epoch, shard, cache))
|
||||
(winning_crosslink, attesting_indices) =
|
||||
(_, attesting_indices) =
|
||||
get_winning_crosslink_and_attesting_indices(
|
||||
state, epoch, shard, cache)
|
||||
attesting_balance = get_total_balance(state, attesting_indices)
|
||||
|
@ -7,9 +7,8 @@
|
||||
# Helpers and functions pertaining to managing the validator set
|
||||
|
||||
import
|
||||
options, nimcrypto, sequtils, math, tables, chronicles,
|
||||
../ssz,
|
||||
./crypto, ./datatypes, ./digest, ./helpers
|
||||
options, nimcrypto, sequtils, math, tables,
|
||||
./datatypes, ./digest, ./helpers
|
||||
|
||||
# TODO: Proceed to renaming and signature changes
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#compute_shuffled_index
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import
|
||||
endians, stew/shims/macros, options, algorithm, math, options,
|
||||
stew/[bitops2, bitseqs, objects, varints], stew/ranges/ptr_arith, stint,
|
||||
stew/[bitops2, bitseqs, objects, varints, ptrops], stint,
|
||||
faststreams/input_stream, serialization, serialization/testing/tracing,
|
||||
nimcrypto/sha2, blscurve, eth/common,
|
||||
./spec/[crypto, datatypes, digest],
|
||||
@ -343,7 +343,7 @@ func addChunk*(merkelizer: SszChunksMerkelizer, data: openarray[byte]) =
|
||||
if not getBitLE(merkelizer.totalChunks, 0):
|
||||
let chunkStartAddr = addr merkelizer.combinedChunks[0].data[0]
|
||||
copyMem(chunkStartAddr, unsafeAddr data[0], data.len)
|
||||
zeroMem(chunkStartAddr.shift(data.len), bytesPerChunk - data.len)
|
||||
zeroMem(chunkStartAddr.offset(data.len), bytesPerChunk - data.len)
|
||||
trs "WROTE BASE CHUNK ", merkelizer.combinedChunks[0]
|
||||
else:
|
||||
var hash = mergeBranches(merkelizer.combinedChunks[0], data)
|
||||
|
@ -31,9 +31,9 @@
|
||||
# now.
|
||||
|
||||
import
|
||||
algorithm, collections/sets, chronicles, math, options, sequtils, sets, tables,
|
||||
./extras, ./ssz, ./beacon_node_types, metrics,
|
||||
./spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
collections/sets, chronicles, math, options, sets, tables,
|
||||
./extras, ./ssz, metrics,
|
||||
./spec/[datatypes, digest, helpers, validator],
|
||||
./spec/[state_transition_block, state_transition_epoch]
|
||||
|
||||
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
|
||||
|
@ -1,8 +1,8 @@
|
||||
import
|
||||
options, tables, sequtils, algorithm, sets, macros,
|
||||
options, tables, sets, macros,
|
||||
chronicles, chronos, metrics, stew/ranges/bitranges,
|
||||
spec/[datatypes, crypto, digest, helpers], eth/rlp,
|
||||
beacon_node_types, eth2_network, beacon_chain_db, block_pool, time, ssz
|
||||
beacon_node_types, eth2_network, beacon_chain_db, block_pool, ssz
|
||||
|
||||
when networkBackend == rlpxBackend:
|
||||
import eth/rlp/options as rlpOptions
|
||||
|
@ -1,6 +1,6 @@
|
||||
import
|
||||
ospaths, chronos, json_serialization, strformat,
|
||||
spec/[datatypes, crypto, digest, beaconstate], beacon_chain_db, conf
|
||||
ospaths, chronos, json_serialization,
|
||||
spec/[datatypes], beacon_chain_db
|
||||
|
||||
const
|
||||
WEAK_SUBJECTVITY_PERIOD* =
|
||||
|
@ -1,8 +1,8 @@
|
||||
import
|
||||
confutils, ospaths, strutils, chronicles, json_serialization,
|
||||
nimcrypto/utils,
|
||||
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
../beacon_chain/[extras, state_transition, ssz]
|
||||
../beacon_chain/spec/[crypto, datatypes, digest],
|
||||
../beacon_chain/[ssz]
|
||||
|
||||
# TODO turn into arguments
|
||||
cli do(kind: string, file: string):
|
||||
|
@ -1,7 +1,7 @@
|
||||
import
|
||||
confutils, ospaths, strutils, chronicles, json_serialization,
|
||||
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
../beacon_chain/[extras, state_transition, ssz]
|
||||
../beacon_chain/spec/[crypto, datatypes, digest],
|
||||
../beacon_chain/[ssz]
|
||||
|
||||
# TODO turn into arguments
|
||||
cli do(kind: string, file: string):
|
||||
|
@ -1,8 +1,8 @@
|
||||
import
|
||||
confutils, ospaths, strutils, chronicles, json_serialization,
|
||||
nimcrypto/utils,
|
||||
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
../beacon_chain/[extras, state_transition, ssz]
|
||||
../beacon_chain/spec/[crypto, datatypes, digest],
|
||||
../beacon_chain/[ssz]
|
||||
|
||||
# TODO turn into arguments
|
||||
cli do(kind: string, file: string):
|
||||
|
@ -1,6 +1,6 @@
|
||||
import
|
||||
confutils, chronicles,
|
||||
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
../beacon_chain/spec/[crypto, datatypes],
|
||||
../beacon_chain/[extras, state_transition, ssz]
|
||||
|
||||
cli do(pre: string, blck: string, post: string, verifyStateRoot = false):
|
||||
|
@ -1 +1,2 @@
|
||||
hints:off
|
||||
-u:metrics
|
||||
|
@ -4,7 +4,7 @@ import
|
||||
options, sequtils, random, tables,
|
||||
../tests/[testutil],
|
||||
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, validator],
|
||||
../beacon_chain/[attestation_pool, extras, ssz, state_transition, fork_choice]
|
||||
../beacon_chain/[attestation_pool, extras, ssz]
|
||||
|
||||
type Timers = enum
|
||||
tBlock = "Process non-epoch slot with block"
|
||||
|
Loading…
x
Reference in New Issue
Block a user