Mintbase / arak

General Purpose Ethereum Event Indexer
GNU General Public License v3.0
1 stars 1 forks source link

Filter Invalid Topic Lengths #20

Closed bh2smith closed 11 months ago

bh2smith commented 11 months ago

Closes #19

This PR introduces an additional check that the length of the topics array aligns with what is expected based on the number of indexed fields in the event. We will no longer get partial Erc20 transfers (without value) int our ERC721 table. There may be other possible fixes (like the one suggested here https://github.com/nlordell/solabi-rs/issues/4), but I also think it makes sense for arak not to decode logs with known invalid data. Unfortunately, I don't believe we can prevent eth.get_Logs from returning this (due to having the same event signature).

cc @nlordell -- in case you're interested.

nlordell commented 11 months ago

So, I think this change works for the events you may be indexing, but it isn't a complete fix in and of itself. Specifically, imagine the following event signature:

event Foo(address bar, address indexed baz);

It cannot be distinguished from:

event Foo(address indexed bar, address bar);

Both will have the same topic[0] value, but one will be indexed with the bar and baz fields inverted. I think this is a pretty strong argument that arak shouldn't allow contract = "*" configurations, but that is a pretty big breaking change.