Common utilities for Ethereum https://nimbus.status.im
Go to file
Jamie Lokier e4b4b7f4af
discv4: Fix Kademlia crash when trying to sync (#342)
Fixes status-im/nim-eth#341, status-im/nimbus-eth1#489.

When using discv4 (Kademlia) to find peers, there is a crash after a few
minutes.  It occurs for most of us on Eth1 mainnet, and everyone on Ropsten.

The cause is `findNodes` being called twice in succession to the same peer,
within about 5 seconds of each other.  ("About" 5 seconds, because Chronos does
not guarantee to run the timeout branch at a particular time, due to queuing
and clock reading delays.)

Then `findNodes` sends a duplicate message to the peer and calls
`waitNeighbours` to listen for the reply.  There's already a `waitNeighbours`
callback in a shared table, so that function hits an assert failure.

Ignoring the assert would be wrong as it would break timeout logic, and sending
`FindNodes` twice in rapid succession also makes us a bad peer.

As a simple workaround, just skip `findNodes` in this state and return a fake
empty `Neighbours` reply.  This is a bit of a hack as `findNodes` should not be
called like this; there's a logic error at a higher level.  But it works.

Tested for about 4 days constant operation on Ropsten.  The crash which occured
every few minutes no longer occurs, and discv4 keeps working.

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-04-02 23:29:02 +02:00
.github/workflows Add github actions timeout of 60 minutes (#328) 2021-02-17 15:43:05 +01:00
doc Use chronos http server for dcli metrics and remove insecure compile flag (#343) 2021-04-02 17:29:38 +02:00
eth discv4: Fix Kademlia crash when trying to sync (#342) 2021-04-02 23:29:02 +02:00
tests Nimble file cleanup and group discv5 tests to compile once (#340) 2021-03-29 15:26:34 +02:00
.appveyor.yml Fix enr deserialization crash + more tests + fuzz test (#274) 2020-07-11 01:28:53 +02:00
.gitignore use bearssl rng throughout (#265) 2020-07-07 10:56:26 +02:00
.travis.yml Fix enr deserialization crash + more tests + fuzz test (#274) 2020-07-11 01:28:53 +02:00
LICENSE-APACHEv2 Moved eth-common to eth 2019-02-05 12:10:36 +02:00
LICENSE-MIT Moved eth-common to eth 2019-02-05 12:10:36 +02:00
README.md add github action 2021-01-05 18:54:53 +07:00
eth.nimble Nimble file cleanup and group discv5 tests to compile once (#340) 2021-03-29 15:26:34 +02:00

README.md

eth - Eth Common Library

License: Apache License: MIT Stability: experimental Github action

Introduction

Ethereum-related utilities written in Nim. Includes things like Bloom filters, private/public key utilities, RLP, devp2p, and more.

Docs

Prerequisites

  • Nim & Nimble
  • RocksDB, SQLite, LMDB (required for the trie backend tests)

E.g. on Ubuntu one can run:

apt install -y librocksdb-dev liblmdb-dev sqlite3

Building & Testing

# Install required modules
nimble install
# Run full test suite
nimble test

You can also run specific parts of the test suite, e.g.:

# Test p2p functionality
nimble test_p2p
# Test rlp functionality
nimble test_rlp

Fuzzing

Next to the test suite, there are also several fuzzing test cases available. How these can be run is explained in the fuzzing readme.

License

Licensed and distributed under either of

or

at your option. This file may not be copied, modified, or distributed except according to those terms.