Skip to content

Commit

Permalink
Merge pull request #340 from ethereum/dev
Browse files Browse the repository at this point in the history
v2.5.0 release
  • Loading branch information
CarlBeek authored Mar 14, 2023
2 parents ef89710 + c8610b6 commit d7b5304
Show file tree
Hide file tree
Showing 31 changed files with 1,259 additions and 112 deletions.
35 changes: 23 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
steps:
- checkout
- restore_cache:
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
- run:
name: Install requirements in venv
command: make venv_build_test
- save_cache:
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
paths:
- ./venv
venv_pytest:
Expand All @@ -45,7 +45,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
- run:
name: Run tests with venv
command: make venv_test
Expand All @@ -61,7 +61,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
- run:
name: Run linter with venv
command: make venv_lint
Expand Down Expand Up @@ -105,6 +105,9 @@ jobs:
- run:
name: Run deposit script on Windows"
command: python ./test_deposit_script.py
- run:
name: Run btec script on Windows"
command: python ./test_btec_script.py
build-linux-amd64:
machine:
image: ubuntu-2004:202201-02
Expand Down Expand Up @@ -135,9 +138,11 @@ jobs:
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
mkdir ${TEST_FOLDER_NAME}
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
cp test_binary_script.py ${TEST_FOLDER_NAME}
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
cd ${TEST_FOLDER_NAME}
python test_binary_script.py ./${BUILD_FILE_NAME};
python test_binary_deposit_script.py ./${BUILD_FILE_NAME};
python test_binary_btec_script.py ./${BUILD_FILE_NAME};
- run:
name: Compress the file
command: |
Expand Down Expand Up @@ -181,9 +186,11 @@ jobs:
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
mkdir ${TEST_FOLDER_NAME}
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
cp test_binary_script.py ${TEST_FOLDER_NAME}
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
cd ${TEST_FOLDER_NAME}
python test_binary_script.py ./${BUILD_FILE_NAME};
python test_binary_deposit_script.py ./${BUILD_FILE_NAME};
python test_binary_btec_script.py ./${BUILD_FILE_NAME};
- run:
name: Compress the file
command: |
Expand Down Expand Up @@ -225,9 +232,11 @@ jobs:
$TEST_FOLDER_NAME = "TMP_TEST_FOLDER"
mkdir ${TEST_FOLDER_NAME}
Copy-item ${BUILD_FILE_NAME} -destination ${TEST_FOLDER_NAME} -recurse
copy test_binary_script.py ${TEST_FOLDER_NAME}
copy test_binary_deposit_script.py ${TEST_FOLDER_NAME}
copy test_binary_btec_script.py ${TEST_FOLDER_NAME}
cd ${TEST_FOLDER_NAME}
python test_binary_script.py ${BUILD_FILE_NAME}
python test_binary_deposit_script.py ${BUILD_FILE_NAME}
python test_binary_btec_script.py ${BUILD_FILE_NAME}
- run:
name: Compress the file
command: |
Expand Down Expand Up @@ -271,9 +280,11 @@ jobs:
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
mkdir ${TEST_FOLDER_NAME}
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
cp test_binary_script.py ${TEST_FOLDER_NAME}
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
cd ${TEST_FOLDER_NAME}
python3 test_binary_script.py ./${BUILD_FILE_NAME};
python3 test_binary_deposit_script.py ./${BUILD_FILE_NAME};
python3 test_binary_btec_script.py ./${BUILD_FILE_NAME};
- run:
name: Compress the file
command: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
validator_keys
bls_to_execution_changes

# Python testing & linting:
build/
Expand Down
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
- [Option 1. Download binary executable file](#option-1-download-binary-executable-file)
- [Step 1. Installation](#step-1-installation)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json)
- [language Argument](#language-argument)
- [`language` Argument](#language-argument)
- [`--non_interactive` flag](#--non_interactive-flag)
- [Commands](#commands)
- [`new-mnemonic` Arguments](#new-mnemonic-arguments)
- [`existing-mnemonic` Arguments](#existing-mnemonic-arguments)
- [Successful message](#successful-message)
- [`generate-bls-to-execution-change` Arguments](#generate-bls-to-execution-change-arguments)
- [Option 2. Build `deposit-cli` with native Python](#option-2-build-deposit-cli-with-native-python)
- [Step 0. Python version checking](#step-0-python-version-checking)
- [Step 1. Installation](#step-1-installation-1)
Expand Down Expand Up @@ -112,14 +114,22 @@ or run the following command to enter the interactive CLI and generate keys from
./deposit existing-mnemonic
```

###### language Argument
###### `language` Argument

The Launchpad offers many language/internationalization options. If you wish to select one as a CLI argument, it must be passed in before one of the commands is chosen.

| Argument | Type | Description |
| -------- | -------- | -------- |
| `--language` | String. Options: `العربية`, `ελληνικά`, `English`, `Français`, `Bahasa melayu`, `Italiano`, `日本語`, `한국어`, `Português do Brasil`, `român`, `简体中文`. Default to `English` | The language you wish to use the CLI in. |

###### `--non_interactive` flag

**Warning: with this flag, there will be no confirmation step(s) to verify the input value(s). Please use it carefully.**

| Argument | Type | Description |
| -------- | -------- | -------- |
| `--non_interactive` | Flag | Run CLI in non-interactive mode. |

###### Commands

The CLI offers different commands depending on what you want to do with the tool.
Expand All @@ -136,10 +146,10 @@ You can use `new-mnemonic --help` to see all arguments. Note that if there are m
| Argument | Type | Description |
| -------- | -------- | -------- |
| `--num_validators` | Non-negative integer | The number of signing keys you want to generate. Note that the child key(s) are generated via the same master key. |
| `--mnemonic_language` | String. Options: `简体中文`, `繁體中文`, `český jazyk`, `English`, `Italiano`, `한국어`, `Português`, `Español`. Default to `English` | The mnemonic language |
| `--mnemonic_language` | String. Options: `简体中文`, `繁體中文`, `český jazyk`, `English`, `Italiano`, `한국어`, `Português`, `Español`. Default to `English` | The language of the mnemonic word list |
| `--folder` | String. Pointing to `./validator_keys` by default | The folder path for the keystore(s) and deposit(s) |
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
| `--eth1_withdrawal_address` | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [EIP-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |
| `--execution_address` (or `--eth1_withdrawal_address`) | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [ERC-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |

###### `existing-mnemonic` Arguments

Expand All @@ -151,7 +161,7 @@ You can use `existing-mnemonic --help` to see all arguments. Note that if there
| `--num_validators` | Non-negative integer | The number of new signing keys you want to generate. Note that the child key(s) are generated via the same master key. |
| `--folder` | String. Pointing to `./validator_keys` by default | The folder path for the keystore(s) and deposit(s) |
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
| `--eth1_withdrawal_address` | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [EIP-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |
| `--execution_address` (or `--eth1_withdrawal_address`) | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [ERC-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |

###### Successful message

Expand All @@ -168,6 +178,22 @@ Success!
Your keys can be found at: <YOUR_FOLDER_PATH>
```

###### `generate-bls-to-execution-change` Arguments

You can use `bls-to-execution-change --help` to see all arguments. Note that if there are missing arguments that the CLI needs, it will ask you for them.

| Argument | Type | Description |
| -------- | -------- | -------- |
| `--bls_to_execution_changes_folder` | String. Pointing to `./bls_to_execution_changes` by default | The folder path for the `bls_to_execution_change-*` JSON file(s) |
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
| `--mnemonic` | String. mnemonic split by space. | The mnemonic you used to create withdrawal credentials. |
| `--mnemonic_password` | Optional string. Empty by default. | The mnemonic password you used in your key generation. Note: It's not the keystore password. |
| `--validator_start_index` | Non-negative integer | The index position for the keys to start generating withdrawal credentials in [ERC-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |
| `--validator_indices` | String of integer(s) | A list of the chosen validator index number(s) as identified on the beacon chain. Split multiple items with whitespaces or commas. |
| `--bls_withdrawal_credentials_list` | String of hexstring(s). | A list of the old BLS withdrawal credentials of the given validator(s). It is for confirming you are using the correct keys. Split multiple items with whitespaces or commas. |
| `--execution_address` (or `--eth1_withdrawal_address`) | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [ERC-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |
| `--devnet_chain_setting` | String. JSON string `'{"network_name": "<NETWORK_NAME>", "genesis_fork_version": "<GENESIS_FORK_VERSION>", "genesis_validator_root": "<GENESIS_VALIDATOR_ROOT>"}'` | The custom chain setting of a devnet or testnet. Note that it will override your `--chain` choice. |

#### Option 2. Build `deposit-cli` with native Python

##### Step 0. Python version checking
Expand Down Expand Up @@ -228,6 +254,7 @@ See [here](#commands)

See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments

###### Successful message
See [here](#successful-message)
Expand Down Expand Up @@ -295,6 +322,7 @@ See [here](#commands)

See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments

#### Option 4. Use Docker image

Expand Down Expand Up @@ -378,6 +406,7 @@ See [here](#commands)

See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments

#### Option 2. Build `deposit-cli` with native Python

Expand Down Expand Up @@ -440,6 +469,7 @@ See [here](#commands)

See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments

#### Option 3. Build `deposit-cli` with `virtualenv`

Expand Down Expand Up @@ -504,6 +534,7 @@ See [here](#commands)

See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments

## Development

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="staking_deposit",
version='2.4.0',
version='2.5.0',
py_modules=["staking_deposit"],
packages=find_packages(exclude=('tests', 'docs')),
python_requires=">=3.8,<4",
Expand Down
56 changes: 35 additions & 21 deletions staking_deposit/cli/existing_mnemonic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click
from typing import (
Any,
Callable,
)

from staking_deposit.exceptions import ValidationError
Expand All @@ -22,6 +23,39 @@
)


def load_mnemonic_arguments_decorator(function: Callable[..., Any]) -> Callable[..., Any]:
'''
This is a decorator that, when applied to a parent-command, implements the
to obtain the necessary arguments for the generate_keys() subcommand.
'''
decorators = [
jit_option(
callback=validate_mnemonic,
help=lambda: load_text(['arg_mnemonic', 'help'], func='existing_mnemonic'),
param_decls='--mnemonic',
prompt=lambda: load_text(['arg_mnemonic', 'prompt'], func='existing_mnemonic'),
type=str,
),
jit_option(
callback=captive_prompt_callback(
lambda x: x,
lambda: load_text(['arg_mnemonic_password', 'prompt'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'confirm'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'mismatch'], func='existing_mnemonic'),
True,
),
default='',
help=lambda: load_text(['arg_mnemonic_password', 'help'], func='existing_mnemonic'),
hidden=True,
param_decls='--mnemonic-password',
prompt=False,
),
]
for decorator in reversed(decorators):
function = decorator(function)
return function


def validate_mnemonic(ctx: click.Context, param: Any, mnemonic: str) -> str:
mnemonic = reconstruct_mnemonic(mnemonic, WORD_LISTS_PATH)
if mnemonic is not None:
Expand All @@ -33,27 +67,7 @@ def validate_mnemonic(ctx: click.Context, param: Any, mnemonic: str) -> str:
@click.command(
help=load_text(['arg_existing_mnemonic', 'help'], func='existing_mnemonic'),
)
@jit_option(
callback=validate_mnemonic,
help=lambda: load_text(['arg_mnemonic', 'help'], func='existing_mnemonic'),
param_decls='--mnemonic',
prompt=lambda: load_text(['arg_mnemonic', 'prompt'], func='existing_mnemonic'),
type=str,
)
@jit_option(
callback=captive_prompt_callback(
lambda x: x,
lambda: load_text(['arg_mnemonic_password', 'prompt'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'confirm'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'mismatch'], func='existing_mnemonic'),
True,
),
default='',
help=lambda: load_text(['arg_mnemonic_password', 'help'], func='existing_mnemonic'),
hidden=True,
param_decls='--mnemonic-password',
prompt=False,
)
@load_mnemonic_arguments_decorator
@jit_option(
callback=captive_prompt_callback(
lambda num: validate_int_range(num, 0, 2**32),
Expand Down
Loading

0 comments on commit d7b5304

Please sign in to comment.