Skip to content

Commit

Permalink
fix: batch size step-down race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Jul 18, 2022
1 parent 93956b6 commit bb5616b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dank_mids/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,13 @@ async def process_batch(self, batch: List, block: str, bid: Optional[int] = None
main_logger.debug('out of gas. cut in half, trying again')
elif any(err in str(e).lower() for err in ["connection reset by peer","request entity too large","server disconnected"]):
main_logger.debug('dank too loud, trying again')
old_step = self.batcher.step
self.batcher.step = round(len(inputs) * 0.99) if len(inputs) >= 100 else len(inputs) - 1
main_logger.warning(f'Multicall batch size reduced from {old_step} to {self.batcher.step}. The failed batch had {len(inputs)} calls.')
new_step = round(len(inputs) * 0.99) if len(inputs) >= 100 else len(inputs) - 1
# We need this check because one of the other multicalls in a batch might have already reduced `self.batcher.step`
if new_step < self.batcher.step:
old_step = self.batcher.step
self.batcher.step = new_step
main_logger.warning(f'Multicall batch size reduced from {old_step} to {new_step}. The failed batch had {len(inputs)} calls.')
else:
#raise
print(f"unexpected exception: {type(e)} {str(e)}")

batches = [[cid, input] for cid, input in zip(cids, inputs)]
Expand Down

0 comments on commit bb5616b

Please sign in to comment.