CityOfZion / neo-local

Personal blockchain for NEO dApp development!
MIT License
52 stars 26 forks source link

Investigate neo-python mounted volume #36

Closed revett closed 6 years ago

revett commented 6 years ago

Problem

@jeroenptrs mentioned that files added to the neo-python mounted volume do not appear in his container.

See:

https://github.com/CityOfZion/neo-local/blob/fb455dbc9a50523ac49a13711324812e40d87507/docker-compose.yml#L23-L25

nunojusto commented 6 years ago

docker-compose.yml seems fine. We need more info. What are the permissions in the host folders?

revett commented 6 years ago

I'm not sure that this is still an issue - @jeroenptrs can you confirm?

jeroenptrs commented 6 years ago

I'm not sure either, this needs to be tested 😄

jeroenptrs commented 6 years ago

Reproducing:

  1. Copy file ICOTemplate.avm (in my case) to smart-contracts folder
  2. make start and login after boot with CoZ wallet
  3. neo> import contract ./smart-contracts/ICOTemplate.avm 0710 05 True False True

Result:

Could not execute command: [Errno 2] No such file or directory: './smart-cont
racts/ICOTemplate.avm'
  File "/usr/lib/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
    task()
  File "/usr/local/lib/python3.6/dist-packages/twisted/_threads/_team.py", line 190, in doWork
    task()
  File "/usr/local/lib/python3.6/dist-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "/usr/local/lib/python3.6/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.6/dist-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.6/dist-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/neo-python/neo/bin/prompt.py", line 1034, in run
    traceback.print_stack()
Traceback (most recent call last):
  File "/neo-python/neo/bin/prompt.py", line 982, in run
    self.do_import(arguments)
  File "/neo-python/neo/bin/prompt.py", line 383, in do_import
    return self.load_smart_contract(arguments)
  File "/neo-python/neo/bin/prompt.py", line 812, in load_smart_contract
    function_code = LoadContract(args[1:])
  File "/neo-python/neo/Prompt/Commands/LoadSmartContract.py", line 93, in LoadContract
    with open(path, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: './smart-contracts/ICOTemplate.avm'
nunojusto commented 6 years ago

Very strange, i can confirm that... i'll keep investigating:

user@server:~/Documents/rpi$ docker ps -a
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                                                                        NAMES
dfdb3004295d        cityofzion/neo-local-faucet               "npm start"              9 minutes ago       Up 9 minutes        0.0.0.0:4002->4002/tcp                                                       neo-faucet
0bf8b20c4ff2        cityofzion/neo-python:v0.7.7              "/bin/sh -c /bin/bash"   9 minutes ago       Up 9 minutes                                                                                     neo-python
30d921d5cd2b        registry.gitlab.com/cityofzion/neo-scan   "/start.sh"              9 minutes ago       Up 9 minutes        0.0.0.0:4000->4000/tcp                                                       neo-scan
0aac8bd41ebf        cityofzion/neo-python                     "/usr/bin/python3 /n…"   9 minutes ago       Up 9 minutes        0.0.0.0:8080->8080/tcp                                                       notifications-server
3906245f2a98        cityofzion/neo-privatenet:2.7.6           "/bin/bash /opt/run.…"   9 minutes ago       Up 9 minutes        0.0.0.0:20333-20336->20333-20336/tcp, 0.0.0.0:30333-30336->30333-30336/tcp   neo-nodes
b6d983fc7301        postgres:10.1                             "docker-entrypoint.s…"   9 minutes ago       Up 9 minutes        5432/tcp                                                                     postgres
user@server:~/Documents/rpi$ docker exec -it 0bf8b20c4ff2 bash
root@server:/neo-python# df
Filesystem     1K-blocks      Used Available Use% Mounted on
none           203755344 184593036   8789036  96% /
tmpfs              65536         0     65536   0% /dev
tmpfs            3786152         0   3786152   0% /sys/fs/cgroup
/dev/sda3      203755344 184593036   8789036  96% /wallets
shm                65536         0     65536   0% /dev/shm
tmpfs            3786152         0   3786152   0% /proc/acpi
tmpfs            3786152         0   3786152   0% /proc/scsi
tmpfs            3786152         0   3786152   0% /sys/firmware
jeroenptrs commented 6 years ago

Weird, calling the smart-contracts volume with import contract from /smart-contracts/contract.avm 0710 07 True False True actually works. ./smart-contracts vs /smart-contracts, the dot makes a difference.

@revett but if I remember correctly, this issue was mostly made because after make start, it wouldn't persist new contracts added to the folder? Or will that never work?

nunojusto commented 6 years ago

Well, there's something wrong with docker-compose itself. You can see above, with the df command that there's only a mount called /wallets. But if I look inside the running container, there's a folder called smart-contracts with the host files. So i create a file called 'aaa' and I can see it inside the running container. That's a really strange behavior, but nonetheless it should work, because it's there and is syncing with the host folder. Another thing is why /wallets and not /smart-contracts show up with df if /wallets is the second volume listed? Well, if we change the mount to /smart (making it a smaller name), /wallets don't show and /smart shows. Funny. But like the other case, it works... the files are there in the folders and synced with the host.

Regarding neo-prompt itself: I can access/load the files with /smart-contracts and with ./smart-contracts i can't

nunojusto commented 6 years ago

@revett but if I remember correctly, this issue was mostly made because after make start, it wouldn't persist new contracts added to the folder? Or will that never work?

I can answer that. All files created on /smart-contracts folder when running it on a container are written in the host folder and then are available after you stop and start all again. I've tested it. So, in resume, it persists new contracts added to the folder.

jeroenptrs commented 6 years ago

@revett seems like this issue is resolved? I'll close it for now, unless something else pops up.

NoorSabah747 commented 4 years ago

plzzzz, where run order in cmd or powersheel or where? : docker pull cityofzion/neo-privatenet docker run -d --name neo-privatenet -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet pause plz i need help plz....