mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Save invalid blob to temp under new flag (#13725)
This commit is contained in:
parent
02cbcf8545
commit
4731304187
@ -3,17 +3,21 @@ package sync
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/verification"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/rand"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/file"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
prysmTime "github.com/prysmaticlabs/prysm/v5/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
@ -109,6 +113,7 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
|
||||
}
|
||||
|
||||
if err := vf.SidecarKzgProofVerified(); err != nil {
|
||||
saveInvalidBlobToTemp(blob)
|
||||
return pubsub.ValidationReject, err
|
||||
}
|
||||
|
||||
@ -165,3 +170,21 @@ func blobFields(b blocks.ROBlob) logrus.Fields {
|
||||
func computeSubnetForBlobSidecar(index uint64) uint64 {
|
||||
return index % params.BeaconConfig().BlobsidecarSubnetCount
|
||||
}
|
||||
|
||||
// saveInvalidBlobToTemp as a block ssz. Writes to temp directory.
|
||||
func saveInvalidBlobToTemp(b blocks.ROBlob) {
|
||||
if !features.Get().SaveInvalidBlob {
|
||||
return
|
||||
}
|
||||
filename := fmt.Sprintf("blob_sidecar_%d.ssz", b.Slot())
|
||||
fp := path.Join(os.TempDir(), filename)
|
||||
log.Warnf("Writing invalid blob sidecar to disk at %s", fp)
|
||||
enc, err := b.MarshalSSZ()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to ssz encode blob sidecar")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(fp, enc); err != nil {
|
||||
log.WithError(err).Error("Failed to write to disk")
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ type Flags struct {
|
||||
BlobSaveFsync bool
|
||||
|
||||
SaveInvalidBlock bool // SaveInvalidBlock saves invalid block to temp.
|
||||
SaveInvalidBlob bool // SaveInvalidBlob saves invalid blob to temp.
|
||||
|
||||
// KeystoreImportDebounceInterval specifies the time duration the validator waits to reload new keys if they have
|
||||
// changed on disk. This feature is for advanced use cases only.
|
||||
@ -195,6 +196,11 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
|
||||
cfg.SaveInvalidBlock = true
|
||||
}
|
||||
|
||||
if ctx.Bool(saveInvalidBlobTempFlag.Name) {
|
||||
logEnabled(saveInvalidBlobTempFlag)
|
||||
cfg.SaveInvalidBlob = true
|
||||
}
|
||||
|
||||
if ctx.IsSet(disableGRPCConnectionLogging.Name) {
|
||||
logDisabled(disableGRPCConnectionLogging)
|
||||
cfg.DisableGRPCConnectionLogs = true
|
||||
|
@ -46,6 +46,10 @@ var (
|
||||
Name: "save-invalid-block-temp",
|
||||
Usage: "Writes invalid blocks to temp directory.",
|
||||
}
|
||||
saveInvalidBlobTempFlag = &cli.BoolFlag{
|
||||
Name: "save-invalid-blob-temp",
|
||||
Usage: "Writes invalid blobs to temp directory.",
|
||||
}
|
||||
disableGRPCConnectionLogging = &cli.BoolFlag{
|
||||
Name: "disable-grpc-connection-logging",
|
||||
Usage: "Disables displaying logs for newly connected grpc clients.",
|
||||
@ -201,6 +205,7 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c
|
||||
enableExperimentalState,
|
||||
writeSSZStateTransitionsFlag,
|
||||
saveInvalidBlockTempFlag,
|
||||
saveInvalidBlobTempFlag,
|
||||
disableGRPCConnectionLogging,
|
||||
HoleskyTestnet,
|
||||
PraterTestnet,
|
||||
|
Loading…
Reference in New Issue
Block a user