Skip to content

Commit

Permalink
chore(events): remove event queue from unsafe mode (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
glevco authored Dec 4, 2024
1 parent 5725e8e commit 52a8fcb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions hathor/builder/cli_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
pubsub = PubSubManager(reactor)

if self._args.x_enable_event_queue:
self.log.warn('--x-enable-event-queue is deprecated and will be removed, use --enable-event-queue instead')

if self._args.x_enable_event_queue or self._args.enable_event_queue:
self.event_ws_factory = EventWebsocketFactory(
peer_id=str(peer.id),
settings=settings,
Expand Down Expand Up @@ -270,8 +273,8 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
full_verification = False
if self._args.x_full_verification:
self.check_or_raise(
not self._args.x_enable_event_queue,
'--x-full-verification cannot be used with --x-enable-event-queue'
not self._args.x_enable_event_queue and not self._args.enable_event_queue,
'--x-full-verification cannot be used with --enable-event-queue'
)
full_verification = True

Expand All @@ -282,8 +285,8 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
execution_manager=execution_manager
)

if self._args.x_enable_event_queue:
self.log.info('--x-enable-event-queue flag provided. '
if self._args.x_enable_event_queue or self._args.enable_event_queue:
self.log.info('--enable-event-queue flag provided. '
'The events detected by the full node will be stored and can be retrieved by clients')

self.feature_service = FeatureService(settings=settings, tx_storage=tx_storage)
Expand Down Expand Up @@ -378,7 +381,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
checkpoints=settings.CHECKPOINTS,
environment_info=get_environment_info(args=str(self._args), peer_id=str(peer.id)),
full_verification=full_verification,
enable_event_queue=self._args.x_enable_event_queue,
enable_event_queue=self._args.x_enable_event_queue or self._args.enable_event_queue,
bit_signaling_service=bit_signaling_service,
verification_service=verification_service,
cpu_mining_service=cpu_mining_service,
Expand Down
2 changes: 1 addition & 1 deletion hathor/builder/resources_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def create_resources(self) -> server.Site:
ws_factory.subscribe(self.manager.pubsub)

# Event websocket resource
if self._args.x_enable_event_queue:
if self._args.x_enable_event_queue or self._args.enable_event_queue:
root.putChild(b'event_ws', WebSocketResource(self.event_ws_factory))
root.putChild(b'event', EventResource(self.manager._event_manager))

Expand Down
5 changes: 3 additions & 2 deletions hathor/cli/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class RunNode:
('--x-sync-bridge', lambda args: bool(args.x_sync_bridge)),
('--x-sync-v1-only', lambda args: bool(args.x_sync_v1_only)),
('--x-sync-v2-only', lambda args: bool(args.x_sync_v2_only)),
('--x-enable-event-queue', lambda args: bool(args.x_enable_event_queue)),
('--x-asyncio-reactor', lambda args: bool(args.x_asyncio_reactor)),
('--x-ipython-kernel', lambda args: bool(args.x_ipython_kernel)),
]
Expand Down Expand Up @@ -146,7 +145,9 @@ def create_parser(cls) -> ArgumentParser:
sync_args.add_argument('--x-sync-bridge', action='store_true', help='Enable running both sync protocols.')
parser.add_argument('--x-localhost-only', action='store_true', help='Only connect to peers on localhost')
parser.add_argument('--x-rocksdb-indexes', action='store_true', help=SUPPRESS)
parser.add_argument('--x-enable-event-queue', action='store_true', help='Enable event queue mechanism')
parser.add_argument('--x-enable-event-queue', action='store_true',
help='Deprecated: use --enable-event-queue instead.')
parser.add_argument('--enable-event-queue', action='store_true', help='Enable event queue mechanism')
parser.add_argument('--peer-id-blacklist', action='extend', default=[], nargs='+', type=str,
help='Peer IDs to forbid connection')
parser.add_argument('--config-yaml', type=str, help='Configuration yaml filepath')
Expand Down
1 change: 1 addition & 0 deletions hathor/cli/run_node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class RunNodeArgs(BaseModel, extra=Extra.allow):
x_localhost_only: bool
x_rocksdb_indexes: bool
x_enable_event_queue: bool
enable_event_queue: bool
peer_id_blacklist: list[str]
config_yaml: Optional[str]
signal_support: set[Feature]
Expand Down
2 changes: 1 addition & 1 deletion tests/others/test_cli_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ def test_event_queue_with_memory_storage(self):

def test_event_queue_with_full_verification(self):
args = ['--x-enable-event-queue', '--memory-storage', '--x-full-verification']
self._build_with_error(args, '--x-full-verification cannot be used with --x-enable-event-queue')
self._build_with_error(args, '--x-full-verification cannot be used with --enable-event-queue')

0 comments on commit 52a8fcb

Please sign in to comment.