Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(stdlibs/std): re-organize gnoEvent struct #2160

Merged

Conversation

r3v4s
Copy link
Contributor

@r3v4s r3v4s commented May 21, 2024

Closes #2002

Also related to #2001

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • [] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • [] Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@r3v4s r3v4s requested review from thehowl, zivkovicmilos and a team as code owners May 21, 2024 09:29
@r3v4s r3v4s self-assigned this May 21, 2024
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels May 21, 2024
Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.79%. Comparing base (6243b56) to head (bfe3538).
Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2160      +/-   ##
==========================================
+ Coverage   54.63%   54.79%   +0.15%     
==========================================
  Files         583      583              
  Lines       78507    79110     +603     
==========================================
+ Hits        42895    43350     +455     
- Misses      32399    32487      +88     
- Partials     3213     3273      +60     
Flag Coverage Δ
contribs/gnodev 23.81% <ø> (ø)
contribs/gnofaucet 15.31% <ø> (+0.85%) ⬆️
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 62.54% <ø> (+0.52%) ⬆️
gnovm 59.97% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looks great 💯

Thank you for applying the suggested changes from the original PR 🙏

gnovm/stdlibs/std/emit_event.go Outdated Show resolved Hide resolved
gnovm/stdlibs/std/emit_event.go Outdated Show resolved Hide resolved
gnovm/stdlibs/std/native.go Outdated Show resolved Hide resolved
gno.land/cmd/gnoland/testdata/event_normal.txtar Outdated Show resolved Hide resolved
@zivkovicmilos
Copy link
Member

@r3v4s Can you pull in the latest master?

gnovm/stdlibs/std/emit_event.go Outdated Show resolved Hide resolved
gnovm/stdlibs/std/emit_event.go Outdated Show resolved Hide resolved
gnovm/stdlibs/std/emit_event.go Outdated Show resolved Hide resolved
@r3v4s r3v4s added this to the 🏗4️⃣ test4.gno.land milestone Jun 3, 2024
@r3v4s r3v4s force-pushed the feat/add-more-metadata-in-gnoevent branch from 5aecf52 to 2525776 Compare June 5, 2024 04:27
@r3v4s
Copy link
Contributor Author

r3v4s commented Jun 18, 2024

@zivkovicmilos @thehowl
Adding more metadata in event struct by default brings pros and cons.

Here is my new suggestion

  1. Remove Type. I really can't find meaningful usage for this specified type data. (Perhaps Name would be more to determine which event)

  2. Keep current pkgPath, Func, OrigCaller and prev. For observability I think these for values are least required ones.

  3. PrevFunc is tricky. I wanted bring more observability only by just examining event datas, not bunch of other datas from another rpc end points. But if this is too much for general point of view, we can get rid of it.

@r3v4s r3v4s force-pushed the feat/add-more-metadata-in-gnoevent branch from 2525776 to 4c4fd24 Compare June 24, 2024 10:18
@thehowl
Copy link
Member

thehowl commented Jun 24, 2024

Okay, I've had a discussion with Milos with what to do here.

Essentially, I don't think there is a compelling case for adding PrevRealm nor PrevFunc. PrevFunc shouldn't be necessary (also I think it's buggy, but anyway); PrevRealm contains information which if it is really useful to the reader of the events, they can just be passed in as attributes. (That's the whole point of attributes).

Reading your last comment;

Here is my new suggestion

1. Remove `Type`. I really can't find meaningful usage for this specified `type` data. (Perhaps `Name` would be more to determine which event)

2. Keep current `pkgPath`, `Func`, `OrigCaller` and `prev`. For observability I think these for values are least required ones.

3. `PrevFunc` is tricky. I wanted bring more observability only by just examining event datas, not bunch of other datas from another rpc end points. But if this is too much for general point of view, we can get rid of it.

I tend to agree on 2. For 3, I don't think PrevFunc or PrevRealm are useful, so just scrap them.

Type: we can change it to name, but having worked with event systems like this in the past, I know it's useful. If you're using Go, it allows you to have the name parsed as a string, and the attributes as a json.RawValue; then switching what to unmarshal the RawValue depending on the value of the type.

We can change it to name; but I think Type is fine too.

This is how I see this PR right now:

  • We can close, or:
  • Change Type to Name; and please, bring it back to the top of the struct (and put attributes next to it, instead of at the bottom)

@r3v4s r3v4s changed the title feat(gnovm/std): add more metadata in gnoEvent feat(gnovm/std): refactor: re-organized gnoEvent struct Jul 2, 2024
@thehowl thehowl changed the title feat(gnovm/std): refactor: re-organized gnoEvent struct refactor(stdlibs/std): re-organize gnoEvent struct Jul 2, 2024
@thehowl thehowl merged commit 981f3fa into gnolang:master Jul 2, 2024
89 checks passed
gfanton pushed a commit to gfanton/gno that referenced this pull request Jul 23, 2024
<!-- please provide a detailed description of the changes made in this
pull request. -->

Closes gnolang#2002

Also related to gnolang#2001 




<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

[chain] Add prev_realm to emitted events
3 participants