Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: devnet stuck on block 2 with crash #6375

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

knst
Copy link
Collaborator

@knst knst commented Oct 31, 2024

Issue being fixed or feature implemented

Failure on devnet:

image

+extra logs haven't got to screenshot:

2024-10-31T13:19:21Z CreateNewBlock(): total size 1000 txs: 0 fees: 0 sigops 100
2024-10-31T13:19:21Z Posix Signal: Aborted

Locally similar error is caught with stacktrace:

    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<CCbTx> GetTxPayload<CCbTx, CTransaction>(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::pair<CBLSSignature, unsigned int>, std::_Optional_base<std::pair<CBLSSignature, unsigned int>, false, false> >::_M_is_engaged() const
       5#: (0x5CE686BB92AA) optional:986        - std::optional<std::pair<CBLSSignature, unsigned int> >::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&)

What was done?

Added check if DIP0003 is indeed activated before retrieving Chainlock of previous block.

How Has This Been Tested?

No crash observed locally

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@knst knst added this to the 22 milestone Oct 31, 2024
ogabrielides
ogabrielides previously approved these changes Oct 31, 2024
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 6044e06

src/evo/cbtx.cpp Outdated
@@ -465,6 +469,11 @@ std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)

std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{
// There's no CbTx before DIP0003 activation
if (DeploymentActiveAfter(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a part of GetCoinbaseTx (because that's where we get CCbTx from), should use DeploymentActiveAt (because pindex is the block we are trying to read, not the one after it), should be if (_not_ active) return nullopt. Should also drop all unrelated refactoring.

tldr: the patch should look like that

diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp
index a5f8d6b1cd..48baccd9d9 100644
--- a/src/evo/cbtx.cpp
+++ b/src/evo/cbtx.cpp
@@ -454,6 +454,11 @@ std::optional<CCbTx> 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;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch for DeploymentActiveAt, I don't know why it worked locally o_O

I'd prefer to drop GetCoinbaseTx completely because it's a confusing that do a lot of checks inside and used in only one module without any benefits, see commits

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to drop GetCoinbaseTx completely because it's a confusing that do a lot of checks inside and used in only one module without any benefits, see commits

I agree it's confusing but let's keep this PR focused

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls drop 24027f8

@knst
Copy link
Collaborator Author

knst commented Oct 31, 2024

pls drop 24027f8

can you be consistent? #6336 (comment) previous review you blocked my PR because you didn't like my negative condition, and here: #6336 (comment)

@knst knst requested a review from UdjinM6 October 31, 2024 13:42
@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v22.0.0-devpr6375.dde1edf3. A new comment will be made when the image is pushed.

@UdjinM6
Copy link

UdjinM6 commented Oct 31, 2024

pls drop 24027f8

can you be consistent? #6336 (comment) previous review you blocked my PR because you didn't like my negative condition, and here: #6336 (comment)

These are 2 completely different cases.

if (A) {
 do_smth_related_to_A
} else {
 do_smth_else
}

vs

if (not A) {
  bail_out
}

@UdjinM6
Copy link

UdjinM6 commented Oct 31, 2024

btw If you still want to keep 24027f8, you should fix its title - it doesn't match the code rn

… 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<CCbTx> GetTxPayload<CCbTx, CTransaction>(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::pair<CBLSSignature, unsigned int>, std::_Optional_base<std::pair<CBLSSignature, unsigned int>, false, false> >::_M_is_engaged() const
       5#: (0x5CE686BB92AA) optional:986        - std::optional<std::pair<CBLSSignature, unsigned int> >::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::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, std::_Identity<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag> >, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, boost::multi_index::detail::hashed_unique_tag, boost::multi_index::detail::hashed_index_global_iterator_tag>, CompareIteratorByHash, std::allocator<boost::multi_index::detail::hashed_index_iterator<boost::multi_index::detail::hashed_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<CTxMemPoolEntry, std::allocator<CTxMemPoolEntry> > > > > >, boost::multi_index::detail::bucket_array<std::allocator<CTxMemPoolEntry> >, 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<UniValue, generatetoaddress()::<lambda(const RPCHelpMan&, const JSONRPCRequest&)>&, const RPCHelpMan&, const JSONRPCRequest&>
      18#: (0x5CE6869E4C6E) invoke.h:116        - __invoke_r<UniValue, generatetoaddress()::<lambda(const RPCHelpMan&, const JSONRPCRequest&)>&, 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<char, std::char_traits<char>, std::allocator<char> >, RPCHelpMan (*)())::{lambda(JSONRPCRequest const&, UniValue&, bool)#1}::operator()(JSONRPCRequest const&, UniValue&, bool) const
      23#: (0x5CE68697D100) std_function.h:292  - std::_Function_handler<bool (JSONRPCRequest const&, UniValue&, bool), CRPCCommand::CRPCCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 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<bool (JSONRPCRequest const&, UniValue&, bool)>::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<HTTPClosure>::operator()(HTTPClosure*) const
      30#: (0x5CE686CA5406) unique_ptr.h:398    - std::unique_ptr<HTTPClosure, std::default_delete<HTTPClosure> >::~unique_ptr()
      31#: (0x5CE686CA5406) httpserver.cpp:107  - WorkQueue<HTTPClosure>::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.
@knst
Copy link
Collaborator Author

knst commented Oct 31, 2024

pls drop 24027f8

I created new PR #6376
I will give later quick view to src/llmq, src/evo code, maybe there's some more functions can be hidden from global namespace also.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v22.0.0-devpr6375.dde1edf3. The image should be on dockerhub soon.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

light ACK 50ea5e1 (reindexed on mainnet and testnet with -assumevalid set to pre-v20 block hashes, no issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants