Error when running Discovery test for tutorial millionaires_problem

Hi,
I am just following the tutorial


but

discovery test

does not work.

my environment:
ubuntu 16.04
node -v : 10.17.0 (system install without using nvm)
npm -v : 6.11.3
discovery -v: 0.1.3

the following messages show up.

Deploying Secret Contract "simple_addition.wasm"...
Smart Contract "Sample.Sol" has been deployed at ETH address: 0x4cFB3F70BF6a80397C2e634e5bDd85BC0bb189EE
Completed. Final Task Status is 2
Secret Contract "simple_addition.wasm" deployed at Enigma address: 0xffd02e0de1519a4f16f2841ed264443f5a5bbdf555d855b8bda1801b5096f650
Deploying Secret Contract "millionaires_problem.wasm"...
Completed. Final Task Status is 2
Secret Contract "millionaires_problem.wasm" deployed at Enigma address: 0x2822d89771ad2e375fcad20340901c716925c343a48e82a864d17274136f8a25


  Contract: MillionairesProblem
Error: Need to set task key pair first
    at e.value (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:691389)
    at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:679994
    at tryCatch (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:97:21)
    at Le (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
    at s (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Error: Need to set task key pair first
    at e.value (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:691389)
    at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:679994
    at tryCatch (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/regenerator-runtime/runtime.js:97:21)
    at Le (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
    at s (/home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
    at process._tickCallback (internal/process/next_tick.js:68:7)
/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/mocha/lib/runner.js:726
  err.uncaught = true;
               ^

TypeError: Cannot create property 'uncaught' on string 'abort({}). Build with -s ASSERTIONS=1 for more info.'
    at Runner.uncaught (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/mocha/lib/runner.js:726:16)
    at process.uncaught (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/mocha/lib/runner.js:839:10)
    at process.emit (events.js:203:15)
    at process._fatalException (internal/bootstrap/node.js:496:27)
1 Like

Hi @KanaGold, thanks for posting this. There was an update that requires setting the task key/pair in the latest discovery release.

Can you add this under the enigma.admin(); call to your test/test_millionaires_problem.js file:

enigma.setTaskKeyPair('cupcake');

I’ll add an issue to get the tutorial updated.

This should resolve the issue, but let me know if it doesn’t!

cc @adi

Hi, @laura
I added it but another error occurs.

Deploying Secret Contract "simple_addition.wasm"...
Smart Contract "Sample.Sol" has been deployed at ETH address: 0x4cFB3F70BF6a80397C2e634e5bDd85BC0bb189EE
Completed. Final Task Status is 2
Secret Contract "simple_addition.wasm" deployed at Enigma address: 0x2822d89771ad2e375fcad20340901c716925c343a48e82a864d17274136f8a25
Deploying Secret Contract "millionaires_problem.wasm"...
Completed. Final Task Status is 2
Secret Contract "millionaires_problem.wasm" deployed at Enigma address: 0x57d8ec4f6c9ee173128453563c505af4fd8e9158141b4f76f7de392229c3d0e0


  Contract: MillionairesProblem
    1) should execute compute task to add the first millionaire
    2) should get the pending task
    3) should get the confirmed task
    4) should execute compute task to add the second millionaire
    5) should get the pending task
    6) should get the confirmed task
    7) should execute compute task to compute richest millionaire
    8) should get the pending task
    9) should get the confirmed task
    10) should get the result and verify the computation is correct

  Contract: Sample
    ✓ should execute compute task (150ms)
    ✓ should get the pending task
Completed. Final Task Status is 2
    ✓ should get the confirmed task (1050ms)
task.encryptedAbiEncodedOutputs is b1a7d18ae4802cfeb5670569c502b96f226010e513a2f11bddeb8a56f92c1fa908b0397b1954acfacaaf46070916de72bca1fca6a8d73f040df4b081
    ✓ should get the result and verify the computation is correct


  4 passing (5s)
  10 failing

  1) Contract: MillionairesProblem
       should execute compute task to add the first millionaire:
     connect ECONNREFUSED 127.0.0.1:3346


  2) Contract: MillionairesProblem
       should get the pending task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:62:25)
      at web3.eth.getBlockNumber.then.result (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/@truffle/core/lib/testing/testrunner.js:153:7)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  3) Contract: MillionairesProblem
       should get the confirmed task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:69:27)

  4) Contract: MillionairesProblem
       should execute compute task to add the second millionaire:
     connect ECONNREFUSED 127.0.0.1:3346


  5) Contract: MillionairesProblem
       should get the pending task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:93:27)
      at web3.eth.getBlockNumber.then.result (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/@truffle/core/lib/testing/testrunner.js:153:7)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  6) Contract: MillionairesProblem
       should get the confirmed task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:100:31)

  7) Contract: MillionairesProblem
       should execute compute task to compute richest millionaire:
     connect ECONNREFUSED 127.0.0.1:3346


  8) Contract: MillionairesProblem
       should get the pending task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:121:27)
      at web3.eth.getBlockNumber.then.result (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/@truffle/core/lib/testing/testrunner.js:153:7)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  9) Contract: MillionairesProblem
       should get the confirmed task:
     TypeError: Cannot read property 'taskId' of undefined
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682784)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at e.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at e.n.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:682957)
      at Context.it (test/test_millionaires_problem.js:128:31)

  10) Contract: MillionairesProblem
       should get the result and verify the computation is correct:
     TypeError: Cannot read property 'taskId' of undefined
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:686369
      at new Promise (<anonymous>)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:686302
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Le (node_modules/enigma-js/lib/enigma-js.node.min.js:1:676859)
      at s (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677062)
      at /home/kanagold/kanagold_test/millionaires_problem_demo/node_modules/enigma-js/lib/enigma-js.node.min.js:1:677123
      at new Promise (<anonymous>)
      at RetryOperation.<anonymous> (node_modules/enigma-js/lib/enigma-js.node.min.js:1:677003)
      at RetryOperation._fn (node_modules/enigma-js/lib/enigma-js.node.min.js:1:687331)
      at RetryOperation.attempt (node_modules/retry/lib/retry_operation.js:112:8)
      at e.value (node_modules/enigma-js/lib/enigma-js.node.min.js:1:686126)
      at Promise (test/test_millionaires_problem.js:137:14)
      at new Promise (<anonymous>)
      at Context.it (test/test_millionaires_problem.js:136:18)
      at web3.eth.getBlockNumber.then.result (/usr/local/lib/node_modules/@enigmampc/discovery-cli/node_modules/@truffle/core/lib/testing/testrunner.js:153:7)
      at process._tickCallback (internal/process/next_tick.js:68:7)

