Skip to content

Commit

Permalink
auto batch size (#5)
Browse files Browse the repository at this point in the history
* feat: auto step down batch size

* fix: bundle deps with pypi package
  • Loading branch information
BobTheBuidler authored May 18, 2022
1 parent f18f5e7 commit a4d81c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dank_mids/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ 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.')
else:
#raise
print(f"unexpected exception: {type(e)} {str(e)}")
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
author_email='bobthebuidlerdefi@gmail.com',
url='https://github.com/BobTheBuidler/dank_mids',
license='MIT',
install_requires=[
"bobs_lazy_logging>=0.0.4",
"multicall>=0.5.1",
]
setup_requires=[
'setuptools_scm',
],
Expand Down

0 comments on commit a4d81c6

Please sign in to comment.