Skip to content

Commit

Permalink
docs: update docs (#19676)
Browse files Browse the repository at this point in the history
Co-authored-by: son trinh <son@decentrio.ventures>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people committed Mar 8, 2024
1 parent 2bf7e9f commit 2bfc037
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 198 deletions.
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ func checkNegativeHeight(height int64) error {
return nil
}

// createQueryContext creates a new sdk.Context for a query, taking as args
// CreateQueryContext creates a new sdk.Context for a query, taking as args
// the block height and whether the query needs a proof or not.
func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, error) {
if err := checkNegativeHeight(height); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (app *BaseApp) SetFauxMerkleMode() {
app.fauxMerkleMode = true
}

// SetNotSigverify during simulation testing, transaction signature verification needs to be ignored.
// SetNotSigverifyTx during simulation testing, transaction signature verification needs to be ignored.
func (app *BaseApp) SetNotSigverifyTx() {
app.sigverifyTx = false
}
Expand Down
65 changes: 32 additions & 33 deletions baseapp/params_legacy.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
/*
Deprecated.
// Deprecated:

// Legacy types are defined below to aid in the migration of CometBFT consensus
// parameters from use of the now deprecated x/params modules to a new dedicated
// x/consensus module.
//
// Application developers should ensure that they implement their upgrade handler
// correctly such that app.ConsensusParamsKeeper.Set() is called with the values
// returned by GetConsensusParams().
//
// Example:
//
// baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
//
// app.UpgradeKeeper.SetUpgradeHandler(
// UpgradeName,
// func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil {
// app.ConsensusParamsKeeper.Set(ctx, cp)
// } else {
// ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName)
// }
//
// return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
// },
// )
//
// Developers can also bypass the use of the legacy Params subspace and set the
// values to app.ConsensusParamsKeeper.Set() explicitly.
//
// Note, for new chains this is not necessary as CometBFT's consensus parameters
// will automatically be set for you in InitChain.

Legacy types are defined below to aid in the migration of CometBFT consensus
parameters from use of the now deprecated x/params modules to a new dedicated
x/consensus module.
Application developers should ensure that they implement their upgrade handler
correctly such that app.ConsensusParamsKeeper.Set() is called with the values
returned by GetConsensusParams().
Example:
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil {
app.ConsensusParamsKeeper.Set(ctx, cp)
} else {
ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName)
}
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
Developers can also bypass the use of the legacy Params subspace and set the
values to app.ConsensusParamsKeeper.Set() explicitly.
Note, for new chains this is not necessary as CometBFT's consensus parameters
will automatically be set for you in InitChain.
*/
package baseapp

import (
Expand Down
2 changes: 1 addition & 1 deletion client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (ctx Context) WithAux(isAux bool) Context {
return ctx
}

// WithLedgerHasProto returns the context with the provided boolean value, indicating
// WithLedgerHasProtobuf returns the context with the provided boolean value, indicating
// whether the target Ledger application can support Protobuf payloads.
func (ctx Context) WithLedgerHasProtobuf(val bool) Context {
ctx.LedgerHasProtobuf = val
Expand Down
2 changes: 1 addition & 1 deletion client/keys/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAddNewKey(name, password, mnemonic string, account, index int) AddNewKey
}
}

// RecoverKeyBody recovers a key
// RecoverKey recovers a key
type RecoverKey struct {
Password string `json:"password"`
Mnemonic string `json:"mnemonic"`
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func QueryBlocks(clientCtx client.Context, page, limit int, query, orderBy strin
return result, nil
}

// get block by height
// GetBlockByHeight get block by height
func GetBlockByHeight(clientCtx client.Context, height *int64) (*cmt.Block, error) {
// get the node
node, err := clientCtx.GetNode()
Expand Down
2 changes: 1 addition & 1 deletion client/v2/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// later versions unsupported by the current version can be added
var buildInfo, _ = debug.ReadBuildInfo()

// DescriptorName returns the name of the descriptor in kebab case.
// DescriptorKebabName returns the name of the descriptor in kebab case.
func DescriptorKebabName(descriptor protoreflect.Descriptor) string {
return strcase.ToKebab(string(descriptor.Name()))
}
Expand Down
2 changes: 1 addition & 1 deletion codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type (
// MustUnmarshal calls Unmarshal and panics if error is returned.
MustUnmarshal(bz []byte, ptr proto.Message)

// Unmarshal parses the data encoded with UnmarshalLengthPrefixed method and stores
// UnmarshalLengthPrefixed parses the data encoded with UnmarshalLengthPrefixed method and stores
// the result in the value pointed to by v.
UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error
// MustUnmarshalLengthPrefixed calls UnmarshalLengthPrefixed and panics if error
Expand Down
6 changes: 3 additions & 3 deletions codec/types/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (a AminoUnpacker) UnpackAny(any *Any, iface interface{}) error {
return nil
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoPacker is provided for backwards compatibility with
// amino for the binary marshaling phase
type AminoPacker struct {
Cdc *amino.Codec
Expand All @@ -123,7 +123,7 @@ func (a AminoPacker) UnpackAny(any *Any, _ interface{}) error {
return err
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoJSONUnpacker is an AnyUnpacker provided for backwards compatibility with
// amino for the JSON marshaling phase
type AminoJSONUnpacker struct {
Cdc *amino.Codec
Expand Down Expand Up @@ -160,7 +160,7 @@ func (a AminoJSONUnpacker) UnpackAny(any *Any, iface interface{}) error {
return nil
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoJSONPacker is an AnyUnpacker provided for backwards compatibility with
// amino for the JSON un-marshaling phase
type AminoJSONPacker struct {
Cdc *amino.Codec
Expand Down
44 changes: 21 additions & 23 deletions codec/unknownproto/doc.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/*
unknownproto implements functionality to "type check" protobuf serialized byte sequences
against an expected proto.Message to report:
a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor
b) Mismatched wire types for a field -- this is indicative of mismatched services
Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case
if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// Handle the error.
}
and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above.
By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize
this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields:
if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// Handle the error.
}
*/
// Package unknownproto implements functionality to "type check" protobuf serialized byte sequences
// against an expected proto.Message to report:
//
// a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor
//
// b) Mismatched wire types for a field -- this is indicative of mismatched services
//
// Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case
//
// if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// // Handle the error.
// }
//
// and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above.
//
// By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize
// this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields:
//
// if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// // Handle the error.
// }
package unknownproto
4 changes: 2 additions & 2 deletions core/comet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

// BlockInfoService is an interface that can be used to get information specific to Comet
// CometInfoService is an interface that can be used to get information specific to Comet
type CometInfoService interface {
GetCometInfo(context.Context) Info
}
Expand Down Expand Up @@ -50,7 +50,7 @@ type VoteInfo struct {
BlockIDFlag BlockIDFlag
}

// BlockIdFlag indicates which BlockID the signature is for
// BlockIDFlag indicates which BlockID the signature is for
type BlockIDFlag int32

const (
Expand Down
2 changes: 1 addition & 1 deletion core/store/database.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package store

// Database provides access to the underlying database for CRUD operations of non-consensus data.
// DatabaseService provides access to the underlying database for CRUD operations of non-consensus data.
// WARNING: using this api will make your module unprovable for fraud and validity proofs
type DatabaseService interface {
GetDatabase() NonConsensusStore
Expand Down
62 changes: 30 additions & 32 deletions errors/doc.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
/*
Package errors implements custom error interfaces for cosmos-sdk.
Error declarations should be generic and cover broad range of cases. Each
returned error instance can wrap a generic error declaration to provide more
details.
This package provides a broad range of errors declared that fits all common
cases. If an error is very specific for an extension it can be registered outside
of the errors package. If it will be needed my many extensions, please consider
registering it in the errors package. To create a new error instance use Register
function. You must provide a unique, non zero error code and a short description, for example:
var ErrZeroDivision = errors.Register(9241, "zero division")
When returning an error, you can attach to it an additional context
information by using Wrap function, for example:
func safeDiv(val, div int) (int, err) {
if div == 0 {
return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
}
return val / div, nil
}
The first time an error instance is wrapped a stacktrace is attached as well.
Stacktrace information can be printed using %+v and %v formats.
%s is just the error message
%+v is the full stack trace
%v appends a compressed [filename:line] where the error was created
*/
// Package errors implements custom error interfaces for cosmos-sdk.
//
// Error declarations should be generic and cover broad range of cases. Each
// returned error instance can wrap a generic error declaration to provide more
// details.
//
// This package provides a broad range of errors declared that fits all common
// cases. If an error is very specific for an extension it can be registered outside
// of the errors package. If it will be needed my many extensions, please consider
// registering it in the errors package. To create a new error instance use Register
// function. You must provide a unique, non zero error code and a short description, for example:
//
// var ErrZeroDivision = errors.Register(9241, "zero division")
//
// When returning an error, you can attach to it an additional context
// information by using Wrap function, for example:
//
// func safeDiv(val, div int) (int, err) {
// if div == 0 {
// return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
// }
// return val / div, nil
// }
//
// The first time an error instance is wrapped a stacktrace is attached as well.
// Stacktrace information can be printed using %+v and %v formats.
//
// %s is just the error message
// %+v is the full stack trace
// %v appends a compressed [filename:line] where the error was created
package errors
2 changes: 1 addition & 1 deletion runtime/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (e Events) EmitKV(eventType string, attrs ...event.Attribute) error {
return nil
}

// Emit emits an typed event that is defined in the protobuf file.
// EmitNonConsensus emits an typed event that is defined in the protobuf file.
// In the future these events will be added to consensus.
func (e Events) EmitNonConsensus(event protoiface.MessageV1) error {
return e.EventManagerI.EmitTypedEvent(event)
Expand Down
16 changes: 8 additions & 8 deletions runtime/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ import (

const ModuleName = "runtime"

// App implements the common methods for a Cosmos SDK-based application
// AppI implements the common methods for a Cosmos SDK-based application
// specific blockchain.
type AppI interface {
// The assigned name of the app.
// Name the assigned name of the app.
Name() string

// Application updates every begin block.
// BeginBlocker updates every begin block.
BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error)

// Application updates every end block.
// EndBlocker updates every end block.
EndBlocker(ctx sdk.Context) (sdk.EndBlock, error)

// Application update at chain (i.e app) initialization.
// InitChainer update at chain (i.e app) initialization.
InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error)

// Loads the app at a given height.
// LoadHeight load the app at a given height.
LoadHeight(height int64) error

// Exports the state of the application for a genesis file.
// ExportAppStateAndValidators exports the state of the application for a genesis file.
ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (types.ExportedApp, error)
}

// AppSimI implements the common methods for a Cosmos SDK-based application
// specific blockchain that chooses to utilize the sdk simulation framework.
type AppSimI interface {
AppI
// Helper for the simulation framework.
// SimulationManager helper for the simulation framework.
SimulationManager() *module.SimulationManager
}
Loading

0 comments on commit 2bfc037

Please sign in to comment.