diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 511b44bfc73..da254d383a9 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -133,17 +133,29 @@ var ( ) type ObjectInfo struct { - ID ObjectID // set if real. - Hash ValueHash `json:",omitempty"` // zero if dirty. - OwnerID ObjectID `json:",omitempty"` // parent in the ownership tree. - ModTime uint64 // time last updated. - RefCount int // for persistence. deleted/gc'd if 0. - IsEscaped bool `json:",omitempty"` // hash in iavl. + ID ObjectID // set if real. + Hash ValueHash `json:",omitempty"` // zero if dirty. + OwnerID ObjectID `json:",omitempty"` // parent in the ownership tree. + ModTime uint64 // time last updated. + RefCount int // for persistence. deleted/gc'd if 0. + + // Object has multiple references (refcount > 1) and is persisted separately + IsEscaped bool `json:",omitempty"` // hash in iavl. + // MemRefCount int // consider for optimizations. - isDirty bool - isDeleted bool - isNewReal bool + // Object has been modified and needs to be saved + isDirty bool + + // Object has been permanently deleted + isDeleted bool + + // Object is newly created in current transaction and will be persisted + isNewReal bool + + // Object newly created multiple references in current transaction isNewEscaped bool + + // Object is marked for deletion in current transaction isNewDeleted bool // XXX huh? @@ -294,7 +306,13 @@ func (oi *ObjectInfo) SetIsDeleted(x bool, mt uint64) { // NOTE: Don't over-write modtime. // Consider adding a DelTime, or just log it somewhere, or // continue to ignore it. - oi.isDirty = x + + // The above comment is likely made because it could introduce complexity + // Objects can be "undeleted" if referenced during a transaction + // If an object is deleted and then undeleted in the same transaction + // If an object is deleted multiple times + // ie...continue to ignore it + oi.isDeleted = x } func (oi *ObjectInfo) GetIsNewReal() bool { diff --git a/gnovm/tests/files/zrealm14.gno b/gnovm/tests/files/zrealm14.gno index ffffa4883fd..84ef45982cb 100644 --- a/gnovm/tests/files/zrealm14.gno +++ b/gnovm/tests/files/zrealm14.gno @@ -65,86 +65,6 @@ func main() { // "RefCount": "1" // } // } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/test.A" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "c" -// } -// } -// ], -// "ObjectInfo": { -// "Hash": "c22ccb7832b422c83fec9943b751cb134fcbed0b", -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "RefCount": "0" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/test.A" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "d" -// } -// } -// ], -// "ObjectInfo": { -// "Hash": "86c916fd78da57d354cb38019923bf64c1a3471c", -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "RefCount": "0" -// } -// } // u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={ // "ObjectInfo": { // "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3", diff --git a/gnovm/tests/files/zrealm15.gno b/gnovm/tests/files/zrealm15.gno index 4ca6ef3b03d..b8ba84bad04 100644 --- a/gnovm/tests/files/zrealm15.gno +++ b/gnovm/tests/files/zrealm15.gno @@ -69,55 +69,6 @@ func main() { // "RefCount": "1" // } // } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/test.A" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/test.S" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "Hash": "5bf603ab337f9f40f8b22441562319d67be402b2", -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9", -// "RefCount": "0" -// } -// } // u[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]={ // "Fields": [ // {