echidna icon indicating copy to clipboard operation
echidna copied to clipboard

Not all event parameters appear in gui's "event sequence"

Open webthethird opened this issue 2 years ago • 1 comments

While fuzzing Uniswap V2 with the Echidna streaming series, I've noticed that the "event sequence" that shows up in the gui when an assert fails does not always show all of the event parameters.

For instance, it seems that indexed event params never appear in the output. I wanted to see the from and to addresses in the Transfer(address indexed from, address indexed to, uint value) event emitted by UniswapV2ERC20, but all I could see was the value. Similarly, I had made my own BalancesBefore(uint balance0, uint balance1) event for debugging purposes, which always displayed two values in the gui, but when I added indexed to one of them, it disappeared from the output. Naturally, I just attributed this to the params being indexed.

What surprised me is that, once I removed the indexed keywords from the event definitions, all I could see in the gui then was the first address argument (i.e., the address 0 when minting, or the user's address when transferring to the pair contract), even though there were clearly two other non-indexed arguments which should also be printed:

Transfer(708794148849199719027776280888423651460573301061) from: UniswapV2ERC20@0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84

I tried adding an address argument to my own event, making it BalancesBefore(address user, uint balance0, uint balance1), and strangely enough, it appeared as I would have expected:

BalancesBefore(Users@0x7C276DcAab99BD16163c1bcce671CaD6A1ec0945, 1332, 2) from: EchidnaTest@0x00a329c0648769A73afAc7F9381E08FB43dBEA72 

Note: the decimal number printed in the Transfer event is equal to the Users address above, when converted to hex.

So, there's something funky going on with indexed event arguments, and something else (possibly unrelated) going on with address arguments in events. Indexed arguments simply never show up in the gui, whereas address arguments behave inexplicably - the first address in Transfer appears (converted to a decimal uint) when I remove the indexed, yet blocks the remaining arguments, whereas the address arg I added to BalanceBefore prints just fine, formatted correctly and without blocking the remaining two arguments after it. Consider me stumped...

webthethird avatar Dec 31 '22 22:12 webthethird

Decoding Indexed parameters are not implemented by hevm yet:

https://github.com/ethereum/hevm/blob/main/src/EVM/Format.hs#L217-L223

We will wait until they implement it, then, this issue will be solved.

ggrieco-tob avatar Jan 05 '23 01:01 ggrieco-tob

This is now fixed.

arcz avatar Feb 29 '24 16:02 arcz