Commit Graph

301 Commits

Author SHA1 Message Date
KonradStaniec 2556b090ea
Add user data to utp (#525) 2022-08-12 15:09:59 +02:00
KonradStaniec 883825aad7
Make discv5 timeouts configurable (#523) 2022-08-05 15:19:16 +02:00
KonradStaniec a5ea6a9a90
Add connection limits to utp (#522) 2022-08-04 15:55:39 +02:00
tersec 92b14b43eb
--styleCheck:error (#520)
* --styleCheck:error

* testcase -> testCase

* more testcase -> testCase

* remove unused imports

* MessageKind enum name consistency in tests

* rest of fuzz_decode_message

* rlpEncodeEIP155 -> rlpEncodeEip155
2022-07-21 08:58:17 +00:00
KonradStaniec cbb233d8a9
Increase tests speed to avoid hangs (#511) 2022-07-11 08:24:03 +02:00
Kim De Mey 9d7e4b031a
Clean-up of several compiler warnings (#519) 2022-07-09 10:55:15 +02:00
Kim De Mey 7cc3c59ff1
Clean-up bootnodes.nim (#518)
- Remove Waku/Whisper Status bootstrap nodes as this is no longer
part of nim-eth
- Update bootstrap nodes according to latest data in go-ethereum
2022-07-08 20:32:41 +02:00
Miran 5c0893bfb6
move -d:nimRawSetjmp to nim.cfg (#513)
* move -d:nimRawSetjmp to nim.cfg

Refs https://github.com/status-im/nimbus-build-system/issues/44
2022-06-21 16:25:42 +02:00
oskarth 44cb2256fd
Delete Whisper remains (moved to nim-waku) (#386)
Types, protocols, tests, hardcoded nodes, references.

Now part of nim-waku:
- https://github.com/status-im/nim-waku/pull/663
- https://github.com/status-im/nim-waku/pull/678
2022-06-20 19:10:50 +03:00
Jacek Sieka 1b516682bd
bearssl: use split api (#510) 2022-06-17 22:45:37 +02:00
KonradStaniec dacf827a86
Add custom scalar functions to sqlite (#509) 2022-06-02 14:14:15 +02:00
KonradStaniec dffaa78cbe
Install cancel callback on whole connection future (#508) 2022-05-30 10:28:10 +02:00
Jordan Hrycaj 00ed6ad312
Dedicated RLP reader for `DisconnectionReason` (#507)
* Provide dedicated `DisconnectionReason` enum type RLP reader

why:
  Without this reader, the program communicating via RLPX will crash when
  receiving out of bound reason codes disconnect message.

  Out of bound value assignments to an enum causes a `RangeError`defect
  and consequently the program to terminate. This `RangeError` is avoided
  here and a `MalformedRlpError` catchable error raised.

* Using default exception type in bespoke `read(DisconnectionReason)`

why:
  This should not differ from the default enum parser. The particular
  message is different and more targeted, here.

  Note: The default RLP parser was not used because `
  `array[1,DisconnectionReason]` is currently not properly handled and
  should give a siliar error message as a `DisconnectionReason` error.

* De-clutter, custom read() was not needed

Co-authored-by: jordan <jordan@curd.mjh-it.com>
2022-05-26 10:23:40 +01:00
Jacek Sieka 3263816d10
remove bzz protocol (#506)
Swarm has moved to libp2p
2022-05-07 13:50:43 +02:00
Kim De Mey 4463a28fd6
Add discv5 max packet size limit (#505) 2022-05-02 16:49:19 +02:00
Kim De Mey 6d4b1f4fe1
Handle the decodeAuthMessage error case separatly and log to trace (#498)
* Handle the decodeAuthMessage error case separatly and log to trace

Garbage data on the TCP port (e.g. from port scanners) would
cause lots of error log messages, so log this to trace and get rid
of a (little) bit of exception usage in the process.

* Remove usage of result var in rlpxAccept and rlpxConnect

* Discv4: Add ENRRequest & ENRResponse msgs to avoid fails on these

Fix #499
These messages are not implemented yet however, but just ignored.
2022-04-04 22:31:09 +02:00
Jacek Sieka 41b8588ade
move rocksdb to nimbus-eth1 (#460)
sqlite ftw!
2022-04-04 13:46:57 +02:00
KonradStaniec eb785207ae
Make packet size configurable (#497)
* Make packet size configurable
2022-04-04 13:44:32 +02:00
KonradStaniec c28597fee5
Change closing proc (#492) 2022-03-28 12:35:08 +02:00
Jordan Hrycaj 03924d672c
Merge pull request #494 from status-im/mitigate-rlp-annoyances
Mitigating RLP annoyances
2022-03-25 15:37:26 +00:00
KonradStaniec f79b79f826
Fix defect in uTP buffer (#493) 2022-03-24 15:56:00 +01:00
Jordan Hrycaj 944d7a4069 Mitigating RLP annoyances
why:
  Rlp errors throw exceptions which cause the dispatcher loop to
  terminate the current session immediately.

details:
  The DisconnectionReasonList message requires a single entry list.
  Observed and now accepted deviations are:

  Geth: single byte number

  bor(a Geth fork): blobbed single entry list containing a number
2022-03-24 14:49:15 +00:00
KonradStaniec 0e20fd6565
Utp improvements (#489)
* Move connection finalization to separate function

* Do not process data unless in correct state
2022-03-18 08:13:17 +01:00
Kim De Mey e62fdfe6f1
Add bind ip and bind port for eth1 rlpx and discovery protocols (#485)
Includes some small refactor on usage of result and Nim style
according to style guide.
2022-03-15 18:08:15 +01:00
KonradStaniec dff9040cc1
Fix bug when reading till eof (#483) 2022-03-03 22:38:13 +01:00
jangko 6c4d04562d
add bootnodes test 2022-02-27 11:53:11 +07:00
jangko 622e6489d8
EIP-4399 changes: random -> prevRandao 2022-02-27 11:40:15 +07:00
KonradStaniec 8ef6b13b1b
Add event loop to socket (#475)
- add eventLoop to control all incoming events
- change semantic of write to asynchronously block only when send buffer is full, and not when bytes do not fit into send window
- change handling of receive buffer, to start dropping packets if the reorder buffer and receive buffer are full. Old behaviour was to async block unless there is space which could lead to resource exhaustion attacks
2022-02-24 18:22:44 +01:00
KonradStaniec 779d767b02
Add more tests stressing conccurent reading and writing on utp socket (#474)
* Add more tests stressing concurrent reading and writing

* Fix bug when remote window dropped below packet size
2022-02-10 08:05:44 +01:00
Kim De Mey 05ef9a8e00
More --styleCheck fixes for discoveryv5 and eth/common (#473) 2022-02-03 15:51:08 +01:00
Kim De Mey 41edd4a3f2
Add DiscoveryConfig to tune routing table ip limits and bitPerHops (#471) 2022-02-02 15:29:45 +01:00
jangko cf95b688e6
EIP-4399 preparation
From EIP-4399 spec:

Renaming

The mixHash field SHOULD further be renamed to random.

...
2022-02-01 13:41:50 +07:00
Jacek Sieka ce4acc168c
kvstore: simplified stmt exec iterator (#467) 2022-01-28 15:23:41 +02:00
KonradStaniec 5791afccc3
Implement fast resend logic for selective acks (#468)
* Implement fast resend logic for selective acks
2022-01-27 11:07:40 +01:00
KonradStaniec 7afd44d33e
Implement fast resend logic (#466) 2022-01-26 09:49:34 +01:00
KonradStaniec 9a7b1afe9b
Add custom talkreq implementation (#464)
* Add custom talkreq implementation to utp over discv5
2022-01-24 11:58:35 +01:00
KonradStaniec 4e2b340af6
Fix sudden window drop bug (#465)
Fixes problem which caused drop of maxWindow to the size of
only one packet in case of only one packet hitting timeout.
2022-01-21 14:48:01 +01:00
KonradStaniec b2dab4be08
Re-send acks for old duplicated packets (#462)
* Re-send acks for old duplicated packets
2022-01-20 09:22:53 +01:00
Kim De Mey 26ab9b078e
Minor adjustments in utp_discv5_protocol (#459)
- Move SocketConfig parameter location
- Reuse rng from disc5 protocol
- add exports
- Some whitespace clean-up
2022-01-10 13:49:36 +01:00
KonradStaniec 0f18272315
Test vectors upt decoding/encoding (#458) 2022-01-07 10:38:36 +01:00
KonradStaniec 9c8e9d9f64
Handle selective acks (#456)
* Handle selective acks
2022-01-04 09:52:38 +01:00
Kim De Mey 8b7d41f596
Don't use exceptions for enr get call (#453)
The ENR code used to be solely exception based, and these
exceptions where a left-over of that. They are useless as later
calls use Result anyhow.

Additionally, they cause quite the performance loss because they
are used in the "common path" for the toTypedRecord call, e.g.
when reading the fields of ip6, tcp6 and udp6.
2021-12-21 15:09:32 +01:00
Kim De Mey 2c236f6495
Style fixes according to --styleCheck:usages (#452)
Currently only setting `--styleCheck:hint` as there are some
dependency fixes required and the compiler seems to trip over the
findnode MessageKind, findnode Message field and the findNode
proc. Also over protocol.Protocol usage.
2021-12-20 13:14:50 +01:00
KonradStaniec 0cfe7df817
Handle packets with selective acks (#451)
* Handle packets with selective acks
2021-12-15 13:35:17 +01:00
Etan Kissling 5655bd035c
Merge pull request #450 from etan-status/reject-whoareyou-len
reject WHOAREYOU packets with non-empty message
2021-12-14 16:22:25 +01:00
Ștefan Talpalaru 2088d7568d
CI: test with multiple Nim version (#429)
* CI: test with multiple Nim version

* clean up the testing tree a little

* replace "unittest" with "unittest2"
2021-12-11 19:12:55 +01:00
Etan Kissling 45387ad4d2
reject WHOAREYOU packets with non-empty message
This changes the `discv5` parser to reject malformed WHOAREYOU packets
that have a non-0 message length. The extra data used to be ignored.
The `message` part of WHOAREYOU packets is always empty.
See https://github.com/ethereum/devp2p/blob/master/discv5/discv5-wire.md
2021-12-11 15:55:14 +01:00
Etan Kissling 3ce2d9a58e
remove outdated and incorrect SSZ code
This removes the outdated copy of the SSZ code. It became incorrect
over time (e.g., empty SSZ list elements), and is no longer in use by
GitHub projects: https://github.com/search?q=extension%3Anim+eth%2Fssz

The canonical SSZ implementation resides at `nim-ssz-serialization`.
Compared to `nim-eth`, these changes were made meanwhile:
- `bitseqs` was extended with JSON serialization support,
  and with the new functions `isZero` and `countOnes`.
- `bytes_reader` was renamed to `codec`, extended with a few additional
  SSZ type conversions as well as support for `SingleMemberUnion`.
- The simplified merkle tree implementation in `merkle_tree.nim`
  was removed. It was not used by other projects.
- `merkleization` was extended with support for `HashArray`, `HashList`
  and `SingleMemberUnion`. The `isValidProof` functionality has been
  moved to `nimbus-eth2` and replaced with the EF defined function
  `is_valid_merkle_branch`. The test was also moved to `nimbus-eth2`.
  There are no other GitHub projects using `isValidProof`:
  https://github.com/search?q=extension%3Anim+isValidProof
  Furthermore, a definition for `GeneralizedIndex` was added.
- `ssz_serialization` was moved one directory up, and improved with
  bug fixes and `HashArray`, `HashList` and `SingleMemberUnion` support.
- `types` was extended with JSON serialization and new type support for
  `Uint128`, `Uint256`, `HashArray`, `HashList` and `SingleMemberUnion`.
  There is also a new `getBit` function for `BitList`.
2021-12-10 15:51:22 +01:00
Kim De Mey 41d2d3c991
Utp top level raises & some clean-up (#445)
* Add few missing top level raises Defect in uTP

- Add top level {.push raises: [Defect].}
- remove some local raises, including some unneeded
CatchableErrors.
- Don't export messageHandler (avoiding annoying naming collisions)
- export utp_router as those connection callbacks are in the API

* Add some missing copyright clauses

* Some ident and max line length cleanup

* Rename utp_discv5_protocol.nim to be more consistent
2021-12-10 11:12:24 +01:00
KonradStaniec 09959d2a3f
Update timestamp and ackNr on packet resend (#444)
* Update timestamp and ackNr on packet resend
2021-12-10 10:18:00 +01:00