AntelopeIO / abieos

Other
2 stars 12 forks source link

empty floating point value #22

Closed cc32d9 closed 11 months ago

cc32d9 commented 11 months ago

I'm troubleshooting a strange problem with Chronicle and a recent WAX snapshot. While processing table deltas from the initial block in the state history, abieos_bin_to_json generated invalid JSON on one particular table row:

Contract: eosio
Table: voters
Scope: eosio
primary_key: "4855417838370997808"

Value:
{"owner":"chkyln44af33","proxy":"hodlwaxiopro","producers":[],"staked":"107200000","unpaid_voteshare":0,"unpaid_voteshare_last_updated":"2023-11-27T03:55:55.000","unpaid_voteshare_change_rate":5.84764897204348e+36,"last_claim_time":"2023-11-27T03:55:55.000","last_vote_weight":5.847648972043329e+36,"proxied_vote_weight":,"is_proxy":false,"flags1":0,"reserved2":0,"reserved3":"0 "}

The float64 in proxied_vote_weight is represented by an empty string, which breaks the resulting JSON syntax.

The table row in question (nodeos version 3.2.3wax01):

cleos -u https://wax.eu.eosamsterdam.net get table eosio eosio voters -L 4855417838370997808 -l 1
{
  "rows": [{
      "owner": "chkyln44af33",
      "proxy": "hodlwaxiopro",
      "producers": [],
      "staked": 107200000,
      "unpaid_voteshare": "0.00000000000000000",
      "unpaid_voteshare_last_updated": "2023-11-27T03:55:55.000",
      "unpaid_voteshare_change_rate": "5847648972043480480643942873884000256.00000000000000000",
      "last_claim_time": "2023-11-27T03:55:55.000",
      "last_vote_weight": "5847648972043329364916491045237161984.00000000000000000",
      "proxied_vote_weight": "-151115727451828646838272.00000000000000000",
      "is_proxy": 0,
      "flags1": 0,
      "reserved2": 0,
      "reserved3": "0 "
    }
  ],
  "more": true,
  "next_key": "4855443352568570880"
}

I looked through the sources of include/eosio/to_json.hpp and include/eosio/fpconv.c, but couldn't find a condition which would result in empty string.

cc32d9 commented 11 months ago

Other values in the same table and field, successfully decoded, below. The number of values is much higher, but this excerpt shows the spectrum of values:

         "proxied_vote_weight" : 3.91804664714639e+42,
         "proxied_vote_weight" : 1.47254765867485e+41,
         "proxied_vote_weight" : "4722366482869645000000",
         "proxied_vote_weight" : 1.85361506461681e+36,
         "proxied_vote_weight" : 1.57166523702453e+36,
         "proxied_vote_weight" : 1.20804244520759e+43,
         "proxied_vote_weight" : 2.54436330334442e+44,
         "proxied_vote_weight" : 1.77855923462261e+37,
         "proxied_vote_weight" : 2.79967445471938e+38,
         "proxied_vote_weight" : 1.34988919770943e+36,
         "proxied_vote_weight" : 2.7488641457696e+36,
         "proxied_vote_weight" : 1.70340841191172e+37,
         "proxied_vote_weight" : 2.05258433298736e+39,
         "proxied_vote_weight" : 5.35286690482005e+36,
         "proxied_vote_weight" : 1.93422933648053e+38,
         "proxied_vote_weight" : "-590295810358705700000",
         "proxied_vote_weight" : 3.82033021261414e+37,
         "proxied_vote_weight" : 1.1797190240921e+41,
         "proxied_vote_weight" : 5.41463785086491e+35,
cc32d9 commented 11 months ago

Binary value and the ABI definition:

cleos -u https://wax.eu.eosamsterdam.net get table eosio eosio voters -L 4855417838370997808 -l 1 -b
{
  "rows": [
    "30c63284cce86143406fa5ae1b1e136d0000be6306000000000000000000000000c02863471a0b06000908566add989147c02863471a0b06008907566add989147000000000000c0c400000000000000000000000000000000000000000000000000"
  ],
  "more": true,
  "next_key": "4855443352568570880"
}
{
      "name": "voter_info",
      "base": "",
      "fields": [{
          "name": "owner",
          "type": "name"
        },{
          "name": "proxy",
          "type": "name"
        },{
          "name": "producers",
          "type": "name[]"
        },{
          "name": "staked",
          "type": "int64"
        },{
          "name": "unpaid_voteshare",
          "type": "float64"
        },{
          "name": "unpaid_voteshare_last_updated",
          "type": "time_point"
        },{
          "name": "unpaid_voteshare_change_rate",
          "type": "float64"
        },{
          "name": "last_claim_time",
          "type": "time_point"
        },{
          "name": "last_vote_weight",
          "type": "float64"
        },{
          "name": "proxied_vote_weight",
          "type": "float64"
        },{
          "name": "is_proxy",
          "type": "bool"
        },{
          "name": "flags1",
          "type": "uint32"
        },{
          "name": "reserved2",
          "type": "uint32"
        },{
          "name": "reserved3",
          "type": "asset"
        }
      ]
    }
cc32d9 commented 11 months ago

I took now a slightly earlier snapshot ( https://snapshots-cdn.eossweden.org/wax/3.x/snapshot-278884675.bin.tar.gz ) and the result is even more interesting. There is some value in proxied_vote_weight, but it's followed by garbage:

state history row ( contract_row_v0::value ):

30c63284cce86143406fa5ae1b1e136d0000be6306000000000000000000000000600096d8ed0a06000908566add989147600096d8ed0a06008907566add989147000000000000c0c400000000000000000000000000000000000000000000000000

result of abieos_bin_to_json() printed by wlog, and the logger broke the ending braces:

{"owner":"chkyln44af33","proxy":"hodlwaxiopro","producers":[],"staked":"107200000","unpaid_voteshare":0,"unpaid_voteshare_last_updated":"2023-11-24T22:55:17.500","unpaid_voteshare_change_rate":5.84764897204348e+36,"last_claim_time":"2023-11-24T22:55:17.500","last_vote_weight":5.847648972043329e+36,"proxied_vote_weight":-15111572745182865000000I5\u007f

The JSON reader that took this from Chronicle reports it as follows:

{"block_num":"278884676","block_timestamp":"2023-11-25T12:03:18.000","added":"true","kvo":{"code":"eosio","scope":"eosio","table":"voters","primary_key":"4855417838370997808","payer":"chkyln44af33","value":{"owner":"chkyln44af33","proxy":"hodlwaxiopro","producers":[],"staked":"107200000","unpaid_voteshare":0,"unpaid_voteshare_last_updated":"2023-11-24T22:55:17.500","unpaid_voteshare_change_rate":5.84764897204348e+36,"last_claim_time":"2023-11-24T22:55:17.500","last_vote_weight":5.847648972043329e+36,"proxied_vote_weight":-15111572745182865000000I�5��}}