Skip to content

Commit 80bad2e

Browse files
committed
fix late acquire
Although it has no practical impact on the processor (except if `addBlock` were cancelled, which it never is), the `acquire` should be outside the `finally` (since obvisouly, if it were cancelled it will not be acquired and therefore shouldn't be released)
1 parent 9b2e81e commit 80bad2e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

beacon_chain/gossip_processing/block_processor.nim

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -755,18 +755,19 @@ proc addBlock*(
755755
return self[].storeBackfillBlock(blck, sidecarsOpt)
756756

757757
let queueTick = Moment.now()
758+
759+
# If the lock is acquired already, the current block will be put on hold
760+
# meaning that we'll form an unbounded queue of blocks to be processed
761+
# waiting for the lock - this is similar to using an `AsyncQueue` but
762+
# without the copying and transition to/from `Forked`.
763+
# The lock is important to ensure that we don't process blocks out-of-order
764+
# which both would upset the `storeBlock` logic and cause unnecessary
765+
# quarantine traffic.
766+
self.pendingStores += 1
767+
await self.storeLock.acquire()
768+
758769
let res =
759770
try:
760-
# If the lock is acquired already, the current block will be put on hold
761-
# meaning that we'll form an unbounded queue of blocks to be processed
762-
# waiting for the lock - this is similar to using an `AsyncQueue` but
763-
# without the copying and transition to/from `Forked`.
764-
# The lock is important to ensure that we don't process blocks out-of-order
765-
# which both would upset the `storeBlock` logic and cause unnecessary
766-
# quarantine traffic.
767-
self.pendingStores += 1
768-
await self.storeLock.acquire()
769-
770771
# Cooperative concurrency: one block per loop iteration - because
771772
# we run both networking and CPU-heavy things like block processing
772773
# on the same thread, we need to make sure that there is steady progress

0 commit comments

Comments
 (0)