Skip to content

Commit 39994f7

Browse files
fix: object deletion; add comments
1 parent d0201fb commit 39994f7

File tree

3 files changed

+28
-139
lines changed

3 files changed

+28
-139
lines changed

gnovm/pkg/gnolang/ownership.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,29 @@ var (
133133
)
134134

135135
type ObjectInfo struct {
136-
ID ObjectID // set if real.
137-
Hash ValueHash `json:",omitempty"` // zero if dirty.
138-
OwnerID ObjectID `json:",omitempty"` // parent in the ownership tree.
139-
ModTime uint64 // time last updated.
140-
RefCount int // for persistence. deleted/gc'd if 0.
141-
IsEscaped bool `json:",omitempty"` // hash in iavl.
136+
ID ObjectID // set if real.
137+
Hash ValueHash `json:",omitempty"` // zero if dirty.
138+
OwnerID ObjectID `json:",omitempty"` // parent in the ownership tree.
139+
ModTime uint64 // time last updated.
140+
RefCount int // for persistence. deleted/gc'd if 0.
141+
142+
// Object has multiple references (refcount > 1) and is persisted separately
143+
IsEscaped bool `json:",omitempty"` // hash in iavl.
144+
142145
// MemRefCount int // consider for optimizations.
143-
isDirty bool
144-
isDeleted bool
145-
isNewReal bool
146+
// Object has been modified and needs to be saved
147+
isDirty bool
148+
149+
// Object has been permanently deleted
150+
isDeleted bool
151+
152+
// Object is newly created in current transaction and will be persisted
153+
isNewReal bool
154+
155+
// Object newly created multiple references in current transaction
146156
isNewEscaped bool
157+
158+
// Object is marked for deletion in current transaction
147159
isNewDeleted bool
148160

149161
// XXX huh?
@@ -294,7 +306,13 @@ func (oi *ObjectInfo) SetIsDeleted(x bool, mt uint64) {
294306
// NOTE: Don't over-write modtime.
295307
// Consider adding a DelTime, or just log it somewhere, or
296308
// continue to ignore it.
297-
oi.isDirty = x
309+
310+
// The above comment is likely made because it could introduce complexity
311+
// Objects can be "undeleted" if referenced during a transaction
312+
// If an object is deleted and then undeleted in the same transaction
313+
// If an object is deleted multiple times
314+
// ie...continue to ignore it
315+
oi.isDeleted = x
298316
}
299317

300318
func (oi *ObjectInfo) GetIsNewReal() bool {

gnovm/tests/files/zrealm14.gno

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -65,86 +65,6 @@ func main() {
6565
// "RefCount": "1"
6666
// }
6767
// }
68-
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={
69-
// "Fields": [
70-
// {
71-
// "T": {
72-
// "@type": "/gno.PointerType",
73-
// "Elt": {
74-
// "@type": "/gno.RefType",
75-
// "ID": "gno.land/r/test.A"
76-
// }
77-
// },
78-
// "V": {
79-
// "@type": "/gno.PointerValue",
80-
// "Base": {
81-
// "@type": "/gno.RefValue",
82-
// "Escaped": true,
83-
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
84-
// },
85-
// "Index": "0",
86-
// "TV": null
87-
// }
88-
// },
89-
// {
90-
// "T": {
91-
// "@type": "/gno.PrimitiveType",
92-
// "value": "16"
93-
// },
94-
// "V": {
95-
// "@type": "/gno.StringValue",
96-
// "value": "c"
97-
// }
98-
// }
99-
// ],
100-
// "ObjectInfo": {
101-
// "Hash": "c22ccb7832b422c83fec9943b751cb134fcbed0b",
102-
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8",
103-
// "ModTime": "0",
104-
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7",
105-
// "RefCount": "0"
106-
// }
107-
// }
108-
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={
109-
// "Fields": [
110-
// {
111-
// "T": {
112-
// "@type": "/gno.PointerType",
113-
// "Elt": {
114-
// "@type": "/gno.RefType",
115-
// "ID": "gno.land/r/test.A"
116-
// }
117-
// },
118-
// "V": {
119-
// "@type": "/gno.PointerValue",
120-
// "Base": {
121-
// "@type": "/gno.RefValue",
122-
// "Escaped": true,
123-
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
124-
// },
125-
// "Index": "0",
126-
// "TV": null
127-
// }
128-
// },
129-
// {
130-
// "T": {
131-
// "@type": "/gno.PrimitiveType",
132-
// "value": "16"
133-
// },
134-
// "V": {
135-
// "@type": "/gno.StringValue",
136-
// "value": "d"
137-
// }
138-
// }
139-
// ],
140-
// "ObjectInfo": {
141-
// "Hash": "86c916fd78da57d354cb38019923bf64c1a3471c",
142-
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
143-
// "ModTime": "0",
144-
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7",
145-
// "RefCount": "0"
146-
// }
147-
// }
14868
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={
14969
// "ObjectInfo": {
15070
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3",

gnovm/tests/files/zrealm15.gno

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -69,55 +69,6 @@ func main() {
6969
// "RefCount": "1"
7070
// }
7171
// }
72-
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]={
73-
// "Fields": [
74-
// {
75-
// "T": {
76-
// "@type": "/gno.PointerType",
77-
// "Elt": {
78-
// "@type": "/gno.RefType",
79-
// "ID": "gno.land/r/test.A"
80-
// }
81-
// },
82-
// "V": {
83-
// "@type": "/gno.PointerValue",
84-
// "Base": {
85-
// "@type": "/gno.RefValue",
86-
// "Escaped": true,
87-
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
88-
// },
89-
// "Index": "0",
90-
// "TV": null
91-
// }
92-
// },
93-
// {
94-
// "T": {
95-
// "@type": "/gno.PointerType",
96-
// "Elt": {
97-
// "@type": "/gno.RefType",
98-
// "ID": "gno.land/r/test.S"
99-
// }
100-
// },
101-
// "V": {
102-
// "@type": "/gno.PointerValue",
103-
// "Base": {
104-
// "@type": "/gno.RefValue",
105-
// "Escaped": true,
106-
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7"
107-
// },
108-
// "Index": "0",
109-
// "TV": null
110-
// }
111-
// }
112-
// ],
113-
// "ObjectInfo": {
114-
// "Hash": "5bf603ab337f9f40f8b22441562319d67be402b2",
115-
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10",
116-
// "ModTime": "0",
117-
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
118-
// "RefCount": "0"
119-
// }
120-
// }
12172
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]={
12273
// "Fields": [
12374
// {

0 commit comments

Comments
 (0)