Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

eth_sendTransaction fails with RPC error: Unknown account #5160

Open
lrettig opened this issue Aug 2, 2018 · 13 comments
Open

eth_sendTransaction fails with RPC error: Unknown account #5160

lrettig opened this issue Aug 2, 2018 · 13 comments
Labels

Comments

@lrettig
Copy link
Contributor

lrettig commented Aug 2, 2018

If I run truffle using a basic, out-of-the-box solidity contract (truffle unbox metacoin) and then attempt to deploy/test against a local aleth instance (with jsonrpcproxy), I get a bunch of RPC errors:

�[35m2018-08-01 21:40:14�[0m �[34m�[0m rpc {"jsonrpc":"2.0","id":14,"method":"eth_sendTransaction","params":[{"from":"0xefadf166849f06eee4b44ddb78e4162580f436b1","gas":"0x47b760","gasPrice":"0x4a817c800","data":"0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582099b1b886ba0812a59fb82ef8207b4c078deb182d5f7e80fee22dcc23942d60590029"}]}
�[35m2018-08-01 21:40:14�[0m �[34m�[0m rpc {"error":{"code":0,"data":null,"message":"Unknown account."},"id":14,"jsonrpc":"2.0"}

�[35m2018-08-01 21:40:14�[0m �[34m�[0m rpc {"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0xefadf166849f06eee4b44ddb78e4162580f436b1","gas":"0x47b760","gasPrice":"0x4a817c800","data":"0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a7230582099b1b886ba0812a59fb82ef8207b4c078deb182d5f7e80fee22dcc23942d60590029"}],"id":1533174014721}
�[35m2018-08-01 21:40:14�[0m �[34m�[0m rpc {"error":{"code":-32602,"message":"INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"},"id":1533174014721,"jsonrpc":"2.0"}

Full trace is at https://gist.githubusercontent.com/lrettig/63d7e941946a313ec460c6484cecfc82/raw/21f776da70f7a9d389c811abfed6b18258c5a55b/cpp-log.txt

@axic
Copy link
Member

axic commented Aug 2, 2018

As mentioned I think you need to supply usable account addresses present in aleth to Truffle. Or it may require the personal API.

@lrettig
Copy link
Contributor Author

lrettig commented Aug 2, 2018

I did specify an account present in aleth to Truffle. The from of the transaction is valid. If you look at the trace you'll see that account listed.

What's the personal API?

@lrettig
Copy link
Contributor Author

lrettig commented Aug 2, 2018

I think it is an accounts issue. Despite the account in question existing and having a nonzero balance (from the genesis config), aleth doesn't recognize it:

> curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":14}' http://127.0.0.1:8545
{"id":14,"jsonrpc":"2.0","result":[]} 

@lrettig lrettig changed the title aleth doesn't play nice with truffle eth_sendTransaction fails with RPC error: Unknown account Aug 2, 2018
@lrettig
Copy link
Contributor Author

lrettig commented Aug 2, 2018

I also tried using:

  1. The genesis account
  2. Sending eth from the genesis account to a new account
  3. The coinbase account collecting mining rewards

I get the same "Unknown account" error regardless of which account I use.

@cdetrio
Copy link
Member

cdetrio commented Aug 2, 2018

it might be best to forget about eth_sendTransaction and hack truffle to use eth_sendRawTransaction. then you can do all the tx signing on the js side.

@cdetrio
Copy link
Member

cdetrio commented Aug 2, 2018

Also, what do you mean by "The genesis account"? If you want to use eth_sendTransaction, cpp needs to know the private key for whatever account you are trying to send from. Have you added the private key to cpp somehow?

@lrettig
Copy link
Contributor Author

lrettig commented Aug 3, 2018

I was able to work around this by using geth to create a keystore file containing the required private key, then manually copying that into the keystore directory beneath the database directory I'm running aleth in (with the -d flag). Oh, and the first time you send a tx from the account in question, aleth prompts you for the password for the keystore file (even if there is none) -- good luck catching that when running in full verbosity through a tee'ed logfile. So that RPC call will fail, but if you enter the password and hit enter, then the next one should succeed. 🤦‍♂️

I'm also encountering a ton of other errors trying to get truffle to talk to aleth -- bad nonce, random RPC errors. If I keep trying to deploy enough times, it seems to eventually sort itself out and start working. Anyway, the issue outlined in this issue seems to be resolved so I'll close this.

@lrettig lrettig closed this as completed Aug 3, 2018
@axic
Copy link
Member

axic commented Aug 3, 2018

I do not call it a resolution if geth needs to create files and random password is prompted for :)

At least create issues for those and/or keep this umbrella one open.

@axic axic reopened this Aug 3, 2018
@axic axic added the bug label Aug 3, 2018
@lrettig
Copy link
Contributor Author

lrettig commented Aug 3, 2018

Here's a braindump of the issues I see:

  • aleth does not appear to contain a toolchain for adequately managing keystore files. alethkey/ethkey does some things but it does not seem able to take a simple private key (in hex) and generate a keystore file/add the key to a keystore. (That's the part I had to use geth for.)
  • aleth -s, -S, --master and --password didn't seem to work for me. It's not clear to me from the documentation what they're supposed to do, but they did not allow me to import a private key or keyfile either.
  • I can't find documentation on any of this (http://www.ethdocs.org/en/latest/ethereum-clients/cpp-ethereum/ appears out of date and incomplete)
  • aleth prompting for a password the first time it encounters an account is an issue -- it should be possible to unlock that account using a commandline flag of some sort -- or if there is no password, there should be no prompt.
  • As I said many seemingly random, nondeterministic RPC errors talking to Truffle. I reran truffle deploy or truffle test two or three times and sometimes it only worked the third time. Would require more investigation.

@gumb0
Copy link
Member

gumb0 commented Sep 6, 2018

aleth does not appear to contain a toolchain for adequately managing keystore files. alethkey/ethkey does some things but it does not seem able to take a simple private key (in hex) and generate a keystore file/add the key to a keystore.

Did you try aleth-key importbare <private_key_hex> ?

@gumb0
Copy link
Member

gumb0 commented Sep 6, 2018

aleth -s <private_key_hex> works for me, too, just doesn't report its success, imports the key silently.

@gumb0
Copy link
Member

gumb0 commented Sep 6, 2018

aleth --unsafe-transactions turns off initial prompt on account first access

@gumb0
Copy link
Member

gumb0 commented Sep 6, 2018

--password is supposed to give a password to try before asking the user, but it doesn't work for me, at least not for the imported accounts (I suspect it does only for keys create by aleth).
We should fix this.

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

No branches or pull requests

4 participants