diff --git a/math/dec.go b/math/dec.go index 0bcd40a4a4..49daf378ea 100644 --- a/math/dec.go +++ b/math/dec.go @@ -896,7 +896,7 @@ func (d *LegacyDec) UnmarshalAmino(bz []byte) error { return d.Unmarshal(bz) } // helpers -// test if two decimal arrays are equal +// LegacyDecsEqual return true if two decimal arrays are equal. func LegacyDecsEqual(d1s, d2s []LegacyDec) bool { if len(d1s) != len(d2s) { return false diff --git a/math/int.go b/math/int.go index fb4f63e15a..d1d54c5628 100644 --- a/math/int.go +++ b/math/int.go @@ -521,7 +521,7 @@ func (i *Int) Size() int { func (i Int) MarshalAmino() ([]byte, error) { return i.Marshal() } func (i *Int) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } -// intended to be used with require/assert: require.True(IntEq(...)) +// IntEq intended to be used with require/assert: require.True(IntEq(...)) func IntEq(t *testing.T, exp, got Int) (*testing.T, bool, string, string, string) { t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() diff --git a/orm/internal/testkv/db.go b/orm/internal/testkv/db.go index c5fc19b132..e9800d1f71 100644 --- a/orm/internal/testkv/db.go +++ b/orm/internal/testkv/db.go @@ -14,7 +14,7 @@ func (ts TestStore) Get(bz []byte) ([]byte, error) { return ts.Db.Get(bz) } -// // Has checks if a key exists. +// Has checks if a key exists. func (ts TestStore) Has(key []byte) (bool, error) { return ts.Db.Has(key) } @@ -23,18 +23,18 @@ func (ts TestStore) Set(k, v []byte) error { return ts.Db.Set(k, v) } -// // SetSync sets the value for the given key, and flushes it to storage before returning. +// SetSync sets the value for the given key, and flushes it to storage before returning. func (ts TestStore) SetSync(k, v []byte) error { return ts.Db.SetSync(k, v) } -// // Delete deletes the key, or does nothing if the key does not exist. -// // CONTRACT: key readonly []byte +// Delete deletes the key, or does nothing if the key does not exist. +// CONTRACT: key readonly []byte func (ts TestStore) Delete(bz []byte) error { return ts.Db.Delete(bz) } -// // DeleteSync deletes the key, and flushes the delete to storage before returning. +// DeleteSync deletes the key, and flushes the delete to storage before returning. func (ts TestStore) DeleteSync(bz []byte) error { return ts.Db.DeleteSync(bz) } diff --git a/server/v2/api/grpc/config.go b/server/v2/api/grpc/config.go index 5cb0f24ed4..86fb514e70 100644 --- a/server/v2/api/grpc/config.go +++ b/server/v2/api/grpc/config.go @@ -16,7 +16,7 @@ func DefaultConfig() *Config { } } -// GRPCConfig defines configuration for the gRPC server. +// Config defines configuration for the gRPC server. type Config struct { // Enable defines if the gRPC server should be enabled. Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable defines if the gRPC server should be enabled."` diff --git a/server/v2/api/grpc/gogoreflection/serverreflection.go b/server/v2/api/grpc/gogoreflection/serverreflection.go index e7ddc4103f..077c15c332 100644 --- a/server/v2/api/grpc/gogoreflection/serverreflection.go +++ b/server/v2/api/grpc/gogoreflection/serverreflection.go @@ -17,7 +17,7 @@ */ /* -Package reflection implements server reflection service. +Package gogoreflection implements server reflection service. The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto. diff --git a/server/v2/appmanager/genesis.go b/server/v2/appmanager/genesis.go index 2d058fa238..8acad003b6 100644 --- a/server/v2/appmanager/genesis.go +++ b/server/v2/appmanager/genesis.go @@ -7,7 +7,7 @@ import ( ) type ( - // exportGenesis is a function type that represents the export of the genesis state. + // ExportGenesis is a function type that represents the export of the genesis state. ExportGenesis func(ctx context.Context, version uint64) ([]byte, error) // InitGenesis is a function type that represents the initialization of the genesis state. InitGenesis func(ctx context.Context, src io.Reader, txHandler func(json.RawMessage) error) error diff --git a/server/v2/appmanager/types.go b/server/v2/appmanager/types.go index a63044e9dd..760637dbcd 100644 --- a/server/v2/appmanager/types.go +++ b/server/v2/appmanager/types.go @@ -41,6 +41,7 @@ type StateTransitionFunction[T transaction.Tx] interface { req transaction.Msg, ) (transaction.Msg, error) + // RunWithCtx executes the provided closure within a context. // TODO: remove RunWithCtx( ctx context.Context, diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index 37698e1941..c500d47e1e 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -506,6 +506,7 @@ func (c *Consensus[T]) Commit(ctx context.Context, _ *abciproto.CommitRequest) ( } // Vote extensions + // VerifyVoteExtension implements types.Application. func (c *Consensus[T]) VerifyVoteExtension( ctx context.Context, diff --git a/server/v2/cometbft/config.go b/server/v2/cometbft/config.go index d35839eaaa..e349cf6dc5 100644 --- a/server/v2/cometbft/config.go +++ b/server/v2/cometbft/config.go @@ -50,7 +50,7 @@ type Config struct { // CmtCfgOption is a function that allows to overwrite the default server configuration. type CmtCfgOption func(*cmtcfg.Config) -// OverwriteDefaultConfig overwrites the default config with the new config. +// OverwriteDefaultCometConfig overwrites the default comet config with the new config. func OverwriteDefaultCometConfig(newCfg *cmtcfg.Config) CmtCfgOption { return func(cfg *cmtcfg.Config) { // nolint:staticcheck // We want to overwrite everything cfg = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything diff --git a/server/v2/flags.go b/server/v2/flags.go index 6ef849a31d..a86154eb76 100644 --- a/server/v2/flags.go +++ b/server/v2/flags.go @@ -1,14 +1,15 @@ +// Package serverv2 defines constants for server configuration flags and output formats. package serverv2 const ( - // Home flags + // FlagHome specifies the home directory flag. FlagHome = "home" - // Logging flags - FlagLogLevel = "log_level" - FlagLogFormat = "log_format" - FlagLogNoColor = "log_no_color" - FlagTrace = "trace" + FlagLogLevel = "log_level" // Sets the logging level + FlagLogFormat = "log_format" // Specifies the log output format + FlagLogNoColor = "log_no_color" // Disables colored log output + FlagTrace = "trace" // Enables trace-level logging + // OutputFormatJSON defines the JSON output format option. OutputFormatJSON = "json" ) diff --git a/server/v2/server.go b/server/v2/server.go index 5e6c790d0f..c8db2773bd 100644 --- a/server/v2/server.go +++ b/server/v2/server.go @@ -43,7 +43,7 @@ type HasStartFlags interface { var _ ServerComponent[AppI[transaction.Tx], transaction.Tx] = (*Server[AppI[transaction.Tx], transaction.Tx])(nil) -// Configs returns a viper instance of the config file +// ReadConfig returns a viper instance of the config file func ReadConfig(configPath string) (*viper.Viper, error) { v := viper.New() v.SetConfigType("toml") @@ -168,7 +168,8 @@ func (s *Server[AppT, T]) Configs() map[string]any { return cfgs } -// Configs returns all configs of all server components. +// Init initializes all server components with the provided application, configuration, and logger. +// It returns an error if any component fails to initialize. func (s *Server[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) error { var components []ServerComponent[AppT, T] for _, mod := range s.components { @@ -217,7 +218,7 @@ func (s *Server[AppT, T]) WriteConfig(configPath string) error { return nil } -// Flags returns all flags of all server components. +// StartFlags returns all flags of all server components. func (s *Server[AppT, T]) StartFlags() []*pflag.FlagSet { flags := []*pflag.FlagSet{} for _, mod := range s.components { diff --git a/server/v2/streaming/grpc.go b/server/v2/streaming/grpc.go index 591b5e1616..38d9c4320b 100644 --- a/server/v2/streaming/grpc.go +++ b/server/v2/streaming/grpc.go @@ -14,11 +14,12 @@ type GRPCClient struct { client ListenerServiceClient } -// ListenEndBlock listens to end block request and responses. -// In addition, it retrieves a types.Context from a context.Context instance. -// It panics if a types.Context was not properly attached. -// When the node is configured to stop on listening errors, -// it will terminate immediately and exit with a non-zero code. +// ListenDeliverBlock listens for block delivery requests and responses. +// It retrieves a types.Context from the provided context.Context. +// If the node is configured to stop on listening errors, it will terminate +// and exit with a non-zero code upon encountering an error. +// +// Panics if a types.Context is not properly attached to the provided context.Context. func (m *GRPCClient) ListenDeliverBlock(goCtx context.Context, req ListenDeliverBlockRequest) error { ctx := goCtx.(Context) sm := ctx.StreamingManager() @@ -30,11 +31,12 @@ func (m *GRPCClient) ListenDeliverBlock(goCtx context.Context, req ListenDeliver return err } -// ListenCommit listens to commit responses and state changes for the current block. -// In addition, it retrieves a types.Context from a context.Context instance. -// It panics if a types.Context was not properly attached. -// When the node is configured to stop on listening errors, -// it will terminate immediately and exit with a non-zero code. +// ListenStateChanges listens for state changes in the current block. +// It retrieves a types.Context from the provided context.Context. +// If the node is configured to stop on listening errors, it will terminate +// and exit with a non-zero code upon encountering an error. +// +// Panics if a types.Context is not properly attached to the provided context.Context. func (m *GRPCClient) ListenStateChanges(goCtx context.Context, changeSet []*StoreKVPair) error { ctx := goCtx.(Context) sm := ctx.StreamingManager() diff --git a/server/v2/streaming/interface.go b/server/v2/streaming/interface.go index 8a55f513ec..d7ee045343 100644 --- a/server/v2/streaming/interface.go +++ b/server/v2/streaming/interface.go @@ -1,4 +1,5 @@ -// Package abci contains shared data between the host and plugins. +// Package streaming provides shared data structures and interfaces for communication +// between the host application and plugins in a streaming context. package streaming import ( @@ -8,22 +9,20 @@ import ( "google.golang.org/grpc" ) -// Listener is the interface that we're exposing as a streaming service. -// It hooks into the ABCI message processing of the BaseApp. -// The error results are propagated to consensus state machine, -// if you don't want to affect consensus, handle the errors internally and always return `nil` in these APIs. +// Listener defines the interface for a streaming service that hooks into +// the ABCI message processing of the BaseApp. Implementations should handle +// errors internally and return nil if they don't want to affect consensus. type Listener interface { - // ListenDeliverBlock updates the streaming service with the latest Delivered Block messages + // ListenDeliverBlock updates the streaming service with the latest Delivered Block messages. ListenDeliverBlock(context.Context, ListenDeliverBlockRequest) error - // ListenCommit updates the steaming service with the latest Commit messages and state changes + + // ListenStateChanges updates the streaming service with the latest Commit messages and state changes. ListenStateChanges(ctx context.Context, changeSet []*StoreKVPair) error } -// Handshake is a common handshake that is shared by streaming and host. -// This prevents users from executing bad plugins or executing a plugin -// directory. It is a UX feature, not a security feature. +// Handshake defines the handshake configuration shared by the streaming service and host. +// It serves as a UX feature to prevent execution of incompatible or unintended plugins. var Handshake = plugin.HandshakeConfig{ - // This isn't required when using VersionedPlugins ProtocolVersion: 1, MagicCookieKey: "ABCI_LISTENER_PLUGIN", MagicCookieValue: "ef78114d-7bdf-411c-868f-347c99a78345", @@ -40,11 +39,13 @@ type ListenerGRPCPlugin struct { Impl Listener } +// GRPCServer registers the ListenerService server implementation. func (p *ListenerGRPCPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error { RegisterListenerServiceServer(s, &GRPCServer{Impl: p.Impl}) return nil } +// GRPCClient creates a new ListenerService client. func (p *ListenerGRPCPlugin) GRPCClient( _ context.Context, _ *plugin.GRPCBroker,