Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Jun 10, 2024
1 parent 7077429 commit aa05667
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
1 change: 0 additions & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

abcitypes "github.com/cometbft/cometbft/abci/types"
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"

cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc/codes"
Expand Down
3 changes: 2 additions & 1 deletion baseapp/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package baseapp
import (
"errors"

"cosmossdk.io/core/genesis"
"github.com/cometbft/cometbft/abci/types"

"cosmossdk.io/core/genesis"
)

var _ genesis.TxHandler = (*BaseApp)(nil)
Expand Down
2 changes: 0 additions & 2 deletions core/context/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package context

type contextKey uint8

type (
execModeKey struct{}
cometInfoKey struct{}
Expand Down
12 changes: 6 additions & 6 deletions orm/encoding/ormfield/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const (

// DurationCodec encodes google.protobuf.Duration values with the following
// encoding:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from -315,576,000,000 to +315,576,000,000) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Durations:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from -315,576,000,000 to +315,576,000,000) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Durations:
// - []byte{0xBB, 0x9A, 0xC9, 0xFF} for zero nanos
// - 4 fixed bytes with the bit mask 0x80 applied to the first byte, with negative nanos scaled so that -999,999,999
// is encoded as 0 and -1 is encoded as 999,999,998
Expand Down
12 changes: 6 additions & 6 deletions orm/encoding/ormfield/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

// TimestampCodec encodes google.protobuf.Timestamp values with the following
// encoding:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Timestamps.
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Timestamps.
//
// When iterating over timestamp indexes, nil values will always be ordered last.
//
Expand Down
31 changes: 16 additions & 15 deletions server/cmt_abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package server
import (
"context"

abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
abci "github.com/cometbft/cometbft/abci/types"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
)
Expand All @@ -16,58 +17,58 @@ func NewCometABCIWrapper(app servertypes.ABCI) abci.Application {
return cometABCIWrapper{app: app}
}

func (w cometABCIWrapper) Info(_ context.Context, req *abci.InfoRequest) (*abci.InfoResponse, error) {
func (w cometABCIWrapper) Info(_ context.Context, req *abciproto.InfoRequest) (*abciproto.InfoResponse, error) {
return w.app.Info(req)
}

func (w cometABCIWrapper) Query(ctx context.Context, req *abci.QueryRequest) (*abci.QueryResponse, error) {
func (w cometABCIWrapper) Query(ctx context.Context, req *abciproto.QueryRequest) (*abciproto.QueryResponse, error) {
return w.app.Query(ctx, req)
}

func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.CheckTxRequest) (*abci.CheckTxResponse, error) {
func (w cometABCIWrapper) CheckTx(_ context.Context, req *abciproto.CheckTxRequest) (*abciproto.CheckTxResponse, error) {
return w.app.CheckTx(req)
}

func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) {
func (w cometABCIWrapper) InitChain(_ context.Context, req *abciproto.InitChainRequest) (*abciproto.InitChainResponse, error) {
return w.app.InitChain(req)
}

func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) {
func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abciproto.PrepareProposalRequest) (*abciproto.PrepareProposalResponse, error) {
return w.app.PrepareProposal(req)
}

func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) {
func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abciproto.ProcessProposalRequest) (*abciproto.ProcessProposalResponse, error) {
return w.app.ProcessProposal(req)
}

func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) {
func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abciproto.FinalizeBlockRequest) (*abciproto.FinalizeBlockResponse, error) {
return w.app.FinalizeBlock(req)
}

func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) {
func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abciproto.ExtendVoteRequest) (*abciproto.ExtendVoteResponse, error) {
return w.app.ExtendVote(ctx, req)
}

func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) {
func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abciproto.VerifyVoteExtensionRequest) (*abciproto.VerifyVoteExtensionResponse, error) {
return w.app.VerifyVoteExtension(req)
}

func (w cometABCIWrapper) Commit(_ context.Context, _ *abci.CommitRequest) (*abci.CommitResponse, error) {
func (w cometABCIWrapper) Commit(_ context.Context, _ *abciproto.CommitRequest) (*abciproto.CommitResponse, error) {
return w.app.Commit()
}

func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abci.ListSnapshotsRequest) (*abci.ListSnapshotsResponse, error) {
func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abciproto.ListSnapshotsRequest) (*abciproto.ListSnapshotsResponse, error) {
return w.app.ListSnapshots(req)
}

func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abci.OfferSnapshotRequest) (*abci.OfferSnapshotResponse, error) {
func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abciproto.OfferSnapshotRequest) (*abciproto.OfferSnapshotResponse, error) {
return w.app.OfferSnapshot(req)
}

func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abci.LoadSnapshotChunkRequest) (*abci.LoadSnapshotChunkResponse, error) {
func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abciproto.LoadSnapshotChunkRequest) (*abciproto.LoadSnapshotChunkResponse, error) {
return w.app.LoadSnapshotChunk(req)
}

func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abci.ApplySnapshotChunkRequest) (*abci.ApplySnapshotChunkResponse, error) {
func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abciproto.ApplySnapshotChunkRequest) (*abciproto.ApplySnapshotChunkResponse, error) {
return w.app.ApplySnapshotChunk(req)
}
33 changes: 17 additions & 16 deletions server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"fmt"
"sync/atomic"

abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
abci "github.com/cometbft/cometbft/abci/types"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"

