mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
2e49fdb3d2
* WIP trying to start from bellatrix state * env var to control log path with unique paths due to flaky test re-run behavior, logs from a failed test run are overwritten by subsequent retries. This makes it difficult to retrieve logs after the first failed run. It also takes some squinting through output to find the location of the log file in the first place. This flag enables logs to be placed in an arbitrary path. Note that bazel sandboxing generally will force this path to be in the /tmp tree. * WIP - grabbing changes from rm-pre-genesis branch * combine bellatrix state w/ rm-pre-genesis branch * WIP * use encoding/detect for genesis state bytes * WIP more fixes towards start from bellatrix * remove debug wrapping * WIP * multiple bugfixes * fix fork ordering bug and bellatrix genesis blocks * send deposits, spam tx to advance, fix miner alloc * WIP * WIP mess * WIP * Print process ID information for purposes of attaching a debugger * bugs: genesis body_root and deposit index mismatch * fix voting period start, skip altair check * add changes * make it better * rm startup FCU, rm logs * cleanup import grouping&ordering * restore FCU log, get rid of tmp var * rm newline * restore newline * restore wrapped error * rm newline * removing boot node version override this doesn't seem to matter? * add issue number to todo comment * rm commented code * rm vmdebug geth flag * unexport values only used with genesis test pkg and add comments where missing from exported values. * adding comments to special cases for testnets * migrate comments from PR to actual code :) * rm unused test param * mark e2e spawns exempt from gosec warning * Fix DeepSource errors in `proposer_bellatrix.go` (#11739) * Fix DeepSource errors in * Omit receiver name * Address PR comments * Remove unused variable * Fix more DeepSource errors Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Remove `Test_IsExecutionEnabledCapella` (#11752) Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Add REST implementation for Validator's `ProposeBeaconBlock` (#11731) * WIP * WIP * WIP * Add tests * WIP * Add more tests * Address DeepSource errors * Remove unused param * Add more tests * Address PR comments * Address PR comments * Fix formatting * Remove unused parameter * Fix TestLittleEndianBytesToBigInt Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fix validator client (#11755) * fix validator client (cherry picked from commit deb138959a2ffcb89cd2e3eb8304477526f4a168) * Use signed changes in middleware block Co-authored-by: Potuz <potuz@prysmaticlabs.com> * API `finalized` metadata field - update protos (#11749) * API `finalized` metadata field - update protos * change nums Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> * log breaks unit tests that don't do full arg setup easiest to just remove it for now * restore prior behavior of phase0 block for altair * update unit tests to account for special case * loosen condition for fork version to match config we don't know which fork version genesis will start from, so we shouldn't force it to be a phase0 genesis. * skip until we can mod configs at runtime * NewGenesisBlockForState computes state root itself * rm noisy log * this log would be noisy in mainnet * fix format specifier, []byte -> string * core.Genesis UnmarshalJson has a value receiver :) * no longer needs to be exported Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com> Co-authored-by: prestonvanloon <preston@prysmaticlabs.com> Co-authored-by: nisdas <nishdas93@gmail.com> Co-authored-by: Patrice Vignola <vignola.patrice@gmail.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: terencechain <terence@prysmaticlabs.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
142 lines
5.0 KiB
Go
142 lines
5.0 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
|
consensusBlocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
|
prysmTime "github.com/prysmaticlabs/prysm/v3/time"
|
|
"github.com/prysmaticlabs/prysm/v3/time/slots"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var log = logrus.WithField("prefix", "blockchain")
|
|
|
|
// logs state transition related data every slot.
|
|
func logStateTransitionData(b interfaces.BeaconBlock) error {
|
|
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()))
|
|
}
|
|
if b.Version() == version.Altair || b.Version() == version.Bellatrix {
|
|
agg, err := b.Body().SyncAggregate()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log = log.WithField("syncBitsCount", agg.SyncCommitteeBits.Count())
|
|
}
|
|
if b.Version() == version.Bellatrix {
|
|
p, err := b.Body().Execution()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log = log.WithField("payloadHash", fmt.Sprintf("%#x", bytesutil.Trunc(p.BlockHash())))
|
|
txs, err := p.Transactions()
|
|
switch {
|
|
case errors.Is(err, consensusBlocks.ErrUnsupportedGetter):
|
|
case err != nil:
|
|
return err
|
|
default:
|
|
log = log.WithField("txCount", len(txs))
|
|
txsPerSlotCount.Set(float64(len(txs)))
|
|
}
|
|
|
|
}
|
|
log.Info("Finished applying state transition")
|
|
return nil
|
|
}
|
|
|
|
func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, justified, finalized *ethpb.Checkpoint, receivedTime time.Time, genesisTime uint64) error {
|
|
startTime, err := slots.ToTime(genesisTime, block.Slot())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
level := log.Logger.GetLevel()
|
|
if level >= logrus.DebugLevel {
|
|
parentRoot := block.ParentRoot()
|
|
log.WithFields(logrus.Fields{
|
|
"slot": block.Slot(),
|
|
"slotInEpoch": block.Slot() % params.BeaconConfig().SlotsPerEpoch,
|
|
"block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]),
|
|
"epoch": slots.ToEpoch(block.Slot()),
|
|
"justifiedEpoch": justified.Epoch,
|
|
"justifiedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(justified.Root)[:8]),
|
|
"finalizedEpoch": finalized.Epoch,
|
|
"finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root)[:8]),
|
|
"parentRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(parentRoot[:])[:8]),
|
|
"version": version.String(block.Version()),
|
|
"sinceSlotStartTime": prysmTime.Now().Sub(startTime),
|
|
"chainServiceProcessedTime": prysmTime.Now().Sub(receivedTime),
|
|
"deposits": len(block.Body().Deposits()),
|
|
}).Debug("Synced new block")
|
|
} else {
|
|
log.WithFields(logrus.Fields{
|
|
"slot": block.Slot(),
|
|
"block": fmt.Sprintf("0x%s...", hex.EncodeToString(blockRoot[:])[:8]),
|
|
"finalizedEpoch": finalized.Epoch,
|
|
"finalizedRoot": fmt.Sprintf("0x%s...", hex.EncodeToString(finalized.Root)[:8]),
|
|
"epoch": slots.ToEpoch(block.Slot()),
|
|
}).Info("Synced new block")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// logs payload related data every slot.
|
|
func logPayload(block interfaces.BeaconBlock) error {
|
|
isExecutionBlk, err := blocks.IsExecutionBlock(block.Body())
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not determine if block is execution block")
|
|
}
|
|
if !isExecutionBlk {
|
|
return nil
|
|
}
|
|
payload, err := block.Body().Execution()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if payload.GasLimit() == 0 {
|
|
return errors.New("gas limit should not be 0")
|
|
}
|
|
gasUtilized := float64(payload.GasUsed()) / float64(payload.GasLimit())
|
|
fields := logrus.Fields{
|
|
"blockHash": fmt.Sprintf("%#x", bytesutil.Trunc(payload.BlockHash())),
|
|
"parentHash": fmt.Sprintf("%#x", bytesutil.Trunc(payload.ParentHash())),
|
|
"blockNumber": payload.BlockNumber,
|
|
"gasUtilized": fmt.Sprintf("%.2f", gasUtilized),
|
|
}
|
|
if block.Version() >= version.Capella {
|
|
withdrawals, err := payload.Withdrawals()
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not get withdrawals")
|
|
}
|
|
fields["withdrawals"] = len(withdrawals)
|
|
changes, err := block.Body().BLSToExecutionChanges()
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not get BLSToExecutionChanges")
|
|
}
|
|
fields["blsToExecutionChanges"] = len(changes)
|
|
}
|
|
log.WithFields(fields).Debug("Synced new payload")
|
|
return nil
|
|
}
|