Commit Graph

39 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
Jacek Sieka 3d51887c15
move signal ignore out of `eth/common` (#734)
`net/nat` is the only place where it is used and it certainly doesn't
belong in `common`
2024-09-24 11:30:05 +02:00
tersec 11eafac0f0
handle new UPnP return value (#728) 2024-09-10 05:10:08 +00: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
Jacek Sieka 0e83cfda97
results: use standalone repo (#687) 2024-05-30 14:46:57 +02:00
Kim De Mey 21f3014f54
Remove usage of stew/shim/net (#670)
* Remove usage of stew/shim/net and replace with std/net where needed

* Remove chronosStrictException compile flag
2024-01-24 09:09:11 +01:00
Kim De Mey 159ae697c5
Remove last leftovers of ValidIpAddress (#664) 2024-01-19 11:15:57 +01:00
tersec ca4898e24a
switch NAT module from ValidIpAddress to IpAddress (#647)
* switch NAT module from ValidIpAddress to IpAddress

* fix dcli build

* switch discv5 from ValidIpAddress to IpAddress

* fix fuzzers build

* mostly finish nim-eth to IpAddress transition
2023-11-10 09:28:21 +03:00
Ivan Folgueira Bande 285da12bf3
nat.nim: breaking dependency with 'confutils' (#609)
* nat.nim: breaking dependency with 'confutils'

The main purpose of this change is to break the dependency with
`confutils`.
2023-05-16 13:43:31 +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 d2a3727c4c
Use chronos isGlobal to verify public IPs for net/nat and discv5 (#588) 2023-02-21 09:34:26 +01:00
Lorenzo Delgado 5c46220e72
add eth topic to all the logs scope (#568) 2022-12-06 14:54:03 +01:00
Justin Traglia e7d3de6ebf
Fix some typos (#557) 2022-11-16 17:44:00 +01:00
Kim De Mey 9b0f054b04
Tackle some Nim warnings new since Nim 1.4 & 1.6 (#553) 2022-11-10 16:32:57 +01:00
Ștefan Talpalaru ea03e66485
nat: getPublicRoutePrefSrcOrExternalIP() (#496)
* nat: getPublicRoutePrefSrcOrExternalIP()

And some refactoring to minimise code duplication.
2022-03-31 16:07:28 +02:00
Ștefan Talpalaru 7b448ed406
net/nat.nim: "raises" annotations (#487) 2022-03-16 15:21:56 +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
Kim De Mey ae0920d40d
Remove hashData usage on objects (#441)
* Remove hashData usage on objects

* Add hash func for NodeId to avoid using the one of stint
2021-12-06 15:24:07 +01:00
Jacek Sieka 2baa4c02a1
avoid allocation in `hash(ValidIpAddress)` (#433)
* avoid allocation in `hash(ValidIpAddress)`

While casually browsing the profiler output, to my great surprise I
found that an allocating string conversion function (gasp!) in the hash
function for ip addresses - this PR carefully excises this evil
construct from the codebase.

* bump nim version
2021-11-29 20:58:45 +01:00
Kim De Mey 1babe38226
Allow for tcp/udp ports to always be configured (#402)
* Allow for tcp/udp ports to always be configured

- Allow for an ENR to be build with tcp and udp ports also when
no IP address is provided
- In the address set-up always provide best efforttcp and udp ports
also when configuration of external ip (and/or ports) fails.
2021-09-29 18:50:23 +02:00
kdeme e10ef19f81
Move push raises to top and add/update license info where needed 2021-04-28 16:20:05 +02:00
Kim De Mey 762415319c
Add build_dcli target and add it to CI (#344)
* Add build_dcli target and add it to CI

* Fix local imports for dcli

* And use local imports for all other files too

* Use local imports in tests and rlpx protocols
2021-04-06 13:33:24 +02:00
Kim De Mey be5e088b21
Move parsing of nat cli option out of setupAddress (#331)
* Move parsing of nat cli option out of setupAddress

* Change some proc to func
2021-03-05 21:23:54 +01:00
Kim De Mey 0700ec770f
Improve network address discovery / NAT setup (#323)
* Add search for best route and refactor setupNat to setupAddress

* Update setupAddress and make enr ports in discovery optional

* Add specific error log when no route is found
* Use bindIP if it is public
* Adjust some log levels
2021-03-02 17:13:29 +01:00
Jacek Sieka 51a8795e56
one upnp is enough (#324)
we shouldn't have to recreate the upnp interface every time
2021-01-26 14:12:04 +01:00
Kim De Mey b4c1391be9
Discv5 ip limits for routing table (#308)
* Add ip limits to routing table and routing table buckets

* Fix order of ip limit check and duplicate check for replacement

* Fix ip limit for node with updated ip in ENR

* Fix bug where address wouldn't update on ENR update

and update some comments

* Reuse some add/remove code in routing table

* Fix seen bug on ENR update in routing table

* Rework addNode to make sure to do address check always

and adjust some logs.

* More documentation on the ip limits in routing table [skip ci]
2020-11-26 18:20:15 +01:00
Ștefan Talpalaru 66e2dc7ba3
ignoreSignalsInThread() 2020-06-21 01:32:13 +02:00
Jacek Sieka ec1492a65a result -> results 2020-04-07 13:32:10 +03:00
Jacek Sieka 1756f7b41f
result -> stew/result (#159) 2020-01-24 09:24:29 +01:00
Ștefan Talpalaru 655fc43751
doPortMapping(): don't set the external IP
because some IGDs can't handle it
2019-12-12 01:57:05 +01:00
kdeme 4976bd9fb9 Replace getCurrentException and getCurrentExceptionMsg 2019-12-02 23:35:34 +02:00
Zahary Karadjov f8da72ca96 Fix the build when json logging is enabled 2019-08-14 17:19:55 +02:00
Ștefan Talpalaru a1a285c290 NAT: move setControlCHook() outside the library 2019-07-11 12:13:13 +03:00
Ștefan Talpalaru bb79902399
eth/net/nat.nim: delete unused var 2019-05-03 17:24:17 +02:00
Ștefan Talpalaru 05bf76c537
fix logic error 2019-04-29 17:32:37 +02:00
Ștefan Talpalaru 20abba71d0
UPnP: port mapping check no longer a show stopper 2019-04-29 17:05:25 +02:00
Ștefan Talpalaru ecc1a995aa
Windows: a new thread is created for the signal handler 2019-04-25 03:06:11 +02:00
Ștefan Talpalaru d0d09559b8
workaround for https://github.com/nim-lang/Nim/issues/4057 2019-04-25 00:25:34 +02:00
Ștefan Talpalaru 3db5f4c5dd
external IP retrieval and port mapping functionality 2019-04-17 03:35:45 +02:00