Commit graph

224 commits

Author SHA1 Message Date
Felix Lange
f96f5965e6 p2p/discover: rename 2024-05-14 22:26:49 +02:00
Felix Lange
008ff21cdf p2p/discover: fix race in test 2024-05-14 13:18:47 +02:00
Felix Lange
9faae76660 p2p/discover: improve test reliability 2024-05-03 14:11:20 +02:00
Felix Lange
051ca137fb p2p/discover: use lock in reseedingRandom 2024-05-03 14:10:09 +02:00
Felix Lange
009658c4fa p2p/discover: seed nodes are not inbound 2024-04-26 15:40:38 +02:00
Felix Lange
1765712a83 p2p/discover: fix double lock 2024-04-26 14:04:19 +02:00
Felix Lange
edb3a12a66 p2p/discover: fix lookup failure log 2024-04-26 14:04:04 +02:00
Felix Lange
ea9f0a4b03 p2p/discover: put back findnode request tracking 2024-04-25 17:37:53 +02:00
Felix Lange
2c2c7f7a07 p2p/discover: rename add node methods
This is to better reflect their purpose. The previous naming of 'seen' and 'verified'
was kind of arbitrary, especially since 'verified' was the stricter one.
2024-04-24 17:32:59 +02:00
Felix Lange
041ce1b7b3 p2p/discover: fix addedAt time 2024-04-24 17:32:59 +02:00
Felix Lange
0048a0f54d
Update p2p/discover/table_reval.go
Co-authored-by: Martin HS <martin@swende.se>
2024-04-24 16:20:40 +02:00
Felix Lange
81e553f428 p2p/discover: faster decay 2024-04-20 11:58:46 +02:00
Felix Lange
30eb2bf406 p2p/discover: remove logging checks in for dead nodes (it's always zero) 2024-04-20 11:58:46 +02:00
Felix Lange
0b44fc4dea p2p/discover: faster 2024-04-20 11:58:46 +02:00
Felix Lange
c2ad0a783d p2p/discover: improve list moving 2024-04-20 11:58:46 +02:00
Felix Lange
822b05926f p2p/discover: fix crash in move 2024-04-20 11:58:46 +02:00
Felix Lange
b44673fa29 p2p/discover: move back to fast list when endpoint changed or dead 2024-04-20 11:58:46 +02:00
Felix Lange
7667ebfceb p2p/discover: simplify rand timer 2024-04-20 11:58:46 +02:00
Felix Lange
c1afb3c0cc p2p/discover: return nextTime from run() 2024-04-20 11:58:46 +02:00
Felix Lange
dc3f78bb81 p2p/discover: add live flag in debug node 2024-04-20 11:58:46 +02:00
Felix Lange
1d896e8165 p2p/discover: fix spin condition 2024-04-20 11:58:46 +02:00
Felix Lange
00e71f5d1b p2p/discover: fix test 2024-04-20 11:58:46 +02:00
Felix Lange
f2ac6927ab p2p/discover: fix shutdown hang 2024-04-20 11:58:46 +02:00
Felix Lange
fad3fe7853 p2p/discover: fix some tests 2024-04-20 11:58:46 +02:00
Felix Lange
0a4b314244 p2p/discover: update 2024-04-20 11:58:46 +02:00
Felix Lange
70b8918ea0 p2p/discover: fix build 2024-04-20 11:58:46 +02:00
Felix Lange
df8e793e1f p2p/discover: new revalidation 2024-04-20 11:58:46 +02:00
Felix Lange
8f4c72c579 p2p/discover: add debug API 2024-04-20 11:58:46 +02:00
cui
9dfe728909
p2p/discover: using slices.Contains (#29395) 2024-04-04 12:24:49 +02:00
Aaron Chen
723b1e36ad
all: fix mismatched names in comments (#29348)
* all: fix mismatched names in comments

* metrics: fix mismatched name in UpdateIfGt
2024-03-26 21:01:28 +01:00
Martin HS
14cc967d19
all: remove dependency on golang.org/exp (#29314)
This change includes a leftovers from https://github.com/ethereum/go-ethereum/pull/29307
- using the [new `slices` package](https://go.dev/doc/go1.21#slices) and
- using the [new `cmp.Ordered`](https://go.dev/doc/go1.21#cmp) instead of exp `constraints.Ordered`
2024-03-25 07:50:18 +01:00
Martin HS
14eb8967be
all: use min/max/clear from go1.21 (#29307) 2024-03-21 13:50:13 +01:00
yzb
db4cf69166
all: replace fmt.Errorf() with errors.New() if no param required (#29126)
replace-fmt-errorf

Co-authored-by: yzb@example.cn <yzb@example.cn>
2024-02-29 11:56:46 +02:00
zoereco
2ab365f6d8
all: fix docstring names (#28923)
* fix wrong comment

* reviewers input

* Update log/handler_glog.go

---------

Co-authored-by: Martin HS <martin@swende.se>
2024-02-07 21:10:49 +01:00
Felix Lange
5b22a472d6
p2p/discover: add liveness check in collectTableNodes (#28686)
* p2p/discover: add liveness check in collectTableNodes

* p2p/discover: fix test

* p2p/discover: rename to appendLiveNodes

* p2p/discover: add dedup logic back

* p2p/discover: simplify

* p2p/discover: fix issue found by test
2023-12-18 10:47:21 +01:00
Martin Holst Swende
b8d44ed98b
log: remove lazy, remove unused interfaces, unexport methods (#28622)
This change 

- Removes interface `log.Format`, 
- Removes method `log.FormatFunc`, 
- unexports `TerminalHandler.TerminalFormat` formatting methods (renamed to `TerminalHandler.format`)
- removes the notion of `log.Lazy` values


The lazy handler was useful in the old log package, since it
could defer the evaluation of costly attributes until later in the
log pipeline: thus, if the logging was done at 'Trace', we could
skip evaluation if logging only was set to 'Info'.

With the move to slog, this way of deferring evaluation is no longer
needed, since slog introduced 'Enabled': the caller can thus do
the evaluate-or-not decision at the callsite, which is much more
straight-forward than dealing with lazy reflect-based evaluation.

Also, lazy evaluation would not work with 'native' slog, as in, these
two statements would be evaluated differently:

```golang
  log.Info("foo", "my lazy", lazyObj)
  slog.Info("foo", "my lazy", lazyObj)
```
2023-12-05 11:54:44 +01:00
jwasinger
28e7371701
all: replace log15 with slog (#28187)
This PR replaces Geth's logger package (a fork of [log15](https://github.com/inconshreveable/log15)) with an implementation using slog, a logging library included as part of the Go standard library as of Go1.21.

Main changes are as follows:
* removes any log handlers that were unused in the Geth codebase.
* Json, logfmt, and terminal formatters are now slog handlers.
* Verbosity level constants are changed to match slog constant values.  Internal translation is done to make this opaque to the user and backwards compatible with existing `--verbosity` and `--vmodule` options.
* `--log.backtraceat` and `--log.debug` are removed.

The external-facing API is largely the same as the existing Geth logger.  Logger method signatures remain unchanged.

A small semantic difference is that a `Handler` can only be set once per `Logger` and not changed dynamically.  This just means that a new logger must be instantiated every time the handler of the root logger is changed.

----
For users of the `go-ethereum/log` module. If you were using this module for your own project, you will need to change the initialization. If you previously did 
```golang
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
```
You now instead need to do 
```golang
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true)))
```
See more about reasoning here: https://github.com/ethereum/go-ethereum/issues/28558#issuecomment-1820606613
2023-11-29 08:33:50 +01:00
Felix Lange
9b46986edc
all: use rlp.DecodeBytes instead of rlp.Decode where possible (#27994) 2023-08-24 11:47:42 +03:00
Péter Szilágyi
be65b47645
all: update golang/x/ext and fix slice sorting fallout (#27909)
The Go authors updated golang/x/ext to change the function signature of the slices sort method. 
It's an entire shitshow now because x/ext is not tagged, so everyone's codebase just 
picked a new version that some other dep depends on, causing our code to fail building.

This PR updates the dep on our code too and does all the refactorings to follow upstream...
2023-08-12 00:04:12 +02:00
Felix Lange
a426999fc9
p2p/discover: filter bootnodes by netrestrict (#27701)
This prevents an issue where the node would attempt to contact the bootstrap
nodes even if they weren't contained in the netrestrict list.
2023-07-12 12:01:38 +02:00
lightclient
cbf2579691
p2p, p2p/discover: add dial metrics (#27621)
This PR adds metrics for p2p dialing, which gives us visibility into the quality of the dial 
candidates  returned by our discovery methods.
2023-07-06 16:20:31 +02:00
Exca-DK
5520cd97a1
p2p/discover: swap verification order in discv4 ping handler (#27532)
In all other UDPv4 methods, the deadline is checked first. It seems weird to me that ping is an exception. Deadline comparison is also less resource intensive.

Co-authored-by: Exca-DK <Exca-DK@users.noreply.github.com>
2023-06-22 10:06:14 +02:00
Dan Laine
289c6c3b15
p2p: use slices package for sorting (#27494)
Co-authored-by: Felix Lange <fjl@twurst.com>
2023-06-19 07:48:12 +02:00
Felix Lange
ac86547b01
p2p/discover: add Table configuration and Nodes method (#27387)
* p2p/discover: remove ReadRandomNodes

Even though it's public, this method is not callable by code outside of
package p2p/discover because one can't get a valid instance of Table.

* p2p/discover: add Table.Nodes

* p2p/discover: make Table settings configurable

In unit tests and externally developed cmd/devp2p test runs, it can be
useful to tune the timer intervals used by Table.
2023-05-31 13:37:10 +02:00
ucwong
ae7db289b8
p2p: initialize maps with known size (#27229) 2023-05-10 10:52:26 +02:00
Martin Holst Swende
7d1ebe51b7
p2p/discover: fix lint nit (#27206) 2023-05-02 04:36:11 -04:00
ucwong
a865e28f28
p2p/discover : typo (#27193) 2023-04-28 21:34:08 +03:00
Felix Lange
47cdea5ac5
p2p/discover: concurrent TALKREQ handling (#27112)
This changes TALKREQ message processing to run the handler on separate goroutine,
instead of running on the main discv5 dispatcher goroutine. It's better this way because
it allows the handler to perform blocking actions.

I'm also adding a new method TalkRequestToID here. The method allows implementing
a request flow where one node A sends TALKREQ to another node B, and node B later
sends a TALKREQ back. With TalkRequestToID, node B does not need the ENR of A to
send its request.
2023-04-28 11:03:43 +02:00
Exca-DK
f8f95346f9
p2p/discover: add traffic metrics (#27008)
Co-authored-by: Exca-DK <dev@DESKTOP-RI45P4J.localdomain>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2023-04-25 12:12:34 +02:00
Martin Holst Swende
eca3d39c31
p2p/discover: pass invalid discv5 packets to Unhandled channel (#26699)
This makes it possible to run another protocol alongside discv5, by reading 
unhandled packets from the channel.
2023-03-14 12:40:40 +01:00