CityOfZion / neo-python

Python Node and SDK for the NEO 2.x blockchain. For NEO 3.x go to our successor project neo-mamba
https://neo-python.readthedocs.io/en/latest/
MIT License
313 stars 189 forks source link

Privatenet fails to initialize #1012

Open jseagrave21 opened 5 years ago

jseagrave21 commented 5 years ago

Current behavior

When trying to run neo-python using a privatenet, the program hangs and I receive the follow error after exiting using "Ctrl-C":

(venv) jseagrave21@DESKTOP-F7E94IM:/mnt/c/users/jseag/neo/neo-python-coz$ np-prompt -p
Privatenet useragent '/Neo:2.10.2/', nonce: 1195469497
Maxpeers set to  5
[I 190824 23:26:08 LevelDBImpl:45] Created DB at /home/jseagrave21/.neopython/Chains/privnet
[I 190824 23:26:08 Blockchain:164] Current stored headers empty, re-creating from stored blocks...
[I 190824 23:26:08 Blockchain:166] Recreate headers
[I 190824 23:26:08 LevelDBImpl:45] Created DB at /home/jseagrave21/.neopython/Chains/privnet_notif
^CShutting down sync manager...DONE
Shutting down node manager...DONE
Traceback (most recent call last):
  File "/mnt/c/users/jseag/neo/neo-python-coz/venv/bin/np-prompt", line 11, in <module>
    load_entry_point('neo-python', 'console_scripts', 'np-prompt')()
  File "/mnt/c/users/jseag/neo/neo-python-coz/neo/bin/prompt.py", line 393, in main
    loop.run_until_complete(shutdown())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 566, in run_until_complete
    return future.result()
  File "/mnt/c/users/jseag/neo/neo-python-coz/neo/bin/prompt.py", line 376, in shutdown
    await task
  File "/mnt/c/users/jseag/neo/neo-python-coz/neo/Network/nodemanager.py", line 80, in start
    raise e
  File "/mnt/c/users/jseag/neo/neo-python-coz/neo/Network/nodemanager.py", line 74, in start
    await self.loop.create_server(proto, host, port)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1346, in create_server
    % (sa, err.strerror.lower())) from None
PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 20333): permission denied

After troubleshooting and receiving advice on Slack, @hal0x2328 led to me a solution: changing the nodeport in the json file to something other than 20333. This is an issue because anyone running the docker image for the privatenet on the same workstation they are using neo-python will run into this problem. The default protocol.privnet.json lists

"SeedList": [
      "127.0.0.1:20333",
      "127.0.0.1:20334",
      "127.0.0.1:20335",
      "127.0.0.1:20336"

And the Nodeport as 20333. Ref: https://github.com/CityOfZion/neo-python/blob/master/neo/data/protocol.privnet.json

Expected behavior

Using the docker image and np-prompt -p, a user should be able to access a privatenet without additional work.

How to reproduce

Your environment

Let us know in what environment you're running into the issue:

ixje commented 4 years ago

I think the discussion here is; should we change the default port of neo-python to not conflict with neo-privatenet if that is running? If so, to what? The issue will still persist when people copy their config files (which is very likely)

jseagrave21 commented 4 years ago

@ixje perhaps this could be improved with better documentation in https://github.com/CityOfZion/neo-privatenet-docker. I was caught off guard originally because I have been using the privatenet without any additional steps since I started contributing. I am not sure what the best way forward is, my only thought was to make the user experience as simple and as straightforward as possible.