Skip to main content
19 votes
Accepted

How does block synchronization work in Bitcoin Core today?

Since the introduction of headers-first synchronization in Bitcoin Core 0.10, the blockchain data structure can be seen as having three components: The block header tree: a tree data structure, with ...
Pieter Wuille's user avatar
12 votes
Accepted

Why are block header bits necessary? (Valid difficulty is already implied by chain history)

They aren't really necessary. The reason that they are included can only be known by Satoshi, and AFAIK, he did not state why he chose to include nBits in the block header (or many other things that ...
Ava Chow's user avatar
  • 71.5k
11 votes

Why don't the timestamps in the block chain always increase?

There is no requirement that blocks have a timestamp after the previous block. The only requirement is that the timestamp is greater than the median timestamp of the last 11 blocks. So this means that ...
Ava Chow's user avatar
  • 71.5k
11 votes

What is a nonce?

Nonce is a 32 bit arbitrary random number that is typically used once. In Bitcoin's mining process, the goal is to find a hash below a target number which is calculated based on the difficulty. Proof ...
abeikverdi's user avatar
11 votes
Accepted

Unusual Version Number in Blocks

but I am going to take a slight guess that this has something to do with miner voting to show what the consensus is for a future change? No. There are currently no active consensus change proposals. ...
Ava Chow's user avatar
  • 71.5k
9 votes
Accepted

How does Segwit prevent ASICBOOST?

There's 2 versions of ASICBOOST: Overt where miners use bits in the version number as extra nonce space Covert where miners "mine" merkle trees with 4 bytes collisions The overt version is very ...
alcio's user avatar
  • 1,274
9 votes

Calculate hash of block header

The version is wrong: I have 02000000 But the one that appears on the block is Version 0x20000000 Doing the formatting: 00000020 Calculating the hash of the block: from hashlib import ...
CamiloARG's user avatar
  • 177
9 votes
Accepted

How does headers-first prevent disk-fill attack?

To add to the other answer, since Bitcoin Core 24.0, there is an additional protection implemented against low-difficulty header spam: header pre-syncing. To recapitulate, since the headers-first ...
Pieter Wuille's user avatar
9 votes
Accepted

What restrictions does the version field in the block header have?

nVersion is a 4-byte little-endian signed integer. Little-endianness means that the least significant byte is first. The order of bits in a byte remains the same. I’m aware of the following ...
Murch's user avatar
  • 77k
8 votes
Accepted

How strict are the Unix Epoch time validation rules?

How strict are the time validation rules? Very. If the next block is mined more than 2 hours after the current block, would this not stall the blockchain? No. It doesn't break the rule "Full ...
RedGrittyBrick's user avatar
7 votes
Accepted

Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?

nBits cannot be changed at all. Its value must equal the (compact encoding of) the target value for that block, which is determined entirely by the predecessors of the block. In other words, if the ...
Pieter Wuille's user avatar
7 votes

How strict are the Unix Epoch time validation rules?

I think you have a misconception about what this clause means: Full nodes will not accept blocks with headers more than two hours in the future according to their clock. You appear to be ...
Douglas's user avatar
  • 171
7 votes
Accepted

What are the components of the raw block shown in this image?

The diagram is wrong The data in the gap between the two brackets is the count of transactions and most of the first coinbase transaction. The start/top of the second bracket is positioned incorrectly....
RedGrittyBrick's user avatar
6 votes
Accepted

Mining Block header bit reversing

Let's take a look at this block, because it only has one transaction (the coinbase): 000000000000000000eb2d0ed97a7b2cff7f1408417dca83908004beb6fd9b95 Let's grab the raw hex data: ...
meshcollider's user avatar
  • 11.9k
6 votes
Accepted

How is mining difficulty defined (formula)?

The nBits field is basically scientific notation in base-256 (256 is 2^8). As an example, we take the one found on the Bitcoin.org Developer Reference: 0x181bc330 (Big-Endian order). This is split ...
meshcollider's user avatar
  • 11.9k
