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

Add setGas cheatcode #2101

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kevm-pyk"
version = "1.0.310"
version = "1.0.311"
description = ""
authors = [
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/src/kevm_pyk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from typing import Final


VERSION: Final = '1.0.310'
VERSION: Final = '1.0.311'
23 changes: 21 additions & 2 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/foundry.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,30 @@ function stopPrank() external;
Gas Manipulation
----------------

### `setGas` - Sets the current gas left (reported by `GAS` opcode) to a specific amount.

```
function setGas(uint256 newGas) external;
```

`setGas` is useful when writing tests that depend on the gas used, and so a specific concrete amount is needed instead of the default infinite gas.

```{.k .bytes}
rule [foundry.call.setGas]:
<k> #call_foundry SELECTOR ARGS => . ... </k>
<gas> _ => #asWord(ARGS) </gas>
<callGas> _ => 0 </callGas>
requires SELECTOR ==Int selector ( "setGas(uint256)" )
```

### `infiniteGas` - Sets the remaining gas to an infinite value.

```
function infiniteGas() external;
```

Set the remaining gas to an infinite value.
This is useful for running tests without them running out of gas.
`infiniteGas` is useful for running tests without them running out of gas.
It is applied by default.

```{.k .bytes .symbolic}
rule [foundry.call.infiniteGas]:
Expand Down Expand Up @@ -1460,6 +1478,7 @@ If the production is matched when no prank is active, it will be ignored.
rule ( selector ( "allowCallsToAddress(address)" ) => 1850795572 )
rule ( selector ( "allowChangesToStorage(address,uint256)" ) => 4207417100 )
rule ( selector ( "infiniteGas()" ) => 3986649939 )
rule ( selector ( "setGas(uint256)" ) => 3713137314 )
```

- selectors for unimplemented cheat code functions.
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.310
1.0.311