mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 19:50:37 +00:00
1373dcf076
## Issue Addressed
Addresses #2557
## Proposed Changes
Adds the `lighthouse validator-manager` command, which provides:
- `lighthouse validator-manager create`
- Creates a `validators.json` file and a `deposits.json` (same format as https://github.com/ethereum/staking-deposit-cli)
- `lighthouse validator-manager import`
- Imports validators from a `validators.json` file to the VC via the HTTP API.
- `lighthouse validator-manager move`
- Moves validators from one VC to the other, utilizing only the VC API.
## Additional Info
In 98bcb947c I've reduced some VC `ERRO` and `CRIT` warnings to `WARN` or `DEBG` for the case where a pubkey is missing from the validator store. These were being triggered when we removed a validator but still had it in caches. It seems to me that `UnknownPubkey` will only happen in the case where we've removed a validator, so downgrading the logs is prudent. All the logs are `DEBG` apart from attestations and blocks which are `WARN`. I thought having *some* logging about this condition might help us down the track.
In 856cd7e37d
I've made the VC delete the corresponding password file when it's deleting a keystore. This seemed like nice hygiene. Notably, it'll only delete that password file after it scans the validator definitions and finds that no other validator is also using that password file.
124 lines
3.3 KiB
Python
124 lines
3.3 KiB
Python
# This script uses the `ethereum/staking-deposit-cli` tool to generate
|
|
# deposit data files which are then used for testing by Lighthouse.
|
|
#
|
|
# To generate vectors, simply run this Python script:
|
|
#
|
|
# `python generate.py`
|
|
#
|
|
import os
|
|
import sys
|
|
import shutil
|
|
import subprocess
|
|
from subprocess import Popen, PIPE, STDOUT
|
|
|
|
|
|
NUM_VALIDATORS=3
|
|
TEST_MNEMONIC = "test test test test test test test test test test test waste"
|
|
WALLET_NAME="test_wallet"
|
|
|
|
|
|
tmp_dir = os.path.join(".", "tmp")
|
|
mnemonic_path = os.path.join(tmp_dir, "mnemonic.txt")
|
|
sdc_dir = os.path.join(tmp_dir, "sdc")
|
|
sdc_git_dir = os.path.join(sdc_dir, "staking-deposit-cli")
|
|
vectors_dir = os.path.join(".", "vectors")
|
|
|
|
|
|
def setup():
|
|
cleanup()
|
|
|
|
if os.path.exists(vectors_dir):
|
|
shutil.rmtree(vectors_dir)
|
|
|
|
os.mkdir(tmp_dir)
|
|
os.mkdir(sdc_dir)
|
|
os.mkdir(vectors_dir)
|
|
|
|
setup_sdc()
|
|
with open(mnemonic_path, "x") as file:
|
|
file.write(TEST_MNEMONIC)
|
|
|
|
|
|
def cleanup():
|
|
if os.path.exists(tmp_dir):
|
|
shutil.rmtree(tmp_dir)
|
|
|
|
# Remove all the keystores since we don't use them in testing.
|
|
if os.path.exists(vectors_dir):
|
|
for root, dirs, files in os.walk(vectors_dir):
|
|
for file in files:
|
|
if file.startswith("keystore"):
|
|
os.remove(os.path.join(root, file))
|
|
|
|
|
|
def setup_sdc():
|
|
result = subprocess.run([
|
|
"git",
|
|
"clone",
|
|
"--single-branch",
|
|
"https://github.com/ethereum/staking-deposit-cli.git",
|
|
str(sdc_git_dir)
|
|
])
|
|
assert(result.returncode == 0)
|
|
result = subprocess.run([
|
|
"pip",
|
|
"install",
|
|
"-r",
|
|
"requirements.txt",
|
|
], cwd=sdc_git_dir)
|
|
assert(result.returncode == 0)
|
|
result = subprocess.run([
|
|
"python",
|
|
"setup.py",
|
|
"install",
|
|
], cwd=sdc_git_dir)
|
|
assert(result.returncode == 0)
|
|
|
|
|
|
def sdc_generate(network, first_index, count, eth1_withdrawal_address=None):
|
|
if eth1_withdrawal_address is not None:
|
|
eth1_flags = ['--eth1_withdrawal_address', eth1_withdrawal_address]
|
|
uses_eth1 = True
|
|
else:
|
|
eth1_flags = []
|
|
uses_eth1 = False
|
|
|
|
test_name = "{}_first_{}_count_{}_eth1_{}".format(network, first_index, count,
|
|
str(uses_eth1).lower())
|
|
output_dir = os.path.join(vectors_dir, test_name)
|
|
os.mkdir(output_dir)
|
|
|
|
command = [
|
|
'/bin/sh',
|
|
'deposit.sh',
|
|
'--language', 'english',
|
|
'--non_interactive',
|
|
'existing-mnemonic',
|
|
'--validator_start_index', str(first_index),
|
|
'--num_validators', str(count),
|
|
'--mnemonic', TEST_MNEMONIC,
|
|
'--chain', network,
|
|
'--keystore_password', 'MyPassword',
|
|
'--folder', os.path.abspath(output_dir),
|
|
] + eth1_flags
|
|
|
|
print("Running " + test_name)
|
|
process = Popen(command, cwd=sdc_git_dir, text=True, stdin = PIPE)
|
|
process.wait()
|
|
|
|
|
|
def test_network(network):
|
|
sdc_generate(network, first_index=0, count=1)
|
|
sdc_generate(network, first_index=0, count=2)
|
|
sdc_generate(network, first_index=12, count=1)
|
|
sdc_generate(network, first_index=99, count=2)
|
|
sdc_generate(network, first_index=1024, count=3)
|
|
sdc_generate(network, first_index=0, count=2,
|
|
eth1_withdrawal_address="0x0f51bb10119727a7e5ea3538074fb341f56b09ad")
|
|
|
|
|
|
setup()
|
|
test_network("mainnet")
|
|
test_network("prater")
|
|
cleanup()
|