Cannot find module EnigmaSimulation.json

Hi. I just upgraded discovery-cli and ran discovery init in a new folder, and when I run discovery migrate it is producting this error below. Any suggestions? Thx.

Starting migrations...                                                                                                                                                                                             
======================                                                                                                                                                                                             
> Network name:    'development'                                                                                                                                                                                   
> Network id:      4447                                                                                                                                                                                            
> Block gas limit: 0x6691b7                                                                                                                                                                                        
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
1_initial_migration.js                                                                                                                                                                                             
======================                                                                                                                                                                                             

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0xe19463566963800a822cdf45daaabcc610699722aa9df2f2c4a6030da5440648
- Blocks: 0            Seconds: 0
   > Blocks: 0            Seconds: 0
   > contract address:    0x1b88Bdb8269A1aB1372459F5a4eC3663D6f5cCc4
   > block number:        53
   > block timestamp:     1577486071
   > account:             0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
   > balance:             99.54973358
   > gas used:            263741
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00527482 ETH


- Saving migration to chain.
   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00527482 ETH


2_deploy_contracts.js
=====================

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/home/brendan/code/2gather/tmp/build/enigma_contracts/EnigmaSimulation.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at require (/home/brendan/code/2gather/tmp/node_modules/truffle/build/cli.bundled.js:342791:18)
    at /home/brendan/code/2gather/tmp/migrations/2_deploy_contracts.js:17:20
    at Script.runInContext (vm.js:133:20)
    at Script.runInNewContext (vm.js:139:17)
    at Object.file (/home/brendan/code/2gather/tmp/node_modules/truffle/build/cli.bundled.js:342829:12)
    at Migration._load (/home/brendan/code/2gather/tmp/node_modules/truffle/build/cli.bundled.js:456247:24)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Truffle v5.1.6 (core: 5.1.6)
Node v10.16.0
(node:14729) UnhandledPromiseRejectionWarning: Error: child exited with code 1
    at ChildProcess.p.on.code (/home/brendan/.config/yarn/global/node_modules/@enigmampc/discovery-cli/src/index.js:39:21)
    at ChildProcess.emit (events.js:198:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:14729) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14729) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Hi Brendan, I’ve just tried a new project and couldn’t reproduce it.
Based on your log, did you init your new project in “/home/brendan/code/2gather/tmp”?

Please check your .env file and view the files in the BUILD_CONTRACTS_PATH, ensure it contains your contracts as expected.
If you initialized your project in SW mode then you should see EnigmaSimulation.json there, amongst others, once you’ve started discovery that is.

Hi, @taariq. Thanks for investigating this with me. I have tried again and get the same error. Here is a complete log from creating the tmp folder until I get the error. I have also run discovery start in another window and can see the the eth_blocknumber log messages being emitted there, so discovery is running.

At the high level, this log contains these steps:

  • create folder and enter it
  • check discovery version
  • discovery init (selecting sw mode)
  • discovery migrate
  • examine contents of .env file
  • examine contents of build/enigma_contracts folder

You will also note I need to rename truffle.js to truffle-config.js for it to work on my system. At the end I show the contents of the .env file for your reference. I also cd into the build/enigma_contracts folder and you can see it is empty.

I am running this on Ubuntu 18.04 using discovery-cli v0.1.8. Thanks for your help with this.

The log file was too big to paste into this message, but you can find it here: https://drive.google.com/file/d/1KR3JcxHaSbQBNHbSfznsC9MQBG-Tdios/view?usp=sharing

No worries Brendan, sure we’ll get to the bottom of this.

I’m on MacOS but I just spun up discovery on Ubuntu 18.04 and I still could not reproduce this. Here’s a screenshot of my mounted volume at the point when discovery starts and has compiled Enigma contracts, top shell is discovery starting and the bottom is the VM’s local volume;

Lets check if the contracts were compiled in your container, I suppose it wouldn’t start otherwise but lets confirm please.
You can jump into the enigma_contract_1 container with docker exec -it enigma_contract_1 bash

