write set spec for object::ObjectCore #102
-
ive been looking through aptos-indexer-processors and the explorer to understand how to work with a transaction's write set. it looks if a transaction writes to a resource in an object, that object's if a resource is only read, and never written to (ie only immutable references) is that resource included in the write set? if there's a spec or documentation on what is included in a write set that would also be super helpful |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Reads are never put into the write set. Any changes to resources are put into the write set based on their storage changes. In this instance, it's because the Objects are using Resource Groups. All of the resources in the resource group may show in the write set if another one is changed. Resource groups are stored as a BTreeMap<StructTag, resource> in one storage slot. So, when anything changes on that slot, the whole thing will be in the write set. See the AIP on resource groups for more details on the storage. https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-9.md#within-storage |
Beta Was this translation helpful? Give feedback.
-
heyo! ObjectCore should always be present in an object. If it's deleted, it would no longer by an object as we define objects. (it can still be a resource group which is just a group of structs in the same slot in memory, aka same Writeset only contains slots (not structs, full slots) that are mutated. If you have slot that you never mutate, then it'll stop appearing in writesets. This is actually a problem for indexing because there might be structs that you never see again. We solve this with normalizing schema (e.g. separating collection and token b/c collections are mutated much less than tokens). |
Beta Was this translation helpful? Give feedback.
Because it's the same StateKeyHash, it will include ObjectCore.
ObjectCore will always be included, as long as it has the ObjectGroup attribute.