31

Yes, it is possible, and you can actually follow "orphaned blocks" here: https://blockchain.info/orphaned-blocks Bitcoin clients always trust the longest chain, so if two blocks is mined on the same time, it's up to (51% of) the miners to decide which is going to be 'accepted' and which is going to be worthless. This is one of the reasons why you shouldn't ...


15

Pieter's answer is good, the chainwork value is the expected work amount in the chain, expressed as a 32 bytes integer, for the double SHA-256 hashes calculation work. The chainwork is used to identify the correct chain, the biggest chainwork value means the strongest or the correct chain. By the way, Satoshi didn't initially realize that choosing the ...


14

What Nicolai said is not completely right. The network would decide which one is the main chain according to the following block mined. Let's assume that block A and B are mined at almost the same time. The miners would accept the first block that was broadcast to them, so there would be some miners accept A and others accept B, it doesn't matter whether A/B ...


13

There are two problems with this: The "longest" block chain is selected not by total number of blocks, but by total difficulty. A chain with a large number of low-difficulty blocks would not win. The Bitcoin reference client hard-codes the hashes of a relatively recent block as a "checkpoint" and will reject any chain not containing that block at the ...


11

Your assumptions are perfectly right. Since there is no information exchange between the two partitions while the network is partitioned, and Bitcoin guarantees liveness, the global consistency suffers (see CAP Theorem). This means that each partition will have its own blockchain fork, unaware of each other. The forks are incompatible not just because the ...


10

Bitcoin Core maintains two databases: The block index The chain state (or UTXO set) The first one just contains a list of all blocks we know about, valid and invalid. It contains all forks we have ever heard about, and all branches that result from it. It also contains information about where on disk these are stored. It does however not contain any ...


10

The "longest" chain is the one with the most work. A chain's work is equal to the expected number of hashes it would take for someone to replicate a chain of the same number of blocks and the exact same difficulty steps. So currently each block adds about 266 work to the chain because it takes on average ~266 hashes to solve a block with the current ...


9

The chainwork value is really just the total amount of work in the chain. It is the total number of hashes that are expected to have been necessary to produce the current chain, in hexadecimal. Converting 0000000000000000000000000000000000000000000086859f7a841475b236fd to decimal, you get 635262017308958427068157, or 635262 exahashes. At june 2014 hash ...


7

Background info: Strongest vs Longest chain and orphaned blocks How does a client decide which is the longest block chain if there is a fork? Where exactly is the "off-by-one" difficulty bug? (timewarp info) A shorter chain could possibly be considered the correct one, but it would be very hard to make this happen in bitcoin. I can think of two ...


7

You're looking for CBlockIndexWorkComparator, which operates by three rules. The rules are applied one at a time, and if a rule leads to a tie, then the next rule is applied. Which blockchain has the most work? Which one was received first? (This can be different for different clients, which is why the previous rule is applied first.) Which one has a ...


7

I am not sure that I can rule out that something useful could be achieved with a tree of blocks, but let me walk you through a few thoughts and you can then tell me whether they answer your question. When we're talking about Bitcoin, we should make clear what we're actually interested in achieving. We're talking about a decentralized system to track value, ...


6

Background info: The block hash must be less than a certain value (as defined by the difficulty function) in order for the block to be valid. Generally, as time has progressed, network difficulty has increased. So as the blockheight has increased, the cutoff value for a valid blockhash has decreased. ————— Why not just e.g. add together all block ...


6

The "apparent" work is 2x higher than actual work due to luck, but the reason it's good bitcoin doesn't use the apparent work is because it has bad stability properties due to variance, and bad game theory interactions. Imagine Bitcoin were worked the way you suggested-- Say, for example, you mine a block and by chance it has 10x the 'work' expected. It ...


6

Bitcoin nodes consider the chain with the most accumulated proof-of-work the best chain. Whenever one chain tip pulls ahead by adding another block, all nodes will reorganize to that chaintip as soon as they learn about it. Another reason for the network to quickly converge on one best chain follows from how Bitcoin miners get paid. When miners construct ...


5

