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
1
  • 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
    Commented Mar 7, 2016 at 9:10

3 Answers 3

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.

5
  • would you start geth to reload the chain or direct with geth --fast?
    – xpnimi
    Commented Mar 7, 2016 at 15:39
  • 1
    geth --fast --cache=512 console is how I would personally start geth :D Commented Mar 7, 2016 at 15:40
  • 12
    Isn't it more careful to use "geth removedb" instead? It's its purpose.
    – bortzmeyer
    Commented Jun 30, 2017 at 7:39
  • 1
    For Mac OSX rm -R ~/Library/Ethereum/geth/chaindata/
    – ramusus
    Commented Jul 14, 2017 at 1:55
  • geth removedb
    – chovy
    Commented Aug 26, 2021 at 14:53
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?.

1
  • 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 Commented Jul 30, 2016 at 22:33
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).

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.