Skip to content

Commit 8f2194c

Browse files
committed
Enable pak enforcement at mempool/block level when appropriate
1 parent fac525b commit 8f2194c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/validation.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,13 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
608608
if (fRequireStandard && !IsStandardTx(tx, reason))
609609
return state.DoS(0, false, REJECT_NONSTANDARD, reason);
610610

611+
// And now do PAK checks. Filtered by next blocks' enforced list
612+
if (chainparams.GetEnforcePak()) {
613+
if (!IsPAKValidTx(tx, GetActivePAKList(chainActive.Tip(), chainparams.GetConsensus()))) {
614+
return state.DoS(0, false, REJECT_NONSTANDARD, "invalid-pegout-proof");
615+
}
616+
}
617+
611618
// Do not work on transactions that are too small.
612619
// A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes.
613620
// Transactions smaller than this are not relayed to reduce unnecessary malloc overhead.
@@ -2117,6 +2124,18 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
21172124
txdata.reserve(block.vtx.size()); // Required so that pointers to individual PrecomputedTransactionData don't get invalidated
21182125

21192126
// ELEMENTS:
2127+
2128+
// Enforce PAK post-dynafed
2129+
if (chainparams.GetEnforcePak() && !block.m_dyna_params.IsNull()) {
2130+
// GetActivePAKList computes for the following block, so use previous index
2131+
CPAKList paklist = GetActivePAKList(pindex->pprev, chainparams.GetConsensus());
2132+
for (const auto& tx : block.vtx) {
2133+
if (!IsPAKValidTx(*tx, paklist)) {
2134+
return state.DoS(100, error("ConnectBlock(): Bad PAK transaction"), REJECT_INVALID, "bad-pak-tx");
2135+
}
2136+
}
2137+
}
2138+
21202139
// Used when ConnectBlock() results are unneeded for mempool ejection
21212140
std::set<std::pair<uint256, COutPoint>> setPeginsSpentDummy;
21222141

0 commit comments

Comments
 (0)