1

[ 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

2 Answers 2

2

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.

2
  • 1
    Thanks. Also do you know what triggres a validator to start mining a block ? I mean when a validator says ok now i have enough txs in the mempool to start mining them . I alwasy thought that once the total gasLimit of transactions were equal to the block gasLimit then the validator started mining, but that's not the case seems
    – Mat.C
    Commented Apr 25, 2022 at 22:39
  • 2
    Only talking about Ethereum (and Bitcoin), with the coinbase transaction (Miner's reward, not counting the tx fees) it is profitable to mine even without any included transactions. So what triggers a miner to mine is simply the fact that it was instructed to do so... Including tx is just an additional reward but not a condition to start mining. You can check early Ethereum blocks such as etherscan.io/block/5 , where there is no transaction present, only the block reward.
    – hroussille
    Commented Apr 26, 2022 at 12:55
0

this will compare gas prices of last 100 transactions, and give the Max Priority Fee Per Gas, which you should put as gas fee for fast transaction (-15 seconds):

const Web3 = require("web3")
const web3 = new Web3(<RPC Link>)

web3.eth.getFeeHistory(100, "latest",  [0, 25, 50, 75, 100]).then((data) => {
    total=0
    for (let i = 0; i < 100; i++) total+=(data.reward[i].map(r => Math.round(Number(r) / 10 ** 9)))[1]+Math.round(Number(data.baseFeePerGas[i]) / 10 ** 9)
    console.log(total/100)
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.