You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Legacy truncates indexed log topic, while IR leaves it untruncated. This would lead to a divergence of blockchain state depending on which backend is used.
To reproduce
$ cp test.sol test/libsolidity/semanticTests
$ isoltest -t semanticTests/test
Running via Yul:
Expected result:
// constructor() ->
// ~ emit ev0(bytes1): #"1"
Obtained result:
// constructor() ->
// ~ emit ev0(bytes1): #"1111111111111111"
Attention: Updates on the test will apply the detected format displayed.
Note that the test passed without Yul.
Note that the divergence is maintained with/without optimizer so I would guess this may be a bug related to truncation (or lack thereof) in Sol->Yul.
The text was updated successfully, but these errors were encountered:
In case of discrepancies, Which version do we prefer? the output produced by the Old Code Generator or the one produced by the New Code generator ?
The one that matches the spec :) Value-type parameters are not hashed and the value passed to the event is just one byte (0x31, i.e. "1" in ASCII) so that's what should be stored.
IR behavior is weird here though. The value is not a hash but the original bytes16 value so somehow it does not generate code for the bytes1 conversion. Or maybe the lower bytes just aren't cleaned? Alternatively, could be a bug with how isoltest displays it. We added support for events only quite recently (#11050).
By the way, I think we should update the docs for indexed parameters as a part of this issue. Encoding of Indexed Event Parameters actually does not say anything about the encoding indexed parameters of value types. It only mentions non-values types.
You can add the attribute indexed to up to three parameters which adds them to a special data structure known as “topics” instead of the data part of the log. A topic can only hold a single word (32 bytes) so if you use a reference type for an indexed argument, the Keccak-256 hash of the value is stored as a topic instead.
Legacy truncates indexed log topic, while IR leaves it untruncated. This would lead to a divergence of blockchain state depending on which backend is used.
To reproduce
Note that the divergence is maintained with/without optimizer so I would guess this may be a bug related to truncation (or lack thereof) in Sol->Yul.
The text was updated successfully, but these errors were encountered: