Structure of CreateMerkleLockup
event
#308
Replies: 2 comments 4 replies
-
Thank you for this analysis @smol-ninja! The issue was prompted initially by my subgraph integration. On the "indexed" aspect - in general we don't use any tooling that searches events on-chain on-demand, so (outside of any third parties maybe using it) we don't take advantage of event filtering anyway. On the "indexed tuple" aspect, the fact that "the whole struct bytes get hashed" as Shub explained in the OP also means that the O3 unfortunately isn't very attractive as it renders our event parsing useless. We could, as an alternative, use web3 calls to get those parameters on demand - but it introduces a ton of complexity and time into the subgraph/indexing algorithm (we already do that for a couple of things like asset data, and it proved non-trivial). O2 seems like a good middle-ground, but we should decide if indexed elements are important for us or not. If the answer is no, O4 seems more efficient. O1 is fine too, has its advantages (not having tuples makes usage through tools like Etherscan and Tenderly easier) but is a bit more messy. I'm leaning towards O4, but would like to hear your takes as well. |
Beta Was this translation helpful? Give feedback.
-
Resolved in |
Beta Was this translation helpful? Give feedback.
-
The emitted events during
CreateMerkleLockup
index the wholeConstructorParams
struct. However, since topics can't hold more than 32 bytes (from docs), the whole struct bytes get hashed before being emitted as an indexed value. Thus, any of the parameters of theConstructorParams
struct cannot be searched directly on-chain. You need to know the values of all the parameters and then use the Keccak-256 hash in order to search for it.Therefore, it does not make sense to index the whole struct. There are two options that we can consider:
O1: Full expansion
This would increase the gas cost by 2466.
O2: Index
admin
andasset
This would increase the gas cost by 750 = 375 * 2 new topics. Note that we are still hashing
baseParams
to save on gas cost.O3: Unchanged / remove
baseParams
This imo is the cheapest way to emit event but it makes
baseParams
unusable. We may be better off not including it at all and saving 375 gas (1 less topic).O4: Remove indexed from
baseParams
This would increase gas cost by 2466 but this makes the entire
baseParams
usable through emitted logs.Comments welcome from @sablier-labs/engineers.
Beta Was this translation helpful? Give feedback.
All reactions