6

WHAT I WANT

Call an action and see it succeed at the first execution.

WHAT IS NOT WORKING

The function, which I am executing, the first time fails with error:

Error 3080006: Transaction took too long

Error Details: deadline exceeded

pending console output:

WHAT IS WORKING

The second time the transaction completes in 7784 us!!!

CLEOS

cleos push action mycontract action1 '[]' -p mycontract@active

  • 1
    I also don't understand sometimes this issue occur, but this happens very rarely. And next time we again push the transaction and it executes. – Nirdesh Kumar Choudhary Oct 17 '18 at 11:19
  • I am actually having the same problem. In my function I am trying to find() element in multiindex by id and if it is found - modify it. If not - emplace a new element. I wonder if that might be somehow connected to the problem. Also another thing might be using optionals in params? – Lonkly Nov 13 '18 at 23:45
  • Are you testing your contract on jungle test net... on dev.cryptolions.io:38888 or you using different IP? – Nirdesh Kumar Choudhary Nov 14 '18 at 7:54
  • Are you using a testnet or a local instance? If you are using testnet checkout my answer in this question. If you are using a local instance this may be related to some schedules of your processor. The computation time of your code is not hard predictable because another process of your os may have a higher priority or is scheduled before the execution. – TeeAttack42 Nov 15 '18 at 12:21
2
+25

The execution time is based on many factors in each execution.

It could be the cache missing or process management could blocks the nodeos process and makes the execution time exceeds the max-transaction-time.

The max-transaction-time set by nodeos on startup or in the config file controls the time to throw the Error 3080006. The default value is 30ms. Trying to set a greater value on max-transaction-time would help.

  • 1
    sir, as I mentioned above, it does not work only the first time I'm calling it. The second time it works fine. Also I want my contract to run on mainnet eventually, so editing configs won't solve the issue – Lonkly Nov 14 '18 at 4:01
  • I think it could be cache missing. As you may be running it on your local testnet, your code could possibly be cached in CPU of the computer running your nodeos. If in this case, the first execution is indeed the true performance of your smart contract. – Tong Shen Nov 14 '18 at 17:56
2

I think, it may related with cache (as twksos commented).

https://github.com/EOSIO/eos/blob/11c25394b6dd05cc3c97f0b7471a84f3d7cfbca3/libraries/chain/include/eosio/chain/wasm_interface_private.hpp#L58

 auto it = instantiation_cache.find(code_id);
 if(it == instantiation_cache.end()) {
    auto timer_pause = fc::make_scoped_exit([&](){
       trx_context.resume_billing_timer();
    });
    trx_context.pause_billing_timer();                            // see this

and https://github.com/EOSIO/eos/blob/11c25394b6dd05cc3c97f0b7471a84f3d7cfbca3/libraries/chain/transaction_context.cpp#L467

void transaction_context::pause_billing_timer() {
      if( explicit_billed_cpu_time || pseudo_start == fc::time_point() ) return; // either irrelevant or already paused

      auto now = fc::time_point::now();
      billed_time = now - pseudo_start;
      deadline_exception_code = deadline_exception::code_value;   // see this
      pseudo_start = fc::time_point();
   }

and deadline_exception is

  FC_DECLARE_DERIVED_EXCEPTION( deadline_exception, resource_exhausted_exception,
                                3080006, "Transaction took too long" )
0

Due to its subjective nature, transaction execution time is likely to vary each time it is executed. It would take longer time to execute on a slower machine while short time to execute on a faster machine. However, the maximum time a transaction is allowed to execute is 30ms. So if a node can't execute your transaction within 30ms, your transaction is considered failed and will not be broadcast to the network. You can either:

  1. Push the same transaction multiple times, hoping somehow it can be finished within 30ms.

  2. (recommended) Optimize your code, given the fact that EOS transfer action can be done in around 0.1ms.

  • the matter is, it only fails the first time, second time it's executed -it's fine, so it definitely can execute in that timeframe :) – Lonkly Nov 20 '18 at 7:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.