trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

fix: store transactions with the correct `effectiveGasPrice` #4112

Closed MicaiahReid closed 1 year ago

MicaiahReid commented 1 year ago

Previously we were returning the wrong gasPrice when a transaction was fetched via eth_getTransactionByHash. This was happening because when we saved the transaction to the chain, we didn't update the transaction's effectiveGasPrice field based off of the baseFeePerGas of the block that the transaction was mined onto in some cases.

However, the effectiveGasPrice returned on a receipt was correct because when the receipt was fetched, we would calculate the effectiveGasPrice on the fly just to correct what we return to the user, rather than directly using what the database returned.

This change removes the on-the-fly calculation of the effectiveGasPrice on the receipt, and presets the transaction's effectiveGasPrice based off of the next block's baseFeePerGas when the transaction is added to the pool. As block's are mined, the miner updates all pending transaction's effectiveGasPrice based off of the next block's baseFeePerGas.

Fixes #4094.

gitpoap-bot[bot] commented 1 year ago

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 Ganache Contributor:

GitPOAP: 2023 Ganache Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.