Ejemplo n.º 1
0
 def __init__(self, chain, db, peer_pool, token=None) -> None:
     super().__init__(token=token)
     self._chain = chain
     self._header_syncer = ETHHeaderChainSyncer(chain,
                                                db,
                                                peer_pool,
                                                token=self.cancel_token)
     self._single_header_syncer = self.HeaderSyncer_OnlyOne(
         self._header_syncer)
     self._paused_header_syncer = self.HeaderSyncer_PauseThenRest(
         self._header_syncer)
     self._draining_syncer = RegularChainBodySyncer(
         chain,
         db,
         peer_pool,
         self._single_header_syncer,
         SimpleBlockImporter(chain),
         self.cancel_token,
     )
     self._body_syncer = RegularChainBodySyncer(
         chain,
         db,
         peer_pool,
         self._paused_header_syncer,
         SimpleBlockImporter(chain),
         self.cancel_token,
     )
Ejemplo n.º 2
0
    def __init__(self,
                 chain: BaseAsyncChain,
                 db: BaseAsyncDB,
                 chain_db: BaseAsyncChainDB,
                 peer_pool: ETHPeerPool,
                 event_bus: EndpointAPI,
                 force_beam_block_number: int = None,
                 token: CancelToken = None) -> None:
        super().__init__(token=token)

        self._header_syncer = ETHHeaderChainSyncer(chain, chain_db, peer_pool,
                                                   self.cancel_token)
        self._header_persister = HeaderOnlyPersist(
            self._header_syncer,
            chain_db,
            force_beam_block_number,
            self.cancel_token,
        )
        self._state_downloader = BeamDownloader(db, peer_pool, event_bus,
                                                self.cancel_token)
        self._data_hunter = MissingDataEventHandler(
            self._state_downloader,
            event_bus,
            token=self.cancel_token,
        )

        self._block_importer = BeamBlockImporter(chain, self._state_downloader,
                                                 event_bus)
        self._checkpoint_header_syncer = HeaderCheckpointSyncer(
            self._header_syncer)
        self._body_syncer = RegularChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._checkpoint_header_syncer,
            self._block_importer,
            self.cancel_token,
        )

        self._manual_header_syncer = ManualHeaderSyncer()
        self._fast_syncer = RigorousFastChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._manual_header_syncer,
            self.cancel_token,
        )

        self._chain = chain
Ejemplo n.º 3
0
    def __init__(
            self,
            chain: AsyncChainAPI,
            db: AtomicDatabaseAPI,
            chain_db: BaseAsyncChainDB,
            peer_pool: ETHPeerPool,
            event_bus: EndpointAPI,
            metrics_registry: MetricsRegistry,
            checkpoint: Checkpoint = None,
            force_beam_block_number: BlockNumber = None,
            enable_backfill: bool = True,
            enable_state_backfill: bool = True) -> None:
        self.logger = get_logger('trinity.sync.beam.chain.BeamSyncer')

        self.metrics_registry = metrics_registry
        self._body_for_header_exists = body_for_header_exists(chain_db, chain)

        if checkpoint is None:
            self._launch_strategy: SyncLaunchStrategyAPI = FromGenesisLaunchStrategy(chain_db)
        else:
            self._launch_strategy = FromCheckpointLaunchStrategy(
                chain_db,
                chain,
                checkpoint,
                peer_pool,
            )

        self._header_syncer = ETHHeaderChainSyncer(
            chain,
            chain_db,
            peer_pool,
            self._launch_strategy,
        )
        self._header_persister = HeaderOnlyPersist(
            self._header_syncer,
            chain_db,
            force_beam_block_number,
            self._launch_strategy,
        )

        self._backfiller = BeamStateBackfill(db, peer_pool)

        if enable_state_backfill:
            self._queen_queue: QueenTrackerAPI = self._backfiller
        else:
            self._queen_queue = QueeningQueue(peer_pool)

        self._state_downloader = BeamDownloader(
            db,
            peer_pool,
            self._queen_queue,
            event_bus,
        )
        self._data_hunter = MissingDataEventHandler(
            self._state_downloader,
            event_bus,
            self.metrics_registry,
        )

        self._block_importer = BeamBlockImporter(
            chain,
            db,
            self._state_downloader,
            self._backfiller,
            event_bus,
            self.metrics_registry,
        )
        self._launchpoint_header_syncer = HeaderLaunchpointSyncer(self._header_syncer)
        self._body_syncer = RegularChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._launchpoint_header_syncer,
            self._block_importer,
        )

        self._manual_header_syncer = ManualHeaderSyncer()
        self._fast_syncer = RigorousFastChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._manual_header_syncer,
        )

        self._header_backfill = SequentialHeaderChainGapSyncer(chain, chain_db, peer_pool)
        self._block_backfill = BodyChainGapSyncer(chain, chain_db, peer_pool)

        self._chain = chain
        self._enable_backfill = enable_backfill
        self._enable_state_backfill = enable_state_backfill
Ejemplo n.º 4
0
    def __init__(self,
                 chain: AsyncChainAPI,
                 db: AtomicDatabaseAPI,
                 chain_db: BaseAsyncChainDB,
                 peer_pool: ETHPeerPool,
                 event_bus: EndpointAPI,
                 checkpoint: Checkpoint = None,
                 force_beam_block_number: BlockNumber = None,
                 token: CancelToken = None) -> None:
        super().__init__(token=token)

        if checkpoint is None:
            self._launch_strategy: SyncLaunchStrategyAPI = FromGenesisLaunchStrategy(
                chain_db, chain)
        else:
            self._launch_strategy = FromCheckpointLaunchStrategy(
                chain_db,
                chain,
                checkpoint,
                peer_pool,
            )

        self._header_syncer = ETHHeaderChainSyncer(chain, chain_db, peer_pool,
                                                   self._launch_strategy,
                                                   self.cancel_token)
        self._header_persister = HeaderOnlyPersist(
            self._header_syncer,
            chain_db,
            force_beam_block_number,
            self._launch_strategy,
            self.cancel_token,
        )

        self._backfiller = BeamStateBackfill(db,
                                             peer_pool,
                                             token=self.cancel_token)

        self._state_downloader = BeamDownloader(
            db,
            peer_pool,
            self._backfiller,
            event_bus,
            self.cancel_token,
        )
        self._data_hunter = MissingDataEventHandler(
            self._state_downloader,
            event_bus,
            token=self.cancel_token,
        )

        self._block_importer = BeamBlockImporter(
            chain,
            db,
            self._state_downloader,
            self._backfiller,
            event_bus,
            self.cancel_token,
        )
        self._checkpoint_header_syncer = HeaderCheckpointSyncer(
            self._header_syncer)
        self._body_syncer = RegularChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._checkpoint_header_syncer,
            self._block_importer,
            self.cancel_token,
        )

        self._manual_header_syncer = ManualHeaderSyncer()
        self._fast_syncer = RigorousFastChainBodySyncer(
            chain,
            chain_db,
            peer_pool,
            self._manual_header_syncer,
            self.cancel_token,
        )

        self._chain = chain