ethereum / pyethapp

MIT License
1.28k stars 605 forks source link

Cannot build Docker container #230

Open Marto32 opened 7 years ago

Marto32 commented 7 years ago

System/environment

Expected behaviour

Following the instructions in the Dockerfile I performed the following steps with docker daemon running on my local machine:

git clone https://github.com/ethereum/pyethapp.git
cd pyethapp
docker build -t pyethapp .
docker run -p 30303:30303 -p 30303:30303/udp pyethapp

I expected the build to complete but I received an error.

Observed behaviour

$ docker run -p 30303:30303 -p 30303:30303/udp pyethapp
Traceback (most recent call last):
  File "/usr/local/bin/pyethapp", line 11, in <module>
    load_entry_point('pyethapp', 'console_scripts', 'pyethapp')()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2649, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2303, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2309, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/apps/pyethapp/pyethapp/app.py", line 22, in <module>
    from ethereum.snapshot import create_snapshot, load_snapshot as _load_snapshot
  File "/apps/pyethereum/ethereum/snapshot.py", line 4, in <module>
    from ethereum import common
  File "/apps/pyethereum/ethereum/common.py", line 10, in <module>
    from ethereum.messages import apply_transaction
  File "/apps/pyethereum/ethereum/messages.py", line 19, in <module>
    from ethereum import new_vm as vm
ImportError: cannot import name new_vm

Steps to reproduce

See above Expected Behavior

Running docker ps -a I see that there is a container, but I cannot attach to it. I'm a bit new to docker so please let me know if I'm simply using it incorrectly...

gsalgado commented 7 years ago

It's a known issue, unfortunately: https://github.com/ethereum/pyethereum/commit/feafaadd2d16de3eb927e94f7cc7b64860be1fe8#commitcomment-22462453

If you set USE_PYETHEREUM_DEVELOP=1 when setting up pyethapp, it will use a known-good version of pyethereum

Marto32 commented 7 years ago

Thanks! Do I set that as an environment variable or in the Dockerfile?

gsalgado commented 7 years ago

As an env var, and you have to make sure it is set when setup.py is executed. See .travis.yml for an example

On 13 June 2017 at 12:39, Michael Martorella notifications@github.com wrote:

Thanks! Do I set that as an environment variable or in the Dockerfile?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ethereum/pyethapp/issues/230#issuecomment-308089388, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZKctZoJjiBrx3m3DF8v-19o5jkx1mkks5sDnTdgaJpZM4N3zBm .

Marto32 commented 7 years ago

So I ran the command listed in the yaml file and am now seeing this error:

Searching for scrypt
Reading https://pypi.python.org/simple/scrypt/
Downloading https://pypi.python.org/packages/af/82/44b030646b9de44ba5a5c7e87b0419a4d44318ba18468f5292b9c16737ac/scrypt-0.8.0.tar.gz#md5=0704e59cc3afb3845c27bb3827baeea9
Best match: scrypt 0.8.0
Processing scrypt-0.8.0.tar.gz
Writing /var/folders/ms/k903zv3131x76k3p9xfn_ddc0000gn/T/easy_install-49N0Lq/scrypt-0.8.0/setup.cfg
Running scrypt-0.8.0/setup.py -q bdist_egg --dist-dir /var/folders/ms/k903zv3131x76k3p9xfn_ddc0000gn/T/easy_install-49N0Lq/scrypt-0.8.0/egg-dist-tmp-KeNwOr
scrypt-1.2.0/libcperciva/crypto/crypto_aes.c:6:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
         ^
1 error generated.
error: Setup script exited with error: command 'clang' failed with exit status 1

I tried brew install openssl but it's already on my machine. Here are the other packages in this virtualenv (using python 2.7):

asn1crypto==0.22.0
cffi==1.10.0
click==6.7
cryptography==1.9
decorator==4.0.11
devp2p==0.9.2
enum34==1.1.6
idna==2.5
ipaddress==1.0.18
lmdb==0.92
pycparser==2.17
pyethapp==1.5.0
requests==2.17.3
rlp==0.5.1
six==1.10.0

I also have the noted brew packages installed: brew install automake libtool pkg-config libffi gmp openssl

gsalgado commented 7 years ago

Sounds like #195

Marto32 commented 7 years ago

@gsalgado I was able to get a build working with the following Dockerfile (though the build does throw warnings when setting up pyethapp):

docker build -t pyethapp/dev:bash .

File Contents:

FROM python:2.7.9

# Update and install dependencies
RUN apt-get update
RUN apt-get install -y \
  git-core \
  build-essential \
  automake \
  pkg-config \
  libtool \
  libffi-dev \
  libgmp-dev \
  python-dev \
  libssl-dev \
  python-pip

RUN pip install --upgrade pip

# Install pyrlp
RUN git clone https://github.com/ethereum/pyrlp /apps/pyrlp
WORKDIR /apps/pyrlp
RUN pip install -e .

# Install pydevp2p
RUN git clone https://github.com/ethereum/pydevp2p /apps/pydevp2p
WORKDIR /apps/pydevp2p
RUN pip install -e .

# # Install pyethereum
# RUN git clone https://github.com/ethereum/pyethereum/ /apps/pyethereum
# WORKDIR /apps/pyethereum
# RUN pip install -e .

# Install and setup pyethapp
RUN git clone https://github.com/ethereum/pyethapp /apps/pyethapp
WORKDIR /apps/pyethapp
RUN pip install -Iv ipython==5.4.1
RUN USE_PYETHEREUM_DEVELOP=1 python setup.py develop

# Fix debian's ridiculous gevent-breaking constant removal
# (e.g. https://github.com/hypothesis/h/issues/1704#issuecomment-63893295):
RUN sed -i 's/PROTOCOL_SSLv3/PROTOCOL_SSLv23/g' /usr/local/lib/python2.7/site-packages/gevent/ssl.py

RUN mkdir -p /data/chaindata
RUN mkdir -p /data/keystore
RUN mkdir -p /data/nodes

EXPOSE 4000
EXPOSE 30303
EXPOSE 30303/udp

VOLUME /data

I enter an interactive shell using this command: docker run -it --entrypoint /bin/bash -p 30304:30303 pyethapp/dev:bash (30303 was already being used so I changed it to 30304)

And after creating an account, I enter the pyethapp console with this command: pyethapp -d /data --profile testnet run --console

However, it doesn't seem like I am connected to the network:

In [1]: lastlog()
INFO:jsonrpc starting IPCRPCServer ipcpath=/tmp/pyethapp.ipc
INFO:jsonrpc starting JSONRPCServer port=4000
INFO:p2p.peermgr waiting for bootstrap

Here is the console initialization output:

Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt

INFO:config     setup default config path=/data
INFO:config     writing config path=/data/config.yaml
INFO:app        using data in path=/data
INFO:config     loading config path=/data
WARNING:accounts        keystore directory does not exist directory=/data/keystore
WARNING:accounts        no accounts found
INFO:app        registering service service=accounts
INFO:db No contrib directory found, so not loading any user services
INFO:db opening LevelDB path=/data/leveldb max_open_files=32000 block_cache_size=8388608 write_buffer_size=4194304
INFO:app        registering service service=db
INFO:p2p.discovery      NodeDiscovery init
INFO:p2p.discovery      starting discovery proto this_enode=enode://d337a0f306b909e638d2b14d26fb01fe0ce23c8b987eb78eb798cce14c83977ed34db36043b848518405f5@0.0.0.0:30303
INFO:app        registering service service=discovery
INFO:p2p.peermgr        PeerManager init
INFO:app        registering service service=peermanager
INFO:eth.chainservice   initializing chain
Initializing chain from provided genesis declaration
INFO:eth.chainservice   chain at number=0
INFO:eth.block_creation Creating head candidate
INFO:eth.block  Block pre-sealed, 0 gas used
INFO:eth.block_creation Created head candidate successfully
INFO:app        registering service service=chain
WARNING:jsonrpc could not import solidity
INFO:app        registering service service=jsonrpc
WARNING:jsonrpc could not import solidity
INFO:app        registering service service=ipc
INFO:app        registering service service=console
INFO:app        starting
INFO:p2p.peermgr        starting peermanager
INFO:p2p.peermgr        starting listener addr=('0.0.0.0', 30303)
INFO:p2p.discovery      starting discovery
INFO:p2p.discovery      starting listener host=0.0.0.0 port=30303

Any ideas?

spacechimplives commented 7 years ago

Could the issue be you running on port 30304 instead of 30303? If that isn't somehow getting proxied back to port 30303, I don't think you'd be able to connect. Sounds like you may have another instance of ethereum running on your Mac. If that's the issue, then I think your best bet is just killing the one running on your host if you want to get the docker instance running.