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

get_table_by_scope parameter lower_bound is NOT properly converted, cause enumeration dead loop #5824

Closed
UMU618 opened this issue Sep 26, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@UMU618
Copy link
Contributor

commented Sep 26, 2018

plugins/chain_plugin/chain_plugin.cpp


LINE 1116

https://github.com/EOSIO/eos/pull/5486/files/0624889abf3b767ed05641b9ed8033a35e2197d2



If I pass '313313313313' to lower_bound, then it's 313313313313 (0x48F2EDC221), SHOULD be 1749138884762583600 (0x1846308C6118C230)
1111111.bank is 595056260428703488 (0x084210842039A700)

313313313313 < N(1111111.bank) < N(313313313313)

You can reproduce BUG by:

cleos -u https://mainnet.meet.one --print-request get scope eosio.token -t accounts -l 1 -L 313313313313
REQUEST:
POST /v1/chain/get_table_by_scope HTTP/1.0
Host: mainnet.meet.one
content-length: 118
Accept: /
Connection: close

{
"code": "eosio.token",
"table": "accounts",
"lower_bound": "313313313313",
"upper_bound": "",
"limit": 1
}
{
"rows": [{
"code": "eosio.token",
"scope": "1111111.bank",
"table": "accounts",
"payer": "1111111.bank",
"count": 1
}
],
"more": "111111111111"
}

Correct one:

cleos -u https://mainnet.meet.one --print-request get scope eosio.token -t accounts -l 1 -L 1749138884762583600

REQUEST:
---------------------
POST /v1/chain/get_table_by_scope HTTP/1.0
Host: mainnet.meet.one
content-length: 125
Accept: */*
Connection: close

{
  "code": "eosio.token",
  "table": "accounts",
  "lower_bound": "1749138884762583600",
  "upper_bound": "",
  "limit": 1
}
---------------------
{
  "rows": [{
      "code": "eosio.token",
      "scope": "31415mengzha",
      "table": "accounts",
      "payer": "vuniyuoxoeub",
      "count": 1
    }
  ],
  "more": "315555555555"
}
@jgiszczak

This comment has been minimized.

Copy link
Contributor

commented Sep 26, 2018

This is a known limitation of the conversion of account names to their actual numeric values. Because Javascript does not support 64 bit integers, the JSON library in EOS.IO has some compatibility hacks that can generate unexpected results. To get what you expect, pass the lower limit as an explicit string:
cleos -u https://mainnet.meet.one --print-request get scope eosio.token -t accounts -l 1 -L " 313313313313"
This gives your expected results:

REQUEST:
---------------------
POST /v1/chain/get_table_by_scope HTTP/1.0
Host: mainnet.meet.one
content-length: 119
Accept: */*
Connection: close

{
  "code": "eosio.token",
  "table": "accounts",
  "lower_bound": " 313313313313",
  "upper_bound": "",
  "limit": 1
}
---------------------
{
  "rows": [{
      "code": "eosio.token",
      "scope": "31415mengzha",
      "table": "accounts",
      "payer": "vuniyuoxoeub",
      "count": 1
    }
  ],
  "more": "315555555555"
}

@jgiszczak jgiszczak closed this Sep 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.