Bitcoin Forum
April 26, 2024, 09:07:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can this fix a Problematic block in Bitcoin Core?  (Read 157 times)
Davidvictorson (OP)
Hero Member
*****
Offline Offline

Activity: 966
Merit: 829


Livecasino.io


View Profile
June 05, 2023, 08:40:38 AM
 #1

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.

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
You can see the statistics of your reports to moderators on the "Report to moderator" pages.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
un_rank
Hero Member
*****
Offline Offline

Activity: 700
Merit: 674


- Jay -


View Profile WWW
June 05, 2023, 08:50:55 AM
Merited by vapourminer (1)
 #2

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 -

██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18507


View Profile
June 05, 2023, 09:45:27 AM
Merited by ABCbits (2), vapourminer (1)
 #3

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
tromp
Legendary
*
Offline Offline

Activity: 977
Merit: 1076


View Profile
June 05, 2023, 10:42:11 AM
Last edit: June 05, 2023, 11:47:36 AM by tromp
Merited by ABCbits (1)
 #4

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.

o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18507


View Profile
June 05, 2023, 04:57:51 PM
 #5

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?
tromp
Legendary
*
Offline Offline

Activity: 977
Merit: 1076


View Profile
June 05, 2023, 06:02:06 PM
Merited by o_e_l_e_o (4)
 #6

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.
Davidvictorson (OP)
Hero Member
*****
Offline Offline

Activity: 966
Merit: 829


Livecasino.io


View Profile
June 06, 2023, 08:03:01 AM
 #7

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.

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
nc50lc
Legendary
*
Offline Offline

Activity: 2394
Merit: 5538


Self-proclaimed Genius


View Profile
June 06, 2023, 08:23:44 AM
Merited by o_e_l_e_o (4), ABCbits (2)
 #8

-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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18507


View Profile
June 06, 2023, 12:07:05 PM
Merited by ABCbits (1)
 #9

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.
Davidvictorson (OP)
Hero Member
*****
Offline Offline

Activity: 966
Merit: 829


Livecasino.io


View Profile
June 06, 2023, 02:09:26 PM
 #10

-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.

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!