mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-23 03:38:21 +00:00
Simple validator onboarding
On your very first connection to each testnet, you'll be asked to become a validator. Please consult our private repo for a Goerli Eth1 private key that you can use for deposits. Other changes: * Added a simple wrapper ./connect-to-testnet script calling the nims file in the correct environment. No extension was used to make the command the same on Unix and Windows. * Bumped a number of modules with fixes from this week * `make testnet0` and `make testnet1` will no longer delete your existing database. This is considered a more appropriate behavior for testing forward sync.
This commit is contained in:
parent
94f9658e7b
commit
ee2448b221
4
Makefile
4
Makefile
@ -70,10 +70,10 @@ clean_eth2_network_simulation_files:
|
|||||||
eth2_network_simulation: | build deps p2pd clean_eth2_network_simulation_files process_dashboard
|
eth2_network_simulation: | build deps p2pd clean_eth2_network_simulation_files process_dashboard
|
||||||
GIT_ROOT="$$PWD" tests/simulation/start.sh
|
GIT_ROOT="$$PWD" tests/simulation/start.sh
|
||||||
|
|
||||||
testnet0: | build deps clean-testnet0
|
testnet0: | build deps
|
||||||
+ $(MAKE) testnet0-no-clean
|
+ $(MAKE) testnet0-no-clean
|
||||||
|
|
||||||
testnet1: | build deps clean-testnet1
|
testnet1: | build deps
|
||||||
+ $(MAKE) testnet1-no-clean
|
+ $(MAKE) testnet1-no-clean
|
||||||
|
|
||||||
clean-testnet0:
|
clean-testnet0:
|
||||||
|
@ -97,10 +97,9 @@ Once the [prerequisites](#prerequisites) are installed you can connect to testne
|
|||||||
```bash
|
```bash
|
||||||
git clone https://github.com/status-im/nim-beacon-chain
|
git clone https://github.com/status-im/nim-beacon-chain
|
||||||
cd nim-beacon-chain
|
cd nim-beacon-chain
|
||||||
make # This invocation will just download all Nimbus dependencies
|
make # This invocation will bootstrap the build system with additional Makefiles
|
||||||
make # The second invocation will compile the Nim compiler and Nimbus
|
make update deps # This will build Nim and all other dependencies
|
||||||
source env.sh
|
./connect-to-testnet testnet0
|
||||||
nim scripts/connect_to_testnet.nims nimbus/testnet0
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The testnets are restarted once per week, usually on Monday evenings (UTC)) and integrate the changes for the past week.
|
The testnets are restarted once per week, usually on Monday evenings (UTC)) and integrate the changes for the past week.
|
||||||
|
@ -288,7 +288,12 @@ proc addLocalValidators(node: BeaconNode, state: BeaconState) =
|
|||||||
|
|
||||||
for kind, file in walkDir(node.config.localValidatorsDir):
|
for kind, file in walkDir(node.config.localValidatorsDir):
|
||||||
if kind in {pcFile, pcLinkToFile}:
|
if kind in {pcFile, pcLinkToFile}:
|
||||||
node.addLocalValidator state, ValidatorPrivKey.init(readFile(file).string)
|
if cmpIgnoreCase(".privkey", splitFile(file).ext) == 0:
|
||||||
|
try:
|
||||||
|
let keyText = ValidatorPrivKey.init(readFile(file).string)
|
||||||
|
node.addLocalValidator state, keyText
|
||||||
|
except CatchableError:
|
||||||
|
warn "Failed to load a validator private key", file
|
||||||
|
|
||||||
info "Local validators attached ", count = node.attachedValidators.count
|
info "Local validators attached ", count = node.attachedValidators.count
|
||||||
|
|
||||||
@ -1138,6 +1143,10 @@ when isMainModule:
|
|||||||
firstIdx = config.totalQuickstartDeposits)
|
firstIdx = config.totalQuickstartDeposits)
|
||||||
|
|
||||||
if config.depositWeb3Url.len > 0 and config.depositContractAddress.len > 0:
|
if config.depositWeb3Url.len > 0 and config.depositContractAddress.len > 0:
|
||||||
|
info "Sending deposits",
|
||||||
|
web3 = config.depositWeb3Url,
|
||||||
|
depositContract = config.depositContractAddress
|
||||||
|
|
||||||
waitFor sendDeposits(
|
waitFor sendDeposits(
|
||||||
quickstartDeposits & randomDeposits,
|
quickstartDeposits & randomDeposits,
|
||||||
config.depositWeb3Url,
|
config.depositWeb3Url,
|
||||||
|
@ -52,16 +52,19 @@ proc generateDeposits*(totalValidators: int,
|
|||||||
proc sendDeposits*(
|
proc sendDeposits*(
|
||||||
deposits: seq[Deposit],
|
deposits: seq[Deposit],
|
||||||
depositWeb3Url, depositContractAddress, privateKey: string) {.async.} =
|
depositWeb3Url, depositContractAddress, privateKey: string) {.async.} =
|
||||||
let
|
var web3 = await newWeb3(depositWeb3Url)
|
||||||
web3 = await newWeb3(depositWeb3Url)
|
|
||||||
contractAddress = Address.fromHex(depositContractAddress)
|
|
||||||
eth1Addresses = await web3.provider.eth_accounts()
|
|
||||||
|
|
||||||
if privateKey.len != 0:
|
if privateKey.len != 0:
|
||||||
web3.privateKey = initPrivateKey(privateKey)
|
web3.privateKey = initPrivateKey(privateKey)
|
||||||
|
|
||||||
|
let eth1Addresses = await web3.provider.eth_accounts()
|
||||||
|
if eth1Addresses.len == 0:
|
||||||
|
error "Eth1 account rejected"
|
||||||
|
return
|
||||||
|
|
||||||
|
let contractAddress = Address.fromHex(depositContractAddress)
|
||||||
|
|
||||||
for i, dp in deposits:
|
for i, dp in deposits:
|
||||||
web3.defaultAccount = eth1Addresses[i]
|
web3.defaultAccount = eth1Addresses[0]
|
||||||
let depositContract = web3.contractSender(DepositContract, contractAddress)
|
let depositContract = web3.contractSender(DepositContract, contractAddress)
|
||||||
discard await depositContract.deposit(
|
discard await depositContract.deposit(
|
||||||
Bytes48(dp.data.pubKey.getBytes()),
|
Bytes48(dp.data.pubKey.getBytes()),
|
||||||
|
5
connect-to-testnet
Executable file
5
connect-to-testnet
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd $(dirname "$0")
|
||||||
|
./env.sh nim scripts/connect_to_testnet.nims $1
|
||||||
|
|
6
connect-to-testnet.cmd
Normal file
6
connect-to-testnet.cmd
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
cd /D "%~dp0"
|
||||||
|
|
||||||
|
vendor/nimbus-build-system/vendor/Nim/bin/nim scripts/connect_to_testnet.nims %1
|
||||||
|
|
@ -55,6 +55,7 @@ cli do (testnetName {.argument.}: string):
|
|||||||
let
|
let
|
||||||
dataDirName = testnetName.replace("/", "_")
|
dataDirName = testnetName.replace("/", "_")
|
||||||
dataDir = buildDir / "data" / dataDirName
|
dataDir = buildDir / "data" / dataDirName
|
||||||
|
validatorsDir = dataDir / "validators"
|
||||||
beaconNodeBinary = buildDir / "beacon_node_" & dataDirName
|
beaconNodeBinary = buildDir / "beacon_node_" & dataDirName
|
||||||
nimFlags = "-d:chronicles_log_level=DEBUG " & getEnv("NIM_PARAMS")
|
nimFlags = "-d:chronicles_log_level=DEBUG " & getEnv("NIM_PARAMS")
|
||||||
|
|
||||||
@ -73,6 +74,31 @@ cli do (testnetName {.argument.}: string):
|
|||||||
|
|
||||||
cd rootDir
|
cd rootDir
|
||||||
exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim"""
|
exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim"""
|
||||||
|
|
||||||
|
if depositContractOpt.len > 0 and not system.dirExists(validatorsDir):
|
||||||
|
mode = Silent
|
||||||
|
echo "Would you like to become a validator (you'll need access to 32 GoETH)? [Yn]"
|
||||||
|
while true:
|
||||||
|
let answer = readLineFromStdin()
|
||||||
|
if answer in ["y", "Y", "yes", ""]:
|
||||||
|
echo "Please enter your Eth1 private key in hex form (e.g. 0x1a2...f3c). Hit Enter to cancel."
|
||||||
|
let privKey = readLineFromStdin()
|
||||||
|
if privKey.len > 0:
|
||||||
|
mkDir validatorsDir
|
||||||
|
exec replace(&"""{beaconNodeBinary} makeDeposits
|
||||||
|
--random-deposits=1
|
||||||
|
--deposits-dir="{validatorsDir}"
|
||||||
|
--deposit-private-key={privKey}
|
||||||
|
--web3-url=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a
|
||||||
|
{depositContractOpt}
|
||||||
|
""", "\n", " ")
|
||||||
|
break
|
||||||
|
elif answer in ["n", "N", "no"]:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
echo "Please answer 'yes' or 'no'"
|
||||||
|
|
||||||
|
mode = Verbose
|
||||||
exec replace(&"""{beaconNodeBinary}
|
exec replace(&"""{beaconNodeBinary}
|
||||||
--data-dir="{dataDir}"
|
--data-dir="{dataDir}"
|
||||||
--bootstrap-file="{testnetDir/bootstrapFile}"
|
--bootstrap-file="{testnetDir/bootstrapFile}"
|
||||||
|
2
vendor/nim-chronos
vendored
2
vendor/nim-chronos
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 2518a4161f723405004c3e2a743fa08ec67404dc
|
Subproject commit c39c0696806a0ef09bc90e477ea6b177d2824699
|
2
vendor/nim-confutils
vendored
2
vendor/nim-confutils
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7a607bfd3d83be86f153517636370b76f3d7cf25
|
Subproject commit 0bdfb3786cad3a1c045934a1d003dedd3498074d
|
2
vendor/nim-eth
vendored
2
vendor/nim-eth
vendored
@ -1 +1 @@
|
|||||||
Subproject commit a54fdc8073be75e1e7f3273fc7382b580d6a8339
|
Subproject commit 4976bd9fb95c36df3688867a4e2fe7bbfed8f966
|
2
vendor/nim-libp2p
vendored
2
vendor/nim-libp2p
vendored
@ -1 +1 @@
|
|||||||
Subproject commit f3fc763895986e96d53349e0696c897303104765
|
Subproject commit f9eed172d4a61f142e596f891f371ecf7c21b415
|
Loading…
x
Reference in New Issue
Block a user