mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 20:35:13 +00:00
verifier: need to wait for reorg
fixes race between verifier and block header download. scenario: client starts, connects to server. while client was offline, there was a reorg. txn A was not mined in the old chain, but is mined after reorg. client subscribes to addresses and starts downloading headers, concurrently. server tells client txn A is mined at height H >= reorg height. client sees it has block header at height H, asks for SPV proof for txn A. but the header the client has is still the old one, the verifier was faster than the block header download (race...). client receives proof. proof is incorrect for old header. client disconnects.
This commit is contained in:
parent
78e9152723
commit
819044221b
1 changed files with 3 additions and 1 deletions
|
@ -90,7 +90,9 @@ class SPV(ThreadJob):
|
|||
tx_height = merkle.get('block_height')
|
||||
pos = merkle.get('pos')
|
||||
merkle_branch = merkle.get('merkle')
|
||||
header = self.network.blockchain().read_header(tx_height)
|
||||
# we need to wait if header sync/reorg is still ongoing, hence lock:
|
||||
async with self.network.bhi_lock:
|
||||
header = self.network.blockchain().read_header(tx_height)
|
||||
try:
|
||||
verify_tx_is_in_block(tx_hash, merkle_branch, pos, header, tx_height)
|
||||
except MerkleVerificationFailure as e:
|
||||
|
|
Loading…
Add table
Reference in a new issue