coreappmgr "cosmossdk.io/core/app"
"cosmossdk.io/core/comet"
Expand Down Expand Up @@ -125,7 +126,7 @@ type BlockData struct {

// CheckTx implements types.Application.
// It is called by cometbft to verify transaction validity
func (c *Consensus[T]) CheckTx(ctx context.Context, req *abci.CheckTxRequest) (*abci.CheckTxResponse, error) {
func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxRequest) (*abciproto.CheckTxResponse, error) {
decodedTx, err := c.txCodec.Decode(req.Tx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -154,7 +155,7 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abci.CheckTxRequest) (*
}

// Info implements types.Application.
func (c *Consensus[T]) Info(ctx context.Context, _ *abci.InfoRequest) (*abci.InfoResponse, error) {
func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abciproto.InfoResponse, error) {
version, _, err := c.store.StateLatest()
if err != nil {
return nil, err
Expand Down Expand Up @@ -182,7 +183,7 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abci.InfoRequest) (*abci.Inf

// Query implements types.Application.
// It is called by cometbft to query application state.
func (c *Consensus[T]) Query(ctx context.Context, req *abci.QueryRequest) (*abci.QueryResponse, error) {
func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (*abciproto.QueryResponse, error) {
// follow the query path from here
decodedMsg, err := c.txCodec.Decode(req.Data)
protoMsg, ok := any(decodedMsg).(transaction.Msg)
Expand All @@ -208,7 +209,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abci.QueryRequest) (*abci
return QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "no query path provided"), c.cfg.Trace), nil
}

var resp *abci.QueryResponse
var resp *abciproto.QueryResponse

switch path[0] {
case QueryPathApp:
Expand All @@ -232,7 +233,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abci.QueryRequest) (*abci
}

// InitChain implements types.Application.
func (c *Consensus[T]) InitChain(ctx context.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) {
func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRequest) (*abciproto.InitChainResponse, error) {
c.logger.Info("InitChain", "initialHeight", req.InitialHeight, "chainID", req.ChainId)

// store chainID to be used later on in execution
Expand Down Expand Up @@ -304,8 +305,8 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abci.InitChainRequest
// It is called by cometbft to prepare a proposal block.
func (c *Consensus[T]) PrepareProposal(
ctx context.Context,
req *abci.PrepareProposalRequest,
) (resp *abci.PrepareProposalResponse, err error) {
req *abciproto.PrepareProposalRequest,
) (resp *abciproto.PrepareProposalResponse, err error) {
if req.Height < 1 {
return nil, errors.New("PrepareProposal called with invalid height")
}
Expand Down Expand Up @@ -347,8 +348,8 @@ func (c *Consensus[T]) PrepareProposal(
// It is called by cometbft to process/verify a proposal block.
func (c *Consensus[T]) ProcessProposal(
ctx context.Context,
req *abci.ProcessProposalRequest,
) (*abci.ProcessProposalResponse, error) {
req *abciproto.ProcessProposalRequest,
) (*abciproto.ProcessProposalResponse, error) {
decodedTxs := make([]T, len(req.Txs))
for _, tx := range req.Txs {
decTx, err := c.txCodec.Decode(tx)
Expand Down Expand Up @@ -384,8 +385,8 @@ func (c *Consensus[T]) ProcessProposal(
// It is called by cometbft to finalize a block.
func (c *Consensus[T]) FinalizeBlock(
ctx context.Context,
req *abci.FinalizeBlockRequest,
) (*abci.FinalizeBlockResponse, error) {
req *abciproto.FinalizeBlockRequest,
) (*abciproto.FinalizeBlockResponse, error) {
if err := c.validateFinalizeBlockHeight(req); err != nil {
return nil, err
}
Expand Down Expand Up @@ -494,7 +495,7 @@ func (c *Consensus[T]) FinalizeBlock(

// Commit implements types.Application.
// It is called by cometbft to notify the application that a block was committed.
func (c *Consensus[T]) Commit(ctx context.Context, _ *abci.CommitRequest) (*abci.CommitResponse, error) {
func (c *Consensus[T]) Commit(ctx context.Context, _ *abciproto.CommitRequest) (*abciproto.CommitResponse, error) {
lastCommittedBlock := c.lastCommittedBlock.Load()

c.snapshotManager.SnapshotIfApplicable(lastCommittedBlock.Height)
Expand All @@ -513,8 +514,8 @@ func (c *Consensus[T]) Commit(ctx context.Context, _ *abci.CommitRequest) (*abci
// VerifyVoteExtension implements types.Application.
func (c *Consensus[T]) VerifyVoteExtension(
ctx context.Context,
req *abci.VerifyVoteExtensionRequest,
) (*abci.VerifyVoteExtensionResponse, error) {
req *abciproto.VerifyVoteExtensionRequest,
) (*abciproto.VerifyVoteExtensionResponse, error) {
// If vote extensions are not enabled, as a safety precaution, we return an
// error.
cp, err := c.GetConsensusParams(ctx)
Expand Down Expand Up @@ -548,7 +549,7 @@ func (c *Consensus[T]) VerifyVoteExtension(
}

// ExtendVote implements types.Application.
func (c *Consensus[T]) ExtendVote(ctx context.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) {
func (c *Consensus[T]) ExtendVote(ctx context.Context, req *abciproto.ExtendVoteRequest) (*abciproto.ExtendVoteResponse, error) {
// If vote extensions are not enabled, as a safety precaution, we return an
// error.
cp, err := c.GetConsensusParams(ctx)
Expand Down

0 comments on commit aa05667

Please sign in to comment.