Is it possible to artificially delete a given block from local chain database without causing any problems? for example, how could I delete the latest block from my local eth node, and resync newly generated blocks from other nodes?

If no known RPCs are available, could I write myself an API to do a delete block operation? As far as I can see, the core.blockchain.go has supported a SetHead function with the following comments:

// SetHead rewinds the local chain to a new head. In the case of headers, everything

// above the new head will be deleted and the new one set. In the case of blocks

// though, the head may be further rewound if block bodies are missing (non-archive

// nodes after a fast sync).

dose that mean I can use this method to reset my local chain head? If so, what will happen to the blocks after this chain head? will these blocks be deleted?

1 Answer 1


There's an api available to set the current block header debug_sethead see the documentation.

There's a warning that you should be aware of.

Note: this is a destructive action and may severely damage your chain. Use with extreme caution.

The removed blocks are not deleted from disk, they are not available because they are not part of the main chain.

If you resync (and the chain did reorganize) those blocks will be part of the main chain again.

The head of the blockchain is like a mark after a reset it will point to the new block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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