cryptonomex / graphene

MIT License
1.05k stars 336 forks source link

Issues with account create/update - possibly due to change in "extensions" #593

Closed roadscape closed 8 years ago

roadscape commented 8 years ago

Users are reporting issues with creating accounts and updating votes, and it may be because "the extensions field on account create/update operations is now a struct not an array"

Source: https://bitsharestalk.org/index.php/topic,21530.msg280473.html#msg280473

When trying to register a premium name an unknown error message is shown and the console shows the following error:

!!! GrapheneApi error: get_required_fees [Array[1], "1.3.0"]0: Array[1]0: Array[2]0: 51: Objectactive: Objectextensions: Array[0]fee: Objectname: "nameredacted"options: Objectowner: Objectreferrer: "1.2.00000"referrer_percent: 0registrar: "1.2.00000"proto: Objectlength: 2proto: Array[0]length: 1proto: Array[0]1: "1.3.0"length: 2proto: Array[0] Object {code: 1, message: "7 bad_cast_exception: Bad Cast↵Invalid cast from t…array_type"}↵ th_a variant.cpp:575 get_object", data: Object}code: 1data: Objectmessage: "7 bad_cast_exception: Bad Cast↵Invalid cast from type 'array_type' to Object↵ {"type":"array_type"}↵ th_a variant.cpp:575 get_object"proto: Object {"code":1,"message":"7 bad_cast_exception: Bad Cast\nInvalid cast from type 'array_type' to Object\n {\"type\":\"array_type\"}\n th_a variant.cpp:575 get_object","data":{"code":7,"name":"bad_cast_exception","message":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":575,"method":"get_object","hostname":"","thread_name":"th_a","timestamp":"2016-02-19T01:28:37"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"array_type"}}]}} app.js:102 ERROR AccountActions.createAccount Object {code: 1, message: "7 bad_cast_exception: Bad Cast↵Invalid cast from t…array_type"}↵ th_a variant.cpp:575 get_object", data: Object}code: 1data: Objectcode: 7message: "Bad Cast"name: "bad_cast_exception"stack: Array[1]0: Objectcontext: Objectdata: Objecttype: "array_type"proto: Objectformat: "Invalid cast from type '${type}' to Object"proto: Objectlength: 1proto: Array[0]proto: Objectmessage: "7 bad_cast_exception: Bad Cast↵Invalid cast from type 'array_type' to Object↵ {"type":"array_type"}↵ th_a variant.cpp:575 get_object"proto: ObjectdefineGetter: defineGetter()defineSetter: defineSetter()lookupGetter: lookupGetter()lookupSetter: lookupSetter()constructor: Object()hasOwnProperty: hasOwnProperty()isPrototypeOf: isPrototypeOf()propertyIsEnumerable: propertyIsEnumerable()toLocaleString: toLocaleString()toString: toString()valueOf: valueOf()get proto: get proto()set proto: set proto()

User pc replies:

The reason for this is an undocumented API change in the latest release. The "extensions" field on account create/update operations is now a struct not an array. Which is precisely the reason why I think one week is far from sufficient time to introduce a hard fork!

https://github.com/bitshares/bitshares-2/commit/a1e8fc07417407525482924df6b125d95c38a06f#diff-1a2d7c55b5a8f1e2bbb1c868896c94eeL117

Another one of the manifestations of this issue is that you cannot change your votes from the GUI wallet. @svk31 wonders if the appropriate changes were made in cli_wallet.

abitmore commented 8 years ago

Reproduce:

unlocked >>> set_voting_proxy abit-2fa in.abit true
set_voting_proxy abit-2fa in.abit true
1600759ms th_a       wallet.cpp:1896               sign_transaction     ] Caught exception while broadcasting tx 15915a9cc04ec88afbbda
c5c9c3f987744221cda:  0 exception: unspecified
7 bad_cast_exception: Bad Cast
Invalid cast from type 'array_type' to Object
    {"type":"array_type"}
    th_a  variant.cpp:575 get_object
    {"error":"7 bad_cast_exception: Bad Cast\nInvalid cast from type 'array_type' to Object\n    {\"type\":\"array_type\"}\n    th_a
variant.cpp:575 get_object","data":{"id":23,"error":{"code":1,"message":"7 bad_cast_exception: Bad Cast\nInvalid cast from type 'array
_type' to Object\n    {\"type\":\"array_type\"}\n    th_a  variant.cpp:575 get_object","data":{"code":7,"name":"bad_cast_exception","m
essage":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":575,"method":"get_object","hostname":"","thread_na
me":"th_a","timestamp":"2016-02-20T15:26:40"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"array_type"}}]}}}}
    th_a  state.cpp:38 handle_reply

Related issue (old cli_wallet with new witness_node as well. There is a new account registered in this block):

locked >>> get_block 3710432
get_block 3710432
7 bad_cast_exception: Bad Cast
Invalid cast from object_type to Array
    {"type":"object_type"}
    th_a  variant.cpp:530 get_array
abitmore commented 8 years ago

The "Related issue" in above comment is unable to fix / won't fix, since the best is to modify the cli_wallet code, but latest cli_wallet works fine so no need to modify.

The issue in OP can probably be fixed by adding an additional judgement "|| get_type() == array_type" here, so arrays have chance to be tried to be converted to object. I will try.

Anyway, please be aware that it's dangerous to enable this new format of transaction before hard fork date, because it may probably cause network forking. please be aware that it's not dangerous to enable this new format before hard fork date if keep the extensions field empty .

abitmore commented 8 years ago

Another option would be change the extensions field back to an array, so it will have better backwards compatibility. For example change the definition in this line from extension< ext > extensions to vector<extension< ext >> extensions and change related code accordingly.

abitmore commented 8 years ago

Update: it's not dangerous to enable this new format before hard fork date if keep the extensions field empty , according to @pmconrad's comment in this thread. So GUi can be updated safely.

theoreticalbts commented 8 years ago

We're aware of this issue and working on a fix

theoreticalbts commented 8 years ago

Fixed in latest release.