mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
feat: mnauth always use basic scheme
fixup: drop CChain from mnauth ProcessMessage feat: let RPC mnauth to generate only BASIC bls messages and fixes for rpc_mnauth.py and p2p_quorum_data.py refactor: drop unused ConstCBLSPublicKeyVersionWrapper
This commit is contained in:
parent
7c00c868d8
commit
09058e0d71
@ -309,21 +309,6 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstCBLSPublicKeyVersionWrapper {
|
|
||||||
private:
|
|
||||||
const CBLSPublicKey& obj;
|
|
||||||
bool legacy;
|
|
||||||
public:
|
|
||||||
ConstCBLSPublicKeyVersionWrapper(const CBLSPublicKey& obj, bool legacy)
|
|
||||||
: obj(obj)
|
|
||||||
, legacy(legacy)
|
|
||||||
{}
|
|
||||||
template <typename Stream>
|
|
||||||
inline void Serialize(Stream& s) const {
|
|
||||||
obj.Serialize(s, legacy);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CBLSPublicKeyVersionWrapper {
|
class CBLSPublicKeyVersionWrapper {
|
||||||
private:
|
private:
|
||||||
CBLSPublicKey& obj;
|
CBLSPublicKey& obj;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <bls/bls.h>
|
#include <bls/bls.h>
|
||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <deploymentstatus.h>
|
|
||||||
#include <evo/deterministicmns.h>
|
#include <evo/deterministicmns.h>
|
||||||
#include <llmq/utils.h>
|
#include <llmq/utils.h>
|
||||||
#include <masternode/meta.h>
|
#include <masternode/meta.h>
|
||||||
@ -19,8 +18,7 @@
|
|||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
|
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman)
|
||||||
const CBlockIndex* tip)
|
|
||||||
{
|
{
|
||||||
CMNAuth mnauth;
|
CMNAuth mnauth;
|
||||||
if (mn_activeman.GetProTxHash().IsNull()) {
|
if (mn_activeman.GetProTxHash().IsNull()) {
|
||||||
@ -41,9 +39,8 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
|
|||||||
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
||||||
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
|
||||||
auto pk = mn_activeman.GetPubKey();
|
auto pk = mn_activeman.GetPubKey();
|
||||||
const CBLSPublicKeyVersionWrapper pubKey(pk, !is_basic_scheme_active);
|
const CBLSPublicKey pubKey(pk);
|
||||||
uint256 signHash = [&]() {
|
uint256 signHash = [&]() {
|
||||||
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
|
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
|
||||||
return ::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn()));
|
return ::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn()));
|
||||||
@ -61,7 +58,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
|
|||||||
}
|
}
|
||||||
|
|
||||||
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||||
const CChain& active_chain, const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
||||||
std::string_view msg_type, CDataStream& vRecv)
|
std::string_view msg_type, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(mn_metaman.IsValid());
|
assert(mn_metaman.IsValid());
|
||||||
@ -106,9 +103,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CCon
|
|||||||
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
|
||||||
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
const CBlockIndex* tip = active_chain.Tip();
|
const CBLSPublicKey pubKey(dmn->pdmnState->pubKeyOperator.Get());
|
||||||
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
|
||||||
ConstCBLSPublicKeyVersionWrapper pubKey(dmn->pdmnState->pubKeyOperator.Get(), !is_basic_scheme_active);
|
|
||||||
// See comment in PushMNAUTH (fInbound is negated here as we're on the other side of the connection)
|
// 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) {
|
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
|
||||||
signHash = ::SerializeHash(std::make_tuple(pubKey, peer.GetSentMNAuthChallenge(), !peer.IsInboundConn()));
|
signHash = ::SerializeHash(std::make_tuple(pubKey, peer.GetSentMNAuthChallenge(), !peer.IsInboundConn()));
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
class CActiveMasternodeManager;
|
class CActiveMasternodeManager;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChain;
|
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CDataStream;
|
class CDataStream;
|
||||||
class CDeterministicMNList;
|
class CDeterministicMNList;
|
||||||
@ -50,15 +49,14 @@ public:
|
|||||||
READWRITE(obj.proRegTxHash, obj.sig);
|
READWRITE(obj.proRegTxHash, obj.sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
|
static void PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman);
|
||||||
const CBlockIndex* tip);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pre CMasternodeMetaMan's database must be successfully loaded before
|
* @pre CMasternodeMetaMan's database must be successfully loaded before
|
||||||
* attempting to call this function regardless of sync state
|
* attempting to call this function regardless of sync state
|
||||||
*/
|
*/
|
||||||
static PeerMsgRet ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
static PeerMsgRet ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||||
const CChain& active_chain, const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
|
||||||
std::string_view msg_type, CDataStream& vRecv);
|
std::string_view msg_type, CDataStream& vRecv);
|
||||||
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
||||||
};
|
};
|
||||||
|
@ -3784,7 +3784,7 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_masternode && !pfrom.m_masternode_probe_connection) {
|
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
|
// Tell our peer we prefer to receive headers rather than inv's
|
||||||
@ -5260,7 +5260,7 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||||
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
||||||
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, peer->m_their_services, m_connman, m_mn_metaman, m_mn_activeman, m_chainman.ActiveChain(), m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, peer->m_their_services, m_connman, m_mn_metaman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
||||||
PostProcessMessage(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom.GetId());
|
PostProcessMessage(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom.GetId());
|
||||||
ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, is_masternode, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, is_masternode, msg_type, vRecv), pfrom);
|
||||||
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <addressindex.h>
|
#include <addressindex.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <consensus/consensus.h>
|
#include <consensus/consensus.h>
|
||||||
#include <deploymentstatus.h>
|
|
||||||
#include <evo/mnauth.h>
|
#include <evo/mnauth.h>
|
||||||
#include <httpserver.h>
|
#include <httpserver.h>
|
||||||
#include <index/blockfilterindex.h>
|
#include <index/blockfilterindex.h>
|
||||||
@ -633,11 +632,8 @@ static RPCHelpMan mnauth()
|
|||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "proTxHash invalid");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "proTxHash invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
|
||||||
|
|
||||||
CBLSPublicKey publicKey;
|
CBLSPublicKey publicKey;
|
||||||
const bool bls_legacy_scheme{!DeploymentActiveAfter(chainman.ActiveChain().Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
publicKey.SetHexStr(request.params[2].get_str(), /*bls_legacy_scheme=*/false);
|
||||||
publicKey.SetHexStr(request.params[2].get_str(), bls_legacy_scheme);
|
|
||||||
if (!publicKey.IsValid()) {
|
if (!publicKey.IsValid()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "publicKey invalid");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "publicKey invalid");
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ ENCRYPTED_CONTRIBUTIONS_MISSING = 6
|
|||||||
|
|
||||||
# Used to overwrite MNAUTH for mininode connections
|
# Used to overwrite MNAUTH for mininode connections
|
||||||
fake_mnauth_1 = ["cecf37bf0ec05d2d22cb8227f88074bb882b94cd2081ba318a5a444b1b15b9fd",
|
fake_mnauth_1 = ["cecf37bf0ec05d2d22cb8227f88074bb882b94cd2081ba318a5a444b1b15b9fd",
|
||||||
"087ba00bf61135f3860c4944a0debabe186ef82628fbe4ceaed1ad51d672c58dde14ea4b321efe0b89257a40322bc972"]
|
"8e7afdb849e5e2a085b035b62e21c0940c753f2d4501325743894c37162f287bccaffbedd60c36581dabbf127a22e43f"]
|
||||||
fake_mnauth_2 = ["6ad7ed7a2d6c2c1db30fc364114602b36b2730a9aa96d8f11f1871a9cee37378",
|
fake_mnauth_2 = ["6ad7ed7a2d6c2c1db30fc364114602b36b2730a9aa96d8f11f1871a9cee37378",
|
||||||
"122463411a86362966a5161805f24cf6a0eef08a586b8e00c4f0ad0b084c5bb3f5c9a60ee5ffc78db2313897e3ab2223"]
|
"ad38860c03c3d1d875771f41b8a9b933415f72929c21a4276c101d8f0268f6fcdfeed46507c16c00e74f26ce1181e69f"]
|
||||||
|
|
||||||
# Used to distinguish mininode connections
|
# Used to distinguish mininode connections
|
||||||
uacomment_m3_1 = "MN3_1"
|
uacomment_m3_1 = "MN3_1"
|
||||||
@ -400,6 +400,7 @@ class QuorumDataMessagesTest(DashTestFramework):
|
|||||||
mn1.node.quorum, "getdata", 0, 100, quorum_hash, 0x03,
|
mn1.node.quorum, "getdata", 0, 100, quorum_hash, 0x03,
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000")
|
"0000000000000000000000000000000000000000000000000000000000000000")
|
||||||
|
|
||||||
|
self.activate_v19(expected_activation_height=900)
|
||||||
# Enable DKG and disable ChainLocks
|
# Enable DKG and disable ChainLocks
|
||||||
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
||||||
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800)
|
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800)
|
||||||
|
@ -20,12 +20,12 @@ class FakeMNAUTHTest(DashTestFramework):
|
|||||||
self.set_dash_test_params(2, 1)
|
self.set_dash_test_params(2, 1)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
self.activate_v19(expected_activation_height=900)
|
||||||
|
|
||||||
masternode = self.mninfo[0]
|
masternode = self.mninfo[0]
|
||||||
masternode.node.add_p2p_connection(P2PInterface())
|
masternode.node.add_p2p_connection(P2PInterface())
|
||||||
|
|
||||||
protx_hash = masternode.proTxHash
|
protx_hash = masternode.proTxHash
|
||||||
#TODO: Fix that with basic BLS
|
|
||||||
public_key = masternode.pubKeyOperator
|
public_key = masternode.pubKeyOperator
|
||||||
|
|
||||||
# The peerinfo should not yet contain verified_proregtx_hash/verified_pubkey_hash
|
# The peerinfo should not yet contain verified_proregtx_hash/verified_pubkey_hash
|
||||||
|
Loading…
Reference in New Issue
Block a user