Then list the files in the container’s build dir with ls /root/enigma-contract/build/contracts

Please also inspect the container with docker inspect enigma_contract_1 so we can verify the volume config etc is as expected.

This is curious too, I didn’t have to do this either, what’s the error you got?
You can try starting with a fresh node in case you installed some other dependencies like ganache in your global. Since you’re on 10.16.0 I’d suggest nvm install v10.16.3, then install discovery-cli again and see if you still get the truffle error.

Hi @taariq. Here is the info from those commands:

It does appear the enigma smart contracts were built and are in the right place:

brendan@brendan-x230t:~/code/2gather/tmp/build/enigma_contracts$ docker exec -it enigma_contract_1 bash 
root@contract:~# ls /root/enigma-contract/build/contracts
Base64.json  ERC20Detailed.json  EnigmaMock.json        EnigmaToken.json  IEnigma.json        PrincipalImplSimulation.json  SolRsaVerify.json        WorkersImpl.json
Bytes.json   Enigma.json         EnigmaSimulation.json  GetCode2.json     Memory.json         SafeMath.json                 TaskImpl.json            WorkersImplSimulation.json
ECDSA.json   EnigmaCommon.json   EnigmaState.json       Getters.json      Migrations.json     Sample.json                   TaskImplSimulation.json
ERC20.json   EnigmaEvents.json   EnigmaStorage.json     IERC20.json       PrincipalImpl.json  SecretContractImpl.json       VotingETH.json
root@contract:~# exit
exit

And here is the result of the docker inspect enigma_contract_1:

