Block

The block is a combination of a batch of transactions and contains the hash of the previous block in the chain. This connects the blocks together (into a chain) because the hash is derived from the encryption of the block data. This prevents fraud because any change in any previous block invalidates all subsequent blocks, and all hashes are changed and noticed by all who run the blockchain.

Why do we need blocks?

To ensure that all participants on the PolySmartChain network stay in sync and agree on the exact history of a transaction, we divide the transaction into multiple blocks. This means that dozens (or hundreds) of transactions are submitted, agreed upon and synchronized at once.

With spaced commits, we can give all network participants enough time to reach consensus even if transaction requests occur tens of times per second. Blocks on PolySmartChain are committed approximately every 3 seconds.

How blocks work

To preserve transaction history, blocks are strictly ordered (each new block created contains a reference to its parent block) and transactions within the block are strictly ordered. Except in rare cases, at any given time, all participants on the network agree on the exact number and history of blocks, and are working to batch the current active transaction requests to the next block.

Once a block is put together (mined) by one of the miners on the network, it propagates to the rest of the network; All nodes add this block to the end of their block chain and continue mining.

What does the block contain?

  • timestamp – Time to mine the block.

  • blockNumber – The length of a block in the blockchain.

  • baseFeePerGas -The minimum cost per gas required to include a transaction in the block.

  • difficulty – The effort required for mining.

  • mixHash – A unique identifier for the block.

  • parentHash – The unique identifier of the previous block (this is how the block forms the chain).

  • transactions –The transactions contained in the block.

  • stateRoot –The entire state of the system: account balance, contract storage, contract codes and account random numbers.

  • nonce – Hash, when used in combination with mixHash, proves that the block has passed the workload proof.

Block Time

Block time refers to the time it takes to mine a new block. In PolySmartChain, the average block time is at 3 seconds and is evaluated after each block. The expected block time is set as a constant at the protocol level and is used to secure the network when miners increase their computing power. The average block time is compared to the expected block time and if the average block time is higher, the block header will be less difficult. If the average block time is lower, the difficulty in the block header is increased.

Block Size

One last important point is that the size of the blocks themselves is bounded. The target size for each block is 15 million gas, but the block size will increase or decrease depending on the network demand. The block limit is limited to a maximum of 30 million (twice the target block size). The total amount of gas consumed by all transactions in the block must be below the block's gas limit. This is important because it ensures that the block does not grow arbitrarily large. If blocks can be arbitrarily large, less capable full nodes will gradually fail to keep up with the network due to space and speed requirements.

Last updated