EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 463 forks source link

Failed to process a transfer transaction with nodejs #47

Closed henryyyx closed 6 years ago

henryyyx commented 6 years ago

api error => http://127.0.0.1:8888/v1/chain/push_transaction {"compression":"none","data":{"expiration":"2018-04-06T22:46:23","region":0,"ref_block_num":3721,"r ef_block_prefix":2640367696,"packed_bandwidth_words":11,"context_free_cpu_bandwidth":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"transfer" ,"authorization":[{"actor":"tester","permission":"active"}],"data":"000000005c95b1ca00000000007015d6701101000000000004454f530000000000"}]},"signatures":["EOSK9x B3Vp7fAp7NGNN1TiXaAVRtqTafMuFKTnWDvKHaUV8zqKXk53BjewByE7m8p7hBGSZTPvqc5MhSDRL5AyYDHvtCEdv9m"]} { Error: {"code":500,"message":"Internal Service Error","error":{ "code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[{"message":"Missing transaction","file":"abi_serializer .hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{" message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"push_transaction"}]}} at /home/vagrant/test/node_modules/eosjs-api/lib/apigen.js:98:23 at at process._tickCallback (internal/process/next_tick.js:188:7) status: 500, statusText: 'Internal Server Error' } { Error: {"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction"," details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":" abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"pus h_transaction"}]}} at /home/vagrant/test/node_modules/eosjs-api/lib/apigen.js:98:23 at at process._tickCallback (internal/process/next_tick.js:188:7) status: 500, statusText: 'Internal Server Error' } [push_transaction error] '{"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid pack ed transaction","details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number": 414,"method":"push_transaction"}]}}', transaction 'bff8c75a0000890e50d0609d0b00000000010000000000ea3055000000572d3ccdcd01000000005c95b1ca00000000a8ed32322100000 0005c95b1ca00000000007015d6701101000000000004454f530000000000' {"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details": [{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_seria lizer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"push_transac tion"}]}} (node:6626) UnhandledPromiseRejectionWarning: {"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception", "what":"Invalid packed transaction","details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Fa iled to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin .cpp","line_number":414,"method":"push_transaction"}]}} (node:6626) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:6626) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

manh-vv commented 6 years ago

I think I faced with the same error.

{
    "compression": "none",
    "data": {
        "expiration": "2018-04-07T08:28:56",
        "region": 0,
        "ref_block_num": 37941,
        "ref_block_prefix": 1183913515,
        "packed_bandwidth_words": 10,
        "context_free_cpu_bandwidth": 0,
        "context_free_actions": [],
        "actions": [
            {
                "account": "hello",
                "name": "sayhello",
                "authorization": [
                    {
                        "actor": "hello",
                        "permission": "active"
                    }
                ],
                "data": "00000000001aa36a0c5361792048656c6c6f20746f"
            }
        ]
    },
    "signatures": [
        "EOSK9LRpwmrASsasgddiRzedDErZbNGa9atGuF4EgeTLdD11eADEebPGnxFNS6XQQeV8vmeA6dygRwdPFMMSGMwo4yyAJjeBL"
    ]
}
{
    "Error": {
        "code": 500,
        "message": "Internal Service Error",
        "error": {
            "code": 3120010,
            "name": "packed_transaction_type_exception",
            "what": "Invalid packed transaction",
            "details": [
                {
                    "message": "Missing transaction",
                    "file": "abi_serializer.hpp",
                    "line_number": 367,
                    "method": "extract"
                },
                {
                    "message": "Failed to deserialize variant",
                    "file": "abi_serializer.hpp",
                    "line_number": 444,
                    "method": "from_variant"
                },
                {
                    "message": "Invalid packed transaction",
                    "file": "chain_plugin.cpp",
                    "line_number": 414,
                    "method": "push_transaction"
                }
            ]
        }
    }
}

Please help.

BTW: Could you please show me steps of signing a transaction.

Thank you,

jcalfee commented 6 years ago

Does it work with the eosio/eos:20180328 docker image?

henryyyx commented 6 years ago

The root cause is that the structure of packet was changed for the fix to https://github.com/EOSIO/eosjs/issues/25

    const packedTr = {
      compression: 'none',
      data: tr,
      signatures: sigs
    }
manh-vv commented 6 years ago

Does it work with the eosio/eos:20180328 docker image? Yes, it does.

:(, sorry, I get the error while running on pre-release of dawn3. Could you make eosjs working with dawn3 - release soon. 👍

tbfleming commented 6 years ago

I have a pull request to support dawn-v3.0.0: https://github.com/EOSIO/eosjs/pull/49

tinyhill666 commented 6 years ago

same problem

gglzf4 commented 6 years ago

the same problem "eosjs": "^7.1.5"

navcsdev commented 6 years ago

@zhangrm @qiushaoxi if you need it immediately you can use

I have a pull request to support dawn-v3.0.0: #49

I change the code in node_modules and it is success 😄

davidfrothin commented 6 years ago

Still have the same problem with 7.1.6 version

[push_transaction error] '{"code":500,"message":"Internal Service Error","error":{"code":3120010,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[{"message":"Missing transaction","file":"abi_serializer.hpp","line_number":367,"method":"extract"},{"message":"Failed to deserialize variant","file":"abi_serializer.hpp","line_number":444,"method":"from_variant"},{"message":"Invalid packed transaction","file":"chain_plugin.cpp","line_number":414,"method":"push_transaction"}]}}',

eq1984 commented 6 years ago

@davidfrothin have a look. your must change your local code. https://github.com/EOSIO/eosjs/pull/49/files

davidfrothin commented 6 years ago

@eq1984 so I went to my node_modules/eosjs/lib/write-api.js

Then made the change of commenting out those lines and replacing data with transaction. I still get the same error.

I will clear out and update again and get back.

eq1984 commented 6 years ago

@davidfrothin restart your nodeos, and add this parameter. ~ nodeos --skip-transaction-signatures From time-to-time the eosjs and eosd binary format will change between releases so you may need to start eosd with the --skip-transaction-signatures parameter to get your transactions to pass.

davidfrothin commented 6 years ago

@eq1984 Did you use npm install eosjs@7.1.6 to install eosjs?

davidfrothin commented 6 years ago

thanks, started with ~ nodeos --skip-transaction-signatures and restarted I see the same error.

I installed eosjs with npm install eosjs@7.1.6

However, the code write-api.js starts with 'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var assert = require('assert'); var ecc = require('eosjs-ecc'); var Fcbuffer = require('fcbuffer');

However 7.1.6 master and https://raw.githubusercontent.com/tbfleming/cib-eosjs/d73cfd240f21ee44192e71d54c4069dbcf08f836/src/write-api.js starts with

const assert = require('assert') const ecc = require('eosjs-ecc') const Fcbuffer = require('fcbuffer') const createHash = require('create-hash') const {processArgs} = require('eosjs-api') const Structs = require('./structs')

module.exports = writeApiGen

eq1984 commented 6 years ago

@davidfrothin yes. i install eosjs npm install eosjs@dawn3

image

image check your post data

davidfrothin commented 6 years ago

Thanks for helping to trouble shoot. Some reason our files downloaded are different

when I install npm install eosjs@dawn3 then I see node_modules/eosjs/lib/write-api.js starts with 'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var assert = require('assert'); var ecc = require('eosjs-ecc'); var Fcbuffer = require('fcbuffer'); var createHash = require('create-hash');

can you please paste the first few lines of /node_modules/eosjs/lib/write-api.js

eq1984 commented 6 years ago

write-api.zip

davidfrothin commented 6 years ago

@eq1984 - thanks for your file. The issue is now resolved. The update worked.

Thanks for your help!

davidfrothin commented 6 years ago

Just an update that it was starting nodeos with nodeos --skip-transaction-signatures and above file that worked.

--skip-transaction-signatures what does it actually do? Will anyone be able to send transactions?

jcalfee commented 6 years ago

--skip-transaction-signatures lets all transactions pass without having a valid signature.. once you start skipping signatures.

jcalfee commented 6 years ago

moved to https://github.com/EOSIO/eosjs/issues/52

Vyshakhcs1 commented 6 years ago

I had the same issue [push_transaction error]. And fixed it by adding modules const assert = require('assert') const ecc = require('eosjs-ecc') const Fcbuffer = require('fcbuffer') const createHash = require('create-hash') const {processArgs} = require('eosjs-api') const Structs = require('./structs')

Cheers (y)

jcalfee commented 6 years ago

@Vyshakhcs1 if your importing eosjs you don't need to manually import fcbuffer or any other eosjs-* package. A pointer to the correct version of each package is under Eos.Localnet().modules.

LIU9293 commented 6 years ago

Can we reopen it cause push_transaction is still not work with current docker image. Related issue here: https://github.com/EOSIO/eos/issues/2514

frankli1224 commented 6 years ago

Anyone can help? I also have this issue in dawn 4 {"code":3010011,"name":"packed_transaction_type_exception","what":"Invalid packed transaction","details":[]}

tbfleming commented 6 years ago

dawn 4 is obsolete; 1.0 came out over a month ago.