Debugging secret contract execution

Hi,

I’m having trouble debugging a secret contract function I created based off the examples in Adi’s guide.

This function works as written, but as mentioned in the TODOs, I’m running into a couple of issues when generating a UUID and saving state:

  1. I’m unable to use the Uuid::new_v4().to_hyphenated().to_string() to create a new UUID (here). If I use this it compiles successfully, but this is the output I see from the discovery network when running discovery test:
p2p_1       | [Sun Jul 21 2019 15:43:21 GMT+0000 (Coordinated Universal Time)] DEBUG [VERIFY_NEW_TASK] successful verification of task 0x69f69e42a12340af2b7ee8ce049ed33386720e902246229f92057611d174632f
p2p_1       | [Sun Jul 21 2019 15:43:21 GMT+0000 (Coordinated Universal Time)] DEBUG [onVerifyTask] saved to db task 0x69f69e42a12340af2b7ee8ce049ed33386720e902246229f92057611d174632f
contract_1  | eth_call
core_1      | Error in execution of smart contract function: Error in execution of WASM code: Instantiation: Module __wbindgen_placeholder__ not found
p2p_1       | [Sun Jul 21 2019 15:43:21 GMT+0000 (Coordinated Universal Time)] INFO [TASK_FINISHED] status = [FAILED] id: 0x69f69e42a12340af2b7ee8ce049ed33386720e902246229f92057611d174632f
p2p_1       | [Sun Jul 21 2019 15:43:21 GMT+0000 (Coordinated Universal Time)] INFO [COMMIT_RECEIPT] success for task 0x69f69e42a12340af2b7ee8ce049ed33386720e902246229f92057611d174632f receipt = [object Promise]
p2p_1       | [Sun Jul 21 2019 15:43:21 GMT+0000 (Coordinated Universal Time)] DEBUG published [/taskresults/0.1]
contract_1  | eth_gasPrice
contract_1  | eth_sendTransaction
  1. I’m unable to write state in the last step of the function (here). Again, this compiles successfully if I include it, but I’m running into the following error when doing discovery test:
contract_1  | eth_blockNumber
contract_1  | eth_call
contract_1  | eth_call
p2p_1       | [Sat Jul 20 2019 23:50:18 GMT+0000 (Coordinated Universal Time)] DEBUG [VERIFY_NEW_TASK] successful verification of task 0x446e739babcd90ddd7f466a78961ca31fa411e14de57f81b359f3cd5d61ecf43
p2p_1       | [Sat Jul 20 2019 23:50:18 GMT+0000 (Coordinated Universal Time)] DEBUG [onVerifyTask] saved to db task 0x446e739babcd90ddd7f466a78961ca31fa411e14de57f81b359f3cd5d61ecf43
contract_1  | eth_blockNumber
core_1      | Error in execution of smart contract function: Error in execution of WASM code: unreachable
p2p_1       | [Sat Jul 20 2019 23:50:19 GMT+0000 (Coordinated Universal Time)] INFO [TASK_FINISHED] status = [FAILED] id: 0x446e739babcd90ddd7f466a78961ca31fa411e14de57f81b359f3cd5d61ecf43
contract_1  | eth_gasPrice
p2p_1       | [Sat Jul 20 2019 23:50:19 GMT+0000 (Coordinated Universal Time)] INFO [COMMIT_RECEIPT] success for task 0x446e739babcd90ddd7f466a78961ca31fa411e14de57f81b359f3cd5d61ecf43 receipt = [object Promise]
p2p_1       | [Sat Jul 20 2019 23:50:19 GMT+0000 (Coordinated Universal Time)] DEBUG published [/taskresults/0.1]
contract_1  | eth_sendTransaction
contract_1  | eth_call

I’m not sure where to look for further debug information or stack traces. From searching around for similar error messages to Error in execution of smart contract function: Error in execution of WASM code: unreachable, I found out about console_error_panic_hook. However I can’t seem to install this because it requires wasm-bindgen, and I’m not able to install that due to a dependency issue when installing wasm-bindgen-cli-support. I’d appreciate any advice on how to go about debugging runtime execution errors in the Rust secret contracts.

Please let me know if I can provide further clarification or more information that would save time when addressing these issues.

2 Likes

Hey @crypto_mentions – sorry we haven’t gotten back to you on this yet. I’m flagging it for followup! cc @adi

1 Like