Skip to content

Commit e22897b

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 688b3ee commit e22897b

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
@@ -725,18 +725,19 @@ proc addBlock*(
725725
return self[].storeBackfillBlock(blck, sidecarsOpt)
726726

727727
let queueTick = Moment.now()
728+
729+
# If the lock is acquired already, the current block will be put on hold
730+
# meaning that we'll form an unbounded queue of blocks to be processed
731+
# waiting for the lock - this is similar to using an `AsyncQueue` but
732+
# without the copying and transition to/from `Forked`.
733+
# The lock is important to ensure that we don't process blocks out-of-order
734+
# which both would upset the `storeBlock` logic and cause unnecessary
735+
# quarantine traffic.
736+
self.pendingStores += 1
737+
await self.storeLock.acquire()
738+
728739
let res =
729740
try:
730-
# If the lock is acquired already, the current block will be put on hold
731-
# meaning that we'll form an unbounded queue of blocks to be processed
732-
# waiting for the lock - this is similar to using an `AsyncQueue` but
733-
# without the copying and transition to/from `Forked`.
734-
# The lock is important to ensure that we don't process blocks out-of-order
735-
# which both would upset the `storeBlock` logic and cause unnecessary
736-
# quarantine traffic.
737-
self.pendingStores += 1
738-
await self.storeLock.acquire()
739-
740741
# Since block processing is async, we want to make sure it doesn't get
741742
# (re)added there while we're busy - the start of processing also removes
742743
# the block from the various quarantines.

0 commit comments

Comments
 (0)