Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[solved] fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2 #131

Closed
YaleZheng opened this issue May 29, 2018 · 10 comments
Closed

Comments

@YaleZheng
Copy link

YaleZheng commented May 29, 2018

Environment

lib_version: eosjs@13.0.0
testnet_site: http://dev.cryptolions.io/

Brief

it seem fail to perform transaction with eosjs@13.0.0
anytime i perform transaction,eosjs will throw error complain "provided keys, permissions, and delays do not satisfy declared authorizations"
but i can do the same transaction with cleos without any error

Code

import * as ecc from "eosjs-ecc";
import * as eosjs from "eosjs";

async function main() {
    const sk = '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
    const pk = await ecc.privateToPublic(sk)
    const accountName = 'yaleconab'

    const client = eosjs.Testnet({
        httpEndpoint: 'http://ayeaye.cypherglass.com:8888',
        keyProvider: [sk],
        broadcast: false,
        sign: true,
        debug: false,
        expireInSeconds: 60,
    })

    const tx = await client.transaction(tr => {
        tr.delegatebw({
            from: 'yaleconab',
            receiver: 'yaleconab',
            stake_net_quantity: '10.0 EOS',
            stake_cpu_quantity: '10.0 EOS',
            transfer: 0,
        })
    })
}

main().catch(console.error)

Cleos

cleos wallet create
cleos wallet import '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
cleos -u 'http://ayeaye.cypherglass.com:8888' system delegatebw yaleconab yaleconab '10.0 EOS' '10.0 EOS'

Error

