def add_argument_parser_common(arg_parser: ArgumentParser): arg_parser.add_argument( "--data-dir", help="Path to store configuration, state and log files", default=config.get_default_data_path() ) arg_parser.add_argument( "--ca-cert-url", help="The URL for retrieving BDN ca certificate data (default: {})".format( config.get_env_default(NodeStartArgs.CA_CERT_URL) ), default=config.get_env_default(NodeStartArgs.CA_CERT_URL), type=str ) arg_parser.add_argument( "--private-ssl-base-url", help="The base URL for retrieving specific certificate data (default: {})".format( config.get_env_default(NodeStartArgs.PRIVATE_SSL_BASE_URL) ), default=config.get_env_default(NodeStartArgs.PRIVATE_SSL_BASE_URL), type=str )
def get_argument_parser() -> argparse.ArgumentParser: arg_parser = argparse.ArgumentParser() arg_parser.add_argument("--external-ip", help="External network ip of this node", type=ip_resolver.blocking_resolve_ip) arg_parser.add_argument("--external-port", help="External network port to listen on", type=int, default=config.get_env_default( NodeStartArgs.EXTERNAL_PORT)) arg_parser.add_argument("--continent", help="The continent of this node", type=str, choices=["NA", "SA", "EU", "AS", "AF", "OC", "AN"]) arg_parser.add_argument("--country", help="The country of this node.", type=str) arg_parser.add_argument("--hostname", help="Hostname the node is running on", type=str, default=constants.HOSTNAME) arg_parser.add_argument("--sdn-url", help="IP or dns of the bloxroute SDN", type=str, default=config.get_env_default( NodeStartArgs.SDN_ROOT_URL)) arg_parser.add_argument("--log-path", help="Path to store logfiles in") arg_parser.add_argument( "--to-stdout", help="Log to stdout. Doesn't generate logfiles in this mode", type=convert.str_to_bool, default=True) arg_parser.add_argument( "--log-level", help="set log level", type=LogLevel.__getattr__, # pyre-ignore choices=list(LogLevel), default=utils_constants.DEFAULT_LOG_LEVEL) arg_parser.add_argument( "--log-format", help="set log format", type=LogFormat.__getattr__, # pyre-ignore choices=list(LogFormat), default=utils_constants.DEFAULT_LOG_FORMAT) arg_parser.add_argument("--log-flush-immediately", help="Enables immediate flush for logs", type=convert.str_to_bool, default=False) arg_parser.add_argument( "--log-level-overrides", help= "override log level for namespace stats=INFO,bxcommon.connections=WARNING", default={ "stats": "NOTSET", "bx": "NOTSET" }, type=log_config.str_to_log_options) arg_parser.add_argument( "--node-id", help="(TEST ONLY) Set the node_id for using in testing.") arg_parser.add_argument( "--transaction-pool-memory-limit", help="Maximum size of transactions to keep in memory pool (MB)", type=int) arg_parser.add_argument( "--info-stats-interval", help="Frequency of info statistics logs in seconds", type=int, default=constants.INFO_STATS_INTERVAL_S) arg_parser.add_argument( "--throughput-stats-interval", help="Frequency of throughput statistics logs in seconds", type=int, default=constants.THROUGHPUT_STATS_INTERVAL_S) arg_parser.add_argument( "--memory-stats-interval", help="Frequency of memory statistics logs in seconds", type=int, default=constants.MEMORY_STATS_INTERVAL_S) arg_parser.add_argument( "--dump-detailed-report-at-memory-usage", help="Total memory usage of application when detailed memory report " "should be dumped to log (MB)", type=int, default=(0.5 * 1024)) arg_parser.add_argument( "--dump-removed-short-ids", help="Dump removed short ids to a file at a fixed interval", type=convert.str_to_bool, default=False) arg_parser.add_argument("--dump-removed-short-ids-path", help="Folder to dump removed short ids to", type=str, default=constants.DUMP_REMOVED_SHORT_IDS_PATH) arg_parser.add_argument( "--enable-buffered-send", help="Enables buffering of sent byte to improve performance", type=convert.str_to_bool, default=False) arg_parser.add_argument( "--track-detailed-sent-messages", help="Enables tracking of messages written on socket", type=convert.str_to_bool, default=True) arg_parser.add_argument( "--use-extensions", help="If true than the node will use the extension module for " "some tasks like block compression (default: {0})".format( constants.USE_EXTENSION_MODULES), default=constants.USE_EXTENSION_MODULES, type=convert.str_to_bool) arg_parser.add_argument( "--import-extensions", help= "If true than the node will import all C++ extensions dependencies on start up", default=False, type=convert.str_to_bool) arg_parser.add_argument( "--thread-pool-parallelism-degree", help="The degree of parallelism to use when running task on a " f"concurrent thread pool (default: {constants.DEFAULT_THREAD_POOL_PARALLELISM_DEGREE})", default=constants.DEFAULT_THREAD_POOL_PARALLELISM_DEGREE, type=config.get_thread_pool_parallelism_degree) arg_parser.add_argument( "--tx-mem-pool-bucket-size", help="The size of each bucket of the transaction mem pool. " "In order to efficiently iterate the mem pool concurrently, it is being split into buckets. " f"(default: {constants.DEFAULT_TX_MEM_POOL_BUCKET_SIZE})", default=constants.DEFAULT_TX_MEM_POOL_BUCKET_SIZE, type=int) return arg_parser
def get_argument_parser() -> argparse.ArgumentParser: # Parse gateway specific command line parameters arg_parser = argparse.ArgumentParser( parents=[cli.get_argument_parser()], description="Command line interface for the bloXroute Gateway.", usage="bloxroute_gateway --blockchain-protocol [PROTOCOL] [additional " "arguments]") arg_parser.add_argument( "--blockchain-protocol", help="Blockchain protocol. e.g BitcoinCash, Ethereum", type=str) arg_parser.add_argument("--blockchain-network", help="Blockchain network. e.g Mainnet, Testnet", type=str) arg_parser.add_argument("--blockchain-port", help="Blockchain node port", type=int) arg_parser.add_argument("--blockchain-ip", help="Blockchain node ip", type=ip_resolver.blocking_resolve_ip, default=None) arg_parser.add_argument( "--peer-gateways", help="Optional gateway peer ip/ports that will always be connected to. " "Should be in the format ip1:port1:GATEWAY,ip2:port2:GATEWAY", type=parse_peer_string, default="") arg_parser.add_argument( "--min-peer-gateways", help= "Minimum number of peer gateways before node will contact SDN for more.", type=int, default=0) arg_parser.add_argument( "--remote-blockchain-ip", help="Remote blockchain node ip to proxy messages from", type=ip_resolver.blocking_resolve_ip) arg_parser.add_argument( "--remote-blockchain-port", help="Remote blockchain node port to proxy messages from", type=int) arg_parser.add_argument( "--connect-to-remote-blockchain", help= "If gateway should proxy messages from a remote bloXroute owned blockchain node", type=convert.str_to_bool, default=True) arg_parser.add_argument("--encrypt-blocks", help="If gateway should encrypt blocks", type=convert.str_to_bool, default=False) arg_parser.add_argument( "--peer-relays", help= "(TEST ONLY) Optional relays peer ip/ports that will always be connected to. " "Should be in the format ip1:port1:RELAY,ip2:port2:RELAY,...", type=parse_peer_string, default="") arg_parser.add_argument( "--test-mode", help="(TEST ONLY) Test modes to run. Possible values: {0}".format( [TestModes.DROPPING_TXS]), default="", nargs="*") # Bitcoin specific arg_parser.add_argument("--blockchain-version", help="Bitcoin protocol version", type=int) arg_parser.add_argument("--blockchain-nonce", help="Bitcoin nonce", default=generate_default_nonce()) arg_parser.add_argument("--blockchain-net-magic", help="Bitcoin net.magic parameter", type=convert_net_magic) arg_parser.add_argument("--blockchain-services", help="Bitcoin services parameter", type=int) arg_parser.add_argument("--enable-node-cache", help="Retrieve peers from cookie if unavailable", type=convert.str_to_bool, default=True) # Ethereum specific arg_parser.add_argument( "--node-public-key", help="Public key of Ethereum node for encrypted communication", type=str) arg_parser.add_argument( "--private-key", help="Private key for encrypted communication with Ethereum node", type=str) arg_parser.add_argument("--network-id", help="Ethereum network id", type=int) arg_parser.add_argument("--genesis-hash", help="Genesis block hash of Ethereum network", type=str) arg_parser.add_argument( "--chain-difficulty", help="Difficulty of genesis block Ethereum network (hex)", type=str) arg_parser.add_argument( "--no-discovery", help="Disable discovery of Ethereum node and wait for node to connect", type=bool, default=False) arg_parser.add_argument( "--remote-public-key", help= "Public key of remote bloXroute owned Ethereum node for encrypted communication " "during chainstate sync ", type=str) arg_parser.add_argument( "--enode", help="Ethereum enode. ex) enode://<eth node public key>@<eth node " "ip>:<port>?discport=0", action=argument_parsers.ParseEnode, type=str, default=None) # Blockchain peers specified by --blockchain-peers and --blockchain-peers-file would be aggregated together arg_parser.add_argument( "--blockchain-peers", help="A comma separated list of node peer info. " "For Ethereum, the format is enode://<eth node public key>@<eth node ip>:<port>. " "For other blockchain protocols, the format is <ip>:<port>", action=argument_parsers.ParseBlockchainPeers, type=str, default=None) arg_parser.add_argument( "--blockchain-peers-file", help="A new line separated list of node peer info. " "For Ethereum, the format is enode://<eth node public key>@<eth node ip>:<port>. " "For other blockchain protocols, the format is <ip>:<port>", type=str, default=None) # IPC arg_parser.add_argument( "--ipc", help="Boolean indicating if IPC should be enabled.", type=convert.str_to_bool, default=False) arg_parser.add_argument( "--ipc-file", help="IPC filename that represents a unix domain socket", type=str, default="bxgateway.ipc") arg_parser.add_argument( "--should-restart-on-high-memory", help="Should a gateway restart itself if memory exceeds 2GB", type=convert.str_to_bool, default=True) # Ontology specific # TODO: Remove test only arguments arg_parser.add_argument( "--http-info-port", help="(TEST ONLY)Ontology http server port to view node information", type=int, default=config.get_env_default(GatewayStartArgs.HTTP_INFO_PORT)) arg_parser.add_argument("--consensus-port", help="Ontology consensus port", type=int, default=config.get_env_default( GatewayStartArgs.CONSENSUS_PORT)) arg_parser.add_argument("--relay", help="(TEST ONLY)Ontology relay state", type=convert.str_to_bool, default=config.get_env_default( GatewayStartArgs.RELAY_STATE)) arg_parser.add_argument("--is-consensus", help="(TEST ONLY)Ontology consensus node", type=convert.str_to_bool, default=config.get_env_default( GatewayStartArgs.IS_CONSENSUS)) arg_parser.add_argument( "--compact-block", help="Specify either the gateway supports compact block message or not", type=convert.str_to_bool, default=constants.ACCEPT_COMPACT_BLOCK) arg_parser.add_argument( "--compact-block-min-tx-count", help= "Minimal number of short transactions in compact block to attempt decompression.", type=int, default=btc_constants.BTC_COMPACT_BLOCK_DECOMPRESS_MIN_TX_COUNT) arg_parser.add_argument( "--dump-short-id-mapping-compression", help= "If true, the gateway will dump all short ids and txhashes compressed into a block", type=convert.str_to_bool, default=False, ) arg_parser.add_argument( "--dump-short-id-mapping-compression-path", help="Folder to dump compressed short ids to", default="/app/bxgateway/debug/compressed-short-ids", ) arg_parser.add_argument( "--tune-send-buffer-size", help= "If true, then the gateway will increase the send buffer's size for the blockchain connection", default=True, type=convert.str_to_bool, ) arg_parser.add_argument( "--max-block-interval-s", help= "Maximum time gateway holds a block while waiting for confirmation of receipt from blockchain node", type=int, default=gateway_constants.MAX_INTERVAL_BETWEEN_BLOCKS_S, ) arg_parser.add_argument( "--cookie-file-path", help="Cookie file path", type=str, ) arg_parser.add_argument( "--blockchain-message-ttl", help= "Duration to queue up messages for if blockchain node connection is broken", type=int, default=gateway_constants.DEFAULT_BLOCKCHAIN_MESSAGE_TTL_S, ) arg_parser.add_argument( "--remote-blockchain-message-ttl", help= "Duration to queue up messages for if remote blockchain node connection is broken", type=int, default=gateway_constants.DEFAULT_REMOTE_BLOCKCHAIN_MESSAGE_TTL_S, ) arg_parser.add_argument( "--stay-alive-duration", help= "Duration Gateway should stay alive for without an active blockchain or relay connection", type=int, default=gateway_constants.DEFAULT_STAY_ALIVE_DURATION_S, ) arg_parser.add_argument( "--initial-liveliness-check", help= "Duration Gateway should stay alive for without an initial blockchain or relay connection", type=int, default=gateway_constants.INITIAL_LIVELINESS_CHECK_S, ) arg_parser.add_argument( "--config-update-interval", help="update the node configuration on cron, 0 to disable", type=int, default=gateway_constants.CONFIG_UPDATE_INTERVAL_S, ) arg_parser.add_argument( "--require-blockchain-connection", help= "Close gateway if connection with blockchain node can't be established " "when the flag is set to True", type=convert.str_to_bool, default=True, ) default_tx_quota_type = config.get_env_default( GatewayStartArgs.DEFAULT_TX_QUOTA_TYPE) arg_parser.add_argument( "--default-tx-quota-type", help= f"quota type to use when distributing transactions to the Bdn network (default: {default_tx_quota_type})", type=QuotaType.from_string, choices=list(QuotaType), default=default_tx_quota_type, ) arg_parser.add_argument( "--ws", help=f"Enable RPC websockets server (default: False)", type=convert.str_to_bool, default=False, ) arg_parser.add_argument( "--ws-host", help= f"Websockets server listening host (default: {gateway_constants.WS_DEFAULT_HOST})", type=str, default=gateway_constants.WS_DEFAULT_HOST, ) arg_parser.add_argument( "--ws-port", help= f"Websockets server listening port (default: {gateway_constants.WS_DEFAULT_PORT}", type=int, default=gateway_constants.WS_DEFAULT_PORT, ) arg_parser.add_argument( "--eth-ws-uri", help="Ethereum websockets endpoint for syncing transaction content", type=str, ) arg_parser.add_argument( "--process-node-txs-in-extension", help= "If true, then the gateway will process transactions received from blockchain node using C++ extension", default=True, type=convert.str_to_bool, ) # TODO temp arg, need to be removed arg_parser.add_argument( "--enable-eth-extensions", help= "If true, run compression and decompression using C++ extensions code", default=True, type=convert.str_to_bool, ) arg_parser.add_argument( "--request-recovery", help= "If true, gateway will send transaction recovery request to relay when unable to decompress a block", default=True, type=convert.str_to_bool, ) arg_parser.add_argument( "--enable-block-compression", help= "If set, overrides value from the SDN, and might be changed if SDN sent an update", type=convert.str_to_bool, nargs='?', ) arg_parser.add_argument( "--filter-txs-factor", help= "Ethereum only. Sets the factor of the average gas price to filter transactions below. " "(i.e. 0 => send all transactions (average * 0), 1 => send all transactions with average or " "higher gas price, etc.)", type=float, default=0) return arg_parser
def get_argument_parser() -> argparse.ArgumentParser: arg_parser = argparse.ArgumentParser(add_help=False) arg_parser.add_argument("--external-ip", help="External network ip of this node", type=ip_resolver.blocking_resolve_ip) arg_parser.add_argument("--external-port", help="External network port to listen on", type=int, default=config.get_env_default(NodeStartArgs.EXTERNAL_PORT)) arg_parser.add_argument("--non-ssl-port", help="External network port for non SSL nodes to listen on", type=int, default=config.get_env_default(NodeStartArgs.NON_SSL_PORT)) arg_parser.add_argument("--continent", help="The continent of this node", type=str, choices=["NA", "SA", "EU", "AS", "AF", "OC", "AN"]) arg_parser.add_argument("--country", help="The country of this node.", type=str) arg_parser.add_argument("--region", help="The region of this node.", type=str) arg_parser.add_argument("--hostname", help="Hostname the node is running on", type=str, default=constants.HOSTNAME) arg_parser.add_argument("--sdn-url", help="IP or dns of the bloxroute SDN", type=str, default=config.get_env_default(NodeStartArgs.SDN_ROOT_URL)) arg_parser.add_argument( "--node-id", help="(TEST ONLY) Set the node_id for using in testing." ) arg_parser.add_argument("--transaction-pool-memory-limit", help="Maximum size of transactions to keep in memory pool (MB)", type=int) arg_parser.add_argument("--info-stats-interval", help="Frequency of info statistics logs in seconds", type=int, default=constants.INFO_STATS_INTERVAL_S) arg_parser.add_argument("--throughput-stats-interval", help="Frequency of throughput statistics logs in seconds", type=int, default=constants.THROUGHPUT_STATS_INTERVAL_S) arg_parser.add_argument("--memory-stats-interval", help="Frequency of memory statistics logs in seconds", type=int, default=constants.MEMORY_STATS_INTERVAL_S) arg_parser.add_argument("--dump-detailed-report-at-memory-usage", help="Total memory usage of application when detailed memory report " "should be dumped to log (MB)", type=int, default=(2 * 1024)) arg_parser.add_argument("--dump-removed-short-ids", help="Dump removed short ids to a file at a fixed interval", type=convert.str_to_bool, default=False) arg_parser.add_argument("--dump-removed-short-ids-path", help="Folder to dump removed short ids to", type=str, default=constants.DUMP_REMOVED_SHORT_IDS_PATH) arg_parser.add_argument("--enable-buffered-send", help="Enables buffering of sent byte to improve performance", type=convert.str_to_bool, default=False) arg_parser.add_argument("--track-detailed-sent-messages", help="Enables tracking of messages written on socket", type=convert.str_to_bool, default=False) arg_parser.add_argument( "--use-extensions", help="If true than the node will use the extension module for " "some tasks like block compression (default: {0})".format(constants.USE_EXTENSION_MODULES), default=constants.USE_EXTENSION_MODULES, type=convert.str_to_bool ) arg_parser.add_argument( "--import-extensions", help="If true than the node will import all C++ extensions dependencies on start up", default=False, type=convert.str_to_bool ) arg_parser.add_argument( "--thread-pool-parallelism-degree", help="The degree of parallelism to use when running task on a " f"concurrent thread pool (default: {constants.DEFAULT_THREAD_POOL_PARALLELISM_DEGREE})", default=constants.DEFAULT_THREAD_POOL_PARALLELISM_DEGREE, type=config.get_thread_pool_parallelism_degree ) arg_parser.add_argument( "--tx-mem-pool-bucket-size", help="The size of each bucket of the transaction mem pool. " "In order to efficiently iterate the mem pool concurrently, it is being split into buckets. " f"(default: {constants.DEFAULT_TX_MEM_POOL_BUCKET_SIZE})", default=constants.DEFAULT_TX_MEM_POOL_BUCKET_SIZE, type=int ) arg_parser.add_argument( "--sync-tx-service", help="sync tx service in node", type=convert.str_to_bool, default=True ) arg_parser.add_argument( "--block-compression-debug", help="Enable debug messages with details of the compressed blocks", type=convert.str_to_bool, default=True ) arg_parser.add_argument( "--enable-tcp-quickack", help="Enable TCP_QUICKACK so that ACK's are not delayed", type=convert.str_to_bool, default=True ) add_argument_parser_logging(arg_parser) add_argument_parser_common(arg_parser) return arg_parser