Added block-list command to enqueue a list of blocks from stdin

This commit is contained in:
Ryan Radomski 2022-01-13 21:59:59 +00:00
parent a93161eabc
commit a0152bc8f2
4 changed files with 26 additions and 0 deletions

View File

@ -148,6 +148,16 @@ For messages permanently failed in the dead letter queue (XQ), query:
HGETALL dramatiq:default.XQ.msgs
```
To query a list of missing blocks in a range, run:
```
psql postgresql://postgres:password@localhost:5432/mev_inspect -c "select generate_series(13999471, 13999571) EXCEPT (select distinct block_number from blocks)" --csv -t
```
To backfill missing blocks in a range, run:
```
psql postgresql://postgres:password@localhost:5432/mev_inspect -c "select generate_series(13999471, 13999571) EXCEPT (select distinct block_number from blocks)" --csv -t | ./mev block-list
```
For more information on queues, see the [spec shared by dramatiq](https://github.com/Bogdanp/dramatiq/blob/24cbc0dc551797783f41b08ea461e1b5d23a4058/dramatiq/brokers/redis/dispatch.lua#L24-L43)

11
cli.py
View File

@ -1,6 +1,7 @@
import logging
import os
import sys
import fileinput
import click
@ -90,6 +91,16 @@ async def inspect_many_blocks_command(
before_block=before_block,
)
@cli.command()
def enqueue_block_list_command():
from worker import ( # pylint: disable=import-outside-toplevel
inspect_many_blocks_task,
)
for block_string in fileinput.input():
block = int(block_string)
logger.info(f"Sending {block} to {block+1}")
inspect_many_blocks_task.send(block, block+1)
@cli.command()
@click.argument("after_block", type=int)

4
mev
View File

@ -45,6 +45,10 @@ case "$1" in
listener)
kubectl exec -ti deploy/mev-inspect -- ./listener $2
;;
block-list)
echo "Backfilling blocks from stdin"
kubectl exec -ti deploy/mev-inspect -- poetry run enqueue-block-list
;;
backfill)
start_block_number=$2
end_block_number=$3

View File

@ -36,6 +36,7 @@ build-backend = "poetry.core.masonry.api"
inspect-block = 'cli:inspect_block_command'
inspect-many-blocks = 'cli:inspect_many_blocks_command'
enqueue-many-blocks = 'cli:enqueue_many_blocks_command'
enqueue-block-list = 'cli:enqueue_block_list_command'
fetch-block = 'cli:fetch_block_command'
fetch-all-prices = 'cli:fetch_all_prices'