api error => { message: 'transaction declares authority \'{"actor":"yaleconab","permission":"active"}\', but does not have signatures for it under a provided delay of 0 ms',
  file: 'authorization_manager.cpp',
  line_number: 405,
  method: 'check_authorization' } http://ayeaye.cypherglass.com:8888/v1/chain/push_transaction {"compression":"none","transaction":{"expiration":"2018-05-29T07:13:29","ref_block_num":7629,"ref_block_prefix":2987331323,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"delegatebw","authorization":[{"actor":"yaleconab","permission":"active"}],"data":"0000386652a4a2f10000386652a4a2f1a08601000000000004454f5300000000a08601000000000004454f530000000000"}],"transaction_extensions":[]},"signatures":["SIG_K1_KkciipwC9HvsoyhYZPsrAYFruSQxNvaCsrtM8aZrMNEBADfV7bTFsdSWaS44NLVuyq4vrn9FCp25uCWu96y17MX8Mn3HRq"]}
{ Error: {"code":500,"message":"Internal Service Error","error":{"code":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"yaleconab\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}
    at /home/yale/Workspace/blockchain/eos-vote-sdk/node_modules/eosjs-api/lib/apigen.js:115:23
    at <anonymous>
    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":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"yaleconab\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}
    at /home/yale/Workspace/blockchain/eos-vote-sdk/node_modules/eosjs-api/lib/apigen.js:115:23
    at <anonymous>
    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":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"yaleconab\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}', transaction '99fd0c5bcd1dfb0e0fb200000000010000000000ea305500003f2a1ba6a24a010000386652a4a2f100000000a8ed3232310000386652a4a2f10000386652a4a2f1a08601000000000004454f5300000000a08601000000000004454f53000000000000'
{"code":500,"message":"Internal Service Error","error":{"code":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"yaleconab\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}
@YaleZheng YaleZheng changed the title fail to perform transaction with testnet jungle4.2 on eosjs@13.0.0 fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2 May 29, 2018
@YaleZheng
Copy link
Author

YaleZheng commented May 29, 2018

after explore the closed issue,
i found an solution,

Step

Code

import * as ecc from "eosjs-ecc";
import * as eosjs from "eosjs";

async function main() {
    const sk = '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
    const pk = await ecc.privateToPublic(sk)
    const accountName = 'yaleconab'

    const client = eosjs.Testnet({
        httpEndpoint: 'http://ayeaye.cypherglass.com:8888',
        keyProvider: [sk],
        broadcast: false,
        sign: true,
        debug: false,
        expireInSeconds: 60,
        chainID: 'a628a5a6123d6ed60242560f23354c557f4a02826e223bb38aad79ddeb9afbca',
    })

    const tx = await client.transaction(tr => {
        tr.delegatebw({
            from: 'yaleconab',
            receiver: 'yaleconab',
            stake_net_quantity: '10.0 EOS',
            stake_cpu_quantity: '10.0 EOS',
            transfer: 0,
        })
    })
}

main().catch(console.error)

Conclusion

I think eosjs shoud detect the correct chain_id by itself.
maybe @jcalfee could add this feature next version

@jcalfee
Copy link
Contributor

jcalfee commented May 29, 2018

The user needs to accept the chain ID for security reasons.. The chainId is the hash of the genesis state which includes all initial accounts and balances. A man in the middle attack would still be complicated by TaPOS, however, a known valid chainID is still done to help ensure the transactions belong to the intended chain.

https://github.com/EOSIO/eos/search?q=compute_chain_id&unscoped_q=compute_chain_id

@randytorres
Copy link
Contributor

I'm running into the same issue but I'm still not able to get it working by following the instructions above.

@YaleZheng After you push a transaction are you able to verify it worked besides it not throwing any errors? When I set broadcast to false it appears to work but eosjs never actually calls push_transaction. When I set broadcast to true I get these errors.

file:"authorization_manager.cpp"
line_number:405
message: "transaction declares authority '{"actor":"randyt","permission":"active"}', but does not have signatures for it under a provided delay of 0 ms"
method:"check_authorization"

http://ayeaye.cypherglass.com:8888/v1/chain/push_transaction {"compression":"none","transaction":{"expiration":"2018-05-29T17:13:36","ref_block_num":9427,"ref_block_prefix":2840150054,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"newaccount","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d010000000100032f7829db81aef9dcd5768b26da14d8646998b9396634427c2fb8d5bfecd55c350100000001000000010002eed0aca9c52e0fb048cf55e26bd86ece19916e009244b40ddc6961efda6d1acd01000000"},{"account":"eosio","name":"buyrambytes","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d00200000"},{"account":"eosio","name":"delegatebw","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d102700000000000004454f5300000000102700000000000004454f530000000000"}],"transaction_extensions":[]},"signatures":["SIG_K1_KePtk6hWafWyoZKqRtjDxswMMxSwpw6yByedQkJjyiA6gZowEjKjb7Cfe1eXUGnStF29PM19ZgcZrEaaDzTkdSMk6EPptx"]}

@jcalfee
Copy link
Contributor

jcalfee commented May 29, 2018

I'm trying to create an account but it just hangs saying "Processing..."

@YaleZheng
Copy link
Author

@randytorres
look like that u did not generate the correct signature

can u list the environment you depended,and paste you relaitve code here?
may be i can give more suggestion?

i have try to delegatebw with boardcast and it work fine too.

Code

import * as eosjs from "eosjs";
import * as ecc from "eosjs-ecc";

async function main() {
    const sk = '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
    const pk = await ecc.privateToPublic(sk)
    const accountName = 'yaleconab'

    const client = eosjs.Testnet({
        httpEndpoint: 'http://ayeaye.cypherglass.com:8888',
        keyProvider: [sk],
        sign: true,
        debug: false,
        expireInSeconds: 60,
        chainId: 'a628a5a6123d6ed60242560f23354c557f4a02826e223bb38aad79ddeb9afbca',
    })

    const tx_signed = await client.transaction(tr => {
        tr.delegatebw({
            from: 'yaleconab',
            receiver: 'yaleconab',
            stake_net_quantity: '10.0 EOS',
            stake_cpu_quantity: '10.0 EOS',
            transfer: 0,
        })
    }, { broadcast: true })

    console.log(JSON.stringify(tx_signed, null, 4))
}

main()

@YaleZheng
Copy link
Author

@jcalfee ,I have try to create account again.

Everything work fine.

May be there r some network issues at that time.

After filled your info, and click the create button,u should able to see something like below

20180530081803

@randytorres
Copy link
Contributor

thanks @YaleZheng and @jcalfee I was able to figure it out and it wasnt related to eosjs.

@YaleZheng YaleZheng changed the title fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2 fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2[solved] May 30, 2018
@YaleZheng YaleZheng changed the title fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2[solved] [solved] fail to perform transaction with eosjs@13.0.0 on testnet jungle4.2 May 30, 2018
@jcalfee jcalfee closed this as completed May 30, 2018
@jcalfee
Copy link
Contributor

jcalfee commented May 30, 2018

I apologize @YaleZheng, I closed too soon .. I'll wait for you to confirm.

@jcalfee jcalfee reopened this May 30, 2018
@YaleZheng
Copy link
Author

it's ok

i just see many people create issue like this
so i keep it open.
i close it now.

@bkawk
Copy link

bkawk commented Jul 11, 2018

I have a similar issue here #248

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants