ganache icon indicating copy to clipboard operation
ganache copied to clipboard

fix: use adjusted time on estimate gas when latest block is being used

Open luzzif opened this issue 2 years ago • 1 comments

When estimating gas, use the adjusted timestamp in case the latest block tag is being used. This helps avoid some errors in time-dependent contracts when using Ganache in fork mode.

Should fix https://github.com/trufflesuite/ganache/issues/3528.

This is my first PR here, would love some guidance.

luzzif avatar Mar 04 '23 12:03 luzzif

A bit of delay on this but... I just implemented the same logic on eth_call on a local fork, but using a slightly different way. I made the readyNextBlock in the blockchain class public and when latest is passed as the block I use that instead of the standard built RuntimeBlock. I wonder if we could simplify the implementation of the eth_estimateGas logic by doing the same here. The only thing we probably need to change is that I noticed that in the eth_estimateGas case the gas limit defaults to the miner's call gas limit instead of the default block gas limit used in the standard readyNextBlock function.

luzzif avatar May 25 '23 08:05 luzzif