ZIP 244: Address review comments

This commit is contained in:
Jack Grigg 2022-02-17 18:36:52 +00:00
parent e9625d2483
commit 4eee55d4de
3 changed files with 10 additions and 9 deletions

View File

@ -1319,8 +1319,8 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
// sighash the txid.
PrecomputedTransactionData txdata(tx, {});
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-sapling-binding-signature-invalid", false, "")).Times(1);
ContextualCheckShieldedInputs(
tx, txdata, state, orchardAuth, chainparams.GetConsensus(), heartwoodBranchId, false, true);
EXPECT_FALSE(ContextualCheckShieldedInputs(
tx, txdata, state, orchardAuth, chainparams.GetConsensus(), heartwoodBranchId, false, true));
RegtestDeactivateHeartwood();
}

View File

@ -75,8 +75,9 @@ TEST(SigHashTest, Zip244RejectsUnknownHashTypes) {
CAmount amount;
uint32_t consensusBranchId;
// Nothing should be thrown for known sighash types.
// An error should be thrown for unknown sighash types.
std::vector<uint8_t> unknownSighashTypes {
0, // Known in BIP 341, unknown in ZIP 244.
SIGHASH_SINGLE + 1,
0x7f,
0xff,

View File

@ -1265,7 +1265,7 @@ bool ContextualCheckShieldedInputs(
} catch (std::logic_error ex) {
// A logic error should never occur because we pass NOT_AN_INPUT and
// SIGHASH_ALL to SignatureHash().
return state.DoS(100, error("ContextualCheckTransaction(): error computing signature hash"),
return state.DoS(100, error("ContextualCheckShieldedInputs(): error computing signature hash"),
REJECT_INVALID, "error-computing-signature-hash");
}
}
@ -1289,7 +1289,7 @@ bool ContextualCheckShieldedInputs(
}
return state.DoS(
dosLevelPotentiallyRelaxing,
error("ContextualCheckTransaction(): invalid joinsplit signature"),
error("ContextualCheckShieldedInputs(): invalid joinsplit signature"),
REJECT_INVALID, "bad-txns-invalid-joinsplit-signature");
}
}
@ -1319,7 +1319,7 @@ bool ContextualCheckShieldedInputs(
librustzcash_sapling_verification_ctx_free(ctx);
return state.DoS(
dosLevelPotentiallyRelaxing,
error("ContextualCheckTransaction(): Sapling spend description invalid"),
error("ContextualCheckShieldedInputs(): Sapling spend description invalid"),
REJECT_INVALID, "bad-txns-sapling-spend-description-invalid");
}
}
@ -1337,7 +1337,7 @@ bool ContextualCheckShieldedInputs(
// This should be a non-contextual check, but we check it here
// as we need to pass over the outputs anyway in order to then
// call librustzcash_sapling_final_check().
return state.DoS(100, error("ContextualCheckTransaction(): Sapling output description invalid"),
return state.DoS(100, error("ContextualCheckShieldedInputs(): Sapling output description invalid"),
REJECT_INVALID, "bad-txns-sapling-output-description-invalid");
}
}
@ -1352,7 +1352,7 @@ bool ContextualCheckShieldedInputs(
librustzcash_sapling_verification_ctx_free(ctx);
return state.DoS(
dosLevelPotentiallyRelaxing,
error("ContextualCheckTransaction(): Sapling binding signature invalid"),
error("ContextualCheckShieldedInputs(): Sapling binding signature invalid"),
REJECT_INVALID, "bad-txns-sapling-binding-signature-invalid");
}
@ -1973,7 +1973,7 @@ bool AcceptToMemoryPool(
}
// Check against previous transactions
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
// This is done near the end to help prevent CPU exhaustion denial-of-service attacks.
std::vector<CTxOut> allPrevOutputs;
for (const auto& input : tx.vin) {
allPrevOutputs.push_back(view.GetOutputFor(input));