Versions increases in dynamic fields

This question is originally from fastfrank in the Suinami Riders group:

Should the version number change on a base object each time I add either a DynamicField or DynamicObjectField?
I’m observing it is not changing:

  1. I have published a package which creates the initial base object 0x62e58282777c47ba949b947973a04ebd401b17ff (herein as A)
  2. I call an entry point that adds a DynamicField and changes a bool in A resulting in A`
  3. I make a second call to entry point that adds a DynamicObjectField and changes a different bool in A resulting in A``
    But A is always the same version if I walk through this object in explorer AND if I check the effects/event using RPC sui_getTransaction

Is this working as designed?

18 Likes

A mutable object’s version should increase every time it appears as a transaction input.

I suspect what you are observing here (at least in the explorer) is that the explorer does not maintain historical object versions, so if you look at the transaction that creates 0x62e58282777c47ba949b947973a04ebd401b17ff (Sui Explorer), see 0x62.. in “Created”, then click the link, it will jump to the latest copy of 0x62 rather than the historical copy.

However, if I query for the original transaction, I see a different version for 0x62:

curl --location --request POST 'https://fullnode.devnet.sui.io' \
--header 'Content-Type: application/json' \
--header 'Cookie: _cfuvid=1CO5QxX7JebZyeQyA7pxWfuFoyX62WygHNaefaCSh.w-1668403826989-0-604800000' \
--data-raw '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"sui_getTransaction",
    "params":["DQJtT2zNggi1LiYyoBo8RQShQGcnUmLbtXd5nu9kuWsw"]
}' | jq
<snip>
"created": [
        {
          "owner": {
            "AddressOwner": "0x3bcadcc8a78ec44b8765ed8a8517b82a9ee310ad"
          },
          "reference": {
            "objectId": "0x62e58282777c47ba949b947973a04ebd401b17ff",
            "version": 13,
            "digest": "0kj6l8JEAcR0occZ1OBoFqbCUEmfKArHuxeasrVoHE4="
          }
        },
<snip>

Similarly, if I look at the tx that adds the dynamic field (Sui Explorer), I see a version of 14 in the output:

curl --location --request POST 'https://fullnode.devnet.sui.io' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc":"2.0",
    "id":1,
    "method":"sui_getTransaction",
    "params":["3PudGqH9Lco8GDyr4PEumqf2QoEPBXrky6ur7im4JHFh"]
}' | jq
<snip>
"mutated": [
          "owner": {
            "AddressOwner": "0x3bcadcc8a78ec44b8765ed8a8517b82a9ee310ad"
          },
          "reference": {
            "objectId": "0x62e58282777c47ba949b947973a04ebd401b17ff",
            "version": 14,
            "digest": "YEHYg5v7GHWUo9AZRewUXQK9k/Z9jUtOCH+Za7uDGn0="
          }
        }
      ],
<snip>
12 Likes

Hi - Just to be certain we are on the same page. I am attempting to walk through the history of an object. First I do a sui_getObject on "0x62e58282777c47ba949b947973a04ebd401b17ff" which produces:

{
  "data": {
    "has_public_transfer": false,
    "fields": {
      "count_accounts": "0",
      "has_child_field": true,
      "has_child_object_field": true,
      "id": "0x62e58282777c47ba949b947973a04ebd401b17ff",
      "initialized": true
    },
    "dataType": "moveObject",
    "type": "0xe43b79b5b81bbb9dfd6203425e109b04cea2be65::base::ServiceTracker",
    "type_arg": ""
  },
  "owner": {
    "owner_type": "AddressOwner",
    "owner": "0x3bcadcc8a78ec44b8765ed8a8517b82a9ee310ad"
  },
  "reference": {
    "objectId": "0x62e58282777c47ba949b947973a04ebd401b17ff",
    "version": 15,
    "digest": "CbGd3IF2gcInkdzS/v0TEnWDyIBvmywylUq5mwcPaKc="
  },
  "storageRebate": 14,
  "previousTransaction": "2soi3dxM67mZLsxRFiAiweMynhKw49ugwKhVtE9oUYFm"
}

Taking the above preivousTransaction I use it as parameter to sui_getTransaction. In the result of this call I expect to see an earlier version somewhere. However; all references:

In effects->events:

{
        "mutateObject": {
          "packageId": "0xe43b79b5b81bbb9dfd6203425e109b04cea2be65",
          "transactionModule": "base",
          "sender": "0x3bcadcc8a78ec44b8765ed8a8517b82a9ee310ad",
          "objectType": "0xe43b79b5b81bbb9dfd6203425e109b04cea2be65::base::ServiceTracker",
          "objectId": "0x62e58282777c47ba949b947973a04ebd401b17ff",
          "version": 15
        }
      },

Note that it is still version 15 as is the current version. I would have thought this would be 14 which was before the transaction changes.

I also find it in the tx results of the effect->mutated info:

"mutated": [
      {
        "reference": {
          "objectId": "0x62e58282777c47ba949b947973a04ebd401b17ff",
          "version": 15,
          "digest": "CbGd3IF2gcInkdzS/v0TEnWDyIBvmywylUq5mwcPaKc="
        },
        "owner": "0x3bcadcc8a78ec44b8765ed8a8517b82a9ee310ad"
      }
    ]

Still at version 15.

Had there been a version difference, I would have used the earlier version to do a sui_tryGetPastObject and repeat the process to walk back in time for an object generation trace.

6 Likes

Thanks @fastfrank01! I think I see what’s going on. In short, I think the problem is that it’s not working because JSON RPC Docs | Sui Docs does not show you the initial versions of object inputs to a MoveCall tx (which you need to know for your history fetching), even though this information is available to the full node. We sent [json] Add modified_at_versions to SuiTransactionEffects by tnowacki · Pull Request #7237 · MystenLabs/sui · GitHub to fix this.

1 Like