Skip to content

Commit

Permalink
feat: mnauth always use basic scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Dec 8, 2024
1 parent 7c00c86 commit fb9fdf9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/evo/mnauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <bls/bls.h>
#include <chain.h>
#include <chainparams.h>
#include <deploymentstatus.h>
#include <evo/deterministicmns.h>
#include <llmq/utils.h>
#include <masternode/meta.h>
Expand All @@ -19,8 +18,7 @@
#include <util/time.h>
#include <validation.h>

void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
const CBlockIndex* tip)
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman)
{
CMNAuth mnauth;
if (mn_activeman.GetProTxHash().IsNull()) {
Expand All @@ -41,9 +39,8 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
}
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
auto pk = mn_activeman.GetPubKey();
const CBLSPublicKeyVersionWrapper pubKey(pk, !is_basic_scheme_active);
const CBLSPublicKey pubKey(pk);
uint256 signHash = [&]() {
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
return ::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn()));
Expand Down Expand Up @@ -106,9 +103,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CCon
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
}
const CBlockIndex* tip = active_chain.Tip();
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
ConstCBLSPublicKeyVersionWrapper pubKey(dmn->pdmnState->pubKeyOperator.Get(), !is_basic_scheme_active);
const CBLSPublicKey pubKey(dmn->pdmnState->pubKeyOperator.Get());
// See comment in PushMNAUTH (fInbound is negated here as we're on the other side of the connection)
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
signHash = ::SerializeHash(std::make_tuple(pubKey, peer.GetSentMNAuthChallenge(), !peer.IsInboundConn()));
Expand Down
3 changes: 1 addition & 2 deletions src/evo/mnauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class CMNAuth
READWRITE(obj.proRegTxHash, obj.sig);
}

static void PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
const CBlockIndex* tip);
static void PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman);

/**
* @pre CMasternodeMetaMan's database must be successfully loaded before
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3784,7 +3784,7 @@ void PeerManagerImpl::ProcessMessage(
}

if (is_masternode && !pfrom.m_masternode_probe_connection) {
CMNAuth::PushMNAUTH(pfrom, m_connman, *m_mn_activeman, m_chainman.ActiveChain().Tip());
CMNAuth::PushMNAUTH(pfrom, m_connman, *m_mn_activeman);
}

// Tell our peer we prefer to receive headers rather than inv's
Expand Down

0 comments on commit fb9fdf9

Please sign in to comment.