diff --git a/beacon-chain/sync/checkpoint/api.go b/beacon-chain/sync/checkpoint/api.go index d20cf5a093..b30e21e281 100644 --- a/beacon-chain/sync/checkpoint/api.go +++ b/beacon-chain/sync/checkpoint/api.go @@ -44,7 +44,7 @@ func NewAPIInitializer(beaconNodeHost string) (*APIInitializer, error) { func (dl *APIInitializer) Initialize(ctx context.Context, d db.Database) error { origin, err := d.OriginCheckpointBlockRoot(ctx) if err == nil && origin != params.BeaconConfig().ZeroHash { - log.Warnf("Origin checkpoint root %#x found in db, ignoring checkpoint sync flags", origin) + log.WithField("root", fmt.Sprintf("%#x", origin)).Info("Origin checkpoint found in the database, ignoring checkpoint sync flags") return nil } if err != nil && !errors.Is(err, db.ErrNotFound) { diff --git a/beacon-chain/sync/checkpoint/file.go b/beacon-chain/sync/checkpoint/file.go index 330e769883..e7cca26fac 100644 --- a/beacon-chain/sync/checkpoint/file.go +++ b/beacon-chain/sync/checkpoint/file.go @@ -44,7 +44,7 @@ type FileInitializer struct { func (fi *FileInitializer) Initialize(ctx context.Context, d db.Database) error { origin, err := d.OriginCheckpointBlockRoot(ctx) if err == nil && origin != params.BeaconConfig().ZeroHash { - log.Warnf("Origin checkpoint root %#x found in db, ignoring checkpoint sync flags", origin) + log.WithField("root", fmt.Sprintf("%#x", origin)).Info("Origin checkpoint found in the database, ignoring checkpoint sync flags") return nil } else { if !errors.Is(err, db.ErrNotFound) { diff --git a/changelog/manu-logs.md b/changelog/manu-logs.md new file mode 100644 index 0000000000..5af761b604 --- /dev/null +++ b/changelog/manu-logs.md @@ -0,0 +1,6 @@ +### Changed + +- Added log prefix to the `genesis` package. +- Added log prefix to the `params` package. +- `WithGenesisValidatorsRoot`: Use camelCase for log field param. +- Move `Origin checkpoint found in db` from WARN to INFO, since it is the expected behaviour. \ No newline at end of file diff --git a/cmd/beacon-chain/genesis/BUILD.bazel b/cmd/beacon-chain/genesis/BUILD.bazel index c93433052d..061ab905ab 100644 --- a/cmd/beacon-chain/genesis/BUILD.bazel +++ b/cmd/beacon-chain/genesis/BUILD.bazel @@ -2,7 +2,10 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", - srcs = ["options.go"], + srcs = [ + "log.go", + "options.go", + ], importpath = "github.com/OffchainLabs/prysm/v7/cmd/beacon-chain/genesis", visibility = ["//visibility:public"], deps = [ diff --git a/cmd/beacon-chain/genesis/log.go b/cmd/beacon-chain/genesis/log.go new file mode 100644 index 0000000000..5240aa2b10 --- /dev/null +++ b/cmd/beacon-chain/genesis/log.go @@ -0,0 +1,5 @@ +package genesis + +import "github.com/sirupsen/logrus" + +var log = logrus.WithField("prefix", "genesis") diff --git a/cmd/beacon-chain/genesis/options.go b/cmd/beacon-chain/genesis/options.go index fc639dcd0a..3369705987 100644 --- a/cmd/beacon-chain/genesis/options.go +++ b/cmd/beacon-chain/genesis/options.go @@ -5,7 +5,6 @@ import ( "github.com/OffchainLabs/prysm/v7/cmd/beacon-chain/sync/checkpoint" "github.com/OffchainLabs/prysm/v7/genesis" "github.com/pkg/errors" - log "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" ) diff --git a/config/params/BUILD.bazel b/config/params/BUILD.bazel index 026d154073..ef8ca6af4e 100644 --- a/config/params/BUILD.bazel +++ b/config/params/BUILD.bazel @@ -14,6 +14,7 @@ go_library( "interop.go", "io_config.go", "loader.go", + "log.go", "mainnet_config.go", "minimal_config.go", "network_config.go", diff --git a/config/params/config.go b/config/params/config.go index 21d30997b1..56ef2db399 100644 --- a/config/params/config.go +++ b/config/params/config.go @@ -10,8 +10,6 @@ import ( "sync" "time" - log "github.com/sirupsen/logrus" - fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" "github.com/OffchainLabs/prysm/v7/crypto/hash" @@ -20,6 +18,7 @@ import ( "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // BeaconChainConfig contains constant configs for node to participate in beacon chain. @@ -359,7 +358,7 @@ type NetworkScheduleEntry struct { isFork bool `yaml:"-" json:"-"` } -func (e NetworkScheduleEntry) LogFields() log.Fields { +func (e NetworkScheduleEntry) LogFields() logrus.Fields { gvr := BeaconConfig().GenesisValidatorsRoot root, err := computeForkDataRoot(e.ForkVersion, gvr) if err != nil { @@ -367,7 +366,7 @@ func (e NetworkScheduleEntry) LogFields() log.Fields { WithField("genesisValidatorsRoot", fmt.Sprintf("%#x", gvr)). WithError(err).Error("Failed to compute fork data root") } - fields := log.Fields{ + fields := logrus.Fields{ "forkVersion": fmt.Sprintf("%#x", e.ForkVersion), "forkDigest": fmt.Sprintf("%#x", e.ForkDigest), "maxBlobsPerBlock": e.MaxBlobsPerBlock, diff --git a/config/params/loader.go b/config/params/loader.go index 767e17d17e..ef05d18951 100644 --- a/config/params/loader.go +++ b/config/params/loader.go @@ -10,7 +10,6 @@ import ( "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" "github.com/OffchainLabs/prysm/v7/math" "github.com/pkg/errors" - log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" ) diff --git a/config/params/log.go b/config/params/log.go new file mode 100644 index 0000000000..355f415c38 --- /dev/null +++ b/config/params/log.go @@ -0,0 +1,5 @@ +package params + +import "github.com/sirupsen/logrus" + +var log = logrus.WithField("prefix", "params") diff --git a/config/params/opts.go b/config/params/opts.go index e01fed36fd..6e9ab2a6ed 100644 --- a/config/params/opts.go +++ b/config/params/opts.go @@ -2,8 +2,6 @@ package params import ( "fmt" - - log "github.com/sirupsen/logrus" ) type Option func(*BeaconChainConfig) @@ -11,6 +9,6 @@ type Option func(*BeaconChainConfig) func WithGenesisValidatorsRoot(gvr [32]byte) Option { return func(cfg *BeaconChainConfig) { cfg.GenesisValidatorsRoot = gvr - log.WithField("genesis_validators_root", fmt.Sprintf("%#x", gvr)).Info("Setting genesis validators root") + log.WithField("genesisValidatorsRoot", fmt.Sprintf("%#x", gvr)).Info("Setting genesis validators root") } }