Documentation
Chevron icon
Neo Blockchain Concepts
Chevron icon

Neo Blockchain Blocks

Apr 28, 2024 1:13:57 AM

Neo Blockchain Blocks

In the Neo blockchain, blocks serve as containers for batch transactions, forming the backbone of the decentralized ledger. These blocks are linked together to create a chain, ensuring integrity, security, and immutability.

What are Blocks?

A block within the Neo blockchain consists of two main components: the block header and the block body. Together, they encapsulate various details, from transaction information to timestamps.

Block Header

The block header provides the basic information for a block and includes:

  • Version: (4 bytes) Block version, currently 0.
  • PrevHash: (32 bytes) The hash of the previous block.
  • MerkleRoot: (32 bytes) The Merkle tree root of the block’s transactions.
  • Timestamp: (8 bytes) UTC-time when the block was generated.
  • Nonce: (8 bytes) A random number.
  • Index: (4 bytes) Block height, with Genesis Block’s starting at 0.
  • PrimaryIndex: (1 byte) Index of the proposal validator in the current round.
  • NextConsensus: (20 bytes) Address of the next round validator.
  • Witness: Contains the block verification scripts.

The block header ensures verification and unique identification of a block.

Block Body

The block body contains the payload of the block, consisting of:

  • Header: Block header information.
  • Transactions: A list of transactions (up to 512 per block).

The block body represents the specific transactions included within the block, allowing them to be processed and verified.

Neo Blockchain Blocks: A Technical Overview

Within the Neo network, blocks play a vital role in the consensus mechanism, enabling high transaction speeds and maintaining decentralization.

  • Block Hash & Index: Used to identify a block, created by performing a SHA256 operation twice on the concatenated attributes.
  • Timestamp Requirement: Must be larger than the previous block’s timestamp.
  • NextConsensus Field: Locks the nodes participating in the next consensus round.
  • Witness Verification: Contains scripts for block verification.

Validation and Verification

Blocks can be verified by any node within the Neo network, but only consensus nodes can propose new blocks. This approach ensures that the network remains decentralized while allowing for high transaction speeds.

To validate a block, the network must first verify the block header. This is done by checking the block hash, ensuring that it is correct and that the timestamp is valid. If the block header is valid, the block body is then verified. This is done by checking the transactions, ensuring that they are valid and that the Merkle root is correct. If the block body is valid, the block is added to the blockchain and propagated to other nodes.

Consensus Address

The Neo network uses a DBFT consensus address to identify the nodes participating in the consensus process. This address is generated using the multi-signature account based on the public keys of the elected consensus nodes.

Witness Verification

In the blockchain ecosystem, witnesses are the scripts (instructions) used in cryptographic authentication. In the Neo network, witnesses are used to verify the validity of blocks and transactions. The witness scripts are stored within the block header, allowing blocks to be verified by any node within the network.

Merkle Root

The merkle root is a hash of all the transactions within a block. This hash is used to verify that the transactions are valid and that the block has not been tampered with. If the Merkle root is incorrect, the block is rejected.