ethereum-optimism / op-geth

GNU Lesser General Public License v3.0
254 stars 652 forks source link

Synchronise full nodes via syncmode=snap #294

Closed YuXiaoCoder closed 1 month ago

YuXiaoCoder commented 2 months ago

System information

Geth version: v1.101308.3, us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101308.3 OP-Node Version: v1.7.2, us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.7.2 OS & Version: Ubuntu 22.04 Docker

Expected behaviour

Expect to be able to synchronise a full node from zero by specifying syncmode=snap, Refer to the documentation: Snap-Sync

/opt/opmain/core/op-geth --networkid=10 --gcmode=full --syncmode=snap --db.engine=pebble --state.scheme=path --datadir=/mnt/opmain/node/geth --http --http.addr=0.0.0.0 --http.port=8545 --http.vhosts=* --http.corsdomain=* --http.api=admin,eth,net,web3,personal,debug,txpool --authrpc.addr=127.0.0.1 --authrpc.port=8551 --authrpc.jwtsecret=/mnt/opmain/node/jwt.hex --authrpc.vhosts=* --rollup.disabletxpoolgossip=true --rollup.sequencerhttp=https://mainnet-sequencer.optimism.io --nodiscover --maxpeers=0 --port=30303 --discovery.port=30303 --rpc.gascap=0 --rpc.txfeecap=0

Actual behaviour

As per the documentation, I did not provide a bedrock datadir and specified networkid=10, but the boot log identifies the network id as 1

