bugfixes
This commit is contained in:
@@ -60,7 +60,7 @@ class Branch:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
return (f"Branch#{str(self.id)[2:7]}[{self.height}" +
|
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}') +
|
('<-'.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':{self.start}' if self.disjoint else '') +
|
||||||
f'<-({hexstr(self.parent)[2:7]})]')
|
f'<-({hexstr(self.parent)[2:7]})]')
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class BlockState:
|
|||||||
difflist = self.diffs_by_series.get(diff.series,{}).get(diff.key)
|
difflist = self.diffs_by_series.get(diff.series,{}).get(diff.key)
|
||||||
if difflist is not None:
|
if difflist is not None:
|
||||||
difflist.remove(diff.entry)
|
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):
|
def get(self, fork: Fork, series, key, default=NARG):
|
||||||
@@ -325,7 +325,7 @@ class BlockState:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
self.root_branch = fork.branch
|
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
|
return diffs
|
||||||
|
|
||||||
# old code that would remove a series entirely upon promotion of the branch that deleted it
|
# old code that would remove a series entirely upon promotion of the branch that deleted it
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ async def handle_uniswap_swaps(swaps: list[EventData]):
|
|||||||
|
|
||||||
|
|
||||||
async def handle_uniswap_swap(swap: 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)
|
data = await get_uniswap_data(swap)
|
||||||
if data is None:
|
if data is None:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ async def load_pool(address: str) -> PoolDict:
|
|||||||
except ValueError as v:
|
except ValueError as v:
|
||||||
try:
|
try:
|
||||||
code = v.args[0].get('code')
|
code = v.args[0].get('code')
|
||||||
except:
|
except Exception:
|
||||||
raise v
|
raise v
|
||||||
else:
|
else:
|
||||||
if code == -32000:
|
if code == -32000:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from asyncio import Event
|
from asyncio import Event, CancelledError
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any, Iterable, Callable, Optional
|
from typing import Any, Iterable, Callable, Optional
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
await async_yield()
|
await async_yield()
|
||||||
except (ConnectionClosedError, TimeoutError, asyncio.TimeoutError) as e:
|
except (ConnectionClosedError, TimeoutError, asyncio.TimeoutError) as e:
|
||||||
log.debug(f'runner timeout {e}')
|
log.debug(f'runner timeout {e}')
|
||||||
except:
|
except Exception:
|
||||||
log.exception(f'Unhandled exception during run_polling()')
|
log.exception(f'Unhandled exception during run_polling()')
|
||||||
finally:
|
finally:
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
@@ -134,7 +134,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
log.debug(f'runner timeout {e}')
|
log.debug(f'runner timeout {e}')
|
||||||
except (ConnectionClosedError, TimeoutError) as e:
|
except (ConnectionClosedError, TimeoutError) as e:
|
||||||
log.debug(f'runner timeout {e}')
|
log.debug(f'runner timeout {e}')
|
||||||
except:
|
except Exception:
|
||||||
log.exception(f'Unhandled exception during run_polling()')
|
log.exception(f'Unhandled exception during run_polling()')
|
||||||
finally:
|
finally:
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
@@ -182,7 +182,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
|
|
||||||
if block.height - self.state.height >= chain.confirms * 2:
|
if block.height - self.state.height >= chain.confirms * 2:
|
||||||
# create a disjoint backfilling branch
|
# 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 more than the chain's batch size
|
||||||
# do not query into the reorgable area. only query finalized data.
|
# do not query into the reorgable area. only query finalized data.
|
||||||
height = min( start + chain.batch_size, block.height - chain.confirms)
|
height = min( start + chain.batch_size, block.height - chain.confirms)
|
||||||
@@ -226,8 +226,11 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
try:
|
try:
|
||||||
if fork is not None:
|
if fork is not None:
|
||||||
await self.process(fork)
|
await self.process(fork)
|
||||||
except:
|
except BaseException as e:
|
||||||
log.exception('Reverting branch due to exception')
|
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)
|
self.state.remove_branch(fork.branch)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('Unhandled exception in runner worker')
|
log.exception('Unhandled exception in runner worker')
|
||||||
@@ -307,7 +310,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
# todo try/except for known retryable errors
|
# todo try/except for known retryable errors
|
||||||
# noinspection PyCallingNonCallable
|
# noinspection PyCallingNonCallable
|
||||||
await maywait(callback(promotion_fork, diff_items))
|
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')
|
log.debug('rolling back session')
|
||||||
if session is not None:
|
if session is not None:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
@@ -328,7 +331,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
# todo separate out the transaction manager completely from runner
|
# todo separate out the transaction manager completely from runner
|
||||||
try:
|
try:
|
||||||
await create_and_send_transactions()
|
await create_and_send_transactions()
|
||||||
except:
|
except BaseException:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@@ -357,7 +360,7 @@ class BlockStateRunner(BlockProgressor):
|
|||||||
for callback in self.postprocess_cbs:
|
for callback in self.postprocess_cbs:
|
||||||
# noinspection PyCallingNonCallable
|
# noinspection PyCallingNonCallable
|
||||||
await maywait(callback())
|
await maywait(callback())
|
||||||
except:
|
except BaseException:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user