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 }}
|
||||
strategy:
|
||||
matrix:
|
||||
nim: [1.6.18, 2.0.14]
|
||||
nim: [2.0.14]
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@ -7,16 +7,17 @@ license = "MIT"
|
||||
skipDirs = @["tests"]
|
||||
|
||||
# Dependencies
|
||||
requires "secp256k1#2acbbdcc0e63002a013fff49f015708522875832" # >= 0.5.2 & < 0.6.0
|
||||
requires "protobuf_serialization#5a31137a82c2b6a989c9ed979bb636c7a49f570e" # >= 0.2.0 & < 0.3.0
|
||||
requires "nimcrypto >= 0.5.4"
|
||||
requires "bearssl == 0.2.5"
|
||||
requires "nim >= 2.0.14 & < 3.0.0"
|
||||
requires "secp256k1" # >= 0.5.2 & < 0.6.0
|
||||
requires "protobuf_serialization" # >= 0.2.0 & < 0.3.0
|
||||
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 "chronos >= 4.0.3 & < 4.1.0"
|
||||
requires "libp2p == 1.5.0"
|
||||
requires "metrics#cacfdc12454a0804c65112b9f4f50d1375208dcd"
|
||||
requires "stew >= 0.2.0"
|
||||
requires "stint#3236fa68394f1e3a06e2bc34218aacdd2d675923"
|
||||
requires "libp2p >= 1.5.0 & < 2.0.0"
|
||||
requires "metrics"
|
||||
requires "stew >= 0.2.0 & < 0.3.0"
|
||||
requires "stint >= 0.8.1 & < 0.9.0"
|
||||
requires "https://github.com/codex-storage/nim-datastore#a969b9799cb7fd2c2511b6820ded00bced141dea"
|
||||
requires "questionable >= 0.10.15 & < 0.11.0"
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
## https://github.com/ethereum/devp2p/blob/master/discv5/discv5-theory.md#sessions
|
||||
##
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
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
|
||||
## sort of moving window as votes expire after `IpVoteTimeout`.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[tables, options],
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import std/[tables, lists, options]
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
export tables, lists, options
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
## These messages get protobuf encoded, while in the spec they get RLP encoded.
|
||||
##
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[hashes, net],
|
||||
|
||||
@ -14,6 +14,7 @@ import
|
||||
stew/endians2,
|
||||
libp2p/routing_record,
|
||||
libp2p/signed_envelope,
|
||||
libp2p/protobuf/minprotobuf,
|
||||
"."/[messages, spr, node],
|
||||
../../../../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).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/hashes,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[sets, options],
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
## more requests will be needed for a lookup (adding bandwidth and latency).
|
||||
## This might be a concern for mobile devices.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
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.
|
||||
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.
|
||||
d.routingTable.randomNodes(maxAmount)
|
||||
|
||||
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
|
||||
## `pred` predicate function applied as filter on the nodes selected.
|
||||
d.routingTable.randomNodes(maxAmount, pred)
|
||||
|
||||
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
|
||||
## the nodes selected are filtered by provided `enrField`.
|
||||
d.randomNodes(maxAmount, proc(x: Node): bool = x.record.contains(enrField))
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
# * 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.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
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).
|
||||
# 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/strutils
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
# * 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.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options
|
||||
import std/sequtils
|
||||
|
||||
@ -19,7 +19,7 @@ import pkg/stew/byteutils
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import ./maintenance
|
||||
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).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[algorithm, times, sequtils, bitops, sets, options, tables],
|
||||
@ -555,7 +555,7 @@ proc nodeToRevalidate*(r: RoutingTable): Node =
|
||||
return b.nodes[^1]
|
||||
|
||||
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`
|
||||
## predicate function applied as filter on the nodes selected.
|
||||
var maxAmount = maxAmount
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
## - the one derived in the key-exchange started by the other node.
|
||||
## To alleviate this issue, we store two decryption keys in each session.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/options,
|
||||
@ -39,7 +39,7 @@ type
|
||||
|
||||
func makeKey(id: NodeId, address: Address): SessionKey =
|
||||
var pos = 0
|
||||
result[pos ..< pos+sizeof(id)] = toBytes(id)
|
||||
result[pos ..< pos+sizeof(id)] = toBytesBE(id)
|
||||
pos.inc(sizeof(id))
|
||||
case address.ip.family
|
||||
of IpAddressFamily.IpV4:
|
||||
@ -47,7 +47,7 @@ func makeKey(id: NodeId, address: Address): SessionKey =
|
||||
of IpAddressFamily.IpV6:
|
||||
result[pos ..< pos+sizeof(address.ip.address_v6)] = 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) =
|
||||
var value: array[3 * sizeof(AesKey), byte]
|
||||
|
||||
@ -287,7 +287,7 @@ suite "Discovery v5 Tests":
|
||||
await mainNode.closeWait()
|
||||
await testNode.closeWait()
|
||||
|
||||
proc testLookupTargets(fast: bool = false) {.async: (raises: [Exception]).} =
|
||||
proc testLookupTargets(fast: bool = false): Future[bool] {.async.} =
|
||||
const
|
||||
nodeCount = 17
|
||||
|
||||
@ -306,9 +306,9 @@ suite "Discovery v5 Tests":
|
||||
for t in nodes:
|
||||
if n != t:
|
||||
let pong = await n.ping(t.localNode)
|
||||
check pong.isOk()
|
||||
if pong.isErr():
|
||||
echo pong.error
|
||||
return false
|
||||
# check (await n.ping(t.localNode)).isOk()
|
||||
|
||||
for i in 1 ..< nodeCount:
|
||||
@ -318,16 +318,19 @@ suite "Discovery v5 Tests":
|
||||
let target = nodes[i]
|
||||
let discovered = await nodes[nodeCount-1].lookup(target.localNode.id, fast = fast)
|
||||
debug "Lookup result", target = target.localNode, discovered
|
||||
check discovered[0] == target.localNode
|
||||
if discovered[0] != target.localNode:
|
||||
return false
|
||||
|
||||
for node in nodes:
|
||||
await node.closeWait()
|
||||
|
||||
return true
|
||||
|
||||
test "Lookup targets":
|
||||
await testLookupTargets()
|
||||
check await testLookupTargets()
|
||||
|
||||
test "Lookup targets using traditional findNode":
|
||||
await testLookupTargets(fast = true)
|
||||
check await testLookupTargets(fast = true)
|
||||
|
||||
test "Resolve target":
|
||||
let
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user