no more proposeBlockAux trace but still crash

This commit is contained in:
Jenkins 2024-03-19 22:56:38 +02:00
parent b857bdd693
commit d1b91a842f
4 changed files with 56 additions and 163 deletions

View File

@ -158,3 +158,49 @@ proc start*(node: BeaconNode) {.raises: [CatchableError].} =
while true:
poll()
when isMainModule:
import
std/os,
confutils,
chronos,
../beacon_chain/[conf, filepath, beacon_node]
const
simulationDepositsCount = 128
dataDir = "./test_keymanager_api"
validatorsDir = dataDir / "validators"
secretsDir = dataDir / "secrets"
depositsFile = dataDir / "deposits.json"
runtimeConfigFile = dataDir / "config.yaml"
genesisFile = dataDir / "genesis.ssz"
depositTreeSnapshotFile = dataDir / "deposit_tree_snapshot.ssz"
bootstrapEnrFile = dataDir / "bootstrap_node.enr"
tokenFilePath = dataDir / "keymanager-token.txt"
correctTokenValue = "some secret token"
defaultFeeRecipient = Eth1Address.fromHex("0x000000000000000000000000000000000000DEAD")
defaultGasLimit = 30_000_000
nodeDataDir = dataDir / "node-0"
nodeValidatorsDir = nodeDataDir / "validators"
nodeSecretsDir = nodeDataDir / "secrets"
proc startBeaconNode() {.raises: [CatchableError].} =
#copyHalfValidators(nodeDataDir, true)
let runNodeConf = try: BeaconNodeConf.load(cmdLine = @[
"--network=" & dataDir,
"--data-dir=" & nodeDataDir,
"--validators-dir=" & nodeValidatorsDir,
"--secrets-dir=" & nodeSecretsDir,
"--no-el"])
except Exception as exc: # TODO fix confutils exceptions
raiseAssert exc.msg
let
metadata = loadEth2NetworkMetadata(dataDir).expect("Metadata is compatible")
node = waitFor BeaconNode.init(runNodeConf, metadata)
node.start()
startBeaconNode()

View File

@ -49,7 +49,7 @@ fi
build/generate_makefile "nimcache/release/${BINARY}/${PROJECT_NAME}.json" "nimcache/release/${BINARY}/${BINARY}.makefile"
# Don't swallow stderr, in case it's important.
[[ "$V" == "0" ]] && exec >/dev/null
"${MAKE}" -f "nimcache/release/${BINARY}/${BINARY}.makefile" --no-print-directory build
make -f "nimcache/release/${BINARY}/${BINARY}.makefile" --no-print-directory build
if uname | grep -qi darwin || [[ -n "${FORCE_DSYMUTIL}" ]]; then
[[ -z "${DSYMUTIL}" ]] && DSYMUTIL="dsymutil"

View File

@ -1,15 +0,0 @@
# beacon_chain
# Copyright (c) 2019-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
# Use only `secp256k1` public key cryptography as an identity in LibP2P.
-d:"libp2p_pki_schemes=secp256k1"
-d:"chronicles_runtime_filtering=on"
--styleCheck:usages
--styleCheck:hint
--hint[ConvFromXtoItselfNotNeeded]:off
--hint[Processing]:off

View File

