Skip to content

Commit d7b5304

Browse files
authored
Merge pull request #340 from ethereum/dev
v2.5.0 release
2 parents ef89710 + c8610b6 commit d7b5304

31 files changed

+1259
-112
lines changed

.circleci/config.yml

+23-12
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
steps:
3131
- checkout
3232
- restore_cache:
33-
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
33+
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
3434
- run:
3535
name: Install requirements in venv
3636
command: make venv_build_test
3737
- save_cache:
38-
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
38+
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
3939
paths:
4040
- ./venv
4141
venv_pytest:
@@ -45,7 +45,7 @@ jobs:
4545
steps:
4646
- checkout
4747
- restore_cache:
48-
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
48+
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
4949
- run:
5050
name: Run tests with venv
5151
command: make venv_test
@@ -61,7 +61,7 @@ jobs:
6161
steps:
6262
- checkout
6363
- restore_cache:
64-
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v2
64+
key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }}-{{ checksum "Makefile" }}-v3
6565
- run:
6666
name: Run linter with venv
6767
command: make venv_lint
@@ -105,6 +105,9 @@ jobs:
105105
- run:
106106
name: Run deposit script on Windows"
107107
command: python ./test_deposit_script.py
108+
- run:
109+
name: Run btec script on Windows"
110+
command: python ./test_btec_script.py
108111
build-linux-amd64:
109112
machine:
110113
image: ubuntu-2004:202201-02
@@ -135,9 +138,11 @@ jobs:
135138
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
136139
mkdir ${TEST_FOLDER_NAME}
137140
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
138-
cp test_binary_script.py ${TEST_FOLDER_NAME}
141+
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
142+
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
139143
cd ${TEST_FOLDER_NAME}
140-
python test_binary_script.py ./${BUILD_FILE_NAME};
144+
python test_binary_deposit_script.py ./${BUILD_FILE_NAME};
145+
python test_binary_btec_script.py ./${BUILD_FILE_NAME};
141146
- run:
142147
name: Compress the file
143148
command: |
@@ -181,9 +186,11 @@ jobs:
181186
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
182187
mkdir ${TEST_FOLDER_NAME}
183188
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
184-
cp test_binary_script.py ${TEST_FOLDER_NAME}
189+
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
190+
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
185191
cd ${TEST_FOLDER_NAME}
186-
python test_binary_script.py ./${BUILD_FILE_NAME};
192+
python test_binary_deposit_script.py ./${BUILD_FILE_NAME};
193+
python test_binary_btec_script.py ./${BUILD_FILE_NAME};
187194
- run:
188195
name: Compress the file
189196
command: |
@@ -225,9 +232,11 @@ jobs:
225232
$TEST_FOLDER_NAME = "TMP_TEST_FOLDER"
226233
mkdir ${TEST_FOLDER_NAME}
227234
Copy-item ${BUILD_FILE_NAME} -destination ${TEST_FOLDER_NAME} -recurse
228-
copy test_binary_script.py ${TEST_FOLDER_NAME}
235+
copy test_binary_deposit_script.py ${TEST_FOLDER_NAME}
236+
copy test_binary_btec_script.py ${TEST_FOLDER_NAME}
229237
cd ${TEST_FOLDER_NAME}
230-
python test_binary_script.py ${BUILD_FILE_NAME}
238+
python test_binary_deposit_script.py ${BUILD_FILE_NAME}
239+
python test_binary_btec_script.py ${BUILD_FILE_NAME}
231240
- run:
232241
name: Compress the file
233242
command: |
@@ -271,9 +280,11 @@ jobs:
271280
export TEST_FOLDER_NAME=TMP_TEST_FOLDER
272281
mkdir ${TEST_FOLDER_NAME}
273282
cp -r ${BUILD_FILE_NAME} ${TEST_FOLDER_NAME}
274-
cp test_binary_script.py ${TEST_FOLDER_NAME}
283+
cp test_binary_deposit_script.py ${TEST_FOLDER_NAME}
284+
cp test_binary_btec_script.py ${TEST_FOLDER_NAME}
275285
cd ${TEST_FOLDER_NAME}
276-
python3 test_binary_script.py ./${BUILD_FILE_NAME};
286+
python3 test_binary_deposit_script.py ./${BUILD_FILE_NAME};
287+
python3 test_binary_btec_script.py ./${BUILD_FILE_NAME};
277288
- run:
278289
name: Compress the file
279290
command: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
validator_keys
2+
bls_to_execution_changes
23

