区块链中文技术社区

EOS 部署合约出现 deadline ? exceeded by ?us

测试环境

OS: Ubuntu 18.04 server
EOS: v2.0.1
合约:v1.9.1

部署系统合约时出现以下错误

error 2020-02-07T03:05:55.178 cleos     main.cpp:4042                 main                 ] Failed with error: deadline 2020-02-07T03:05:55.175 exceeded by 43us  (2)
deadline 2020-02-07T03:05:55.175 exceeded by 43us

跟下代码(跳转github

#define FC_CHECK_DEADLINE( DEADLINE, ... ) \
  FC_MULTILINE_MACRO_BEGIN \
    if( DEADLINE < fc::time_point::maximum() && DEADLINE < fc::time_point::now() ) { \
       auto log_mgs = FC_LOG_MESSAGE( error, "deadline ${d} exceeded by ${t}us ", \
             FC_FORMAT_ARG_PARAMS(__VA_ARGS__)("d", DEADLINE)("t", fc::time_point::now() - DEADLINE) ); \
       auto msg = log_mgs.get_limited_message(); \
       throw timeout_exception( std::move( log_mgs ), timeout_exception_code, "timeout_exception", std::move( msg ) ); \
    } \
  FC_MULTILINE_MACRO_END

跟踪宏的调用 (跳转github

string exception::to_string( log_level ll   )const
   {
      const auto deadline = fc::time_point::now() + format_time_limit;
      std::stringstream ss;
      try {
         ss << my->_what;
         try {
            ss << " (" << variant( my->_code ).as_string() << ")\n";
         } catch( std::bad_alloc& ) {
            throw;
         } catch( ... ) {
            ss << "<- exception in to_string.\n";
         }
         for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr ) {
            try {
               FC_CHECK_DEADLINE(deadline);

查看 main.cpp:4042跳转github

if (!print_recognized_errors(e, verbose)) {
         // Error is not recognized
         if (!print_help_text(e) || verbose) {
            elog("Failed with error: ${e}", ("e", verbose ? e.to_detail_string() : e.to_string()));
         }
      }

发现该异常,为解析异常错误导致的解析超时错误,并非当时真实的错误。
继续查找 https://github.com/EOSIO/eos/issues/8443

2.0和1.8.9包括新的选项http-max-response-time-ms,该选项有助于减轻api节点的滥用。它允许您指定处理请求的时间限制。当前,这意味着将响应转换为json所需的时间受到限制,这是大多数api请求中最耗时的部分。我们将默认值设为30毫秒,以匹配默认的max-transaction-time。对于大块,30ms可能不足以让您的节点转换为json。当然取决于硬件等。随时随地将它放置在任何级别,您可以满足任何一个处理请求的要求。

解决方法

http-max-response-time-ms参数修改为30毫秒

http-max-response-time-ms = 30

参考

https://github.com/EOSIO/eos/issues/8443
https://github.com/EOSIO/eos/releases/tag/v1.8.9

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »