Author

Topic: Can this fix a Problematic block in Bitcoin Core? (Read 157 times)

hero member
Activity: 952
Merit: 824
Livecasino.io
-snip-; that it is possible to fix a corrupt blk*.dat file and it can be done as long as I do not something crazy to the block that changes the consensus rule.  
So it's just a simple "fix" to a corrupted block.dat file.

Bitcoin Core already has a feature that can detect corrupted blocks or other data and may start with an error.
Running command line option at start like -reindex (depending on the error) is the usual solution to this, no need to change a line code or anything.

What everyone explained is if you want to change in the protocol, because it is what OP sounds like.
Thank you nc50lc clarification and o_e_l_e_o for the elaboration. Obviously I still have a lot to learn here but this is a good start that would build on the already future learning on this subject matter.
legendary
Activity: 2268
Merit: 18509
Hey o_e_l_e_o, this is just what I was looking for; that it is possible to fix a corrupt blk*.dat file and it can be done as long as I do not something crazy to the block that changes the consensus rule.
So this is a completely different scenario to what you described in your first post. You cannot fix a corrupted block by editing your Bitcoin Core files, since the two things are entirely separate. You also shouldn't try to manually edit your blk*.dat files to fix a mistake, as you will almost certainly just create more errors in the process.

As nc50lc says, the correct approach to a corrupted blk*.dat file is to run Bitcoin Core with the -reindex option. This will wipe your block index and your chainstate and build them from your blk*.dat files. If it finds a corrupted block or blocks, it will request a replacement from peers.
legendary
Activity: 2394
Merit: 5531
Self-proclaimed Genius
-snip-; that it is possible to fix a corrupt blk*.dat file and it can be done as long as I do not something crazy to the block that changes the consensus rule.  
So it's just a simple "fix" to a corrupted block.dat file.

Bitcoin Core already has a feature that can detect corrupted blocks or other data and may start with an error.
Running command line option at start like -reindex (depending on the error) is the usual solution to this, no need to change a line code or anything.

What everyone explained is if you want to change in the protocol, because it is what OP sounds like.
hero member
Activity: 952
Merit: 824
Livecasino.io
You can freely edit the code of your own copy of Bitcoin Core to make it run locally in a specific way you choose, such as changing your mempool parameters, what criteria you will accept for replacing transactions, how many nodes you will connect to, what you will relay, and so forth. There is no problem making these kinds of changes and your node will continue to run and connect to peers just fine.

Hey o_e_l_e_o, this is just what I was looking for; that it is possible to fix a corrupt blk*.dat file and it can be done as long as I do not something crazy to the block that changes the consensus rule. 
This is not my strong point though but I am still in the rabbit hole hopefully soon enough, I will get the hang of it. Thank you all.
legendary
Activity: 978
Merit: 1080
Even before I successfully mine a block at height 481,826, can we not say that I am working on a forked version of the main chain?
Working on? Yes, we can say that. Even if you start coding the consensus changes, you're working on the fork.

Forked away? That is much less clear.
I would say not, since the "away" suggests each has gone its own way.
legendary
Activity: 2268
Merit: 18509
You won't have forked away until you produce at least one block with the differing consensus rule.
Let's say I implement a change which considers all segwit transactions invalid. As such, my local chain rolls back to block 481,825, and I consider everything after that invalid. Even before I successfully mine a block at height 481,826, can we not say that I am working on a forked version of the main chain?
legendary
Activity: 978
Merit: 1080
The issue will arise if you make a change which breaks with the consensus rules - for example, you start considering some blocks invalid, which the rest of the network still considers valid. At that point you will have forked yourself away from the main network and on to your own personal branch.
You won't have forked away until you produce at least one block with the differing consensus rule.

But unless you have a sizeable mining operation, it could take you years to even come up with a block satisfying the current difficulty...

The only exception is when your consensus changes include changing the PoW and/or difficulty rules.

legendary
Activity: 2268
Merit: 18509
You can freely edit the code of your own copy of Bitcoin Core to make it run locally in a specific way you choose, such as changing your mempool parameters, what criteria you will accept for replacing transactions, how many nodes you will connect to, what you will relay, and so forth. There is no problem making these kinds of changes and your node will continue to run and connect to peers just fine.

The issue will arise if you make a change which breaks with the consensus rules - for example, you start considering some blocks invalid, which the rest of the network still considers valid. At that point you will have forked yourself away from the main network and on to your own personal branch.

This is of course assuming you don't make a change which just breaks something entirely. Wink
hero member
Activity: 644
Merit: 661
- Leo -
You will have to provide some more information like what sort of error you can notice and if it is in your candidate block or one already confirmed on the blockchain.

The blockchain is immutable, meaning it is not subject to change. You cannot make changes to a block that has already been confirmed and added to the chain, if there is any malicious activity going on, using consensus the malicious chain can be abandoned and everyone would continue with the genuine one.

- Jay -
hero member
Activity: 952
Merit: 824
Livecasino.io
Let me paint a scenario: if I am running a Python script and notice an error in the output, I simply locate the line where the error occurs, make the necessary corrections, and then rerun the script.

Now, assuming that the Python script in question is Bitcoin Core 25.0, and I notice an error in a line or a block. Just like in a Python script, if I rewrite the problematic block (assuming I am able to do so) and rerun the script, would it work?

PS: Please pardon my Python script scenario. I know it may not be the best scenario to paint here in this case but it is just how my brain is trying to process it for easier understanding.
Jump to: