From 4c6b7a93dca88897b4806fec073bb3eb3aa6d2dc Mon Sep 17 00:00:00 2001 From: Mate Soos Date: Wed, 30 Apr 2025 13:01:15 +0200 Subject: [PATCH] No need to fetch and transfer for 0 tx to precompile --- src/EVM.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/EVM.hs b/src/EVM.hs index 4ac225523..647ca918c 100644 --- a/src/EVM.hs +++ b/src/EVM.hs @@ -1167,13 +1167,14 @@ precompiledContract this xGas precompileAddr recipient xValue inOffset inSize ou case result' of Nothing -> case stk of x:_ -> case maybeLitWordSimp x of - Just 0 -> + Just 0 -> pure () + Just 1 -> do + when (xValue /= Lit 0) $ do + fetchAccount (LitAddr recipient) $ \_ -> do + touchAccount self + touchAccount (LitAddr recipient) + transfer self (LitAddr recipient) xValue pure () - Just 1 -> - fetchAccount (LitAddr recipient) $ \_ -> do - touchAccount self - touchAccount (LitAddr recipient) - transfer self (LitAddr recipient) xValue _ -> unexpectedSymArg "unexpected return value from precompile" [x] _ -> underrun _ -> pure ()