From f019af70983840b21908f30c041b98132057123c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 09:17:15 -0500 Subject: [PATCH 1/7] Add check for unknown type --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index dbff40a9a57..c58b3afe67a 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -230,7 +230,9 @@ namespace impl { auto abi = resolver(act.account); if (abi.valid()) { auto type = abi->get_action_type(act.name); - mvo("data", abi->binary_to_variant(type, act.data)); + if (!type.empty()) { + mvo( "data", abi->binary_to_variant( type, act.data )); + } mvo("hex_data", act.data); } else { mvo("data", act.data); @@ -391,7 +393,9 @@ namespace impl { auto abi = resolver(act.account); if (abi.valid()) { auto type = abi->get_action_type(act.name); - act.data = std::move(abi->variant_to_binary(type, data)); + if (!type.empty()) { + act.data = std::move( abi->variant_to_binary( type, data )); + } } } } From 709b5d212db3cfa68f28c65f8d1f02ffd3d99811 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 09:17:55 -0500 Subject: [PATCH 2/7] Remove issue 2099 special check --- tests/nodeos_run_test.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/nodeos_run_test.py b/tests/nodeos_run_test.py index 9472f16a91d..0e1cc64b8c8 100755 --- a/tests/nodeos_run_test.py +++ b/tests/nodeos_run_test.py @@ -637,13 +637,10 @@ def cmdError(name, cmdCode=0, exitNow=False): Print("CurrentBlockNum: %d" % (currentBlockNum)) Print("Request blocks 1-%d" % (currentBlockNum)) for blockNum in range(1, currentBlockNum+1): - block=node.getBlock(str(blockNum), retry=False, silentErrors=True) + block=node.getBlock(str(blockNum), retry=False, silentErrors=False) if block is None: - # TBD: Known issue (Issue 2099) that the block containing setprods isn't retrievable. - # Enable errorExit() once that is resolved. - Print("WARNING: Failed to get block %d (probably issue 2099). Report and keep going..." % (blockNum)) - # cmdError("%s get block" % (ClientName)) - # errorExit("get block by num %d" % blockNum) + cmdError("%s get block" % (ClientName)) + errorExit("get block by num %d" % blockNum) if enableMongo: blockId=block["block_id"] From 0bcab69d1d81fd2ab757edc9c51394cec78335df Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 09:17:15 -0500 Subject: [PATCH 3/7] Add check for unknown type --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index dbff40a9a57..c58b3afe67a 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -230,7 +230,9 @@ namespace impl { auto abi = resolver(act.account); if (abi.valid()) { auto type = abi->get_action_type(act.name); - mvo("data", abi->binary_to_variant(type, act.data)); + if (!type.empty()) { + mvo( "data", abi->binary_to_variant( type, act.data )); + } mvo("hex_data", act.data); } else { mvo("data", act.data); @@ -391,7 +393,9 @@ namespace impl { auto abi = resolver(act.account); if (abi.valid()) { auto type = abi->get_action_type(act.name); - act.data = std::move(abi->variant_to_binary(type, data)); + if (!type.empty()) { + act.data = std::move( abi->variant_to_binary( type, data )); + } } } } From fa05bce0172720f434ec33619ee3503ee90d24d3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 09:17:55 -0500 Subject: [PATCH 4/7] Remove issue 2099 special check --- tests/nodeos_run_test.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/nodeos_run_test.py b/tests/nodeos_run_test.py index cc7f1b75635..8ee57d3585c 100755 --- a/tests/nodeos_run_test.py +++ b/tests/nodeos_run_test.py @@ -638,13 +638,10 @@ def cmdError(name, cmdCode=0, exitNow=False): Print("CurrentBlockNum: %d" % (currentBlockNum)) Print("Request blocks 1-%d" % (currentBlockNum)) for blockNum in range(1, currentBlockNum+1): - block=node.getBlock(str(blockNum), retry=False, silentErrors=True) + block=node.getBlock(str(blockNum), retry=False, silentErrors=False) if block is None: - # TBD: Known issue (Issue 2099) that the block containing setprods isn't retrievable. - # Enable errorExit() once that is resolved. - Print("WARNING: Failed to get block %d (probably issue 2099). Report and keep going..." % (blockNum)) - # cmdError("%s get block" % (ClientName)) - # errorExit("get block by num %d" % blockNum) + cmdError("%s get block" % (ClientName)) + errorExit("get block by num %d" % blockNum) if enableMongo: blockId=block["block_id"] From 15360f8320956349cb56e9aa610ebae4bd01281d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 14:15:21 -0500 Subject: [PATCH 5/7] Add bios actions/structs so get blocks with these structs provides pretty print output --- contracts/eosio.system/eosio.system.abi | 53 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/contracts/eosio.system/eosio.system.abi b/contracts/eosio.system/eosio.system.abi index f0308be1373..0e11106d27b 100644 --- a/contracts/eosio.system/eosio.system.abi +++ b/contracts/eosio.system/eosio.system.abi @@ -16,6 +16,7 @@ "new_type_name": "weight_type", "type": "uint16" }], + "____comment": "eosio.bios structs: set_account_limits, setpriv, set_global_limits, producer_key, set_producers, require_auth are provided so abi available for deserialization in future.", "structs": [{ "name": "permission_level", "base": "", @@ -333,6 +334,40 @@ {"name":"account", "type":"account_name"}, {"name":"is_priv", "type":"int8"} ] + },{ + "name": "set_account_limits", + "base": "", + "fields": [ + {"name":"account", "type":"account_name"}, + {"name":"ram_bytes", "type":"int64"}, + {"name":"net_weight", "type":"int64"}, + {"name":"cpu_weight", "type":"int64"} + ] + },{ + "name": "set_global_limits", + "base": "", + "fields": [ + {"name":"cpu_usec_per_period", "type":"int64"} + ] + },{ + "name": "producer_key", + "base": "", + "fields": [ + {"name":"producer_name", "type":"account_name"}, + {"name":"block_signing_key", "type":"public_key"} + ] + },{ + "name": "set_producers", + "base": "", + "fields": [ + {"name":"schedule", "type":"producer_key[]"} + ] + },{ + "name": "require_auth", + "base": "", + "fields": [ + {"name":"from", "type":"account_name"} + ] } ], "actions": [{ @@ -423,7 +458,23 @@ "name": "setpriv", "type": "setpriv", "ricardian_contract": "" - }], + },{ + "name": "setalimits", + "type": "set_account_limits", + "ricardian_contract": "" + },{ + "name": "setglimits", + "type": "set_global_limits", + "ricardian_contract": "" + },{ + "name": "setprods", + "type": "set_producers", + "ricardian_contract": "" + },{ + "name": "reqauth", + "type": "require_auth", + "ricardian_contract": "" + }], "tables": [{ "name": "producers", "type": "producer_info", From 66331e84414d40ff453c55fcd625946e0557354a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 16:00:01 -0500 Subject: [PATCH 6/7] Put hex data in 'data' when no abi --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index c58b3afe67a..f4b79b40852 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -231,9 +231,11 @@ namespace impl { if (abi.valid()) { auto type = abi->get_action_type(act.name); if (!type.empty()) { - mvo( "data", abi->binary_to_variant( type, act.data )); + mvo("data", abi->binary_to_variant(type, act.data)); + mvo("hex_data", act.data); + } else { + mvo("data", act.data); } - mvo("hex_data", act.data); } else { mvo("data", act.data); } @@ -397,6 +399,9 @@ namespace impl { act.data = std::move( abi->variant_to_binary( type, data )); } } + if (act.data.empty()) { + from_variant(data, act.data); + } } } From dbe7e45ac088c1b6307069864f8baabd0a2a3191 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 18 May 2018 16:10:21 -0500 Subject: [PATCH 7/7] Remove invalid attempt to extract data --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 6311dbbe039..eca88c5e05e 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -402,9 +402,6 @@ namespace impl { act.data = std::move( abi->variant_to_binary( type, data )); } } - if (act.data.empty()) { - from_variant(data, act.data); - } } }