Commit graph

812 commits

Author SHA1 Message Date
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
thinkAfCod
1ae723db49 fix: fix test case 2024-06-03 14:30:21 +08:00
thinkAfCod
ba87b9da66 fix: fix memory leak 2024-06-03 14:30:21 +08:00
Chen Kai
7b4b081ff4 Revert "fix: close conn after read"
This reverts commit c6766840d4.
2024-06-01 08:21:17 +08:00
Chen Kai
3a133719f8 Revert "fix: upgrade utp version for using sync pool to get buffer"
This reverts commit 210a81d4b3.
2024-06-01 08:21:17 +08:00
Chen Kai
2826476c80 Revert "fix: test case and upgrade utp-go version"
This reverts commit 02b87d96e4.
2024-06-01 08:21:17 +08:00
thinkAfCod
02b87d96e4 fix: test case and upgrade utp-go version 2024-05-31 14:02:18 +08:00
thinkAfCod
210a81d4b3 fix: upgrade utp version for using sync pool to get buffer 2024-05-31 14:02:18 +08:00
thinkAfCod
c6766840d4 fix: close conn after read 2024-05-31 14:02:18 +08:00
Felix Lange
94a8b296e4
p2p/discover: refactor node and endpoint representation (#29844)
Here we clean up internal uses of type discover.node, converting most code to use
enode.Node instead. The discover.node type used to be the canonical representation of
network hosts before ENR was introduced. Most code worked with *node to avoid conversions
when interacting with Table methods. Since *node also contains internal state of Table and
is a mutable type, using *node outside of Table code is prone to data races. It's also
cleaner not having to wrap/unwrap *enode.Node all the time.

discover.node has been renamed to tableNode to clarify its purpose.

While here, we also change most uses of net.UDPAddr into netip.AddrPort. While this is
technically a separate refactoring from the *node -> *enode.Node change, it is more
convenient because *enode.Node handles IP addresses as netip.Addr. The switch to package
netip in discovery would've happened very soon anyway.

The change to netip.AddrPort stops at certain interface points. For example, since package
p2p/netutil has not been converted to use netip.Addr yet, we still have to convert to
net.IP/net.UDPAddr in a few places.
2024-05-29 15:02:26 +02:00
thinkAfCod
c7e93e70cc fix: find node info 2024-05-29 20:26:30 +08:00
lilasxie
153f8da887
p2p/nodestate: remove unused package (#29872) 2024-05-29 12:11:18 +02:00
bugmaker9371
daf4f72077
p2p/simulations: remove stale information about docker adapter (#29874) 2024-05-29 12:09:58 +02:00
lightclient
cc22e0cdf0
p2p/discover: fix update logic in handleAddNode (#29836)
It seems the semantic differences between addFoundNode and addInboundNode were lost in
#29572. My understanding is addFoundNode is for a node you have not contacted directly
(and are unsure if is available) whereas addInboundNode is for adding nodes that have
contacted the local node and we can verify they are active.

handleAddNode seems to be the consolidation of those two methods, yet it bumps the node in
the bucket (updating it's IP addr) even if the node was not an inbound. This PR fixes
this. It wasn't originally caught in tests like TestTable_addSeenNode because the
manipulation of the node object actually modified the node value used by the test.

New logic is added to reject non-inbound updates unless the sequence number of the
(signed) ENR increases. Inbound updates, which are published by the updated node itself,
are always accepted. If an inbound update changes the endpoint, the node will be
revalidated on an expedited schedule.

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-05-28 21:30:17 +02:00
Felix Lange
af0a3274be
p2p/discover: fix crash when revalidated node is removed (#29864)
In #29572, I assumed the revalidation list that the node is contained in could only ever
be changed by the outcome of a revalidation request. But turns out that's not true: if the
node gets removed due to FINDNODE failure, it will also be removed from the list it is in.
This causes a crash.

The invariant is: while node is in table, it is always in exactly one of the two lists. So
it seems best to store a pointer to the current list within the node itself.
2024-05-28 18:13:03 +02:00
Chen Kai
5361160fd7 use id to send
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-05-27 15:16:48 +08:00
Chen Kai
526ee8ad9e revert
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-05-27 14:48:30 +08:00
Chen Kai
3ab51ce84f revert utp async
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-05-27 09:32:04 +08:00
gitglorythegreat
64b1cd8aaf
p2p: fix typos (#29828) 2024-05-24 11:33:19 +02:00
Aaron Chen
61b3d93bb0
p2p/enode: fix TCPEndpoint (#29827) 2024-05-23 23:17:51 +02:00