celo-blockchain icon indicating copy to clipboard operation
celo-blockchain copied to clipboard

Use full node in geth import command (using istanbul engine)

Open hbandura opened this issue 3 years ago • 4 comments

Currently, geth import is broken. This is due to the node created during config lacking the proper consensus engine.

This PR ensures the node created during the import command to have the proper istanbul engine.

hbandura avatar Dec 11 '21 03:12 hbandura

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit de5a944722c79045b8f3692df998f598b1a11133

coverage: 42.6% of statements across all listed packages
coverage:  47.4% of statements in consensus/istanbul
coverage:  23.7% of statements in consensus/istanbul/announce
coverage:  54.4% of statements in consensus/istanbul/backend
coverage:   0.0% of statements in consensus/istanbul/backend/backendtest
coverage:  24.3% of statements in consensus/istanbul/backend/internal/replica
coverage:  51.1% of statements in consensus/istanbul/core
coverage:  45.0% of statements in consensus/istanbul/db
coverage:   0.0% of statements in consensus/istanbul/proxy
coverage:  64.4% of statements in consensus/istanbul/uptime
coverage:  51.8% of statements in consensus/istanbul/validator
coverage:  79.2% of statements in consensus/istanbul/validator/random
CommentID: 762c9e6792

piersy avatar Dec 11 '21 03:12 piersy

@hbandura how can I test this?

piersy avatar Dec 15 '21 22:12 piersy

@piersy

geth export _file_ [_startblock_ _endblock_]. then with a clean node geth import _file_

e.g geth export mychain or geth export mychain 0 1000000

then run the import

geth import mychain

hbandura avatar Jan 05 '22 14:01 hbandura

Hi @hbandura this is not working for me. Please excuse the strange characters, my shell prompt doesn't seem to display nicely in github.

I ran a network with mycelo (not shown) and then ran a local node connecting to that network and then stopped the local node and exported the data (this worked) but then trying to import that failed, see below.

    ~/projects/celo-blockchain   #v1.5.4 *23 !2 ?20 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔  9s   11:06:12 
 ./build/bin/geth --datadir localnode --bootnodes `./build/bin/geth attach --exec "admin.nodeInfo" http://localhost:8545 | perl -n -e 's/enode: "(.+?)",/\1/ && print' | perl -p -e 's/\?discport=0//'`  --port 30333 --http --http.port 8081 --http.api personal,eth,net,web3,debug
