From 50ea5e13f513a218f1853b7c27d9b6edd6ddacd2 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 31 Oct 2024 19:09:45 +0700 Subject: [PATCH] fix: cbtx tx as special transaction can't be retrieved before DIP0003 is activated It's true, let's add a check here before asking GetTxPayload which causes assert Assertion failure: assertion: (tx.nType == T::SPECIALTX_TYPE) file: ./evo/specialtx.h, line: 33 function: std::optional<_Tp> GetTxPayload(const TxType&, bool) [with T = CCbTx; TxType = CTransaction] 0#: (0x5CE686FB3AB0) stacktraces.cpp:655 - __wrap___assert_fail 1#: (0x5CE686BB9120) specialtx.h:33 - std::optional GetTxPayload(CTransaction const&, bool) 2#: (0x5CE686BB9120) cbtx.cpp:463 - GetCoinbaseTx(CBlockIndex const*) 3#: (0x5CE686BB916D) cbtx.cpp:470 - GetNonNullCoinbaseChainlock(CBlockIndex const*) 4#: (0x5CE686BB92AA) optional:469 - std::_Optional_base_impl, std::_Optional_base, false, false> >::_M_is_engaged() const 5#: (0x5CE686BB92AA) optional:986 - std::optional >::has_value() const 6#: (0x5CE686BB92AA) cbtx.cpp:401 - CalcCbTxBestChainlock(llmq::CChainLocksHandler const&, CBlockIndex const*, unsigned int&, CBLSSignature&) 7#: (0x5CE686D36318) miner.cpp:233 - BlockAssembler::CreateNewBlock(CScript const&) 8#: (0x5CE6869E450B) stl_tree.h:733 - std::_Rb_tree > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, boost::multi_index::detail::hashed_index_iterator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > >::_M_mbegin() const 9#: (0x5CE6869E450B) stl_tree.h:737 - std::_Rb_tree > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, boost::multi_index::detail::hashed_index_iterator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > >::_M_begin() 10#: (0x5CE6869E450B) stl_tree.h:982 - std::_Rb_tree > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, boost::multi_index::detail::hashed_index_iterator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > >::~_Rb_tree() 11#: (0x5CE6869E450B) stl_set.h:283 - std::set > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator > > > > >, boost::multi_index::detail::bucket_array >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> > >::~set() 12#: (0x5CE6869E450B) miner.h:146 - BlockAssembler::~BlockAssembler() 13#: (0x5CE6869E450B) mining.cpp:174 - generateBlocks 14#: (0x5CE6869E4C6E) prevector.h:479 - prevector<28u, unsigned char, unsigned int, int>::~prevector() 15#: (0x5CE6869E4C6E) script.h:393 - CScript::~CScript() 16#: (0x5CE6869E4C6E) mining.cpp:300 - operator() 17#: (0x5CE6869E4C6E) invoke.h:61 - __invoke_impl&, const RPCHelpMan&, const JSONRPCRequest&> 18#: (0x5CE6869E4C6E) invoke.h:116 - __invoke_r&, const RPCHelpMan&, const JSONRPCRequest&> 19#: (0x5CE6869E4C6E) std_function.h:291 - _M_invoke 20#: (0x5CE686F48F8E) util.cpp:541 - RPCHelpMan::HandleRequest(JSONRPCRequest const&) const 21#: (0x5CE68697CD18) univalue.h:17 - UniValue::operator=(UniValue&&) 22#: (0x5CE68697CD18) server.h:107 - CRPCCommand::CRPCCommand(std::__cxx11::basic_string, std::allocator >, RPCHelpMan (*)())::{lambda(JSONRPCRequest const&, UniValue&, bool)#1}::operator()(JSONRPCRequest const&, UniValue&, bool) const 23#: (0x5CE68697D100) std_function.h:292 - std::_Function_handler, std::allocator >, RPCHelpMan (*)())::{lambda(JSONRPCRequest const&, UniValue&, bool)#1}>::_M_invoke(std::_Any_data const&, JSONRPCRequest const&, UniValue&, bool&&) 24#: (0x5CE686A876C0) std_function.h:591 - std::function::operator()(JSONRPCRequest const&, UniValue&, bool) const 25#: (0x5CE686A876C0) server.cpp:622 - ExecuteCommand 26#: (0x5CE686A889C6) server.cpp:511 - ExecuteCommands 27#: (0x5CE686A889C6) server.cpp:543 - CRPCTable::execute(JSONRPCRequest const&) const 28#: (0x5CE686C951B5) httprpc.cpp:247 - HTTPReq_JSONRPC 29#: (0x5CE686CA5406) unique_ptr.h:93 - std::default_delete::operator()(HTTPClosure*) const 30#: (0x5CE686CA5406) unique_ptr.h:398 - std::unique_ptr >::~unique_ptr() 31#: (0x5CE686CA5406) httpserver.cpp:107 - WorkQueue::Run() dashd: ./evo/specialtx.h:33: std::optional<_Tp> GetTxPayload(const TxType&, bool) [with T = CCbTx; TxType = CTransaction]: Assertion `(tx.nType == T::SPECIALTX_TYPE)' failed. --- src/evo/cbtx.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index a5f8d6b1cde31..48baccd9d967a 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -454,6 +454,11 @@ std::optional GetCoinbaseTx(const CBlockIndex* pindex) return std::nullopt; } + // There's no CbTx before DIP0003 activation + if (!DeploymentActiveAt(*pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003)) { + return std::nullopt; + } + CBlock block; if (!ReadBlockFromDisk(block, pindex, Params().GetConsensus())) { return std::nullopt;