Add comment in lieu of redundant overwinter version check & fix tests.
This also includes the following: commit b12adf605640abba4cef6ddab1a2797b12cbf454 Author: Kris Nuttycombe <kris.nuttycombe@gmail.com> Date: Mon Aug 24 16:01:18 2020 -0600 Add assertions to ensure that dependencies between active upgrades are respected. Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
4089e760fb
commit
bff5476a19
|
@ -311,7 +311,7 @@ TEST_F(ContextualCheckBlockTest, BlockOverwinterRulesRejectOtherTx) {
|
|||
|
||||
{
|
||||
SCOPED_TRACE("BlockOverwinterRulesRejectSproutTx");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set");
|
||||
}
|
||||
|
||||
// Make it a Sapling transaction
|
||||
|
@ -321,7 +321,7 @@ TEST_F(ContextualCheckBlockTest, BlockOverwinterRulesRejectOtherTx) {
|
|||
|
||||
{
|
||||
SCOPED_TRACE("BlockOverwinterRulesRejectSaplingTx");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "bad-overwinter-tx-version-group-id");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "bad-tx-overwinter-version-too-high");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ TEST_F(ContextualCheckBlockTest, BlockSaplingRulesRejectOtherTx) {
|
|||
|
||||
{
|
||||
SCOPED_TRACE("BlockSaplingRulesRejectSproutTx");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set");
|
||||
}
|
||||
|
||||
// Make it an Overwinter transaction
|
||||
|
@ -368,7 +368,7 @@ TEST_F(ContextualCheckBlockTest, BlockBlossomRulesRejectOtherTx) {
|
|||
|
||||
{
|
||||
SCOPED_TRACE("BlockBlossomRulesRejectSproutTx");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwinter-active");
|
||||
ExpectInvalidBlockFromTx(CTransaction(mtx), 100, "tx-overwintered-flag-not-set");
|
||||
}
|
||||
|
||||
// Make it an Overwinter transaction
|
||||
|
|
|
@ -947,7 +947,7 @@ TEST(ChecktransactionTests, OverwinterFlagNotSet) {
|
|||
|
||||
CTransaction tx(mtx);
|
||||
MockCValidationState state;
|
||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-flag-not-set", false)).Times(1);
|
||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwintered-flag-not-set", false)).Times(1);
|
||||
ContextualCheckTransaction(tx, state, Params(), 1, true);
|
||||
|
||||
// Revert to default
|
||||
|
|
|
@ -167,7 +167,7 @@ TEST(Mempool, SproutV3TxWhenOverwinterActive) {
|
|||
|
||||
LOCK(cs_main);
|
||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
||||
EXPECT_EQ(state1.GetRejectReason(), "tx-overwinter-flag-not-set");
|
||||
EXPECT_EQ(state1.GetRejectReason(), "tx-overwintered-flag-not-set");
|
||||
|
||||
// Revert to default
|
||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
|
||||
|
|
|
@ -796,6 +796,10 @@ bool ContextualCheckTransaction(
|
|||
bool heartwoodActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD);
|
||||
bool canopyActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY);
|
||||
|
||||
assert(!saplingActive || overwinterActive); // Sapling cannot be active unless Overwinter is
|
||||
assert(!heartwoodActive || saplingActive); // Heartwood cannot be active unless Sapling is
|
||||
assert(!canopyActive || heartwoodActive); // Canopy cannot be active unless Heartwood is
|
||||
|
||||
// Rules that apply only to Sprout
|
||||
if (beforeOverwinter) {
|
||||
// Reject transactions which are intended for Overwinter and beyond
|
||||
|
@ -817,6 +821,10 @@ bool ContextualCheckTransaction(
|
|||
REJECT_INVALID, "tx-overwintered-flag-not-set");
|
||||
}
|
||||
|
||||
// The condition `if (tx.nVersion < OVERWINTER_MIN_TX_VERSION)`
|
||||
// that would otherwise fire here is already performed in the
|
||||
// noncontextual checks in CheckTransactionWithoutProofVerification
|
||||
|
||||
// Check that all transactions are unexpired
|
||||
if (IsExpiredTx(tx, nHeight)) {
|
||||
// Don't increase banscore if the transaction only just expired
|
||||
|
|
Loading…
Reference in New Issue