The Bitcoin blockchain converges to a single-file chain because each block references exactly one predecessor, and thus there can only be one block at every height in the chain connecting the genesis block and the chain-tip. However, at times more than one block will be found at the same height. This happens either due to the mere happenstance of two miners ...


5

Bitcoin clients always accept the longest valid chain. On one hand, clients check the received blocks for validity, on the other hand length is defined by another metric than many assume. The length of the blockchain is the sum of the difficulty of all its blocks, not the number of blocks. So, in order to create a fake chain, the attacker would have to ...


5

I think this would be considered a time warp attack. What prevents this strategy from working is actually quite simple, as explained in https://bitcoin.stackexchange.com/a/37960/26673: Bitcoin nodes do not compare chains by their height. (Although they used to do this.) They calculate the total work in each chain (nChainWork), and compare by that. This ...


5

First of all, finding the longest chain is not the goal, but the chain with the most accumulated proof-of-work [1] Now, finding the most-work chain is the entire goal of the full node. The whole meaning of its existence is finding the most-work chain, and so you can pick almost any line out of the networking and validation modules of the code and explain it ...


4

This process, generally know as forking, creates two parallel chains that are incompatible, that is, there will be some transactions that will be valid against one chain but are not valid against the other. If there are parallel branches, a miner might keep track of both of them. Once a chain is rejected, transactions in that chain are checked against the ...


4

Nate gave a good answer on the modern meaning of "longest chain"-- as a historical curiosity, the originally released Bitcoin software behaved like you were expecting and that attack would actually work! It was later changed to determine "longest" in terms of work. This seems like a pretty big mistake, but for Bitcoin's first year the difficulty was ...


4

Stale and orphan blocks are confusing terms with many meanings, depending on whom you ask. If by stale blocks you mean "blocks that are on branches off the main chain, but are otherwise valid", yes, those still exist. They are inherent to proof-of-work chains, as you can't avoid the case where occasionally two miners produce a competing block. Necessarily, ...


4

Consensus rules are often a lot more delicate than they might first appear. Having a tie breaker can actually enable attacks. If I find a block with a really low nonce, I can gamble to keep it secret and then only when a competing block is found, I can simply neutralize it by broadcasting my low-nonce block. This makes other miners waste their time on a ...


4

The answer to the question "Are the segwit witnesses part of the blockchain" depends on what you define as the blockchain: According to old pre-segwit nodes, the answer is no, as they don't care or receive the witnesses. According to new segwit nodes, the answer is yes; the witnesses are as much part of the chain as everything else, and subject to just as ...


4

how can I make sure that this block that my node received is a valid block Bitcoin Core will only announce (through ZMQ) blocks that change the tip of the best-known valid chain. This implies they together with all their ancestors are fully valid. and it is not an orphan block At the time it is announced, you know that it is part of the best-known valid ...


4

Blockchain forks occur when two blocks are found at the same height. Only one of the two chaintips can become part of the best chain. Each full node will consider the first block it saw to be the best block for that height, until proven otherwise by another chaintip accumulating a greater total difficulty (i.e. adding another block). When another chaintip ...


3

If a block is part of the main chain, that means that the tip of the blockchain is a descendant of that block. If a block is not part of the main chain, that means there is a longer chain of blocks that does not include this one. These are called orphaned blocks or invalid chains. If a block is in the main chain, its parent is automatically in the main ...


3

Appending blocks to the longest blockchain fork. _ _ _ _ _ _ _this is the best chain _ _ _ _/ \_ _ this is NOT


3

This is explained in the Bitcoin paper: Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in ...


3

Miners have mempools where they store all transactions they consider to include in future blocks. They don't put transactions they received into their blocks, right away. But they don't put them into their mempool right away, either. The transactions in each miner's mempool are valid and worth the miner's effort (pay at least a certain amount of fee). They ...


3

The rule is that the longest* valid chain is considered the active one. If you build a forking branch with invalid transactions in it, the network (in particular, all full nodes - including miners) will simply ignore it. If it's invalid, it does not exist. Blocks are not relayed to peers before validating them entirely. You may be able to temporarily fool ...


Only top voted, non community-wiki answers of a minimum length are eligible