Skip to content

Commit 62c56f4

Browse files
committed
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.
1 parent 5d7cd6b commit 62c56f4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

qa/rpc-tests/feature_fedpeg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def setup_network(self, split=False):
9797
'-peginconfirmationdepth=10',
9898
'-mainchainrpchost=127.0.0.1',
9999
'-mainchainrpcport=%s' % rpc_port(n),
100+
'-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout
100101
]
101102
if not self.options.parent_bitcoin:
102103
args.extend([
@@ -319,12 +320,13 @@ def run_test(self):
319320
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], binary=self.binary, chain=self.parent_chain, cookie_auth=True)
320321
parent2 = self.nodes[1]
321322
connect_nodes_bi(self.nodes, 0, 1)
322-
time.sleep(5)
323323

324324
# Don't make a block, race condition when pegin-invalid block
325325
# is awaiting further validation, nodes reject subsequent blocks
326326
# even ones they create
327+
print("Now waiting for node to re-evaluate peg-in witness failed block... should take a few seconds")
327328
self.sync_all()
329+
print("Completed!\n")
328330
print("Now send funds out in two stages, partial, and full")
329331
some_btc_addr = get_new_unconfidential_address(parent)
330332
bal_1 = sidechain.getwalletinfo()["balance"]["bitcoin"]

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
18701870
if (tx.vin[i].m_is_pegin) {
18711871
// Check existence and validity of pegin witness
18721872
if (tx.wit.vtxinwit.size() <= i || !IsValidPeginWitness(tx.wit.vtxinwit[i].m_pegin_witness, prevout)) {
1873-
return state.DoS(0, false, REJECT_PEGIN, "bad-pegin-witness", true);
1873+
return state.DoS(0, false, REJECT_PEGIN, "bad-pegin-witness");
18741874
}
18751875
std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.wit.vtxinwit[i].m_pegin_witness.stack[2]), prevout);
18761876
if (inputs.IsWithdrawSpent(pegin)) {

0 commit comments

Comments
 (0)