def orderer(consensus_data, internal_bus, external_bus, name, write_manager, txn_roots, state_roots, bls_bft_replica, tconf, stasher, validators): orderer = OrderingService( data=consensus_data(name), timer=QueueTimer(), bus=internal_bus, network=external_bus, write_manager=write_manager, bls_bft_replica=bls_bft_replica, freshness_checker=FreshnessChecker( freshness_timeout=tconf.STATE_FRESHNESS_UPDATE_INTERVAL), primaries_selector=RoundRobinConstantNodesPrimariesSelector( validators), stasher=stasher) orderer._data.node_mode = Mode.participating orderer._data.primary_name = "Alpha:0" orderer.get_txn_root_hash = lambda ledger, to_str=False: txn_roots[ledger] orderer.get_state_root_hash = lambda ledger, to_str=False: state_roots[ ledger] orderer.requestQueues[DOMAIN_LEDGER_ID] = OrderedSet() orderer._revert = lambda *args, **kwargs: None orderer.db_manager.stores[LAST_SENT_PP_STORE_LABEL] = \ FakeSomething(store_last_sent_pp_seq_no=lambda b, c: None) return orderer
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus, write_manager: WriteRequestManager = None, bls_bft_replica: BlsBftReplica = None): self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = primary_name self._orderer = OrderingService(data=self._data, timer=timer, bus=bus, network=network, write_manager=write_manager, bls_bft_replica=bls_bft_replica) self._checkpointer = CheckpointService(self._data, bus, network) self._view_changer = ViewChangeService(self._data, timer, bus, network) # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='empty'))
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus, write_manager: WriteRequestManager, bls_bft_replica: BlsBftReplica=None): self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = primary_name config = getConfig() stasher = StashingRouter(config.REPLICA_STASH_LIMIT, buses=[bus, network]) self._orderer = OrderingService(data=self._data, timer=timer, bus=bus, network=network, write_manager=write_manager, bls_bft_replica=bls_bft_replica, freshness_checker=FreshnessChecker( freshness_timeout=config.STATE_FRESHNESS_UPDATE_INTERVAL), stasher=stasher) self._checkpointer = CheckpointService(self._data, bus, network, stasher, write_manager.database_manager) self._view_changer = ViewChangeService(self._data, timer, bus, network, stasher) # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='4F7BsTMVPKFshM1MwLf6y23cid6fL3xMpazVoF9krzUw'))
def orderer(consensus_data, internal_bus, external_bus, name, write_manager, txn_roots, state_roots, bls_bft_replica, tconf, stasher): orderer = OrderingService( data=consensus_data(name), timer=QueueTimer(), bus=internal_bus, network=external_bus, write_manager=write_manager, bls_bft_replica=bls_bft_replica, freshness_checker=FreshnessChecker( freshness_timeout=tconf.STATE_FRESHNESS_UPDATE_INTERVAL), stasher=stasher) orderer._data.node_mode = Mode.participating orderer._data.primary_name = "Alpha:0" orderer.get_txn_root_hash = lambda ledger, to_str=False: txn_roots[ledger] orderer.get_state_root_hash = lambda ledger, to_str=False: state_roots[ ledger] orderer.requestQueues[DOMAIN_LEDGER_ID] = OrderedSet() orderer._revert = lambda *args, **kwargs: None orderer.db_manager.stores[LAST_SENT_PP_STORE_LABEL] = \ FakeSomething(store_last_sent_pp_seq_no=lambda b, c: None) future_primaries_handler = FuturePrimariesBatchHandler( write_manager.database_manager, FakeSomething(nodeReg={}, nodeIds=[])) future_primaries_handler.get_primaries = lambda *args, **kwargs: orderer._data.primaries write_manager.register_batch_handler(future_primaries_handler) return orderer
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus, write_manager: WriteRequestManager, bls_bft_replica: BlsBftReplica = None): # ToDo: Maybe ConsensusSharedData should be initiated before and passed already prepared? self._internal_bus = bus self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = generateName(primary_name, self._data.inst_id) self.config = getConfig() self.stasher = StashingRouter(self.config.REPLICA_STASH_LIMIT, buses=[bus, network]) self._write_manager = write_manager self._primaries_selector = RoundRobinNodeRegPrimariesSelector( self._write_manager.node_reg_handler) self._orderer = OrderingService( data=self._data, timer=timer, bus=bus, network=network, write_manager=self._write_manager, bls_bft_replica=bls_bft_replica, freshness_checker=FreshnessChecker( freshness_timeout=self.config.STATE_FRESHNESS_UPDATE_INTERVAL), primaries_selector=self._primaries_selector, stasher=self.stasher) self._checkpointer = CheckpointService(self._data, bus, network, self.stasher, write_manager.database_manager) self._view_changer = ViewChangeService(self._data, timer, bus, network, self.stasher, self._primaries_selector) self._message_requestor = MessageReqService(self._data, bus, network) self._add_ledgers() # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='4F7BsTMVPKFshM1MwLf6y23cid6fL3xMpazVoF9krzUw')) # ToDo: it should be done in Zero-view stage. write_manager.on_catchup_finished() self._data.primaries = self._view_changer._primaries_selector.select_primaries( self._data.view_no) # ToDo: ugly way to understand node_reg changing self._previous_node_reg = self._write_manager.node_reg_handler.committed_node_reg bus.subscribe(Ordered, self.emulate_ordered_processing)
def _init_ordering_service(self) -> OrderingService: return OrderingService(data=self._consensus_data, timer=self.node.timer, bus=self.internal_bus, network=self._external_bus, write_manager=self.node.write_manager, bls_bft_replica=self._bls_bft_replica, freshness_checker=self._freshness_checker, get_current_time=self.get_current_time, get_time_for_3pc_batch=self.get_time_for_3pc_batch, stasher=self.stasher, metrics=self.metrics)
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus): self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = primary_name self._orderer = OrderingService(self._data, bus, network) self._checkpointer = CheckpointService(self._data, bus, network) self._view_changer = ViewChangeService(self._data, timer, bus, network) # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='empty'))
def orderer(consensus_data, internal_bus, external_bus, name, write_manager, txn_roots, state_roots, bls_bft_replica): orderer = OrderingService(data=consensus_data(name), timer=QueueTimer(), bus=internal_bus, network=external_bus, write_manager=write_manager, bls_bft_replica=bls_bft_replica, is_master=is_master) orderer._data.is_participating = True orderer.primary_name = "Alpha:0" orderer.l_txnRootHash = lambda ledger, to_str=False: txn_roots[ledger] orderer.l_stateRootHash = lambda ledger, to_str=False: state_roots[ledger] orderer.requestQueues[DOMAIN_LEDGER_ID] = OrderedSet() orderer.l_revert = lambda *args, **kwargs: None return orderer
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus, write_manager: WriteRequestManager, bls_bft_replica: BlsBftReplica = None): self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = primary_name config = getConfig() stasher = StashingRouter(config.REPLICA_STASH_LIMIT) self._orderer = OrderingService(data=self._data, timer=timer, bus=bus, network=network, write_manager=write_manager, bls_bft_replica=bls_bft_replica, stasher=stasher) self._checkpointer = CheckpointService( self._data, bus, network, stasher, write_manager.database_manager, old_stasher=FakeSomething(unstash_watermarks=lambda: None)) self._view_changer = ViewChangeService(self._data, timer, bus, network) # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='empty'))
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus): self._data = ConsensusDataProvider(name, validators, primary_name) self._orderer = OrderingService(self._data, bus, network) self._checkpointer = CheckpointService(self._data, bus, network) self._view_changer = ViewChangeService(self._data, timer, bus, network)
def __init__(self, name: str, validators: List[str], primary_name: str, timer: TimerService, bus: InternalBus, network: ExternalBus, write_manager: WriteRequestManager, bls_bft_replica: BlsBftReplica = None): # ToDo: Maybe ConsensusSharedData should be initiated before and passed already prepared? self._network = network self._data = ConsensusSharedData(name, validators, 0) self._data.primary_name = generateName(primary_name, self._data.inst_id) self._timer = timer self.config = getConfig() self.stasher = StashingRouter(self.config.REPLICA_STASH_LIMIT, buses=[bus, network]) self._write_manager = write_manager self._primaries_selector = RoundRobinNodeRegPrimariesSelector(self._write_manager.node_reg_handler) self._freshness_checker = FreshnessChecker(freshness_timeout=self.config.STATE_FRESHNESS_UPDATE_INTERVAL) for ledger_id in [POOL_LEDGER_ID, DOMAIN_LEDGER_ID, CONFIG_LEDGER_ID]: self._freshness_checker.register_ledger(ledger_id=ledger_id, initial_time=self.get_time_for_3pc_batch()) self._orderer = OrderingService(data=self._data, timer=self._timer, bus=bus, network=network, write_manager=self._write_manager, bls_bft_replica=bls_bft_replica, freshness_checker=self._freshness_checker, get_time_for_3pc_batch=self.get_time_for_3pc_batch, stasher=self.stasher) self._checkpointer = CheckpointService(self._data, bus, network, self.stasher, write_manager.database_manager) self._view_changer = ViewChangeService(self._data, self._timer, bus, network, self.stasher, self._primaries_selector) self._view_change_trigger = ViewChangeTriggerService(data=self._data, timer=self._timer, bus=bus, network=network, db_manager=write_manager.database_manager, is_master_degraded=lambda: False, stasher=self.stasher) self._primary_connection_monitor = PrimaryConnectionMonitorService(data=self._data, timer=self._timer, bus=bus, network=network) self._freshness_monitor = FreshnessMonitorService(data=self._data, timer=self._timer, bus=bus, network=network, freshness_checker=self._freshness_checker, get_time_for_3pc_batch=self.get_time_for_3pc_batch) self._message_requestor = MessageReqService(self._data, bus, network) self._add_ledgers() # TODO: This is just for testing purposes only self._data.checkpoints.append( Checkpoint(instId=0, viewNo=0, seqNoStart=0, seqNoEnd=0, digest='4F7BsTMVPKFshM1MwLf6y23cid6fL3xMpazVoF9krzUw')) # ToDo: it should be done in Zero-view stage. write_manager.on_catchup_finished() # Simulate node behavior self._internal_bus = bus self._internal_bus.subscribe(NodeNeedViewChange, self.process_node_need_view_change) self._internal_bus.subscribe(Ordered, self.emulate_ordered_processing) # ToDo: ugly way to understand node_reg changing self._previous_node_reg = self._write_manager.node_reg_handler.committed_node_reg
def __init__(self, name: str, network: ExternalBus): self._data = ConsensusDataProvider(name) self._orderer = OrderingService(self._data, network) self._checkpointer = CheckpointService(self._data, network) self._view_changer = ViewChangeService(self._data, network)