Unable to migrate secret contract

I can’t seem to get discovery migrate to work. Any time I try to migrate a secret contract (even simple_addition.wasm) I get this error: { code: -32000, message: 'socket hang up' }

Migrating a smart contract works fine though.

Any suggestions?

I have never seen that error.

Can you give us more info on your setup, or your software versions, or any changes that you have introduced that can provide us more context or give us a clue to help you troubleshoot this?

I updated to the new version of discovery and enigma-js by calling discovery pull and npm install enigma-js

I’m using node version 10.16.0

I’m on Ubuntu 18.04.2

If I run discovery init to download clean folder, run discovery start, compile the simple_addition contract, and run discovery migrate it installs the smart contract but times out on the secret contract. I’m only able to see the error message by turning const address = await deploySecretContract(config) into a promise like so:

deploySecretContract(config).then(function(response){
      const address = response;
      console.log(`Secret Contract "${config.filename}" deployed at Enigma address: ${address}`);
    }, function(error){
      console.log('Error: ', error)
    });

And here is the output from the terminal running the discovery testnet:

contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0x643b006f8a6baaa66415287dd5df2c17418155a426dd857ac755fb457640d3df
contract_1  |   Contract created: 0x1b88bdb8269a1ab1372459f5a4ec3663d6f5ccc4
contract_1  |   Gas usage: 261329
contract_1  |   Block Number: 53
contract_1  |   Block Time: Fri Aug 09 2019 16:55:49 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_getCode
contract_1  | eth_getBlockByNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0x2a4903a9601566fdd00981edc675ac94c06341304586ddfffa5fc2088e3f1ce6
contract_1  |   Gas usage: 42023
contract_1  |   Block Number: 54
contract_1  |   Block Time: Fri Aug 09 2019 16:55:49 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_getBlockByNumber
contract_1  | eth_accounts
contract_1  | eth_getBlockByNumber
contract_1  | eth_call
contract_1  | eth_getBlockByNumber
contract_1  | eth_blockNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_call
contract_1  | eth_estimateGas
contract_1  | eth_call
contract_1  | eth_getBlockByNumber
contract_1  | eth_blockNumber
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 46, current: 54, next: 56 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_sendTransaction
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: getWorkerEncryptionKey
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] DEBUG [PROXY_DISPATCH] sending dispatched rpc request
p2p_1       | [rpc] subscribed to target topic = QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgmba814d35fd5886b15518386dfc5c7247db01468d26k8RbeqzYah
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] INFO [WORK_TOPIC_PUBLISH] NewTaskEncryptionKey
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] DEBUG published [ba814d35fd5886b15518386dfc5c7247db01468d]
core_1      | 16:55:50 [INFO] get_dh_user_key() => Ok(NewTaskEncryptionKey { result: DHKey { dh_key: "9032d2865439ecbf0e66158aa07ca661cc00d976495578374b8e269b13761f1d05a006e0c7ff1a9185d50381702a155d70de3af1f9ab2edf3a3da86bae039a05", sig: "25445f2d639d8abd9c105f75d88ae553f4125f77b1974b97eaec0ffc056a9c2b2036ec0036d3d03cee790e62bd1ef09596d83f300b65354669eea74af2f384791c" } })
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] DEBUG published workerEncryptionKey=[9032d2865439ecbf0e66158aa07ca661cc00d976495578374b8e269b13761f1d05a006e0c7ff1a9185d50381702a155d70de3af1f9ab2edf3a3da86bae039a05] encryption key
p2p_1       | [Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)] DEBUG published [QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgmba814d35fd5886b15518386dfc5c7247db01468d26k8RbeqzYah]
contract_1  | 
contract_1  |   Transaction: 0xc8c7c8c5dc38e512b35045145c67b75f27c4e2307ffef2a5de32a5e429876d35
contract_1  |   Contract created: 0x7414e38377d6daf6045626ec8a8abb8a1bc4b97a
contract_1  |   Gas usage: 355316
contract_1  |   Block Number: 55
contract_1  |   Block Time: Fri Aug 09 2019 16:55:50 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_sign
contract_1  | eth_getTransactionReceipt
contract_1  | eth_call
contract_1  | eth_getCode
contract_1  | eth_sendTransaction
contract_1  | eth_getBlockByNumber
contract_1  | 
contract_1  |   Transaction: 0x10b318b8e5e836d6293c039eac8df1d90bb58a2f27d1aaa2e9eb8b6577eebdb7
contract_1  |   Gas usage: 45514
contract_1  |   Block Number: 56
contract_1  |   Block Time: Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_getBlockByNumber
contract_1  | eth_sendTransaction
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0x5eac1a86b444604e24fcbc307913fbb10a8ac75ec6f983f8bb8f1e42009690dd
contract_1  |   Gas usage: 180121
contract_1  |   Block Number: 57
contract_1  |   Block Time: Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | 
contract_1  |   Transaction: 0x2e00fd95a40a4b42f1c0d18e9f294b4f12bee0470aa57bbbbe41e7c7ba625b3f
contract_1  |   Gas usage: 27023
contract_1  |   Block Number: 58
contract_1  |   Block Time: Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
p2p_1       | [Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: deploySecretContract
p2p_1       | [Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: DeploySecretContract
p2p_1       | [Fri Aug 09 2019 16:55:51 GMT+0000 (Coordinated Universal Time)] INFO [PROXY_DISPATCH] an exception occurred while trying to unpack DeploySecretContract RPC Error: incorrect header check
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 46, current: 58, next: 56 [🔊 ]
km_1        | [☼ ] New epoch found [☼ ]
contract_1  | eth_call
km_1        | Evaluating nonce/seed based on EpochState: None
km_1        | Calling enclave set_worker_params with nonce/seed: "0000000000000000000000000000000000000000000000000000000000000000"/"0000000000000000000000000000000000000000000000000000000000000000"
km_1        | Creating new epoch with nonce 0x3
km_1        | Generated random seed: 0x1e50a08d744a38f264319e68579750b20f815744102748bf1ad62f50fcf3b196
km_1        | [+] Home dir is /root
km_1        | Back from Ocall: /root/.enigma
km_1        | Sealed document: "/root/.enigma/epoch/epoch-marker-0x3.sealed" written successfully.
km_1        | Sealed the epoch marker: "/root/.enigma/epoch/epoch-marker-0x3.sealed"
km_1        | Inserting epoch: Epoch { nonce: 0x3, seed: 0x1e50a08d744a38f264319e68579750b20f815744102748bf1ad62f50fcf3b196, worker_params: InputWorkerParams { block_number: 0x3a, workers: [0xba814d35fd5886b15518386dfc5c7247db01468d], stakes: [0x14f46b0400] } } in cache
km_1        | Cache reached its capacity of 2, removed first epoch: Epoch { nonce: 0x1, seed: 0xaf7f9e11c308bcfadef22a197aa2e60d712cf2500c11bcc477353ec27119b560, worker_params: InputWorkerParams { block_number: 0x22, workers: [], stakes: [] } }
km_1        | Initial epoch stored successfully
km_1        | Signed the message : 0x00000000000000201e50a08d744a38f264319e68579750b20f815744102748bf1ad62f50fcf3b1960000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000010000000000000014ba814d35fd5886b15518386dfc5c7247db01468d0000000000000001000000000000002000000000000000000000000000000000000000000000000000000014f46b0400
km_1        | Worker parameters set successfully
km_1        | Removed first EpochState of capped list: EpochState { seed: 79380229034079850589405765279177423538612952423000251602540276752588142654816, sig: Bytes([255, 246, 25, 105, 116, 60, 91, 134, 2, 240, 142, 105, 85, 248, 71, 104, 167, 98, 127, 119, 18, 158, 117, 20, 119, 206, 244, 167, 167, 29, 223, 52, 97, 187, 125, 132, 229, 153, 73, 104, 30, 31, 212, 24, 186, 104, 38, 189, 94, 233, 208, 196, 203, 146, 94, 210, 57, 81, 33, 225, 103, 163, 121, 68, 27]), nonce: 1, confirmed_state: Some(ConfirmedEpochState { selected_workers: {}, block_number: 35 }) }
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0xe54342ee04973aaa3c38a71495e442b2e9ef9cf7cfa64318dafc23f4109656ab
contract_1  |   Gas usage: 318011
contract_1  |   Block Number: 59
contract_1  |   Block Time: Fri Aug 09 2019 16:55:52 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_call
core_1      | 16:55:52 [INFO] get_ptt_req() => Ok(GetPTTRequest { result: Request { request: "83a464617461a752657175657374a269649cccd479ccd2cceaccef3a77ccf04f21ccf65da67075626b6579dc0040cc961d795bcccbcc806e4f01ccc8cce2ccce48cc85cc98cce2cce066140316ccd9ccaf7a71ccfb4a3accf5ccf1cce0094ecc9f0bcc8f7bccdf7d67cc864242ccde3acca1ccc5ccde40ccd66e77cc87ccdf0a39ccf71d65ccb91acc8fcc95ccd5", sig: "80659391bd4c08c019f190593f09a723098241b6051bb96276287b391774418410b6458ee3c1b6483a4c2d0177b84dd12ab18d4712833ebc33318e509131ea671b" } })
km_1        | Got get_state_keys request: StateKeyRequest { data: StringWrapper("83a464617461a752657175657374a269649cccd479ccd2cceaccef3a77ccf04f21ccf65da67075626b6579dc0040cc961d795bcccbcc806e4f01ccc8cce2ccce48cc85cc98cce2cce066140316ccd9ccaf7a71ccfb4a3accf5ccf1cce0094ecc9f0bcc8f7bccdf7d67cc864242ccde3acca1ccc5ccde40ccd66e77cc87ccdf0a39ccf71d65ccb91acc8fcc95ccd5"), sig: StringWrapper("80659391bd4c08c019f190593f09a723098241b6051bb96276287b391774418410b6458ee3c1b6483a4c2d0177b84dd12ab18d4712833ebc33318e509131ea671b"), block_number: None, addresses: None }
km_1        | Got internal error: EpochStateTransitionErr { current_state: "UNCONFIRMED, waiting for confirmation from Ethereum" }
p2p_1       | [Fri Aug 09 2019 16:55:52 GMT+0000 (Coordinated Universal Time)] DEBUG Connecting to principal node: http://172.26.0.2:3040
p2p_1       | [Fri Aug 09 2019 16:55:52 GMT+0000 (Coordinated Universal Time)] DEBUG Error received from KM, will retry..
contract_1  | eth_call
km_1        | Confirmed epoch with worker params: InputWorkerParams { block_number: 58, workers: [0xba814d35fd5886b15518386dfc5c7247db01468d], stakes: [90000000000] }
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 59, current: 59, next: 69 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
km_1        | Got get_state_keys request: StateKeyRequest { data: StringWrapper("83a464617461a752657175657374a269649cccd479ccd2cceaccef3a77ccf04f21ccf65da67075626b6579dc0040cc961d795bcccbcc806e4f01ccc8cce2ccce48cc85cc98cce2cce066140316ccd9ccaf7a71ccfb4a3accf5ccf1cce0094ecc9f0bcc8f7bccdf7d67cc864242ccde3acca1ccc5ccde40ccd66e77cc87ccdf0a39ccf71d65ccb91acc8fcc95ccd5"), sig: StringWrapper("80659391bd4c08c019f190593f09a723098241b6051bb96276287b391774418410b6458ee3c1b6483a4c2d0177b84dd12ab18d4712833ebc33318e509131ea671b"), block_number: None, addresses: None }
km_1        | No addresses in message, reading from epoch state...
km_1        | Searching contract addresses for recovered worker: [186, 129, 77, 53, 253, 88, 134, 177, 85, 24, 56, 109, 252, 92, 114, 71, 219, 1, 70, 141]
km_1        | Generated hash image: [0, 0, 0, 0, 0, 0, 0, 64, 150, 29, 121, 91, 203, 128, 110, 79, 1, 200, 226, 206, 72, 133, 152, 226, 224, 102, 20, 3, 22, 217, 175, 122, 113, 251, 74, 58, 245, 241, 224, 9, 78, 159, 11, 143, 123, 223, 125, 103, 134, 66, 66, 222, 58, 161, 197, 222, 64, 214, 110, 119, 135, 223, 10, 57, 247, 29, 101, 185, 26, 143, 149, 213, 0, 0, 0, 0, 0, 0, 0, 12, 212, 121, 210, 234, 239, 58, 119, 240, 79, 33, 246, 93] for request: PrincipalMessage { data: Request, pubkey: [150, 29, 121, 91, 203, 128, 110, 79, 1, 200, 226, 206, 72, 133, 152, 226, 224, 102, 20, 3, 22, 217, 175, 122, 113, 251, 74, 58, 245, 241, 224, 9, 78, 159, 11, 143, 123, 223, 125, 103, 134, 66, 66, 222, 58, 161, 197, 222, 64, 214, 110, 119, 135, 223, 10, 57, 247, 29, 101, 185, 26, 143, 149, 213], id: [212, 121, 210, 234, 239, 58, 119, 240, 79, 33, 246, 93] }
km_1        | The partially encrypted response: "83a46461746181b1456e63727970746564526573706f6e7365dc001dccb108261fccd1435e7b77ccc82ecca6ccb0380b0bcce813ccde114739ccccccc618ccb8cc8b0e17a269649cccd479ccd2cceaccef3a77ccf04f21ccf65da67075626b6579dc0040ccbbcc9542ccf0ccf063cc9810cc8619ccfccce7ccc6cc8c1fcc97cce040ccce144a2acc8f06cc8e56ccf029ccc7ccf72bcc83ccd6ccdf642acc86cca0ccce001acc823166cceeccb64513ccebcce9cc8841ccbbccfecc9cccf273ccaaccc2ccee5f2ccc8e1c"
p2p_1       | [Fri Aug 09 2019 16:55:54 GMT+0000 (Coordinated Universal Time)] DEBUG Connecting to principal node: http://172.26.0.2:3040
core_1      | building state for 0 contracts
core_1      | 16:55:54 [INFO] ptt_build_state() => []
core_1      | 16:55:54 [INFO] ptt_response() => Ok(PTTResponse { result: Errors([]) })
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 59, current: 59, next: 69 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 59, current: 59, next: 69 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
//These lines repeat until timeout
``

Just a followup, it seems to get hung up on this function inside the deploySecretContract function of the migration script:

enigma.deploySecretContract(config.fn, config.args, config.gasLimit, config.gasPrice, config.from, preCode)
      .on(eeConstants.DEPLOY_SECRET_CONTRACT_RESULT, (receipt) => resolve(receipt))
      .on(eeConstants.ERROR, (error) => reject(error));
1 Like

hey @pmp,

What does your discovery start log show? I wonder if there’s anything helpful there. I haven’t pulled the latest yet. I’ll have to do that soon!

@laura do you mean when I first start it?

yeah, I usually start the network in the background and save it to a log file, that I tail -f on.

Oh sorry! I see you’ve posted it above.

If you still want the startup messages, here they are: https://pastebin.com/yz4beaqr

1 Like

hi @pmp can you try upgrading to the latest discovery release and see if that resolves the issue? Instructions are here: New Release of the Enigma Protocol.

Oh, I’m sorry it wasn’t clear when I first posted. This issue started after upgrading to the new discovery version

@laura, oops I didn’t see that discovery was updated again. Unfortunately, that didn’t solve my problem.

@pmp I’m now seeing the same thing on the migrate, where it seems to get hung up on the discovery migrate. For me it’s occurring in one of my existing projects that I updated to the latest release. When I tried it in a new dir, starting from scratch, with discovery init the migrate is working.

Could you try in a new project too and see if it works for you that way?

FYI - this is the error in the discovery start log that you and I are both getting. I’m not sure why yet, but it seems to be having an issue the epoch state transitioning.

Ok, I ran discovery init in a new folder again and everything worked this time. I copied my old files over to the new folder, and was able to migrate without issue. So I guess we can marked this one solved, although I don’t know what was fixed.

Thanks for your help @laura!

1 Like

No problem! I’ve also relayed this to @victor because it seems like an issue with updating to the latest release in an existing project vs. starting from scratch.

Yes, I confirm that there are is no easy way to upgrade an old project to the new version, and one should restart from scratch for now. I understand that this is a pain point, and I will look into options, but it’s complicated because in some of these files, the user may have edited manually, so that’s where merging can get very messy (essentially we would need to have our own version of git or something to that extent…)

1 Like