2023-11-21 18:44:38 +00:00
|
|
|
package logging
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
2023-11-21 18:44:38 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BlobFields extracts a standard set of fields from a BlobSidecar into a logrus.Fields struct
|
|
|
|
// which can be passed to log.WithFields.
|
|
|
|
func BlobFields(blob blocks.ROBlob) logrus.Fields {
|
|
|
|
return logrus.Fields{
|
2024-02-22 22:40:36 +00:00
|
|
|
"slot": blob.Slot(),
|
|
|
|
"proposerIndex": blob.ProposerIndex(),
|
|
|
|
"blockRoot": fmt.Sprintf("%#x", blob.BlockRoot()),
|
|
|
|
"parentRoot": fmt.Sprintf("%#x", blob.ParentRoot()),
|
|
|
|
"kzgCommitment": fmt.Sprintf("%#x", blob.KzgCommitment),
|
|
|
|
"index": blob.Index,
|
2023-11-21 18:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-06 23:47:09 +00:00
|
|
|
|
|
|
|
// BlockFieldsFromBlob extracts the set of fields from a given BlobSidecar which are shared by the block and
|
|
|
|
// all other sidecars for the block.
|
|
|
|
func BlockFieldsFromBlob(blob blocks.ROBlob) logrus.Fields {
|
|
|
|
return logrus.Fields{
|
2024-02-22 22:40:36 +00:00
|
|
|
"slot": blob.Slot(),
|
|
|
|
"proposerIndex": blob.ProposerIndex(),
|
|
|
|
"blockRoot": fmt.Sprintf("%#x", blob.BlockRoot()),
|
|
|
|
"parentRoot": fmt.Sprintf("%#x", blob.ParentRoot()),
|
2024-01-06 23:47:09 +00:00
|
|
|
}
|
|
|
|
}
|