Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/x/evidence/google.gola…
Browse files Browse the repository at this point in the history
…ng.org/grpc-1.66.2
  • Loading branch information
julienrbrt authored Sep 13, 2024
2 parents ceb5f5b + 0064ccb commit 6b0252d
Show file tree
Hide file tree
Showing 41 changed files with 1,295 additions and 1,965 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/gosec.yml

This file was deleted.

55 changes: 10 additions & 45 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ run:
timeout: 15m
allow-parallel-runners: true
build-tags:
- e2e
- ledger
- test_ledger_mock

- e2e
- ledger
- test_ledger_mock

linters:
disable-all: true
Expand Down Expand Up @@ -35,7 +34,7 @@ linters:
- unused

issues:
exclude-dirs:
exclude-dirs:
- testutil/testdata
exclude-files:
- server/grpc/gogoreflection/fix_registration.go
Expand All @@ -46,9 +45,6 @@ issues:
- crypto/keys/secp256k1/internal/*
- types/coin_regex.go
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
Expand Down Expand Up @@ -99,44 +95,13 @@ linters-settings:
disabled: true

gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
# - G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement
excludes:
- G101 # Potential hardcoded credentials
- G107 # Potential HTTP request made with variable url
- G404 # Use of weak random number generator (math/rand instead of crypto/rand)
exclude-generated: true
confidence: medium
misspell:
locale: US
gofumpt:
Expand Down
2 changes: 0 additions & 2 deletions collections/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ type collectionSchemaCodec struct {
objectType schema.ObjectType
keyDecoder func([]byte) (any, error)
valueDecoder func([]byte) (any, error)
keyEncoder func(any) ([]byte, error)
valueEncoder func(any) ([]byte, error)
}

// Prefix defines a segregation bytes namespace for specific collections objects.
Expand Down
12 changes: 5 additions & 7 deletions collections/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,11 @@ func ensureFieldNames(x any, defaultName string, cols []schema.Field) {
for i, col := range cols {
if names != nil && i < len(names) {
col.Name = names[i]
} else {
if col.Name == "" {
if i == 0 && len(cols) == 1 {
col.Name = defaultName
} else {
col.Name = fmt.Sprintf("%s%d", defaultName, i+1)
}
} else if col.Name == "" {
if i == 0 && len(cols) == 1 {
col.Name = defaultName
} else {
col.Name = fmt.Sprintf("%s%d", defaultName, i+1)
}
}
cols[i] = col
Expand Down
2 changes: 2 additions & 0 deletions indexer/postgres/tests/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func TestPostgresIndexer(t *testing.T) {
}

func testPostgresIndexer(t *testing.T, retainDeletions bool) {
t.Helper()

tempDir, err := os.MkdirTemp("", "postgres-indexer-test")
require.NoError(t, err)

Expand Down
7 changes: 3 additions & 4 deletions orm/model/ormdb/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
ormmodulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1"
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"
"cosmossdk.io/core/genesis"
"cosmossdk.io/core/store"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
Expand Down Expand Up @@ -361,11 +360,11 @@ type testStoreService struct {
db corestore.KVStoreWithBatch
}

func (t testStoreService) OpenKVStore(context.Context) store.KVStore {
func (t testStoreService) OpenKVStore(context.Context) corestore.KVStore {
return testkv.TestStore{Db: t.db}
}

func (t testStoreService) OpenMemoryStore(context.Context) store.KVStore {
func (t testStoreService) OpenMemoryStore(context.Context) corestore.KVStore {
return testkv.TestStore{Db: t.db}
}

Expand Down Expand Up @@ -395,7 +394,7 @@ func TestGetBackendResolver(t *testing.T) {
assert.NilError(t, err)
}

func ProvideTestRuntime() store.KVStoreService {
func ProvideTestRuntime() corestore.KVStoreService {
return testStoreService{db: dbm.NewMemDB()}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ replace (

require (
cosmossdk.io/api v0.7.5
cosmossdk.io/core v1.0.0-alpha.1
cosmossdk.io/core v1.0.0-alpha.2
cosmossdk.io/depinject v1.0.0
cosmossdk.io/log v1.4.1
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions runtime/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fed
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
cosmossdk.io/core v1.0.0-alpha.1 h1:iElkDJhxmy51aLMSLMZcfsqcv4QG4/1UHbHiW8Llw6k=
cosmossdk.io/core v1.0.0-alpha.1/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA=
Expand Down
7 changes: 5 additions & 2 deletions server/v2/cometbft/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func TestConsensus_Query(t *testing.T) {
c := setUpConsensus(t, 100_000, cometmock.MockMempool[mock.Tx]{})

// Write data to state storage
c.store.GetStateStorage().ApplyChangeset(1, &store.Changeset{
err := c.store.GetStateStorage().ApplyChangeset(1, &store.Changeset{
Changes: []store.StateChanges{
{
Actor: actorName,
Expand All @@ -589,8 +589,9 @@ func TestConsensus_Query(t *testing.T) {
},
},
})
require.NoError(t, err)

_, err := c.InitChain(context.Background(), &abciproto.InitChainRequest{
_, err = c.InitChain(context.Background(), &abciproto.InitChainRequest{
Time: time.Now(),
ChainId: "test",
InitialHeight: 1,
Expand Down Expand Up @@ -630,6 +631,8 @@ func TestConsensus_Query(t *testing.T) {
}

func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock.Tx]) *Consensus[mock.Tx] {
t.Helper()

msgRouterBuilder := getMsgRouterBuilder(t, func(ctx context.Context, msg *gogotypes.BoolValue) (*gogotypes.BoolValue, error) {
return nil, nil
})
Expand Down
10 changes: 5 additions & 5 deletions server/v2/cometbft/client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"encoding/hex"
"fmt"

v11 "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/api/cometbft/types/v1"

abciv1beta1 "cosmossdk.io/api/cosmos/base/abci/v1beta1"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// GetChainHeight returns the current blockchain height.
Expand Down Expand Up @@ -39,7 +39,7 @@ func GetChainHeight(ctx context.Context, rpcClient CometRPC) (int64, error) {
// tx.height = 5 # all txs of the fifth block
//
// For more information, see the /subscribe CometBFT RPC endpoint documentation
func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query, orderBy string) (*abciv1beta1.SearchBlocksResult, error) {
func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query, orderBy string) (*sdk.SearchBlocksResult, error) {
resBlocks, err := rpcClient.BlockSearch(ctx, query, &page, &limit, orderBy)
if err != nil {
return nil, err
Expand All @@ -56,7 +56,7 @@ func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query
}

// GetBlockByHeight gets block by height
func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*v11.Block, error) {
func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*cmttypes.Block, error) {
// header -> BlockchainInfo
// header, tx -> Block
// results -> BlockResults
Expand All @@ -77,7 +77,7 @@ func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (*
}

// GetBlockByHash gets block by hash
func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString string) (*v11.Block, error) {
func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString string) (*cmttypes.Block, error) {
hash, err := hex.DecodeString(hashHexString)
if err != nil {
return nil, err
Expand Down
19 changes: 9 additions & 10 deletions server/v2/cometbft/client/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package rpc
import (
"fmt"

v11 "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/api/cometbft/types/v1"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
gogoproto "github.com/cosmos/gogoproto/proto"
protov2 "google.golang.org/protobuf/proto"

abciv1beta1 "cosmossdk.io/api/cosmos/base/abci/v1beta1"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// formatBlockResults parses the indexed blocks into a slice of BlockResponse objects.
func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*v11.Block, error) {
func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmttypes.Block, error) {
var (
err error
out = make([]*v11.Block, len(resBlocks))
out = make([]*cmttypes.Block, len(resBlocks))
)
for i := range resBlocks {
out[i], err = NewResponseResultBlock(resBlocks[i])
Expand All @@ -30,9 +29,9 @@ func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*v11.Block, error
return out, nil
}

func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*v11.Block) *abciv1beta1.SearchBlocksResult {
func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*cmttypes.Block) *sdk.SearchBlocksResult {
totalPages := calcTotalPages(totalCount, limit)
return &abciv1beta1.SearchBlocksResult{
return &sdk.SearchBlocksResult{
TotalCount: totalCount,
Count: count,
PageNumber: page,
Expand All @@ -43,7 +42,7 @@ func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*v11.B
}

// NewResponseResultBlock returns a BlockResponse given a ResultBlock from CometBFT
func NewResponseResultBlock(res *coretypes.ResultBlock) (*v11.Block, error) {
func NewResponseResultBlock(res *coretypes.ResultBlock) (*cmttypes.Block, error) {
blkProto, err := res.Block.ToProto()
if err != nil {
return nil, err
Expand All @@ -53,8 +52,8 @@ func NewResponseResultBlock(res *coretypes.ResultBlock) (*v11.Block, error) {
return nil, err
}

blk := &v11.Block{}
err = protov2.Unmarshal(blkBz, blk)
blk := &cmttypes.Block{}
err = gogoproto.Unmarshal(blkBz, blk)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 6b0252d

Please sign in to comment.