Skip to content

Commit

Permalink
Merge commit '7ec1521c52bdcbfe88a0b6da99b124f73b125b21' into dev/etan…
Browse files Browse the repository at this point in the history
…/lc-optsync

* commit '7ec1521c52bdcbfe88a0b6da99b124f73b125b21':
  use unsigned literals (#3717)
  Bump libp2p (#3709)
  remove unused imports in tests/ (#3713)
  • Loading branch information
etan-status committed Jun 8, 2022
2 parents ece4866 + 7ec1521 commit dfcd1d5
Show file tree
Hide file tree
Showing 29 changed files with 48 additions and 63 deletions.
8 changes: 4 additions & 4 deletions beacon_chain/rpc/rest_nimbus_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ type
proc toInfo(node: BeaconNode, peerId: PeerId): RestPeerInfo =
RestPeerInfo(
peerId: $peerId,
addrs: node.network.switch.peerStore.addressBook.get(peerId).toSeq().mapIt($it),
protocols: node.network.switch.peerStore.protoBook.get(peerId).toSeq(),
protoVersion: node.network.switch.peerStore.protoVersionBook.get(peerId),
agentVersion: node.network.switch.peerStore.agentBook.get(peerId)
addrs: node.network.switch.peerStore[AddressBook][peerId].mapIt($it),
protocols: node.network.switch.peerStore[ProtoBook][peerId],
protoVersion: node.network.switch.peerStore[ProtoVersionBook][peerId],
agentVersion: node.network.switch.peerStore[AgentBook][peerId]
)

proc toNode(v: PubSubPeer, backoff: Moment): RestPubSubPeer =
Expand Down
10 changes: 5 additions & 5 deletions beacon_chain/rpc/rest_node_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ proc getLastSeenAddress(node: BeaconNode, id: PeerId): string =
# TODO (cheatfate): We need to provide filter here, which will be able to
# filter such multiaddresses like `/ip4/0.0.0.0` or local addresses or
# addresses with peer ids.
let addrs = node.network.switch.peerStore.addressBook.get(id).toSeq()
let addrs = node.network.switch.peerStore[AddressBook][id]
if len(addrs) > 0:
$addrs[len(addrs) - 1]
else:
Expand Down Expand Up @@ -200,8 +200,8 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
state: peer.connectionState.toString(),
direction: peer.direction.toString(),
# Fields `agent` and `proto` are not part of specification
agent: node.network.switch.peerStore.agentBook.get(peer.peerId),
proto: node.network.switch.peerStore.protoVersionBook.get(peer.peerId)
agent: node.network.switch.peerStore[AgentBook][peer.peerId],
proto: node.network.switch.peerStore[ProtoVersionBook][peer.peerId]
)
res.add(peer)
return RestApiResponse.jsonResponseWMeta(res, (count: uint64(len(res))))
Expand Down Expand Up @@ -242,8 +242,8 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
last_seen_p2p_address: getLastSeenAddress(node, peer.peerId),
state: peer.connectionState.toString(),
direction: peer.direction.toString(),
agent: node.network.switch.peerStore.agentBook.get(peer.peerId), # Fields `agent` and `proto` are not
proto: node.network.switch.peerStore.protoVersionBook.get(peer.peerId) # part of specification
agent: node.network.switch.peerStore[AgentBook][peer.peerId], # Fields `agent` and `proto` are not
proto: node.network.switch.peerStore[ProtoVersionBook][peer.peerId] # part of specification
)
)

Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/sync/sync_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ proc getBlocks*[A, B](man: SyncManager[A, B], peer: A,
try:
let res =
if peer.useSyncV2():
await beaconBlocksByRange_v2(peer, req.slot, req.count, 1)
await beaconBlocksByRange_v2(peer, req.slot, req.count, 1'u64)
else:
(await beaconBlocksByRange(peer, req.slot, req.count, 1)).map(
(await beaconBlocksByRange(peer, req.slot, req.count, 1'u64)).map(
proc(blcks: seq[phase0.SignedBeaconBlock]): auto =
blcks.mapIt(newClone(ForkedSignedBeaconBlock.init(it))))

Expand Down
6 changes: 3 additions & 3 deletions beacon_chain/sync/sync_queue.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{.push raises: [Defect].}

import std/[options, heapqueue, tables, strutils, sequtils, math, algorithm]
import std/[options, heapqueue, tables, strutils, sequtils, math]
import stew/[results, base10], chronos, chronicles
import
../spec/datatypes/[base, phase0, altair],
Expand Down Expand Up @@ -134,8 +134,8 @@ proc checkResponse*[T](req: SyncRequest[T],
inc(dindex)
else:
return false
slot = slot + 1
rindex = rindex + 1'u64
slot += 1'u64
rindex += 1'u64

if dindex == len(data):
return true
Expand Down
1 change: 0 additions & 1 deletion tests/all_tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# All tests except scenarios, which as compiled separately for mainnet and minimal

import
chronicles,
./testutil

import # Unit test
Expand Down
3 changes: 0 additions & 3 deletions tests/consensus_spec/altair/all_altair_fixtures.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

{.used.}

import
chronicles

import
./test_fixture_fork,
./test_fixture_merkle_single_proof,
Expand Down
6 changes: 2 additions & 4 deletions tests/consensus_spec/altair/test_fixture_rewards.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2020-2021 Status Research & Development GmbH
# Copyright (c) 2020-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).
Expand All @@ -9,9 +9,7 @@

import
# Standard library
os,
# Utilities
stew/results,
std/os,
# Beacon chain internals
../../beacon_chain/spec/[beaconstate, validator, helpers, state_transition_epoch],
../../beacon_chain/spec/datatypes/altair,
Expand Down
1 change: 0 additions & 1 deletion tests/consensus_spec/altair/test_fixture_sanity_slots.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{.used.}

import
chronicles,
# Standard library
os, strutils,
# Beacon chain internals
Expand Down
1 change: 0 additions & 1 deletion tests/consensus_spec/altair/test_fixture_transition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import
# Standard library
os, sequtils,
# Status internal
chronicles,
faststreams, streams,
# Beacon chain internals
../../../beacon_chain/spec/[state_transition, forks, helpers],
Expand Down
6 changes: 2 additions & 4 deletions tests/consensus_spec/bellatrix/test_fixture_rewards.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2020-2021 Status Research & Development GmbH
# Copyright (c) 2020-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).
Expand All @@ -9,9 +9,7 @@

import
# Standard library
os,
# Utilities
stew/results,
std/os,
# Beacon chain internals
../../beacon_chain/spec/[beaconstate, validator, helpers, state_transition_epoch],
../../beacon_chain/spec/datatypes/[altair, bellatrix],
Expand Down
1 change: 0 additions & 1 deletion tests/consensus_spec/bellatrix/test_fixture_transition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import
# Standard library
std/[os, sequtils, strutils],
# Status internal
chronicles,
faststreams, streams,
# Beacon chain internals
../../../beacon_chain/spec/[state_transition, forks, helpers],
Expand Down
6 changes: 2 additions & 4 deletions tests/consensus_spec/phase0/test_fixture_rewards.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2020-2021 Status Research & Development GmbH
# Copyright (c) 2020-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).
Expand All @@ -9,9 +9,7 @@

import
# Standard library
os,
# Utilities
stew/results,
std/os,
# Beacon chain internals
../../beacon_chain/spec/[validator, helpers, state_transition_epoch],
../../beacon_chain/spec/datatypes/phase0,
Expand Down
7 changes: 3 additions & 4 deletions tests/slashing_protection/test_fixtures.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
Expand All @@ -9,10 +9,9 @@

import
# Standard library
std/[os],
std/os,
# Status lib
stew/[results, byteutils],
nimcrypto/utils,
chronicles,
# Internal
../../beacon_chain/validators/[slashing_protection, slashing_protection_v2],
Expand Down Expand Up @@ -264,4 +263,4 @@ suite "Slashing Interchange tests " & preset():
# rather than also checking the actual signing_root
skip()
else:
runTest(path)
runTest(path)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# 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).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
# Standard library
strformat, tables,
std/strformat,
# Specs
../../beacon_chain/spec/datatypes/phase0,
../../beacon_chain/spec/[beaconstate, validator, helpers],
Expand Down
3 changes: 1 addition & 2 deletions tests/test_block_dag.nim
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -8,7 +8,6 @@
{.used.}

import
chronicles,
unittest2,
../beacon_chain/consensus_object_pools/block_dag

Expand Down
4 changes: 2 additions & 2 deletions tests/test_block_processor.nim
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -8,7 +8,7 @@
{.used.}

import
chronicles, chronos,
chronos,
std/[options, sequtils],
unittest2,
eth/keys, taskpools,
Expand Down
1 change: 0 additions & 1 deletion tests/test_block_quarantine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{.used.}

import
chronicles,
unittest2,
../beacon_chain/spec/forks,
../beacon_chain/spec/datatypes/phase0,
Expand Down
2 changes: 0 additions & 2 deletions tests/test_blockchain_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
{.used.}

import
chronicles,
unittest2,
stew/assign2,
eth/keys, taskpools,
../beacon_chain/spec/datatypes/base,
../beacon_chain/spec/[beaconstate, forks, helpers, signatures, state_transition],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_engine_authentication.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{.used.}

import
std/[json, options, sequtils],
std/[json, sequtils],
unittest2,
../beacon_chain/spec/engine_authentication

Expand Down
5 changes: 2 additions & 3 deletions tests/test_exit_pool.nim
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# beacon_chain
# Copyright (c) 2020 Status Research & Development GmbH
# Copyright (c) 2020-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.

{.used.}

import chronicles, chronos
import eth/keys
import chronos
import ../beacon_chain/spec/[datatypes/base, forks, presets]
import ../beacon_chain/consensus_object_pools/[
block_quarantine, blockchain_dag, exit_pool]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import
std/sequtils,
# Status lib
unittest2,
chronicles, chronos,
chronos,
eth/keys, taskpools,
# Internal
../beacon_chain/[beacon_clock],
../beacon_chain/gossip_processing/[gossip_validation, batch_validation],
../beacon_chain/fork_choice/[fork_choice_types, fork_choice],
../beacon_chain/fork_choice/fork_choice,
../beacon_chain/consensus_object_pools/[
block_quarantine, blockchain_dag, block_clearance, attestation_pool,
sync_committee_msg_pool],
Expand Down
9 changes: 8 additions & 1 deletion tests/test_key_splitting.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# 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.

{.used.}

import
std/[json, typetraits, sequtils],
std/[typetraits, sequtils],
unittest2, eth/keys, stew/byteutils,
../beacon_chain/spec/[crypto, keystore],
./testutil
Expand Down
2 changes: 1 addition & 1 deletion tests/test_keymanager_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import
std/[typetraits, os, options, json, sequtils, uri, algorithm],
testutils/unittests, chronicles, stint, json_serialization, confutils,
chronos, eth/keys, blscurve, libp2p/crypto/crypto as lcrypto,
stew/[byteutils, io2], stew/shims/net, nimcrypto/utils,
stew/[byteutils, io2], stew/shims/net,

../beacon_chain/spec/[crypto, keystore, eth2_merkleization],
../beacon_chain/spec/datatypes/base,
Expand Down
1 change: 0 additions & 1 deletion tests/test_keystore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import
unittest2,
stew/byteutils, blscurve, eth/keys, json_serialization,
libp2p/crypto/crypto as lcrypto,
nimcrypto/utils as ncrutils,
../beacon_chain/spec/[crypto, keystore],
./testutil

Expand Down
3 changes: 1 addition & 2 deletions tests/test_keystore_management.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import
std/[os, options, json, typetraits, uri, algorithm],
unittest2, chronos, chronicles, stint, json_serialization,
blscurve, eth/keys, nimcrypto/utils,
blscurve, eth/keys,
libp2p/crypto/crypto as lcrypto,
stew/[io2, byteutils],
../beacon_chain/filepath,
../beacon_chain/networking/network_metadata,
../beacon_chain/spec/eth2_merkleization,
../beacon_chain/spec/datatypes/base,
../beacon_chain/spec/[crypto, keystore],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import
# Status libraries
chronicles, eth/keys, stew/objects, taskpools,
eth/keys, stew/objects, taskpools,
# Beacon chain internals
../beacon_chain/consensus_object_pools/
[block_clearance, block_quarantine, blockchain_dag],
Expand Down
5 changes: 2 additions & 3 deletions tests/test_remote_keystore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
{.used.}

import
std/[json, typetraits],
std/typetraits,
unittest2, json_serialization,
blscurve, eth/keys, libp2p/crypto/crypto as lcrypto,
nimcrypto/utils as ncrutils,
blscurve,
../beacon_chain/spec/[crypto, keystore],
./testutil

Expand Down
2 changes: 1 addition & 1 deletion tests/teststateutil.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{.push raises: [Defect].}

import
options, stew/endians2,
std/options,
./mocking/mock_deposits,
./helpers/math_helpers,
../beacon_chain/spec/[
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-libp2p

0 comments on commit dfcd1d5

Please sign in to comment.