mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Save invalid block to temp save-invalid-block-temp
(#13722)
This commit is contained in:
parent
ec7949fa4b
commit
697bcd418c
@ -108,6 +108,7 @@ go_library(
|
|||||||
"//crypto/rand:go_default_library",
|
"//crypto/rand:go_default_library",
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//encoding/ssz/equality:go_default_library",
|
"//encoding/ssz/equality:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//network/forks:go_default_library",
|
"//network/forks:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
|
@ -2,10 +2,16 @@ package sync
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
||||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition/interop"
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition/interop"
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/io/file"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,7 +39,10 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message)
|
|||||||
if r != [32]byte{} {
|
if r != [32]byte{} {
|
||||||
s.setBadBlock(ctx, r) // Setting head block as bad.
|
s.setBadBlock(ctx, r) // Setting head block as bad.
|
||||||
} else {
|
} else {
|
||||||
|
// TODO(13721): Remove this once we can deprecate the flag.
|
||||||
interop.WriteBlockToDisk(signed, true /*failed*/)
|
interop.WriteBlockToDisk(signed, true /*failed*/)
|
||||||
|
|
||||||
|
saveInvalidBlockToTemp(signed)
|
||||||
s.setBadBlock(ctx, root)
|
s.setBadBlock(ctx, root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,3 +54,21 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message)
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteInvalidBlockToDisk as a block ssz. Writes to temp directory.
|
||||||
|
func saveInvalidBlockToTemp(block interfaces.ReadOnlySignedBeaconBlock) {
|
||||||
|
if !features.Get().SaveInvalidBlock {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
filename := fmt.Sprintf("beacon_block_%d.ssz", block.Block().Slot())
|
||||||
|
fp := path.Join(os.TempDir(), filename)
|
||||||
|
log.Warnf("Writing invalid block to disk at %s", fp)
|
||||||
|
enc, err := block.MarshalSSZ()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to ssz encode block")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := file.WriteFile(fp, enc); err != nil {
|
||||||
|
log.WithError(err).Error("Failed to write to disk")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -72,6 +72,9 @@ type Flags struct {
|
|||||||
PrepareAllPayloads bool // PrepareAllPayloads informs the engine to prepare a block on every slot.
|
PrepareAllPayloads bool // PrepareAllPayloads informs the engine to prepare a block on every slot.
|
||||||
// BlobSaveFsync requires blob saving to block on fsync to ensure blobs are durably persisted before passing DA.
|
// BlobSaveFsync requires blob saving to block on fsync to ensure blobs are durably persisted before passing DA.
|
||||||
BlobSaveFsync bool
|
BlobSaveFsync bool
|
||||||
|
|
||||||
|
SaveInvalidBlock bool // SaveInvalidBlock saves invalid block to temp.
|
||||||
|
|
||||||
// KeystoreImportDebounceInterval specifies the time duration the validator waits to reload new keys if they have
|
// 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.
|
// changed on disk. This feature is for advanced use cases only.
|
||||||
KeystoreImportDebounceInterval time.Duration
|
KeystoreImportDebounceInterval time.Duration
|
||||||
@ -187,6 +190,11 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
|
|||||||
cfg.WriteSSZStateTransitions = true
|
cfg.WriteSSZStateTransitions = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Bool(saveInvalidBlockTempFlag.Name) {
|
||||||
|
logEnabled(saveInvalidBlockTempFlag)
|
||||||
|
cfg.SaveInvalidBlock = true
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.IsSet(disableGRPCConnectionLogging.Name) {
|
if ctx.IsSet(disableGRPCConnectionLogging.Name) {
|
||||||
logDisabled(disableGRPCConnectionLogging)
|
logDisabled(disableGRPCConnectionLogging)
|
||||||
cfg.DisableGRPCConnectionLogs = true
|
cfg.DisableGRPCConnectionLogs = true
|
||||||
|
@ -42,6 +42,10 @@ var (
|
|||||||
Name: "interop-write-ssz-state-transitions",
|
Name: "interop-write-ssz-state-transitions",
|
||||||
Usage: "Writes SSZ states to disk after attempted state transitio.",
|
Usage: "Writes SSZ states to disk after attempted state transitio.",
|
||||||
}
|
}
|
||||||
|
saveInvalidBlockTempFlag = &cli.BoolFlag{
|
||||||
|
Name: "save-invalid-block-temp",
|
||||||
|
Usage: "Writes invalid blocks to temp directory.",
|
||||||
|
}
|
||||||
disableGRPCConnectionLogging = &cli.BoolFlag{
|
disableGRPCConnectionLogging = &cli.BoolFlag{
|
||||||
Name: "disable-grpc-connection-logging",
|
Name: "disable-grpc-connection-logging",
|
||||||
Usage: "Disables displaying logs for newly connected grpc clients.",
|
Usage: "Disables displaying logs for newly connected grpc clients.",
|
||||||
@ -196,6 +200,7 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c
|
|||||||
devModeFlag,
|
devModeFlag,
|
||||||
enableExperimentalState,
|
enableExperimentalState,
|
||||||
writeSSZStateTransitionsFlag,
|
writeSSZStateTransitionsFlag,
|
||||||
|
saveInvalidBlockTempFlag,
|
||||||
disableGRPCConnectionLogging,
|
disableGRPCConnectionLogging,
|
||||||
HoleskyTestnet,
|
HoleskyTestnet,
|
||||||
PraterTestnet,
|
PraterTestnet,
|
||||||
|
Loading…
Reference in New Issue
Block a user