mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
caf9bdbc6f
* commit initial work * checkpoint current work * gaz * checkpoint * req/resp changes * initial-sync * finally works * fix error * fix bugs * fix issue * fix issues * fix refs * tests * more text fixes * more text fixes * more text fixes * fix tests * fix tests * tests * finally fix builds * finally * comments * fix fuzz * share common library * fix * fix * add in more defensive nil checks * add in more defensive nil checks * imports * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_wrapper.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * imports * fix bad changes * fix * terence's review * terence's review * fmt * Update beacon-chain/rpc/beacon/blocks.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fix tests * fix * fix all tests Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
59 lines
2.1 KiB
Go
59 lines
2.1 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
"time"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
|
"github.com/prysmaticlabs/prysm/shared/interfaces"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var log = logrus.WithField("prefix", "blockchain")
|
|
|
|
// logs state transition related data every slot.
|
|
func logStateTransitionData(b interfaces.BeaconBlock) {
|
|
log := log.WithField("slot", b.Slot)
|
|
if len(b.Body().Attestations()) > 0 {
|
|
log = log.WithField("attestations", len(b.Body().Attestations()))
|
|
}
|
|
if len(b.Body().Deposits()) > 0 {
|
|
log = log.WithField("deposits", len(b.Body().Deposits()))
|
|
}
|
|
if len(b.Body().AttesterSlashings()) > 0 {
|
|
log = log.WithField("attesterSlashings", len(b.Body().AttesterSlashings()))
|
|
}
|
|
if len(b.Body().ProposerSlashings()) > 0 {
|
|
log = log.WithField("proposerSlashings", len(b.Body().ProposerSlashings()))
|
|
}
|
|
if len(b.Body().VoluntaryExits()) > 0 {
|
|
log = log.WithField("voluntaryExits", len(b.Body().VoluntaryExits()))
|
|
}
|
|
log.Info("Finished applying state transition")
|
|
}
|
|
|
|
func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error {
|
|
startTime, err := helpers.SlotToTime(genesisTime, block.Slot())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.WithFields(logrus.Fields{
|
|
"slot": block.Slot(),
|
|
"slotInEpoch": block.Slot() % params.BeaconConfig().SlotsPerEpoch,
|
|
"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")
|
|
log.WithFields(logrus.Fields{
|
|
"slot": block.Slot,
|
|
"sinceSlotStartTime": timeutils.Now().Sub(startTime),
|
|
"chainServiceProcessedTime": timeutils.Now().Sub(receivedTime),
|
|
}).Debug("Sync new block times")
|
|
return nil
|
|
}
|