INFO [03-03|11:06:17.088] Starting Geth on Celo mainnet...
INFO [03-03|11:06:17.088] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [03-03|11:06:17.088] Maximum peer count                       ETH=175 LES=0 total=175
INFO [03-03|11:06:17.089] Set global gas cap                       cap=25,000,000
INFO [03-03|11:06:17.089] Allocated trie memory caches             clean=614.00MiB dirty=1024.00MiB
INFO [03-03|11:06:17.089] Allocated cache and file handles         database=/Users/piersy/projects/celo-blockchain/localnode/celo/chaindata cache=2.00GiB handles=5120
INFO [03-03|11:06:17.248] Opened ancient database                  database=/Users/piersy/projects/celo-blockchain/localnode/celo/chaindata/ancient readonly=false
INFO [03-03|11:06:17.252] Initialised chain configuration          config="{ChainID: 9099000 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0 Churrito: 0, Donut: 0, Espresso: <nil>, Engine: istanbul}"
INFO [03-03|11:06:17.253] Open roundstate db                       func=newRoundStateDB type=roundStateDB rsdb_path=/Users/piersy/projects/celo-blockchain/localnode/celo/roundstates
INFO [03-03|11:06:17.569] Initialising Ethereum protocol           versions="[67 66]" network=9,099,000 dbversion=8
INFO [03-03|11:06:17.578] Loaded most recent local header          number=0 hash=c9133d..12c9a1 td=1 age=4m20s
INFO [03-03|11:06:17.578] Loaded most recent local full block      number=0 hash=c9133d..12c9a1 td=1 age=4m20s
INFO [03-03|11:06:17.578] Loaded most recent local fast block      number=0 hash=c9133d..12c9a1 td=1 age=4m20s
INFO [03-03|11:06:17.581] Loaded local transaction journal         transactions=0 dropped=0
INFO [03-03|11:06:17.582] Regenerated local transaction journal    transactions=0 accounts=0
INFO [03-03|11:06:17.614] Allocated fast sync bloom                size=2.00GiB
INFO [03-03|11:06:17.615] Starting peer-to-peer node               instance=celo/v1.5.4-stable-cf079449/darwin-amd64/go1.17.6
INFO [03-03|11:06:17.623] Initialized state bloom                  items=541 errorrate=0.000 elapsed=8.114ms
INFO [03-03|11:06:17.734] New local node record                    seq=3 id=fb6d8eb0588c527b ip=127.0.0.1 udp=30333 tcp=30333
INFO [03-03|11:06:17.734] Started P2P networking                   self=enode://1723c57cb48ad8da6f1f9c73f756a17b0f57343853b31d2dbcfc602408771cac089b6f263ca14a282df046cc9b3058d3f635c8a41855713577a4e207c960e689@127.0.0.1:30333 maxdialed=58 maxinbound=117
INFO [03-03|11:06:17.735] IPC endpoint opened                      url=/Users/piersy/projects/celo-blockchain/localnode/geth.ipc
INFO [03-03|11:06:17.735] HTTP server started                      endpoint=127.0.0.1:8081 prefix= cors= vhosts=localhost
INFO [03-03|11:06:17.736] Block synchronisation started
INFO [03-03|11:06:18.080] Imported new block headers               count=52 elapsed=340.761ms number=52 hash=0112d1..aeb39b
INFO [03-03|11:06:18.082] Downloader queue stats                   receiptTasks=0 blockTasks=0 itemSize=135.20B throttle=8192
INFO [03-03|11:06:18.087] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=4.979ms   mgasps=0.000 number=1  hash=497693..57ffd0 age=4m16s dirty=4.25KiB
INFO [03-03|11:06:18.403] Imported new chain segment               blocks=51 txs=0 mgas=0.000 elapsed=316.012ms mgasps=0.000 number=52 hash=0112d1..aeb39b dirty=189.01KiB
INFO [03-03|11:06:18.403] Fast sync complete, auto disabling
INFO [03-03|11:06:22.051] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=9.207ms   mgasps=0.000 number=53 hash=4b5cb0..638192 dirty=192.45KiB
INFO [03-03|11:06:27.051] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=9.094ms   mgasps=0.000 number=54 hash=175f2e..91df9e dirty=195.82KiB
INFO [03-03|11:06:28.254] Looking for peers                        peercount=1 tried=1 static=0
INFO [03-03|11:06:32.050] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=8.777ms   mgasps=0.000 number=55 hash=3a305f..b205f0 dirty=199.22KiB
^CINFO [03-03|11:06:32.265] Got interrupt, shutting down...
INFO [03-03|11:06:32.266] HTTP server stopped                      endpoint=127.0.0.1:8081
INFO [03-03|11:06:32.266] IPC endpoint closed                      url=/Users/piersy/projects/celo-blockchain/localnode/geth.ipc
INFO [03-03|11:06:32.266] Deallocated state bloom                  items=541 errorrate=0.000
ERROR[03-03|11:06:32.267] Peer removal from tx fetcher  failed     peer=1db6fe5848ecb3c0d3262023beca9585bc0a2c40f0fe636d38f1273284254418 err=terminated
INFO [03-03|11:06:32.267] Ethereum protocol stopped
INFO [03-03|11:06:32.267] Transaction pool stopped
ERROR[03-03|11:06:32.267] Error in istanbul's subscription to the blockchain's chain event err=nil
ERROR[03-03|11:06:32.267] Error in istanbul's subscription to the blockchain's chainhead event err=nil
INFO [03-03|11:06:32.268] Writing cached state to disk             block=55 hash=3a305f..b205f0 root=c1589b..72b86d
INFO [03-03|11:06:32.268] Persisted trie from memory database      nodes=108 size=14.57KiB time="593.479µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=535 livesize=118.78KiB
INFO [03-03|11:06:32.268] Writing cached state to disk             block=54 hash=175f2e..91df9e root=2df19d..749f2e
INFO [03-03|11:06:32.268] Persisted trie from memory database      nodes=9   size=2.34KiB  time="71.829µs"  gcnodes=0 gcsize=0.00B gctime=0s livenodes=526 livesize=116.45KiB
INFO [03-03|11:06:32.269] Writing snapshot state to disk           root=0e5c76..c3ef79
INFO [03-03|11:06:32.269] Persisted trie from memory database      nodes=0   size=0.00B    time="1.845µs"   gcnodes=0 gcsize=0.00B gctime=0s livenodes=526 livesize=116.45KiB
INFO [03-03|11:06:32.270] Writing clean trie cache to disk         path=/Users/piersy/projects/celo-blockchain/localnode/celo/triecache threads=12
INFO [03-03|11:06:32.278] Persisted the clean trie cache           path=/Users/piersy/projects/celo-blockchain/localnode/celo/triecache elapsed=8.533ms
INFO [03-03|11:06:32.278] Blockchain stopped
    ~/projects/celo-blockchain   #v1.5.4 *23 !2 ?20 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔  16s   11:06:32 
 ./build/bin/geth --datadir localnode export backup
