Skip to content

Commit 25410e1

Browse files
committed
evo: prohibit any ProTx with legacy BLS version after basic BLS upgrade
Even though only ProUpRegTx updates the operator key field, it is not good policy to allow transactions that don't use the version that defines the masternode's currently active key scheme or higher.
1 parent ee34525 commit 25410e1

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/evo/deterministicmns.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,11 +1422,18 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
14221422
}
14231423

14241424
auto mnList = dmnman.GetListForBlock(pindexPrev);
1425-
auto mn = mnList.GetMN(opt_ptx->proTxHash);
1426-
if (!mn) {
1425+
auto dmn = mnList.GetMN(opt_ptx->proTxHash);
1426+
if (!dmn) {
14271427
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-hash");
14281428
}
14291429

1430+
const bool is_v23_active{DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V23)};
1431+
1432+
// Don't allow legacy scheme versioned transactions after upgrading to basic scheme
1433+
if (is_v23_active && dmn->pdmnState->nVersion >= ProTxVersion::BasicBLS && opt_ptx->nVersion == ProTxVersion::LegacyBLS) {
1434+
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version-downgrade");
1435+
}
1436+
14301437
// don't allow updating to addresses already used by other MNs
14311438
for (const NetInfoEntry& entry : opt_ptx->netInfo.GetEntries()) {
14321439
if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) {
@@ -1447,7 +1454,7 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
14471454
}
14481455

14491456
if (opt_ptx->scriptOperatorPayout != CScript()) {
1450-
if (mn->nOperatorReward == 0) {
1457+
if (dmn->nOperatorReward == 0) {
14511458
// don't allow setting operator reward payee in case no operatorReward was set
14521459
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-operator-payee");
14531460
}
@@ -1461,7 +1468,7 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
14611468
// pass the state returned by the function above
14621469
return false;
14631470
}
1464-
if (check_sigs && !CheckHashSig(*opt_ptx, mn->pdmnState->pubKeyOperator.Get(), state)) {
1471+
if (check_sigs && !CheckHashSig(*opt_ptx, dmn->pdmnState->pubKeyOperator.Get(), state)) {
14651472
// pass the state returned by the function above
14661473
return false;
14671474
}
@@ -1489,6 +1496,13 @@ bool CheckProUpRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gs
14891496
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-hash");
14901497
}
14911498

1499+
const bool is_v23_active{DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V23)};
1500+
1501+
// Don't allow legacy scheme versioned transactions after upgrading to basic scheme
1502+
if (is_v23_active && dmn->pdmnState->nVersion >= ProTxVersion::BasicBLS && opt_ptx->nVersion == ProTxVersion::LegacyBLS) {
1503+
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version-downgrade");
1504+
}
1505+
14921506
// don't allow reuse of payee key for other keys (don't allow people to put the payee key onto an online server)
14931507
if (payoutDest == CTxDestination(PKHash(dmn->pdmnState->keyIDOwner)) || payoutDest == CTxDestination(PKHash(opt_ptx->keyIDVoting))) {
14941508
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-payee-reuse");
@@ -1544,8 +1558,16 @@ bool CheckProUpRevTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gs
15441558

15451559
auto mnList = dmnman.GetListForBlock(pindexPrev);
15461560
auto dmn = mnList.GetMN(opt_ptx->proTxHash);
1547-
if (!dmn)
1561+
if (!dmn) {
15481562
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-hash");
1563+
}
1564+
1565+
const bool is_v23_active{DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V23)};
1566+
1567+
// Don't allow legacy scheme versioned transactions after upgrading to basic scheme
1568+
if (is_v23_active && dmn->pdmnState->nVersion >= ProTxVersion::BasicBLS && opt_ptx->nVersion == ProTxVersion::LegacyBLS) {
1569+
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version-downgrade");
1570+
}
15491571

15501572
if (!CheckInputsHash(tx, *opt_ptx, state)) {
15511573
// pass the state returned by the function above

0 commit comments

Comments
 (0)