Skip to content

Commit

Permalink
Merge branch 'main' into marko/check_senden
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle authored May 13, 2024
2 parents 10c1b38 + 11de280 commit 7cd9ca5
Show file tree
Hide file tree
Showing 54 changed files with 880 additions and 269 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/v2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ jobs:
if: env.GIT_DIFF
run: |
cd server/v2/stf && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock'
appamanger:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
server/v2/appmanager/**/*.go
server/v2/appmanager/go.mod
server/v2/appmanager/go.sum
- name: test & coverage report creation
if: env.GIT_DIFF
run: |
cd server/v2/appmanager && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock'
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ linters:
enable:
- dogsled
- errcheck
- errorlint
- exportloopref
- gci
- goconst
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility.
* (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore.
* (genutil) [#19971](https://github.com/cosmos/cosmos-sdk/pull/19971) Allow manually setting the consensus key type in genesis
* (debug) [#20328](https://github.com/cosmos/cosmos-sdk/pull/20328) Add consensus address for debug cmd.

### Improvements

Expand Down
34 changes: 25 additions & 9 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,42 @@ func AddrCmd() *cobra.Command {
addr []byte
err error
)
addr, err = hex.DecodeString(addrString)
if err != nil {
var err2 error
addr, err2 = clientCtx.AddressCodec.StringToBytes(addrString)
if err2 != nil {
var err3 error
addr, err3 = clientCtx.ValidatorAddressCodec.StringToBytes(addrString)
if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %w, bech32 acc: %w, bech32 val: %w", err, err2, err3)
decodeFns := []func(text string) ([]byte, error){
hex.DecodeString,
clientCtx.AddressCodec.StringToBytes,
clientCtx.ValidatorAddressCodec.StringToBytes,
clientCtx.ConsensusAddressCodec.StringToBytes,
}
errs := make([]any, 0, len(decodeFns))
for _, fn := range decodeFns {
if addr, err = fn(addrString); err == nil {
break
}
errs = append(errs, err)
}
if len(errs) == len(decodeFns) {
errTags := []string{
"hex", "bech32 acc", "bech32 val", "bech32 con",
}
format := ""
for i := range errs {
if format != "" {
format += ", "
}
format += errTags[i] + ": %w"
}
return fmt.Errorf("expected hex or bech32. Got errors: "+format, errs...)
}

acc, _ := clientCtx.AddressCodec.BytesToString(addr)
val, _ := clientCtx.ValidatorAddressCodec.BytesToString(addr)
con, _ := clientCtx.ConsensusAddressCodec.BytesToString(addr)

cmd.Println("Address:", addr)
cmd.Printf("Address (hex): %X\n", addr)
cmd.Printf("Bech32 Acc: %s\n", acc)
cmd.Printf("Bech32 Val: %s\n", val)
cmd.Printf("Bech32 Con: %s\n", con)
return nil
},
}
Expand Down
3 changes: 2 additions & 1 deletion client/snapshot/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/tar"
"bytes"
"compress/gzip"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -80,7 +81,7 @@ func LoadArchiveCmd() *cobra.Command {
for i := uint32(0); i < snapshot.Chunks; i++ {
hdr, err = tr.Next()
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
break
}
return err
Expand Down
2 changes: 2 additions & 0 deletions core/transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type Codec[T Tx] interface {
// Decode decodes the tx bytes into a DecodedTx, containing
// both concrete and bytes representation of the tx.
Decode([]byte) (T, error)
// DecodeJSON decodes the tx JSON bytes into a DecodedTx
DecodeJSON([]byte) (T, error)
}

type Tx interface {
Expand Down
6 changes: 3 additions & 3 deletions crypto/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ func EncodeArmor(blockType string, headers map[string]string, data []byte) strin
buf := new(bytes.Buffer)
w, err := armor.Encode(buf, blockType, headers)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %v", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
_, err = w.Write(data)
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %v", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
err = w.Close()
if err != nil {
panic(fmt.Errorf("could not encode ascii armor: %v", err))
panic(fmt.Errorf("could not encode ascii armor: %w", err))
}
return buf.String()
}
Expand Down
2 changes: 1 addition & 1 deletion math/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u Uint) IsNil() bool {
func NewUintFromBigInt(i *big.Int) Uint {
u, err := checkNewUint(i)
if err != nil {
panic(fmt.Errorf("overflow: %s", err))
panic(fmt.Errorf("overflow: %w", err))
}
return u
}
Expand Down
3 changes: 2 additions & 1 deletion orm/encoding/ormfield/string.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ormfield

import (
"errors"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (s NonTerminalStringCodec) Decode(r Reader) (protoreflect.Value, error) {
var bz []byte
for {
b, err := r.ReadByte()
if b == 0 || err == io.EOF {
if b == 0 || errors.Is(err, io.EOF) {
return protoreflect.ValueOfString(string(bz)), err
}
bz = append(bz, b)
Expand Down
3 changes: 2 additions & 1 deletion orm/encoding/ormkv/index_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ormkv

import (
"bytes"
"errors"
"io"

"google.golang.org/protobuf/reflect/protoreflect"
Expand Down Expand Up @@ -64,7 +65,7 @@ func NewIndexKeyCodec(prefix []byte, messageType protoreflect.MessageType, index
func (cdc IndexKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []protoreflect.Value, err error) {
values, err := cdc.DecodeKey(bytes.NewReader(k))
// got prefix key
if err == io.EOF {
if errors.Is(err, io.EOF) {
return values, nil, nil
} else if err != nil {
return nil, nil, err
Expand Down
3 changes: 2 additions & 1 deletion orm/encoding/ormkv/key_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ormkv

import (
"bytes"
"errors"
"io"

"google.golang.org/protobuf/reflect/protoreflect"
Expand Down Expand Up @@ -122,7 +123,7 @@ func (cdc *KeyCodec) DecodeKey(r *bytes.Reader) ([]protoreflect.Value, error) {
values := make([]protoreflect.Value, 0, n)
for i := 0; i < n; i++ {
value, err := cdc.fieldCodecs[i].Decode(r)
if err == io.EOF {
if errors.Is(err, io.EOF) {
return values, err
} else if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions orm/encoding/ormkv/primary_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ormkv

import (
"bytes"
"errors"
"io"

"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -38,7 +39,7 @@ func (p PrimaryKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []
indexFields, err = p.DecodeKey(bytes.NewReader(k))

// got prefix key
if err == io.EOF {
if errors.Is(err, io.EOF) {
return indexFields, nil, nil
} else if err != nil {
return nil, nil, err
Expand All @@ -54,7 +55,7 @@ func (p PrimaryKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []

func (p PrimaryKeyCodec) DecodeEntry(k, v []byte) (Entry, error) {
values, err := p.DecodeKey(bytes.NewReader(k))
if err == io.EOF {
if errors.Is(err, io.EOF) {
return &PrimaryKeyEntry{
TableName: p.messageType.Descriptor().FullName(),
Key: values,
Expand Down
3 changes: 2 additions & 1 deletion orm/encoding/ormkv/unique_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ormkv

import (
"bytes"
"errors"
"io"

"google.golang.org/protobuf/reflect/protoreflect"
Expand Down Expand Up @@ -87,7 +88,7 @@ func (u UniqueKeyCodec) DecodeIndexKey(k, v []byte) (indexFields, primaryKey []p
ks, err := u.keyCodec.DecodeKey(bytes.NewReader(k))

// got prefix key
if err == io.EOF {
if errors.Is(err, io.EOF) {
return ks, nil, err
} else if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/base/tendermint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ message ABCIQueryResponse {
int64 index = 5;
bytes key = 6;
bytes value = 7;
// depreacted in favor of comet proof type
// deprecated in favor of comet proof type
reserved 8;
int64 height = 9;
string codespace = 10;
Expand Down
3 changes: 2 additions & 1 deletion server/grpc/gogoreflection/serverreflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ package gogoreflection
import (
"bytes"
"compress/gzip"
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -375,7 +376,7 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio
sentFileDescriptors := make(map[string]bool)
for {
in, err := stream.Recv()
if err == io.EOF {
if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,11 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
_, _, _, _, _, proxyMetrics, _, _ := metrics(genDoc.ChainID) // nolint: dogsled // function from comet
proxyApp := proxy.NewAppConns(clientCreator, proxyMetrics)
if err := proxyApp.Start(); err != nil {
return nil, fmt.Errorf("error starting proxy app connections: %v", err)
return nil, fmt.Errorf("error starting proxy app connections: %w", err)
}
res, err := proxyApp.Query().Info(context, proxy.InfoRequest)
if err != nil {
return nil, fmt.Errorf("error calling Info: %v", err)
return nil, fmt.Errorf("error calling Info: %w", err)
}
err = proxyApp.Stop()
if err != nil {
Expand Down
Loading

0 comments on commit 7cd9ca5

Please sign in to comment.