Parity-ethereum: Dev mode times out on send transaction

Created on 10 Jul 2018  ·  8Comments  ·  Source: openethereum/parity-ethereum

I'm running:

  • Which Parity version?: latest docker image parity/parity
  • Which operating system?: MacOS
  • How installed?: docker
  • Are you fully synchronized?: n/a
  • Which network are you connected to?: dev
  • Did you try to restart the node?: yes

How to reproduce

Running parity like so:

docker run -d -p 8545:8545 parity/parity --config dev --jsonrpc-interface all --jsonrpc-apis all --jsonrpc-cors "*"

I'm having trouble with transactions that never complete.

Web3.py (this code times out):

import web3
from web3 import HTTPProvider, Web3
w3 = Web3(HTTPProvider("http://localhost:8545"))
w3.eth.sendTransaction({'to': w3.eth.accounts[1], 'from': w3.eth.coinbase, 'value': 3 * 10**9})

Web3.js (this code hangs):

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
var BN = web3.utils.BN;

web3.eth.getAccounts(async (err, acc) => {
    let startingBalance = web3.utils.toBN(await web3.eth.getBalance(acc[0]))
    console.log(startingBalance.toString());
    let result = await web3.eth.sendTransaction({
        from: acc[0],
        to: acc[1],
        value: 1000000
    })
    console.log(result);
});

The same code works perfectly fine with geth --dev or ganache nodes.

M6-rpcapi 📣 Z1-question 🙋‍♀️

Most helpful comment

Summary:

  • Parity is a more secure node, so behaves differently in dev mode compared to geth or ganache
  • It does offer a "coinbase" account with significant ether in address 00a329c0648769a73afac7f9381e08fb43dbea72 unlocked by the empty passphrase ""
  • However, every account either needs to be unlocked or signed on transaction
  • Moreover, unlocking is only active for one request, so signature is preferred
  • A typical transaction like w3.eth.sendTransaction(tx) needs to change to w3.personal.sendTransaction(tx, passphrase)

All 8 comments

You need to unlock the account you are using, pre-sign the transaction or use personal_sendTransaction. Web3 is waiting for you to sign it in this case.

Thanks for the note @Tbaut . I've traced the same problem in this thread: https://github.com/paritytech/parity/issues/5335 which was apparently resolved by https://github.com/paritytech/parity/pull/5612. However despite what https://github.com/paritytech/parity/pull/5612 claims, accounts 0 and 1 are not unlocked by default. Was there developer documentation I've missed about how to use parity for integration testing?

The ticket mentioned creates an account, it's in ~/.local/share/io.parity.ethereum/keys/DevelopmentChain/ but there is no mention of unlock it.

@Tbaut, in this StackOverflow thread I've found an explanation that suggests the "rich" account is the account recovered with an empty passphrase, however, this code reveals it to have 0 balance.

rich = web3.personal.newAccount("")
web3.personal.unlockAccount(rich, "")
print(w3.eth.getBalance(rich)) #=> 0

Check this out, it's the chain spec of the dev chain. This account is rich and it has already been created for you:
https://github.com/paritytech/parity/blob/master/ethcore/res/instant_seal.json#L49

@Tbaut, thanks a lot, was able to confirm the address like so (it indeed has the balance as stated):

if client == 'parity':
    rich = to_checksum_address("00a329c0648769a73afac7f9381e08fb43dbea72")
    w3.personal.unlockAccount(rich, "")
else:
    rich = w3.eth.coinbase

However, the unlocked address is still unable to send transactions.

@Tbaut sorted, I was able to send using `personal.sendTransaction' like so:

w3.personal.sendTransaction({'to': w3.eth.accounts[1], 'from': rich, 'value': 3*10**9}, "")

Thanks a lot for helping me out, will summarise the steps and feed back from all relevant tickets for future stumblers.

Summary:

  • Parity is a more secure node, so behaves differently in dev mode compared to geth or ganache
  • It does offer a "coinbase" account with significant ether in address 00a329c0648769a73afac7f9381e08fb43dbea72 unlocked by the empty passphrase ""
  • However, every account either needs to be unlocked or signed on transaction
  • Moreover, unlocking is only active for one request, so signature is preferred
  • A typical transaction like w3.eth.sendTransaction(tx) needs to change to w3.personal.sendTransaction(tx, passphrase)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dukei picture dukei  ·  3Comments

jordipainan picture jordipainan  ·  3Comments

jurijbajzelj picture jurijbajzelj  ·  3Comments

gaoxiangxyz picture gaoxiangxyz  ·  3Comments

BillSantos picture BillSantos  ·  3Comments