humaneXNum -> shortLog
This commit is contained in:
parent
6a4d27f4ac
commit
e639cd95c7
|
@ -45,10 +45,10 @@ proc validate(
|
||||||
if attestationSlot <
|
if attestationSlot <
|
||||||
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch():
|
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch():
|
||||||
debug "Old attestation",
|
debug "Old attestation",
|
||||||
attestationSlot = humaneSlotNum(attestationSlot),
|
attestationSlot = shortLog(attestationSlot),
|
||||||
attestationEpoch = humaneEpochNum(attestationSlot.compute_epoch_of_slot),
|
attestationEpoch = shortLog(attestationSlot.compute_epoch_of_slot),
|
||||||
stateSlot = humaneSlotNum(state.slot),
|
stateSlot = shortLog(state.slot),
|
||||||
finalizedEpoch = humaneEpochNum(state.finalized_checkpoint.epoch)
|
finalizedEpoch = shortLog(state.finalized_checkpoint.epoch)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ proc validate(
|
||||||
# desperatly behind or someone is sending bogus attestations...
|
# desperatly behind or someone is sending bogus attestations...
|
||||||
if attestationSlot > state.slot + 64:
|
if attestationSlot > state.slot + 64:
|
||||||
debug "Future attestation",
|
debug "Future attestation",
|
||||||
attestationSlot = humaneSlotNum(attestationSlot),
|
attestationSlot = shortLog(attestationSlot),
|
||||||
attestationEpoch = humaneEpochNum(attestationSlot.compute_epoch_of_slot),
|
attestationEpoch = shortLog(attestationSlot.compute_epoch_of_slot),
|
||||||
stateSlot = humaneSlotNum(state.slot),
|
stateSlot = shortLog(state.slot),
|
||||||
finalizedEpoch = humaneEpochNum(state.finalized_checkpoint.epoch)
|
finalizedEpoch = shortLog(state.finalized_checkpoint.epoch)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not attestation.custody_bits.BitSeq.isZeros:
|
if not attestation.custody_bits.BitSeq.isZeros:
|
||||||
|
@ -124,22 +124,22 @@ proc slotIndex(
|
||||||
We should have checked in validate that attestation is newer than
|
We should have checked in validate that attestation is newer than
|
||||||
finalized_slot and we never prune things before that, per below condition!
|
finalized_slot and we never prune things before that, per below condition!
|
||||||
""" &
|
""" &
|
||||||
", attestationSlot: " & $humaneSlotNum(attestationSlot) &
|
", attestationSlot: " & $shortLog(attestationSlot) &
|
||||||
", startingSlot: " & $humaneSlotNum(pool.startingSlot)
|
", startingSlot: " & $shortLog(pool.startingSlot)
|
||||||
|
|
||||||
if pool.slots.len == 0:
|
if pool.slots.len == 0:
|
||||||
# Because the first attestations may arrive in any order, we'll make sure
|
# Because the first attestations may arrive in any order, we'll make sure
|
||||||
# to start counting at the last finalized epoch start slot - anything
|
# to start counting at the last finalized epoch start slot - anything
|
||||||
# earlier than that is thrown out by the above check
|
# earlier than that is thrown out by the above check
|
||||||
info "First attestation!",
|
info "First attestation!",
|
||||||
attestationSlot = $humaneSlotNum(attestationSlot)
|
attestationSlot = $shortLog(attestationSlot)
|
||||||
pool.startingSlot =
|
pool.startingSlot =
|
||||||
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch()
|
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch()
|
||||||
|
|
||||||
if pool.startingSlot + pool.slots.len.uint64 <= attestationSlot:
|
if pool.startingSlot + pool.slots.len.uint64 <= attestationSlot:
|
||||||
debug "Growing attestation pool",
|
debug "Growing attestation pool",
|
||||||
attestationSlot = $humaneSlotNum(attestationSlot),
|
attestationSlot = $shortLog(attestationSlot),
|
||||||
startingSlot = $humaneSlotNum(pool.startingSlot)
|
startingSlot = $shortLog(pool.startingSlot)
|
||||||
|
|
||||||
# Make sure there's a pool entry for every slot, even when there's a gap
|
# Make sure there's a pool entry for every slot, even when there's a gap
|
||||||
while pool.startingSlot + pool.slots.len.uint64 <= attestationSlot:
|
while pool.startingSlot + pool.slots.len.uint64 <= attestationSlot:
|
||||||
|
@ -148,9 +148,9 @@ proc slotIndex(
|
||||||
if pool.startingSlot <
|
if pool.startingSlot <
|
||||||
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch():
|
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch():
|
||||||
debug "Pruning attestation pool",
|
debug "Pruning attestation pool",
|
||||||
startingSlot = $humaneSlotNum(pool.startingSlot),
|
startingSlot = $shortLog(pool.startingSlot),
|
||||||
finalizedSlot =
|
finalizedSlot =
|
||||||
$humaneSlotNum(
|
$shortLog(
|
||||||
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch())
|
state.finalized_checkpoint.epoch.compute_start_slot_of_epoch())
|
||||||
|
|
||||||
# TODO there should be a better way to remove a whole epoch of stuff..
|
# TODO there should be a better way to remove a whole epoch of stuff..
|
||||||
|
@ -274,12 +274,12 @@ proc getAttestationsForBlock*(
|
||||||
newBlockSlot: Slot): seq[Attestation] =
|
newBlockSlot: Slot): seq[Attestation] =
|
||||||
if newBlockSlot - GENESIS_SLOT < MIN_ATTESTATION_INCLUSION_DELAY:
|
if newBlockSlot - GENESIS_SLOT < MIN_ATTESTATION_INCLUSION_DELAY:
|
||||||
debug "Too early for attestations",
|
debug "Too early for attestations",
|
||||||
newBlockSlot = humaneSlotNum(newBlockSlot)
|
newBlockSlot = shortLog(newBlockSlot)
|
||||||
return
|
return
|
||||||
|
|
||||||
if pool.slots.len == 0: # startingSlot not set yet!
|
if pool.slots.len == 0: # startingSlot not set yet!
|
||||||
info "No attestations found (pool empty)",
|
info "No attestations found (pool empty)",
|
||||||
newBlockSlot = humaneSlotNum(newBlockSlot)
|
newBlockSlot = shortLog(newBlockSlot)
|
||||||
return
|
return
|
||||||
|
|
||||||
var cache = get_empty_per_epoch_cache()
|
var cache = get_empty_per_epoch_cache()
|
||||||
|
@ -294,9 +294,9 @@ proc getAttestationsForBlock*(
|
||||||
if attestationSlot < pool.startingSlot or
|
if attestationSlot < pool.startingSlot or
|
||||||
attestationSlot >= pool.startingSlot + pool.slots.len.uint64:
|
attestationSlot >= pool.startingSlot + pool.slots.len.uint64:
|
||||||
info "No attestations",
|
info "No attestations",
|
||||||
attestationSlot = humaneSlotNum(attestationSlot),
|
attestationSlot = shortLog(attestationSlot),
|
||||||
startingSlot = humaneSlotNum(pool.startingSlot),
|
startingSlot = shortLog(pool.startingSlot),
|
||||||
endingSlot = humaneSlotNum(pool.startingSlot + pool.slots.len.uint64)
|
endingSlot = shortLog(pool.startingSlot + pool.slots.len.uint64)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -281,8 +281,8 @@ proc updateHead(node: BeaconNode, slot: Slot): BlockRef =
|
||||||
debug "Preparing for fork choice",
|
debug "Preparing for fork choice",
|
||||||
stateRoot = shortLog(root),
|
stateRoot = shortLog(root),
|
||||||
connectedPeers = node.network.peersCount,
|
connectedPeers = node.network.peersCount,
|
||||||
stateSlot = humaneSlotNum(state.slot),
|
stateSlot = shortLog(state.slot),
|
||||||
stateEpoch = humaneEpochNum(state.slot.computeEpochOfSlot)
|
stateEpoch = shortLog(state.slot.computeEpochOfSlot)
|
||||||
|
|
||||||
let
|
let
|
||||||
justifiedHead = node.blockPool.latestJustifiedBlock()
|
justifiedHead = node.blockPool.latestJustifiedBlock()
|
||||||
|
@ -296,8 +296,8 @@ proc updateHead(node: BeaconNode, slot: Slot): BlockRef =
|
||||||
|
|
||||||
lmdGhost(node.attestationPool, state, justifiedHead)
|
lmdGhost(node.attestationPool, state, justifiedHead)
|
||||||
info "Fork chosen",
|
info "Fork chosen",
|
||||||
newHeadSlot = humaneSlotNum(newHead.slot),
|
newHeadSlot = shortLog(newHead.slot),
|
||||||
newHeadEpoch = humaneEpochNum(newHead.slot.computeEpochOfSlot),
|
newHeadEpoch = shortLog(newHead.slot.computeEpochOfSlot),
|
||||||
newHeadBlockRoot = shortLog(newHead.root)
|
newHeadBlockRoot = shortLog(newHead.root)
|
||||||
|
|
||||||
node.blockPool.updateHead(node.stateCache, newHead)
|
node.blockPool.updateHead(node.stateCache, newHead)
|
||||||
|
@ -336,16 +336,16 @@ proc proposeBlock(node: BeaconNode,
|
||||||
slot: Slot): Future[BlockRef] {.async.} =
|
slot: Slot): Future[BlockRef] {.async.} =
|
||||||
if head.slot > slot:
|
if head.slot > slot:
|
||||||
notice "Skipping proposal, we've already selected a newer head",
|
notice "Skipping proposal, we've already selected a newer head",
|
||||||
headSlot = humaneSlotNum(head.slot),
|
headSlot = shortLog(head.slot),
|
||||||
headBlockRoot = shortLog(head.root),
|
headBlockRoot = shortLog(head.root),
|
||||||
slot = humaneSlotNum(slot)
|
slot = shortLog(slot)
|
||||||
return head
|
return head
|
||||||
|
|
||||||
if head.slot == slot:
|
if head.slot == slot:
|
||||||
# Weird, we should never see as head the same slot as we're proposing a
|
# Weird, we should never see as head the same slot as we're proposing a
|
||||||
# block for - did someone else steal our slot? why didn't we discard it?
|
# block for - did someone else steal our slot? why didn't we discard it?
|
||||||
warn "Found head at same slot as we're supposed to propose for!",
|
warn "Found head at same slot as we're supposed to propose for!",
|
||||||
headSlot = humaneSlotNum(head.slot),
|
headSlot = shortLog(head.slot),
|
||||||
headBlockRoot = shortLog(head.root)
|
headBlockRoot = shortLog(head.root)
|
||||||
# TODO investigate how and when this happens.. maybe it shouldn't be an
|
# TODO investigate how and when this happens.. maybe it shouldn't be an
|
||||||
# assert?
|
# assert?
|
||||||
|
@ -465,8 +465,8 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||||
# finalized epoch.. also, it seems that posting very old attestations
|
# finalized epoch.. also, it seems that posting very old attestations
|
||||||
# is risky from a slashing perspective. More work is needed here.
|
# is risky from a slashing perspective. More work is needed here.
|
||||||
notice "Skipping attestation, head is too recent",
|
notice "Skipping attestation, head is too recent",
|
||||||
headSlot = humaneSlotNum(head.slot),
|
headSlot = shortLog(head.slot),
|
||||||
slot = humaneSlotNum(slot)
|
slot = shortLog(slot)
|
||||||
return
|
return
|
||||||
|
|
||||||
let attestationHead = head.findAncestorBySlot(slot)
|
let attestationHead = head.findAncestorBySlot(slot)
|
||||||
|
@ -475,13 +475,13 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||||
# attesting to a past state - we must then recreate the world as it looked
|
# attesting to a past state - we must then recreate the world as it looked
|
||||||
# like back then
|
# like back then
|
||||||
notice "Attesting to a state in the past, falling behind?",
|
notice "Attesting to a state in the past, falling behind?",
|
||||||
headSlot = humaneSlotNum(head.slot),
|
headSlot = shortLog(head.slot),
|
||||||
attestationHeadSlot = humaneSlotNum(attestationHead.slot),
|
attestationHeadSlot = shortLog(attestationHead.slot),
|
||||||
attestationSlot = humaneSlotNum(slot)
|
attestationSlot = shortLog(slot)
|
||||||
|
|
||||||
debug "Checking attestations",
|
debug "Checking attestations",
|
||||||
attestationHeadRoot = shortLog(attestationHead.blck.root),
|
attestationHeadRoot = shortLog(attestationHead.blck.root),
|
||||||
attestationSlot = humaneSlotNum(slot)
|
attestationSlot = shortLog(slot)
|
||||||
|
|
||||||
|
|
||||||
# Collect data to send before node.stateCache grows stale
|
# Collect data to send before node.stateCache grows stale
|
||||||
|
@ -566,7 +566,7 @@ proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot):
|
||||||
|
|
||||||
debug "Expecting proposal",
|
debug "Expecting proposal",
|
||||||
headRoot = shortLog(head.root),
|
headRoot = shortLog(head.root),
|
||||||
slot = humaneSlotNum(slot),
|
slot = shortLog(slot),
|
||||||
proposer = shortLog(state.validators[proposerIdx].pubKey)
|
proposer = shortLog(state.validators[proposerIdx].pubKey)
|
||||||
|
|
||||||
return head
|
return head
|
||||||
|
@ -584,17 +584,17 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
|
||||||
nextSlot = slot + 1
|
nextSlot = slot + 1
|
||||||
|
|
||||||
debug "Slot start",
|
debug "Slot start",
|
||||||
lastSlot = humaneSlotNum(lastSlot),
|
lastSlot = shortLog(lastSlot),
|
||||||
scheduledSlot = humaneSlotNum(scheduledSlot),
|
scheduledSlot = shortLog(scheduledSlot),
|
||||||
slot = humaneSlotNum(slot)
|
slot = shortLog(slot)
|
||||||
|
|
||||||
if slot < lastSlot:
|
if slot < lastSlot:
|
||||||
# This can happen if the system clock changes time for example, and it's
|
# This can happen if the system clock changes time for example, and it's
|
||||||
# pretty bad
|
# pretty bad
|
||||||
# TODO shut down? time either was or is bad, and PoS relies on accuracy..
|
# TODO shut down? time either was or is bad, and PoS relies on accuracy..
|
||||||
warn "Beacon clock time moved back, rescheduling slot actions",
|
warn "Beacon clock time moved back, rescheduling slot actions",
|
||||||
slot = humaneSlotNum(slot),
|
slot = shortLog(slot),
|
||||||
scheduledSlot = humaneSlotNum(scheduledSlot)
|
scheduledSlot = shortLog(scheduledSlot)
|
||||||
|
|
||||||
addTimer(saturate(node.beaconClock.fromNow(nextSlot))) do (p: pointer):
|
addTimer(saturate(node.beaconClock.fromNow(nextSlot))) do (p: pointer):
|
||||||
asyncCheck node.onSlotStart(slot, nextSlot)
|
asyncCheck node.onSlotStart(slot, nextSlot)
|
||||||
|
@ -608,9 +608,9 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
|
||||||
# how long attestations remain interesting
|
# how long attestations remain interesting
|
||||||
# TODO should we shut down instead? clearly we're unable to keep up
|
# TODO should we shut down instead? clearly we're unable to keep up
|
||||||
warn "Unable to keep up, skipping ahead without doing work",
|
warn "Unable to keep up, skipping ahead without doing work",
|
||||||
lastSlot = humaneSlotNum(lastSlot),
|
lastSlot = shortLog(lastSlot),
|
||||||
slot = humaneSlotNum(slot),
|
slot = shortLog(slot),
|
||||||
scheduledSlot = humaneSlotNum(scheduledSlot)
|
scheduledSlot = shortLog(scheduledSlot)
|
||||||
|
|
||||||
addTimer(saturate(node.beaconClock.fromNow(nextSlot))) do (p: pointer):
|
addTimer(saturate(node.beaconClock.fromNow(nextSlot))) do (p: pointer):
|
||||||
# We pass the current slot here to indicate that work should be skipped!
|
# We pass the current slot here to indicate that work should be skipped!
|
||||||
|
@ -650,9 +650,9 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
|
||||||
# state rewinds while waiting for async operations like validator
|
# state rewinds while waiting for async operations like validator
|
||||||
# signature..
|
# signature..
|
||||||
notice "Catching up",
|
notice "Catching up",
|
||||||
curSlot = humaneSlotNum(curSlot),
|
curSlot = shortLog(curSlot),
|
||||||
lastSlot = humaneSlotNum(lastSlot),
|
lastSlot = shortLog(lastSlot),
|
||||||
slot = humaneSlotNum(slot)
|
slot = shortLog(slot)
|
||||||
|
|
||||||
# For every slot we're catching up, we'll propose then send
|
# For every slot we're catching up, we'll propose then send
|
||||||
# attestations - head should normally be advancing along the same branch
|
# attestations - head should normally be advancing along the same branch
|
||||||
|
@ -688,7 +688,7 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
|
||||||
else: halfSlot - attestationStart.offset
|
else: halfSlot - attestationStart.offset
|
||||||
|
|
||||||
debug "Waiting to send attestations",
|
debug "Waiting to send attestations",
|
||||||
slot = humaneSlotNum(slot),
|
slot = shortLog(slot),
|
||||||
fromNow = shortLog(fromNow)
|
fromNow = shortLog(fromNow)
|
||||||
|
|
||||||
await sleepAsync(fromNow)
|
await sleepAsync(fromNow)
|
||||||
|
@ -703,9 +703,9 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
|
||||||
nextSlotStart = saturate(node.beaconClock.fromNow(nextSlot))
|
nextSlotStart = saturate(node.beaconClock.fromNow(nextSlot))
|
||||||
|
|
||||||
info "Scheduling slot actions",
|
info "Scheduling slot actions",
|
||||||
lastSlot = humaneSlotNum(slot),
|
lastSlot = shortLog(slot),
|
||||||
slot = humaneSlotNum(slot),
|
slot = shortLog(slot),
|
||||||
nextSlot = humaneSlotNum(nextSlot),
|
nextSlot = shortLog(nextSlot),
|
||||||
fromNow = shortLog(nextSlotStart)
|
fromNow = shortLog(nextSlotStart)
|
||||||
|
|
||||||
addTimer(nextSlotStart) do (p: pointer):
|
addTimer(nextSlotStart) do (p: pointer):
|
||||||
|
@ -737,7 +737,7 @@ proc run*(node: BeaconNode) =
|
||||||
fromNow = saturate(node.beaconClock.fromNow(startSlot))
|
fromNow = saturate(node.beaconClock.fromNow(startSlot))
|
||||||
|
|
||||||
info "Scheduling first slot action",
|
info "Scheduling first slot action",
|
||||||
nextSlot = humaneSlotNum(startSlot),
|
nextSlot = shortLog(startSlot),
|
||||||
fromNow = shortLog(fromNow)
|
fromNow = shortLog(fromNow)
|
||||||
|
|
||||||
addTimer(fromNow) do (p: pointer):
|
addTimer(fromNow) do (p: pointer):
|
||||||
|
@ -767,7 +767,7 @@ proc start(node: BeaconNode, headState: BeaconState) =
|
||||||
slotsSinceFinalization =
|
slotsSinceFinalization =
|
||||||
int64(node.blockPool.finalizedHead.slot) -
|
int64(node.blockPool.finalizedHead.slot) -
|
||||||
int64(node.beaconClock.now()),
|
int64(node.beaconClock.now()),
|
||||||
stateSlot = humaneSlotNum(headState.slot),
|
stateSlot = shortLog(headState.slot),
|
||||||
SHARD_COUNT,
|
SHARD_COUNT,
|
||||||
SLOTS_PER_EPOCH,
|
SLOTS_PER_EPOCH,
|
||||||
SECONDS_PER_SLOT,
|
SECONDS_PER_SLOT,
|
||||||
|
|
|
@ -187,7 +187,7 @@ proc addResolvedBlock(
|
||||||
blck = shortLog(blck),
|
blck = shortLog(blck),
|
||||||
blockRoot = shortLog(blockRoot),
|
blockRoot = shortLog(blockRoot),
|
||||||
justifiedRoot = shortLog(foundHead.get().justified.blck.root),
|
justifiedRoot = shortLog(foundHead.get().justified.blck.root),
|
||||||
justifiedSlot = humaneSlotNum(foundHead.get().justified.slot)
|
justifiedSlot = shortLog(foundHead.get().justified.slot)
|
||||||
|
|
||||||
# Now that we have the new block, we should see if any of the previously
|
# Now that we have the new block, we should see if any of the previously
|
||||||
# unresolved blocks magically become resolved
|
# unresolved blocks magically become resolved
|
||||||
|
@ -225,7 +225,7 @@ proc add*(
|
||||||
if blck.slot <= pool.finalizedHead.slot:
|
if blck.slot <= pool.finalizedHead.slot:
|
||||||
debug "Old block, dropping",
|
debug "Old block, dropping",
|
||||||
blck = shortLog(blck),
|
blck = shortLog(blck),
|
||||||
tailSlot = humaneSlotNum(pool.tail.slot),
|
tailSlot = shortLog(pool.tail.slot),
|
||||||
blockRoot = shortLog(blockRoot)
|
blockRoot = shortLog(blockRoot)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -371,7 +371,7 @@ proc maybePutState(pool: BlockPool, state: HashedBeaconState, blck: BlockRef) =
|
||||||
if state.data.slot mod SLOTS_PER_EPOCH == 0:
|
if state.data.slot mod SLOTS_PER_EPOCH == 0:
|
||||||
if not pool.db.containsState(state.root):
|
if not pool.db.containsState(state.root):
|
||||||
info "Storing state",
|
info "Storing state",
|
||||||
stateSlot = humaneSlotNum(state.data.slot),
|
stateSlot = shortLog(state.data.slot),
|
||||||
stateRoot = shortLog(state.root)
|
stateRoot = shortLog(state.root)
|
||||||
pool.db.putState(state.root, state.data)
|
pool.db.putState(state.root, state.data)
|
||||||
# TODO this should be atomic with the above write..
|
# TODO this should be atomic with the above write..
|
||||||
|
@ -432,10 +432,10 @@ proc rewindState(pool: BlockPool, state: var StateData, bs: BlockSlot):
|
||||||
doAssert false, "Oh noes, we passed big bang!"
|
doAssert false, "Oh noes, we passed big bang!"
|
||||||
|
|
||||||
debug "Replaying state transitions",
|
debug "Replaying state transitions",
|
||||||
stateSlot = humaneSlotNum(state.data.data.slot),
|
stateSlot = shortLog(state.data.data.slot),
|
||||||
ancestorStateRoot = shortLog(ancestor.data.state_root),
|
ancestorStateRoot = shortLog(ancestor.data.state_root),
|
||||||
ancestorStateSlot = humaneSlotNum(ancestorState.get().slot),
|
ancestorStateSlot = shortLog(ancestorState.get().slot),
|
||||||
slot = humaneSlotNum(bs.slot),
|
slot = shortLog(bs.slot),
|
||||||
blockRoot = shortLog(bs.blck.root),
|
blockRoot = shortLog(bs.blck.root),
|
||||||
ancestors = ancestors.len
|
ancestors = ancestors.len
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ proc updateHead*(pool: BlockPool, state: var StateData, blck: BlockRef) =
|
||||||
if pool.head.blck == blck:
|
if pool.head.blck == blck:
|
||||||
debug "No head update this time",
|
debug "No head update this time",
|
||||||
headBlockRoot = shortLog(blck.root),
|
headBlockRoot = shortLog(blck.root),
|
||||||
headBlockSlot = humaneSlotNum(blck.slot)
|
headBlockSlot = shortLog(blck.slot)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -533,20 +533,20 @@ proc updateHead*(pool: BlockPool, state: var StateData, blck: BlockRef) =
|
||||||
parentRoot = shortLog(blck.parent.root),
|
parentRoot = shortLog(blck.parent.root),
|
||||||
stateRoot = shortLog(state.data.root),
|
stateRoot = shortLog(state.data.root),
|
||||||
headBlockRoot = shortLog(state.blck.root),
|
headBlockRoot = shortLog(state.blck.root),
|
||||||
stateSlot = humaneSlotNum(state.data.data.slot),
|
stateSlot = shortLog(state.data.data.slot),
|
||||||
justifiedEpoch =
|
justifiedEpoch =
|
||||||
humaneEpochNum(state.data.data.current_justified_checkpoint.epoch),
|
shortLog(state.data.data.current_justified_checkpoint.epoch),
|
||||||
finalizedEpoch =
|
finalizedEpoch =
|
||||||
humaneEpochNum(state.data.data.finalized_checkpoint.epoch)
|
shortLog(state.data.data.finalized_checkpoint.epoch)
|
||||||
else:
|
else:
|
||||||
info "Updated head",
|
info "Updated head",
|
||||||
stateRoot = shortLog(state.data.root),
|
stateRoot = shortLog(state.data.root),
|
||||||
headBlockRoot = shortLog(state.blck.root),
|
headBlockRoot = shortLog(state.blck.root),
|
||||||
stateSlot = humaneSlotNum(state.data.data.slot),
|
stateSlot = shortLog(state.data.data.slot),
|
||||||
justifiedEpoch =
|
justifiedEpoch =
|
||||||
humaneEpochNum(state.data.data.current_justified_checkpoint.epoch),
|
shortLog(state.data.data.current_justified_checkpoint.epoch),
|
||||||
finalizedEpoch =
|
finalizedEpoch =
|
||||||
humaneEpochNum(state.data.data.finalized_checkpoint.epoch)
|
shortLog(state.data.data.finalized_checkpoint.epoch)
|
||||||
|
|
||||||
let
|
let
|
||||||
# TODO there might not be a block at the epoch boundary - what then?
|
# TODO there might not be a block at the epoch boundary - what then?
|
||||||
|
@ -560,9 +560,9 @@ proc updateHead*(pool: BlockPool, state: var StateData, blck: BlockRef) =
|
||||||
if finalizedHead != pool.finalizedHead:
|
if finalizedHead != pool.finalizedHead:
|
||||||
info "Finalized block",
|
info "Finalized block",
|
||||||
finalizedBlockRoot = shortLog(finalizedHead.blck.root),
|
finalizedBlockRoot = shortLog(finalizedHead.blck.root),
|
||||||
finalizedBlockSlot = humaneSlotNum(finalizedHead.slot),
|
finalizedBlockSlot = shortLog(finalizedHead.slot),
|
||||||
headBlockRoot = shortLog(blck.root),
|
headBlockRoot = shortLog(blck.root),
|
||||||
headBlockSlot = humaneSlotNum(blck.slot)
|
headBlockSlot = shortLog(blck.slot)
|
||||||
|
|
||||||
var cur = finalizedHead.blck
|
var cur = finalizedHead.blck
|
||||||
while cur != pool.finalizedHead.blck:
|
while cur != pool.finalizedHead.blck:
|
||||||
|
|
|
@ -497,14 +497,14 @@ proc process_attestation*(
|
||||||
|
|
||||||
if not (attestation_slot + MIN_ATTESTATION_INCLUSION_DELAY <= stateSlot):
|
if not (attestation_slot + MIN_ATTESTATION_INCLUSION_DELAY <= stateSlot):
|
||||||
warn("Attestation too new",
|
warn("Attestation too new",
|
||||||
attestation_slot = humaneSlotNum(attestation_slot),
|
attestation_slot = shortLog(attestation_slot),
|
||||||
state_slot = humaneSlotNum(stateSlot))
|
state_slot = shortLog(stateSlot))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (stateSlot <= attestation_slot + SLOTS_PER_EPOCH):
|
if not (stateSlot <= attestation_slot + SLOTS_PER_EPOCH):
|
||||||
warn("Attestation too old",
|
warn("Attestation too old",
|
||||||
attestation_slot = humaneSlotNum(attestation_slot),
|
attestation_slot = shortLog(attestation_slot),
|
||||||
state_slot = humaneSlotNum(stateSlot))
|
state_slot = shortLog(stateSlot))
|
||||||
return
|
return
|
||||||
|
|
||||||
let pending_attestation = PendingAttestation(
|
let pending_attestation = PendingAttestation(
|
||||||
|
|
|
@ -550,10 +550,10 @@ when useListType:
|
||||||
else:
|
else:
|
||||||
template asSeq*[T; N](x: List[T, N]): auto = x
|
template asSeq*[T; N](x: List[T, N]): auto = x
|
||||||
|
|
||||||
func humaneSlotNum*(s: Slot): uint64 =
|
func shortLog*(s: Slot): uint64 =
|
||||||
s - GENESIS_SLOT
|
s - GENESIS_SLOT
|
||||||
|
|
||||||
func humaneEpochNum*(e: Epoch): uint64 =
|
func shortLog*(e: Epoch): uint64 =
|
||||||
e - GENESIS_EPOCH
|
e - GENESIS_EPOCH
|
||||||
|
|
||||||
func shortLog*(v: BeaconBlock): tuple[
|
func shortLog*(v: BeaconBlock): tuple[
|
||||||
|
@ -566,7 +566,7 @@ func shortLog*(v: BeaconBlock): tuple[
|
||||||
transfers_len: int,
|
transfers_len: int,
|
||||||
signature: string
|
signature: string
|
||||||
] = (
|
] = (
|
||||||
humaneSlotNum(v.slot), shortLog(v.parent_root),
|
shortLog(v.slot), shortLog(v.parent_root),
|
||||||
shortLog(v.state_root), v.body.proposer_slashings.len(),
|
shortLog(v.state_root), v.body.proposer_slashings.len(),
|
||||||
v.body.attester_slashings.len(), v.body.attestations.len(),
|
v.body.attester_slashings.len(), v.body.attestations.len(),
|
||||||
v.body.deposits.len(), v.body.voluntary_exits.len(), v.body.transfers.len(),
|
v.body.deposits.len(), v.body.voluntary_exits.len(), v.body.transfers.len(),
|
||||||
|
@ -576,13 +576,13 @@ func shortLog*(v: BeaconBlock): tuple[
|
||||||
func shortLog*(v: AttestationData): auto =
|
func shortLog*(v: AttestationData): auto =
|
||||||
(
|
(
|
||||||
shortLog(v.beacon_block_root),
|
shortLog(v.beacon_block_root),
|
||||||
humaneEpochNum(v.source.epoch), shortLog(v.target.root),
|
shortLog(v.source.epoch), shortLog(v.target.root),
|
||||||
shortLog(v.source.root),
|
shortLog(v.source.root),
|
||||||
v.crosslink
|
v.crosslink
|
||||||
)
|
)
|
||||||
|
|
||||||
chronicles.formatIt Slot: it.humaneSlotNum
|
chronicles.formatIt Slot: it.shortLog
|
||||||
chronicles.formatIt Epoch: it.humaneEpochNum
|
chronicles.formatIt Epoch: it.shortLog
|
||||||
chronicles.formatIt BeaconBlock: it.shortLog
|
chronicles.formatIt BeaconBlock: it.shortLog
|
||||||
chronicles.formatIt AttestationData: it.shortLog
|
chronicles.formatIt AttestationData: it.shortLog
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ proc processBlockHeader(
|
||||||
# Verify that the slots match
|
# Verify that the slots match
|
||||||
if not (blck.slot == state.slot):
|
if not (blck.slot == state.slot):
|
||||||
notice "Block header: slot mismatch",
|
notice "Block header: slot mismatch",
|
||||||
block_slot = humaneSlotNum(blck.slot),
|
block_slot = shortLog(blck.slot),
|
||||||
state_slot = humaneSlotNum(state.slot)
|
state_slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# Verify that the parent matches
|
# Verify that the parent matches
|
||||||
|
@ -462,37 +462,37 @@ proc processBlock*(
|
||||||
# TODO probably better to do all verification first, then apply state changes
|
# TODO probably better to do all verification first, then apply state changes
|
||||||
|
|
||||||
if not processBlockHeader(state, blck, flags, stateCache):
|
if not processBlockHeader(state, blck, flags, stateCache):
|
||||||
notice "Block header not valid", slot = humaneSlotNum(state.slot)
|
notice "Block header not valid", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processRandao(state, blck.body, flags, stateCache):
|
if not processRandao(state, blck.body, flags, stateCache):
|
||||||
debug "[Block processing] Randao failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Randao failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
processEth1Data(state, blck.body)
|
processEth1Data(state, blck.body)
|
||||||
|
|
||||||
if not processProposerSlashings(state, blck, flags, stateCache):
|
if not processProposerSlashings(state, blck, flags, stateCache):
|
||||||
debug "[Block processing] Proposer slashing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Proposer slashing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processAttesterSlashings(state, blck, stateCache):
|
if not processAttesterSlashings(state, blck, stateCache):
|
||||||
debug "[Block processing] Attester slashing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Attester slashing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processAttestations(state, blck, flags, stateCache):
|
if not processAttestations(state, blck, flags, stateCache):
|
||||||
debug "[Block processing] Attestation processing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Attestation processing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processDeposits(state, blck):
|
if not processDeposits(state, blck):
|
||||||
debug "[Block processing] Deposit processing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Deposit processing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processVoluntaryExits(state, blck, flags):
|
if not processVoluntaryExits(state, blck, flags):
|
||||||
debug "[Block processing] Exit processing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Exit processing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if not processTransfers(state, blck, flags, stateCache):
|
if not processTransfers(state, blck, flags, stateCache):
|
||||||
debug "[Block processing] Transfer processing failure", slot = humaneSlotNum(state.slot)
|
debug "[Block processing] Transfer processing failure", slot = shortLog(state.slot)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
|
@ -58,7 +58,7 @@ func genRandaoReveal*(k: ValidatorPrivKey, state: BeaconState, slot: Slot):
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#randao
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.2.0/specs/core/0_beacon-chain.md#randao
|
||||||
|
|
||||||
# Off-by-one? I often get slot == state.slot but the check was "doAssert slot > state.slot" (Mamy)
|
# Off-by-one? I often get slot == state.slot but the check was "doAssert slot > state.slot" (Mamy)
|
||||||
doAssert slot >= state.slot, "input slot: " & $humaneSlotNum(slot) & " - beacon state slot: " & $humaneSlotNum(state.slot)
|
doAssert slot >= state.slot, "input slot: " & $shortLog(slot) & " - beacon state slot: " & $shortLog(state.slot)
|
||||||
bls_sign(k, hash_tree_root(compute_epoch_of_slot(slot).uint64).data,
|
bls_sign(k, hash_tree_root(compute_epoch_of_slot(slot).uint64).data,
|
||||||
get_domain(state, DOMAIN_RANDAO, compute_epoch_of_slot(slot)))
|
get_domain(state, DOMAIN_RANDAO, compute_epoch_of_slot(slot)))
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ template withTimerRet(stats: var RunningStat, body: untyped): untyped =
|
||||||
proc writeJson*(prefix, slot, v: auto) =
|
proc writeJson*(prefix, slot, v: auto) =
|
||||||
var f: File
|
var f: File
|
||||||
defer: close(f)
|
defer: close(f)
|
||||||
let fileName = fmt"{prefix:04}-{humaneSlotNum(slot):08}.json"
|
let fileName = fmt"{prefix:04}-{shortLog(slot):08}.json"
|
||||||
Json.saveFile(fileName, v, pretty = true)
|
Json.saveFile(fileName, v, pretty = true)
|
||||||
|
|
||||||
cli do(slots = 448,
|
cli do(slots = 448,
|
||||||
|
@ -139,8 +139,8 @@ cli do(slots = 448,
|
||||||
flushFile(stdout)
|
flushFile(stdout)
|
||||||
|
|
||||||
if (state.slot) mod SLOTS_PER_EPOCH == 0:
|
if (state.slot) mod SLOTS_PER_EPOCH == 0:
|
||||||
echo &" slot: {humaneSlotNum(state.slot)} ",
|
echo &" slot: {shortLog(state.slot)} ",
|
||||||
&"epoch: {humaneEpochNum(state.slot.compute_epoch_of_slot)}"
|
&"epoch: {shortLog(state.slot.compute_epoch_of_slot)}"
|
||||||
|
|
||||||
maybeWrite() # catch that last state as well..
|
maybeWrite() # catch that last state as well..
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue