rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
134 stars 60 forks source link

[indexer] Bug: Indexer object state not consistent with state. #1759

Closed pause125 closed 4 weeks ago

pause125 commented 4 weeks ago

How to reproduce:

  1. clean and start a new server.
  2. query an object through rooch object command and rpc rooch_queryObjectStates, the results are not consistent. Here use 0x2::object::ObjectEntity<0x2::module_store::ModuleStore>, which has object id "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb":
$ rooch object --id "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb"
{
  "value": "0x012214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb000000000000000000000000000000000000000000000000000000000000000201942e783307ae8939edf37ebd0a808d68e07138bbb3972b561209bd6a6c3c1ce7050000000000000000",
  "value_type": "0x2::object::ObjectEntity<0x2::module_store::ModuleStore>",
  "decoded_value": {
    "abilities": 0,
    "type": "0x2::object::ObjectEntity<0x2::module_store::ModuleStore>",
    "value": {
      "flag": 1,
      "id": "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb",
      "owner": "0x0000000000000000000000000000000000000000000000000000000000000002",
      "size": "5",
      "state_root": "0x942e783307ae8939edf37ebd0a808d68e07138bbb3972b561209bd6a6c3c1ce7",
      "value": {
        "abilities": 8,
        "type": "0x2::module_store::ModuleStore",
        "value": {
          "dummy_field": false
        }
      }
    }
  },
  "display_fields": null
}

$ rooch rpc request --method rooch_queryObjectStates --params '[{"object_id":["0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb"]}, null, "1", {"descending": true,"showDisplay":false}]'
Error: RPC call failed: ErrorObject { code: ServerError(-32000), message: "Failed to query indexer global states: SQLiteReadError(\"Record not found\")", data: None }

You will receive an error when use rpc rooch_queryObjectStates.

  1. After publish a new package, you can get data through rpc querying, but the outputs are not consistent. For example, publishing an example package: $ rooch move publish -p examples/display/ --named-addresses display=default.

Then the query output:

$ rooch object --id "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb"                        {
  "value": "0x012214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb000000000000000000000000000000000000000000000000000000000000000201024b72f98f579612dda19adfdc98e7b17e0568a84f172ff42adc9f37c6fb9ee5060000000000000000",
  "value_type": "0x2::object::ObjectEntity<0x2::module_store::ModuleStore>",
  "decoded_value": {
    "abilities": 0,
    "type": "0x2::object::ObjectEntity<0x2::module_store::ModuleStore>",
    "value": {
      "flag": 1,
      "id": "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb",
      "owner": "0x0000000000000000000000000000000000000000000000000000000000000002",
      "size": "6",
      "state_root": "0x024b72f98f579612dda19adfdc98e7b17e0568a84f172ff42adc9f37c6fb9ee5",
      "value": {
        "abilities": 8,
        "type": "0x2::module_store::ModuleStore",
        "value": {
          "dummy_field": false
        }
      }
    }
  },
  "display_fields": null
}

$ rooch rpc request --method rooch_queryObjectStates --params '[{"object_id":["0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb"]}, null, "1", {"descending": true,"showDisplay":false}]'
{
  "data": [
    {
      "object_id": "0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb",
      "owner": "rooch1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqcm08j4",
      "flag": 1,
      "value": {
        "abilities": 8,
        "type": "0x2::module_store::ModuleStore",
        "value": {
          "dummy_field": false
        }
      },
      "object_type": "0x2::module_store::ModuleStore",
      "state_root": "0x942e783307ae8939edf37ebd0a808d68e07138bbb3972b561209bd6a6c3c1ce7",
      "size": 6,
      "tx_order": 1,
      "state_index": 1,
      "created_at": 0,
      "updated_at": 0,
      "display_fields": null
    }
  ],
  "next_cursor": {
    "tx_order": 1,
    "state_index": 1
  },
  "has_next_page": false
}

You can see the state root is not the same.