46

I have a currupt Blockchain and want to hard reset the chain. what do I need to delete in order to start downloading the chain from scratch?

I know that there are 2 ethereum folders (I am on OSX):

$home/.ethereum
$home/Libary/Ethereum

I updated geth recently to "Homestead" 1.3.5 and get error in the terminal like:

E0306 ... 3211 trie.go:309] Dangling hash node ref 3c6233326.... leveldb: not found

and sometimes I get a bad block warning:

Bad block #1102797
eth
  • 85,679
  • 53
  • 285
  • 406
xpnimi
  • 723
  • 1
  • 7
  • 10
  • I updated geth to v 1.3.5, but I also installed eth a while ago (v 1.1.0 / eth newtwork protocol version: 61). I didn't use both a lot just fired them up once in a while – xpnimi Mar 07 '16 at 09:10

3 Answers3

40

You can also use geth removedb to remove the blockchain and state databases.

geth removedb
Remove local database? [y/N] 

After removing the old databases, run geth --fast --cache=1024 (see answer to this question by @eth).

Note that using geth --fast will prevent you from using debug.traceTransaction(...) on the blocks that were --fast downloaded. Some further information in How to check the VM trace using Geth? and How can the transaction status from a thrown error be detected when gas can be exactly the same as the gasUsed for a successful transaction?.

See also What is Geth's "fast" sync, and why is it faster?.

guest
  • 401
  • 4
  • 2
  • Also if your pc has more RAM then the --cache=4024 can also be done. And geth --fast can only be used when the blocks database is empty. If you are already downloading the blocks then it is advised not to use geth --fast – radiopassive Jul 30 '16 at 22:33
32

For geth, delete $home/Libary/Ethereum/chaindata. That should wipe out the blockchain itself and let you sync from scratch. Also you probably want to do a fast sync afterwards to get back fast-ish on the chain --fast.

Péter Szilágyi
  • 10,436
  • 39
  • 42
22

For other operating systems, the default datadir is:

Mac: ~/Library/Ethereum
Linux: ~/.ethereum
Windows: %APPDATA%/Ethereum

Delete the chaindata subdirectory that you find.

Run geth --fast --cache=1024 for a recommended way to sync the chain quickly (don't forget to use a bigger --cache with a value like 1024, otherwise the default is 16, and it won't sync as quickly).

eth
  • 85,679
  • 53
  • 285
  • 406
  • https://www.youtube.com/watch?v=vPi3nMmaunY - shows how to find your %APPDATA% folder in windows 10. For me: %AppData%/Roaming/Ethereum/geth/chaindata – nanonerd Apr 10 '17 at 04:27