15
15
#include < consensus/validation.h>
16
16
#include < deploymentstatus.h>
17
17
#include < net.h>
18
- #include < net_processing.h>
19
18
#include < primitives/block.h>
20
19
#include < primitives/transaction.h>
21
20
#include < saltedhasher.h>
@@ -46,16 +45,16 @@ static const std::string DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT_Q_INDEXED = "q_m
46
45
47
46
static const std::string DB_BEST_BLOCK_UPGRADE = " q_bbu2" ;
48
47
49
- CQuorumBlockProcessor::CQuorumBlockProcessor (CChainState& chainstate, CConnman& _connman, CEvoDB& evoDb, const std::unique_ptr<PeerManager>& peerman ) :
50
- m_chainstate (chainstate), connman(_connman), m_evoDb(evoDb), m_peerman(peerman)
48
+ CQuorumBlockProcessor::CQuorumBlockProcessor (CChainState& chainstate, CConnman& _connman, CEvoDB& evoDb) :
49
+ m_chainstate (chainstate), connman(_connman), m_evoDb(evoDb)
51
50
{
52
51
utils::InitQuorumsCache (mapHasMinedCommitmentCache);
53
52
}
54
53
55
- void CQuorumBlockProcessor::ProcessMessage (const CNode& peer, std::string_view msg_type, CDataStream& vRecv)
54
+ PeerMsgRet CQuorumBlockProcessor::ProcessMessage (const CNode& peer, std::string_view msg_type, CDataStream& vRecv)
56
55
{
57
56
if (msg_type != NetMsgType::QFCOMMITMENT) {
58
- return ;
57
+ return {} ;
59
58
}
60
59
61
60
CFinalCommitment qc;
@@ -65,16 +64,14 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
65
64
66
65
if (qc.IsNull ()) {
67
66
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- null commitment from peer=%d\n " , __func__, peer.GetId ());
68
- m_peerman->Misbehaving (peer.GetId (), 100 );
69
- return ;
67
+ return tl::unexpected{100 };
70
68
}
71
69
72
70
const auto & llmq_params_opt = GetLLMQParams (qc.llmqType );
73
71
if (!llmq_params_opt.has_value ()) {
74
72
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- invalid commitment type %d from peer=%d\n " , __func__,
75
73
ToUnderlying (qc.llmqType ), peer.GetId ());
76
- m_peerman->Misbehaving (peer.GetId (), 100 );
77
- return ;
74
+ return tl::unexpected{100 };
78
75
}
79
76
auto type = qc.llmqType ;
80
77
@@ -88,33 +85,32 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
88
85
qc.quorumHash .ToString (), peer.GetId ());
89
86
// can't really punish the node here, as we might simply be the one that is on the wrong chain or not
90
87
// fully synced
91
- return ;
88
+ return {} ;
92
89
}
93
90
if (m_chainstate.m_chain .Tip ()->GetAncestor (pQuorumBaseBlockIndex->nHeight ) != pQuorumBaseBlockIndex) {
94
91
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- block %s not in active chain, peer=%d\n " , __func__,
95
92
qc.quorumHash .ToString (), peer.GetId ());
96
93
// same, can't punish
97
- return ;
94
+ return {} ;
98
95
}
99
96
int quorumHeight = pQuorumBaseBlockIndex->nHeight - (pQuorumBaseBlockIndex->nHeight % llmq_params_opt->dkgInterval ) + int (qc.quorumIndex );
100
97
if (quorumHeight != pQuorumBaseBlockIndex->nHeight ) {
101
98
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- block %s is not the first block in the DKG interval, peer=%d\n " , __func__,
102
99
qc.quorumHash .ToString (), peer.GetId ());
103
- m_peerman->Misbehaving (peer.GetId (), 100 );
104
- return ;
100
+ return tl::unexpected{100 };
105
101
}
106
102
if (pQuorumBaseBlockIndex->nHeight < (m_chainstate.m_chain .Height () - llmq_params_opt->dkgInterval )) {
107
103
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- block %s is too old, peer=%d\n " , __func__,
108
104
qc.quorumHash .ToString (), peer.GetId ());
109
105
// TODO: enable punishment in some future version when all/most nodes are running with this fix
110
- // m_peerman->Misbehaving(peer.GetId(), 100) ;
111
- return ;
106
+ // return tl::unexpected{ 100} ;
107
+ return {} ;
112
108
}
113
109
if (HasMinedCommitment (type, qc.quorumHash )) {
114
110
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- commitment for quorum hash[%s], type[%d], quorumIndex[%d] is already mined, peer=%d\n " ,
115
111
__func__, qc.quorumHash .ToString (), ToUnderlying (type), qc.quorumIndex , peer.GetId ());
116
112
// NOTE: do not punish here
117
- return ;
113
+ return {} ;
118
114
}
119
115
}
120
116
@@ -127,7 +123,7 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
127
123
if (it != minableCommitmentsByQuorum.end ()) {
128
124
auto jt = minableCommitments.find (it->second );
129
125
if (jt != minableCommitments.end () && jt->second .CountSigners () <= qc.CountSigners ()) {
130
- return ;
126
+ return {} ;
131
127
}
132
128
}
133
129
}
@@ -136,14 +132,14 @@ void CQuorumBlockProcessor::ProcessMessage(const CNode& peer, std::string_view m
136
132
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- commitment for quorum %s:%d is not valid quorumIndex[%d] nversion[%d], peer=%d\n " ,
137
133
__func__, qc.quorumHash .ToString (),
138
134
ToUnderlying (qc.llmqType ), qc.quorumIndex , qc.nVersion , peer.GetId ());
139
- m_peerman->Misbehaving (peer.GetId (), 100 );
140
- return ;
135
+ return tl::unexpected{100 };
141
136
}
142
137
143
138
LogPrint (BCLog::LLMQ, " CQuorumBlockProcessor::%s -- received commitment for quorum %s:%d, validMembers=%d, signers=%d, peer=%d\n " , __func__,
144
139
qc.quorumHash .ToString (), ToUnderlying (qc.llmqType ), qc.CountValidMembers (), qc.CountSigners (), peer.GetId ());
145
140
146
141
AddMineableCommitment (qc);
142
+ return {};
147
143
}
148
144
149
145
bool CQuorumBlockProcessor::ProcessBlock (const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, BlockValidationState& state, bool fJustCheck , bool fBLSChecks )
0 commit comments