Commit graph

831 commits

Author SHA1 Message Date
Rafael Sampaio
b4bbdced85 added missing '/' to strings 2024-10-08 19:29:30 -03:00
Rafael Sampaio
07c5d2fb83 replace trace log strings [implement #184] 2024-10-08 19:13:48 -03:00
Rafael Sampaio
120be2f1ee add portMapping to localNode creation 2024-10-04 16:43:56 -03:00
Rafael Sampaio
52c2bfb5b3 add stun server for ip discovery and flag stun 2024-10-03 23:44:13 -03:00
Chen Kai
80d0a8bc17 Merge branch 'gethmaster' into selfportal 2024-09-30 15:01:29 +08:00
Martin HS
b5a88dafae
p2p/discover: fix flaky tests writing to test.log after completion (#30506)
This PR fixes two tests, which had a tendency to sometimes write to the `*testing.T` `log` facility after the test function had completed, which is not allowed. This PR fixes it by using waitgroups to ensure that the handler/logwriter terminates before the test exits.

closes #30505
2024-09-26 08:12:12 +02:00
fearlessfe
316e49fca8 fix: offer test failed in hive state interop 2024-09-26 09:12:43 +08:00
thinkAfCod
7c5231ce74 fix test case log 2024-09-25 21:32:33 +08:00
fearlessfe
29ec4025dc feat: state storage 2024-09-21 00:17:23 +08:00
Guillaume Michel
f544fc3b46
p2p/enode: add quic ENR entry (#30283)
Add `quic` entry to the ENR as proposed in
https://github.com/ethereum/consensus-specs/pull/3644

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
2024-09-13 23:47:18 +02:00
fearlessfe
d4d644c13c feat: refactor protocolId 2024-08-28 23:46:52 +08:00
Nicolas Gotchac
87377c58bc
p2p/discover: fix Write method in metered connection (#30355)
`WriteToUDP` was never called, since `meteredUdpConn` exposed directly
all the methods from the underlying `UDPConn` interface.

This fixes the `discover/egress` metric never being updated.
2024-08-27 14:10:32 +02:00
lightclient
00294e9d28
cmd/utils,p2p: enable discv5 by default (#30327) 2024-08-20 16:02:54 +02:00
thinkAfCod
064a3cf2a9 fix parse enr ip 2024-08-19 23:46:21 +08:00
Chen Kai
3fe80adec2
Merge branch 'ethereum:master' into portal 2024-08-17 14:07:49 +08:00
thinkAfCod
d9ac99649f No longer check if the IP is a multicast address when call AddEnr 2024-08-17 14:07:28 +08:00
lightclient
33a13b6f21
p2p/simulations: remove packages (#30250)
Looking at the history of these packages over the past several years, there
haven't been any meaningful contributions or usages:
https://github.com/ethereum/go-ethereum/commits/master/p2p/simulations?before=de6d5976794a9ed3b626d4eba57bf7f0806fb970+35

Almost all of the commits are part of larger refactors or low-hanging-fruit contributions.
Seems like it's not providing much value and taking up team + contributor time.
2024-08-12 10:36:48 +02:00
Daniel Knopik
de6d597679
p2p/discover: schedule revalidation also when all nodes are excluded (#30239)
## Issue

If `nextTime` has passed, but all nodes are excluded, `get` would return
`nil` and `run` would therefore not invoke `schedule`. Then, we schedule
a timer for the past, as neither `nextTime` value has been updated. This
creates a busy loop, as the timer immediately returns.

## Fix

With this PR, revalidation will be also rescheduled when all nodes are
excluded.

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
2024-07-31 21:38:23 +02:00
Marius G
6e33dbf96a
p2p: fix flaky test TestServerPortMapping (#30241)
The test specifies `ListenAddr: ":0"`, which means a random ephemeral
port will be chosen for the TCP listener by the OS. Additionally, since
no `DiscAddr` was specified, the same port that is chosen automatically
by the OS will also be used for the UDP listener in the discovery UDP
setup. This sometimes leads to test failures if the TCP listener picks a
free TCP port that is already taken for UDP. By specifying `DiscAddr:
":0"`, the UDP port will be chosen independently from the TCP port,
fixing the random failure.

See issue #29830.

Verified using
```
cd p2p
go test -c -race
stress ./p2p.test -test.run=TestServerPortMapping
...
5m0s: 4556 runs so far, 0 failures
```

The issue described above can technically lead to sporadic failures on
systems that specify a listen address via the `--port` flag of 0 while
not setting `--discovery.port`. Since the default is using port `30303`
and using a random ephemeral port is likely not used much to begin with,
not addressing the root cause might be acceptable.
2024-07-30 07:31:27 -06:00
Chen Kai
5e49d18f43
Merge branch 'ethereum:master' into portal 2024-07-27 18:51:29 +08:00
dknopik
b0f66e34ca
p2p/nat: return correct port for ExtIP NAT (#30234)
Return the actually requested external port instead of 0 in the
AddMapping implementation for `--nat extip:<IP>`.
2024-07-27 10:18:05 +02:00
Chen Kai
7b8ce855f7
Merge branch 'ethereum:master' into portal 2024-07-25 13:23:02 +08:00
yukionfire
4dfc75deef
beacon/types, cmd/devp2p, p2p/enr: clean up uses of fmt.Errorf (#30182) 2024-07-25 00:32:58 +02:00
thinkAfCod
f96f5d753d fix format 2024-07-23 18:55:43 +08:00
thinkAfCod
2c5d6c257f add logs 2024-07-23 13:34:56 +08:00
thinkAfCod
26114068ee add logs 2024-07-20 16:08:35 +08:00
Chen Kai
458839f483
Merge branch 'ethereum:master' into portal 2024-07-18 23:47:59 +08:00
Felix Lange
ad49c708f5
p2p/discover: remove type encPubkey (#30172)
The pubkey type was moved to package v4wire a long time ago. Remaining uses of
encPubkey were probably left in due to laziness.
2024-07-18 11:09:02 +02:00
thinkAfCod
8de928c004 add log 2024-07-17 21:47:26 +08:00
Chen Kai
839a7877a8
Merge branch 'ethereum:master' into portal 2024-07-16 18:05:47 +08:00
Nathan Jo
4bbe993252
p2p: fix ip change log parameter (#30158) 2024-07-15 10:15:35 +02:00
Chen Kai
0f8632ed9b
Merge branch 'ethereum:master' into portal 2024-06-22 11:39:03 +08:00
Halimao
a71f6f91fd
p2p/discover: improve flaky revalidation tests (#30023) 2024-06-21 15:29:07 +02:00
David Theodore
27654d3022
p2p/rlpx: 2KB maximum size for handshake messages (#30029)
Co-authored-by: Felix Lange <fjl@twurst.com>
2024-06-20 14:08:54 +02:00
Chen Kai
1189e67f12 fix:make add enr
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-20 16:31:52 +08:00
Chen Kai
792b4746b8 fix:add lock in addenr
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-19 21:46:22 +08:00
Chen Kai
9918abaaa1 fix:add lock when del enr
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-19 09:29:39 +08:00
Chen Kai
af02291ad4 fix:add enr should add node immediately
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-18 21:12:43 +08:00
Chen Kai
13e8f62b34 fix:fix delete no lock
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-18 08:28:24 +08:00
Chen Kai
6088495691 fix:merge geth p2p change
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-06-17 20:28:49 +08:00
fearlessfe
703e97781a feat: change node radius 2024-06-12 11:02:05 +08:00
bugmaker9371
b6f2bbd417
p2p/simulations: update doc of HTTP endpoints (#29894) 2024-06-11 19:41:17 +02:00
thinkAfCod
0d4f0732f8 fix: close conn in defer 2024-06-10 14:55:47 +08:00
Gealber Morales
8bda642963
p2p: use package slices to sort in PeersInfo (#29957) 2024-06-09 22:50:22 +02:00
Gealber Morales
349fcdd22d
p2p/discover: add missing lock when calling tab.handleAddNode (#29960) 2024-06-09 22:47:51 +02:00
Felix Lange
85459e1439
p2p/discover: unwrap 4-in-6 UDP source addresses (#29944)
Fixes an issue where discovery responses were not recognized.
2024-06-06 16:15:22 +03:00
Hteev Oli
0750cb0c8f
p2p/netutil: fix comments (#29942) 2024-06-06 10:56:41 +03:00
Felix Lange
bc6569462d
p2p: use netip.Addr where possible (#29891)
enode.Node was recently changed to store a cache of endpoint information. The IP address in the cache is a netip.Addr. I chose that type over net.IP because it is just better. netip.Addr is meant to be used as a value type. Copying it does not allocate, it can be compared with ==, and can be used as a map key.

This PR changes most uses of Node.IP() into Node.IPAddr(), which returns the cached value directly without allocating.
While there are still some public APIs left where net.IP is used, I have converted all code used internally by p2p/discover to the new types. So this does change some public Go API, but hopefully not APIs any external code actually uses.

There weren't supposed to be any semantic differences resulting from this refactoring, however it does introduce one: In package p2p/netutil we treated the 0.0.0.0/8 network (addresses 0.x.y.z) as LAN, but netip.Addr.IsPrivate() doesn't. The treatment of this particular IP address range is controversial, with some software supporting it and others not. IANA lists it as special-purpose and invalid as a destination for a long time, so I don't know why I put it into the LAN list. It has now been marked as special in p2p/netutil as well.
2024-06-05 19:31:04 +02:00
fearlessfe
1ed713ad1e feat: nat 2024-06-05 12:53:19 +08:00
qcloud
04c50486b8 refactor: contentLookup and traceContentLookup 2024-06-03 23:17:55 +08:00