don't set CorruptionPossible for peg-in transaction failure

Previously the peg-in validation logic was done in script
which means it was handled correctly by mempool/block logic.

We then moved these checks outside of script, which means
that these checks aren't multithreaded/batched, and return
the specific error states, including CorruptionPossible.

This means that blocks are never considered permanently invalid and
in certain circumstances tried in an infinite loop.

Instead we mark it as a normal failure, and allow the peg-in invalid
block queue to take care of it instead.
This commit is contained in:
Gregory Sanders 2018-09-28 18:25:07 -04:00
parent 5d7cd6b843
commit 62c56f446a
2 changed files with 4 additions and 2 deletions

View file

@ -97,6 +97,7 @@ class FedPegTest(BitcoinTestFramework):
'-peginconfirmationdepth=10',
'-mainchainrpchost=127.0.0.1',
'-mainchainrpcport=%s' % rpc_port(n),
'-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout
]
if not self.options.parent_bitcoin:
args.extend([
@ -319,12 +320,13 @@ class FedPegTest(BitcoinTestFramework):
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], binary=self.binary, chain=self.parent_chain, cookie_auth=True)
parent2 = self.nodes[1]
connect_nodes_bi(self.nodes, 0, 1)
time.sleep(5)
# Don't make a block, race condition when pegin-invalid block
# is awaiting further validation, nodes reject subsequent blocks
# even ones they create
print("Now waiting for node to re-evaluate peg-in witness failed block... should take a few seconds")
self.sync_all()
print("Completed!\n")
print("Now send funds out in two stages, partial, and full")
some_btc_addr = get_new_unconfidential_address(parent)
bal_1 = sidechain.getwalletinfo()["balance"]["bitcoin"]

View file

@ -1870,7 +1870,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
if (tx.vin[i].m_is_pegin) {
// Check existence and validity of pegin witness
if (tx.wit.vtxinwit.size() <= i || !IsValidPeginWitness(tx.wit.vtxinwit[i].m_pegin_witness, prevout)) {
return state.DoS(0, false, REJECT_PEGIN, "bad-pegin-witness", true);
return state.DoS(0, false, REJECT_PEGIN, "bad-pegin-witness");
}
std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.wit.vtxinwit[i].m_pegin_witness.stack[2]), prevout);
if (inputs.IsWithdrawSpent(pegin)) {