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

WIP fix(gnovm): PoC of inter-realm spec #2958

Draft
wants to merge 79 commits into
base: master
Choose a base branch
from

Conversation

ltzmaxwell
Copy link
Contributor

@ltzmaxwell ltzmaxwell commented Oct 16, 2024

WIP: adding filetest for inter-realm spec, NOT FINAL.
relate: #2743

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

@ltzmaxwell ltzmaxwell requested review from jaekwon, moul, piux2, thehowl, mvertes and a team as code owners October 16, 2024 10:22
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related labels Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 95.58442% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gnovm/pkg/gnolang/debug.go 25.00% 4 Missing and 2 partials ⚠️
gnovm/pkg/gnolang/realm.go 97.46% 4 Missing and 1 partial ⚠️
gnovm/pkg/gnolang/ownership.go 96.66% 2 Missing and 1 partial ⚠️
gnovm/pkg/gnolang/uverse.go 75.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jefft0 jefft0 added review/triage-pending PRs opened by external contributors that are waiting for the 1st review and removed review/triage-pending PRs opened by external contributors that are waiting for the 1st review labels Oct 16, 2024
@jefft0
Copy link
Contributor

jefft0 commented Oct 17, 2024

(The "review team" label was added by mistake. This PR is opened by a core dev.)

@Kouteki Kouteki removed the in focus label Feb 3, 2025
Comment on lines 1 to 27
// PKGPATH: gno.land/r/crossrealm_test
package crossrealm_test

import (
"std"

crossrealm "gno.land/r/demo/tests/crossrealm/func"
)

var b = 1

type Local_S struct {
name string
}

func main() {
f := func() bool {
c := b
var ls *Local_S
return true
}
crossrealm.SetCallback(f)
println("ok")
}

// Output:
// ok
Copy link
Contributor Author

@ltzmaxwell ltzmaxwell Feb 3, 2025

Choose a reason for hiding this comment

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

When a FuncValue is associated with an ownership tree, its parent block is persisted during finalization. The main reason for this is that when the FuncValue is executed, it needs to resolve names from its outer blocks.

However, this introduces a side effect: when a FuncValue is associated with an external realm, its "clo", the parent block(the main block in the code above) gets attached to that external realm, is it intended? if yes, while attaching this block to external realm, it is necessary to check recursively against the objects within this block , to identify if cross-realm happens, iff the block is un-real(if it's already real, everything is good), right?

So the FuncLit works similarly as MapLit, StructLit, etc.

↑ are some thoughts about FuncValue behavior in cross-realm situation after last call. @thehowl .

Anyway, will write some tests to explore this. And will appreciate if @jaekwon can help clarify this.

Copy link
Contributor Author

@ltzmaxwell ltzmaxwell Feb 10, 2025

Choose a reason for hiding this comment

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

Upon further consideration, if a function(closure) does not reference or capture any variables from outer scopes, it can be considered pure. As a result, the Closure field of the FuncValue is nil. Therefore, when associating this func with the current or an external realm, there is no need to attach its parent block, so this issue is also resolved: #3693, correct?

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Feb 13, 2025
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: No status
Status: In Progress
Development

Successfully merging this pull request may close these issues.

7 participants