Skip to content

Commit

Permalink
Merge pull request #576 from elopez/fix-cheat-gas
Browse files Browse the repository at this point in the history
Fix gas accounting in cheatcodes
  • Loading branch information
arcz authored Oct 6, 2024
2 parents f52f5e6 + 2e481b2 commit fdc3d80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/EVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,9 @@ cheatCode = LitAddr $ unsafeInto (keccak' "hevm cheat code")

cheat
:: (?op :: Word8, VMOps t)
=> (Expr EWord, Expr EWord) -> (Expr EWord, Expr EWord) -> [Expr EWord]
=> Gas t -> (Expr EWord, Expr EWord) -> (Expr EWord, Expr EWord) -> [Expr EWord]
-> EVM t s ()
cheat (inOffset, inSize) (outOffset, outSize) xs = do
cheat gas (inOffset, inSize) (outOffset, outSize) xs = do
vm <- get
input <- readMemory (Expr.add inOffset (Lit 4)) (Expr.sub inSize (Lit 4))
calldata <- readMemory inOffset inSize
Expand All @@ -1682,7 +1682,7 @@ cheat (inOffset, inSize) (outOffset, outSize) xs = do
pushTrace $ FrameTrace newContext
next
vm1 <- get
pushTo #frames $ Frame
burn' gas $ pushTo #frames $ Frame
{ state = vm1.state { stack = xs }
, context = newContext
}
Expand Down Expand Up @@ -1954,7 +1954,7 @@ delegateCall this gasGiven xTo xContext xValue xInOffset xInSize xOutOffset xOut
\(xTo', xContext') ->
precompiledContract this gasGiven xTo' xContext' xValue xInOffset xInSize xOutOffset xOutSize xs
| xTo == cheatCode = do
cheat (xInOffset, xInSize) (xOutOffset, xOutSize) xs
cheat gasGiven (xInOffset, xInSize) (xOutOffset, xOutSize) xs
| otherwise =
callChecks this gasGiven xContext xTo xValue xInOffset xInSize xOutOffset xOutSize xs $
\xGas -> do
Expand Down

0 comments on commit fdc3d80

Please sign in to comment.