34
# Python testing & linting:
45
build/

README.md

+36-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
- [Option 1. Download binary executable file](#option-1-download-binary-executable-file)
1414
- [Step 1. Installation](#step-1-installation)
1515
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json)
16-
- [language Argument](#language-argument)
16+
- [`language` Argument](#language-argument)
17+
- [`--non_interactive` flag](#--non_interactive-flag)
1718
- [Commands](#commands)
1819
- [`new-mnemonic` Arguments](#new-mnemonic-arguments)
1920
- [`existing-mnemonic` Arguments](#existing-mnemonic-arguments)
2021
- [Successful message](#successful-message)
22+
- [`generate-bls-to-execution-change` Arguments](#generate-bls-to-execution-change-arguments)
2123
- [Option 2. Build `deposit-cli` with native Python](#option-2-build-deposit-cli-with-native-python)
2224
- [Step 0. Python version checking](#step-0-python-version-checking)
2325
- [Step 1. Installation](#step-1-installation-1)
@@ -112,14 +114,22 @@ or run the following command to enter the interactive CLI and generate keys from
112114
./deposit existing-mnemonic
113115
```
114116

115-
###### language Argument
117+
###### `language` Argument
116118

117119
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.
118120

119121
| Argument | Type | Description |
120122
| -------- | -------- | -------- |
121123
| `--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. |
122124

125+
###### `--non_interactive` flag
126+
127+
**Warning: with this flag, there will be no confirmation step(s) to verify the input value(s). Please use it carefully.**
128+
129+
| Argument | Type | Description |
130+
| -------- | -------- | -------- |
131+
| `--non_interactive` | Flag | Run CLI in non-interactive mode. |
132+
123133
###### Commands
124134

125135
The CLI offers different commands depending on what you want to do with the tool.
@@ -136,10 +146,10 @@ You can use `new-mnemonic --help` to see all arguments. Note that if there are m
136146
| Argument | Type | Description |
137147
| -------- | -------- | -------- |
138148
| `--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. |
139-
| `--mnemonic_language` | String. Options: `简体中文`, `繁體中文`, `český jazyk`, `English`, `Italiano`, `한국어`, `Português`, `Español`. Default to `English` | The mnemonic language |
149+
| `--mnemonic_language` | String. Options: `简体中文`, `繁體中文`, `český jazyk`, `English`, `Italiano`, `한국어`, `Português`, `Español`. Default to `English` | The language of the mnemonic word list |
140150
| `--folder` | String. Pointing to `./validator_keys` by default | The folder path for the keystore(s) and deposit(s) |
141151
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
142-
| `--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). |
152+
| `--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). |
143153

144154
###### `existing-mnemonic` Arguments
145155

@@ -151,7 +161,7 @@ You can use `existing-mnemonic --help` to see all arguments. Note that if there
151161
| `--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. |
152162
| `--folder` | String. Pointing to `./validator_keys` by default | The folder path for the keystore(s) and deposit(s) |
153163
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
154-
| `--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). |
164+
| `--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). |
155165

156166
###### Successful message
157167

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

181+
###### `generate-bls-to-execution-change` Arguments
182+
183+
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.
184+
185+
| Argument | Type | Description |
186+
| -------- | -------- | -------- |
187+
| `--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) |
188+
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
189+
| `--mnemonic` | String. mnemonic split by space. | The mnemonic you used to create withdrawal credentials. |
190+
| `--mnemonic_password` | Optional string. Empty by default. | The mnemonic password you used in your key generation. Note: It's not the keystore password. |
191+
| `--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). |
192+
| `--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. |
193+
| `--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. |
194+
| `--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). |
195+
| `--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. |
196+
171197
#### Option 2. Build `deposit-cli` with native Python
172198

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

229255
See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
230256
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
257+
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments
231258

232259
###### Successful message
233260
See [here](#successful-message)
@@ -295,6 +322,7 @@ See [here](#commands)
295322

296323
See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
297324
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
325+
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments
298326

299327
#### Option 4. Use Docker image
300328

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

379407
See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
380408
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
409+
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments
381410

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

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

441470
See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
442471
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
472+
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments
443473

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

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

505535
See [here](#new-mnemonic-arguments) for `new-mnemonic` arguments
506536
See [here](#existing-mnemonic-arguments) for `existing-mnemonic` arguments
537+
See [here](#generate-bls-to-execution-change-arguments) for `generate-bls-to-execution-change` arguments
507538

508539
## Development
509540

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="staking_deposit",
9-
version='2.4.0',
9+
version='2.5.0',
1010
py_modules=["staking_deposit"],
1111
packages=find_packages(exclude=('tests', 'docs')),
1212
python_requires=">=3.8,<4",

staking_deposit/cli/existing_mnemonic.py

+35-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import click
22
from typing import (
33
Any,
4+
Callable,
45
)
56

67
from staking_deposit.exceptions import ValidationError
@@ -22,6 +23,39 @@
2223
)
2324

2425

26+
def load_mnemonic_arguments_decorator(function: Callable[..., Any]) -> Callable[..., Any]:
27+
'''
28+
This is a decorator that, when applied to a parent-command, implements the
29+
to obtain the necessary arguments for the generate_keys() subcommand.
30+
'''
31+
decorators = [
32+
jit_option(
33+
callback=validate_mnemonic,
34+
help=lambda: load_text(['arg_mnemonic', 'help'], func='existing_mnemonic'),
35+
param_decls='--mnemonic',
36+
prompt=lambda: load_text(['arg_mnemonic', 'prompt'], func='existing_mnemonic'),
37+
type=str,
38+
),
39+
jit_option(
40+
callback=captive_prompt_callback(
41+
lambda x: x,
42+
lambda: load_text(['arg_mnemonic_password', 'prompt'], func='existing_mnemonic'),
43+
lambda: load_text(['arg_mnemonic_password', 'confirm'], func='existing_mnemonic'),
44+
lambda: load_text(['arg_mnemonic_password', 'mismatch'], func='existing_mnemonic'),
45+
True,
46+
),
47+
default='',
48+
help=lambda: load_text(['arg_mnemonic_password', 'help'], func='existing_mnemonic'),
49+
hidden=True,
50+
param_decls='--mnemonic-password',
51+
prompt=False,
52+
),
53+
]
54+
for decorator in reversed(decorators):
55+
function = decorator(function)
56+
return function
57+
58+
2559
def validate_mnemonic(ctx: click.Context, param: Any, mnemonic: str) -> str:
2660
mnemonic = reconstruct_mnemonic(mnemonic, WORD_LISTS_PATH)
2761
if mnemonic is not None:
@@ -33,27 +67,7 @@ def validate_mnemonic(ctx: click.Context, param: Any, mnemonic: str) -> str:
3367
@click.command(
3468
help=load_text(['arg_existing_mnemonic', 'help'], func='existing_mnemonic'),
3569
)
36-
@jit_option(
37-
callback=validate_mnemonic,
38-
help=lambda: load_text(['arg_mnemonic', 'help'], func='existing_mnemonic'),
39-
param_decls='--mnemonic',
40-
prompt=lambda: load_text(['arg_mnemonic', 'prompt'], func='existing_mnemonic'),
41-
type=str,
42-
)
43-
@jit_option(
44-
callback=captive_prompt_callback(
45-
lambda x: x,
46-
lambda: load_text(['arg_mnemonic_password', 'prompt'], func='existing_mnemonic'),
47-
lambda: load_text(['arg_mnemonic_password', 'confirm'], func='existing_mnemonic'),
48-
lambda: load_text(['arg_mnemonic_password', 'mismatch'], func='existing_mnemonic'),
49-
True,
50-
),
51-
default='',
52-
help=lambda: load_text(['arg_mnemonic_password', 'help'], func='existing_mnemonic'),
53-
hidden=True,
54-
param_decls='--mnemonic-password',
55-
prompt=False,
56-
)
70+
@load_mnemonic_arguments_decorator
5771
@jit_option(
5872
callback=captive_prompt_callback(
5973
lambda num: validate_int_range(num, 0, 2**32),

0 commit comments

Comments
 (0)