Commit Graph

41 Commits

Author SHA1 Message Date
Csaba Kiraly 0d9118404e
addValue: use fast lookup
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:45:57 +02:00
Csaba Kiraly 5bc4bbffdf
fix ValueReplication counter
Number of replicas was ValueReplication+1 before.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:45:31 +02:00
Csaba Kiraly d7de86060c
implement findValue
retrieve a value from the DHT

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:45:20 +02:00
Csaba Kiraly bca26eb059
add ValueGetFrom count for naive getValue
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:43:37 +02:00
Csaba Kiraly 7c7cd29df1
add ValueReplication cound for addValue
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:43:30 +02:00
Csaba Kiraly cef43612ea
logging: GetValue error should be debug
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-09-05 08:43:18 +02:00
Csaba Kiraly fc7d04e3bb
add DHT storage (addValue/getValue) functionality
this is a minimal implementation, with lots of
work still needed.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 10:52:03 +02:00
Csaba Kiraly 13e48b8836
encoding: introducing type cipher=aes128
Introducing the cipher type to ease changing cipher.
No functional change

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:46 +02:00
Csaba Kiraly 5c62d100e4
dht: waitMessage: expose timeout as parameter, keeping default
defults to ResponseTimeout as before

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:46 +02:00
Csaba Kiraly 9f4cec415c
remove some debug output 2023-07-11 00:36:46 +02:00
Csaba Kiraly 52530b7569
fixup: move sendRequest forward
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:46 +02:00
Csaba Kiraly 94a7d01d7b
introduce waitResponse wrapper
initialize wait for response before sending request.
This is needed in cases where the response arrives before
moving to the next instruction, such as a directly connected
test.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:46 +02:00
Csaba Kiraly 9cd6af5afd
change revalidateLoop to use [RevalidateMax/2, RevalidateMax]
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:46 +02:00
Csaba Kiraly c1f39a89c9
improve tracing of message exchange
run e.g. as
```
nim c -r -d:debug -d:chronicles_enabled=on -d:chronicles_log_level=TRACE -d:chronicles_sinks=textlines[nocolors,stdout] tests/dht/test_providers.nim >err
```

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2023-07-11 00:36:45 +02:00
Csaba Kiraly f8523ae629
log routing table size periodically 2023-07-11 00:36:45 +02:00
Dmitriy Ryajov 4375b92298
use datastore `has` (#56) 2022-12-02 16:47:16 -06:00
Dmitriy Ryajov e4e7a3e11f
track nim-libp2p's unstable branch and nim-bearssl's master branch (#51)
* track nim-libp2p's unstable branch and nim-bearssl's master branch

refactor accordingly: mainly switching from `import bearssl` to
`import bearssl/rand`, `BrHmacDrbgContext` to `HmacDrbgContext`, and related
changes

* fix ambiguous identifier

* nim 1.4 is deprecated

Co-authored-by: Michael Bradley, Jr <michaelsbradleyjr@gmail.com>
2022-11-02 10:21:05 -06:00
Dmitriy Ryajov d6d255b4b5
Cleanups (#55)
* limit query to batchSize

* allow initializing node from ip and port

* misc cleanups
2022-10-31 22:41:33 -06:00
Dmitriy Ryajov 08928e57d8
Remove local providers (#53)
* refactor to use batch deletes

* add ability to remove local providers
2022-10-03 15:14:47 -06:00
Dmitriy Ryajov 4b9fa0356e
Adding maintenance routines to cleanup expired and orphaned records (#52)
* add maintenance routines and split out cache

* start provider manager

* export provider manager

* add maintenance tests

* start is now async
2022-10-01 10:05:03 -06:00
Dmitriy Ryajov 69ae7c2012
Persist providers (#49)
* initial providers manager implementation

* misc license update

* spelling

* rename provider tests

* add provider tests

* reexport provider manager

* only update provider record if it changed

* small bug in getProvByKey

* pass providers to both constructors

* fix records retrieval

* disable cache during tests

* avoid redefining data

* adding back tests with cache

* use `.errorOption`

* proper err msg unpacking
2022-09-29 17:49:55 -06:00
Dmitriy Ryajov 9dfa86767d Revert "track nim-libp2p's unstable branch and nim-bearssl's master branch"
This reverts commit c480fb5732.
2022-09-23 15:59:31 -06:00
Michael Bradley, Jr c480fb5732 track nim-libp2p's unstable branch and nim-bearssl's master branch
refactor accordingly: mainly switching from `import bearssl` to
`import bearssl/rand`, `BrHmacDrbgContext` to `HmacDrbgContext`, and related
changes
2022-09-19 20:05:34 -05:00
Dmitriy Ryajov 7c259731a4
add formating for SignedPeerRecord
needs to move to libp2
2022-09-13 12:01:36 -06:00
Dmitriy Ryajov f5afe784c5
prevent npe when table is 0 2022-09-12 21:08:55 -06:00
Dmitriy Ryajov f84bc647ce
don't touch the cache when checking for id 2022-09-12 21:08:26 -06:00
Dmitriy Ryajov 23e20a2f1c
bad merge 2022-09-12 18:41:44 -06:00
Dmitriy Ryajov fca255b2f7
use `pure` enums 2022-09-12 18:06:48 -06:00
Dmitriy Ryajov c646b9c2b9
providers LRU - avoid unchecked growth 2022-09-12 18:06:46 -06:00
Dmitriy Ryajov 2d93fa9e69
fix `updateRecord`
- support incrementing seqNo
- support updating with new record
2022-09-12 17:13:34 -06:00
Tanguy d90f0a03b9
Fixes for json logs 2022-09-12 17:13:33 -06:00
Tanguy bde7a26f9d
Fixes for integration 2022-09-12 17:13:33 -06:00
Tanguy f824c0a3cd
Remove nim-eth dependency (#37) 2022-04-08 12:13:14 +02:00
Michael Bradley, Jr faf5cad9d4 protobuf encoding for all message types 2022-04-07 14:47:35 -05:00
Eric Mastro 4c65f4bd94 chore: remove nim-eth/keys in favour of over to libp2p/crypto
Closes: #2.

Libp2p supports multiple cryptographic curves, however we have currently only implented support for secp256k1.

This needs to be run with the compiler flag `libp2p_pki_schemes` set to `secp256k1`. If running the tests, this can be run like so: `nimble test —libp2p_pki_schemes=secp256k1` to put secp as the first supported crypto scheme.
2022-04-07 14:11:48 -05:00
Csaba Kiraly 01488104e5 add "traditional" targetID based findNode message
This patch adds a findNode message sending the actual
target ID as in traditional Kademlia lookup. This in
contrast to the actual findNode message that send information
about the distance only, leading to more secure but slower lookups.

Having both primitives allows us to select which to use per use case.

Current naming is findNode for the distance based message and
findNodeFast for the message added in this patch.
2022-03-22 15:18:44 +01:00
Csaba Kiraly 4362c83a56 log improvements 2022-03-22 11:53:55 +01:00
Csaba Kiraly 7bef1e105f fix bootstrap: add node after successful handshake
Previous version was very conservative about adding nodes to the
routing table, requiring a full request/response message exchange
initiated by us.
Here we also add the node as 'seen' if the whoareyou/handshake
exchange was successful.
This significantly speeds up bootstreap from 0

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
2022-03-22 11:53:55 +01:00
Csaba Kiraly 9a01791e11 feat: Swap ENR to libp2p SignedPeerRecords
Swap all instances of Record with SignedPeerRecord.

Allow for `SignedPeerRecord`s to be updated by updating the first multiaddress in the `PeerRecord`. This also increments the `seqNo` in the `PeerRecord` only if the address was actually updated.
2022-03-22 11:00:26 +11:00
Eric Mastro b843c8823c feat: merge add/get providers with discv5
Merge the add/get providers messages with the discovery v5 messages inside of the discovery v5 code. Discovery v5 uses RLP encoding, while the add/get providers uses protobufs, as per the libp2p spec. The merge of these two uses RLP on the outer wrapper of the message, and a protobuf-encoded blob on the “inside” for the add/get providers messages only. Eventually this needs to change so that we use protobufs only.

There is still some code in the libp2pdht/dht directory, which is being read from the discovery v5 directory. Eventually these two should merge as well.
2022-03-17 14:56:54 +11:00
Eric Mastro acd03ff831 feat: reorg project to add nimble build system
Project has been updated to use nimble as a build system. All required dependencies have been added.

All nim-eth mirrored files were added to a private folder in the libp2pdht module. A libp2pdht/discv5 module was added to alias the nim-eth modules (which will change over time).

Test have been updated to use status-im/asynctest. This PR uses a branch of asynctest that supports async suite before/after. This seemed like the only the tests would work without throwing gcsafe errors.

All tests working.
2022-02-25 09:10:43 +11:00