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