Skip to content

fix(gnovm): skip closure frames in AssertOriginCall origin check#5407

Open
notJoon wants to merge 3 commits intognolang:masterfrom
notJoon:test/issue-3918-assertorigincall-anon-func
Open

fix(gnovm): skip closure frames in AssertOriginCall origin check#5407
notJoon wants to merge 3 commits intognolang:masterfrom
notJoon:test/issue-3918-assertorigincall-anon-func

Conversation

@notJoon
Copy link
Copy Markdown
Member

@notJoon notJoon commented Apr 1, 2026

Description

fixes #3918

Fixes an "invalid non-origin call" panic occurs when runtime.AssertOriginCall() is invoked through an anonymous(closure) function.

The previous isOriginCall determined whether a call was an origin call by comparing the number of frames against a hardcoded constant. Closures add a frame upon invocation, but they should not be semantically treated as a separate method call.

Although FuncValue.IsClosure clearly distinguish between func lits and func decls, isOriginCall did not utilize this and instead compared only the total number of frames.

IsClosure bool // is a func lit expr closure (not decl)

I believe this was the root cause of the issue, so I updated all instance of isOriginCall to determine origin call status based on the frame count excluding closure frames.

Changes

  • Added Machine.NumNonClosureFrames() to count only non-closure frame calls
  • Added file tests reproducing this issue (std13.gno, std14.gno)

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Apr 1, 2026
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Apr 1, 2026
@Gno2D2
Copy link
Copy Markdown
Collaborator

Gno2D2 commented Apr 1, 2026

🛠 PR Checks Summary

🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: notJoon/gno-core)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least one of these user(s) reviewed the pull request: [davd-gzl jefft0 notJoon omarsy MikaelVallenet] (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            └── 🔴 On no pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 64.28571% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gnovm/stdlibs/chain/runtime/native.go 0.00% 3 Missing ⚠️
...ovm/tests/stdlibs/chain/runtime/testing_runtime.go 50.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 🤖 gnovm Issues or PRs gnovm related review/triage-pending PRs opened by external contributors that are waiting for the 1st review

Projects

Status: No status
Status: In Review

Development

Successfully merging this pull request may close these issues.

[GnoVM] Using anonymous functions with AssertOriginCall

2 participants