forge-std icon indicating copy to clipboard operation
forge-std copied to clipboard

Allow clearing storage and address warmness

Open CodeSandwich opened this issue 3 years ago • 1 comments

Forge (IIUC) executes all the tests in a single transaction. As of now it don't think that it's possible to create a precise gas benchmark in Forge if there's storage or a call involved. If a test requires a storage initialization, the initialization makes the slot warm, which makes its usage lower than if it was in a separate transaction. Also if any contract is deployed, its address is automatically becoming warm, again lowering the gas usage when calling it. The EVM could expose a cheatcode to clear the warmness states allowing the benchmarks to be as expensive as when running in a separate transaction.

CodeSandwich avatar Aug 18 '22 12:08 CodeSandwich

Probably a duplicate of https://github.com/foundry-rs/foundry/issues/2429

CodeSandwich avatar Aug 29 '22 10:08 CodeSandwich

Closing this as a duplicate of the linked issue + https://github.com/foundry-rs/foundry/issues/1340. This is something that would need to be handled upstream in foundry as opposed to here in forge-std 🙂

mds1 avatar Oct 25 '22 22:10 mds1