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 83 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2dcdfd5
naive fix
ltzmaxwell Jun 24, 2024
3056bcd
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell Jul 26, 2024
e69dfc0
Merge branch 'master' of github.com:gnolang/gno
ltzmaxwell Aug 13, 2024
9d05216
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell Aug 22, 2024
fb2f408
fix untyped bool
ltzmaxwell Aug 22, 2024
22f973f
revert un-intentional change
ltzmaxwell Aug 27, 2024
2926b3d
test files
ltzmaxwell Sep 22, 2024
c3e3bdd
debug
ltzmaxwell Sep 23, 2024
72b28d7
debug
ltzmaxwell Sep 27, 2024
00a59e7
save
ltzmaxwell Oct 7, 2024
71c6fed
external type
ltzmaxwell Oct 8, 2024
07d9029
save
ltzmaxwell Oct 10, 2024
8fdc399
save
ltzmaxwell Oct 14, 2024
a604cdc
more test
ltzmaxwell Oct 16, 2024
2e6a97c
save
ltzmaxwell Nov 6, 2024
7bedb54
save
ltzmaxwell Nov 6, 2024
eeb5bd8
more obj info
ltzmaxwell Nov 8, 2024
9175b85
test
ltzmaxwell Nov 9, 2024
c41caa3
make test pass
ltzmaxwell Nov 12, 2024
48eb8b9
fixup
ltzmaxwell Nov 12, 2024
0bef907
fixup
ltzmaxwell Nov 12, 2024
585b370
test array
ltzmaxwell Nov 13, 2024
c8b24f5
add test
ltzmaxwell Nov 13, 2024
ff95ddc
debug
ltzmaxwell Nov 16, 2024
ecad113
more embede tests
ltzmaxwell Nov 22, 2024
e2670cc
start refactor
ltzmaxwell Nov 24, 2024
e28a2ba
save
ltzmaxwell Nov 25, 2024
696e6da
save
ltzmaxwell Nov 25, 2024
675355d
clean
ltzmaxwell Nov 25, 2024
4af9d45
save
ltzmaxwell Nov 25, 2024
588b9dd
change api
ltzmaxwell Nov 26, 2024
928bda2
fixup
ltzmaxwell Nov 26, 2024
35927e6
fixup
ltzmaxwell Nov 26, 2024
8b435e6
fixup
ltzmaxwell Nov 26, 2024
0d2c203
debug
ltzmaxwell Nov 26, 2024
e0a040e
add test
ltzmaxwell Nov 28, 2024
3ec7a2e
fixup
ltzmaxwell Dec 30, 2024
fd7f8c8
refactor test
ltzmaxwell Dec 31, 2024
453554b
fixup
ltzmaxwell Jan 1, 2025
30883f0
debug
ltzmaxwell Jan 4, 2025
b0241aa
fixup
ltzmaxwell Jan 5, 2025
926e6e9
fixup
ltzmaxwell Jan 6, 2025
bff5b19
fixup
ltzmaxwell Jan 8, 2025
119e505
fixup
ltzmaxwell Jan 13, 2025
91a38af
clean
ltzmaxwell Jan 13, 2025
6e39af1
merge master
ltzmaxwell Jan 13, 2025
b09f61a
fixup{
ltzmaxwell Jan 13, 2025
aa06af6
func value check
ltzmaxwell Jan 13, 2025
ea06afc
fixup
ltzmaxwell Jan 15, 2025
ce22178
fixup
ltzmaxwell Jan 15, 2025
78eca08
fixup
ltzmaxwell Jan 15, 2025
36738b1
save
ltzmaxwell Jan 15, 2025
0a25077
add some comments
ltzmaxwell Feb 3, 2025
23644d8
refactor
ltzmaxwell Feb 4, 2025
301935f
fixup
ltzmaxwell Feb 4, 2025
3342991
fixup
ltzmaxwell Feb 4, 2025
4ed5fe6
save
ltzmaxwell Feb 5, 2025
6b13f34
fixup
ltzmaxwell Feb 6, 2025
943a82e
fixup
ltzmaxwell Feb 6, 2025
a57e1bf
fixup
ltzmaxwell Feb 6, 2025
5be6f68
fixup
ltzmaxwell Feb 9, 2025
79e0903
fixup
ltzmaxwell Feb 10, 2025
5a84415
fixup
ltzmaxwell Feb 10, 2025
dd7bfa4
fixup
ltzmaxwell Feb 11, 2025
3e949ff
recursive guard
ltzmaxwell Feb 11, 2025
77f4a22
fixup
ltzmaxwell Feb 11, 2025
f174e98
test
ltzmaxwell Feb 11, 2025
d0ead8c
fixup
ltzmaxwell Feb 11, 2025
f527e18
fixup
ltzmaxwell Feb 12, 2025
0f7448d
fixup
ltzmaxwell Feb 12, 2025
c740c45
refactor
ltzmaxwell Feb 12, 2025
d2981b7
sync
ltzmaxwell Feb 12, 2025
e2274bc
recursive guard
ltzmaxwell Feb 12, 2025
3cf2dab
revert machine change
ltzmaxwell Feb 12, 2025
8a30b99
fixup
ltzmaxwell Feb 13, 2025
a64a951
test pass
ltzmaxwell Feb 13, 2025
b29397b
fixup
ltzmaxwell Feb 13, 2025
e0eb2b3
fixup
ltzmaxwell Feb 13, 2025
1d80388
save, handle dirty oo
ltzmaxwell Feb 14, 2025
938b3a4
fixup
ltzmaxwell Feb 15, 2025
5aeadd6
fixup
ltzmaxwell Feb 16, 2025
3bdaab2
clean
ltzmaxwell Feb 16, 2025
9136a1d
sync
ltzmaxwell Feb 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/gno.land/p/demo/tests/tests.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
psubtests "gno.land/p/demo/tests/subtests"
)

