Block Gas Limit calculation

bscgas-limitweb3js

[ Working on BSC ]

I'm trying to better understand the block gasLimit field,

As I know, it places an upper limit on the gas limit of transactions Gas Limit in a block,
therefore a validator cannot extract a quantity of transactions whose summed limit gas will exceed the gas limit value, am i right ?

Basically on bscscan when you go to analize a block in the field gasLimit it says: Total gas limit provided by all transactions in the block.
enter image description here

Does that mean that the they intend the gas limit as the sum of all the transactions limits of the mined transactions?

I also tried to do some tests by summing the transactions gas limit, and i expected to have the same value of the block gasLimit value,
but i think i'm missunderstunding what that field means.
Here are some results of my tests

[Block 17258101] Block Gas Limit: 79,830,526 | Sum Transactions GasLimit: 127,576,449
[Block 17258102] Block Gas Limit: 80,000,000 | Sum Transactions GasLimit: 58,258,522
[Block 17258103] Block Gas Limit: 79,810,757 | Sum Transactions GasLimit: 87,189,554
[Block 17258104] Block Gas Limit: 79,686,763 | Sum Transactions GasLimit: 35,581,016
[Block 17258105] Block Gas Limit: 79,465,224 | Sum Transactions GasLimit: 66,705,611
[Block 17258106] Block Gas Limit: 79,154,814 | Sum Transactions GasLimit: 59,747,460
[Block 17258107] Block Gas Limit: 78,845,617 | Sum Transactions GasLimit: 101,815,788
[Block 17258108] Block Gas Limit: 79,153,606 | Sum Transactions GasLimit: 55,161,147
[Block 17258109] Block Gas Limit: 79,462,798 | Sum Transactions GasLimit: 61,621,550
[Block 17258110] Block Gas Limit: 79,773,198 | Sum Transactions GasLimit: 80,544,337

So seems that it is not really related to the block GasLimit field. So there is any relation between the transactions gas limit and the block gas limit ?

From the above tests i've omitted ( when calculating the sum of block's transactions gas Limit ) the gas limit of the transaction that burn the block's fees, i'm not sure if that's correct, usually that is always the last transaction of a block and has a gas limit of 9,223,372,036,854,775,807

Ex: https://bscscan.com/tx/0x7780d200b0bed42c3ce648a07f88f8ef601af49e5b9c8e0e5535d51d117ab7e4

Best Answer

As I know, it places an upper limit on the gas limit of transactions Gas Limit in a block, therefore a validator cannot extract a quantity of transactions whose summed limit gas will exceed the gas limit value, am i right ?

The block gas limit is more of an upper bound on the total gas used by all transactions. See this piece of code from the Ethereum consensus :

// Verify that the gasUsed is <= gasLimit
if header.GasUsed > header.GasLimit {
    return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
}

So seems that it is not really related to the block GasLimit field. So there is any relation between the transactions gas limit and the block gas limit ?

There is one, a tx gas limit cannot exceed the block gas limit, as you can see here.

So the sum of all tx gas limit can be above the block gas limit, but the sum of all tx gas used cannot be above the block gas limit in the same sense that a tx gas used cannot be higher than its own gas limit.

I hope that answers your question.

Related Topic