mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-01-02 13:33:08 +00:00
Merge pull request #105 from codex-storage/fix/deps/2.0-deps
fix(deps): remove deps pinned to commit hash
This commit is contained in:
commit
d435c6945f
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
nim: [1.6.18, 2.0.14]
|
nim: [2.0.14]
|
||||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@ -7,16 +7,17 @@ license = "MIT"
|
|||||||
skipDirs = @["tests"]
|
skipDirs = @["tests"]
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
requires "secp256k1#2acbbdcc0e63002a013fff49f015708522875832" # >= 0.5.2 & < 0.6.0
|
requires "nim >= 2.0.14 & < 3.0.0"
|
||||||
requires "protobuf_serialization#5a31137a82c2b6a989c9ed979bb636c7a49f570e" # >= 0.2.0 & < 0.3.0
|
requires "secp256k1" # >= 0.5.2 & < 0.6.0
|
||||||
requires "nimcrypto >= 0.5.4"
|
requires "protobuf_serialization" # >= 0.2.0 & < 0.3.0
|
||||||
requires "bearssl == 0.2.5"
|
requires "nimcrypto >= 0.6.2 & < 0.7.0"
|
||||||
|
requires "bearssl >= 0.2.5 & < 0.3.0"
|
||||||
requires "chronicles >= 0.10.2 & < 0.11.0"
|
requires "chronicles >= 0.10.2 & < 0.11.0"
|
||||||
requires "chronos >= 4.0.3 & < 4.1.0"
|
requires "chronos >= 4.0.3 & < 4.1.0"
|
||||||
requires "libp2p == 1.5.0"
|
requires "libp2p >= 1.5.0 & < 2.0.0"
|
||||||
requires "metrics#cacfdc12454a0804c65112b9f4f50d1375208dcd"
|
requires "metrics"
|
||||||
requires "stew >= 0.2.0"
|
requires "stew >= 0.2.0 & < 0.3.0"
|
||||||
requires "stint#3236fa68394f1e3a06e2bc34218aacdd2d675923"
|
requires "stint >= 0.8.1 & < 0.9.0"
|
||||||
requires "https://github.com/codex-storage/nim-datastore#a969b9799cb7fd2c2511b6820ded00bced141dea"
|
requires "https://github.com/codex-storage/nim-datastore#a969b9799cb7fd2c2511b6820ded00bced141dea"
|
||||||
requires "questionable >= 0.10.15 & < 0.11.0"
|
requires "questionable >= 0.10.15 & < 0.11.0"
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
## https://github.com/ethereum/devp2p/blob/master/discv5/discv5-theory.md#sessions
|
## https://github.com/ethereum/devp2p/blob/master/discv5/discv5-theory.md#sessions
|
||||||
##
|
##
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[hashes, net, options, sugar, tables],
|
std/[hashes, net, options, sugar, tables],
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
## To select the right address, a majority count is done. This is done over a
|
## To select the right address, a majority count is done. This is done over a
|
||||||
## sort of moving window as votes expire after `IpVoteTimeout`.
|
## sort of moving window as votes expire after `IpVoteTimeout`.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[tables, options],
|
std/[tables, options],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import std/[tables, lists, options]
|
import std/[tables, lists, options]
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
export tables, lists, options
|
export tables, lists, options
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
## These messages get protobuf encoded, while in the spec they get RLP encoded.
|
## These messages get protobuf encoded, while in the spec they get RLP encoded.
|
||||||
##
|
##
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[hashes, net],
|
std/[hashes, net],
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import
|
|||||||
stew/endians2,
|
stew/endians2,
|
||||||
libp2p/routing_record,
|
libp2p/routing_record,
|
||||||
libp2p/signed_envelope,
|
libp2p/signed_envelope,
|
||||||
|
libp2p/protobuf/minprotobuf,
|
||||||
"."/[messages, spr, node],
|
"."/[messages, spr, node],
|
||||||
../../../../dht/providers_encoding
|
../../../../dht/providers_encoding
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/hashes,
|
std/hashes,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[sets, options],
|
std/[sets, options],
|
||||||
|
|||||||
@ -71,7 +71,7 @@
|
|||||||
## more requests will be needed for a lookup (adding bandwidth and latency).
|
## more requests will be needed for a lookup (adding bandwidth and latency).
|
||||||
## This might be a concern for mobile devices.
|
## This might be a concern for mobile devices.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[tables, sets, options, math, sequtils, algorithm, strutils],
|
std/[tables, sets, options, math, sequtils, algorithm, strutils],
|
||||||
@ -236,18 +236,18 @@ proc getNode*(d: Protocol, id: NodeId): Option[Node] =
|
|||||||
## Get the node with id from the routing table.
|
## Get the node with id from the routing table.
|
||||||
d.routingTable.getNode(id)
|
d.routingTable.getNode(id)
|
||||||
|
|
||||||
proc randomNodes*(d: Protocol, maxAmount: int): seq[Node] {.raises: Exception.} =
|
proc randomNodes*(d: Protocol, maxAmount: int): seq[Node] =
|
||||||
## Get a `maxAmount` of random nodes from the local routing table.
|
## Get a `maxAmount` of random nodes from the local routing table.
|
||||||
d.routingTable.randomNodes(maxAmount)
|
d.routingTable.randomNodes(maxAmount)
|
||||||
|
|
||||||
proc randomNodes*(d: Protocol, maxAmount: int,
|
proc randomNodes*(d: Protocol, maxAmount: int,
|
||||||
pred: proc(x: Node): bool {.gcsafe, noSideEffect.}): seq[Node] {.raises: Exception.} =
|
pred: proc(x: Node): bool {.gcsafe, noSideEffect, raises: [].}): seq[Node] =
|
||||||
## Get a `maxAmount` of random nodes from the local routing table with the
|
## Get a `maxAmount` of random nodes from the local routing table with the
|
||||||
## `pred` predicate function applied as filter on the nodes selected.
|
## `pred` predicate function applied as filter on the nodes selected.
|
||||||
d.routingTable.randomNodes(maxAmount, pred)
|
d.routingTable.randomNodes(maxAmount, pred)
|
||||||
|
|
||||||
proc randomNodes*(d: Protocol, maxAmount: int,
|
proc randomNodes*(d: Protocol, maxAmount: int,
|
||||||
enrField: (string, seq[byte])): seq[Node] {.raises: Exception.} =
|
enrField: (string, seq[byte])): seq[Node] =
|
||||||
## Get a `maxAmount` of random nodes from the local routing table. The
|
## Get a `maxAmount` of random nodes from the local routing table. The
|
||||||
## the nodes selected are filtered by provided `enrField`.
|
## the nodes selected are filtered by provided `enrField`.
|
||||||
d.randomNodes(maxAmount, proc(x: Node): bool = x.record.contains(enrField))
|
d.randomNodes(maxAmount, proc(x: Node): bool = x.record.contains(enrField))
|
||||||
@ -563,7 +563,7 @@ proc ping*(d: Protocol, toNode: Node):
|
|||||||
dht_message_requests_outgoing.inc(labelValues = ["invalid_response"])
|
dht_message_requests_outgoing.inc(labelValues = ["invalid_response"])
|
||||||
return err("Invalid response to ping message")
|
return err("Invalid response to ping message")
|
||||||
else:
|
else:
|
||||||
# A ping (or the pong) was lost, what should we do? Previous implementation called
|
# A ping (or the pong) was lost, what should we do? Previous implementation called
|
||||||
# d.replaceNode(toNode) immediately, which removed the node. This is too aggressive,
|
# d.replaceNode(toNode) immediately, which removed the node. This is too aggressive,
|
||||||
# especially if we have a temporary network outage. Although bootstrap nodes are protected
|
# especially if we have a temporary network outage. Although bootstrap nodes are protected
|
||||||
# from being removed, everything else would slowly be removed.
|
# from being removed, everything else would slowly be removed.
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/strutils
|
import std/strutils
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import std/options
|
import std/options
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import pkg/stew/byteutils
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import ./maintenance
|
import ./maintenance
|
||||||
import ./cache
|
import ./cache
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[algorithm, times, sequtils, bitops, sets, options, tables],
|
std/[algorithm, times, sequtils, bitops, sets, options, tables],
|
||||||
@ -21,7 +21,7 @@ declarePublicGauge dht_routing_table_buckets,
|
|||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "discv5 routingtable"
|
topics = "discv5 routingtable"
|
||||||
|
|
||||||
type
|
type
|
||||||
DistanceProc* = proc(a, b: NodeId): NodeId {.raises: [Defect], gcsafe, noSideEffect.}
|
DistanceProc* = proc(a, b: NodeId): NodeId {.raises: [Defect], gcsafe, noSideEffect.}
|
||||||
LogDistanceProc* = proc(a, b: NodeId): uint16 {.raises: [Defect], gcsafe, noSideEffect.}
|
LogDistanceProc* = proc(a, b: NodeId): uint16 {.raises: [Defect], gcsafe, noSideEffect.}
|
||||||
@ -425,7 +425,7 @@ proc addNode*(r: var RoutingTable, n: Node): NodeStatus =
|
|||||||
(depth mod r.bitsPerHop != 0 and depth != ID_SIZE):
|
(depth mod r.bitsPerHop != 0 and depth != ID_SIZE):
|
||||||
r.splitBucket(r.buckets.find(bucket))
|
r.splitBucket(r.buckets.find(bucket))
|
||||||
return r.addNode(n) # retry adding
|
return r.addNode(n) # retry adding
|
||||||
|
|
||||||
# When bucket doesn't get split the node is added to the replacement cache
|
# When bucket doesn't get split the node is added to the replacement cache
|
||||||
return r.addReplacement(bucket, n)
|
return r.addReplacement(bucket, n)
|
||||||
|
|
||||||
@ -555,7 +555,7 @@ proc nodeToRevalidate*(r: RoutingTable): Node =
|
|||||||
return b.nodes[^1]
|
return b.nodes[^1]
|
||||||
|
|
||||||
proc randomNodes*(r: RoutingTable, maxAmount: int,
|
proc randomNodes*(r: RoutingTable, maxAmount: int,
|
||||||
pred: proc(x: Node): bool {.gcsafe, noSideEffect.} = nil): seq[Node] {.raises: Exception.} =
|
pred: proc(x: Node): bool {.gcsafe, noSideEffect, raises: [].} = nil): seq[Node] =
|
||||||
## Get a `maxAmount` of random nodes from the routing table with the `pred`
|
## Get a `maxAmount` of random nodes from the routing table with the `pred`
|
||||||
## predicate function applied as filter on the nodes selected.
|
## predicate function applied as filter on the nodes selected.
|
||||||
var maxAmount = maxAmount
|
var maxAmount = maxAmount
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
## - the one derived in the key-exchange started by the other node.
|
## - the one derived in the key-exchange started by the other node.
|
||||||
## To alleviate this issue, we store two decryption keys in each session.
|
## To alleviate this issue, we store two decryption keys in each session.
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/options,
|
std/options,
|
||||||
@ -39,7 +39,7 @@ type
|
|||||||
|
|
||||||
func makeKey(id: NodeId, address: Address): SessionKey =
|
func makeKey(id: NodeId, address: Address): SessionKey =
|
||||||
var pos = 0
|
var pos = 0
|
||||||
result[pos ..< pos+sizeof(id)] = toBytes(id)
|
result[pos ..< pos+sizeof(id)] = toBytesBE(id)
|
||||||
pos.inc(sizeof(id))
|
pos.inc(sizeof(id))
|
||||||
case address.ip.family
|
case address.ip.family
|
||||||
of IpAddressFamily.IpV4:
|
of IpAddressFamily.IpV4:
|
||||||
@ -47,7 +47,7 @@ func makeKey(id: NodeId, address: Address): SessionKey =
|
|||||||
of IpAddressFamily.IpV6:
|
of IpAddressFamily.IpV6:
|
||||||
result[pos ..< pos+sizeof(address.ip.address_v6)] = address.ip.address_v6
|
result[pos ..< pos+sizeof(address.ip.address_v6)] = address.ip.address_v6
|
||||||
pos.inc(sizeof(address.ip.address_v6))
|
pos.inc(sizeof(address.ip.address_v6))
|
||||||
result[pos ..< pos+sizeof(address.port)] = toBytes(address.port.uint16)
|
result[pos ..< pos+sizeof(address.port)] = toBytesBE(address.port.uint16)
|
||||||
|
|
||||||
func swapr*(s: var Sessions, id: NodeId, address: Address) =
|
func swapr*(s: var Sessions, id: NodeId, address: Address) =
|
||||||
var value: array[3 * sizeof(AesKey), byte]
|
var value: array[3 * sizeof(AesKey), byte]
|
||||||
|
|||||||
@ -287,7 +287,7 @@ suite "Discovery v5 Tests":
|
|||||||
await mainNode.closeWait()
|
await mainNode.closeWait()
|
||||||
await testNode.closeWait()
|
await testNode.closeWait()
|
||||||
|
|
||||||
proc testLookupTargets(fast: bool = false) {.async: (raises: [Exception]).} =
|
proc testLookupTargets(fast: bool = false): Future[bool] {.async.} =
|
||||||
const
|
const
|
||||||
nodeCount = 17
|
nodeCount = 17
|
||||||
|
|
||||||
@ -306,9 +306,9 @@ suite "Discovery v5 Tests":
|
|||||||
for t in nodes:
|
for t in nodes:
|
||||||
if n != t:
|
if n != t:
|
||||||
let pong = await n.ping(t.localNode)
|
let pong = await n.ping(t.localNode)
|
||||||
check pong.isOk()
|
|
||||||
if pong.isErr():
|
if pong.isErr():
|
||||||
echo pong.error
|
echo pong.error
|
||||||
|
return false
|
||||||
# check (await n.ping(t.localNode)).isOk()
|
# check (await n.ping(t.localNode)).isOk()
|
||||||
|
|
||||||
for i in 1 ..< nodeCount:
|
for i in 1 ..< nodeCount:
|
||||||
@ -318,16 +318,19 @@ suite "Discovery v5 Tests":
|
|||||||
let target = nodes[i]
|
let target = nodes[i]
|
||||||
let discovered = await nodes[nodeCount-1].lookup(target.localNode.id, fast = fast)
|
let discovered = await nodes[nodeCount-1].lookup(target.localNode.id, fast = fast)
|
||||||
debug "Lookup result", target = target.localNode, discovered
|
debug "Lookup result", target = target.localNode, discovered
|
||||||
check discovered[0] == target.localNode
|
if discovered[0] != target.localNode:
|
||||||
|
return false
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
await node.closeWait()
|
await node.closeWait()
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
test "Lookup targets":
|
test "Lookup targets":
|
||||||
await testLookupTargets()
|
check await testLookupTargets()
|
||||||
|
|
||||||
test "Lookup targets using traditional findNode":
|
test "Lookup targets using traditional findNode":
|
||||||
await testLookupTargets(fast = true)
|
check await testLookupTargets(fast = true)
|
||||||
|
|
||||||
test "Resolve target":
|
test "Resolve target":
|
||||||
let
|
let
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user