2019-08-24 17:51:00 +00:00
|
|
|
package blockchain
|
|
|
|
|
|
|
|
import (
|
2020-04-29 16:57:04 +00:00
|
|
|
"encoding/hex"
|
2020-01-27 21:48:16 +00:00
|
|
|
"fmt"
|
|
|
|
|
2019-11-27 05:08:18 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
2020-01-27 21:48:16 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
2020-08-20 18:43:03 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
2019-08-24 17:51:00 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var log = logrus.WithField("prefix", "blockchain")
|
|
|
|
|
|
|
|
// logs state transition related data every slot.
|
2020-01-07 23:45:29 +00:00
|
|
|
func logStateTransitionData(b *ethpb.BeaconBlock) {
|
2019-08-24 17:51:00 +00:00
|
|
|
log.WithFields(logrus.Fields{
|
2020-02-27 17:22:39 +00:00
|
|
|
"attestations": len(b.Body.Attestations),
|
|
|
|
"deposits": len(b.Body.Deposits),
|
|
|
|
"attesterSlashings": len(b.Body.AttesterSlashings),
|
2020-04-11 23:04:05 +00:00
|
|
|
"proposerSlashings": len(b.Body.ProposerSlashings),
|
|
|
|
"voluntaryExits": len(b.Body.VoluntaryExits),
|
2019-10-01 20:05:17 +00:00
|
|
|
}).Info("Finished applying state transition")
|
2019-08-24 17:51:00 +00:00
|
|
|
}
|
2020-01-27 21:48:16 +00:00
|
|
|
|
2020-04-29 16:57:04 +00:00
|
|
|
func logBlockSyncStatus(block *ethpb.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint) {
|
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"slot": block.Slot,
|
2020-08-20 18:43:03 +00:00
|
|
|
"slotInEpoch": block.Slot % params.BeaconConfig().SlotsPerEpoch,
|
2020-04-29 16:57:04 +00:00
|
|
|
"block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]),
|
|
|
|
"epoch": helpers.SlotToEpoch(block.Slot),
|
|
|
|
"finalizedEpoch": finalized.Epoch,
|
|
|
|
"finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root[:])[:8]),
|
|
|
|
}).Info("Synced new block")
|
|
|
|
}
|