eos icon indicating copy to clipboard operation
eos copied to clipboard

cleos get table not working with latest master

Open brightermatter opened this issue 8 years ago • 9 comments

running: cleos get table myaccount myaccount mycustomer returns: 1592776ms thread-0 main.cpp:2366 main ] Failed with error: Out of Range (8) read datastream of length 379 over by -23

environment:

  • Latest master branch
  • Ubuntu VM

issues to repro:

  1. create myaccount
  2. create a contract that emplaces a mycustomer struct into db successfully
  3. call cleos get table myaccount myaccount mycustomer

brightermatter avatar May 17 '18 15:05 brightermatter

Your ABI may be wrong?

bytemaster avatar May 17 '18 15:05 bytemaster

These are all executed fine respectively and the data is inserted in block.. Could ABI be wrong?

  • eosiocpp -o mykyc.wast mykyc.cpp
  • eosiocpp -g mykyc.abi mykyc.cpp
  • cleos push action myaccount addcustomer '{..all the json here..}' -p myaccount

image

brightermatter avatar May 17 '18 15:05 brightermatter

This types of errors happens to me when: 1 - Publish a contract and emplace some info to table. 2 - Change struct order of fields, datatype of field or remove fields for the same table. 3 - Update contract with the changes.

Probably the layout of the memory allocated before the change does not match the new one (defined in ABI) and the datastream cant parse it correctly.

mmcs85 avatar May 17 '18 15:05 mmcs85

Yeah I encountered similar problems before. That's why I started with a clean install, clean contract and an empty (--resync) blockchain. In the issue above, neither the contract action params nor the struct is modified by adding or removing a field.

brightermatter avatar May 17 '18 16:05 brightermatter

Without the ABI and CPP we cannot debug or validate this error.

bytemaster avatar May 17 '18 19:05 bytemaster

@brightermatter Did you add // @abi table before table struct?

alexsharypin avatar May 18 '18 15:05 alexsharypin

yes. here's the table struct:

//@abi table mycustomer i64 struct mycustomer { uint64_t customerId; string companyTitle; string contactAddress; string contactTelephone; string contactFax; uint64_t contactPersonList; uint64_t contactPersonCount; string taxOffice; string taxNumber; string applicationReason; uint64_t createdByCompanyId; uint64_t createdByUserId; string contactEmail; string corporateWebsite; string headquarterAddress; string fieldOfActivity; string statusOfActivity; string commercialRegistryOffice; string commercialRegistryNumber; string registryDate; string foundationDate; string termOfCompany; uint64_t status; time customerCreationDate; time customerUpdateDate; uint64_t primary_key() const { return customerId; } uint64_t by_companyTitle() const { return N(companyTitle); } uint64_t by_taxNumber() const { return N(taxNumber); } uint64_t by_createdByCompanyId() const { return createdByCompanyId; } uint64_t by_commercialRegistryNumber() const { return N(commercialRegistryNumber); } uint64_t by_foundationDate() const { return N(foundationDate); } EOSLIB_SERIALIZE(mycustomer, (customerId)(companyTitle)(contactAddress)(contactTelephone)(contactFax)(contactPersonList)(contactPersonCount)(taxOffice)(taxNumber)(applicationReason)(applicationReason)(createdByCompanyId)(createdByUserId)(contactEmail)(corporateWebsite)(headquarterAddress)(fieldOfActivity)(statusOfActivity)(commercialRegistryOffice)(commercialRegistryNumber)(registryDate)(foundationDate)(termOfCompany)(status)(customerCreationDate)(customerUpdateDate)) };

and there goes the abi:

