From a4d81c63dfbc3fd8b2f06582e481e20cf9306c39 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 18 May 2022 04:38:00 -0400 Subject: [PATCH] auto batch size (#5) * feat: auto step down batch size * fix: bundle deps with pypi package --- dank_mids/controller.py | 3 +++ setup.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/dank_mids/controller.py b/dank_mids/controller.py index 69cb3698..27af69bc 100644 --- a/dank_mids/controller.py +++ b/dank_mids/controller.py @@ -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)}") diff --git a/setup.py b/setup.py index 59ead266..5e0d35cf 100644 --- a/setup.py +++ b/setup.py @@ -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', ],