Improving decodeLogs #1637
Replies: 3 comments
-
Hey! Thanks for the feedback here. Those ideas are definitely very valuable!
Would you be able to provide a minimal reproduction here (usage + ABI)? Will be more than happy to look into this issue if you provide one!
Definitely agree. We checksum by default as a "safety by default" thing, but for some usecases that rely heavily on perf, this may be useless (we can get another ~8x perf improvement by not checksumming!). Perhaps we can add a |
Beta Was this translation helpful? Give feedback.
-
Yes sharing here:
prior to this, I had: as both are identical, only the name is changing. by the way the ts-expect-error is probably due to the fact that "Log" is from ethersjs, thus had to as any everything, thus viem is throwing an error. For the checksum side of the thing, I'd say a general env / client level setting could be a huge feature (for us at least) - a parameter to decodeLog could be good tho. |
Beta Was this translation helpful? Give feedback.
-
I love your website jxom.io btw. Amazing lighthouse score, congrats |
Beta Was this translation helpful? Give feedback.
-
Hello!
Been using decodeLogs, switching from decodeEvents of Web3JS due to improve perf (almost x2, congrats!)
I had some ideas in mind which I thought might be worth sharing:
decodeLogs crash sensitivity
decodeLogs is crashing when trying to parse an event with an ABI which would work BUT isn't exactly similar. For example, I'm parsing Withdraw/Deposit events with the same piece of code - the events are identical, only the name differs. With Web3js, I had no crash, but with decodeLogs I have to duplicate / complexify my code while the parsing remains the same.
Checksum is expensive
When parsing addresses, Viem is applying Checksum by default - checksum is super expensive, I believe most of the resources of my indexing script (indexing > 1B events) is actually coming (CPU wise) from cheksum events of this decodeLogs, while I don't need this at all, I'm lowercasing all the addresses for harmonization purpose - might be interesting to make it optional, maybe even at the library level - i.e. (addressType = lowercase | checksum) - would also save us from inattention mistakes & solidity type safety.
Just my 2 grains of salt, thanks a lot for producing viem.
Beta Was this translation helpful? Give feedback.
All reactions