@ -1,159 +1,24 @@
import
std/os,
json_serialization, confutils,
chronos, blscurve,
stew/[byteutils, io2],
../beacon_chain/spec/[crypto, keystore, eth2_merkleization],
../beacon_chain/spec/datatypes/base,
../beacon_chain/validators/keystore_management,
../beacon_chain/networking/network_metadata,
../beacon_chain/[conf, filepath, beacon_node,
nimbus_beacon_node],
../ncli/ncli_testnet
confutils,
chronos,
../beacon_chain/[
conf,
filepath,
beacon_node,
nimbus_beacon_node,
]
const
simulationDepositsCount = 128
dataDir = "./test_keymanager_api"
validatorsDir = dataDir / "validators"
secretsDir = dataDir / "secrets"
depositsFile = dataDir / "deposits.json"
runtimeConfigFile = dataDir / "config.yaml"
genesisFile = dataDir / "genesis.ssz"
depositTreeSnapshotFile = dataDir / "deposit_tree_snapshot.ssz"
bootstrapEnrFile = dataDir / "bootstrap_node.enr"
tokenFilePath = dataDir / "keymanager-token.txt"
correctTokenValue = "some secret token"
defaultFeeRecipient = Eth1Address.fromHex("0x000000000000000000000000000000000000DEAD")
defaultGasLimit = 30_000_000
nodeDataDir = dataDir / "node-0"
nodeValidatorsDir = nodeDataDir / "validators"
nodeSecretsDir = nodeDataDir / "secrets"
vcDataDir = dataDir / "validator-0"
from std/sequtils import mapIt
proc prepareNetwork =
let
rng = HmacDrbgContext.new()
mnemonic = generateMnemonic(rng[])
seed = getSeed(mnemonic, KeystorePass.init "")
cfg = defaultRuntimeConfig
let vres = secureCreatePath(validatorsDir)
let sres = secureCreatePath(secretsDir)
if sres.isErr():
discard
let deposits = generateDeposits(
cfg,
rng[],
seed,
0, simulationDepositsCount,
validatorsDir,
secretsDir,
KeystoreMode.Fast)
if deposits.isErr:
quit 1
let launchPadDeposits =
mapIt(deposits.value, LaunchPadDeposit.init(cfg, it))
Json.saveFile(depositsFile, launchPadDeposits)
let runtimeConfigWritten = secureWriteFile(runtimeConfigFile, """
ALTAIR_FORK_EPOCH: 0
BELLATRIX_FORK_EPOCH: 0
""")
if runtimeConfigWritten.isOk:
discard
else:
quit 1
let createTestnetConf = try: ncli_testnet.CliConfig.load(cmdLine = @[
"createTestnet",
"--data-dir=" & dataDir,
"--total-validators=" & $simulationDepositsCount,
"--deposits-file=" & depositsFile,
"--output-genesis=" & genesisFile,
"--output-deposit-tree-snapshot=" & depositTreeSnapshotFile])
except Exception as exc: # TODO Fix confutils exceptions
raiseAssert exc.msg
doCreateTestnet(createTestnetConf, rng[])
let tokenFileRes = secureWriteFile(tokenFilePath, correctTokenValue)
if tokenFileRes.isErr:
quit 1
proc copyHalfValidators(dstDataDir: string, firstHalf: bool) =
let dstValidatorsDir = dstDataDir / "validators"
block:
let status = secureCreatePath(dstValidatorsDir)
if status.isErr():
quit 1
let dstSecretsDir = dstDataDir / "secrets"
block:
let status = secureCreatePath(dstSecretsDir)
if status.isErr():
quit 1
var validatorIdx = 0
for validator in walkDir(validatorsDir):
if (validatorIdx < simulationDepositsCount div 2) == firstHalf:
let
currValidator = os.splitPath(validator.path).tail
secretFile = secretsDir / currValidator
secretRes = readAllChars(secretFile)
if secretRes.isErr:
quit 1
let
dstSecretFile = dstSecretsDir / currValidator
secretFileStatus = secureWriteFile(dstSecretFile, secretRes.get)
if secretFileStatus.isErr:
quit 1
let
dstValidatorDir = dstDataDir / "validators" / currValidator
validatorDirRes = secureCreatePath(dstValidatorDir)
if validatorDirRes.isErr:
quit 1
let
keystoreFile = validatorsDir / currValidator / "keystore.json"
readKeystoreRes = readAllChars(keystoreFile)
if readKeystoreRes.isErr:
quit 1
let
dstKeystore = dstValidatorDir / "keystore.json"
writeKeystoreRes = secureWriteFile(dstKeystore, readKeystoreRes.get)
if writeKeystoreRes.isErr:
quit 1
inc validatorIdx
proc startBeaconNode() {.raises: [CatchableError].} =
copyHalfValidators(nodeDataDir, true)
let runNodeConf = try: BeaconNodeConf.load(cmdLine = @[
"--network=" & dataDir,
"--data-dir=" & nodeDataDir,
"--validators-dir=" & nodeValidatorsDir,
"--secrets-dir=" & nodeSecretsDir,
"--no-el"])
"--data-dir=" & nodeDataDir])
except Exception as exc: # TODO fix confutils exceptions
raiseAssert exc.msg
@ -163,7 +28,4 @@ proc startBeaconNode() {.raises: [CatchableError].} =
node.start()
if dirExists(dataDir):
os.removeDir dataDir
prepareNetwork()
startBeaconNode()