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

fix(gnovm): object deletion; add comments #3741

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 28 additions & 10 deletions gnovm/pkg/gnolang/ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?
thehowl marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -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 {
Expand Down
80 changes: 0 additions & 80 deletions gnovm/tests/files/zrealm14.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 0 additions & 49 deletions gnovm/tests/files/zrealm15.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
// {
Expand Down
Loading