Don't increase banscore if the transaction only just expired.
Author: Jack Grigg <str4d@z.cash>
This commit is contained in:
parent
a0ea82301a
commit
473a113241
|
@ -97,7 +97,7 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Mininodes send transaction to zcashd node.
|
# Mininodes send transaction to zcashd node.
|
||||||
def setExpiryHeight(tx):
|
def setExpiryHeight(tx):
|
||||||
tx.nExpiryHeight = 1
|
tx.nExpiryHeight = 101
|
||||||
|
|
||||||
spendtx = self.create_transaction(self.nodes[0],
|
spendtx = self.create_transaction(self.nodes[0],
|
||||||
self.coinbase_blocks[0],
|
self.coinbase_blocks[0],
|
||||||
|
@ -114,6 +114,19 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
||||||
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||||
assert_equal(0, peerinfo[0]["banscore"])
|
assert_equal(0, peerinfo[0]["banscore"])
|
||||||
|
|
||||||
|
# Mine a block and resend the transaction
|
||||||
|
self.nodes[0].generate(1)
|
||||||
|
test_node.send_message(msg_tx(spendtx))
|
||||||
|
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# Verify test mininode has not been dropped
|
||||||
|
# but has a banscore of 10.
|
||||||
|
peerinfo = self.nodes[0].getpeerinfo()
|
||||||
|
versions = [x["version"] for x in peerinfo]
|
||||||
|
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||||
|
assert_equal(10, peerinfo[0]["banscore"])
|
||||||
|
|
||||||
[ c.disconnect_node() for c in connections ]
|
[ c.disconnect_node() for c in connections ]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -897,7 +897,9 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
||||||
|
|
||||||
// Check that all transactions are unexpired
|
// Check that all transactions are unexpired
|
||||||
if (IsExpiredTx(tx, nHeight)) {
|
if (IsExpiredTx(tx, nHeight)) {
|
||||||
return state.DoS(0, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired");
|
// Don't increase banscore if the transaction only just expired
|
||||||
|
int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? dosLevel : 0;
|
||||||
|
return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue