Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #48 from icon-project/feature/LC-102
Browse files Browse the repository at this point in the history
[LC-102] update citizen node run script and config
  • Loading branch information
windies21 authored Jan 22, 2019
2 parents d050c01 + 8169160 commit 0d9111e
Show file tree
Hide file tree
Showing 24 changed files with 797 additions and 121 deletions.
577 changes: 518 additions & 59 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.24.2
21 changes: 21 additions & 0 deletions conf/develop/iconrpcserver_conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"log": {
"logger": "iconrpcserver",
"colorLog": true,
"level": "info",
"filePath": "./log/develop/iconrpcserver.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
"period": "daily",
"interval": 1,
"backupCount": 10,
"maxBytes": 50000000
}
},
"channel": "icon_dex",
"port": 9000,
"amqpTarget": "127.0.0.1",
"amqpKey": "7100",
"gunicornWorkerCount": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"log": {
"logger": "iconservice",
"colorLog": true,
"level": "warning",
"filePath": "./log/iconservice.log",
"level": "info",
"filePath": "./log/develop/iconservice.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
Expand All @@ -13,8 +13,8 @@
"maxBytes": 50000000
}
},
"scoreRootPath": ".storage_test/.score_testnet",
"stateDbRootPath": ".storage_test/.statedb_testnet",
"scoreRootPath": ".storage/.score",
"stateDbRootPath": ".storage/.statedb",
"channel": "icon_dex",
"amqpKey": "7100",
"amqpTarget": "127.0.0.1",
Expand Down
21 changes: 21 additions & 0 deletions conf/mainnet/iconrpcserver_conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"log": {
"logger": "iconrpcserver",
"colorLog": true,
"level": "warning",
"filePath": "./log/mainnet/iconrpcserver.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
"period": "daily",
"interval": 1,
"backupCount": 10,
"maxBytes": 50000000
}
},
"channel": "icon_dex",
"port": 9100,
"amqpTarget": "127.0.0.1",
"amqpKey": "7200",
"gunicornWorkerCount": 1
}
28 changes: 28 additions & 0 deletions conf/mainnet/iconservice_conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"log": {
"logger": "iconservice",
"colorLog": true,
"level": "warning",
"filePath": "./log/mainnet/iconservice.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
"period": "daily",
"interval": 1,
"backupCount": 10,
"maxBytes": 50000000
}
},
"scoreRootPath": ".storage_mainnet/.score",
"stateDbRootPath": ".storage_mainnet/.statedb",
"channel": "icon_dex",
"amqpKey": "7200",
"amqpTarget": "127.0.0.1",
"builtinScoreOwner": "hx677133298ed5319607a321a38169031a8867085c",
"service": {
"fee": true,
"audit": true,
"deployerWhiteList": false,
"scorePackageValidator": false
}
}
29 changes: 29 additions & 0 deletions conf/mainnet/loopchain_conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"CHANNEL_OPTION" : {
"icon_dex": {
"block_versions": {
"0.1a": 0
},
"hash_versions": {
"genesis": 0,
"0x2": 1,
"0x3": 1
},
"load_cert": false,
"consensus_cert_use": false,
"tx_cert_use": false,
"key_load_type": 0,
"public_path": "./resources/my_pki/my_public.pem",
"private_path": "./resources/my_pki/my_private.pem"
}
},
"USE_EXTERNAL_SCORE": true,
"EXTERNAL_SCORE_RUN_IN_LAUNCHER": true,
"PORT_PEER": 7200,
"AMQP_KEY": "7200",
"DEFAULT_STORAGE_PATH": ".storage_mainnet/",
"ALLOW_MAKE_EMPTY_BLOCK": false,
"SUBSCRIBE_USE_HTTPS": true,
"LOOPCHAIN_LOG_LEVEL": "INFO",
"LOG_FILE_LOCATION": "./log/mainnet"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"logger": "iconrpcserver",
"colorLog": true,
"level": "warning",
"filePath": "./log/iconrpcserver.log",
"filePath": "./log/testnet/iconrpcserver.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
Expand All @@ -17,6 +17,5 @@
"port": 9000,
"amqpTarget": "127.0.0.1",
"amqpKey": "7100",
"gunicornWorkerCount": 1,
"subscribeUseHttps": true
"gunicornWorkerCount": 1
}
28 changes: 28 additions & 0 deletions conf/testnet/iconservice_conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"log": {
"logger": "iconservice",
"colorLog": true,
"level": "warning",
"filePath": "./log/testnet/iconservice.log",
"outputType": "console|file",
"rotate": {
"type": "period|bytes",
"period": "daily",
"interval": 1,
"backupCount": 10,
"maxBytes": 50000000
}
},
"scoreRootPath": ".storage_testnet/.score",
"stateDbRootPath": ".storage_testnet/.statedb",
"channel": "icon_dex",
"amqpKey": "7100",
"amqpTarget": "127.0.0.1",
"builtinScoreOwner": "hxba096790caa1804a8828939839a901a5978020a7",
"service": {
"fee": true,
"audit": true,
"deployerWhiteList": false,
"scorePackageValidator": false
}
}
8 changes: 4 additions & 4 deletions conf/loopchain_conf.json → conf/testnet/loopchain_conf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"LOOPCHAIN_DEFAULT_CHANNEL": "icon_dex",
"CHANNEL_OPTION" : {
"icon_dex": {
"block_versions": {
Expand All @@ -19,11 +18,12 @@
}
},
"USE_EXTERNAL_SCORE": true,
"USE_EXTERNAL_REST": true,
"EXTERNAL_SCORE_RUN_IN_LAUNCHER": true,
"PORT_PEER": 7100,
"AMQP_KEY": "7100",
"DEFAULT_STORAGE_PATH": ".storage_test/",
"DEFAULT_STORAGE_PATH": ".storage_testnet/",
"ALLOW_MAKE_EMPTY_BLOCK": false,
"SUBSCRIBE_USE_HTTPS": true,
"LOOPCHAIN_LOG_LEVEL": "INFO"
"LOOPCHAIN_LOG_LEVEL": "INFO",
"LOG_FILE_LOCATION": "./log/testnet"
}
3 changes: 2 additions & 1 deletion loopchain/channel/channel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ async def __run_score_container(self):
command_arguments.Type.AMQPTarget,
command_arguments.Type.AMQPKey,
command_arguments.Type.Develop,
command_arguments.Type.ConfigurationFilePath
command_arguments.Type.ConfigurationFilePath,
command_arguments.Type.RadioStationTarget
)
self.__score_container = CommonSubprocess(process_args)

