Exemple #1
0
def retract_candidate_fork_readiness_signal(args):
    core_api_helper = CoreApiHelper(False)
    should_vote = input(
        f"This action will retract your candidate fork readiness signal (if there was one), continue? [Y/n]{bcolors.ENDC}"
    )
    if Helpers.check_Yes(should_vote):
        core_api_helper.withdraw_vote(print_response=True)
Exemple #2
0
def signal_candidate_fork_readiness(args):
    core_api_helper = CoreApiHelper(False)
    health = DefaultApiHelper(False).health()
    if health['fork_vote_status'] == 'VOTE_REQUIRED':
        candidate_fork_name = core_api_helper.engine_configuration(
        )["forks"][-1]['name']
        print(
            f"{bcolors.WARNING}NOTICE: Because the validator is running software with a candidate fork ({candidate_fork_name}{bcolors.WARNING}), "
            +
            "by performing this action, the validator will signal the readiness to run this fork onto the ledger.\n"
            +
            f"If you later choose to downgrade the software to a version that no longer includes this fork configuration, you should manually retract your readiness signal by using the retract-candidate-fork-readiness-signal subcommand.{bcolors.ENDC}"
        )
        should_vote = input(
            f"Do you want to signal the readiness for {core_api_helper.engine_configuration().forks[-1]['name']} now? [Y/n]{bcolors.ENDC}"
        )
        if Helpers.check_Yes(should_vote):
            core_api_helper.vote(print_response=True)
    else:
        print(
            f"{bcolors.WARNING}There's no need to signal the readiness for any candidate fork.{bcolors.ENDC}"
        )
Exemple #3
0
def entity(args):
    core_api_helper = CoreApiHelper(False)
    key_list_response: KeyListResponse = core_api_helper.key_list(False)
    validator_address = key_list_response.public_keys[
        0].identifiers.validator_entity_identifier.address
    account_address = key_list_response.public_keys[
        0].identifiers.account_entity_identifier.address
    if args.validator:
        if args.subEntitySystem:
            subEntity = SubEntity(address=str("system"))
            entityIdentifier = EntityIdentifier(address=validator_address,
                                                sub_entity=subEntity)
        else:
            entityIdentifier = EntityIdentifier(address=validator_address, )

        core_api_helper.entity(entityIdentifier, True)
        sys.exit()
    if args.address:
        if args.subPreparedStake:
            metadata = SubEntityMetadata(validator=validator_address)
            subEntity = SubEntity(address=str("prepared_stake"),
                                  metadata=metadata)
            entityIdentifier = EntityIdentifier(address=account_address,
                                                sub_entity=subEntity)
        if args.subPreparedUnStake:
            metadata = SubEntityMetadata(validator=validator_address)
            subEntity = SubEntity(address=str("prepared_unstake"),
                                  metadata=metadata)
            entityIdentifier = EntityIdentifier(address=account_address,
                                                sub_entity=subEntity)
        if args.subExitingStake:
            metadata = SubEntityMetadata(validator=validator_address)
            subEntity = SubEntity(address=str("exiting_stake"),
                                  metadata=metadata)
            entityIdentifier = EntityIdentifier(address=account_address,
                                                sub_entity=subEntity)
        else:
            entityIdentifier = EntityIdentifier(address=account_address, )
        core_api_helper.entity(entityIdentifier, True)
        sys.exit()
    if args.p2p:
        core_api_helper.entity(
            key_list_response.public_keys[0].identifiers.p2p_node, True)
        sys.exit()
Exemple #4
0
class ApiTests(unittest.TestCase):
    """
    Below tests require environment variables exported before in hand. Below are the environment variables to export
    NODE_END_POINT=https://35.154.183.163
    DISABLE_VERSION_CHECK=true
    NGINX_ADMIN_PASSWORD=<Admin password for above node>
    NGINX_METRICS_PASSWORD=<metrics password for above node>
    NGINX_SUPERADMIN_PASSWORD=<superadmin password for above node>
    """

    core_api_helper = CoreApiHelper(False)

    @classmethod
    def setUpClass(cls):
        warnings.simplefilter("ignore")

    def test_network_configuration(self):
        self.assertIsInstance(self.core_api_helper.network_configuration(), NetworkConfigurationResponse)

    def test_network_status(self):
        self.assertIsInstance(self.core_api_helper.network_status(), NetworkStatusResponse)

    def test_key_list(self):
        self.assertIsInstance(self.core_api_helper.key_list(), KeyListResponse)

    def test_mempool(self):
        self.assertIsInstance(self.core_api_helper.mempool(), MempoolResponse)

    def test_entity(self):
        key_list_response: KeyListResponse = self.core_api_helper.key_list(True)
        response = self.core_api_helper.entity(key_list_response.public_keys[0].identifiers.validator_entity_identifier,
                                               True)
        self.assertIsInstance(response, EntityResponse)

    def test_construction_build(self):
        key_list_response: KeyListResponse = self.core_api_helper.key_list()
        validator_info: EntityResponse = self.core_api_helper.entity(
            key_list_response.public_keys[0].identifiers.validator_entity_identifier)
        actions = [Action().set_validator_registeration(False)]
        response = self.core_api_helper.construction_build(actions)
        self.assertIsInstance(response, ConstructionBuildResponse)

    def test_key_sign(self):
        key_list_response: KeyListResponse = self.core_api_helper.key_list()
        validator_info: EntityResponse = self.core_api_helper.entity(
            key_list_response.public_keys[0].identifiers.validator_entity_identifier)
        actions = [Action().set_validator_registeration(False)]
        build_response = self.core_api_helper.construction_build(actions)
        response = self.core_api_helper.key_sign(build_response.unsigned_transaction)
        self.assertIsInstance(response, KeySignResponse)
Exemple #5
0
def engine_configuration(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.engine_configuration(True)
Exemple #6
0
def network_configuration(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.network_configuration(True)
Exemple #7
0
def update_validator_config(args):
    health = DefaultApiHelper(verify_ssl=False).check_health()
    core_api_helper = CoreApiHelper(verify_ssl=False)

    key_list_response: KeyListResponse = core_api_helper.key_list()

    validator_info: EntityResponse = core_api_helper.entity(
        key_list_response.public_keys[0].identifiers.
        validator_entity_identifier)

    actions = []
    actions = ValidatorConfig.registration(actions, validator_info, health)
    actions = ValidatorConfig.validator_metadata(actions, validator_info,
                                                 health)
    actions = ValidatorConfig.add_validation_fee(actions, validator_info)
    actions = ValidatorConfig.setup_update_delegation(actions, validator_info)
    actions = ValidatorConfig.add_change_ownerid(actions, validator_info)
    build_response: ConstructionBuildResponse = core_api_helper.construction_build(
        actions, ask_user=True)
    if build_response:
        signed_transaction: KeySignResponse = core_api_helper.key_sign(
            build_response.unsigned_transaction)
        core_api_helper.construction_submit(
            signed_transaction.signed_transaction, print_response=True)

    if health['fork_vote_status'] == 'VOTE_REQUIRED':
        print("\n------Candidate fork detected------")
        engine_configuration = core_api_helper.engine_configuration()
        print_vote_and_fork_info(health, engine_configuration)
        should_vote = input(
            f"Do you want to signal the readiness for {core_api_helper.engine_configuration().forks[-1]['name']} now? [Y/n]{bcolors.ENDC}"
        )
        if Helpers.check_Yes(should_vote):
            core_api_helper.vote(print_response=True)
Exemple #8
0
def mempool_transaction(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.mempool_transaction(args.transactionId, True)
Exemple #9
0
def mempool(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.mempool(True)
Exemple #10
0
def key_list(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.key_list(True)
Exemple #11
0
def network_status(args):
    core_api_helper = CoreApiHelper(False)
    core_api_helper.network_status(True)
Exemple #12
0
def fork_information(args):
    engine_configuration = CoreApiHelper(False).engine_configuration()
    health = DefaultApiHelper(False).health()
    print_vote_and_fork_info(health, engine_configuration)