【Xu Xiaodi】EOS block data structure

For a blockchain project, the core data is the block data, and the block data structure is the technical foundation of the entire blockchain project. However, because the EOS project has been iterating rapidly and the block data structure has been constantly updated, I will introduce it to you today.

block header (block_header)

The first is the block header data structure, including hash, timestamp, Merkel root, witness account, etc.

//区块头结构体
struct block_header
{
  //前一区块哈希  
  block_id_type           previous;
  //区块时间戳
  block_timestamp_type    timestam
  交易的默克尔根
  checksum256_type        transaction_mroot; /// mroot of cycles_summary
  //Action 的默克尔根
  checksum256_type        action_mroot;
  //区块默克尔根
  checksum256_type        block_mroot;
  //见证人账号
  account_name            producer;
  //见证人排序版本号
  uint32_t                 schedule_version = 0;
  //下一个见证人(可以为空)
  optional<producer_schedule_type>  new_producers;
};

Block header (signed) (signed_block_header)

On the basis of the block header, the signature of the block witness is to sign the block header:

//签名区块头结构体
struct signed_block_header : public block_header
{
  见证人签名
  signature_type             producer_signature;
};

Block summary (signed) (signed_block_summary)

The purpose of the signed block digest is to distribute the transactions (Transactions) in the block to various levels. There is no complete information about the transaction, but only the level and grouping structure of the transaction.

   struct signed_block_summary : public signed_block_header {

     vector<region_summary>    regions;
  };

The structure of the block summary is explained in the EOS white paper:

    Region
     Cycles (sequential)(串行)
       Shards (parallel)(并行)
         Transactions (sequential)(串行)

It can be seen that multiple Transactions form a Shards, multiple Shards form a Cycles, and multiple cycles form a Region. The transactions contained in each block are organized by such a hierarchical structure, and the final organizational structure is recorded separately in the block. This is also the basis for EOS to develop parallel execution in the future.

block (signed) (signed_block)

As mentioned above, the block summary only describes the organizational structure of the transaction, and there is no specific transaction information. We need to add the complete transaction information at the end of the block to form an EOS complete block.

struct signed_block : public signed_block_summary {
 //完整交易信息
 vector<packed_transaction>   input_transactions;
};

Summarize

We have drawn the EOS block data structure with graphics for easy understanding.

 

 

Yuanfangyuan Blockchain brings together a large number of famous blockchain teachers and adopts a tutor duty system to solve technical difficulties for students in real time. Please pay attention to Yuanfangyuan Blockchain Knowledge Planet and Mentors. (For training inquiries, please contact the captain on 13826054890 with the same WeChat mobile number)

 

The author, Xiaodi, focuses on EOS technology research and blockchain smart contract development. He is the mentor of Yuanfangyuan Blockchain. For more articles and videos of Mr. Xiaodi, please pay attention to the official account of Yuanfangyuan Chain Circle.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324780373&siteId=291194637