From c53e76011f37a1f8bd43a5a2e19cfa11f83a66db Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Mon, 5 Dec 2022 11:56:15 -0500 Subject: [PATCH] TEMP: Printing/logging for debug of client/SPVnode interactions. --- lbry/wallet/ledger.py | 13 +++++++++---- lbry/wallet/network.py | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 42499d2c6..800374f1b 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -30,6 +30,7 @@ from lbry.wallet.bip32 import PublicKey, PrivateKey from lbry.wallet.coinselection import CoinSelector log = logging.getLogger(__name__) +log.setLevel("DEBUG") LedgerType = Type['BaseLedger'] @@ -506,6 +507,7 @@ class Ledger(metaclass=LedgerRegistry): def process_status_update(self, update): address, remote_status = update + print(f"**** status update {address} {remote_status}") self._update_tasks.add(self.update_history(address, remote_status)) async def update_history(self, address, remote_status, address_manager: AddressManager = None, @@ -518,6 +520,7 @@ class Ledger(metaclass=LedgerRegistry): return True remote_history = await self.network.retriable_call(self.network.get_history, address) + print(f'>>>>>> {remote_history}') remote_history = list(map(itemgetter('tx_hash', 'height'), remote_history)) we_need = set(remote_history) - set(local_history) if not we_need: @@ -549,7 +552,7 @@ class Ledger(metaclass=LedgerRegistry): continue to_request[i] = (txid, remote_height) - log.debug( + log.warning( "request %i transactions, %i/%i for %s are already synced", len(to_request), len(already_synced), len(remote_history), address ) @@ -558,8 +561,8 @@ class Ledger(metaclass=LedgerRegistry): self.maybe_has_channel_key(tx) pending_synced_history[tx_indexes[tx.id]] = f"{tx.id}:{tx.height}:" if len(pending_synced_history) % 100 == 0: - log.info("Syncing address %s: %d/%d", address, len(pending_synced_history), len(to_request)) - log.info("Sync finished for address %s: %d/%d", address, len(pending_synced_history), len(to_request)) + log.warning("Syncing address %s: %d/%d", address, len(pending_synced_history), len(to_request)) + log.warning("Sync finished for address %s: %d/%d", address, len(pending_synced_history), len(to_request)) assert len(pending_synced_history) == len(remote_history), \ f"{len(pending_synced_history)} vs {len(remote_history)} for {address}" @@ -606,7 +609,7 @@ class Ledger(metaclass=LedgerRegistry): self._known_addresses_out_of_sync.add(address) return False else: - log.debug("finished syncing transaction history for %s, %i known txs", address, len(local_history)) + log.warning("finished syncing transaction history for %s, %i known txs", address, len(local_history)) return True async def maybe_verify_transaction(self, tx, remote_height, merkle=None): @@ -621,6 +624,8 @@ class Ledger(metaclass=LedgerRegistry): header = await self.headers.get(remote_height) tx.position = merkle['pos'] tx.is_verified = merkle_root == header['merkle_root'] + if not tx.is_verified: + print(f"&&&&&&& {tx.height}: {merkle_root} != {header['merkle_root']}") return tx def maybe_has_channel_key(self, tx): diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 55b8b145b..274cc18b1 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -76,7 +76,9 @@ class ClientSession(BaseClientSession): raise asyncio.TimeoutError if done: try: - return request.result() + result = request.result() + log.warning("sent %s%s to %s:%i (%i timeout) result: %s", method, tuple(args), self.server[0], self.server[1], self.timeout, result) + return result except ConnectionResetError: log.error( "wallet server (%s) reset connection upon our %s request, json of %i args is %i bytes", @@ -304,7 +306,7 @@ class Network: await client.ensure_server_version() return client except (asyncio.TimeoutError, ConnectionError, OSError, IncompatibleWalletServerError, RPCError): - log.warning("Connecting to %s:%d failed", host, port) + log.exception("Connecting to %s:%d failed", host, port) client._close() return @@ -328,7 +330,8 @@ class Network: features = await client.send_request('server.features', []) self.client, self.server_features = client, features log.debug("discover other hubs %s:%i", *client.server) - await self._update_hubs(await client.send_request('server.peers.subscribe', [])) + # TODO: Enable this after herald.go supports 'server.peers.subscribe'. + #await self._update_hubs(await client.send_request('server.peers.subscribe', [])) log.info("subscribe to headers %s:%i", *client.server) self._update_remote_height((await self.subscribe_headers(),)) self._on_connected_controller.add(True)