New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple transactions in one block #4090
Comments
Hi @graygt, can you try setting this in your config?
|
@fvictorio Thanks! It works! |
Glad to hear that! I'll explain what's goin on here just in case: Normally when you send a transaction a gas estimation is performed first. The way gas is estimated is that the same transaction is executed multiple times with different gas limits until a correct value is found (doing a binary search). This is also what geth does under the hood. The problem is that doing that for each transaction is kind of slow. So, when you are using the Hardhat network, we don't estimate gas by default. Instead, we just use the full block gas limit as the estimation. In previous versions of The problem with using the full block gas limit as an estimation though is that, if there are multiple transactions in the mempool and you are mining a block, only one transaction will be mined. This happens because, when the second transaction is added, the algorithm is something like this:
You could argue that we should run that transaction anyway and include it if the gas that it actually uses fits the remaining gas in the block. But we are following what geth does here (IIRC it works this way to prevent a DoS vector) So, when you set Hope that helps, happy to answer any questions about this. |
Version of Hardhat
2.16.0
What happened?
There is a problem in packing multiple transaction in one block. There only one transaction in mempool. To mine more than one tx, "evm_mine" should be called multiple times. There is no way to pack two txs to one block. I will just provide a code that shows pending block, compared to v2.14.0 where it works correctly.
Hardhat v2.16.0, ethers v6.6.0
Result:
Comparison to Hardhat v2.14.0, ethers v5.7.2 where it works correctly.
Result:
Minimal reproduction steps
Just check the code above. It's reproducible.
Search terms
No response
The text was updated successfully, but these errors were encountered: