Skip to content
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

Simulating with a custom gas price #28

Open
Denzel-Haverkamp opened this issue Jan 7, 2024 · 0 comments
Open

Simulating with a custom gas price #28

Denzel-Haverkamp opened this issue Jan 7, 2024 · 0 comments

Comments

@Denzel-Haverkamp
Copy link

Currently, it seems all transactions are simulated with a gas_price of 0 gwei (base_fee_per_gas and priority_fee_per_gas are both set to 0). This means the LackOfFundForGasLimit EVM error is only caused by a transaction being sent with a value that is higher than the amount of ETH held by the from address.
It would be very useful if Temper also supported simulating with a custom gas_price so that a simulation fails if the from address does not have enough ETH to pay for gas * price + value.
In this case, there would be two options.

  • The easiest option to implement would probably be to just set the gas_price and let Foundry handle the failure, but in this case Foundry will likely use the provided gasLimit to calculate the total gas cost, instead of the actual amount of gas used by the tx.
  • A nicer (but likely more difficult to implement) option would be to fail a TX when the from address does not have enough ETH for the amount of gas that was actually used (+ the value of the tx).
    One (inefficient) way to implement this second option is by simulating the transaction twice, once with a gas_price of 0, gasLimit set to the maximum of the block and calling call_raw without committing the result. The second simulation could then set the gas_price to the one provided by the user, and set the gasLimit to the amount of gas used in the first simulation.

If the second option is implemented, some use cases may still benefit from the option to check for the LackOfFundForGasLimit error using a user-provided gasLimit instead of the simulated amount, which could be implemented by only running the first simulation if the user does not provide their own gasLimit parameter. This would make the gasLimit parameter optional.

A slight ease-of-use addition would be to automatically use the base_fee_per_gas from the block if the user provides a priority_fee_per_gas without explicitly providing a base_fee_per_gas. If the user provides a gas_price (pre- eip-1559), the base- and priority fee could be set automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant