Skip to content

Commit aede16a

Browse files
committed
feat(p2p): remove sync-v1 code and disable tests
1 parent 90fddc7 commit aede16a

File tree

112 files changed

+221
-3783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+221
-3783
lines changed

hathor/builder/builder.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,14 @@ def add_factories(
6666
cls,
6767
settings: HathorSettingsType,
6868
p2p_manager: ConnectionsManager,
69-
sync_v1_support: 'SyncSupportLevel',
7069
sync_v2_support: 'SyncSupportLevel',
7170
vertex_parser: VertexParser,
7271
vertex_handler: VertexHandler,
7372
) -> None:
7473
"""Adds the sync factory to the manager according to the support level."""
75-
from hathor.p2p.sync_v1.factory import SyncV11Factory
7674
from hathor.p2p.sync_v2.factory import SyncV2Factory
7775
from hathor.p2p.sync_version import SyncVersion
7876

79-
# sync-v1 support:
80-
if sync_v1_support > cls.UNAVAILABLE:
81-
p2p_manager.add_sync_factory(SyncVersion.V1_1, SyncV11Factory(p2p_manager, vertex_parser=vertex_parser))
82-
if sync_v1_support is cls.ENABLED:
83-
p2p_manager.enable_sync_version(SyncVersion.V1_1)
8477
# sync-v2 support:
8578
if sync_v2_support > cls.UNAVAILABLE:
8679
sync_v2_factory = SyncV2Factory(
@@ -185,8 +178,7 @@ def __init__(self) -> None:
185178
self._enable_tokens_index: bool = False
186179
self._enable_utxo_index: bool = False
187180

188-
self._sync_v1_support: SyncSupportLevel = SyncSupportLevel.UNAVAILABLE
189-
self._sync_v2_support: SyncSupportLevel = SyncSupportLevel.UNAVAILABLE
181+
self._sync_v2_support: SyncSupportLevel = SyncSupportLevel.ENABLED
190182

191183
self._enable_stratum_server: Optional[bool] = None
192184

@@ -209,7 +201,7 @@ def build(self) -> BuildArtifacts:
209201
if self.artifacts is not None:
210202
raise ValueError('cannot call build twice')
211203

212-
if SyncSupportLevel.ENABLED not in {self._sync_v1_support, self._sync_v2_support}:
204+
if SyncSupportLevel.ENABLED not in {self._sync_v2_support}:
213205
raise TypeError('you must enable at least one sync version')
214206

215207
settings = self._get_or_create_settings()
@@ -435,7 +427,6 @@ def _get_or_create_p2p_manager(self) -> ConnectionsManager:
435427
SyncSupportLevel.add_factories(
436428
self._get_or_create_settings(),
437429
self._p2p_manager,
438-
self._sync_v1_support,
439430
self._sync_v2_support,
440431
self._get_or_create_vertex_parser(),
441432
self._get_or_create_vertex_handler(),
@@ -772,26 +763,11 @@ def set_pubsub(self, pubsub: PubSubManager) -> 'Builder':
772763
self._pubsub = pubsub
773764
return self
774765

775-
def set_sync_v1_support(self, support_level: SyncSupportLevel) -> 'Builder':
776-
self.check_if_can_modify()
777-
self._sync_v1_support = support_level
778-
return self
779-
780766
def set_sync_v2_support(self, support_level: SyncSupportLevel) -> 'Builder':
781767
self.check_if_can_modify()
782768
self._sync_v2_support = support_level
783769
return self
784770

785-
def enable_sync_v1(self) -> 'Builder':
786-
self.check_if_can_modify()
787-
self._sync_v1_support = SyncSupportLevel.ENABLED
788-
return self
789-
790-
def disable_sync_v1(self) -> 'Builder':
791-
self.check_if_can_modify()
792-
self._sync_v1_support = SyncSupportLevel.DISABLED
793-
return self
794-
795771
def enable_sync_v2(self) -> 'Builder':
796772
self.check_if_can_modify()
797773
self._sync_v2_support = SyncSupportLevel.ENABLED

hathor/builder/cli_builder.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
import platform
1818
import sys
19-
from enum import Enum, auto
2019
from typing import Any, Optional
2120

2221
from structlog import get_logger
@@ -53,13 +52,6 @@
5352
DEFAULT_CACHE_SIZE: int = 100000
5453

5554

56-
class SyncChoice(Enum):
57-
V1_DEFAULT = auto() # v1 enabled, v2 disabled but can be enabled in runtime
58-
V2_DEFAULT = auto() # v2 enabled, v1 disabled but can be enabled in runtime
59-
BRIDGE_DEFAULT = auto() # both enabled, either can be disabled in runtime
60-
V2_ONLY = auto() # v1 is unavailable, it cannot be enabled in runtime
61-
62-
6355
class CliBuilder:
6456
"""CliBuilder builds the core objects from args.
6557
@@ -198,46 +190,20 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
198190

199191
hostname = self.get_hostname()
200192

201-
sync_choice: SyncChoice
202193
if self._args.sync_bridge:
203-
self.log.warn('--sync-bridge is deprecated and will be removed')
204-
sync_choice = SyncChoice.BRIDGE_DEFAULT
194+
raise BuilderError('--sync-bridge was removed')
205195
elif self._args.sync_v1_only:
206-
self.log.warn('--sync-v1-only is deprecated and will be removed')
207-
sync_choice = SyncChoice.V1_DEFAULT
196+
raise BuilderError('--sync-v1-only was removed')
208197
elif self._args.sync_v2_only:
209198
self.log.warn('--sync-v2-only is the default, this parameter has no effect')
210-
sync_choice = SyncChoice.V2_DEFAULT
211199
elif self._args.x_remove_sync_v1:
212-
sync_choice = SyncChoice.V2_ONLY
200+
self.log.warn('--x-remove-sync-v1 is deprecated and has no effect')
213201
elif self._args.x_sync_bridge:
214-
self.log.warn('--x-sync-bridge is deprecated and will be removed')
215-
sync_choice = SyncChoice.BRIDGE_DEFAULT
202+
raise BuilderError('--x-sync-bridge was removed')
216203
elif self._args.x_sync_v1_only:
217-
self.log.warn('--x-sync-v1-only is deprecated and will be removed')
218-
sync_choice = SyncChoice.V1_DEFAULT
204+
raise BuilderError('--x-sync-v1-only was removed')
219205
elif self._args.x_sync_v2_only:
220206
self.log.warn('--x-sync-v2-only is deprecated and will be removed')
221-
sync_choice = SyncChoice.V2_DEFAULT
222-
else:
223-
# XXX: this is the default behavior when no parameter is given
224-
sync_choice = SyncChoice.V2_DEFAULT
225-
226-
sync_v1_support: SyncSupportLevel
227-
sync_v2_support: SyncSupportLevel
228-
match sync_choice:
229-
case SyncChoice.V1_DEFAULT:
230-
sync_v1_support = SyncSupportLevel.ENABLED
231-
sync_v2_support = SyncSupportLevel.DISABLED
232-
case SyncChoice.V2_DEFAULT:
233-
sync_v1_support = SyncSupportLevel.DISABLED
234-
sync_v2_support = SyncSupportLevel.ENABLED
235-
case SyncChoice.BRIDGE_DEFAULT:
236-
sync_v1_support = SyncSupportLevel.ENABLED
237-
sync_v2_support = SyncSupportLevel.ENABLED
238-
case SyncChoice.V2_ONLY:
239-
sync_v1_support = SyncSupportLevel.UNAVAILABLE
240-
sync_v2_support = SyncSupportLevel.ENABLED
241207

242208
pubsub = PubSubManager(reactor)
243209

@@ -345,14 +311,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
345311
log_vertex_bytes=self._args.log_vertex_bytes,
346312
)
347313

348-
SyncSupportLevel.add_factories(
349-
settings,
350-
p2p_manager,
351-
sync_v1_support,
352-
sync_v2_support,
353-
vertex_parser,
354-
vertex_handler,
355-
)
314+
SyncSupportLevel.add_factories(settings, p2p_manager, SyncSupportLevel.ENABLED, vertex_parser, vertex_handler)
356315

357316
from hathor.consensus.poa import PoaBlockProducer, PoaSignerFile
358317
poa_block_producer: PoaBlockProducer | None = None

hathor/cli/run_node.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,13 @@ def create_parser(cls) -> ArgumentParser:
135135
parser.add_argument('--enable-debug-api', action='store_true', help='Enable _debug/* endpoints')
136136
parser.add_argument('--enable-crash-api', action='store_true', help='Enable _crash/* endpoints')
137137
sync_args = parser.add_mutually_exclusive_group()
138-
sync_args.add_argument('--sync-bridge', action='store_true', help=SUPPRESS) # moved to --x-sync-bridge
139-
sync_args.add_argument('--sync-v1-only', action='store_true', help=SUPPRESS) # moved to --x-sync-v1-only
140-
sync_args.add_argument('--sync-v2-only', action='store_true', help=SUPPRESS) # already default
141-
sync_args.add_argument('--x-remove-sync-v1', action='store_true', help='Make sync-v1 unavailable, thus '
142-
'impossible to be enabled in runtime.')
143-
sync_args.add_argument('--x-sync-v1-only', action='store_true', help='Disable support for running sync-v2.')
144-
sync_args.add_argument('--x-sync-v2-only', action='store_true', help=SUPPRESS) # old argument
145-
sync_args.add_argument('--x-sync-bridge', action='store_true', help='Enable running both sync protocols.')
138+
sync_args.add_argument('--sync-bridge', action='store_true', help=SUPPRESS) # deprecated
139+
sync_args.add_argument('--sync-v1-only', action='store_true', help=SUPPRESS) # deprecated
140+
sync_args.add_argument('--sync-v2-only', action='store_true', help=SUPPRESS) # deprecated
141+
sync_args.add_argument('--x-remove-sync-v1', action='store_true', help=SUPPRESS) # deprecated
142+
sync_args.add_argument('--x-sync-v1-only', action='store_true', help=SUPPRESS) # deprecated
143+
sync_args.add_argument('--x-sync-v2-only', action='store_true', help=SUPPRESS) # deprecated
144+
sync_args.add_argument('--x-sync-bridge', action='store_true', help=SUPPRESS) # deprecated
146145
parser.add_argument('--x-localhost-only', action='store_true', help='Only connect to peers on localhost')
147146
parser.add_argument('--x-rocksdb-indexes', action='store_true', help=SUPPRESS)
148147
parser.add_argument('--x-enable-event-queue', action='store_true',

hathor/cli/util.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,6 @@ def setup_logging(
269269
'level': 'INFO' if logging_options.debug else 'WARN',
270270
'propagate': False,
271271
},
272-
'hathor.p2p.sync_v1': {
273-
'handlers': handlers,
274-
'level': 'DEBUG' if debug_sync else 'INFO',
275-
'propagate': False,
276-
},
277272
'hathor.p2p.sync_v2': {
278273
'handlers': handlers,
279274
'level': 'DEBUG' if debug_sync else 'INFO',

hathor/p2p/sync_v1/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)