{ "____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-05-17T15:24:00", "types": [{ "new_type_name": "time", "type": "uint32" } ], "structs": [{ "name": "mycustomer", "base": "", "fields": [{ "name": "customerId", "type": "uint64" },{ "name": "companyTitle", "type": "string" },{ "name": "contactAddress", "type": "string" },{ "name": "contactTelephone", "type": "string" },{ "name": "contactFax", "type": "string" },{ "name": "contactPersonList", "type": "uint64" },{ "name": "contactPersonCount", "type": "uint64" },{ "name": "taxOffice", "type": "string" },{ "name": "taxNumber", "type": "string" },{ "name": "applicationReason", "type": "string" },{ "name": "createdByCompanyId", "type": "uint64" },{ "name": "createdByUserId", "type": "uint64" },{ "name": "contactEmail", "type": "string" },{ "name": "corporateWebsite", "type": "string" },{ "name": "headquarterAddress", "type": "string" },{ "name": "fieldOfActivity", "type": "string" },{ "name": "statusOfActivity", "type": "string" },{ "name": "commercialRegistryOffice", "type": "string" },{ "name": "commercialRegistryNumber", "type": "string" },{ "name": "registryDate", "type": "string" },{ "name": "foundationDate", "type": "string" },{ "name": "termOfCompany", "type": "string" },{ "name": "status", "type": "uint64" },{ "name": "customerCreationDate", "type": "time" },{ "name": "customerUpdateDate", "type": "time" } ] },{ "name": "addcustomer", "base": "", "fields": [{ "name": "account", "type": "account_name" },{ "name": "customerId", "type": "uint64" },{ "name": "companyTitle", "type": "string" },{ "name": "contactAddress", "type": "string" },{ "name": "contactTelephone", "type": "string" },{ "name": "contactFax", "type": "string" },{ "name": "taxOffice", "type": "string" },{ "name": "taxNumber", "type": "string" },{ "name": "applicationReason", "type": "string" },{ "name": "createdByCompanyId", "type": "uint64" },{ "name": "createdByUserId", "type": "uint64" },{ "name": "contactEmail", "type": "string" },{ "name": "corporateWebsite", "type": "string" },{ "name": "headquarterAddress", "type": "string" },{ "name": "fieldOfActivity", "type": "string" },{ "name": "statusOfActivity", "type": "string" },{ "name": "commercialRegistryOffice", "type": "string" },{ "name": "commercialRegistryNumber", "type": "string" },{ "name": "registryDate", "type": "string" },{ "name": "foundationDate", "type": "string" },{ "name": "termOfCompany", "type": "string" },{ "name": "status", "type": "uint64" } ] },{ "name": "updcustomer", "base": "", "fields": [{ "name": "account", "type": "account_name" },{ "name": "customerId", "type": "uint64" },{ "name": "companyTitle", "type": "string" },{ "name": "contactAddress", "type": "string" },{ "name": "contactTelephone", "type": "string" },{ "name": "contactFax", "type": "string" },{ "name": "taxOffice", "type": "string" },{ "name": "taxNumber", "type": "string" },{ "name": "applicationReason", "type": "string" },{ "name": "createdByCompanyId", "type": "uint64" },{ "name": "createdByUserId", "type": "uint64" },{ "name": "contactEmail", "type": "string" },{ "name": "corporateWebsite", "type": "string" },{ "name": "headquarterAddress", "type": "string" },{ "name": "fieldOfActivity", "type": "string" },{ "name": "statusOfActivity", "type": "string" },{ "name": "commercialRegistryOffice", "type": "string" },{ "name": "commercialRegistryNumber", "type": "string" },{ "name": "registryDate", "type": "string" },{ "name": "foundationDate", "type": "string" },{ "name": "termOfCompany", "type": "string" },{ "name": "status", "type": "uint64" } ] },{ "name": "delcustomer", "base": "", "fields": [{ "name": "account", "type": "account_name" },{ "name": "customerId", "type": "uint16" } ] },{ "name": "rmvcustomer", "base": "", "fields": [{ "name": "account", "type": "account_name" },{ "name": "customerId", "type": "uint16" } ] },{ "name": "findcustomer", "base": "", "fields": [{ "name": "customerId", "type": "uint64" },{ "name": "kapId", "type": "string" },{ "name": "companyTitle", "type": "string" },{ "name": "taxNumber", "type": "string" },{ "name": "createdByCompanyId", "type": "uint64" },{ "name": "commercialRegistryNumber", "type": "string" },{ "name": "foundationDate", "type": "string" } ] } ], "actions": [{ "name": "addcustomer", "type": "addcustomer", "ricardian_contract": "" },{ "name": "updcustomer", "type": "updcustomer", "ricardian_contract": "" },{ "name": "delcustomer", "type": "delcustomer", "ricardian_contract": "" },{ "name": "rmvcustomer", "type": "rmvcustomer", "ricardian_contract": "" },{ "name": "findcustomer", "type": "findcustomer", "ricardian_contract": "" } ], "tables": [{ "name": "mycustomer", "index_type": "i64", "key_names": [ "customerId" ], "key_types": [ "uint64" ], "type": "mycustomer" } ], "ricardian_clauses": [] }

brightermatter avatar May 18 '18 15:05 brightermatter

Having same issue after resync and redeploying

Thanks,

eosconsultant avatar May 24 '18 19:05 eosconsultant

EOSLIB_SERIALIZE(mycustomer, (customerId)(companyTitle)(contactAddress)(contactTelephone)(contactFax)(contactPersonList)(contactPersonCount)(taxOffice)(taxNumber)(applicationReason)****(applicationReason)(createdByCompanyId)(createdByUserId)(contactEmail)(corporateWebsite)(headquarterAddress)(fieldOfActivity)(statusOfActivity)(commercialRegistryOffice)(commercialRegistryNumber)(registryDate)(foundationDate)(termOfCompany)(status)(customerCreationDate)(customerUpdateDate))

applicationReason is duplicated in the EOSLIB_SERIALIZE layout.

mmcs85 avatar May 28 '18 16:05 mmcs85