Two errors - "not enough allowance" and "incorrect nonce"

Opening this issue to address @pmp 's errors he encountered debugging his application.

@pmp can you share the error logs in more detail here?

cc @laura

2 Likes

For ‘Incorrect nonce yielding bad secret contract address’ this is the log from the discover cli:

km_1        | [🔊 ] Blocks @ previous: 81, current: 81, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_accounts
contract_1  | net_version
contract_1  | eth_accounts
contract_1  | eth_getBlockByNumber
contract_1  | eth_accounts
contract_1  | eth_getBlockByNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_estimateGas
contract_1  | eth_getBlockByNumber
contract_1  | eth_blockNumber
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0xf93983687b247a63fb94c15e5a2184d393b1b6d42fbd1982f33719b5790b47c9
contract_1  |   Contract created: 0xdfccc9c59c7361307d47c558ffa75840b32dba29
contract_1  |   Gas usage: 261329
contract_1  |   Block Number: 82
contract_1  |   Block Time: Wed Sep 18 2019 17:10:16 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: 0x0364811b022f52e4d836b4838632549b48ce84fc545c86e24bbaa724da39209e
contract_1  |   Gas usage: 42023
contract_1  |   Block Number: 83
contract_1  |   Block Time: Wed Sep 18 2019 17:10:16 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_getBlockByNumber
contract_1  | eth_accounts
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 83, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_getBlockByNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_getBlockByNumber
contract_1  | eth_estimateGas
contract_1  | eth_getBlockByNumber
contract_1  | eth_blockNumber
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0xd22d8fc6fc082f9067fffaa94d0a24252daf75103654534b7c1b71c842129118
contract_1  |   Contract created: 0xfe82e8f24a51e670133f4268cdfc164c49fc3b37
contract_1  |   Gas usage: 1999391
contract_1  |   Block Number: 84
contract_1  |   Block Time: Wed Sep 18 2019 17:10:17 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | eth_getCode
contract_1  | eth_getBlockByNumber
contract_1  | eth_call
contract_1  | eth_getBlockByNumber
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0xbbfe40f22a43ed45c39e0ee3d85e35c814b18e5aefbe67bfe44d7fd152c6c365
contract_1  |   Gas usage: 27023
contract_1  |   Block Number: 85
contract_1  |   Block Time: Wed Sep 18 2019 17:10:17 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | evm_snapshot
contract_1  | Saved snapshot #3
contract_1  | eth_blockNumber
contract_1  | eth_call
contract_1  | eth_blockNumber
contract_1  | eth_call
contract_1  | eth_call
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 85, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 85, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 85, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 85, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]
contract_1  | eth_blockNumber
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: getWorkerEncryptionKey
contract_1  | eth_call
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] DEBUG [PROXY_DISPATCH] sending dispatched rpc request
p2p_1       | [rpc] subscribed to target topic = QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm8cab9effffb9013de50ff9cf3325c6433ec38023Ew1VfUC1KkJ2
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] INFO [WORK_TOPIC_PUBLISH] NewTaskEncryptionKey
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] DEBUG published [8cab9effffb9013de50ff9cf3325c6433ec38023]
core_1      | 17:10:20 [INFO] get_dh_user_key() => Ok(NewTaskEncryptionKey { result: DHKey { dh_key: "c7687d3aff5672e6d31626336d0678e720eadbb3dac003ee4c6cd02cc96754e38aadb01f88ac7154eaed9e6770f364c7f625eef0ddf9e26d211e84e842fcb860", sig: "37a88b1be4a6613c0a435ad6df0b141000bf24b27caf333a1e89e858bd8a2afb0d17b619dc5285744d1f73ee5f91a9faa8df4d1333b19233b7e3ff3fe7e571df1b" } })
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] DEBUG published workerEncryptionKey=[c7687d3aff5672e6d31626336d0678e720eadbb3dac003ee4c6cd02cc96754e38aadb01f88ac7154eaed9e6770f364c7f625eef0ddf9e26d211e84e842fcb860] encryption key
p2p_1       | [Wed Sep 18 2019 17:10:20 GMT+0000 (Coordinated Universal Time)] DEBUG published [QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm8cab9effffb9013de50ff9cf3325c6433ec38023Ew1VfUC1KkJ2]
contract_1  | eth_sign
contract_1  | eth_call
contract_1  | eth_call
contract_1  | eth_sendTransaction
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: getWorkerEncryptionKey
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG [PROXY_DISPATCH] sending dispatched rpc request
p2p_1       | [rpc] subscribed to target topic = QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm8cab9effffb9013de50ff9cf3325c6433ec38023CPzVmcezNzKJ
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] INFO [WORK_TOPIC_PUBLISH] NewTaskEncryptionKey
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG published [8cab9effffb9013de50ff9cf3325c6433ec38023]
core_1      | 17:10:21 [INFO] get_dh_user_key() => Ok(NewTaskEncryptionKey { result: DHKey { dh_key: "a21edf3a4b077c7b2a02ed6ba34465dd016373dd211f354666bdf8004e9993bd451d470d069ad08febf3a0aa17493070ad5f9206c9a8f4c5bf329b5c8404a2e2", sig: "fdec345d297b468d08286195bff9d3baa8d7079f20d2bbe55976e15c2dae5c0b657cc2dd0ce71d472fa5709d7f3ade3b686db4699cf84c3f594cd9249430c8611b" } })
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG published workerEncryptionKey=[a21edf3a4b077c7b2a02ed6ba34465dd016373dd211f354666bdf8004e9993bd451d470d069ad08febf3a0aa17493070ad5f9206c9a8f4c5bf329b5c8404a2e2] encryption key
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG published [QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm8cab9effffb9013de50ff9cf3325c6433ec38023CPzVmcezNzKJ]
contract_1  | 
contract_1  |   Transaction: 0x712e9c0c3c467013bfea45443acb20e452382fe40cd305452049bee007caad9e
contract_1  |   Gas usage: 30578
contract_1  |   Block Number: 86
contract_1  |   Block Time: Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_sign
contract_1  | eth_getTransactionReceipt
contract_1  | eth_call
contract_1  | eth_sendTransaction
contract_1  | eth_sendTransaction
contract_1  | 
contract_1  |   Transaction: 0x93cbdf0d866a7bbde62fd4a789f6dc4072e051d058dd3729a8cb3f08079b5a3b
contract_1  |   Gas usage: 179277
contract_1  |   Block Number: 87
contract_1  |   Block Time: Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
contract_1  | 
contract_1  |   Transaction: 0xde13492dfc653bb2105fd6ad0ea6215ec61b113b13b049b23ad427c1f8910005
contract_1  |   Gas usage: 45514
contract_1  |   Block Number: 88
contract_1  |   Block Time: Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)
contract_1  | 
contract_1  | eth_getTransactionReceipt
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: sendTaskInput
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] INFO [+] JsonRpc: ComputeTask
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG [PROXY_DISPATCH] sending dispatched rpc request
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] INFO [WORK_TOPIC_PUBLISH] ComputeTask
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG published [8cab9effffb9013de50ff9cf3325c6433ec38023]
core_1      | 17:10:21 [INFO] get_register_signing_address() => [140, 171, 158, 255, 255, 185, 1, 61, 229, 15, 249, 207, 51, 37, 198, 67, 62, 195, 128, 35]
core_1      | 17:10:21 [INFO] produce_quote() => "AgAAAAsAAADvAO8A7+/v77AzX9O8HMqPgE65imQgWS3GzXNyHAZ/0j90UmYgJYpTSCDzN2rmsvIDTTt6S0ineAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAHAAAAAAAAAJTTMoO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7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7eFXkmj4cVO5NHXHtMeJyV"
core_1      | 17:10:21 [INFO] get_registration_params() => Ok(GetRegistrationParams { result: RegistrationParams { signing_key: "8cab9effffb9013de50ff9cf3325c6433ec38023", report: "416741414141734141414476414f3841372b2f763737417a58394f38484d715067453635696d5167575333477a584e7948415a2f306a3930556d59674a5970545343447a4e32726d73764944545474365330696e65414141414141414141414141414141414141414141414141414141414141414141414141414141414141414277414141414141414141484141414141414141414a54544d6f4f5765775331524c7131694c436a4253713974316e4d2b495745793167346d4a72356b533246414141414141414141414141414141414141414141414141414141414141414141414141414141414141434431786e6e6665724b4648443275765971545864444138695a32326b434435787737683338434d664f6e674141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141434d7135372f2f376b42506555502b63387a4a635a4450734f4149774141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414171414941414f37753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377557623465542b624f434b324946345a3267424141447537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775377537753775376546586b6d6a3463564f354e485848744d654a7956", signature: "" } })
contract_1  | eth_call
contract_1  | eth_sendTransaction
contract_1  | eth_blockNumber
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG [VERIFY_NEW_TASK] successful verification of task 57d8ec4f6c9ee173128453563c505af4fd8e9158141b4f76f7de392229c3d0e0
p2p_1       | [Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)] DEBUG [onVerifyTask] saved to db task 57d8ec4f6c9ee173128453563c505af4fd8e9158141b4f76f7de392229c3d0e0
contract_1  | 
contract_1  |   Transaction: 0x2876483a4623106f2937ea81ad55afc0c4d32441fe7c56a38ff487b1715396a5
contract_1  |   Gas usage: 29186
contract_1  |   Block Number: 89
contract_1  |   Block Time: Wed Sep 18 2019 17:10:21 GMT+0000 (Coordinated Universal Time)
contract_1  |   Runtime Error: revert
contract_1  |   Revert reason: Incorrect nonce yielding bad secret contract address
contract_1  | 
contract_1  | eth_blockNumber
km_1        | [🔊 ] Blocks @ previous: 81, current: 89, next: 91 [🔊 ]
km_1        | [⏳ ] Epoch still active [⏳ ]

I’ll post a log of the allowance error when I manage to recreate it

2 Likes

Hi @pmp,was the “incorrect nonce” error a result of a call on your secret contract or is it happening during discovery start?

Can you share the link to your repo here?

It happens when I call on the contract during discovery test.

Here is the repo: https://github.com/PeterMPhillips/discovery_rock_paper_scissors

2 Likes

Thanks! I’ll check it out.

1 Like

I’ve been able to reproduce both of the errors you’re seeing @pmp. The discovery log messages are showing a decryption error when the new_game() function is called with arguments. If I call it with no arguments, it works.

contract_1  | eth_call
core_1      | Error in deployment of smart contract function: Input Error: Cryptography Error: DecryptionError
core_1      | 13:14:25 [INFO] Ok(FailedTask { result: FailedTask { output: "6bc1fc2006c30f2df0ab7057c8d0d45470f2fec85b3ca1c31a0a371fc8d5c58333a476edd7306715f65baeb7f9c4f183024b81e1dea0f741e9661e3eadf2a8263ce21deee17f28f9413fef9a", used_gas: 0, signature: "d789928aff806eb8c91357b112cef81529f0edd384fb30eed68ae87362cc857f6368734d725e1646e07482b7c2d9c4078049bb9a312afd845c8c6b97b2d73b881c" } })
core_1      | building state for 8 contracts

