erigontech / erigon

Ethereum implementation on the efficiency frontier https://erigon.gitbook.io
GNU Lesser General Public License v3.0
3.15k stars 1.13k forks source link

DevP2P port uses 30303, ignores provided --port flag #8330

Open jakubgs opened 1 year ago

jakubgs commented 1 year ago

System information

Erigon version: 2.49.3 OS & Version: Ubuntu 22.04

Erigon Command: click to unfold
--chain=holesky
--maxpeers=20
--port=30305
--nat=extip:194.33.40.148
--allow-insecure-unlock
--datadir=/data
--mine=true
--miner.sigfile=/keys/sigfile
--prune=hrtc
--metrics
--metrics.addr=0.0.0.0
--metrics.port=6062
--http
--http.addr=0.0.0.0
--http.port=8547
--http.api=eth,net,erigon,admin,engine
--authrpc.addr=0.0.0.0
--authrpc.port=8553
--authrpc.jwtsecret=/keys/jwtsecret
--v5disc=true

Concensus Layer: Nimbus Beacon Node 23.9.1

Erigon Command: click to unfoldConcensus Layer Command (with flags/config): click to unfold
--network=holesky
--history=prune
--el=http://localhost:8553
--jwt-secret=jwt.hex
--log-format=json
--log-level=DEBUG
--nat=extip:194.33.40.148
--tcp-port=9002
--udp-port=9002
--max-peers=320
--insecure-netkey-password=true
--sync-light-client=false
--subscribe-all-subnets=false
--doppelganger-detection=true
--num-threads=0
--rest=true
--rest-address=0.0.0.0
--rest-port=9302
--rest-max-body-size=16384
--rest-max-headers-size=128
--metrics=true
--metrics-address=0.0.0.0
--metrics-port=9202
--validator-monitor-auto=true
--validator-monitor-details=false

Chain/Network: holesky

Expected behaviour

The DevP2P port listens on the port specified via --port flag.

Actual behaviour

The DevP2P port is listening on 30303 despite flag specifying a different value.

/ # ps faux
PID   USER     TIME  COMMAND
    1 root     28:33 /usr/local/bin/erigon --chain=holesky --maxpeers=20 --port=30306 ...

/ # netstat -lpnt | grep -e 3030 -e Proto
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 :::30303                :::*                    LISTEN      1/erigon
tcp        0      0 :::30304                :::*                    LISTEN      1/erigon

Steps to reproduce the behaviour

Use --port with value different than 30303.

jakubgs commented 1 year ago

I just found out about this flag:

--p2p.allowed-ports value [ --p2p.allowed-ports value ]  Allowed ports to pick for different eth p2p protocol versions as follows <porta>,<portb>,..,<porti> (default: 30303, 30304, 30305, 30306, 30307)

What kind of silly formatting is this, and what the hell does portb or porti mean?

jakubgs commented 1 year ago

If I specify just one port for --p2p.allowed-ports I get this:

EROR Erigon startup    err="run out of allowed ports for p2p eth protocols [40404]. Extend allowed port list via --p2p.allowed-ports"

What is this weird behavior? I've never seen this with any other exec layer clients.

jakubgs commented 1 year ago

Could someone elucidate the difference between --port and --p2p.allowed-ports?

jakubgs commented 1 year ago

If I use --port 40403 --p2p.allowed-ports 40404 I get:

 > d exec -it test netstat -lpnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:42069           0.0.0.0:*               LISTEN      1/erigon
tcp        0      0 127.0.0.1:8551          0.0.0.0:*               LISTEN      1/erigon
tcp        0      0 127.0.0.1:8545          0.0.0.0:*               LISTEN      1/erigon
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      1/erigon
tcp        0      0 :::40403                :::*                    LISTEN      1/erigon
tcp        0      0 :::40404                :::*                    LISTEN      1/erigon

Why?

jakubgs commented 1 year ago

So I'm assuming this is related to this flag:

--p2p.protocol value [ --p2p.protocol value ]   Version of eth p2p protocol (default: 68, 67)

Which I assume is the number of ports that will be used from the list provided to --p2p.allowed-ports.

But why? Why is this something no other client does?

jakubgs commented 1 year ago

Is there some kind of magical way to use just the latest version of protocol? Like --p2p.protocol=latest?

jakubgs commented 1 year ago

What I don't get is why does the default value in help message say it's 68, 67 and not just 68 based on this: https://github.com/ledgerwatch/erigon/blob/411913dd161afafdf87c5e30da64b4226fda502c/cmd/devnet/args/node.go#L28

jakubgs commented 1 year ago

It appears the default version is coming from here: https://github.com/ledgerwatch/erigon/blob/b6ffd87e4480a43a425a727b366cc500c59e5dff/cmd/utils/flags.go#L505-L509 Which in turn comes from here: https://github.com/ledgerwatch/erigon/blob/b6ffd87e4480a43a425a727b366cc500c59e5dff/node/nodecfg/defaults.go#L52 But I still don't get why there are two protocols enabled on two different ports.

jakubgs commented 1 year ago

Apparently - based on suggestions on Discord - the --port flag is an "anachronism" and should not be used.

Not sure why it exists then, since it just causes confusion.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

jakubgs commented 1 year ago

I don't think this is stale at all. The flags are confusing and need cleanup, or help message needs updating.

AskAlexSharov commented 1 year ago

right. need or fix it or remove it.