save ssz dummps during processing (#471)

This commit is contained in:
Jacek Sieka 2019-12-03 12:32:27 +01:00 committed by Dustin Brody
parent c457904a61
commit afc0686b36
4 changed files with 30 additions and 0 deletions

View File

@ -373,6 +373,12 @@ proc sendAttestation(node: BeaconNode,
node.network.broadcast(topicAttestations, attestation)
if node.config.dump:
SSZ.saveFile(
node.config.dumpDir / "att-" & $attestationData.slot & "-" &
$attestationData.index & "-" & validator.pubKey.shortLog &
".ssz", attestation)
info "Attestation sent",
attestationData = shortLog(attestationData),
validator = shortLog(validator),
@ -482,6 +488,15 @@ proc proposeBlock(node: BeaconNode,
validator = shortLog(validator),
cat = "consensus"
if node.config.dump:
SSZ.saveFile(
node.config.dumpDir / "block-" & $newBlock.slot & "-" &
shortLog(newBlockRef.root) & ".ssz", newBlock)
SSZ.saveFile(
node.config.dumpDir / "state-" & $tmpState.data.slot & "-" &
shortLog(newBlockRef.root) & "-" & shortLog(tmpState.root) & ".ssz",
tmpState.data)
node.network.broadcast(topicBeaconBlocks, newBlock)
beacon_blocks_proposed.inc()

View File

@ -136,6 +136,11 @@ type
desc: "Listening HTTP port of the metrics server."
name: "metrics-server-port" }: uint16
dump* {.
defaultValue: false
desc: "Write SSZ dumps of blocks, attestations and states to data dir"
.}: bool
of createTestnet:
validatorsDir* {.
desc: "Directory containing validator descriptors named 'vXXXXXXX.deposit.json'."
@ -243,3 +248,6 @@ proc defaultDataDir*(conf: BeaconNodeConf): string =
proc validatorFileBaseName*(validatorIdx: int): string =
# there can apparently be tops 4M validators so we use 7 digits..
fmt"v{validatorIdx:07}"
func dumpDir*(conf: BeaconNodeConf): string =
conf.dataDir / "dump"

View File

@ -56,6 +56,7 @@ cli do (testnetName {.argument.}: string):
dataDirName = testnetName.replace("/", "_")
dataDir = buildDir / "data" / dataDirName
validatorsDir = dataDir / "validators"
dumpDir = dataDir / "dump"
beaconNodeBinary = buildDir / "beacon_node_" & dataDirName
nimFlags = "-d:chronicles_log_level=DEBUG " & getEnv("NIM_PARAMS")
@ -75,6 +76,8 @@ cli do (testnetName {.argument.}: string):
cd rootDir
exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim"""
mkDir dumpDir
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]"
@ -101,6 +104,7 @@ cli do (testnetName {.argument.}: string):
mode = Verbose
exec replace(&"""{beaconNodeBinary}
--data-dir="{dataDir}"
--dump=true
--bootstrap-file="{testnetDir/bootstrapFile}"
--state-snapshot="{testnetDir/genesisFile}" """ & depositContractOpt, "\n", " ")

View File

@ -44,6 +44,9 @@ if [[ $NODE_ID -lt $TOTAL_NODES ]]; then
popd >/dev/null
fi
rm -rf "$DATA_DIR/dump"
mkdir -p "$DATA_DIR/dump"
$BEACON_NODE_BIN \
--bootstrap-file=$BOOTSTRAP_ADDRESS_FILE \
--data-dir=$DATA_DIR \