type Foo struct{ name string }

var F = Foo{"p"}

const World = "world"

func CurrentRealmPath() string {
Expand Down
12 changes: 6 additions & 6 deletions examples/gno.land/r/demo/boards/z_4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func main() {
// "Base": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "336074805fc853987abe6f7fe3ad97a6a6f3077a:2"
// "ObjectID": "purePkg:336074805fc853987abe6f7fe3ad97a6a6f3077a:2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for object from pure package, make objectID with a prefix "purePkg", so it's possible to distinct with object from realm. this does not change the current realm object persistence. but it looks ugly.

// },
// "Index": "182",
// "TV": null
Expand Down Expand Up @@ -504,7 +504,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "0fd3352422af0a56a77ef2c9e88f479054e3d51f",
// "Hash": "4f0883532c1f35946dd4ca240781157e91447a92",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131"
// }
// },
Expand Down Expand Up @@ -541,7 +541,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "c45bbd47a46681a63af973db0ec2180922e4a8ae",
// "Hash": "92761e5476881f637dd3b1c511e7f2beedec200f",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127"
// }
// }
Expand Down Expand Up @@ -792,7 +792,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "a416a751c3a45a1e5cba11e737c51340b081e372",
// "Hash": "92919a731f2816f8ac28938c1ee66fb12d95810c",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:86"
// }
// },
Expand All @@ -810,7 +810,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "36299fccbc13f2a84c4629fad4cb940f0bd4b1c6",
// "Hash": "f00c735099ba634c00dc3076978e16fd9899e9d0",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:87"
// }
// },
Expand Down Expand Up @@ -905,7 +905,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "a88a9b837af217656ee27084309f7cd02cd94cb3",
// "Hash": "bbf8cb63d9a27d3cb74e676801c92239fe00a159",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:85"
// }
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package crossrealm_array

type Foo struct{ name string }

var f = Foo{"foo"}

func GetArray() [2]Foo {
return [2]Foo{Foo{"a"}, Foo{"b"}}
}

func GetArray2() [2]*Foo {
return [2]*Foo{&Foo{"a"}, &Foo{"b"}}
}

func GetArray3() [1]*Foo {
return [1]*Foo{&f}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (ls *LocalStruct) String() string {
var local *LocalStruct

func init() {
local = &LocalStruct{A: 123}
local = &LocalStruct{A: 123} // this is attached first
}

// Make1 returns a local object wrapped by a p struct
Expand Down
47 changes: 47 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/func/crossrealm_func.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package crossrealm_func

type F func() bool

var f F

func SetCallback(ff F) {
f = ff
}

func ExecuteCallback() {
f()
}

var ff = func() string { return "a" } // parent object already escaped

// XXX, this is special case, for ff, it's closure is referenced,
// so need to check all embedded items attached?
// see zrealm_crossrealm38.gno
func GetFunc() func() string {
return ff
}

func GetFunc2() func() string {
return func() string {
return "b"
}
}

type MyStruct struct{}
type MyStruct2 struct{ name string }

func (sv *MyStruct) M() string { return "a" }

var mysv *MyStruct = &MyStruct{}

func (sv2 MyStruct2) M2() string { return "a2" }

var mysv2 = MyStruct2{name: "struct_val"}

func GetMethod() func() string {
return mysv.M
}

func GetMethod2() func() string {
return mysv2.M2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package iface

type Foo2 struct{}

// XXX, how about not interface
type Fooer interface{ Foo() }

var fooer Fooer

func SetFooer(f Fooer) Fooer {
fooer = f
return fooer
}

func CallFoo() { fooer.Foo() }

// container in external realm
type Container struct {
name string
f Fooer
}

var container Container // attached

func RunF() {
container.f.Foo()
}
func SetContainer(f Fooer) {
container.f = f // update
}

func SetContainer2(f Fooer) {
ff := f // associate to non-attached object
SetContainer(ff) // attach container, while ff is not attached
}
37 changes: 37 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/map/crossrealm_map.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package crossrealm_map

type Foo struct{}

var f = Foo{}

var m map[string]int

func init() {
m = make(map[string]int)
m["a"] = 1
}

func GetMap() map[string]int {
return m
}

func GetMap2(f func(map[string]int)) {
m1 := map[string]int{"a": 1}
f(m1)
}

func GetMap4() map[string]Foo {
var m1 = map[string]Foo{"foo": f}
return m1
}

// --------------------------------------
type MyMap map[string]int

var m2 = MyMap{"a": 1}

func GetMap3() MyMap {
return m2
}

// TODO: add some map with elements of object
124 changes: 124 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package crossrealm_slice

import "gno.land/p/demo/tests/p_crossrealm"

type Fooer interface{ Foo() }

var S []Fooer

func SetSlice(fs []Fooer) {
S = fs
for _, f := range fs {
f.Foo()
}
}

var Arr [3]Fooer

func SetArray(arr [3]Fooer) {
Arr = arr
for _, f := range Arr {
println(f)
}
}

// -------------------------------------
type XYZ struct{ name string }

var s1 []XYZ // underlying array is real after decl
var s3 []XYZ

// var s4 []XYZ
var s4 = make([]XYZ, 1, 2)

// NOTE that if new list allocated, XYZ{"4"} will be copied, and it's a new object
// var s4 = make([]XYZ, 1)
var s5 []*XYZ
var s6 = make([]*XYZ, 2)

var s7 [2]XYZ

var s10 []int

func init() {
s1 = append(s1, XYZ{"1"})
s1 = append(s1, XYZ{"2"})

s3 = append(s3, XYZ{"3"})
//s4 = append(s4, XYZ{"4"})
s4[0] = XYZ{"4"}

s5 = append(s5, &XYZ{"5"})

s6[0] = &XYZ{"6"}

s7[0] = XYZ{"7"}
s7[1] = XYZ{"7.1"} // should be real after this
s10 = append(s10, 1)
}

func GetSlice() []XYZ {
return s1[:]
}

// -------------------------------------------------------
var e1 = XYZ{"1"}
var e2 = XYZ{"2"}

func GetSlice2() []XYZ {
var s2 []XYZ
s2 = append(s2, e1)
s2 = append(s2, e2)
return s2
}

// ------------------------------------------------------
func GetSlice3() []XYZ {
s3 = append(s3, XYZ{"0"}) // this is real after function
return s3
}

func GetSlice4(f func(s []XYZ)) {
s4 = append(s4, XYZ{"0"}) // this is real after this function
f(s4)
}

func GetSlice5() []*XYZ { // TODO, unwrap
return s5
}

func GetSlice6(f func(s []*XYZ)) {
s6[1] = &XYZ{"6.1"}
f(s6)
}

func GetSlice7(f func(s [2]XYZ)) {
//s7[1] = XYZ{"7.1"}
f(s7)
}

var s8 [1]p_crossrealm.Stringer

func GetSlice8(f p_crossrealm.Stringer) [1]p_crossrealm.Stringer {
s8[0] = f
return s8
}

func GetSlice9(f p_crossrealm.Stringer) [1]p_crossrealm.Stringer {
var s9 [1]p_crossrealm.Stringer
s9[0] = f
return s9
}

// XXX, s10 under array is real, and owned by this realm.
func GetSlice10() []int {
return s10
}

func GetSlice11(f func(s []int)) {
// XXX, this is valid cuz the type of
// array is not defined in current realm(or any other),
// and the underlying array is not owned by this realm.
s11 := []int{1}
f(s11)
}
Loading
Loading