So the tests are trying to connect to localhost on 3346, but this port is no longer exposed on all interfaces.
The guide is missing this update and I’ll follow that up too.

Meanwhile you can run docker ps and look at the Ports column to see what’s exposed to your host, you’ll notice nginx is listening on 3333, this container will proxy requests to http://p2p:3346, that’s configured in config/nginx.conf btw.

If you change the Enigma port in the test from 3346 to to 3333 it should work now.

Hi,
Changing 3346 to 3333 in test_millionaires_problem.js works fine for my environment.
I continued following the next tutorial


and confugured /client/utils/getEnigmaInit.js from 3346 to 3333 as well.

However, accessing from http://localhost:3000 failed in initialization.

Unhandled Rejection (Error): Given action "ENIGMA_INITIALIZED", reducer "enigma" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.

35 | // Initialize enigma-js client library (including web3)
  36 | const enigma = await getEnigmaInit();
  37 | // Create redux action to initialize set state variable containing enigma-js client library
> 38 | this.props.initializeEnigma(enigma);
     | ^  39 | // Initialize unlocked accounts
  40 | const accounts = await enigma.web3.eth.getAccounts();
  41 | // Create redux action to initialize set state variable containing unlocked accounts

Not sure about that one offhand, but would check if your metamask is configured for the local truffle env (port 9545).

Otherwise please push your project to github so I can try it out.

Hi,
I really appreciate your help!

I uploaded the entire project to the following github.

btw, I am not using metamask for this test. Do I need to make it work with this project? In that case, I think I need to learn more about the architecture…
Currently, I am running this project on ubuntu on AWS, and when I test the redux application, I use ngrok for bridging, and accessing from my local laptop environment.

I also make sure that 9545 is running on the environment.

CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS                            NAMES
62cfdc04eb85        nginx:latest                       "nginx -g 'daemon of…"   3 hours ago         Up 3 hours          80/tcp, 0.0.0.0:3333->3333/tcp   enigma_nginx_1
151b60afb85f        enigmampc/enigma_contract:latest   "/bin/bash -c './lau…"   3 hours ago         Up 3 hours          0.0.0.0:9545->9545/tcp           enigma_contract_1
95b1eaa3fa10        enigmampc/enigma_core_sw:latest    "/usr/bin/env /bin/b…"   3 hours ago         Up 3 hours                                           enigma_core_1
1ba0c90f8fe8        enigmampc/enigma_contract:latest   "/bin/bash -c './log…"   3 hours ago         Up 3 hours                                           enigma_client_1
b07716261217        enigmampc/enigma_km_sw:latest      "/usr/bin/env /bin/b…"   3 hours ago         Up 3 hours                                           enigma_km_1
e71db2bab5f2        enigmampc/enigma_p2p:latest        "/bin/bash -c './sta…"   3 hours ago         Up 3 hours          3346/tcp                         enigma_p2p_1
1 Like

No problem, and thanks for raising these issues in the guide.

Not metamask per se, though it does make it simple to use web3, it injects an instance for the javascript client to interact with ethereum.
Did you have something else in mind?

And BTW that works great, I had no trouble adding and computing millionaires with your project.

1 Like

Hi,

1 enable Metamask in the browser and make sure window.ethereum is avilable.
2 run ‘discovery migrate’ again( because I terminated the discovery process after I previously migrated. this could be figured out for checking secretContractCount)
3 added enigma.setTaskKeyPair('cupcake'); in getEnigmaInit.js as well.

and finally worked!!!

I really appreciate your help!!!

1 Like

Nicely done, happy coding!

2 Likes

that’s great @KanaGold!

1 Like