Polygon Block Performance

    db_img

    Description of work

    In this work, we want to compare Polygon with Layer 1 blockchains and Layer 2 solutions in terms of block performance in the last 1M blocks. This comparison includes the following parts:

    • 1 - Average time between blocks and maximum and minimum recorded time between two blocks.

    • 2 - The average number of transactions done in a block and the maximum and the minimum number of transactions done in a block.

    Blockchains used for comparison in this work

    Polygon itself is known as a sidechain.

    • Layer 1 blockchains that we compare Polygon with include Ethereum, Solana, Avalanche, Flow, Harmony, and Near.
    • Layer 2 blockchains that we compare Polygon with them are Ethereum Layer 2 solutions, including Arbitrum and Optimism.

    First of all, let's explain some terms.

    • What is a block?

      A block in a blockchain network is like a link in a chain. In the field of cryptocurrency, blocks are like records that store valid transactions like a page of a record book and are hashed and encrypted into a hash tree or Merkle tree.


      Blocks are like the building blocks of any blockchain, and they are distinguishable from one another as they have different characteristics. When a block is completed,  it makes room for the following block in the blockchain. A block is very secure and is impossible to hack virtually.

      \

      • How does a block work?

        In any cryptocurrency, there are a huge number of transactions occurring every day throughout the world. It is important for the users to keep track of these transactions, and they can do it with the help of blocks. A block contains the recent data and every time the block is completed, it becomes a part of the past and makes room for a new block on the blockchain.


        The completed block is a permanent record of prior transactions, and new ones are recorded in the current one. As a result, the entire system enters into a loop that permanently saves all data.

    • Layer 1 blockchains

      In the decentralized ecosystem, a Layer-1 network refers to a blockchain, while a Layer-2 protocol is a third-party integration that can be used in conjunction with a Layer-1 blockchain. Bitcoin, Litecoin, and Ethereum, for example, are Layer-1 blockchains. Layer-1 scaling solutions augment the base layer of the blockchain protocol itself in order to improve scalability. A number of methodologies are currently being developed — and practiced — that improve the scalability of blockchain networks directly.

      Here’s how it works: Layer-1 solutions change the rules of the protocol directly to increase transaction capacity and speed, while accommodating more users and data. Layer-1 scaling solutions can entail, for example, increasing the amount of data contained in each block, or accelerating the rate at which blocks are confirmed, so as to increase overall network throughput.

      \

    • Layer 2 solutions

      Layer-2 refers to a network or technology that operates on top of an underlying blockchain protocol to improve its scalability and efficiency. This category of scaling solutions entails shifting a portion of a blockchain protocol’s transactional burden to an adjacent system architecture, which then handles the brunt of the network’s processing and only subsequently reports back to the main blockchain to finalize its results. By abstracting the majority of data processing to auxiliary architecture, the base layer blockchain becomes less congested — and ultimately more scalable.

      For instance, Ethereum is a Layer-1 network, and Arbitrum and Optimism is a Layer-2 solution built on the Bitcoin network.

      \

    • Sidechains

      Sidechains: A sidechain is a blockchain-adjacent transactional chain that’s typically used for large batch transactions. Sidechains use an independent consensus mechanism — i.e., separate from the original chain — which can be optimized for speed and scalability. With a sidechain architecture, the primary role of the mainchain is to maintain overall security, confirm batched transaction records, and resolve disputes. Sidechains are differentiated from state channels in a number of integral ways. Firstly, sidechain transactions aren’t private between participants — they are publicly recorded to the ledger. Further, sidechain security breaches do not impact the mainchain or other sidechains. Establishing a sidechain might require substantial effort, as the infrastructure is usually built from the ground up.

      \

    source: analyticssteps.com, gemini.com


    Description of work

    In this work, we only use the data of the [FACT_BLOCKS] table related to each blockchain for calculations.

    • 1 - To calculate the Average time between blocks in the last 1 million blocks:

      \

      • 1 - First, we extract the BLOCK_NUMBER (in Flow and Near is BLOCK_HEIGHT and in Harmony is BLOCK_ID) of the last 1 million blocks along with their BLOCK_TIMESTAMPs for each blockchain using the following query ( This query is related to the Polygon blockchain)

        • WITH Polygon_BLOCK_NUMBER AS (SELECT BLOCK_NUMBER "Block number", BLOCK_TIMESTAMP FROM polygon.core.fact_blocks ORDER BY "Block number" DESC LIMIT 1000000 )

        \

      • 2 - Then we increase all the ‍Block _Number (in Flow and Near is BLOCK_HEIGHT and in Harmony is BLOCK_ID) values extracted in step1 by 1 unit using the following query:

      • Polygon_BLOCK_NUMBER_PLUS_ONE AS ( SELECT "Block number" + 1 "Block number plus 1" , BLOCK_TIMESTAMP AS "Previous block TIMESTAMP" FROM Polygon_BLOCK_NUMBER)

      \

      • 3 - Then we join the results of step 1 and step 2 using the following query:
        • Polygon AS (SELECT Polygon_BLOCK_NUMBER.*, Polygon_BLOCK_NUMBER_PLUS_ONE.* FROM Polygon_BLOCK_NUMBER JOIN Polygon_BLOCK_NUMBER_PLUS_ONE ON "Block number" = "Block number plus 1")
          • Adding 1 to all BLOCK_NUMBER in step 2 is because when we join the results of the first step and the second step, in each row of the final result, there is both the BLOCK_TIMESTAMP related to the current BLOCK_NUMBER and the BLOCK_TIMESTAMP related to previous BLOCK_NUMBER
      • 4 - Finally, to calculate the Average time between blocks, we use the following query:
        • SELECT AVG(DATEDIFF(second, "Previous block TIMESTAMP", BLOCK_TIMESTAMP)) AS Block_time FROM Polygon
    • 2 - To calculate the maximum and minimum recorded time between two blocks in the last 1 million blocks:

      • We use the results of step 3 from calculating the Average time between blocks following query:
        • SELECT MAX(DATEDIFF(second, "Previous block TIMESTAMP", BLOCK_TIMESTAMP)) "Max block time", MIN(DATEDIFF(second, "Previous block TIMESTAMP", BLOCK_TIMESTAMP)) "Min block time" FROM Polygon

          \

    • 3 - To calculate the average number of transactions done in a block in the last 1 million blocks, we use the following query ( This query is related to the Polygon blockchain)

      • SELECT AVG(TX_COUNT)::int AS AVERAGE FROM polygon.core.fact_blocks WHERE BLOCK_NUMBER >= (SELECT BLOCK_NUMBER - 1000000 FROM polygon.core.fact_blocks ORDER BY BLOCK_NUMBER DESC LIMIT 1)

        \

    • 4 - To calculate the maximum and the minimum number of transactions done in a block the last 1 million blocks, we use the following query ( This query is related to the Polygon blockchain)

      • SELECT MIN(TX_COUNT) AS MIN_TX, MAX(TX_COUNT) AS MAX_TX FROM polygon.core.fact_blocks WHERE BLOCK_NUMBER >= (SELECT BLOCK_NUMBER - 1000000 FROM polygon.core.fact_blocks ORDER BY BLOCK_NUMBER DESC LIMIT 1)
    • In this question, we have used information related to the last 1 million blocks of each blockchain, so all the results obtained are related to the state of blockchains in the past few days, not their condition over time.

    • Information about Binance Smart Chain blocks is related to the last 13038. Therefore, we have not used this blockchain in comparisons.

    1 - Average time between blocks and maximum and minimum recorded time between two blocks

    Loading...
    Loading...

    According to the results:

    • The higher the average block time is, the fewer blocks are generated, so the average block time and the speed of block generation have an inverse relationship.

    • The highest average block time by far belongs to Ethereum with 13.81 seconds. After Ethereum, the highest average block time belongs to Harmony with 2.45 seconds.

      \

    • After Ethereum and Harmony, the highest average block time is related to Polygon(2.24 seconds), Avalanche(2.02 seconds), Flow(1.4 seconds), Near(1.2 seconds), Arbitrum (1.04 seconds), Optimism(0.7 seconds), and Solana(0.64 seconds) respectively.

    • This huge difference in average block time in Ethereum compared to other blockchains can be due to the different type of transaction processing in Ethereum. Because Ethereum currently uses the Proof of Work method to process transactions and other blockchains use the Proof of Stake method to process transactions.

      \

    • In terms of average block time, Polygon is higher than all layer 1 blockchains (except Ethereum and Harmony) and all layer 2 solutions (Optimism and Arbitrum). In terms of block production speed, it is slower than all layer 1 blockchains (except Ethereum and Harmony) and all layer 2 solutions (Optimism and Arbitrum).

      \

    • Solana blockchain has the highest block production speed, and the lowest block production speed is related to Ethereum.

      \

    • layer 2 solutions (Optimism and Arbitrum) are faster than all layer 1 blockchains except Solana in block production.

    • The highest maximum time between two blocks belongs to Arbitrum with 216 seconds. After Arbitrum, the highest maximum time between two blocks belongs to Ethereum(172 seconds),

      Harmony (112 seconds), Optimism(41 seconds), Flow(41 seconds), Polygon(25 seconds), Avalanche(15 seconds), Solana(14 seconds) and Near(6 seconds) respectively.

    • In terms of maximum time between two blocks, Polygon works better than the layer 2 solutions (Optimism and Arbitrum) and among the blockchains of layer 1 it works better than Harmony, Flow, and Ethereum.

      \

    • The minimum time between two blocks is equal to 0 for all the checked blockchains except Ethereum (1 second) and Polygon (2 seconds) . This means that in these blockchains, several blocks are generated at the same time.

    2 - The average number of transactions done in a block and the maximum and the minimum number of transactions done in a block

    Loading...

    According to the results:

    • In terms of the average number of transactions done in a block, Solana is in a different league!

      \

    • The highest average number of transactions done in a block belongs to Solana (2145) by a wide margin.

      • After Solana, Ethereum (181), Polygon (72), Harmony(12), Flow(11), Near(5), Avalanche(5), Optimism(1), and Arbitrum(1) ranked second to ninth.

      \

    • In terms of the average number of transactions performed in one block, Polygon performs better than layer 2 solutions, and among layer 1 blockchains, after Solana and Ethereum, it has the highest average number of transactions performed in one block.

      \

    • When we analyze the maximum number of transactions done in a block, the situation is the same as the average number of transactions performed in one block. Solana is by a large margin higher than other blockchains.

      • After Solana(6618 transactions), Ethereum (1424 transactions), Polygon (1160 transactions), Near(622 transactions), Harmony(467 transactions), Avalanche(360 transactions), Flow(260 transactions), Arbitrum(59 transactions) and Optimism(1 transaction) ranked second to ninth.

        \

    • When we check the minimum number of transactions done in a block, except for Optimism(1 transaction), the minimum number of transactions in a block is equal to 0 for all blockchains. Blocks in which there are no transactions are called Empty Blocks. By researching empty blocks, we came to the conclusion that these empty blocks have two basic uses in the blockchain:

      \

      • Although empty blocks contain no trade information, they do include a transaction in which the block rewards are distributed to the miner that is known as a coinbase transaction.

        \

      • Many empty blocks are mined because of the inevitable block validation time lag and its consequences on mining fresh blocks vs invalidated blocks.

        \

      • When there are no transactions on the network, empty blocks are generated. In fact, these empty blocks make the network not stop working when no transaction is done on the network and continues to operate.

        \

      • To read more about empty blocks, see these articles: Into the mempool: Empty blocks, What is the Story Behind All the Empty Blocks?

        \

    • The number of empty blocks in the Ethereum blockchain is more than other blockchains. This number is equal to 28,710, which includes 2.87% of the last 1 million blocks. Near (18719 Empty blocks - 1.87% of the last 1M blocks), Polygon (13293 Empty blocks - 1.32% of the last 1M blocks), Flow (5529 Empty blocks - 0.55% of the last 1M blocks), Harmony (1047 Empty blocks - 0.1% of the last 1M blocks), Avalanche (163 Empty blocks - 0.016% of the last 1M blocks), Arbitrum (18719 Empty blocks ), and Solana (22 Empty blocks ) have the highest number of empty blocks after Ethereum.

      \

    • Optimism works in such a way that each block contains only 1 transaction.

    • When we calculate the minimum number of transactions in a block without considering empty blocks, this value is 1 for all blockchains.

    • In the last 1M blocks of each blochchains, the highest number of transactions are related to Solana and Ethereum , respectively.

    Loading...
    Loading...

    Conclusion

    • In this work, In the terms of block performance, there are two main criteria for comparing blockchains.

      \

      • The average time between blocks: The lower the value of this criterion for a blockchain, it means that it can generate more blocks in the same period of time than other blockchains.
        • In terms of the average time between blocks, Ethereum (13.81 seconds block time), Harmony (2.45 seconds block time), Polygon(2.24 seconds block time), Avalanche(2.02 seconds block time), Flow(1.4 seconds block time), Near(1.2 seconds block time), Arbitrum (1.04 seconds block time), Optimism(0.7 seconds block time) and Solana(0.64) seconds block time) respectively.

          \

      • The average number of transactions done in a block: As it is clear from its name, the higher its value means more transactions can be placed in each block of the blockchain.
        • In terms of the average number of transactions done in a block, Solana (2145), Ethereum (181), Polygon (72), Harmony(12), Flow(11), Near(5), Avalanche(5), Optimism(1), and Arbitrum(1) have the best performance, respectively.

          \

    • The highest maximum time between two blocks belongs to Arbitrum with 216 seconds. After Arbitrum, the highest maximum time between two blocks belongs to Ethereum(172 seconds),

      Harmony (112 seconds), Optimism(41 seconds), Flow(41 seconds), Polygon(25 seconds), Avalanche(15 seconds), Solana(14 seconds) and Near(6 seconds) respectively.

      • In terms of maximum time between two blocks, Polygon works better than the layer 2 solutions (Optimism and Arbitrum), and among the layer 1 blockchains, it works better than Harmony, Flow, and Ethereum.
    • The highest maximum number of transactions done in a block belongs to Solana(6618), Ethereum (1424), Polygon (1160), Near(622), Harmony(467), Avalanche(360), Flow(260), Arbitrum(59) and Optimism(1) respectively.

    • When we check the minimum number of transactions done in a block, except for Optimism(1 transaction), the minimum number of transactions in a block is equal to 0 for all blockchains. Blocks in which there are no transactions are called Empty Blocks.

    • The average number of transactions performed in a block has a direct relationship with the number of transactions performed.

    • The highest number of transactions in the last 1 million blocks are related to Solana(1.894B transactions) and Ethereum(180.709M transactions), Polygon(70.186M transactions), Harmony(11.604M transactions), Flow(10.722M transactions), Near(10.577M transactions), Avalanche(4.827M transactions), Arbitrum(1.129M transactions) and Optimism(0.99M transitions) , respectively.

    • Solana has the best performance by a large margin in all compared criteria for block performance, but there are other criteria for comparing blockchains, which Solana performs poorly in its criterion, rate of successful transactions. You can read our previous work -Near Performance- on this matter for more information.


      \

    Loading...