`eth_estimateGas` does not use blockchain's `adjustedTime`
See original GitHub issueIn the blockchain, when a block is being prepared to be mined, the timestamp is adjusted by the chain’s internal offset:
if (timestamp == null) {
timestamp = this.#adjustedTime(previousHeader.timestamp);
}
return new RuntimeBlock(
Quantity.from(previousNumber + 1n),
previousBlock.hash(),
this.coinbase,
minerOptions.blockGasLimit.toBuffer(),
BUFFER_ZERO,
Quantity.from(timestamp),
minerOptions.difficulty,
previousHeader.totalDifficulty,
Block.calcNextBaseFee(previousBlock)
);
However, eth_estimateGas
just uses the parent block’s timestamp:
const block = new RuntimeBlock(
Quantity.from((parentHeader.number.toBigInt() || 0n) + 1n),
parentHeader.parentHash,
parentHeader.miner,
tx.gas.toBuffer(),
parentHeader.gasUsed.toBuffer(),
parentHeader.timestamp,
options.miner.difficulty,
parentHeader.totalDifficulty,
0n // no baseFeePerGas for estimates
);
This is particularly annoying if you are using Truffle to test a contract that is time dependent because truffle calls an eth_estimateGas
before sending your actual transaction. If you use evm_setTime
to the time needed for your contract to do what it needs to do, the actual transaction would pass, but Truffle doesn’t let you get that far because the eth_estimateGas
fails beforehand.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
The Truth About Blockchain - Harvard Business Review
The technology behind bitcoin, blockchain is an open, distributed ledger that ... We can't predict exactly how many years the transformation will take, ......
Read more >Blockchain Facts: What Is It, How It Works, and How It Can Be ...
A blockchain is a digitally distributed, decentralized, public ledger that exists across a network. It is most noteworthy in its use with cryptocurrencies ......
Read more >A Blockchain Platform for User Data Sharing Ensuring User ...
We propose a new platform for user modeling with blockchains that allows users to share data without losing control and ownership of it...
Read more >How secure is blockchain really? - MIT Technology Review
The whole point of using a blockchain is to let people—in particular, people who don't trust one another—share valuable data in a secure, ......
Read more >The Privacy Questions Raised by Blockchain | Insights & Events
This article seeks to establish a framework for understanding the privacy and security challenges so that the industry can address them, cut ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also related to: #3425 ?
Oh duh. Thanks!