diff --git a/hathor/builder/cli_builder.py b/hathor/builder/cli_builder.py index 9581be9fd..2d7cf1372 100644 --- a/hathor/builder/cli_builder.py +++ b/hathor/builder/cli_builder.py @@ -309,6 +309,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager: feature_service=self.feature_service, pubsub=pubsub, wallet=self.wallet, + log_vertex_bytes=self._args.log_vertex_bytes, ) self.manager = HathorManager( diff --git a/hathor/cli/run_node.py b/hathor/cli/run_node.py index 166c7cef6..32f5848f9 100644 --- a/hathor/cli/run_node.py +++ b/hathor/cli/run_node.py @@ -151,6 +151,8 @@ def create_parser(cls) -> ArgumentParser: # XXX: this is temporary, should be added as a sysctl instead before merging parser.add_argument('--x-ipython-kernel', action='store_true', help='Launch embedded IPython kernel for remote debugging') + parser.add_argument('--log-vertex-bytes', action='store_true', + help='Log tx bytes for debugging') return parser def prepare(self, *, register_resources: bool = True) -> None: diff --git a/hathor/cli/run_node_args.py b/hathor/cli/run_node_args.py index 1d161cecf..c67aaeebb 100644 --- a/hathor/cli/run_node_args.py +++ b/hathor/cli/run_node_args.py @@ -79,3 +79,4 @@ class RunNodeArgs(BaseModel, extra=Extra.allow): x_asyncio_reactor: bool x_ipython_kernel: bool nano_testnet: bool + log_vertex_bytes: bool diff --git a/hathor/vertex_handler/vertex_handler.py b/hathor/vertex_handler/vertex_handler.py index 5bcbc1369..0ef601aa0 100644 --- a/hathor/vertex_handler/vertex_handler.py +++ b/hathor/vertex_handler/vertex_handler.py @@ -45,6 +45,7 @@ class VertexHandler: '_feature_service', '_pubsub', '_wallet', + '_log_vertex_bytes', ) def __init__( @@ -59,6 +60,7 @@ def __init__( feature_service: FeatureService, pubsub: PubSubManager, wallet: BaseWallet | None, + log_vertex_bytes: bool = False, ) -> None: self._log = logger.new() self._reactor = reactor @@ -70,6 +72,7 @@ def __init__( self._feature_service = feature_service self._pubsub = pubsub self._wallet = wallet + self._log_vertex_bytes = log_vertex_bytes def on_new_vertex( self, @@ -223,6 +226,8 @@ def _log_new_object(self, tx: BaseTransaction, message_fmt: str, *, quiet: bool) 'time_from_now': tx.get_time_from_now(now), 'validation': metadata.validation.name, } + if self._log_vertex_bytes: + kwargs['bytes'] = bytes(tx).hex() if tx.is_block: message = message_fmt.format('block') if isinstance(tx, Block):