diff --git a/conf/loopchain_conf.json b/conf/loopchain_conf.json index bd53d5605..14926b71d 100644 --- a/conf/loopchain_conf.json +++ b/conf/loopchain_conf.json @@ -10,8 +10,6 @@ "0x2": 1, "0x3": 1 }, - "store_valid_transaction_only": true, - "send_tx_type": 2, "load_cert": false, "consensus_cert_use": false, "tx_cert_use": false, diff --git a/loopchain/baseservice/broadcast_scheduler.py b/loopchain/baseservice/broadcast_scheduler.py index e37d8914d..786b2e367 100644 --- a/loopchain/baseservice/broadcast_scheduler.py +++ b/loopchain/baseservice/broadcast_scheduler.py @@ -332,8 +332,6 @@ def __handler_create_tx(self, create_tx_param): # logging.debug(f"Broadcast create_tx....") try: tx_item = TxItem.create_tx_item(create_tx_param, self.__channel) - # util.logger.spam(f"broadcast_process:__handler_create_tx " - # f"send_tx_type({create_tx_param.meta[Transaction.SEND_TX_TYPE_KEY]})") except Exception as e: logging.warning(f"tx in channel({self.__channel})") logging.warning(f"__handler_create_tx: meta({create_tx_param})") diff --git a/loopchain/blockchain/blockchain.py b/loopchain/blockchain/blockchain.py index ef6dce498..88f263d1c 100644 --- a/loopchain/blockchain/blockchain.py +++ b/loopchain/blockchain/blockchain.py @@ -58,10 +58,8 @@ def __init__(self, blockchain_db=None, channel_name=None): self.__last_block = None # last unconfirmed block that the leader broadcast. self.last_unconfirmed_block = None - self.__save_tx_by_address_strategy = None self.__channel_name = channel_name self.__peer_id = ChannelProperty().peer_id - self.__set_send_tx_type(conf.CHANNEL_OPTION[channel_name]["send_tx_type"]) # block db has [ block_hash - block | block_height - block_hash | BlockChain.LAST_BLOCK_KEY - block_hash ] self.__confirmed_block_db = blockchain_db @@ -91,12 +89,6 @@ def __init__(self, blockchain_db=None, channel_name=None): for tx_version, tx_hash_version in channel_option.get("hash_versions", {}).items(): self.__tx_versioner.hash_generator_versions[tx_version] = tx_hash_version - def __set_send_tx_type(self, send_tx_type): - if send_tx_type == conf.SendTxType.icx: - self.__save_tx_by_address_strategy = self.__save_tx_by_address - else: - self.__save_tx_by_address_strategy = self.__save_tx_by_address_pass - def close_blockchain_db(self): del self.__confirmed_block_db self.__confirmed_block_db = None @@ -111,12 +103,6 @@ def total_tx(self): @property def last_block(self) -> Block: - try: - logging.debug(f"ENGINE-303 blockchain last_block: " - f"{self.__last_block.header.height}, " - f"{self.__last_block.header.hash.hex()}") - except: - pass return self.__last_block @property @@ -407,7 +393,7 @@ def __add_tx_to_block_db(self, block, invoke_results): # util.logger.spam(f"pop tx from queue:{tx_hash}") if block.header.height > 0: - self.__save_tx_by_address_strategy(tx) + self.__save_tx_by_address(tx) self.__save_invoke_result_block_height(block.header.height) @@ -443,9 +429,6 @@ def __save_tx_by_address(self, tx: 'Transaction'): address = tx.from_address.hex_hx() return self.add_tx_to_list_by_address(address, tx.hash.hex()) - def __save_tx_by_address_pass(self, tx): - return True - @staticmethod def __get_tx_list_key(address, index): return conf.TX_LIST_ADDRESS_PREFIX + (address + str(index)).encode(encoding=conf.HASH_KEY_ENCODING) diff --git a/loopchain/channel/channel_inner_service.py b/loopchain/channel/channel_inner_service.py index 98241f20d..84034ddbb 100644 --- a/loopchain/channel/channel_inner_service.py +++ b/loopchain/channel/channel_inner_service.py @@ -115,17 +115,11 @@ async def get_status(self): block_manager = self._channel_service.block_manager status_data["made_block_count"] = block_manager.made_block_count unconfirmed_block_height = None - if block_manager.get_blockchain().last_block is not None: - block_height = block_manager.get_blockchain().last_block.header.height - if block_manager.get_blockchain().last_unconfirmed_block: - unconfirmed_block_height = block_manager.get_blockchain().last_unconfirmed_block.header.height - logging.debug("getstatus block hash(block_manager.get_blockchain().last_block.block_hash): " - + str(block_manager.get_blockchain().last_block.header.hash.hex())) - logging.debug("getstatus block hash(block_manager.get_blockchain().block_height): " - + str(block_manager.get_blockchain().block_height)) - logging.debug("getstatus block height: " + str(block_height)) - # Score와 상관없이 TransactionTx는 블럭매니저가 관리 합니다. + last_block = block_manager.get_blockchain().last_block + if last_block: + block_height = last_block.header.height total_tx = block_manager.get_total_tx() + logging.debug(f"last_block height({block_height}), hash({last_block.header.hash})") status_data["status"] = block_manager.service_status status_data["state"] = self._channel_service.state_machine.state diff --git a/loopchain/channel/channel_service.py b/loopchain/channel/channel_service.py index 131603d81..19bcae4f4 100644 --- a/loopchain/channel/channel_service.py +++ b/loopchain/channel/channel_service.py @@ -252,10 +252,7 @@ async def subscribe_network(self): def __init_peer_auth(self): try: - channel_authorization = IcxAuthorization if util.channel_use_icx(ChannelProperty().name) \ - else PeerAuthorization - - self.__peer_auth = channel_authorization(ChannelProperty().name) + self.__peer_auth = IcxAuthorization(ChannelProperty().name) except Exception as e: logging.exception(f"peer auth init fail cause : {e}") @@ -354,17 +351,10 @@ async def __run_score_container(self): ) self.__score_container = CommonSubprocess(process_args) - if util.channel_use_icx(ChannelProperty().name): - await StubCollection().create_icon_score_stub(ChannelProperty().name) - await StubCollection().icon_score_stubs[ChannelProperty().name].connect() - await StubCollection().icon_score_stubs[ChannelProperty().name].async_task().hello() - return None - else: - await StubCollection().create_score_stub(ChannelProperty().name, ChannelProperty().score_package) - await StubCollection().score_stubs[ChannelProperty().name].connect() - await StubCollection().score_stubs[ChannelProperty().name].async_task().hello() - - return await self.__load_score() + await StubCollection().create_icon_score_stub(ChannelProperty().name) + await StubCollection().icon_score_stubs[ChannelProperty().name].connect() + await StubCollection().icon_score_stubs[ChannelProperty().name].async_task().hello() + return None async def __load_score(self): channel_name = ChannelProperty().name @@ -826,22 +816,10 @@ def score_write_precommit_state(self, block: Block): return True def score_remove_precommit_state(self, block: Block): - if not util.channel_use_icx(ChannelProperty().name): - request = { - "blockHeight": block.height, - "blockHash": block.block_hash, - } - request = convert_params(request, ParamType.remove_precommit_state) - - stub = StubCollection().icon_score_stubs[ChannelProperty().name] - stub.sync_task().remove_precommit_state(request) - - return True - else: - invoke_fail_info = json.dumps({"block_height": block.height, "block_hash": block.block_hash}) - stub = StubCollection().score_stubs[ChannelProperty().name] - stub.sync_task().remove_precommit_state(invoke_fail_info) - return True + invoke_fail_info = json.dumps({"block_height": block.height, "block_hash": block.block_hash}) + stub = StubCollection().score_stubs[ChannelProperty().name] + stub.sync_task().remove_precommit_state(invoke_fail_info) + return True def get_object_has_queue_by_consensus(self): if conf.CONSENSUS_ALGORITHM == conf.ConsensusAlgorithm.lft: diff --git a/loopchain/launcher.py b/loopchain/launcher.py index 2d089a7ae..8afd3c506 100644 --- a/loopchain/launcher.py +++ b/loopchain/launcher.py @@ -149,7 +149,7 @@ def start_as_score(args): amqp_target = args.amqp_target or conf.AMQP_TARGET amqp_key = args.amqp_key or conf.AMQP_KEY - if util.channel_use_icx(channel) and conf.USE_EXTERNAL_SCORE: + if conf.USE_EXTERNAL_SCORE: if conf.EXTERNAL_SCORE_RUN_IN_LAUNCHER: from iconservice.icon_service import IconService from iconservice.icon_config import default_icon_config diff --git a/loopchain/peer/block_manager.py b/loopchain/peer/block_manager.py index b8aab030f..face59ced 100644 --- a/loopchain/peer/block_manager.py +++ b/loopchain/peer/block_manager.py @@ -43,8 +43,7 @@ def __init__(self, name: str, channel_manager, peer_id, channel_name, level_db_i self.__channel_service: ChannelService = channel_manager self.__channel_name = channel_name - self.__pre_validate_strategy = None - self.__set_send_tx_type(conf.CHANNEL_OPTION[channel_name]["send_tx_type"]) + self.__pre_validate_strategy = self.__pre_validate self.__peer_id = peer_id self.__level_db = None self.__level_db_path = "" @@ -73,12 +72,6 @@ def __init__(self, name: str, channel_manager, peer_id, channel_name, level_db_i self.name = name self.__service_status = status_code.Service.online - def __set_send_tx_type(self, send_tx_type): - if send_tx_type == conf.SendTxType.icx: - self.__pre_validate_strategy = self.__pre_validate - else: - self.__pre_validate_strategy = self.__pre_validate_pass - @property def channel_name(self): return self.__channel_name diff --git a/loopchain/peer/peer_outer_service.py b/loopchain/peer/peer_outer_service.py index 914f43c4b..a0dc3d90c 100644 --- a/loopchain/peer/peer_outer_service.py +++ b/loopchain/peer/peer_outer_service.py @@ -191,7 +191,7 @@ def Request(self, request, context): def __status_update(self, channel, future): # update peer outer status cache by channel - util.logger.spam(f"peer_outer_service:__status_update channel({channel}) result({future.result()})") + util.logger.spam(f"status_update channel({channel}) result({future.result()})") self.__status_cache_update_time[channel] = datetime.datetime.now() self.peer_service.status_cache[channel] = future.result() @@ -252,10 +252,7 @@ def GetStatus(self, request, context): stubs = { "peer": StubCollection().peer_stub, "channel": StubCollection().channel_stubs.get(channel_name), - "score": - StubCollection().icon_score_stubs.get(channel_name) - if util.channel_use_icx(channel_name) else - StubCollection().score_stubs.get(channel_name) + "score": StubCollection().icon_score_stubs.get(channel_name) } mq_status_data = {} diff --git a/loopchain/peer/peer_service.py b/loopchain/peer/peer_service.py index bb0247d53..42802b663 100644 --- a/loopchain/peer/peer_service.py +++ b/loopchain/peer/peer_service.py @@ -198,8 +198,7 @@ def __get_channel_infos(self): channels = json.loads(response.channel_infos) else: response = self.stub_to_radiostation.call_in_times(method_name="GetChannelInfos") - channels = {channel: value for channel, value in response["channel_infos"].items() - if util.channel_use_icx(channel)} + channels = {channel: value for channel, value in response["channel_infos"].items()} return channels @@ -235,21 +234,7 @@ def __run_rest_services(self, port): def __make_peer_id(self): """네트워크에서 Peer 를 식별하기 위한 UUID를 level db 에 생성한다. """ - if util.channel_use_icx(conf.LOOPCHAIN_DEFAULT_CHANNEL): - self.__peer_id = IcxAuthorization(conf.LOOPCHAIN_DEFAULT_CHANNEL).address - else: - try: - uuid_bytes = bytes(self.__level_db.Get(conf.LEVEL_DB_KEY_FOR_PEER_ID)) - peer_id = uuid.UUID(bytes=uuid_bytes) - except KeyError: # It's first Run - peer_id = None - - if peer_id is None: - peer_id = uuid.uuid1() - logging.info("make new peer_id: " + str(peer_id)) - self.__level_db.Put(conf.LEVEL_DB_KEY_FOR_PEER_ID, peer_id.bytes) - - self.__peer_id = str(peer_id) + self.__peer_id = IcxAuthorization(conf.LOOPCHAIN_DEFAULT_CHANNEL).address logger_preset = loggers.get_preset() logger_preset.peer_id = self.peer_id @@ -407,7 +392,4 @@ async def ready_tasks(self): for channel_name, channel_info in self.__channel_infos.items(): await StubCollection().create_channel_stub(channel_name) - if util.channel_use_icx(channel_name): - await StubCollection().create_icon_score_stub(channel_name) - else: - await StubCollection().create_score_stub(channel_name, channel_info['score_package']) + await StubCollection().create_icon_score_stub(channel_name) diff --git a/loopchain/rest_server/peer_service_stub.py b/loopchain/rest_server/peer_service_stub.py index f9d95b2e0..6f903e655 100644 --- a/loopchain/rest_server/peer_service_stub.py +++ b/loopchain/rest_server/peer_service_stub.py @@ -66,10 +66,7 @@ def get_last_block_hash(self, channel: str) -> str: def get_block(self, channel: str, block_hash: str= "", block_height: int=-1): block_data_filter = "prev_block_hash, height, block_hash, merkle_tree_root_hash," \ " time_stamp, peer_id, signature" - if conf.CHANNEL_OPTION[channel]['send_tx_type'] == conf.SendTxType.icx: - tx_data_filter = "icx_origin_data" - else: - tx_data_filter = "tx_hash, timestamp, data_string, peer_id" + tx_data_filter = "icx_origin_data" response = self.call("GetBlock", loopchain_pb2.GetBlockRequest( diff --git a/loopchain/utils/__init__.py b/loopchain/utils/__init__.py index 2a2599643..0b748dec9 100644 --- a/loopchain/utils/__init__.py +++ b/loopchain/utils/__init__.py @@ -343,10 +343,6 @@ def get_private_ip(): return get_private_ip3() -def channel_use_icx(channel): - return conf.CHANNEL_OPTION[channel]['send_tx_type'] == conf.SendTxType.icx - - def dict_to_binary(the_dict): return str.encode(json.dumps(the_dict)) diff --git a/loopchain/utils/json_rpc.py b/loopchain/utils/json_rpc.py index cd8f5084a..a962073b6 100644 --- a/loopchain/utils/json_rpc.py +++ b/loopchain/utils/json_rpc.py @@ -119,10 +119,7 @@ async def get_block_by_params(block_height=None, block_hash="", with_commit_stat channel_name = conf.LOOPCHAIN_DEFAULT_CHANNEL block_data_filter = "prev_block_hash, height, block_hash, merkle_tree_root_hash," \ " time_stamp, peer_id, signature" - if conf.CHANNEL_OPTION[channel_name]['send_tx_type'] == conf.SendTxType.icx: - tx_data_filter = "icx_origin_data" - else: - tx_data_filter = "tx_hash, timestamp, data_string, peer_id" + tx_data_filter = "icx_origin_data" channel_stub = StubCollection().channel_stubs[channel_name] response_code, block_hash, block_data_json, tx_data_json_list = \ await channel_stub.async_task().get_block( diff --git a/testcase/unittest/test_configure.py b/testcase/unittest/test_configure.py index e56fd0096..fccbff149 100644 --- a/testcase/unittest/test_configure.py +++ b/testcase/unittest/test_configure.py @@ -85,8 +85,6 @@ def test_save_and_restore_user_configure(self): conf.DISABLE_V1_API = False conf.CHANNEL_OPTION = { conf.LOOPCHAIN_DEFAULT_CHANNEL: { - "store_valid_transaction_only": True, - "send_tx_type": conf.SendTxType.icx, "load_cert": False, "consensus_cert_use": False, "tx_cert_use": False, @@ -96,8 +94,6 @@ def test_save_and_restore_user_configure(self): "private_password": b'test' }, conf.LOOPCHAIN_TEST_CHANNEL: { - "store_valid_transaction_only": False, - "send_tx_type": conf.SendTxType.pickle, "load_cert": False, "consensus_cert_use": False, "tx_cert_use": False,