Expand Down
20 changes: 17 additions & 3 deletions loopchain/configure_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LogOutputType(IntFlag):

LOG_OUTPUT_TYPE = LogOutputType.console | LogOutputType.file

LOG_FILE_LOCATION = "/var/tmp/"
LOG_FILE_LOCATION = os.path.join(LOOPCHAIN_ROOT_PATH, 'log')
LOG_FILE_PREFIX = "loopchain"
LOG_FILE_EXTENSION = "log"

Expand Down Expand Up @@ -202,7 +202,6 @@ class SendTxType(IntEnum):
DEFAULT_SCORE_PACKAGE = 'loopchain/default'
DEFAULT_SCORE_BRANCH_MASTER = 'master'
DEFAULT_SCORE_BRANCH = os.getenv('DEFAULT_SCORE_BRANCH', DEFAULT_SCORE_BRANCH_MASTER)
DEFAULT_SCORE_CONF_PATH = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/iconservice_conf.json')

# DEFAULT USER / PASSWORD
DEFAULT_SCORE_BASE_USER = 'score'
Expand Down Expand Up @@ -328,7 +327,7 @@ def is_support_node_function(cls, node_function, node_type):
# If disconnected state of the peer is maintained, That peer will removed from peer list after this minutes.
TIMEOUT_PEER_REMOVE_IN_LIST = 5 # minutes, replace by NO_RESPONSE_COUNT_ALLOW_BY_HEARTBEAT
RADIO_STATION_NAME = "RadioStation"
LOOPCHAIN_DEFAULT_CHANNEL = "loopchain_default" # Default Channel Name
LOOPCHAIN_DEFAULT_CHANNEL = "icon_dex" # Default Channel Name
LOOPCHAIN_TEST_CHANNEL = "loopchain_test"
CHANNEL_MANAGE_DATA_PATH = os.path.join(LOOPCHAIN_ROOT_PATH, 'channel_manage_data.json') # Channel Manage Data Path
ENABLE_CHANNEL_AUTH = False # if this option is true, peer only gets channel infos to which it belongs.
Expand Down Expand Up @@ -428,3 +427,18 @@ def is_support_node_function(cls, node_function, node_type):
# LFT ####
####################
ALLOW_MAKE_EMPTY_BLOCK = True


####################
# ICON ####
####################
URL_CITIZEN_TESTNET = 'https://int-test-ctz.solidwallet.io'
URL_CITIZEN_MAINNET = 'https://int-ctz.solidwallet.io'
CONF_PATH_LOOPCHAIN_TESTNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/testnet/loopchain_conf.json')
CONF_PATH_LOOPCHAIN_MAINNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/mainnet/loopchain_conf.json')
CONF_PATH_ICONSERVICE_DEV = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/develop/iconservice_conf.json')
CONF_PATH_ICONSERVICE_TESTNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/testnet/iconservice_conf.json')
CONF_PATH_ICONSERVICE_MAINNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/mainnet/iconservice_conf.json')
CONF_PATH_ICONRPCSERVER_DEV = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/develop/iconrpcserver_conf.json')
CONF_PATH_ICONRPCSERVER_TESTNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/testnet/iconrpcserver_conf.json')
CONF_PATH_ICONRPCSERVER_MAINNET = os.path.join(LOOPCHAIN_ROOT_PATH, 'conf/mainnet/iconrpcserver_conf.json')
3 changes: 2 additions & 1 deletion loopchain/container/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def run(self, conn, event: multiprocessing.Event):
command_arguments.Type.AMQPTarget,
command_arguments.Type.AMQPKey,
command_arguments.Type.Develop,
command_arguments.Type.ConfigurationFilePath
command_arguments.Type.ConfigurationFilePath,
command_arguments.Type.RadioStationTarget
)
server = CommonSubprocess(args)
api_port = self._port + conf.PORT_DIFF_REST_SERVICE_CONTAINER
Expand Down
38 changes: 28 additions & 10 deletions loopchain/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def main(argv):
args = parser.parse_args(argv)
command_arguments.set_raw_commands(args)

if args.radio_station_target == 'testnet':
args.radio_station_target = conf.URL_CITIZEN_TESTNET
args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_TESTNET
elif args.radio_station_target == 'mainnet':
args.radio_station_target = conf.URL_CITIZEN_MAINNET
args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_MAINNET

if args.configure_file_path:
conf.Configure().load_configure_json(args.configure_file_path)

Expand Down Expand Up @@ -100,20 +107,24 @@ def start_as_rest_server(args):
channel = conf.LOOPCHAIN_DEFAULT_CHANNEL
amqp_key = args.amqp_key or conf.AMQP_KEY
api_port = int(peer_port) + conf.PORT_DIFF_REST_SERVICE_CONTAINER
conf_path = conf.CONF_PATH_ICONRPCSERVER_DEV

if args.radio_station_target:
if args.radio_station_target == conf.URL_CITIZEN_TESTNET:
conf_path = conf.CONF_PATH_ICONRPCSERVER_TESTNET
elif args.radio_station_target == conf.URL_CITIZEN_MAINNET:
conf_path = conf.CONF_PATH_ICONRPCSERVER_MAINNET

from iconrpcserver.default_conf.icon_rpcserver_config import default_rpcserver_config
from iconrpcserver.icon_rpcserver_cli import start_process, find_procs_by_params
from iconcommons.icon_config import IconConfig
from iconcommons.logger import Logger

with open(conf_path) as file:
load_conf = json.load(file)

additional_conf = {
"log": {
"logger": "iconrpcserver",
"colorLog": True,
"level": "info",
"filePath": "./log/iconrpcserver.log",
"outputType": "console|file"
},
"log": load_conf.get("log"),
"channel": channel,
"port": api_port,
"amqpKey": amqp_key,
Expand Down Expand Up @@ -148,6 +159,13 @@ def start_as_score(args):
score_package = args.score_package or conf.DEFAULT_SCORE_PACKAGE
amqp_target = args.amqp_target or conf.AMQP_TARGET
amqp_key = args.amqp_key or conf.AMQP_KEY
conf_path = conf.CONF_PATH_ICONSERVICE_DEV

if args.radio_station_target:
if args.radio_station_target == conf.URL_CITIZEN_TESTNET:
conf_path = conf.CONF_PATH_ICONSERVICE_TESTNET
elif args.radio_station_target == conf.URL_CITIZEN_MAINNET:
conf_path = conf.CONF_PATH_ICONSERVICE_MAINNET

if conf.USE_EXTERNAL_SCORE:
if conf.EXTERNAL_SCORE_RUN_IN_LAUNCHER:
Expand All @@ -156,13 +174,13 @@ def start_as_score(args):
from iconcommons.icon_config import IconConfig
from iconcommons.logger import Logger

with open(conf.DEFAULT_SCORE_CONF_PATH) as file:
with open(conf_path) as file:
load_conf = json.load(file)

additional_conf = {
"log": load_conf.get("log"),
"scoreRootPath": f".storage/.score{amqp_key}_{channel}",
"stateDbRootPath": f".storage/.statedb{amqp_key}_{channel}",
"scoreRootPath": load_conf.get("scoreRootPath") + f"{amqp_key}_{channel}",
"stateDbRootPath": load_conf.get("stateDbRootPath") + f"{amqp_key}_{channel}",
"channel": channel,
"amqpKey": amqp_key,
"builtinScoreOwner": load_conf.get("builtinScoreOwner"),
Expand Down
4 changes: 3 additions & 1 deletion loopchain/peer/block_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ def __get_peer_stub_list(self, target_peer_stub=None):
response = target_peer_stub.call("Status")
util.logger.spam('{/api/v1/status/peer} response: ' + response.text)
response.block_height = int(json.loads(response.text)["block_height"])
response.unconfirmed_block_height = int(json.loads(response.text)["unconfirmed_block_height"])
response.unconfirmed_block_height = int(
json.loads(response.text).get("unconfirmed_block_height", -1)
)
stub.target = target

response.block_height = max(response.block_height, response.unconfirmed_block_height)
Expand Down
3 changes: 2 additions & 1 deletion loopchain/peer/peer_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ async def serve_channels(self):
command_arguments.Type.Develop,
command_arguments.Type.AMQPTarget,
command_arguments.Type.AMQPKey,
command_arguments.Type.ConfigurationFilePath
command_arguments.Type.ConfigurationFilePath,
command_arguments.Type.RadioStationTarget
)

service = CommonSubprocess(args)
Expand Down
2 changes: 1 addition & 1 deletion loopchain/utils/loggers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _create_file_handler(self):
if not os.path.isdir(self.log_file_location):
raise RuntimeError(f"LogFileLocation({self.log_file_location}) is not a directory.")
else:
os.mkdir(self.log_file_location)
os.makedirs(self.log_file_location)

if self.log_file_rotate_when and self.log_file_rotate_max_bytes:
file_handler = SizedTimedRotatingFileHandler(
Expand Down
21 changes: 0 additions & 21 deletions run_loopchain.sh

This file was deleted.

Loading

0 comments on commit 0d9111e

Please sign in to comment.