@@ -317,8 +317,10 @@ namespace master_nodes
317
317
#ifndef BELDEX_ENABLE_INTEGRATION_TEST_HOOKS
318
318
// NOTE: Wait at least 2 hours before we're allowed to vote so that we collect necessary
319
319
// voting information from people on the network
320
- if (live_time < m_core.get_net_config ().UPTIME_PROOF_VALIDITY )
321
- continue ;
320
+ if (live_time < m_core.get_net_config ().UPTIME_PROOF_VALIDITY ) {
321
+ LOG_PRINT_L1 (" May not vote, this node needs to be online more time(>2hours) to be allowed to vote" );
322
+ continue ;
323
+ }
322
324
#endif
323
325
324
326
if (!m_core.master_node ())
@@ -356,23 +358,34 @@ namespace master_nodes
356
358
const auto &node_key = worker_it->pubkey ;
357
359
const auto &info = *worker_it->info ;
358
360
359
- if (!info.can_be_voted_on (m_obligations_height))
361
+ if (!info.can_be_voted_on (m_obligations_height)){
362
+ LOG_PRINT_L2 (" process_quorums: Can not vote on:" ); // TODO:VOTE
360
363
continue ;
364
+ }
361
365
362
366
auto test_results = check_master_node (obligations_height_hf_version, node_key, info);
363
367
bool passed = test_results.passed (hf_version==cryptonote::network_version_12_security_signature);
368
+ LOG_PRINT_L2 (" process_quorums: check_master_node passed:" );// TODO:VOTE
369
+ LOG_PRINT_L3 (" NODE KEY:" << quorum->workers [node_index]);
364
370
371
+ int64_t credit = calculate_decommission_credit (info, latest_height,hf_version);
365
372
new_state vote_for_state;
366
373
uint16_t reason = 0 ;
367
374
if (passed) {
368
375
if (info.is_decommissioned ()) {
369
- vote_for_state = new_state::recommission;
370
- LOG_PRINT_L2 (" Decommissioned master node " << quorum->workers [node_index] << " is now passing required checks; voting to recommission" );
376
+ if (credit>=0 ) {
377
+ vote_for_state = new_state::recommission;
378
+ LOG_PRINT_L2 (" process_quorums: passed and is_decommissioned credit>0 newstate:recommission node:" );
379
+ }else {
380
+ vote_for_state = new_state::deregister; // Credit ran out!
381
+ LOG_PRINT_L2 (" process_quorums: passed and is_decommissioned credit 0 newstate:deregister node:" );
382
+ }
383
+ LOG_PRINT_L2 (" Decommissioned master node is now passing required checks; voting to recommission" );
371
384
} else if (!test_results.single_ip ) {
372
385
// Don't worry about this if the SN is getting recommissioned (above) -- it'll
373
386
// already reenter at the bottom.
374
387
vote_for_state = new_state::ip_change_penalty;
375
- LOG_PRINT_L2 (" Master node " << quorum-> workers [node_index] << " was observed with multiple IPs recently; voting to reset reward position" );
388
+ LOG_PRINT_L2 (" Master node was observed with multiple IPs recently; voting to reset reward position" );
376
389
} else {
377
390
good++;
378
391
continue ;
@@ -387,7 +400,7 @@ namespace master_nodes
387
400
if (!test_results.belnet_reachable ) reason |= cryptonote::Decommission_Reason::belnet_unreachable;
388
401
if (!test_results.timestamp_participation ) reason |= cryptonote::Decommission_Reason::timestamp_response_unreachable;
389
402
if (!test_results.timesync_status ) reason |= cryptonote::Decommission_Reason::timesync_status_out_of_sync;
390
- int64_t credit = calculate_decommission_credit (info, latest_height,hf_version);
403
+
391
404
392
405
if (info.is_decommissioned ()) {
393
406
if (credit >= 0 ) {
@@ -459,6 +472,8 @@ namespace master_nodes
459
472
LOG_PRINT_L0 (" Master Node is passing all local tests" );
460
473
LOG_PRINT_L0 (" (Note that some tests, such as storage server and belnet reachability, can only assessed by remote master nodes)" );
461
474
}
475
+ }else {
476
+ LOG_PRINT_L0 (" process_quorums: Cant be voted on my Master Node" );
462
477
}
463
478
}
464
479
}
@@ -534,27 +549,33 @@ namespace master_nodes
534
549
535
550
static bool handle_obligations_vote (cryptonote::core &core, const quorum_vote_t & vote, const std::vector<pool_vote_entry>& votes, const quorum& quorum)
536
551
{
552
+ LOG_PRINT_L2 (" start handle_obligations_vote" );
537
553
if (votes.size () < STATE_CHANGE_MIN_VOTES_TO_CHANGE_STATE)
538
554
{
539
555
LOG_PRINT_L2 (" Don't have enough votes yet to submit a state change transaction: have " << votes.size () << " of " << STATE_CHANGE_MIN_VOTES_TO_CHANGE_STATE << " required" );
540
556
return true ;
541
557
}
542
-
558
+ LOG_PRINT_L2 ( " get_network_version " );
543
559
auto net = core.get_blockchain_storage ().get_network_version ();
544
-
545
560
// NOTE: Verify state change is still valid or have we processed some other state change already that makes it invalid
546
561
{
547
562
crypto::public_key const &master_node_pubkey = quorum.workers [vote.state_change .worker_index ];
563
+ LOG_PRINT_L2 (" get_master_node_list_state " << master_node_pubkey);
548
564
auto master_node_infos = core.get_master_node_list_state ({master_node_pubkey});
549
- if (!master_node_infos.size () ||
550
- !master_node_infos[0 ].info ->can_transition_to_state (net, vote.block_height , vote.state_change .state ))
565
+
566
+ if (master_node_infos.empty () ||
567
+ !master_node_infos[0 ].info ->can_transition_to_state (net, vote.block_height , vote.state_change .state )
568
+ ){
551
569
// NOTE: Vote is valid but is invalidated because we cannot apply the change to a master node or it is not on the network anymore
552
570
// So don't bother generating a state change tx.
571
+ LOG_PRINT_L2 (" Vote is valid but is invalidated because we cannot apply the change to a master node" );
553
572
return true ;
573
+ }
554
574
}
555
-
556
575
using version_t = cryptonote::tx_extra_master_node_state_change::version_t ;
576
+ LOG_PRINT_L2 (" State not reachable A!?" );
557
577
auto ver = net >= HF_VERSION_PROOF_BTENC ? version_t ::v4_reasons : version_t ::v0;
578
+
558
579
cryptonote::tx_extra_master_node_state_change state_change{
559
580
ver,
560
581
vote.state_change .state ,
@@ -573,8 +594,10 @@ namespace master_nodes
573
594
}
574
595
575
596
cryptonote::transaction state_change_tx{};
597
+ LOG_PRINT_L2 (" Before add_master_node_state_change_to_tx_extra " );// << quorum.workers[vote.state_change.worker_index]);
576
598
if (cryptonote::add_master_node_state_change_to_tx_extra (state_change_tx.extra , state_change, net))
577
599
{
600
+ LOG_PRINT_L2 (" add_master_node_state_change_to_tx_extra " );
578
601
state_change_tx.version = cryptonote::transaction::get_max_version_for_hf (net);
579
602
state_change_tx.type = cryptonote::txtype::state_change;
580
603
@@ -592,8 +615,9 @@ namespace master_nodes
592
615
else
593
616
LOG_PRINT_L1 (" Failed to add state change to tx extra for height: "
594
617
<< vote.block_height << " and master node: " << vote.state_change .worker_index );
595
-
618
+ LOG_PRINT_L2 ( " handle_obligations_vote returned true " );
596
619
return true ;
620
+
597
621
}
598
622
599
623
static bool handle_checkpoint_vote (cryptonote::core& core, const quorum_vote_t & vote, const std::vector<pool_vote_entry>& votes, const quorum& quorum)
@@ -671,22 +695,29 @@ namespace master_nodes
671
695
bool quorum_cop::handle_vote (quorum_vote_t const &vote, cryptonote::vote_verification_context &vvc,uint8_t hf_version)
672
696
{
673
697
vvc = {};
674
- if (!verify_vote_age (vote, m_core.get_current_blockchain_height (), vvc,hf_version))
675
- return false ;
698
+ if (!verify_vote_age (vote, m_core.get_current_blockchain_height (), vvc,hf_version)) {
699
+ LOG_PRINT_L1 (" failed verify_vote_age" );
700
+ return false ;
701
+ }
676
702
677
703
std::shared_ptr<const quorum> quorum = m_core.get_quorum (vote.type , vote.block_height );
678
704
if (!quorum)
679
705
{
680
706
vvc.m_invalid_block_height = true ;
707
+ LOG_PRINT_L1 (" m_invalid_block_height (vote)" );
681
708
return false ;
682
709
}
683
710
684
- if (!verify_vote_signature (get_network_version (m_core.get_nettype (), vote.block_height ), vote, vvc, *quorum))
685
- return false ;
686
-
711
+ if (!verify_vote_signature (get_network_version (m_core.get_nettype (), vote.block_height ), vote, vvc, *quorum)) {
712
+ LOG_PRINT_L1 (" failed verify_vote_signature" );
713
+ return false ;
714
+ }
687
715
std::vector<pool_vote_entry> votes = m_vote_pool.add_pool_vote_if_unique (vote, vvc);
688
716
if (!vvc.m_added_to_pool ) // NOTE: Not unique vote
689
- return true ;
717
+ {
718
+ LOG_PRINT_L1 (" NOTE: Not unique vote" );
719
+ return true ;
720
+ }
690
721
691
722
bool result = true ;
692
723
switch (vote.type )
@@ -699,17 +730,19 @@ namespace master_nodes
699
730
};
700
731
701
732
case quorum_type::obligations:
733
+ LOG_PRINT_L1 (" handle_obligations_vote" );
702
734
result &= handle_obligations_vote (m_core, vote, votes, *quorum);
703
735
break ;
704
736
705
737
case quorum_type::checkpointing:
738
+ LOG_PRINT_L1 (" handle_checkpointing_vote " );
706
739
result &= handle_checkpoint_vote (m_core, vote, votes, *quorum);
707
740
break ;
708
741
}
709
742
return result;
710
743
}
711
744
712
- // Calculate the decommission credit for a master node. If the SN is current decommissioned this
745
+ // Calculate the decommission credit for a master node. If the MN is current decommissioned this
713
746
// accumulated blocks.
714
747
int64_t quorum_cop::calculate_decommission_credit (const master_node_info &info, uint64_t current_height,uint8_t hf_version)
715
748
{
0 commit comments