Skip to content

Commit f87034e

Browse files
committed
Do not apply RDTS rules to the coinbase outputs on signet
1 parent eda185e commit f87034e

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/consensus/tx_verify.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,18 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
161161
return nSigOps;
162162
}
163163

164-
bool Consensus::CheckOutputSizes(const CTransaction& tx, TxValidationState& state)
164+
bool Consensus::CheckOutputSizes(const CTransaction& tx, TxValidationState& state, bool is_signet)
165165
{
166166
for (const auto& txout : tx.vout) {
167167
if (txout.scriptPubKey.empty()) continue;
168-
if (txout.scriptPubKey.size() > ((txout.scriptPubKey[0] == OP_RETURN) ? MAX_OUTPUT_DATA_SIZE : MAX_OUTPUT_SCRIPT_SIZE)) {
168+
if (txout.scriptPubKey[0] == OP_RETURN) {
169+
if (txout.scriptPubKey.size() > MAX_OUTPUT_DATA_SIZE) {
170+
if (tx.IsCoinBase() && is_signet) {
171+
continue;
172+
}
173+
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "bad-txns-vout-script-toolarge");
174+
}
175+
} else if (txout.scriptPubKey.size() > MAX_OUTPUT_SCRIPT_SIZE) {
169176
return state.Invalid(TxValidationResult::TX_PREMATURE_SPEND, "bad-txns-vout-script-toolarge");
170177
}
171178
}
@@ -181,7 +188,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,
181188
}
182189

183190
// NOTE: CheckTransaction is arguably the more logical place to do this, but it's context-independent, so this is probably the next best place for now
184-
if (rules.test(CheckTxInputsRules::OutputSizeLimit) && !CheckOutputSizes(tx, state)) {
191+
if (rules.test(CheckTxInputsRules::OutputSizeLimit) && !CheckOutputSizes(tx, state, rules.test(CheckTxInputsRules::SignetCoinbaseExemption))) {
185192
return false;
186193
}
187194

src/consensus/tx_verify.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CheckTxInputsRules {
2525
enum class Rule {
2626
None = 0,
2727
OutputSizeLimit = 1 << 0,
28+
SignetCoinbaseExemption = 1 << 1,
2829
};
2930

3031
public:
@@ -47,7 +48,7 @@ namespace Consensus {
4748
* Regular outputs must be <= MAX_OUTPUT_SCRIPT_SIZE (34 bytes).
4849
* OP_RETURN outputs must be <= MAX_OUTPUT_DATA_SIZE (83 bytes).
4950
*/
50-
[[nodiscard]] bool CheckOutputSizes(const CTransaction& tx, TxValidationState& state);
51+
[[nodiscard]] bool CheckOutputSizes(const CTransaction& tx, TxValidationState& state, bool is_signet = false);
5152

5253
/**
5354
* Check whether all inputs of this transaction are valid (no double spends and amounts)

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
987987
// The mempool holds txs for the next block, so pass height+1 to CheckTxInputs
988988
const auto block_height_current = m_active_chainstate.m_chain.Height();
989989
const auto block_height_next = block_height_current + 1;
990-
if (!Consensus::CheckTxInputs(tx, state, m_view, block_height_next, ws.m_base_fees, CheckTxInputsRules::OutputSizeLimit)) {
990+
if (!Consensus::CheckTxInputs(tx, state, m_view, block_height_next, ws.m_base_fees, CheckTxInputsRules{CheckTxInputsRules::OutputSizeLimit} | CheckTxInputsRules{args.m_chainparams.GetConsensus().signet_blocks ? CheckTxInputsRules::SignetCoinbaseExemption : CheckTxInputsRules::None})) {
991991
return false; // state filled in by CheckTxInputs
992992
}
993993

@@ -2903,12 +2903,12 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
29032903
? m_chainman.m_versionbitscache.StateSinceHeight(pindex->pprev, params.GetConsensus(), Consensus::DEPLOYMENT_REDUCED_DATA)
29042904
: std::numeric_limits<int>::max();
29052905

2906-
const CheckTxInputsRules chk_input_rules{DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_REDUCED_DATA) ? CheckTxInputsRules::OutputSizeLimit : CheckTxInputsRules::None};
2906+
const CheckTxInputsRules chk_input_rules{CheckTxInputsRules{DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_REDUCED_DATA) ? CheckTxInputsRules::OutputSizeLimit : CheckTxInputsRules::None} | CheckTxInputsRules{params.GetConsensus().signet_blocks ? CheckTxInputsRules::SignetCoinbaseExemption : CheckTxInputsRules::None}};
29072907

29082908
// Check generation tx output sizes if REDUCED_DATA is active
29092909
if (chk_input_rules.test(CheckTxInputsRules::OutputSizeLimit)) {
29102910
TxValidationState tx_state;
2911-
if (!Consensus::CheckOutputSizes(*block.vtx[0], tx_state)) {
2911+
if (!Consensus::CheckOutputSizes(*block.vtx[0], tx_state, params.GetConsensus().signet_blocks)) {
29122912
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
29132913
tx_state.GetRejectReason(),
29142914
tx_state.GetDebugMessage() + " in generation tx " + block.vtx[0]->GetHash().ToString());

0 commit comments

Comments
 (0)