diff --git a/indy_client/test/cli/test_send_claim_def_permission_all.py b/indy_client/test/cli/test_send_claim_def_permission_all.py new file mode 100644 index 000000000..8b98f0efc --- /dev/null +++ b/indy_client/test/cli/test_send_claim_def_permission_all.py @@ -0,0 +1,36 @@ +import json +import pytest + +from indy_common.auth import Authoriser +from plenum.test.helper import sdk_sign_request_from_dict, sdk_send_and_check + +from indy_node.test.anon_creds.conftest import claim_def + + +@pytest.fixture(scope="module") +def tconf(tconf): + # We need to reset authorization map to set new authorization rules + Authoriser.auth_map = None + OLD_WRITES_REQUIRE_TRUST_ANCHOR = tconf.WRITES_REQUIRE_TRUST_ANCHOR + tconf.WRITES_REQUIRE_TRUST_ANCHOR = False + + yield tconf + + tconf.WRITES_REQUIRE_TRUST_ANCHOR = OLD_WRITES_REQUIRE_TRUST_ANCHOR + Authoriser.auth_map = None + + +def test_client_can_send_claim_def(looper, + txnPoolNodeSet, + sdk_wallet_client, + sdk_wallet_trust_anchor, + sdk_pool_handle, + claim_def, + tconf): + # Trust anchor can create claim_def in any case + req = sdk_sign_request_from_dict(looper, sdk_wallet_trust_anchor, claim_def) + sdk_send_and_check([json.dumps(req)], looper, txnPoolNodeSet, sdk_pool_handle) + + # Client can create claim_def if WRITES_REQUIRE_TRUST_ANCHOR flag set to False + req = sdk_sign_request_from_dict(looper, sdk_wallet_client, claim_def) + sdk_send_and_check([json.dumps(req)], looper, txnPoolNodeSet, sdk_pool_handle) diff --git a/indy_client/test/cli/test_send_claim_def_permission_no_client.py b/indy_client/test/cli/test_send_claim_def_permission_no_client.py new file mode 100644 index 000000000..8346367da --- /dev/null +++ b/indy_client/test/cli/test_send_claim_def_permission_no_client.py @@ -0,0 +1,39 @@ +import json +import pytest + +from indy_common.auth import Authoriser +from plenum.common.exceptions import RequestRejectedException +from plenum.test.helper import sdk_sign_request_from_dict, sdk_send_and_check, sdk_send_signed_requests, \ + sdk_get_bad_response + +from indy_node.test.anon_creds.conftest import claim_def + + +@pytest.fixture(scope="module") +def tconf(tconf): + # We need to reset authorization map to set new authorization rules + Authoriser.auth_map = None + OLD_WRITES_REQUIRE_TRUST_ANCHOR = tconf.WRITES_REQUIRE_TRUST_ANCHOR + tconf.WRITES_REQUIRE_TRUST_ANCHOR = True + + yield tconf + + tconf.WRITES_REQUIRE_TRUST_ANCHOR = OLD_WRITES_REQUIRE_TRUST_ANCHOR + Authoriser.auth_map = None + + +def test_client_cant_send_claim_def(looper, + txnPoolNodeSet, + sdk_wallet_client, + sdk_wallet_trust_anchor, + sdk_pool_handle, + claim_def, + tconf): + # Trust anchor can create claim_def in any case + req = sdk_sign_request_from_dict(looper, sdk_wallet_trust_anchor, claim_def) + sdk_send_and_check([json.dumps(req)], looper, txnPoolNodeSet, sdk_pool_handle) + + # Client cant send create if WRITES_REQUIRE_TRUST_ANCHOR flag set to True + req = sdk_sign_request_from_dict(looper, sdk_wallet_client, claim_def) + req = sdk_send_signed_requests(sdk_pool_handle, [json.dumps(req)]) + sdk_get_bad_response(looper, req, RequestRejectedException, 'None role cannot add claim def') diff --git a/indy_client/test/cli/test_send_schema_permission_all.py b/indy_client/test/cli/test_send_schema_permission_all.py new file mode 100644 index 000000000..b5f82a68f --- /dev/null +++ b/indy_client/test/cli/test_send_schema_permission_all.py @@ -0,0 +1,42 @@ +import json + +import pytest +from indy.anoncreds import issuer_create_schema +from indy.ledger import build_schema_request + +from indy_common.auth import Authoriser +from plenum.test.helper import sdk_get_and_check_replies, sdk_sign_and_submit_req + + +@pytest.fixture(scope="module") +def tconf(tconf): + # We need to reset authorization map to set new authorization rules + Authoriser.auth_map = None + OLD_WRITES_REQUIRE_TRUST_ANCHOR = tconf.WRITES_REQUIRE_TRUST_ANCHOR + tconf.WRITES_REQUIRE_TRUST_ANCHOR = False + + yield tconf + + tconf.WRITES_REQUIRE_TRUST_ANCHOR = OLD_WRITES_REQUIRE_TRUST_ANCHOR + Authoriser.auth_map = None + + +def test_client_can_send_schema(looper, + txnPoolNodeSet, + sdk_wallet_client, + sdk_wallet_trust_anchor, + sdk_pool_handle, + tconf): + # Trust anchor can create schema in any case + _, identifier = sdk_wallet_trust_anchor + _, schema_json = looper.loop.run_until_complete( + issuer_create_schema(identifier, "name", "1.0", json.dumps(["first", "last"]))) + request = looper.loop.run_until_complete(build_schema_request(identifier, schema_json)) + sdk_get_and_check_replies(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trust_anchor, request)]) + + # Client can create schema if WRITES_REQUIRE_TRUST_ANCHOR flag set to False + _, identifier = sdk_wallet_client + _, schema_json = looper.loop.run_until_complete( + issuer_create_schema(identifier, "name", "1.0", json.dumps(["first", "last"]))) + request = looper.loop.run_until_complete(build_schema_request(identifier, schema_json)) + sdk_get_and_check_replies(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_client, request)]) diff --git a/indy_client/test/cli/test_send_schema_permission_no_client.py b/indy_client/test/cli/test_send_schema_permission_no_client.py new file mode 100644 index 000000000..a0ab7b056 --- /dev/null +++ b/indy_client/test/cli/test_send_schema_permission_no_client.py @@ -0,0 +1,45 @@ +import json + +import pytest +from indy.anoncreds import issuer_create_schema +from indy.ledger import build_schema_request + +from indy_common.auth import Authoriser +from plenum.common.exceptions import RequestRejectedException + +from plenum.test.helper import sdk_get_bad_response, sdk_sign_and_submit_req, sdk_get_and_check_replies + + +@pytest.fixture(scope="module") +def tconf(tconf): + # We need to reset authorization map to set new authorization rules + Authoriser.auth_map = None + OLD_WRITES_REQUIRE_TRUST_ANCHOR = tconf.WRITES_REQUIRE_TRUST_ANCHOR + tconf.WRITES_REQUIRE_TRUST_ANCHOR = True + + yield tconf + + tconf.WRITES_REQUIRE_TRUST_ANCHOR = OLD_WRITES_REQUIRE_TRUST_ANCHOR + Authoriser.auth_map = None + + +def test_client_cant_send_schema(looper, + txnPoolNodeSet, + sdk_wallet_client, + sdk_wallet_trust_anchor, + sdk_pool_handle, + tconf): + # Trust anchor can create schema in any case + _, identifier = sdk_wallet_trust_anchor + _, schema_json = looper.loop.run_until_complete( + issuer_create_schema(identifier, "another_name", "2.0", json.dumps(["first", "last"]))) + request = looper.loop.run_until_complete(build_schema_request(identifier, schema_json)) + sdk_get_and_check_replies(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trust_anchor, request)]) + + # Client cant create schema if WRITES_REQUIRE_TRUST_ANCHOR flag set to True + _, identifier = sdk_wallet_client + _, schema_json = looper.loop.run_until_complete( + issuer_create_schema(identifier, "another_name", "2.0", json.dumps(["first", "last"]))) + request = looper.loop.run_until_complete(build_schema_request(identifier, schema_json)) + sdk_get_bad_response(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_client, request)], + RequestRejectedException, 'None role cannot add schema') diff --git a/indy_common/auth.py b/indy_common/auth.py index 1a3b3b7c8..143466036 100644 --- a/indy_common/auth.py +++ b/indy_common/auth.py @@ -1,3 +1,4 @@ +from indy_common.config_util import getConfig from plenum.common.constants import TRUSTEE, STEWARD, NODE from stp_core.common.log import getlogger @@ -12,10 +13,8 @@ # TODO: make this class the only point of authorization and checking permissions! # There are some duplicates of this logic in *_req_handler classes -class Authoriser: - ValidRoles = (TRUSTEE, TGB, STEWARD, TRUST_ANCHOR, None) - - AuthMap = { +def generate_auth_map(valid_roles, need_permission=None): + auth_map = { '{}_role__{}'.format(NYM, TRUSTEE): {TRUSTEE: []}, '{}_role__{}'.format(NYM, TGB): @@ -39,7 +38,7 @@ class Authoriser: '{}___'.format(CLAIM_DEF): {TRUSTEE: [OWNER, ], STEWARD: [OWNER, ], TRUST_ANCHOR: [OWNER, ]}, '{}_verkey__'.format(NYM): - {r: [OWNER] for r in ValidRoles}, + {r: [OWNER] for r in valid_roles}, '{}_services__[VALIDATOR]'.format(NODE): {STEWARD: [OWNER, ]}, # INDY-410 - steward allowed to demote/promote its validator @@ -68,6 +67,16 @@ class Authoriser: '{}___'.format(VALIDATOR_INFO): {TRUSTEE: [], STEWARD: []}, } + if need_permission is False or (need_permission is None and not getConfig().WRITES_REQUIRE_TRUST_ANCHOR): + auth_map['{}___'.format(SCHEMA)][None] = [] + auth_map['{}___'.format(CLAIM_DEF)][None] = [OWNER] + return auth_map + + +class Authoriser: + ValidRoles = (TRUSTEE, TGB, STEWARD, TRUST_ANCHOR, None) + + auth_map = None @staticmethod def isValidRole(role) -> bool: @@ -94,17 +103,19 @@ def isValidRoleName(roleName) -> bool: @staticmethod def authorised(typ, actorRole, field=None, oldVal=None, newVal=None, isActorOwnerOfSubject=None) -> (bool, str): + if not Authoriser.auth_map: + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles) field = field if field is not None else "" oldVal = '' if oldVal is None else \ str(oldVal).replace('"', '').replace("'", '') newVal = '' if newVal is None else \ str(newVal).replace('"', '').replace("'", '') key = '_'.join([typ, field, oldVal, newVal]) - if key not in Authoriser.AuthMap: + if key not in Authoriser.auth_map: any_value = '_'.join([typ, field, '', '']) - if any_value not in Authoriser.AuthMap: + if any_value not in Authoriser.auth_map: any_field = '_'.join([typ, "", '', '']) - if any_field not in Authoriser.AuthMap: + if any_field not in Authoriser.auth_map: msg = "key '{}' not found in authorized map".format(key) logger.debug(msg) return False, msg @@ -112,10 +123,10 @@ def authorised(typ, actorRole, field=None, oldVal=None, newVal=None, key = any_field else: key = any_value - roles = Authoriser.AuthMap[key] + roles = Authoriser.auth_map[key] if actorRole not in roles: roles_as_str = [Roles.nameFromValue(role) for role in roles.keys()] - return False, '{} not in allowed roles {}'.\ + return False, '{} not in allowed roles {}'. \ format(Roles.nameFromValue(actorRole), roles_as_str) roleDetails = roles[actorRole] if len(roleDetails) == 0: diff --git a/indy_common/config.py b/indy_common/config.py index bbf635012..06bcf7ff9 100644 --- a/indy_common/config.py +++ b/indy_common/config.py @@ -107,3 +107,5 @@ # Top level packet to be updated via pool upgrade command UPGRADE_ENTRY = 'indy-node' + +WRITES_REQUIRE_TRUST_ANCHOR = True diff --git a/indy_common/test/auth/conftest.py b/indy_common/test/auth/conftest.py index cd97492a9..493e89135 100644 --- a/indy_common/test/auth/conftest.py +++ b/indy_common/test/auth/conftest.py @@ -1,4 +1,6 @@ import pytest + +from indy_common.auth import Authoriser, generate_auth_map from plenum.common.constants import STEWARD, TRUSTEE from indy_common.constants import TRUST_ANCHOR, TGB @@ -17,3 +19,8 @@ def is_owner(request): @pytest.fixture(scope='function', params=[None, "value1"]) def old_values(request): return request.param + + +@pytest.fixture(scope='module') +def initialized_auth_map(): + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles, True) diff --git a/indy_common/test/auth/test_auth_claim_def.py b/indy_common/test/auth/test_auth_claim_def.py index 00d10925c..91f5d5a4b 100644 --- a/indy_common/test/auth/test_auth_claim_def.py +++ b/indy_common/test/auth/test_auth_claim_def.py @@ -1,31 +1,31 @@ from plenum.common.constants import TRUSTEE, STEWARD -from indy_common.auth import Authoriser +from indy_common.auth import Authoriser, generate_auth_map from indy_common.constants import REF, TGB, TRUST_ANCHOR, CLAIM_DEF -def test_claim_def_adding(): +def test_claim_def_adding(initialized_auth_map): roles = {TRUSTEE, STEWARD, TRUST_ANCHOR} for role in roles: r, msg = _authorised_for_claim_def(role, True) assert r and not msg -def test_claim_def_adding_without_permission(): +def test_claim_def_adding_without_permission(initialized_auth_map): roles = {TGB, None} for role in roles: r, msg = _authorised_for_claim_def(role, True) assert not r and msg -def test_claim_def_adding_not_owner(): +def test_claim_def_adding_not_owner(initialized_auth_map): roles = {TRUSTEE, STEWARD, TRUST_ANCHOR} for role in roles: r, msg = _authorised_for_claim_def(role, False) assert not r and msg == "Only owner is allowed" -def test_claim_def_adding_with_some_field(): +def test_claim_def_adding_with_some_field(initialized_auth_map): r, msg = Authoriser.authorised(typ=CLAIM_DEF, actorRole=TRUSTEE, field="name", @@ -33,6 +33,26 @@ def test_claim_def_adding_with_some_field(): assert r and not msg +def test_client_can_send_claim_def(): + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles, False) + + r, msg = Authoriser.authorised(typ=CLAIM_DEF, + actorRole=None, + field="name", + isActorOwnerOfSubject=True) + assert r and not msg + + +def test_client_cant_send_claim_def(): + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles, True) + + r, msg = Authoriser.authorised(typ=CLAIM_DEF, + actorRole=None, + field="name", + isActorOwnerOfSubject=True) + assert not r and "None role not in allowed roles" in msg + + def _authorised_for_claim_def(role, is_owner): return Authoriser.authorised(typ=CLAIM_DEF, actorRole=role, diff --git a/indy_common/test/auth/test_auth_schema.py b/indy_common/test/auth/test_auth_schema.py index 8a07e7e69..58e3d0f6b 100644 --- a/indy_common/test/auth/test_auth_schema.py +++ b/indy_common/test/auth/test_auth_schema.py @@ -1,23 +1,37 @@ from plenum.common.constants import TRUSTEE, STEWARD -from indy_common.auth import Authoriser +from indy_common.auth import Authoriser, generate_auth_map from indy_common.constants import NAME, TGB, TRUST_ANCHOR, SCHEMA -def test_schema_adding(): +def test_schema_adding(initialized_auth_map): roles = {TRUSTEE, STEWARD, TRUST_ANCHOR} for role in roles: r, msg = _authorised_for_schemas(role) assert r and not msg -def test_schema_adding_without_permission(): +def test_schema_adding_without_permission(initialized_auth_map): roles = {TGB, None} for role in roles: r, msg = _authorised_for_schemas(role) assert not r and msg +def test_client_can_send_claim_def(): + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles, False) + + r, msg = _authorised_for_schemas(None) + assert r and not msg + + +def test_client_cant_send_claim_def(): + Authoriser.auth_map = generate_auth_map(Authoriser.ValidRoles, True) + + r, msg = _authorised_for_schemas(None) + assert not r and "None role not in allowed roles" in msg + + def _authorised_for_schemas(role): return Authoriser.authorised(typ=SCHEMA, actorRole=role) diff --git a/scripts/get_metrics b/scripts/get_metrics index 36471b15c..3c4321cf4 100755 --- a/scripts/get_metrics +++ b/scripts/get_metrics @@ -7,11 +7,11 @@ import argparse import logging import os import shutil -from datetime import datetime +from datetime import datetime, timedelta from indy_common.config_util import getConfig from plenum.common.constants import KeyValueStorageType -from plenum.common.metrics_collector import MetricsType +from plenum.common.metrics_collector import MetricsName from plenum.common.metrics_stats import load_metrics_from_kv_store from storage.helper import initKeyValueStorage @@ -27,19 +27,27 @@ def read_args(): parser.add_argument('--data_dir', required=False, help="Path to metrics data, replaces a") parser.add_argument('--node_name', required=False, help="Node's name") parser.add_argument('--network', required=False, help="Network name to read metrics from") + parser.add_argument('--output', required=False, default="metrics.csv", help="Output CSV file name with metrics") parser.add_argument( '--min_ts', type=datetime, required=False, default=None, - help="process all metrics starting from given timestamp (beginning by default)") + help="Process all metrics starting from given timestamp (beginning by default)") parser.add_argument( '--max_ts', type=datetime, required=False, default=None, - help="process all metrics till given timestamp (end by default)") + help="Process all metrics till given timestamp (end by default)") + parser.add_argument( + '--step', + type=int, + required=False, + default=60, + help="Build timelog with given timestep, seconds (60 by default)" + ) return parser.parse_args() @@ -72,56 +80,107 @@ def make_copy_of_data(data_dir): return read_copy_data_dir -def process_storage(storage, min_ts, max_ts): - stats = load_metrics_from_kv_store(storage, min_ts, max_ts) +def process_storage(storage, args): + stats = load_metrics_from_kv_store(storage, args.min_ts, args.max_ts, timedelta(seconds=args.step)) + + with open(args.output, 'w') as f: + columns = [ + "timestamp", + "avg_looper_run_time_spent", + "avg_three_pc_batch_size", + "avg_incoming_node_message_size", + "avg_outgoing_node_message_size", + "avg_incoming_client_message_size", + "avg_outgoing_client_message_size", + "node_stack_messages_processed_per_sec", + "client_stack_messages_processed_per_sec", + "three_pc_batch_count_per_sec", + "requests_count_per_sec", + "incoming_node_messages_per_sec", + "incoming_node_traffic_per_sec", + "outgoing_node_messages_per_sec", + "outgoing_node_traffic_per_sec", + "incoming_client_messages_per_sec", + "incoming_client_traffic_per_sec", + "outgoing_client_messages_per_sec", + "outgoing_client_traffic_per_sec" + ] + f.write(",".join(columns)) + f.write("\n") + for ts, frame in sorted(stats.frames(), key=lambda v: v[0]): + row = [ + ts.replace(microsecond=0), + frame.get(MetricsName.LOOPER_RUN_TIME_SPENT).avg, + frame.get(MetricsName.THREE_PC_BATCH_SIZE).avg, + frame.get(MetricsName.INCOMING_NODE_MESSAGE_SIZE).avg, + frame.get(MetricsName.OUTGOING_NODE_MESSAGE_SIZE).avg, + frame.get(MetricsName.INCOMING_CLIENT_MESSAGE_SIZE).avg, + frame.get(MetricsName.OUTGOING_CLIENT_MESSAGE_SIZE).avg, + frame.get(MetricsName.NODE_STACK_MESSAGES_PROCESSED).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.CLIENT_STACK_MESSAGES_PROCESSED).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.THREE_PC_BATCH_SIZE).count / stats.timestep.total_seconds(), + frame.get(MetricsName.THREE_PC_BATCH_SIZE).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.INCOMING_NODE_MESSAGE_SIZE).count / stats.timestep.total_seconds(), + frame.get(MetricsName.INCOMING_NODE_MESSAGE_SIZE).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.OUTGOING_NODE_MESSAGE_SIZE).count / stats.timestep.total_seconds(), + frame.get(MetricsName.OUTGOING_NODE_MESSAGE_SIZE).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.INCOMING_CLIENT_MESSAGE_SIZE).count / stats.timestep.total_seconds(), + frame.get(MetricsName.INCOMING_CLIENT_MESSAGE_SIZE).sum / stats.timestep.total_seconds(), + frame.get(MetricsName.OUTGOING_CLIENT_MESSAGE_SIZE).count / stats.timestep.total_seconds(), + frame.get(MetricsName.OUTGOING_CLIENT_MESSAGE_SIZE).sum / stats.timestep.total_seconds() + ] + f.write(",".join(str(v if v else "0") for v in row)) + f.write("\n") print("Start time: {}".format(stats.min_ts)) print("End time: {}".format(stats.max_ts)) print("Duration: {}".format(stats.max_ts - stats.min_ts)) print("") + total = stats.total + print("Number of node messages processed in one looper run:") - print(" {}".format(stats.get(MetricsType.NODE_STACK_MESSAGES_PROCESSED))) + print(" {}".format(total.get(MetricsName.NODE_STACK_MESSAGES_PROCESSED))) print("") print("Number of client messages processed in one looper run:") - print(" {}".format(stats.get(MetricsType.CLIENT_STACK_MESSAGES_PROCESSED))) + print(" {}".format(total.get(MetricsName.CLIENT_STACK_MESSAGES_PROCESSED))) print("") print("Seconds passed between looper runs:") - print(" {}".format(stats.get(MetricsType.LOOPER_RUN_TIME_SPENT))) + print(" {}".format(total.get(MetricsName.LOOPER_RUN_TIME_SPENT))) print("") print("Number of requests in one 3PC batch:") - print(" {}".format(stats.get(MetricsType.THREE_PC_BATCH_SIZE))) + print(" {}".format(total.get(MetricsName.THREE_PC_BATCH_SIZE))) print("") print("Number of messages in one tranport batch:") - print(" {}".format(stats.get(MetricsType.TRANSPORT_BATCH_SIZE))) + print(" {}".format(total.get(MetricsName.TRANSPORT_BATCH_SIZE))) print("") print("Incoming node message size, bytes:") - print(" {}".format(stats.get(MetricsType.INCOMING_NODE_MESSAGE_SIZE))) + print(" {}".format(total.get(MetricsName.INCOMING_NODE_MESSAGE_SIZE))) print("") print("Outgoing node message size, bytes:") - print(" {}".format(stats.get(MetricsType.OUTGOING_NODE_MESSAGE_SIZE))) + print(" {}".format(total.get(MetricsName.OUTGOING_NODE_MESSAGE_SIZE))) print("") print("Incoming client message size, bytes:") - print(" {}".format(stats.get(MetricsType.INCOMING_CLIENT_MESSAGE_SIZE))) + print(" {}".format(total.get(MetricsName.INCOMING_CLIENT_MESSAGE_SIZE))) print("") print("Outgoing client message size, bytes:") - print(" {}".format(stats.get(MetricsType.OUTGOING_CLIENT_MESSAGE_SIZE))) + print(" {}".format(total.get(MetricsName.OUTGOING_CLIENT_MESSAGE_SIZE))) print("") print("Additional statistics:") - three_pc = stats.get(MetricsType.THREE_PC_BATCH_SIZE) - node_in = stats.get(MetricsType.INCOMING_NODE_MESSAGE_SIZE) - node_out = stats.get(MetricsType.OUTGOING_NODE_MESSAGE_SIZE) - client_in = stats.get(MetricsType.INCOMING_CLIENT_MESSAGE_SIZE) - client_out = stats.get(MetricsType.OUTGOING_CLIENT_MESSAGE_SIZE) + three_pc = total.get(MetricsName.THREE_PC_BATCH_SIZE) + node_in = total.get(MetricsName.INCOMING_NODE_MESSAGE_SIZE) + node_out = total.get(MetricsName.OUTGOING_NODE_MESSAGE_SIZE) + client_in = total.get(MetricsName.INCOMING_CLIENT_MESSAGE_SIZE) + client_out = total.get(MetricsName.OUTGOING_CLIENT_MESSAGE_SIZE) node_messages = node_in.count + node_out.count node_traffic = node_in.sum + node_out.sum client_messages = (client_in.count + client_out.count) @@ -143,7 +202,7 @@ if __name__ == '__main__': if args.data_dir is not None: storage = initKeyValueStorage(KeyValueStorageType.Rocksdb, args.data_dir, "") - process_storage(storage, args.min_ts, args.max_ts) + process_storage(storage, args) exit() data_dir = get_data_dir(args.node_name, args.network) @@ -159,7 +218,7 @@ if __name__ == '__main__': data_dir, config.METRICS_KV_DB_NAME) - process_storage(storage, args.min_ts, args.max_ts) + process_storage(storage, args) finally: if data_is_copied: shutil.rmtree(data_dir) diff --git a/setup.py b/setup.py index f8e132bbc..0ebce1ae1 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ data_files=[( (BASE_DIR, ['data/nssm_original.exe']) )], - install_requires=['indy-plenum-dev==1.5.483', + install_requires=['indy-plenum-dev==1.5.484', 'indy-anoncreds-dev==1.0.32', 'python-dateutil', 'timeout-decorator==0.4.0'], @@ -72,6 +72,7 @@ 'scripts/start_node_control_tool', 'scripts/clear_node.py', 'scripts/get_keys', + 'scripts/get_metrics', 'scripts/generate_indy_pool_transactions', 'scripts/init_indy_keys', 'scripts/upgrade_indy_node_ubuntu1604.sh',