Code Monkey home page Code Monkey logo

validator-cli's Introduction

SKALE Validator CLI

Build and publish Test Discord

Table of Contents

  1. Installation
  2. CLI usage
    2.1 Init
    2.2 Validator commands
    2.3 Holder commands
    2.4 Metrics commands
    2.5 Wallet commands
    2.6 Self-recharging wallet commands
  3. Exit codes
  4. Development

Installation

Requirements

  • Linux x86_64 machine

  • Download executable

VERSION_NUM={put the version number here} && sudo -E bash -c "curl -L https://github.com/skalenetwork/validator-cli/releases/download/$VERSION_NUM/sk-val-$VERSION_NUM-`uname -s`-`uname -m` >  /usr/local/bin/sk-val"
  • Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/sk-val

Where to find out the latest version?

All validator-cli version numbers are available here: https://github.com/skalenetwork/validator-cli/releases

CLI Usage

Init

Download SKALE Manager contracts info and set the endpoint.

sk-val init

Required arguments:

  • --endpoint/-e - RPC endpoint of the node in the network where SKALE manager is deployed (http or https)
  • --contracts-url/-c - - URL to SKALE Manager contracts ABI and addresses
  • -w/--wallet - Type of the wallet that will be used for signing transactions (software, sgx or hardware)

If you want to use sgx wallet you need to initialize it first (see SGX commands)

Usage example:

sk-val init -e ws://geth.test.com:8546 -c https://test.com/manager.json --wallet software

SGX commands

Init

Initialize sgx wallet

sk-val sgx init [SGX_SERVER_URL]

Optional arguments:

  • --force/-f - Rewrite current sgx wallet data
  • --ssl-port - Port that is used by sgx server to establish tls connection

Info

Print sgx wallet information

sk-val sgx info 

Optional arguments:

  • --raw - Print info in plain json

Validator commands

Register

Register as a new SKALE validator

sk-val validator register

Required arguments:

  • --name/-n - Validator name
  • --description/-d - Validator description
  • --commission-rate/-c - Commission rate (percentage)
  • --min-delegation - Validator minimum delegation amount

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Usage example:

sk-val validator register -n test -d "test description" -c 20 --min-delegation 1000 --pk-file ./pk.txt

List

List of available validators

sk-val validator ls

Options:

  • --wei/-w - Show tokens amount in wei

Delegations

List of delegations for validator ID

sk-val validator delegations [VALIDATOR_ID]

Required params:

  1. VALIDATOR_ID - ID of the validator

Accept pending delegation

Accept pending delegation request by delegation ID

sk-val validator accept-delegation --pk-file ./pk.txt

Required arguments:

  • --delegation-id - ID of the delegation request to accept

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Accept all pending delegations

Accept ALL pending delegations request for the address.
List with all pending delegations to be accepted will be shown. After this user should confirm the operation.

sk-val validator accept-all-delegations --pk-file ./pk.txt

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Validator linked addresses

List of the linked addresses for validator address

sk-val validator linked-addresses [ADDRESS]

Required params:

  1. Address - Ethereum address of the validator

Link address

Link node address to the validator account

sk-val validator link-address [ADDRESS] [NODE_SIGNATURE] --pk-file ./pk.txt

Required params:

  1. Address - Ethereum address that will be linked
  2. Node signature - Signature of the node that you can get using skale node signature command from skale-node-cli

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Unlink address

Unlink node address from the validator account

sk-val validator unlink-address [ADDRESS] --pk-file ./pk.txt

Required params:

  1. Address - Ethereum address that will be unlinked

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Validator info

Info about the validator

sk-val validator info [VALIDATOR_ID]

Required params:

  1. Address - Ethereum address of the validator

Output info:

  1. Validator ID
  2. Name
  3. Address
  4. Fee rate (percent - %)
  5. Minimum delegation amount (SKL)
  6. Accepting new delegation requests

Withdraw fee

Withdraw earned fee to specified address

sk-val validator withdraw-fee [RECIPIENT_ADDRESS] --pk-file ./pk.txt

Required params:

  1. RECIPIENT_ADDRESS - Address to transfer bounty

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Set MDA

Set a new minimum delegation amount for the validator

sk-val validator set-mda [NEW_MDA] --pk-file ./pk.txt

Required params:

  1. NEW_MDA - New MDA value

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Request address change

Request address change for the validator

sk-val validator change-address [ADDRESS] --pk-file ./pk.txt

Required params:

  1. ADDRESS - New validator address

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Confirm address change

Confirm address change for the validator. Should be executed using new validator key.

sk-val validator confirm-address [VALIDATOR_ID] --pk-file ./pk.txt

Required params:

  1. VALIDATOR_ID - ID of the validator

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Earned fees

Get earned fee amount for the validator address

sk-val validator earned-fees [ADDRESS]

Required params:

  1. ADDRESS - Validator address

Optional arguments:

  • --wei - Show amount in wei

Holder commands

Delegate

Delegate tokens to validator

sk-val holder delegate

Required arguments:

  • --validator-id - ID of the validator to delegate
  • --amount - Amount of SKALE tokens to delegate
  • --delegation-period - Delegation period (in months - only 2 avaliable now)
  • --info - Delegation request info

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Delegations

List of delegations for address

sk-val holder delegations [ADDRESS]

Required arguments:

  1. ADDRESS - Ethereum address of the token holder

Options:

  • --wei/-w - Show tokens amount in wei

Cancel pending delegation

Cancel pending delegation request

sk-val holder cancel-delegation [DELEGATION_ID]

Required params:

  1. Delegation ID - ID of the delegation to cancel

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Request undelegation

Request undelegation in the end of delegation period

sk-val holder undelegate [DELEGATION_ID]

Required params:

  1. Delegation ID - ID of the delegation

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Withdraw bounty

Withdraw earned bounty to specified address

sk-val holder withdraw-bounty [VALIDATOR_ID] [RECIPIENT_ADDRESS] --pk-file ./pk.txt

Required params:

  1. VALIDATOR_ID - ID of the validator
  2. RECIPIENT_ADDRESS - Address to transfer bounty

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)
  • --yes - Confirmation flag

Locked

Show amount of locked tokens for address

sk-val holder locked [ADDRESS]

Required arguments:

  1. ADDRESS - Ethereum address of the token holder

Options:

  • --wei/-w - Show tokens amount in wei

Earned bounties

Get earned bounties amount by token holder for the validator ID

sk-val holder earned-bounties [VALIDATOR_ID] [ADDRESS]

Required params:

  1. VALIDATOR_ID - ID of the validator
  2. ADDRESS - Token holder address

Optional arguments:

  • --wei - Show amount in wei

Wallet commands

Setup Ledger

This command works only if you're using the Ledger wallet

sk-val wallet setup-ledger

Required params:

  • --address-index - Index of the address to use (starting from 0)
  • --keys-type - Type of the Ledger keys (live or legacy)

Send ETH tokens

Send ETH tokens to specific address

sk-val wallet send-eth [ADDRESS] [AMOUNT]

Required arguments:

  1. ADDRESS - Ethereum receiver address
  2. AMOUNT - Amount of ETH tokens to send

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --yes - Confirmation flag

Usage example:

sk-val wallet send-eth 0x01C19c5d3Ad1C3014145fC82263Fbae09e23924A 0.01 --pk-file ./pk.txt --yes

Send SKL tokens

Send SKL tokens to specific address

sk-val wallet send-skl [ADDRESS] [AMOUNT]

Required arguments:

  1. ADDRESS - Ethereum receiver address
  2. AMOUNT - Amount of SKL tokens to send

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --yes - Confirmation flag

Usage example:

sk-val wallet send-skl 0x01C19c5d3Ad1C3014145fC82263Fbae09e23924A 0.01 --pk-file ./pk.txt --yes

Self-recharging wallet commands

Balance

Show balance of the validator self-recharging wallet

sk-val srw balance [VALIDATOR_ID]

Required arguments:

  1. VALIDATOR_ID - ID if the validator

Optional arguments:

  • --wei/-w - Show amount in wei

Usage example:

sk-val srw balance 1 --wei

Recharge

Recharge validator SRW wallet (amount in ETH)

sk-val srw recharge [AMOUNT]

Required arguments:

  1. AMOUNT - Amount of ETH to recharge

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Usage example:

sk-val srw recharge 0.1 --pk-file ./tests/test-pk.txt

Withdraw

Withdraw ETH from validator SRW wallet (amount in ETH)

sk-val srw withdraw [AMOUNT]

Required arguments:

  1. AMOUNT - Amount of ETH to withdraw

Optional arguments:

  • --pk-file - Path to file with private key (only for software wallet type)
  • --gas-price - Gas price value in Gwei for transaction (if not specified doubled average network value will be used)

Usage example:

sk-val srw withdraw 0.1 --pk-file ./tests/test-pk.txt

Exit codes

Exit codes conventions for SKALE CLI tools

  • 0 - Everything is OK
  • 1 - General error exit code
  • 3 - Bad API response
  • 4 - Script execution error
  • 5 - Transaction error
  • 6 - Revert error

Development

Setup repo

Install development dependencies

pip install -e .[dev]
Add flake8 git hook

In file .git/hooks/pre-commit add:

#!/bin/sh
flake8 .

Debugging

Run commands in dev mode:

python main.py YOUR_COMMAND

Setting up Travis

Required environment variables:

  • ACCESS_KEY_ID - DO Spaces/AWS S3 API Key ID
  • SECRET_ACCESS_KEY - DO Spaces/AWS S3 Secret access key
  • GITHUB_EMAIL - Email of GitHub user
  • GITHUB_OAUTH_TOKEN - GitHub auth token
  • ETH_PRIVATE_KEY - Ethereum private key for tests (without 0x prefix)
  • MANAGER_BRANCH - Branch of the skale-manager to pull from DockerHub ($MANAGER_BRANCH-latest tag will be used)

License

GitHub

All contributions are made under the GNU Affero General Public License v3. See LICENSE.

validator-cli's People

Contributors

alexgex avatar badrogger avatar cstrangedk avatar dependabot-preview[bot] avatar dependabot[bot] avatar dimastebaev avatar dmytronazarenko avatar dmytrotkk avatar jmunb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

validator-cli's Issues

Validator wallet can be refilled only from validator address

According to spec:
function rechargeValidatorWallet(uint validatorId) external;

Recharge the validator wallet by identifier. Given validator must exist. Anyone can recharge validator wallet if she knows desired validatorId.

Input params:

validatorId - id of validator

On contract we have opportunity to refill validator wallet by validator ID from any address
In current version of validator cli validator can refill validator vallet(wallets.sol) only from validator address(sign tx)

┆Issue is synchronized with this Jira Bug

Add Wallet functionality to validator-cli

Validators can use the CLI to recharge, withdraw funds from, or check the balance of the self-recharging wallet. Also anyone can recharge or check the balance by interacting with the Wallet contract on Ethereum.

For the CLI

  1. recharges the self-recharging wallet from the validator wallet (sk-val wallet info)
    sk-val ... recharge --amount [AMOUNT_IN_ETH]
  2. withdraw an amount from the self-recharging wallet
    sk-val ... withdraw --amount [AMOUNT_IN_ETH]
  3. returns self-recharging wallet balance
    sk-val ... balance

┆Issue is synchronized with this Jira Task

Validator Cli issue during the upgrade

Error happened while updating to 1.3.0-beta.0 :

$ sk-val-1.3.0-beta.0 --help
Traceback (most recent call last):
File "cli/main.py", line 25, in
ImportError: cannot import name 'TransactionError' from 'skale.transactions.result' (/var/folders/09/vdwg2td92psb7bbkxzpj44l00000gn/T/_MEILqoNMM/skale/transactions/result.pyc)
[30775] Failed to execute script main

┆Issue is synchronized with this Jira Bug

Use global config dir for validator-cli

Currently, validator-cli uses .sk-val directory in the home dir of the user. This will cause errors if commands will be executed by different users (or with and without sudo).

[~accountid:60a23b479b362f0069d741a8] faced with this issue during the initial setup of the validator-cli.

┆Issue is synchronized with this Jira Task

Add accept new delegations switch

Current problem

Validators want to turn on or turn off accept new delegations, but currently all of them are doing it on etherscan. It would be good to add this functionality in validator-cli so they can do it simpler.

Solution

Add new calls:

  1. start-accept
  2. stop-accept

Which would call:

  1. skale.validator_service.start_accepting_new_requests()
  2. skale.validator_service.stop_accepting_new_requests()
    Accordingly

Build is broken

Describe the bug
Right now binary for Linux cannot be built because of incompatibility of packages

To Reproduce
Build binary

Expected behavior
Binary is working

Additional context
Proposal to run builds for Linux in docker containers to avoid similar problems in the future.

Upgrade to use python 3.11

We're currently using Python 3.7 for most of our repos (release date: 2018-06-27 with the end of support 2023-06-27).
Lots of performance improvements were introduces since then, for example:

CPython 3.11 is on average 25% faster than CPython 3.10 when measured with the pyperformance benchmark suite, and compiled with GCC on Ubuntu Linux. Depending on your workload, the speedup could be up to 10-60% faster.

Upgrading Python to 3.11 shouldn't break anything for our customers, since all code will be used in docker containers.

"New validator registered" but not in "sk-val validator ls"

sk-val validator register -n FreshSKALE -d "Skale Fuji Testnet" -c 20 --min-delegation 1000 --pk-file ./pk.txt
Are you sure you want to register a new validator account?
Please, re-check all values above before confirming. [y/N]: y
✔ New validator registered

image

Registered 0xaCaF87A99d8056D5a2E8dAf1a9754301319f2d2e

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.