Skip to content

Commit 4ce710c

Browse files
authored
Merge pull request #1450 from gustavo-grieco/fix-event-decoding-crash
Fixed event decoding crash
2 parents 100aa72 + 9a5fc66 commit 4ce710c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/Echidna/Events.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import Data.Text (pack, Text)
1717
import Data.Tree (flatten)
1818
import Data.Tree.Zipper (fromForest, TreePos, Empty)
1919
import Data.Vector (fromList)
20+
import Data.Vector qualified as V
2021

2122
import EVM (traceForest)
22-
import EVM.ABI (Event(..), Indexed(..), decodeAbiValue, getAbi, AbiType(..), AbiValue(..))
23+
import EVM.ABI (Event(..), Indexed(..), decodeAbiValue, getAbiSeq, AbiType(..), AbiValue(..))
2324
import EVM.Dapp (DappContext(..), DappInfo(..))
2425
import EVM.Expr (maybeLitWordSimp)
2526
import EVM.Format (showValues, showError, contractNamePart)
@@ -91,10 +92,12 @@ extractEventValues dappInfo vm vm' =
9192
LogEntry _addr (ConcreteBuf bs) (sigHash : _) ->
9293
case Map.lookup (forceWord sigHash) dappInfo.eventMap of
9394
Just (Event _ _ params) ->
94-
[ (ty, val)
95-
| (_, ty, NotIndexed) <- params
96-
, Right (_, _, val) <- [ runGetOrFail (getAbi ty) (fromStrict bs) ]
97-
]
95+
let
96+
types = [ t | (_, t, NotIndexed) <- params ]
97+
in
98+
case runGetOrFail (getAbiSeq (length types) types) (fromStrict bs) of
99+
Right (_, _, vals) -> zip types (V.toList vals)
100+
_ -> []
98101
Nothing -> []
99102
_ -> []
100103

tests/solidity/values/events.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
contract EventAssert {
22
bytes32 private hash;
3-
event Secret(bytes32);
3+
event Secret(uint256, string, bytes32);
44
function reset(uint seed) public {
55
require(hash == 0);
66
bytes32 secret = keccak256(abi.encodePacked(seed));
7-
emit Secret(secret);
7+
emit Secret(1, "abc", secret);
88
hash = keccak256(abi.encodePacked(secret));
99
}
1010
function check(bytes32 seed) public {

0 commit comments

Comments
 (0)