[
    {
        "Id": "57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771",
        "Created": "2019-12-27T21:25:16.736145539Z",
        "Path": "/bin/bash",
        "Args": [
            "-c",
            "./launch_ganache.bash; bash"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 16909,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-12-27T21:25:21.822417918Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:3ac1ccd1694c15c53279941d9f6386b54794d89e222db0e79ab70d9786e0f574",
        "ResolvConfPath": "/var/lib/docker/containers/57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771/hostname",
        "HostsPath": "/var/lib/docker/containers/57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771/hosts",
        "LogPath": "/var/lib/docker/containers/57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771/57ca268039021cdcf4b188539feaa4a5eb80c2f6e5e40880ff0aad06f38b6771-json.log",
        "Name": "/enigma_contract_1",
        "RestartCount": 0,
        "Driver": "aufs",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "enigma_shared:/root/.enigma:rw",
                "/home/brendan/code/2gather/2gather/enigma/build/enigma_contracts:/root/enigma-contract/build/contracts:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "enigma_net",
            "PortBindings": {
                "9545/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9545"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/home/brendan/code/2gather/2gather/enigma/build/enigma_contracts",
                "Destination": "/root/enigma-contract/build/contracts",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "enigma_shared",
                "Source": "/var/lib/docker/volumes/enigma_shared/_data",
                "Destination": "/root/.enigma",
                "Driver": "local",
                "Mode": "rw",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "contract",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9545/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "SGX_MODE=SW",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=10.16.3",
                "YARN_VERSION=1.17.3"
            ],
            "Cmd": null,
            "Image": "enigmampc/enigma_contract:latest",
            "Volumes": {
                "/root/.enigma": {},
                "/root/enigma-contract/build/contracts": {}
            },
            "WorkingDir": "/root",
            "Entrypoint": [
                "/bin/bash",
                "-c",
                "./launch_ganache.bash; bash"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "287d3e92140d597f9ae2ba5d364cc9db39aff3f71a060981be1e04138e7eb7ac",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "enigma",
                "com.docker.compose.service": "contract",
                "com.docker.compose.version": "1.24.1",
                "maintainer": "info@enigma.co"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "c557ba7551261f0d8f72179f3b7784f58d895fc492938d5e1873ecd11ebbee6e",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "9545/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "9545"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/c557ba755126",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "enigma_net": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "contract",
                        "57ca26803902"
                    ],
                    "NetworkID": "4a04c7c7c78b7bcc617f38a692c9ff98834c4a91e6df41fb959b93bc8bdaeb7a",
                    "EndpointID": "48ef4fa22c5c8fb77149c776e59e4e3790c851ae11fd2115e362261060047d8d",
                    "Gateway": "172.22.0.1",
                    "IPAddress": "172.22.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:16:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]

Do you have any recommendations? Since you have been able to get things going on Ubuntu 18.04, it seems like either there was a something that failed when I first installed, or there is some conflict on my system that is preventing the engima contracts from getting copied into the project.

I would be willing to try a refresh install, but I would appreciate your guidance on how to make sure everything is correctly removed first. Or if not that let me know what you suggest. Thx.

As suspected the contracts are built but the volume isn’t configured correctly.
It says /home/brendan/code/2gather/2gather/enigma/build/enigma_contracts when we expected /home/brendan/code/2gather/tmp/enigma/build/enigma_contracts

What’s your docker-compose.yml say under the service contract?

Mine is
volumes: - "${BUILD_CONTRACTS_PATH}:/root/enigma-contract/build/contracts"

Perhaps your system is overriding BUILD_CONTRACTS_PATH from the .env file, eg process or system variables, though you’d be aware of doing so. Hopefully there’s a clue in the docker-compose.yml.

Lets see about the docker-compose.yml first, but if you do a fresh install I’d start with nvm setting up a new node version, eg v10.16.3, or amongst the supported versions. You’ll have an empty global node_module dir, a clean slate.

Then install discovery-cli and that should set you up with a fresh project that works without any issues or copying of truffle config, else lets tackle that first, it ought to work out of the box.

Hi, @taariq. Regarding your comment about the volume not being configured correctly, can discovery-cli only be used with one project folder? What you seem to be suggesting is that the globally installed discovery-cli need to be have configuration details set within it for a specific project folder.

How would it be possible to use discovery-cli with two or more project folders simultaneously?

In the meantime I will try out the node version bump and reinstall you suggest.

Hi @bmiller59 Yes it can work with multiple projects simultaneously, though you can’t start 2 instances at once, the 2nd discovery start will detect and stop the 1st.

discovery-cli is using the dotenv library and that .env is local to the project, however, you can set or export environment variables which may affect other projects. I think if you did this you’d know.

You can type set in your shell and see a list of variables for your user, there are other ways to override too, like docker or docker-compose but again you’d know this especially with a new project.

Lets see what happens with your new install, holding thumbs.

@taariq Ok, so the solution was simple once I understood what was happening under the hood with discovery. :wink:

All I had to do was to discovery stop and then change into the current/active project folder and run discovery start. After that I was able to see the enigma contracts in the build/enigma_contracts folder, and the discovery migrate command succeeded!

I did not have to reinstall discovery or upgrade the node version.

I had been thinking of discovery-cli like ganache-cli, which I have also used, but it is not quite the same. While one can start ganache once and use it simultaneously in multiple project folders, discovery-cli needs to be started in the correct/active project folder to work.

I was reviewing the README for discovery-cli, and I don’t think this point is very clear. I would recommend you make it more clear in the documentation that when you start discovery, it is relative to one project folder at a time.

Thank for your help.

1 Like

That’s great @bmiller59 , glad it’s working, I should have confirmed your directory.
The truffle config still doesn’t make sense but if you run into it again please post a new thread.

The readme can surely be clearer about this, the getting started guide is linked from it and does mention “From within our Discovery-initialized project, to:”, we could just say why right in the readme to avoid this pitfall.

Happy coding!

@taariq Thanks.

Actually, I was realizing it would be easy for discovery migrate to confirm that the docker inspect enigma_contract_1 is pointing to the right/current folder. Then it would be dummy/confusion-proofed. I would recommend that.

1 Like

Good idea Brendan, and perhaps even simpler by comparing the current working directory on migrate with the root of the contracts path.

Either way, thanks for the idea!

1 Like