Open jinoosss opened 5 days ago
@zivkovicmilos @thehowl Can you take a look, please?
There is an assumption in this OP, and that is that having the information on where the event was called is useful information to begin with. I tend to disagree. If in the event we have information on where an event was emitted, then a consumer of the event will use this information to discriminate between different events.
Personally, I actually think we should remove more functionality from the current event implementation; ie. the Func
field, for the same reason I described. A consumer of the event should not have this information, as it can be used to conditionally handle an event, where really only the event pkgpath, type and attributes should be used to make that work. If I'm reorganizing my realm's code and decide to move a function with a different name, or to also emit the event somewhere else, the consumer application should not break because of this.
In light of this, here's what I think:
Line
in the event, which contains a line/column spec like gno.land/r/demo/emitter/package/pkg.gno:89:3
? This way you can point to where the event emission happens in Gnoscan, while having the event data be more obviously debugging information rather than information which should be depended upn.Line
field.Does this sound like something which could fit your use case?
I agree with that we shouldn't include too much information in std.Emit
like @thehowl suggested. However, there's also a need for detailed information to advancing the Gnoscan. But, using the line numbers seems impractical as it wouldn't provide enough context and would require complex tasks like drawing call graphs. Also, we cannot retreive enough state/data from a given blocks.
So instead of showing metadata like previous function or realm through the Emit
, what if create a new function like Ethereum's getLog
function to send only logging information via RPC, allowing data exchange with tools like tx-indexer?
In this case, I think we can use Emit
purely for messages, which allows to remove unneccesary metadata while still being able to utilize this information throught the log
. What do you think?
cc @dongwon8247 @jinoosss @r3v4s
Description
We're planning to introduce a new feature in GnoScan which traces and displays events that occured within a transaction. Below is the preview of the UI.
Unfortunately, we've come across an issue in the progress. There isn't a clear way to guarantee (1) the "depth" of each event within the function call stack, and (2) the function from which the event was emitted.
Here’s a simple contract example.
Two functions(
EmitEventMain
,EmitEventMainWithSub
) in a Realm(emit_main
) emit the same event "EVENT_MAIN".EmitEventMainWithSub
function, another contract(emit_sub
)'s function is called to emit the "EVENT_SUB" event.In this case, we cannot identify which of the two functions in the
emit_main
realm has triggered the emission of "EVENT_SUB" simply by parsing the events.[Realm: gno.land/r/demo/emit_sub]
[Realm: gno.land/r/demo/emit_main]
Block Results's ResponseBase when the
EmitEventMain
function andEmitEventMainWithSub
function are executed as multi messagesPR #2061, was an attempt to provide such a way by adding an index to each event, but was closed due to some concerns.
Are there any suggestions on how we should approach this issue? If not, it seems like it's worth re-exploring the
msg_idx
idea or something similar.This event support in GnoScan will be useful for users and developers to track events in-depth, especially for contracts that require connected events, such as DAOs, DEXes, etc.