DEV Community

shivi28 for Kubernetes Community Days Chennai

Posted on

Blockchain Architecture

In this article we understand basic blockchain block structure and learn about the fields by taking example of a real block with block-number=#601439

block601439

In the Block we have following fields:

Block Number/Block Height

It represents the number of a block in line, so the first block would be 1, the second 2, and so on to our block 601439.

Block size

Maximum limit for the amount of transactions. It is not the actual number of transactions allowed instead it is the size of transactions that is allowed.

Block Hash

A block hash in this case, which is created from the block header with SHA256

Version

This is a protocol version. Miners need to know protocol versions in order to be able to properly process blocks.

hashMerkelRoot

If all the transactions are used to create a single hash, this would be simple, and not what we have here!. This principle is not used because if we wanted to run a verification of a particular transaction we would need to know all of the other ones as well. This is doable, just less efficient than the Merkel tree approach.

In this approach , we only need some of the “hashes”. We go slowly, we first take hashes in a set of 2 transactions till we reach just one hash.

Merkel tree

Number of Transactions

Each block contains a number of transactions. Usually a maximum size is defined, but the number of transactions per block varies.

TimeStamp

This is the time when the hashing actually took place. It can be in a different format but for all blocks with the same number it should point to the same time. Notation difference is ignored.

Transactions

In this example transaction refers to payment, but different protocols can define transactions in different ways. Yet it does not always have to be an individual transaction. Instead it can just be observed as an event defined by a given protocol.

Bits

It can be a hexadecimal number. This is just another representation of difficulty

Difficulty

When the hashing process takes place, the difficulty is determined by the targeted number of zeroes that the hash needs to begin with. As more people involved in mining we need to increase the difficulty

Difficulty = expected/actual(available computation power)
if D >1 then increase(0.25, 4)
if D < 1, then decrease(0.25,4)
want no sudden change that’s why keeping this threshold
so newDifficulty = oldDifficulty * expected/actual
targetDiff = targetMax(=Bits)/difficulty
Enter fullscreen mode Exit fullscreen mode

so, blockHash < targetDiff always.

Nonce

This is the data that we need to the block data to make block hash < targetDiff

hashPrefixBlock

This is the hash of the previous block, and is embedded into the current block. Hash should have a certain number of zeroes before it.

Top comments (0)