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

feat: make AssertOriginCall always panic with MsgRun #1665

Merged

Conversation

tbruyelle
Copy link
Contributor

Fix #1663

AssertOriginCall used to panic on MsgRun because it involves more than 2 frames. But we want to reinforce that property, with an additional check.

Added an improved version of the unit and txtar tests from #1048. In particular, the txtar adds 2 more cases :

  1. MsgCall invokes std.AssertOriginCall directly: pass
  2. MsgRun invokes std.AssertOriginCall directly: PANIC

Note that 19) involves a change in the AssertOriginCall algorithm, because in that situation there's only a single frame. Even if there's no reason to call std.AssertOriginCall() directly from the command line, I think it's logic to make it pass, because that's a origin call.

To run the txtar test:

$ go test ./gno.land/cmd/gnoland/ -v -run TestTestdata/assert
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.

@tbruyelle tbruyelle requested review from jaekwon, thehowl, moul and a team as code owners February 18, 2024 18:12
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Feb 18, 2024
Copy link

codecov bot commented Feb 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.84%. Comparing base (8de4c31) to head (31a6ef4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1665      +/-   ##
==========================================
+ Coverage   49.91%   53.84%   +3.92%     
==========================================
  Files         576      435     -141     
  Lines       77820    67514   -10306     
==========================================
- Hits        38847    36350    -2497     
+ Misses      35843    28209    -7634     
+ Partials     3130     2955     -175     
Flag Coverage Δ
contribs/gnodev ?
contribs/gnofaucet ?
contribs/gnokeykc ?
contribs/gnomd ?
gno.land 61.67% <ø> (+0.04%) ⬆️
gnovm 44.96% <100.00%> (+0.06%) ⬆️
misc/autocounterd ?
misc/genproto ?
misc/genstd ?
misc/goscan ?
misc/logos ?
misc/loop ?
tm2 ?

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
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

Looks good, just left a couple of minor comments. Thanks 💯

gnovm/stdlibs/std/native.gno Outdated Show resolved Hide resolved
gnovm/stdlibs/std/native.gno Outdated Show resolved Hide resolved
gnovm/stdlibs/std/native.go Show resolved Hide resolved
tbruyelle and others added 5 commits April 22, 2024 21:00
Fix gnolang#1663

`AssertOriginCall` used to panic on `MsgRun` because it involves more
than 2 frames. But we want to reinforce that property, with an
additional check.

Added an improved version of the unit and txtar tests from gnolang#1048. In
particular, the txtar adds 2 more cases :

19) MsgCall invokes std.AssertOriginCall directly: pass
20) MsgRun invokes std.AssertOriginCall directly: PANIC

Note that 19) involves a change in the AssertOriginCall algorithm,
because in that situation there's only a single frame. Even if there's
no reason to call `std.AssertOriginCall()` directly from the command
line, I think it's logic to make it pass, because that's a origin call.
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
@tbruyelle tbruyelle force-pushed the tbruyelle/feat/assertOriginCall-msgRun branch from 242c3af to f4f867e Compare April 22, 2024 19:09
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.

Thank you for the fix as always 🙏

@zivkovicmilos
Copy link
Member

Hey @tbruyelle, can you pull in the latest master changes into the PR, so we can go ahead and merge? 🙏

@tbruyelle tbruyelle requested review from mvertes and a team as code owners May 15, 2024 13:09
@tbruyelle
Copy link
Contributor Author

tbruyelle commented May 15, 2024

Hey @tbruyelle, can you pull in the latest master changes into the PR, so we can go ahead and merge? 🙏

So I was able to merge master and fix some tests, but there's something I don't understand; the stdlib/std.Realm type is no longer there, so the added tested TestPrevRealmIsOrigin is complaining. Seems related to the work of @thehowl with native stuff. Any help would be appreciated.

@thehowl thehowl merged commit 5924df8 into gnolang:master May 27, 2024
48 of 49 checks passed
omarsy pushed a commit to TERITORI/gno that referenced this pull request Jun 3, 2024
…gnolang#1665)

Fix gnolang#1663

`AssertOriginCall` used to panic on `MsgRun` because it involves more
than 2 frames. But we want to reinforce that property, with an
additional check.

Added an improved version of the unit and txtar tests from gnolang#1048. In
particular, the txtar adds 2 more cases :

19) MsgCall invokes std.AssertOriginCall directly: pass
20) MsgRun invokes std.AssertOriginCall directly: PANIC

Note that 19) involves a change in the AssertOriginCall algorithm,
because in that situation there's only a single frame. Even if there's
no reason to call `std.AssertOriginCall()` directly from the command
line, I think it's logic to make it pass, because that's a origin call.

To run the txtar test:
```
$ go test ./gno.land/cmd/gnoland/ -v -run TestTestdata/assert
```

<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
- [x] 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>

---------

Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
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 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

feat: make AssertOriginCall always panic with MsgRun
5 participants