Skip to content

Commit

Permalink
Add setGas cheatcode (#2101)
Browse files Browse the repository at this point in the history
* Add `setGas` cheatcode

* Set Version: 1.0.310

* Set Version: 1.0.311

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: rv-jenkins <[email protected]>
  • Loading branch information
3 people authored Oct 3, 2023
1 parent b1de680 commit c0e85ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
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. <[email protected]>",
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

0 comments on commit c0e85ad

Please sign in to comment.