mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 04:24:05 +00:00
More logging close to the code that fails often
This commit is contained in:
parent
eed9ea8f0a
commit
a9c026b957
@ -262,6 +262,8 @@ proc scheduleEpochActions(node: BeaconNode, epoch: uint64) =
|
||||
## attestations from our attached validators.
|
||||
doAssert node != nil
|
||||
|
||||
debug "Scheduling epoch actions", epoch
|
||||
|
||||
# TODO: this copy of the state shouldn't be necessary, but please
|
||||
# see the comments in `get_beacon_proposer_index`
|
||||
var nextState = node.beaconState
|
||||
@ -299,19 +301,30 @@ proc scheduleEpochActions(node: BeaconNode, epoch: uint64) =
|
||||
proc processBlocks*(node: BeaconNode) =
|
||||
node.network.subscribe(topicBeaconBlocks) do (newBlock: BeaconBlock):
|
||||
info "Block received", slot = newBlock.slot,
|
||||
stateRoot = shortHash(newBlock.state_root)
|
||||
stateRoot = shortHash(newBlock.state_root),
|
||||
currentStateSlot = node.beaconState.slot
|
||||
|
||||
# TODO: This should be replaced with the real fork-choice rule
|
||||
if newBlock.slot <= node.beaconState.slot:
|
||||
debug "Ignoring block"
|
||||
return
|
||||
|
||||
let newBlockRoot = hash_tree_root_final(newBlock)
|
||||
|
||||
var state = node.beaconState
|
||||
for slot in node.beaconState.slot + 1 ..< newBlock.slot:
|
||||
info "Skipping block", slot
|
||||
let ok = updateState(node.beaconState, node.headBlockRoot, none[BeaconBlock](), {})
|
||||
let ok = updateState(state, node.headBlockRoot, none[BeaconBlock](), {})
|
||||
doAssert ok
|
||||
|
||||
let ok = updateState(node.beaconState, node.headBlockRoot, some(newBlock), {})
|
||||
doAssert ok
|
||||
let ok = updateState(state, node.headBlockRoot, some(newBlock), {})
|
||||
if not ok:
|
||||
debug "Ignoring non-validating block"
|
||||
return
|
||||
|
||||
node.headBlock = newBlock
|
||||
node.headBlockRoot = newBlockRoot
|
||||
node.beaconState = state
|
||||
|
||||
# TODO:
|
||||
#
|
||||
@ -334,7 +347,7 @@ proc processBlocks*(node: BeaconNode) =
|
||||
node.attestationPool.add(a, node.beaconState)
|
||||
|
||||
dynamicLogScope(node = node.config.tcpPort - 50000):
|
||||
let epoch = node.beaconState.slot.epoch
|
||||
let epoch = node.beaconState.timeSinceGenesis().toSlot div EPOCH_LENGTH
|
||||
node.scheduleEpochActions(epoch)
|
||||
|
||||
runForever()
|
||||
@ -348,7 +361,8 @@ proc createPidFile(filename: string) =
|
||||
|
||||
when isMainModule:
|
||||
let config = load BeaconNodeConf
|
||||
setLogLevel(config.logLevel)
|
||||
if config.logLevel != LogLevel.NONE:
|
||||
setLogLevel(config.logLevel)
|
||||
|
||||
case config.cmd
|
||||
of createChain:
|
||||
|
@ -71,7 +71,7 @@ proc main() =
|
||||
withdrawal_credentials: withdrawalCredentials,
|
||||
randao_commitment: randaoCommitment)))
|
||||
|
||||
startupData.genesisTime = (now() div 1000) + 10
|
||||
startupData.genesisTime = (now() div 1000)
|
||||
|
||||
writeFile(outPath / "startup.json", startupData)
|
||||
|
||||
|
2
tests/simulation/.gitignore
vendored
2
tests/simulation/.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
simulation-data
|
||||
data/
|
||||
|
||||
|
@ -9,7 +9,7 @@ set -eu
|
||||
NUMBER_OF_VALIDATORS=99
|
||||
|
||||
cd $(dirname "$0")
|
||||
SIMULATION_DIR=$PWD/simulation-data
|
||||
SIMULATION_DIR=$PWD/data
|
||||
mkdir -p "$SIMULATION_DIR"
|
||||
|
||||
STARTUP_FILE="$SIMULATION_DIR/startup.json"
|
||||
@ -38,7 +38,7 @@ if [ ! -f $SNAPSHOT_FILE ]; then
|
||||
--out:$SNAPSHOT_FILE
|
||||
fi
|
||||
|
||||
MASTER_NODE_ADDRESS_FILE="$SIMULATION_DIR/data-0/beacon_node.address"
|
||||
MASTER_NODE_ADDRESS_FILE="$SIMULATION_DIR/node-0/beacon_node.address"
|
||||
|
||||
# Delete any leftover address files from a previous session
|
||||
if [ -f $MASTER_NODE_ADDRESS_FILE ]; then
|
||||
@ -57,7 +57,7 @@ for i in $(seq 0 9); do
|
||||
done
|
||||
fi
|
||||
|
||||
DATA_DIR=$SIMULATION_DIR/data-$i
|
||||
DATA_DIR=$SIMULATION_DIR/node-$i
|
||||
|
||||
$BEACON_NODE_BIN \
|
||||
--dataDir:"$DATA_DIR" \
|
||||
|
Loading…
x
Reference in New Issue
Block a user