Skip to content

Commit

Permalink
Create committee shares (#16)
Browse files Browse the repository at this point in the history
* Implement upload deposit data

* Update local sync

* Fix upload command

* Fix spec output format
  • Loading branch information
tsudmi authored Feb 15, 2022
1 parent 4056e65 commit ae049be
Show file tree
Hide file tree
Showing 24 changed files with 1,715 additions and 1,144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build
local.env
*.spec
validator_keys/
committee/
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
rev: 22.1.0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 5.9.3
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Read more about operators onboarding process [here](https://docs.stakewise.io/no

See [releases page](https://github.com/stakewise/cli/releases) to download and decompress the corresponding binary files.

### Step 2. Generate DAO proposal
### Step 2. Create Deposit Data

Run the following command to generate the DAO proposal specification:

```bash
./operator-cli generate-proposal
./operator-cli create-deposit-data
```

**NB! You must store the generated mnemonic in a secure cold storage.
Expand All @@ -34,7 +34,7 @@ to deploy the ETH2 staking infrastructure.
### Step 5. Sync keys to the Vault

You must **use the same mnemonic** as generated in step 1.
Also, **using the same mnemonic for multiple vaults will result into validators slashings**.
**NB! Using the same mnemonic for multiple vaults will result into validators slashings**.

Run the following command to sync new validator keys to the vault:

Expand Down
126 changes: 126 additions & 0 deletions operator_cli/commands/create_deposit_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
from os import getcwd
from os.path import join

import click

from operator_cli.committee_shares import create_committee_shares
from operator_cli.eth1 import generate_specification, validate_operator_address
from operator_cli.eth2 import (
LANGUAGES,
VALIDATOR_DEPOSIT_AMOUNT,
create_new_mnemonic,
generate_merkle_deposit_datum,
generate_unused_validator_keys,
validate_mnemonic,
)
from operator_cli.ipfs import upload_deposit_data_to_ipfs
from operator_cli.networks import (
ETHEREUM_GOERLI,
ETHEREUM_MAINNET,
GNOSIS_CHAIN,
NETWORKS,
)
from operator_cli.queries import get_ethereum_gql_client, get_stakewise_gql_client


@click.command(help="Creates deposit data and generates a forum post specification")
@click.option(
"--network",
default=ETHEREUM_MAINNET,
help="The network to generate the deposit data for",
prompt="Enter the network name",
type=click.Choice(
[ETHEREUM_MAINNET, ETHEREUM_GOERLI, GNOSIS_CHAIN], case_sensitive=False
),
)
@click.option(
"--existing-mnemonic",
is_flag=True,
help="Indicates whether the deposit data is generated for the existing mnemonic.",
)
@click.option(
"--committee-folder",
default=join(getcwd(), "committee"),
help="The folder where committee files will be saved.",
type=click.Path(exists=False, file_okay=False, dir_okay=True),
)
def create_deposit_data(
network: str, existing_mnemonic: bool, committee_folder: str
) -> None:
if not existing_mnemonic:
language = click.prompt(
"Choose your mnemonic language",
default="english",
type=click.Choice(LANGUAGES, case_sensitive=False),
)
mnemonic = create_new_mnemonic(language)
else:
mnemonic = click.prompt(
'Enter your mnemonic separated by spaces (" ")',
value_proc=validate_mnemonic,
type=click.STRING,
)

keys_count = click.prompt(
"Enter the number of new validator keys you would like to generate",
type=click.IntRange(1, 1000000),
)

# 1. Generate unused validator keys
ethereum_gql_client = get_ethereum_gql_client(network)
keypairs = generate_unused_validator_keys(
gql_client=ethereum_gql_client, mnemonic=mnemonic, keys_count=keys_count
)

# 2. Generate and save deposit data
(deposit_data_merkle_root, deposit_data,) = generate_merkle_deposit_datum(
genesis_fork_version=NETWORKS[network]["GENESIS_FORK_VERSION"],
withdrawal_credentials=NETWORKS[network]["WITHDRAWAL_CREDENTIALS"],
deposit_amount=VALIDATOR_DEPOSIT_AMOUNT,
loading_label="Creating deposit data:\t\t",
validator_keypairs=keypairs,
)

# 3. Assign operator wallet address
operator = click.prompt(
"Enter the wallet address that will receive rewards."
" If you already run StakeWise validators, please re-use the same wallet address",
value_proc=validate_operator_address,
)

# 4. Generate private key shares for the committee
sw_gql_client = get_stakewise_gql_client(network)
committee_paths = create_committee_shares(
network=network,
gql_client=sw_gql_client,
operator=operator,
committee_folder=committee_folder,
keypairs=keypairs,
)

# 5. Upload deposit data to IPFS
ipfs_url = upload_deposit_data_to_ipfs(deposit_data)

# 6. Generate proposal specification part
specification = generate_specification(
merkle_root=deposit_data_merkle_root,
ipfs_url=ipfs_url,
gql_client=sw_gql_client,
operator=operator,
)
click.clear()
click.secho(
"Submit the post to https://forum.stakewise.io with the following specification section:",
bold=True,
fg="green",
)
click.echo(specification)

# 7. Generate committee message
click.secho(
"Share the encrypted validator key shares with the committee members through Telegram:",
bold=True,
fg="green",
)
for username, path in committee_paths.items():
click.echo(f"- @{username}: {path}")
151 changes: 0 additions & 151 deletions operator_cli/commands/generate_proposal.py

This file was deleted.

Loading

0 comments on commit ae049be

Please sign in to comment.