INFO [04-09|16:49:34.775] Maximum peer count                       ETH=0 total=0
INFO [04-09|16:49:34.776] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [04-09|16:49:34.776] Using pebble as db engine
INFO [04-09|16:49:34.779] Global gas cap disabled
INFO [04-09|16:49:34.779] Initializing the KZG library             backend=gokzg
INFO [04-09|16:49:34.803] Allocated trie memory caches             clean=154.00MiB dirty=256.00MiB
INFO [04-09|16:49:34.803] Using pebble as the backing database
INFO [04-09|16:49:34.803] Allocated cache and file handles         database=/mnt/opmain/node/geth/geth/chaindata cache=512.00MiB handles=524,288
INFO [04-09|16:49:34.826] Opened ancient database                  database=/mnt/opmain/node/geth/geth/chaindata/ancient/chain readonly=false
INFO [04-09|16:49:34.826] State schema set to default              scheme=hash
INFO [04-09|16:49:34.828] Writing default main-net genesis block
INFO [04-09|16:49:35.180] Persisted trie from memory database      nodes=12356 size=1.79MiB time=61.431775ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=0 livesize=0.00B
INFO [04-09|16:49:35.220]
INFO [04-09|16:49:35.220] ---------------------------------------------------------------------------------------------------------------------------------------------------------
INFO [04-09|16:49:35.221] Chain ID:  1 (mainnet)
INFO [04-09|16:49:35.221] Consensus: Beacon (proof-of-stake), merged from Ethash (proof-of-work)
INFO [04-09|16:49:35.221]
INFO [04-09|16:49:35.221] Pre-Merge hard forks (block based):
INFO [04-09|16:49:35.221]  - Homestead:                   #1150000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)
INFO [04-09|16:49:35.221]  - DAO Fork:                    #1920000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/dao-fork.md)
INFO [04-09|16:49:35.221]  - Tangerine Whistle (EIP 150): #2463000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/tangerine-whistle.md)
INFO [04-09|16:49:35.221]  - Spurious Dragon/1 (EIP 155): #2675000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)
INFO [04-09|16:49:35.221]  - Spurious Dragon/2 (EIP 158): #2675000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)
INFO [04-09|16:49:35.221]  - Byzantium:                   #4370000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/byzantium.md)
INFO [04-09|16:49:35.221]  - Constantinople:              #7280000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/constantinople.md)
INFO [04-09|16:49:35.221]  - Petersburg:                  #7280000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/petersburg.md)
INFO [04-09|16:49:35.221]  - Istanbul:                    #9069000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/istanbul.md)
INFO [04-09|16:49:35.221]  - Muir Glacier:                #9200000  (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/muir-glacier.md)
INFO [04-09|16:49:35.221]  - Berlin:                      #12244000 (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md)
INFO [04-09|16:49:35.221]  - London:                      #12965000 (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)
INFO [04-09|16:49:35.221]  - Arrow Glacier:               #13773000 (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/arrow-glacier.md)
INFO [04-09|16:49:35.221]  - Gray Glacier:                #15050000 (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/gray-glacier.md)
INFO [04-09|16:49:35.221]
INFO [04-09|16:49:35.221] Merge configured:
INFO [04-09|16:49:35.221]  - Hard-fork specification:    https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md
INFO [04-09|16:49:35.221]  - Network known to be merged: true
INFO [04-09|16:49:35.221]  - Total terminal difficulty:  58750000000000000000000
INFO [04-09|16:49:35.221]
INFO [04-09|16:49:35.221] Post-Merge hard forks (timestamp based):
INFO [04-09|16:49:35.221]  - Shanghai:                    @1681338455 (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)
INFO [04-09|16:49:35.221]
INFO [04-09|16:49:35.221] ---------------------------------------------------------------------------------------------------------------------------------------------------------
INFO [04-09|16:49:35.221]
INFO [04-09|16:49:35.221] Loaded most recent local block           number=0 hash=d4e567..cb8fa3 td=17,179,869,184 age=55y3w1d
WARN [04-09|16:49:35.221] Failed to load snapshot                  err="missing or corrupted snapshot"
INFO [04-09|16:49:35.223] Rebuilding state snapshot
INFO [04-09|16:49:35.225] Initialising Ethereum protocol           network=10 dbversion=<nil>
INFO [04-09|16:49:35.225] Resuming state snapshot generation       root=d7f897..0f0544 accounts=0 slots=0 storage=0.00B dangling=0 elapsed=1.534ms
INFO [04-09|16:49:35.225] Regenerated local transaction journal    transactions=0 accounts=0
INFO [04-09|16:49:35.225] Initialized transaction indexer          limit=2,350,000
INFO [04-09|16:49:35.231] Enabled snap sync                        head=0 hash=d4e567..cb8fa3
INFO [04-09|16:49:35.231] Chain post-merge, sync via beacon client
INFO [04-09|16:49:35.231] Gasprice oracle is ignoring threshold set threshold=2
WARN [04-09|16:49:35.233] Engine API enabled                       protocol=eth
INFO [04-09|16:49:35.233] Starting peer-to-peer node               instance=Geth/v0.1.0-unstable-0ff6f563/linux-amd64/go1.21.8
INFO [04-09|16:49:35.245] New local node record                    seq=1,712,652,575,244 id=34462fffc99952a6 ip=127.0.0.1 udp=0 tcp=30303
INFO [04-09|16:49:35.245] Started P2P networking                   self="enode://08656eef77771e14605aab711a05bb69f4456f774deb9ec14a1cfc85a1bcb111d32be12f22cdb1712c28068494e8cb7473d69c89fcb47e196850cdaacc6372fa@127.0.0.1:30303?discport=0"
INFO [04-09|16:49:35.245] IPC endpoint opened                      url=/mnt/opmain/node/geth/geth.ipc
INFO [04-09|16:49:35.246] Loaded JWT secret file                   path=/mnt/opmain/node/jwt.hex crc32=0x223d6a08
INFO [04-09|16:49:35.246] HTTP server started                      endpoint=[::]:8545 auth=false prefix= cors=* vhosts=*
INFO [04-09|16:49:35.246] WebSocket enabled                        url=ws://127.0.0.1:8551
INFO [04-09|16:49:35.246] HTTP server started                      endpoint=127.0.0.1:8551 auth=true  prefix= cors=localhost vhosts=*
INFO [04-09|16:49:35.272] Generated state snapshot                 accounts=8893 slots=0 storage=409.64KiB dangling=0 elapsed=49.275ms
WARN [04-09|16:50:10.234] Post-merge network, but no beacon client seen. Please launch one to follow the chain!
INFO [04-09|16:51:14.627] Got interrupt, shutting down...
INFO [04-09|16:51:14.627] HTTP server stopped                      endpoint=[::]:8545
INFO [04-09|16:51:14.627] HTTP server stopped                      endpoint=127.0.0.1:8551
INFO [04-09|16:51:14.627] IPC endpoint closed                      url=/mnt/opmain/node/geth/geth.ipc
INFO [04-09|16:51:14.627] Ethereum protocol stopped
INFO [04-09|16:51:14.627] Transaction pool stopped

This causes OP-node to report an error as well.

t=2024-04-09T16:51:12+0800 lvl=info msg="Not opted in to ProtocolVersions signal loading, disabling ProtocolVersions contract now."
t=2024-04-09T16:51:12+0800 lvl=info msg="Rollup Config" l2_chain_id=10 l2_network=OP-Mainnet l1_chain_id=1 l1_network=mainnet l2_start_time=1686068903 l2_block_hash=0xdbf6a80fef073de06add9b0d14026d6e5a86c85f6d102c36d3d8e9cf89c2afd3 l2_block_number=105235063 l1_block_hash=0x438335a20d98863a4c0c97999eb2481921ccd28553eac6f913af7c12aec04108 l1_block_number=17422590 regolith_time="@ genesis" canyon_time="@ 1704992401 ~ Fri Jan 12 01:00:01 CST 2024" delta_time="@ 1708560000 ~ Thu Feb 22 08:00:00 CST 2024" ecotone_time="@ 1710374401 ~ Thu Mar 14 08:00:01 CST 2024" fjord_time="(not configured)" interop_time="(not configured)"
t=2024-04-09T16:51:12+0800 lvl=info msg="Initializing rollup node" version=v0.0.0-99a53381-1710933867
t=2024-04-09T16:51:12+0800 lvl=info msg="Connected to L1 Beacon API, ready for EIP-4844 blobs retrieval." version="Prysm/v5.0.3 (linux amd64)"
t=2024-04-09T16:51:12+0800 lvl=eror msg="Error initializing the rollup node" err="failed to init L2: incorrect L2 RPC chain id 1, expected 10"
t=2024-04-09T16:51:12+0800 lvl=crit msg="Application failed" message="failed to setup: unable to create the rollup node: failed to init L2: incorrect L2 RPC chain id 1, expected 10"

Steps to reproduce the behaviour

/opt/opmain/core/op-geth --networkid=10 --gcmode=full --syncmode=snap --db.engine=pebble --state.scheme=path --datadir=/mnt/opmain/node/geth
opfocus commented 2 months ago

Try replacing --networkid=10 with --op-network=op-mainnet

YuXiaoCoder commented 2 months ago

The service is up and running, synchronising headers now.

YuXiaoCoder commented 2 months ago

@opfocus How long will this process take?

INFO [04-09|20:20:21.614] Forkchoice requested sync to new head    number=118,533,222 hash=fedefe..c029ba
INFO [04-09|20:20:24.252] Forkchoice requested sync to new head    number=118,533,223 hash=177908..522036
INFO [04-09|20:20:26.248] Forkchoice requested sync to new head    number=118,533,224 hash=0f1105..158aec
INFO [04-09|20:20:27.930] Forkchoice requested sync to new head    number=118,533,225 hash=8849a9..6897c1
quickchase commented 2 months ago

You also need peers for snap sync, you should ideally remove

--nodiscover --maxpeers=0
opfocus commented 2 months ago

@opfocus How long will this process take?

INFO [04-09|20:20:21.614] Forkchoice requested sync to new head    number=118,533,222 hash=fedefe..c029ba
INFO [04-09|20:20:24.252] Forkchoice requested sync to new head    number=118,533,223 hash=177908..522036
INFO [04-09|20:20:26.248] Forkchoice requested sync to new head    number=118,533,224 hash=0f1105..158aec
INFO [04-09|20:20:27.930] Forkchoice requested sync to new head    number=118,533,225 hash=8849a9..6897c1

Sorry, I have not run a mainnet node . You can observe the log of the op-node sync processto get a rough estimate.

YuXiaoCoder commented 2 months ago

You also need peers for snap sync, you should ideally remove

--nodiscover --maxpeers=0

I removed this flag and geth started syncing up, thanks

YuXiaoCoder commented 2 months ago

@opfocus How long will this process take?

INFO [04-09|20:20:21.614] Forkchoice requested sync to new head    number=118,533,222 hash=fedefe..c029ba
INFO [04-09|20:20:24.252] Forkchoice requested sync to new head    number=118,533,223 hash=177908..522036
INFO [04-09|20:20:26.248] Forkchoice requested sync to new head    number=118,533,224 hash=0f1105..158aec
INFO [04-09|20:20:27.930] Forkchoice requested sync to new head    number=118,533,225 hash=8849a9..6897c1

Sorry, I have not run a mainnet node . You can observe the log of the op-node sync processto get a rough estimate.

Thank you very much, I will check it out