INFO [03-03|11:07:19.045] Maximum peer count                       ETH=175 LES=0 total=175
INFO [03-03|11:07:19.046] Set global gas cap                       cap=25,000,000
INFO [03-03|11:07:19.046] Allocated cache and file handles         database=/Users/piersy/projects/celo-blockchain/localnode/celo/chaindata cache=512.00MiB handles=5120
INFO [03-03|11:07:19.347] Opened ancient database                  database=/Users/piersy/projects/celo-blockchain/localnode/celo/chaindata/ancient readonly=false
INFO [03-03|11:07:19.349] Loaded most recent local header          number=55 hash=3a305f..b205f0 td=56 age=47s
INFO [03-03|11:07:19.349] Loaded most recent local full block      number=55 hash=3a305f..b205f0 td=56 age=47s
INFO [03-03|11:07:19.349] Loaded most recent local fast block      number=55 hash=3a305f..b205f0 td=56 age=47s
INFO [03-03|11:07:19.349] Loaded last fast-sync pivot marker       number=0
INFO [03-03|11:07:19.354] Exporting blockchain                     file=backup
INFO [03-03|11:07:19.369] Exporting batch of blocks                count=56
INFO [03-03|11:07:19.412] Exported blockchain                      file=backup
Export done in 58.195662ms
    ~/projects/celo-blockchain   #v1.5.4 *23 !2 ?21 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔  11:07:19 
 ./build/bin/geth --datadir localnode2 import backup
INFO [03-03|11:07:48.644] Maximum peer count                       ETH=175 LES=0 total=175
INFO [03-03|11:07:48.645] Set global gas cap                       cap=25,000,000
INFO [03-03|11:07:48.645] Allocated cache and file handles         database=/Users/piersy/projects/celo-blockchain/localnode2/celo/chaindata cache=512.00MiB handles=5120
INFO [03-03|11:07:48.873] Opened ancient database                  database=/Users/piersy/projects/celo-blockchain/localnode2/celo/chaindata/ancient readonly=false
INFO [03-03|11:07:48.874] Writing default main-net genesis block
INFO [03-03|11:07:48.876] Persisted trie from memory database      nodes=45 size=6.75KiB time="254.109µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
INFO [03-03|11:07:48.878] Loaded most recent local header          number=0 hash=19ea33..bd11c3 td=1 age=1y10mo2w
INFO [03-03|11:07:48.878] Loaded most recent local full block      number=0 hash=19ea33..bd11c3 td=1 age=1y10mo2w
INFO [03-03|11:07:48.878] Loaded most recent local fast block      number=0 hash=19ea33..bd11c3 td=1 age=1y10mo2w
WARN [03-03|11:07:48.878] Failed to load snapshot, regenerating    err="missing or corrupted snapshot"
INFO [03-03|11:07:48.878] Rebuilding state snapshot
INFO [03-03|11:07:48.878] Resuming state snapshot generation       root=b7424a..a67167 accounts=0 slots=0 storage=0.00B elapsed="334.498µs"
INFO [03-03|11:07:48.879] Importing blockchain                     file=backup
INFO [03-03|11:07:48.879] Generated state snapshot                 accounts=32 slots=1 storage=1.67KiB elapsed=1.355ms
WARN [03-03|11:07:48.880] Failed to load old bad blocks            error="leveldb: not found"
ERROR[03-03|11:07:48.881]
########## BAD BLOCK #########
Chain config: {ChainID: 9099000 Homestead: 0 DAO: <nil> DAOSupport: true EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0 Churrito: 6774000, Donut: 6774000, Espresso: 11838440, Engine: istanbul}

Number: 1
Hash: 0x4976937307346efa8e71a80babaca5ce49e834dc3d809d2c4458116f8857ffd0


Error: unknown ancestor
##############################

ERROR[03-03|11:07:48.881] Import error                             file=backup err="invalid block 55: unknown ancestor"
INFO [03-03|11:07:48.881] Writing snapshot state to disk           root=b7424a..a67167
INFO [03-03|11:07:48.881] Persisted trie from memory database      nodes=0  size=0.00B   time="1.925µs"   gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [03-03|11:07:48.881] Blockchain stopped
Import done in 2.538605ms.

Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
-------+------------+---------------+---------------+---------------+---------------
 Total |          0 |       0.00000 |       0.00000 |       0.00000 |       0.00000

Read(MB):0.00000 Write(MB):0.02334
Object memory: 131.736 MB current, 130.990 MB peak
System memory: 152.710 MB current, 147.960 MB peak
Allocations:   0.037 million
GC pause:      119.741µs

Compacting entire database...
Compaction done in 99.328373ms.

Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
   0   |          0 |       0.00000 |       0.05670 |       0.00000 |       0.01858
   1   |          1 |       0.01852 |       0.03905 |       0.01858 |       0.01852
-------+------------+---------------+---------------+---------------+---------------
 Total |          1 |       0.01852 |       0.09575 |       0.01858 |       0.03709

Read(MB):0.01837 Write(MB):0.06067
invalid block 55: unknown ancestor

piersy avatar Mar 03 '22 11:03 piersy

I've successfully used geth import on our current master with mycelo. Should we close this?

karlb avatar Apr 14 '23 08:04 karlb

Closing this as we don't plan to include this in the short term.

palango avatar Aug 28 '23 15:08 palango