I’m still trying to figure out why the args are causing a decryption error, which seems to be happening in the enclave code where the task is getting executed.

I’ll let you know what else I come up with!

@pmp I was able to narrow it down to the statement where you’re initializing the new_sig array in your verify() function. Looks like a typo where you’ve initialized the elements to “0u8” instead of “0”.

It’s not getting called in your tests, but I guess it’s enough to cause an issue when the enclave is trying to execute your new_game() function.

Can you verify that changing your verify() function, new_sig array declaration and initialization from:

let mut new_sig: [u8; 65] = [0u8; 65];

to:

let mut new_sig: [u8; 65] = [0; 65];

resolves the error(s) you were seeing?

Good catch @laura, thank you!

I’m curious, why wouldn’t that mistake have been picked up by the compiler?

1 Like

Hey @laura, I have another question that I hope you can answer. With the verify() function that was causing errors, I got the code from one of Enigma’s repos: https://github.com/enigmampc/enigma-core/blob/develop/examples/eng_wasm_contracts/erc20/src/lib.rs (Just a note, the error also exists in that code). As you can see it takes a Vec<u8> as one of the parameters. How do you pass a Vec<u8> type to a secret contract? My instinct was to pass my signature as a hash and call it a bytes for the Solidity type e.g.:
Secret contract:

#[pub_interface]
pub trait ContractInterface{
    fn new_game(player_1: H160, move_1: String, sig: Vec<u8>);
}

And for the Javascript:

let taskFn = 'new_game(address,string,bytes)';
let taskArgs = [
      [address, 'address'],
      [message, 'string'],
      [signature, 'bytes']
    ];
enigma.computeTask(taskFn, taskArgs, ...);

Is this correct?

1 Like

yeah, I was curious about that too. I tried a simple Rust program and sure enough rustc didn’t complain.

@pmp,

Yes, you have it right for passing a Vec<u8> type to the secret contract by using the arg type:

[signature, 'bytes']

Here’s a link to the types documentation which includes the mapping of secret contract to Solidity types: https://enigma.co/discovery-documentation/types/

Thank you for pointing out that code in the erc20 example! I’ll make a note of that.

1 Like

Were we able to resolve this problem for you, @pmp ?