Skip to content

Commit

Permalink
ignore missing scale types, nicer node log
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 16, 2025
1 parent 8a14da4 commit 9dca759
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/dipdup/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# NOTE: All imports except the basic ones are very lazy in this module. Let's keep it that way.
import asyncio
import atexit
from collections import defaultdict
import logging
import sys
import traceback
from collections import defaultdict
from collections.abc import Callable
from collections.abc import Coroutine
from contextlib import AsyncExitStack
Expand Down Expand Up @@ -979,12 +979,14 @@ async def self_env(ctx: click.Context) -> None:
env.refresh()
env.print()


@cli.group(hidden=True)
@click.pass_context
@_cli_wrapper
async def abi(ctx: click.Context) -> None:
pass


@abi.command(name='lookup', hidden=True)
@click.pass_context
@click.argument('query', type=str)
Expand All @@ -1006,7 +1008,7 @@ async def abi_lookup(ctx: click.Context, query: str) -> None:
res = subprocess.run(
('grep', '-n', '-r', query, *abi_paths),
capture_output=True,
check=True,
check=False,
)
out = res.stdout.decode()
lines = out.splitlines()
Expand All @@ -1022,6 +1024,7 @@ async def abi_lookup(ctx: click.Context, query: str) -> None:
echo('- ' + line)
echo('')


@cli.group()
@click.pass_context
@_cli_wrapper
Expand Down
9 changes: 6 additions & 3 deletions src/dipdup/datasources/substrate_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ async def run(self) -> None:
await asyncio.sleep(self._http_config.polling_interval)

async def initialize(self) -> None:
version_info = await self._interface.rpc_request('system_version', [])
self._logger.info('running version %s', version_info['result'])

level = await self.get_head_level()
self.set_sync_level(None, level)

# NOTE: Prepare substrate_interface
await self._interface.init_props() # type: ignore[no-untyped-call]
self._interface.reload_type_registry()

self._logger.info(
'connected to %s (%s)',
self._interface.chain,
self._interface.version,
)

@cached_property
def _interface(self) -> 'SubstrateInterface':
from dipdup.datasources._aiosubstrate import SubstrateInterfaceProxy
Expand Down
13 changes: 9 additions & 4 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,15 @@ def decode_event_args(
value_len = len(value[2:]) * 2
value = f'0x{value_len:02x}{value[2:]}'

scale_obj = self.runtime_config.create_scale_object(
type_string=type_,
data=ScaleBytes(value) if isinstance(value, str) else value,
)
try:
scale_obj = self.runtime_config.create_scale_object(
type_string=type_,
data=ScaleBytes(value) if isinstance(value, str) else value,
)
except NotImplementedError:
_logger.error('unsupported type `%s`', type_)
payload[key] = value
continue

payload[key] = scale_obj.process()

Expand Down

0 comments on commit 9dca759

Please sign in to comment.