Commit Graph

78 Commits

Author SHA1 Message Date
Jacek Sieka 6bd6bae86c
Align core types with execution spec (#733)
Since these types were written, we've gained an executable spec:

https://github.com/ethereum/execution-specs

This PR aligns some of the types we use with this spec to simplify
comparisons and cross-referencing.

Using a `distinct` type is a tradeoff between nim ergonomics, type
safety and the ability to work around nim quirks and stdlib weaknesses.

In particular, it allows us to overload common functions such as `hash`
with correct and performant versions as well as maintain control over
string conversions etc at the cost of a little bit of ceremony when
instantiating them.

Apart from distinct byte types, `Hash32`, is introduced in lieu of the
existing `Hash256`, again aligning this commonly used type with the spec
which picks bytes rather than bits in the name.
2024-09-29 10:52:19 +02:00
Kim De Mey f2568a64c0
Fix potential uTP clock drift overflow (#726) 2024-09-03 16:48:24 +02:00
Kim De Mey b874e12516
Differentiate log for invalid packet seqnr without reorder buffer and not (#723) 2024-08-29 18:15:26 +02:00
Kim De Mey 26212c881b
Use results.Opt instead of option in discv5, utp and nat (#705)
+ some other minor cleanups
2024-06-18 18:09:27 +02:00
Kim De Mey f169068df6
Fix missing CancelledError on discv5 waitMessage + results imports (#704)
Fixes a missing CancelledError async raising on discv5 waitMessage
which would cause "Error set on a non-raising future".

Also moves some more results import away from stew.
2024-06-13 12:11:25 +02:00
Kim De Mey 207244c2db
Add more missing async raises in uTP (#702) 2024-06-12 18:01:23 +02:00
Kim De Mey c3f9160fd2
Add async raises annotations for uTP code (#692)
* Add async raises annotations for uTP code

* Avoid compiler error + further clean-up
2024-06-11 13:56:37 +02:00
Kim De Mey 3d66c5b899
Fix ImplicitDefaultValue warnings + replace some obsolete inits (#697) 2024-06-10 21:19:25 +02:00
Kim De Mey 19965bab95
Fix chronos related deprecated warnings in uTP code part II (#669)
This also makes the uTP SendCallBack not returning a Future any
more as it is not used in sendData anyhow. And in case of uTP
over discv5, discv5 send call is already not async.

This gives quite a noticable throughput benchmark improvement over
with uTP over UDP, and a slightly noticable with uTP over discv5
2024-01-23 18:41:38 +01:00
Kim De Mey 496bcdab74
Fix chronos related deprecated warnings in discv5 and uTP (#667)
* Fix chronos related deprecated warnings in discv5

* Fix chronos related deprecated warnings in uTP code

* Improve discv5 closeWait order of events and add noCancel
2024-01-22 17:08:08 +01:00
Kim De Mey 974a995b21
Add uTP over discv5 test and small uTP performance improvements (#663)
- Add a multiple sockets use test for uTP over discv5
- Use assign2 for the biggest consumer of genericAssignAux in uTP
- Avoid calling exists on the growable buffer when there is no
place in the socket window.
2024-01-18 12:07:03 +01:00
Kim De Mey cbcd1fd307
Fix for uTP issues with latest chronos (#655)
* Fix for uTP issues with latest chronos

* Fix for discv5 issue with latest chronos

* Increase amount of data send in uTP and uTP over discv5 tests
2024-01-12 17:35:44 +01:00
Kim De Mey 11049fb87d
Fix a bunch of compiler hints and warnings in uTP and discv5 (#652)
* Fix a bunch of compiler hints and warnings in uTP and discv5

* Leave in the cancel() for now
2024-01-12 09:49:06 +01:00
Kim De Mey 0d7e7448c4
Allow passing along the handshake ENR through talkresp handler (#634)
This allows for protocols build on top of discv5 to use the ENR
provided in the handshake directly, instead of having to rely
on requesting it from the discv5 routing table.
2023-08-30 17:44:05 +02:00
Kim De Mey c5dd5e4115
Enable tests with also json sink and fix failures (#624)
And a few minor cleanups
2023-06-22 16:13:16 +00:00
Kim De Mey d74dc40bee
Style fixes and comment improvements on uTP code (#623) 2023-06-22 11:31:30 +00:00
Kim De Mey c3860244b1
Fix potentential uTP socket leak for socket in SynSent state (#620)
Socket leak could because ST_DATA (and ST_FIN) packets for sockets
not in connected stated were only dropped after appling acks.
2023-06-21 12:44:52 +02:00
Kim De Mey cea23299be
Avoid double socket destroy on timed-out uTP SYN-ACK (#619) 2023-06-15 12:26:22 +02:00
Jacek Sieka 55b9da0bea
fix cancellation syntax (#615)
* fix cancellation syntax

* simplify
2023-06-02 14:33:06 +02:00
Kim De Mey d57a1094b1
Remove all Defect raises to avoid unnecessary warnings (#607)
As this module dropped support for Nim versions < 1.6, all Defect
raises can be removed to avoid unnecessary warnings
2023-05-10 15:50:04 +02:00
Kim De Mey ea3c164a00
uTP clarification on SYN-ACK seqnr and some cleanup (#596)
- Clarify why on SYN-ACK seqNr gets -1
- Cleanup comments
- Style fixes
- Reuse WriteResult
2023-04-04 17:11:36 +02:00
Kim De Mey 29b14749fa
Improve uTP decoded packet logs + style and comment clean-up (#593)
* Improve uTP decoded packet logs + style and comment clean-up

* Don't test for the exact error strings in uTP decode + clean-up
2023-03-14 16:17:39 +00:00
Lorenzo Delgado 5c46220e72
add eth topic to all the logs scope (#568) 2022-12-06 14:54:03 +01:00
KonradStaniec 22d0ac81e1
Fix defect when writing over send buffer (#564)
* Fix defect when writing over send buffer
2022-11-30 09:34:08 +01:00
Justin Traglia e7d3de6ebf
Fix some typos (#557) 2022-11-16 17:44:00 +01:00
andri lim 10870d8b15
Revert #544 "Fix related to nim devel branch" (#551)
This reverts commit:
5d13052dd9
e1bdf1741a
d238693571
2022-11-09 18:57:04 +01:00
jangko 5d13052dd9
refactor: compile with nim-devel 2022-11-08 11:08:25 +07:00
Kim De Mey bd8d9c65a3
Seperate discv5 protocol message encoding from packet encoding (#539)
And some additional clean-ups
2022-10-10 12:13:20 +02:00
KonradStaniec 2556b090ea
Add user data to utp (#525) 2022-08-12 15:09:59 +02:00
KonradStaniec a5ea6a9a90
Add connection limits to utp (#522) 2022-08-04 15:55:39 +02:00
Kim De Mey 9d7e4b031a
Clean-up of several compiler warnings (#519) 2022-07-09 10:55:15 +02:00
Kim De Mey c67e48be1d
Change info log to debug in uTP router connect (#517)
These uTP logs are common and should be under debug,
else they spam on application level.
Probably accidentally changed in https://github.com/status-im/nim-eth/pull/508
2022-07-04 12:13:46 +02:00
Jacek Sieka 1b516682bd
bearssl: use split api (#510) 2022-06-17 22:45:37 +02:00
KonradStaniec dffaa78cbe
Install cancel callback on whole connection future (#508) 2022-05-30 10:28:10 +02:00
Kim De Mey 01684a2130
Adjust uTP log levels to be more user focused (#502)
Also cleanup several whitespace and line char limits
2022-04-12 21:11:01 +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
KonradStaniec f79b79f826
Fix defect in uTP buffer (#493) 2022-03-24 15:56:00 +01:00
KonradStaniec e794c149f5
Fix compilation error (#490) 2022-03-18 15:53:51 +01: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
KonradStaniec f16f175412
Add metrics to utp router (#488)
* Add metrics to utp router
2022-03-17 10:53:46 +01:00
KonradStaniec dff9040cc1
Fix bug when reading till eof (#483) 2022-03-03 22:38:13 +01: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
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 45348e7664
Add more logs to utp (#463)
* Add more logs to utp

* Change initial timeout for inc socket to positive value
2022-01-20 13:20:30 +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