gno icon indicating copy to clipboard operation
gno copied to clipboard

WIP: fix(gnovm): fill package value for GetPackage and GetObject

Open ltzmaxwell opened this issue 6 months ago • 2 comments

ltzmaxwell avatar Jun 15 '25 16:06 ltzmaxwell

🛠 PR Checks Summary

All Automated Checks passed. ✅

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)

☑️ 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: ltzmaxwell/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this 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

Gno2D2 avatar Jun 15 '25 16:06 Gno2D2

Codecov Report

:x: Patch coverage is 70.83333% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gnovm/pkg/gnolang/store.go 80.00% 3 Missing and 1 partial :warning:
gnovm/pkg/gnolang/realm.go 0.00% 3 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Jun 16 '25 10:06 codecov[bot]

Can we make GetPackage call GetObjectSafe, at this point? 👍 , see f76bdb2

I'm worried if this might encourage misuse of GetObject to get packages more generally; maybe one small step against this is to unexport ObjectIDFromPkgPath?

That can avoid misuse in external package only. i'd like to introduce a new method only for getting pkg from store: GetPackageFromStore, along with some comments, so that people are still discouraged to use GetObject for a *PackageValue, as it may yield unpredictable result . wdyt? see: https://github.com/gnolang/gno/pull/4376/commits/55a018a91f4ca28152dd19d5d69582e0444d84fe

ltzmaxwell avatar Jul 23 '25 13:07 ltzmaxwell

That can avoid misuse in external package only. i'd like to introduce a new method only for getting pkg from store: GetPackageFromStore, along with some comments, so that people are still discouraged to use GetObject for a *PackageValue, as it may yield unpredictable result . wdyt?

The change works if GetObject panics if it should return a PackageValue. Maybe we can have this in GetObject rather than GetObjectSafe, so "safe" is the method that does not panic. Do you agree?

thehowl avatar Aug 05 '25 10:08 thehowl

This PR is a blocker for GnoSwap

Kouteki avatar Sep 01 '25 06:09 Kouteki

I'm worried if this might encourage misuse of GetObject to get packages more generally; maybe one small step against this is to unexport ObjectIDFromPkgPath?

I think the reason we didn’t want GetObject to be used for retrieving packages was that it’s not a complete implementation—it doesn’t use pkgGetter and it also doesn’t populate the package’s realm. By design, GetPackage is the only intended entry point for this.

However, now we need to retrieve a package by ObjectID solely from the cache/store(get containing package of an object), so using GetObject for this purpose makes sense. do you agree. @thehowl

ltzmaxwell avatar Sep 03 '25 13:09 ltzmaxwell