Skip to content

Complex event data#677

Open
konradkonrad wants to merge 14 commits intomainfrom
complex_event_data
Open

Complex event data#677
konradkonrad wants to merge 14 commits intomainfrom
complex_event_data

Conversation

@konradkonrad
Copy link
Contributor

@konradkonrad konradkonrad commented Mar 12, 2026

There was an incorrect assumption when defining event trigger
matches on "complex" data values (i.e. those, spanning multiple data
words: bytes, string, ...).

Previously, we encoded the Length in the trigger definition and
expected to read that much from log data in order to match. However,
this would break, when the actual log data had a different alignment
(due to previous non-targeted arguments).

Instead we could remove Length from LogValueRef,
and rely on the encoded length in the event data (see
https://docs.soliditylang.org/en/latest/abi-spec.html) at the specified
Offset.

We added more tests, that use a SimulatedBackend EVM to make sure, we
can properly decode and match actual EVM generated logs.

Since Length is no longer defined, we had to adjust some tests and
remove some edge case checks that no longer apply.

This increments the Version byte of event trigger definition RLP encoding to 0x02.

Relates to shutter-network/shutter-api#84
Critical for: shutter-network/shutter-api#110

There was an incorrect assumption when defining event trigger
matches on "complex" data values (i.e. those, spanning multiple data
words: bytes, string, ...).

Previously, we encoded the `Length` in the trigger definition and
expected to read that much from log data in order to match. However,
this would break, when the actual log data had a different alignment
(due to previous non-targeted arguments).

Instead we could remove `Length` from `LogValueRef`,
and rely on the encoded length in the event data (see
https://docs.soliditylang.org/en/latest/abi-spec.html) at the specified
`Offset`.

We added more tests, that use a `SimulatedBackend` EVM to make sure, we
can properly decode and match actual EVM generated logs.

Since `Length` is no longer defined, we had to adjust some tests and
remove some edge case checks that no longer apply.
@konradkonrad konradkonrad marked this pull request as ready for review March 19, 2026 10:45
@konradkonrad konradkonrad requested a review from jannikluhn March 19, 2026 10:45
Following a PR comment, this introduces a boolean flag, to signal,
whether a LogPredicateValue should be read as a single word (`Dynamic:
false`) or an ABI encoded data slice of "dynamic size" (`Dynamic: true`).
Copy link
Contributor

@jannikluhn jannikluhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just one note about the RLP encoding/decoding

buf.ListEnd(listIndex)
}
buf.WriteBool(r.Dynamic)
buf.WriteUint64(r.Offset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't work, it needs a buf.List() call at the start to announce it's encoding an RLP list, not individual values. The same in the decoding function. However, since the encoding is static now (not either a list or a single value depending on the length), I don't think the custom EncodeRLP and DecodeRLP functions are necessary at all anymore. The RLP package should be able to encode/decode LogValueRef values out of the box. (missed this in my previous review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants