Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use validators file to stake, unstake, etc #409

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

popenta
Copy link
Contributor

@popenta popenta commented Feb 7, 2024

Added a parameter --validators-file for staking operations like remove-nodes, stake-nodes, unbond-nodes, unstake-nodes and unjail-nodes.

The commands can be used by providing the bls keys using --bls-keys or the validators file using --validators-file.

@popenta popenta self-assigned this Feb 7, 2024
validators_file = args.validators_file

if not bls_keys and not validators_file:
raise errors.BadUsage("No bls keys or validators file provided")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally, can be changed to do this, do that: "Either specify the ..., or the ...".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "multiversx-sdk-cli"
version = "9.4.1"
version = "9.5.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -72,7 +73,45 @@ def test_remove_nodes(capsys: Any):
assert transaction["gasLimit"] == 13645500


def test_stake_nodes(capsys: Any):
def test_remove_nodes_with_validators_file(capsys: Any):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment on lines 112 to 117
if args.bls_keys:
public_keys = self._parse_public_bls_keys(args.bls_keys)
else:
validators_file_path = Path(args.validators_file).expanduser()
validators_file = ValidatorsFile(validators_file_path)
public_keys = validators_file.load_public_keys()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be extracted to _load_validator_public_keys(args) (duplicated below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted the code in a method

Comment on lines 43 to 46
validator_pem = Path(validator.get("pemFile")).expanduser()
validator_pem = validator_pem if validator_pem.is_absolute() else self.validators_file_path.parent / validator_pem

pem_file = ValidatorPEM.from_file(validator_pem)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 lines can also be extracted to a separate function e.g. load_validator_pem(path): ValidatorPEM / optional (code exists above, as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted in a method

@popenta popenta merged commit 26f5889 into main Feb 8, 2024
11 checks passed
@popenta popenta deleted the stake-nodes-with-validators-file branch February 8, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants