-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gnovm): save object when refCount changed
- Loading branch information
Showing
7 changed files
with
587 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# test issue | ||
|
||
loadpkg gno.land/r/demo/realm $WORK | ||
|
||
# start a new node | ||
gnoland start | ||
|
||
|
||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func Fill --args 0 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func UnFill --args 0 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func Fill --args 0 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
|
||
|
||
-- realm.gno -- | ||
package main | ||
|
||
type A struct { | ||
A string | ||
} | ||
type B struct { | ||
A *A | ||
B string | ||
} | ||
|
||
var ( | ||
a = &A{A: "here"} | ||
b [2]*B | ||
) | ||
|
||
func Fill(i int) { | ||
c := B{ | ||
A: a, | ||
B: "", | ||
} | ||
b[i] = &c | ||
} | ||
|
||
func UnFill(i int) { | ||
b[i] = nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# test issue | ||
|
||
loadpkg gno.land/r/demo/realm $WORK | ||
|
||
# start a new node | ||
gnoland start | ||
|
||
|
||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func Fill --args 0 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func Fill --args 1 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
gnokey maketx call -pkgpath gno.land/r/demo/realm --func UnFill --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1 | ||
|
||
|
||
-- realm.gno -- | ||
package main | ||
|
||
type A struct { | ||
A string | ||
} | ||
type B struct { | ||
A *A | ||
B string | ||
} | ||
|
||
var ( | ||
a = &A{A: "here"} | ||
b [2]*B | ||
) | ||
|
||
func Fill(i int) { | ||
c := B{ | ||
A: a, | ||
B: "", | ||
} | ||
b[i] = &c | ||
} | ||
|
||
func UnFill() { | ||
b[0] = nil | ||
b[1] = nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// PKGPATH: gno.land/r/test | ||
package test | ||
|
||
var ( | ||
a = &A{A: "here"} | ||
b [2]*B | ||
) | ||
|
||
|
||
type A struct { | ||
A string | ||
} | ||
type B struct { | ||
A *A | ||
B string | ||
} | ||
|
||
func init() { | ||
c := B{ | ||
A: a, | ||
B: "c", | ||
} | ||
b[0] = &c | ||
|
||
d := B{ | ||
A: a, | ||
B: "d", | ||
} | ||
b[1] = &d | ||
} | ||
|
||
func main() { | ||
b[0] = nil | ||
} | ||
|
||
|
||
// Realm: | ||
// switchrealm["gno.land/r/test"] | ||
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:5]={ | ||
// "Data": null, | ||
// "List": [ | ||
// { | ||
// "T": { | ||
// "@type": "/gno.PointerType", | ||
// "Elt": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// } | ||
// } | ||
// }, | ||
// { | ||
// "T": { | ||
// "@type": "/gno.PointerType", | ||
// "Elt": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// } | ||
// }, | ||
// "V": { | ||
// "@type": "/gno.PointerValue", | ||
// "Base": { | ||
// "@type": "/gno.RefValue", | ||
// "Escaped": true, | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7" | ||
// }, | ||
// "Index": "1", | ||
// "TV": null | ||
// } | ||
// } | ||
// ], | ||
// "ObjectInfo": { | ||
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", | ||
// "ModTime": "9", | ||
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", | ||
// "RefCount": "1" | ||
// } | ||
// } | ||
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:7]={ | ||
// "Blank": {}, | ||
// "ObjectInfo": { | ||
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", | ||
// "IsEscaped": true, | ||
// "ModTime": "9", | ||
// "RefCount": "1" | ||
// }, | ||
// "Parent": { | ||
// "@type": "/gno.RefValue", | ||
// "Escaped": true, | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6" | ||
// }, | ||
// "Source": { | ||
// "@type": "/gno.RefNode", | ||
// "BlockNode": null, | ||
// "Location": { | ||
// "Column": "1", | ||
// "File": "main.gno", | ||
// "Line": "18", | ||
// "PkgPath": "gno.land/r/test" | ||
// } | ||
// }, | ||
// "Values": [ | ||
// { | ||
// "T": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// }, | ||
// "V": { | ||
// "@type": "/gno.RefValue", | ||
// "Hash": "c22ccb7832b422c83fec9943b751cb134fcbed0b", | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8" | ||
// } | ||
// }, | ||
// { | ||
// "T": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// }, | ||
// "V": { | ||
// "@type": "/gno.RefValue", | ||
// "Hash": "86c916fd78da57d354cb38019923bf64c1a3471c", | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9" | ||
// } | ||
// } | ||
// ] | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// PKGPATH: gno.land/r/test | ||
package test | ||
|
||
var ( | ||
a = &A{A: "here"} | ||
b [2]*B | ||
) | ||
|
||
|
||
type A struct { | ||
A string | ||
} | ||
type B struct { | ||
A *A | ||
B string | ||
} | ||
|
||
func init() { | ||
c := B{ | ||
A: a, | ||
B: "c", | ||
} | ||
b[0] = &c | ||
|
||
d := B{ | ||
A: a, | ||
B: "d", | ||
} | ||
b[1] = &d | ||
} | ||
|
||
func main() { | ||
b[0] = nil | ||
b[1] = nil | ||
} | ||
|
||
// Realm: | ||
// switchrealm["gno.land/r/test"] | ||
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:5]={ | ||
// "Data": null, | ||
// "List": [ | ||
// { | ||
// "T": { | ||
// "@type": "/gno.PointerType", | ||
// "Elt": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// } | ||
// } | ||
// }, | ||
// { | ||
// "T": { | ||
// "@type": "/gno.PointerType", | ||
// "Elt": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.B" | ||
// } | ||
// } | ||
// } | ||
// ], | ||
// "ObjectInfo": { | ||
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", | ||
// "ModTime": "9", | ||
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", | ||
// "RefCount": "1" | ||
// } | ||
// } | ||
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={ | ||
// "ObjectInfo": { | ||
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3", | ||
// "IsEscaped": true, | ||
// "ModTime": "9", | ||
// "RefCount": "1" | ||
// }, | ||
// "Value": { | ||
// "T": { | ||
// "@type": "/gno.RefType", | ||
// "ID": "gno.land/r/test.A" | ||
// }, | ||
// "V": { | ||
// "@type": "/gno.RefValue", | ||
// "Hash": "95dca2f5b12899b6367402ecdac04c7ca59a03d9", | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" | ||
// } | ||
// } | ||
// } | ||
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:6]={ | ||
// "Blank": {}, | ||
// "ObjectInfo": { | ||
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6", | ||
// "IsEscaped": true, | ||
// "ModTime": "9", | ||
// "RefCount": "3" | ||
// }, | ||
// "Parent": { | ||
// "@type": "/gno.RefValue", | ||
// "Escaped": true, | ||
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2" | ||
// }, | ||
// "Source": { | ||
// "@type": "/gno.RefNode", | ||
// "BlockNode": null, | ||
// "Location": { | ||
// "Column": "1", | ||
// "File": "main.gno", | ||
// "Line": "2", | ||
// "PkgPath": "gno.land/r/test" | ||
// } | ||
// }, | ||
// "Values": [] | ||
// } | ||
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:7] | ||
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:8] | ||
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:9] |
Oops, something went wrong.