6 votes

How does headers-first prevent disk-fill attack?

since checkpoints are removed, we would be vulnerable to this attack Where did you see that checkpoints are removed? They're still in src/chainparams.cpp as of current master (commit f8bcef38f). ...
David A. Harding's user avatar
6 votes

Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?

nTime: blocks must have a higher timestamp than the median of the 11 previous blocks, and a lower timestamp than two hours in the future of the validating node's own clock. Assuming a regular block ...
Murch's user avatar
  • 77k
5 votes
Accepted

Merkle Root for 1-transaction block!

The merkle root of a block is the hash of all of the transactions. If there is one transaction, then the hash of all of the transactions is the hash of that one transaction. So the merkle root and the ...
Ava Chow's user avatar
  • 71.5k
5 votes
Accepted

how to convert blockchain to new version?

The issue here is with: (block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) Your block has version 2, but I assume the block you are trying to download is higher than ...
meshcollider's user avatar
  • 11.9k
5 votes
Accepted

Are there any blockchain explorers that provide raw Tx data and block headers?

You can get this info from blockchain.info, by simply adding ?format=hexto the end of the relevant URL. For example, here is a recent block (height 509,244): https://blockchain.info/block/...
chytrik's user avatar
  • 18.3k
5 votes

Why are block header bits necessary? (Valid difficulty is already implied by chain history)

Directly committing to the nbits allows you to determine how much work was used to produce the header statelessly before looking for (or fetching) information about prior headers. This can help fend ...
G. Maxwell's user avatar
  • 7,727
5 votes
Accepted

If a lot of miners start at nonce 0, how are there no ties?

The block templates of two different miners will never overlap. Miners get paid by assigning the block reward in their mined blocks to themselves. Since each miner is trying to credit a different ...
Murch's user avatar
  • 77k
4 votes

Why don't the timestamps in the block chain always increase?

There is a fair amount of leeway in the block timestamp. The timestamp for block N must be greater than the median network time, which is calculated as the median of the past 11 blocks, and also less ...
Raghav Sood's user avatar
  • 17.2k
4 votes
Accepted

How is the mempool incorporated in the calculation of the block hash?

Every node in the network has a mempool. The mempool contains unconfirmed transactions. Each mempool may be slightly different as they constitute a subset of all unconfirmed transactions in the ...
Murch's user avatar
  • 77k
4 votes
Accepted

Is the hash of the previous block included in the block header?

The block header is 80 bytes: Version number: 4 bytes Previous block header hash: 32 bytes Merkle root: 32 bytes Timestamp: 4 bytes Bits: 4 bytes Nonce: 4 bytes The merkle tree hashes all the ...
alcio's user avatar
  • 1,274
4 votes
Accepted

What is the difference between Root Hash and Block Hash?

First, all transactions are hashed along a Merkle tree. The root of that tree is the Merkle root. Then the block header is created with 6 fields: version number, the hash of the previous block, the ...
Pieter Wuille's user avatar
4 votes
Accepted

What is the source for the "hash" field reported by the 'bitcoin-cli getblock' command?

Is the "hash" field something that the 'bitcoin-cli' calculates and inserts in situ into the json for informational purpouses This is correct. The block contains all of the info necessary to compute ...
chytrik's user avatar
  • 18.3k
4 votes

Can a full node provide a bogus block bloomfilter to a Neutrino node?

They can lie to you about the filters, yes. However due to the filters being deterministic you can query other nodes for the hashes of their filters to gauge relative correctness. You can also use a ...
Claris's user avatar
  • 15.5k
4 votes

How to get block header hex?

I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is. It is a composite of values from the block - in brief, it is the concatenated binary (...
circulosmeos's user avatar
4 votes
Accepted

"New rules activated" warning after upgrading to 0.20.0

Miners have been using the version field of the blocks' headers as an "extra nonce" (*). However, this version field has been used to signal readiness from miners to deploy a soft fork (update to new ...
Antoine Poinsot's user avatar

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