Commit Graph

190 Commits

Author SHA1 Message Date
Shane Bammel
75db06fa1d Add support for PulseChain
Thanks @bretep for the original integration.
2024-02-14 13:10:45 -06:00
Mark Holt
19bc328a07
Added db loggers to all db callers and fixed flag settings (#9099)
Mdbx now takes a logger - but this has not been pushed to all callers -
meaning it had an invalid logger

This fixes the log propagation.

It also fixed a start-up issue for http.enabled and txpool.disable
created by a previous merge
2023-12-31 17:10:08 +07:00
Mark Holt
509a7af26a
Discovery zero refresh timer (#8661)
This fixes an issue where the mumbai testnet node struggle to find
peers. Before this fix in general test peer numbers are typically around
20 in total between eth66, eth67 and eth68. For new peers some can
struggle to find even a single peer after days of operation.

These are the numbers after 12 hours or running on a node which
previously could not find any peers: eth66=13, eth67=76, eth68=91.

The root cause of this issue is the following:

- A significant number of mumbai peers around the boot node return
network ids which are different from those currently available in the
DHT
- The available nodes are all consequently busy and return 'too many
peers' for long periods

These issues case a significant number of discovery timeouts, some of
the queries will never receive a response.

This causes the discovery read loop to enter a channel deadlock - which
means that no responses are processed, nor timeouts fired. This causes
the discovery process in the node to stop. From then on it just
re-requests handshakes from a relatively small number of peers.

This check in fixes this situation with the following changes:

- Remove the deadlock by running the timer in a separate go-routine so
it can run independently of the main request processing.
- Allow the discovery process matcher to match on port if no id match
can be established on initial ping. This allows subsequent node
validation to proceed and if the node proves to be valid via the
remainder of the look-up and handshake process it us used as a valid
peer.
- Completely unsolicited responses, i.e. those which come from a
completely unknown ip:port combination continue to be ignored.
-
2023-11-07 08:48:58 +00:00
battlmonstr
d92898a508
p2p: silkworm sentry (#8527) 2023-11-02 08:35:13 +07:00
Dmytro
9adf31b8eb
bytes transfet separated by capability and category (#8568)
Co-authored-by: Mark Holt <mark@distributed.vision>
2023-10-27 22:30:28 +03:00
battlmonstr
f1c81dc14e
devnet: fix node startup on macOS (#8569)
* call getEnode before NodeStarted to make sure it is ready for RPC
calls
* fix connection error detection on macOS
* use a non-default p2p port to avoid conflicts
* disable bor milestones on local heimdall
* generate node keys for static peers config
2023-10-26 12:58:01 +07:00
battlmonstr
e04dee12fd
p2p: bad p2p server port in the log (#8493)
Problem:
"Started P2P networking" log message contains port zero on startup,
e.g.: 127.0.0.1:0 because of the outdated localnodeAddrCache.

Solution:
Call updateLocalNodeStaticAddrCache after updating the port.
2023-10-17 10:40:02 +07:00
Alex Sharov
6d9a4f4d94
rpcdaemon: must not create db - because doesn't know right parameters (#8445) 2023-10-12 14:11:46 +07:00
battlmonstr
340b9811b0
p2p: refactor peer errors to propagate with a DiscReason (#8089)
Improve p2p error handling to propagate errors
from the origin up the call chain the Server peer removal code
using a new PeerError type containing a DiscReason and a more detailed
description.

The origin can be tracked down using PeerErrorCode (code) and DiscReason
(reason)
which looks like this in the log:

> [TRACE] [08-28|16:33:40.205] Removing p2p peer peercount=0
url=enode://d399f4b...@1.2.3.4:30303 duration=6.901ms
err="PeerError(code=remote disconnect reason, reason=too many peers,
err=<nil>, message=Peer.run got a remote DiscReason)"
2023-08-31 16:45:23 +01:00
battlmonstr
6c017c33f9
p2p: log NAT ExternalIP error (#8026) 2023-08-22 10:51:00 +02:00
ledgerwatch
c919283b0c
[devnet] separate logging p2p (#7549)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2023-05-19 23:08:45 +01:00
ledgerwatch
b0117a7c30
[devnet] separate logging - p2p (#7547)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2023-05-19 18:41:53 +01:00
battlmonstr
404e395bb4
p2p: fix peer ID serialization (#7495)
The peer ID in sentry.proto is a H512 / 64 bytes value, and
MarshalPubkey creates it from a public key.

There's no need to cut the first byte, because MarshalPubkey already
does it.
Doing so results in a 63 bytes value that is incompatible with silkworm
sentry.
2023-05-11 17:19:47 +01:00
Alex Sharov
f23612bdfe
Enode logging broke when NAT Parameter set in 2.43.0 (#7480)
for https://github.com/ledgerwatch/erigon/issues/7472
2023-05-10 10:25:53 +07:00
hexoscott
3b36d5d57a
get localnode address up front on creation to save potential data race (#7111)
the log line here was the culprit for the race. made sense to just
capture this on localnode creation instead and hold onto it for when the
server is started.

ran test with `-race` and `-count=5000` to double check and all looks
good
2023-03-16 03:44:00 +00:00
hexoscott
efd541028c
read metrics config from yaml file (#7089) 2023-03-14 00:07:05 +00:00
ledgerwatch
ee83447fa1
CL lightclient to create memdb in the tmpdir which gets cleaned up on… (#6829)
… startup

---------

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
2023-02-11 20:44:51 +00:00
awskii
a124bcf6ac
added --p2p.allowed-port flag (#6263)
Regarding https://github.com/ledgerwatch/erigon/issues/6260

added flag `--p2p.allowed-ports=<porta>,<portb>` to restrict which ports
to use for sentries for different protocol versions.

Default for this flag is `30303, 30304` (first port is inherited from
`--port` flag defaults.
If `--port` is changed and it's new value is not presented in allowed
port list, provided port will be allowed as well as list provided via
`--p2p.allowed-ports`

Port picking is straightforward, we create sentry gRPC server for
protocol over first allowed port that is not already taken.
If there are no allowed ports left, erigon exits with hint.
2022-12-12 13:25:47 +00:00
Andrew Ashikhmin
14c0643476
Enable both eth/66 and eth/67 by default (#6048) 2022-11-15 10:41:56 +01:00
Andrew Ashikhmin
eec5fa4d41
Add support for eth/67 (#4564)
* Add eth/67

* Listen to eth/66 on a separate port

* Fix compilation error

* Fix cfg66.ListenAddr

* Update erigon ports in README

* Expose port 30304 in docker

* P2pProtocolVersionFlag instead of second sentry

* Remove "66 by default" from usage

* Small comment
2022-07-08 11:14:16 +02:00
battlmonstr
bc2e9e7b72
p2p: crawler-friendly handshake (#3982)
* exchange RLPx Hello even when maxpeers limit is reached
* bump MaxPendingPeers to increase the default handshake queue
  (and the likelyhood of Hello exchange)
2022-04-28 23:21:22 +01:00
battlmonstr
c6649f584b
p2p: refactor MaxPendingPeers handling (#3981)
* use semaphore instead of a chan struct{}
* move MaxPendingPeers default value to DefaultConfig.P2P
* log Error if Accept fails
* replace quit channel with context
2022-04-28 09:21:52 +07:00
ledgerwatch
f56d4c5881
Switch peerId from 256 to 512 bit (as in stable) (#3862)
* Switch peerId from 256 to 512 bit (as in stable)

* go mod tidy

* Fix some tests

* Fixed

* Fixes

* Fix tests

* Update to erigon-lib main

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2022-04-10 08:01:25 +01:00
battlmonstr
930d662f21
Refactor crypto.FromECDSAPub to MarshalPubkey/Std (#3797)
Most places that used this method were cutting off the 1st byte.
Refactor this idea to a common place.

* better naming: MarshalPubkey matches existing UnmarshalPubkey
* "Std" suffix for the ANSI standard encoding without cut off
* docs
2022-03-31 11:06:20 +07:00
battlmonstr
f5a0c9d834
p2p: Disable port mapping task with --nat extip (#3612)
If --nat extip:1.2.3.4 option is specified, the port mapping logic
(AddMapping/DeleteMapping) does nothing.
This optimization avoids running a goroutine for doing nothing.
2022-02-24 15:09:56 +00:00
battlmonstr
082194d538
Discovery: add Context to Listen. (#3577)
Add explicit Context to ListenV4 and ListenV5.
This makes it possible to stop listening by an external signal.
2022-02-22 18:18:43 +00:00
battlmonstr
4337871f7f
Rename log/logger to follow conventions. (#3579)
* use "log" for struct fields
* use "logger" for function parameters and local vars

This is a compromise between:
1) using logger := log.New() to avoid aliasing (log := log.New())
2) and keeping it short when logging e.g.: srv.log.Info(...)
2022-02-22 18:17:15 +00:00
Alex Sharov
01380316a5
close nodes db on server start error (#3424) 2022-02-04 13:04:37 +07:00
ledgerwatch
14f81db038
Not try to create temporary file with enode (#3035)
* Update server.go

* Update server.go
2021-11-25 18:36:15 +00:00
TBC Dev
e1c44cd19b
Change sentry peer_id from H512 pubkey to H256 keccak256(pubkey) (#3013)
* Rename protoHandshake.ID to protoHandshake.Pubkey

* Fix enode.ID comment descriptions

* Change sentry peer_id from H512 pubkey to H256 keccak256(pubkey)

* Simplify PeerInfo helpers
2021-11-22 05:39:31 +00:00
Dmitry Savelev
77a31a8b36
Fix Sentry server initialization (#3008) 2021-11-21 19:36:26 +00:00
Andrea Lanfranchi
3bc3be4b5f
Clean up DEBUG category logs (#2776)
- move many DEBUG logs into TRACE category
2021-10-05 08:14:04 +07:00
Alex Sharov
5069558752
Apache licensed logger (#2460) 2021-07-29 17:23:23 +07:00
alex.sharov
bc65759c84 clien id in rpc 2021-07-15 16:11:39 +07:00
Alex Sharov
188dfb14b8
txPool: propagate on peer connect (#2335) 2021-07-11 14:01:16 +07:00
Alex Sharov
afd8674c4b
Peer log (#2294)
* Revert "Revert "better handshake""

This reverts commit 4141c54c95.

* better peers logs

* better peers logs
2021-07-04 08:51:08 +01:00
alex.sharov
4141c54c95 Revert "better handshake"
This reverts commit 1db9d2ca95.
2021-07-04 10:55:34 +07:00
alex.sharov
1db9d2ca95 better handshake 2021-07-04 10:55:15 +07:00
alex.sharov
bf06a2ce4b better peers logging 2021-07-03 10:35:11 +07:00
Alex Sharov
ea81761991
enable private rpc by default in Erigon, better logs in the beginning (#2262) 2021-07-01 22:30:55 +01:00
Alex Sharov
59d05dc5fe
hide file exists err (#2218) 2021-06-22 11:09:45 +01:00
Artem Vorotnikov
af836a6200
Nuke LMDB (#2167) 2021-06-16 13:57:58 +03:00
Artem Vorotnikov
9a8c0f9669
Always enable eth65 (#2166)
* Always enable eth65

* Add ListenAddr65 to defaults
2021-06-15 17:57:26 +01:00
BitBaseBit
7ed337cdcc
Implemented panic handling, graceful shutdown and reporting for all goroutines that don't explicitly handle them. (#2153)
* implemented crash reporting for all goroutine panics that aren't handled explicitly

* implemented crash reporting for all goroutine panics that aren't handled explicitly

* changed node defaults back to originals after testing

* implemented panic handling for all goroutines that don't explicitly handle them, outputting the stack trace to a file in crashreports

* handling panics on all goroutines gracefully

* updated missing call

* error assignment

* implemented suggestions

* path.Join added

* implemented Evgeny's suggestions

* changed path.Join to filepath.Join for cross-platform

* added err check

* updated RecoverStackTrace to LogPanic

* updated closures

* removed call of common.Go to some goroutines

* updated scope capture

* removed testing files

* reverted back to original method, I feel like its less intrusive

* update filename for clarity
2021-06-13 17:41:39 +01:00
Alex Sharov
759af6a15d
cli param to enable eth65 and counfigure it's port (#2075)
* cli param to enable eth65

* save

* save
2021-06-02 08:43:24 +01:00
Alex Sharov
3016b96e88
1 Sentry per protocol (#2046) 2021-05-30 09:53:30 +07:00
Alex Sharov
0be3044b7e
rename (#1978)
* rename

* rename "make grpc"

* rename "abi bindings templates"

* rename "abi bindings templates"
2021-05-20 19:25:53 +01:00
Alex Sharov
9d66aa0fe3
better support for mdbx in snapshots (#1971) 2021-05-20 18:12:07 +07:00
Alex Sharov
249b3098cb
add --sentry.api.addr flag (#1850)
* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr

* add --sentry.api.addr
2021-04-30 16:09:03 +01:00
Felföldi Zsolt
0d8a69b8c6 les: switch to new discv5 (#21940)
This PR enables running the new discv5 protocol in both LES client
and server mode. In client mode it mixes discv5 and dnsdisc iterators
(if both are enabled) and filters incoming ENRs for "les" tag and fork ID.
The old p2p/discv5 package and all references to it are removed.

Co-authored-by: Felix Lange <fjl@twurst.com>
# Conflicts:
#	cmd/bootnode/main.go
#	cmd/faucet/faucet.go
#	cmd/utils/flags.go
#	les/client.go
#	les/commons.go
#	les/enr_entry.go
#	les/server.go
#	les/serverpool.go
#	les/serverpool_test.go
#	mobile/discover.go
#	mobile/params.go
#	p2p/discv5/database.go
#	p2p/discv5/metrics.go
#	p2p/discv5/net.go
#	p2p/discv5/net_test.go
#	p2p/discv5/node.go
#	p2p/discv5/node_test.go
#	p2p/discv5/sim_test.go
#	p2p/discv5/table.go
#	p2p/discv5/table_test.go
#	p2p/discv5/ticket.go
#	p2p/discv5/topic.go
#	p2p/discv5/topic_test.go
#	p2p/discv5/udp.go
#	p2p/server.go
2021-03-09 12:54:06 +01:00