This commit is contained in:
Tim
2024-04-03 02:57:40 -04:00
parent 38cb5dfb01
commit 747d95739b
5 changed files with 17 additions and 13 deletions

View File

@@ -60,7 +60,7 @@ class Branch:
def __str__(self):
# noinspection PyTypeChecker
return (f"Branch#{str(self.id)[2:7]}[{self.height}" +
(':' if self.contiguous else '_') +
('_' if self.path else '') +
('<-'.join(hexstr(b)[2:7] for b in self.path) if self.path else f'{self.start}') +
(f':{self.start}' if self.disjoint else '') +
f'<-({hexstr(self.parent)[2:7]})]')

View File

@@ -176,7 +176,7 @@ class BlockState:
difflist = self.diffs_by_series.get(diff.series,{}).get(diff.key)
if difflist is not None:
difflist.remove(diff.entry)
state_log.info(('promoting' if remove_series_diffs else 'removed')+f' branch {branch}')
state_log.info(('removed' if remove_series_diffs else 'promoting')+f' branch {branch}')
def get(self, fork: Fork, series, key, default=NARG):
@@ -325,7 +325,7 @@ class BlockState:
pass
self.root_branch = fork.branch
state_log.info(f'promoted {self.root_branch.height} '+(hexstr(self.root_branch.path[0])[:7]+' ' if self.root_branch.path else '')+' '.join(str(b) for b in reversed(promotion_branches)))
# state_log.info(f'promoted {self.root_branch.height} '+(hexstr(self.root_branch.path[0])[:7]+' ' if self.root_branch.path else '')+' '.join(str(b) for b in reversed(promotion_branches)))
return diffs
# old code that would remove a series entirely upon promotion of the branch that deleted it

View File

@@ -149,6 +149,7 @@ async def handle_uniswap_swaps(swaps: list[EventData]):
async def handle_uniswap_swap(swap: EventData):
# todo gather prices first then apply only the value at the end of the block
data = await get_uniswap_data(swap)
if data is None:
return

View File

@@ -51,7 +51,7 @@ async def load_pool(address: str) -> PoolDict:
except ValueError as v:
try:
code = v.args[0].get('code')
except:
except Exception:
raise v
else:
if code == -32000:

View File

@@ -1,6 +1,6 @@
import asyncio
import logging
from asyncio import Event
from asyncio import Event, CancelledError
from datetime import timedelta
from typing import Any, Iterable, Callable, Optional
@@ -93,7 +93,7 @@ class BlockStateRunner(BlockProgressor):
await async_yield()
except (ConnectionClosedError, TimeoutError, asyncio.TimeoutError) as e:
log.debug(f'runner timeout {e}')
except:
except Exception:
log.exception(f'Unhandled exception during run_polling()')
finally:
# noinspection PyBroadException
@@ -134,7 +134,7 @@ class BlockStateRunner(BlockProgressor):
log.debug(f'runner timeout {e}')
except (ConnectionClosedError, TimeoutError) as e:
log.debug(f'runner timeout {e}')
except:
except Exception:
log.exception(f'Unhandled exception during run_polling()')
finally:
# noinspection PyBroadException
@@ -182,7 +182,7 @@ class BlockStateRunner(BlockProgressor):
if block.height - self.state.height >= chain.confirms * 2:
# create a disjoint backfilling branch
start = self.state.root_branch.height + 1
start = self.state.height + 1
# do not query more than the chain's batch size
# do not query into the reorgable area. only query finalized data.
height = min( start + chain.batch_size, block.height - chain.confirms)
@@ -226,8 +226,11 @@ class BlockStateRunner(BlockProgressor):
try:
if fork is not None:
await self.process(fork)
except:
log.exception('Reverting branch due to exception')
except BaseException as e:
if isinstance(e, Exception):
log.exception(f'Reverting {fork.branch} due to exception')
else:
log.info(f'Reverting {fork.branch} due to {e}')
self.state.remove_branch(fork.branch)
except Exception:
log.exception('Unhandled exception in runner worker')
@@ -307,7 +310,7 @@ class BlockStateRunner(BlockProgressor):
# todo try/except for known retryable errors
# noinspection PyCallingNonCallable
await maywait(callback(promotion_fork, diff_items))
except: # legitimately catch EVERYTHING because we re-raise
except Exception: # legitimately catch EVERYTHING because we re-raise
log.debug('rolling back session')
if session is not None:
session.rollback()
@@ -328,7 +331,7 @@ class BlockStateRunner(BlockProgressor):
# todo separate out the transaction manager completely from runner
try:
await create_and_send_transactions()
except:
except BaseException:
db.session.rollback()
raise
else:
@@ -357,7 +360,7 @@ class BlockStateRunner(BlockProgressor):
for callback in self.postprocess_cbs:
# noinspection PyCallingNonCallable
await maywait(callback())
except:
except BaseException:
session.rollback()
raise
else: