From c0e85adece461201de15e637a2bb002a026929c4 Mon Sep 17 00:00:00 2001 From: Palina Tolmach Date: Tue, 3 Oct 2023 22:02:45 +0800 Subject: [PATCH] Add `setGas` cheatcode (#2101) * Add `setGas` cheatcode * Set Version: 1.0.310 * Set Version: 1.0.311 --------- Co-authored-by: devops Co-authored-by: rv-jenkins --- kevm-pyk/pyproject.toml | 2 +- kevm-pyk/src/kevm_pyk/__init__.py | 2 +- .../kevm_pyk/kproj/evm-semantics/foundry.md | 23 +++++++++++++++++-- package/version | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/kevm-pyk/pyproject.toml b/kevm-pyk/pyproject.toml index 19bae199fa..5060ea4b0d 100644 --- a/kevm-pyk/pyproject.toml +++ b/kevm-pyk/pyproject.toml @@ -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. ", diff --git a/kevm-pyk/src/kevm_pyk/__init__.py b/kevm-pyk/src/kevm_pyk/__init__.py index 71d04aadc1..451f492103 100644 --- a/kevm-pyk/src/kevm_pyk/__init__.py +++ b/kevm-pyk/src/kevm_pyk/__init__.py @@ -6,4 +6,4 @@ from typing import Final -VERSION: Final = '1.0.310' +VERSION: Final = '1.0.311' diff --git a/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/foundry.md b/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/foundry.md index 633ddb62f5..e705e13854 100644 --- a/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/foundry.md +++ b/kevm-pyk/src/kevm_pyk/kproj/evm-semantics/foundry.md @@ -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]: + #call_foundry SELECTOR ARGS => . ... + _ => #asWord(ARGS) + _ => 0 + 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]: @@ -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. diff --git a/package/version b/package/version index c8d4d5a4ea..5039e3d723 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -1.0.310 +1.0.311