Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Unable to successfully sign ethereum transaction offline #257

Closed
purpleeggplant opened this issue May 8, 2018 · 17 comments
Closed

Unable to successfully sign ethereum transaction offline #257

purpleeggplant opened this issue May 8, 2018 · 17 comments

Comments

@purpleeggplant
Copy link

I am trying to complete a transaction with trezorctl ethereum_sign_tx, but I get the following error:

Traceback (most recent call last):
File "/usr/local/bin/trezorctl", line 851, in
cli()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 27, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/usr/local/bin/trezorctl", line 687, in ethereum_sign_tx
from ethjsonrpc import EthJsonRpc
File "/usr/local/lib/python3.5/dist-packages/ethjsonrpc/init.py", line 1, in
from ethjsonrpc.client import (EthJsonRpc, ParityEthJsonRpc,
File "/usr/local/lib/python3.5/dist-packages/ethjsonrpc/client.py", line 7, in
from ethereum import utils
File "/usr/local/lib/python3.5/dist-packages/ethereum/utils.py", line 103, in
assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
AttributeError: 'bytes' object has no attribute 'encode'

I've tried on different OS / VMs but had no luck. Not sure if this is a user error, or how to work around it. Any insight would be appreciated.

@prusnak
Copy link
Member

prusnak commented May 9, 2018

As you can see from the backtrace, this is a bug in ethereum library and as such should be reported here: https://github.com/ethereum/pyethereum

@prusnak prusnak closed this as completed May 9, 2018
@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

more likely at EthJsonRpc which enforces unreasonably old versions of its dependencies:
https://github.com/ConsenSys/ethjsonrpc
but that seems unmaintained.

this is the part of code that shouldn't live in trezorctl anyway

@purpleeggplant
Copy link
Author

Any way to work around this in the meantime?

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

pip install --upgrade ethereum
pip install rlp==0.6.0

ethereum dependencies are a big mess right now :/

@purpleeggplant
Copy link
Author

I'll try from scratch again, but that still produces the same error.

When trying to upgrade ethereum, I get:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-3AyHeM/eth-hash/

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

try upgrading setuptools as well

@purpleeggplant
Copy link
Author

purpleeggplant commented May 9, 2018

Nope. I get an error with the ethereum package still:

Complete output from command python setup.py egg_info:
Maybe try: sudo apt-get install pandoc
See http://johnmacfarlane.net/pandoc/installing.html
for installation options
---------------------------------------------------------------

zip_safe flag not set; analyzing archive contents...
pypandoc.__init__: module references __file__


!!! pandoc not found, long_description is bad, don't upload this to PyPI !!!



Installed /tmp/pip-build-LO8fnl/eth-hash/.eggs/pypandoc-1.4-py2.7.egg
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-LO8fnl/eth-hash/setup.py", line 71, in <module>
    'Programming Language :: Python :: Implementation :: PyPy',
  File "/home/ma/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "/home/ma/.local/lib/python2.7/site-packages/setuptools/dist.py", line 363, in __init__
    _Distribution.__init__(self, attrs)
  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "/home/ma/.local/lib/python2.7/site-packages/setuptools/dist.py", line 519, in finalize_options
    ep.load()(self, ep.name, value)
  File "/tmp/pip-build-LO8fnl/eth-hash/.eggs/setuptools_markdown-0.2-py2.7.egg/setuptools_markdown.py", line 22, in long_description_markdown_filename
    output = pypandoc.convert(markdown_filename, 'rst')
  File "/tmp/pip-build-LO8fnl/eth-hash/.eggs/pypandoc-1.4-py2.7.egg/pypandoc/__init__.py", line 66, in convert
    raise RuntimeError("Format missing, but need one (identified source as text as no "
RuntimeError: Format missing, but need one (identified source as text as no file with that name was found).

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-LO8fnl/eth-hash/

@purpleeggplant
Copy link
Author

purpleeggplant commented May 9, 2018

I tried running sudo apt-get install pandoc but it didn't help.

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

Are you doing this in python 2? Python 2 is unsupported.
If you're doing this directly, i.e., outside of a virtualenv, try pip3 instead of pip.

pip3 install --upgrade setuptools
pip3 install trezor
pip3 install ethjsonrpc
pip3 install "ethereum>2.3" "rlp==0.6.0"

More technical info, in case more people stumble upon this from google:

  • ethjsonrpc is stuck on an old version of ethereum, which has a bug (in python3 presumably)
  • you can request a new version of ethereum, but that pulls in new rlp which is incompatible, so you need to fix it at 0.6.0
  • meanwhile rlp's dependencies get eth-hash which has a broken build step when not installed from a wheel -- so you need recent enough setuptools + pip to pull in a wheel. Also, hopefully, combining ethereum and rlp into one call will not even try to install eth-hash at all.
  • all in all, it is a mess.

@purpleeggplant
Copy link
Author

purpleeggplant commented May 9, 2018

That did it. Thank you for your assistance, kind internet stranger.

Should I still raise this to https://github.com/ConsenSys/ethjsonrpc or/and https://github.com/ethereum/pyethereum ?

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

it's already known and fixed on the ethereum side: ethereum/pyethereum#870

i see you reported an issue on ethjsonrpc already: Consensys/ethjsonrpc#51
but ... they're also aware of this and there's even a PR: Consensys/ethjsonrpc#17
it's a year and a half old. i wouldn't put my hopes up :/

the last piece is https://github.com/ethereum/eth-hash, where i'm not entirely sure what the problem is. if you can reliably reproduce it, it would definitely be worth reporting.

@purpleeggplant
Copy link
Author

ok. Thanks. As far as syntax goes, if I want to sign on Ropsten, is this correct?

trezorctl ethereym_sign_tx -c "3" -n"/44'60'/0'/0/0" -v "100 milliether" -g "21000" -t "41000000000" -i "0" 0xTOADDRESS

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

you've got a number of typos there.
trezorctl ethereum_sign_tx -c 3 -n "m/44'/60'/0'/0/0" -v "100 milliether" -g 21000 -t 41000000000 -i 0 0xTOADDRESS
as far as syntax goes, that seems correct. as for the values, i have no idea

@purpleeggplant
Copy link
Author

Ok. thanks. It doesn't seem to affect the raw signature output.

I will test it out and see if I can successfully sign on an offline computer and then publish online.

@purpleeggplant
Copy link
Author

purpleeggplant commented May 9, 2018

If I try to push the signed transaction to https://ropsten.etherscan.io/pushTx

I get the following error:
Error! Unable to broadcast Tx : {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid RLP.","data":"RlpExpectedToBeData"},"id":1}

@matejcik
Copy link
Contributor

matejcik commented May 9, 2018

you're probably running into #236

i hope to release 0.9.2 soon; in the meantime you'll probably need to update to github master

@purpleeggplant
Copy link
Author

purpleeggplant commented May 9, 2018

so? build from master? or wait for 0.9.2

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

No branches or pull requests

3 participants