-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
vm.cool
cheatcode
#1340
Comments
If you call the same contract multiple times within a single test, then the storage slot remains warm. This is intended, and largely a very very very hard fix, so I don't think the cost of changing this behavior is worth it. In some cases, it might even be the preferred behavior, further complicating the change, since we would probably need a way to switch between one or the other However, the first time you call a contract within a test, that gas usage should be correct. It might be slightly off, see #960 |
Ah ok, must of overlooked it in the documentation. I guess I should create a feature request for cool off accounts and storage slots cheat code |
vm.cool
cheatcode
I changed the issue to request a |
Yes, thank you! |
See test/core/gas/README.md Adds a ./gas-measurement.sh for dumping measurements to out/gas-measurement.csv Note: There are quite a bit of tests that inherit from other tests and override setup to change the test case. This is due to only setup being able to vary test data without warming stuff: foundry-rs/foundry#1340 .
Hi there, If this cheatcode already on life? I see this seems completed and #5830 is merged however I'm not able to use |
@clauBv23 I came with the same question, looks like it was rollback and there is a new PR here, but it's pretty dead: #5852 (no activity since december) An alternative is to use the |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (2865fa5 2022-04-14T21:44:28.244220110+00:00)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
With the introduction of the Berlin hardfork EIP2929 was implemented and went live on the Ethereum blockchain. This EIP introduced cost changes to storage and account accessing opcodes, including (but not limited to):
SLOAD
,SSTORE
,CALL
,BALANCE
etc. Specifically these opcodes received an additional cost the first time they are used to access storage slots and/or accounts within a transaction. These costs are however not always properly accounted for in foundry solidity tests. Specifically addresses and storage slots seem to remain warm between calls within the context of a single test, falsely reducing the cost of calls and certain contract executions. This not only leads to inaccurate traces but gas usage dependent tests may also incorrectly fail / pass.This bug may or may not be a feature. It is likely more useful / straightforward if accounts and storage slots do not remain warm between calls within a single test by default. Cheat codes may be added to purposefully keep accounts and storage slots warm or potentially even pre-warm to simulate transactions with access lists (EIP2930).
EDIT(onbjerg): I am requesting a
vm.cool(address)
cheatcode to cool off warm accountsThe text was updated successfully, but these errors were encountered: