Skip to content

Commit

Permalink
chore: check blockhash/txhash length whether it is 64 (Finschia#699)
Browse files Browse the repository at this point in the history
* chore: check txhash length whether it is 64

Keep the case where txhash is empty to convey more detailed messages to the user.

* chore: check blockhash length whether it is 64

* update tc to cover new logic

* chore: change `GetByBlockHash` endpoint

* test: add tc about `GetByBlockHash`

* test: add more cases to match coverage to 100%

* chore: goimports

* chore: write to CHANGELOG

* chore: turn off REST test

Unlike gRPC, REST requests often fail. Need to understand the cause later

* chore: update statik to resolve conflict

* chore: change magic number to constant in hash check
  • Loading branch information
tkxkd0159 authored Oct 12, 2022
1 parent 8b8c01b commit 289ca6b
Show file tree
Hide file tree
Showing 12 changed files with 897 additions and 846 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (refactor) [\#685](https://github.com/line/lbm-sdk/pull/685) remove x/foundation UpdateValidatorAuthsProposal
* (x/foundation) [\#686](https://github.com/line/lbm-sdk/pull/686) remove `Minthreshold` and `MinPercentage` from x/foundation config
* (x/foundation) [\#693](https://github.com/line/lbm-sdk/pull/693) add pool to the state of x/foundation
* (x/auth, client) [\#699](https://github.com/line/lbm-sdk/pull/699) Improvement on input validation of `req.Hash`
* (x/wasm,distribution) [\#696](https://github.com/line/lbm-sdk/pull/696) x/wasm,distribution - add checking a file size before reading it
* (x/foundation) [\#698](https://github.com/line/lbm-sdk/pull/698) update x/group relevant logic in x/foundation
* (x/auth,bank,foundation,wasm) [\#691](https://github.com/line/lbm-sdk/pull/691) change AccAddressFromBech32 to MustAccAddressFromBech32
Expand Down
9 changes: 4 additions & 5 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

1,492 changes: 746 additions & 746 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

161 changes: 81 additions & 80 deletions client/grpc/tmservice/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/grpc/tmservice/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package tmservice

import (
"context"
"crypto/sha256"

gogogrpc "github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
abci "github.com/line/ostracon/abci/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

abci "github.com/line/ostracon/abci/types"

"github.com/line/lbm-sdk/client"
"github.com/line/lbm-sdk/client/rpc"
codectypes "github.com/line/lbm-sdk/codec/types"
Expand Down Expand Up @@ -88,6 +88,13 @@ func (s queryServer) GetBlockByHeight(ctx context.Context, req *GetBlockByHeight

// GetBlockByHash implements ServiceServer.GetBlockByHash
func (s queryServer) GetBlockByHash(_ context.Context, req *GetBlockByHashRequest) (*GetBlockByHashResponse, error) {
if n := len(req.Hash); n != sha256.Size {
if n == 0 {
return nil, status.Error(codes.InvalidArgument, "block hash cannot be empty")
}
return nil, status.Error(codes.InvalidArgument, "The length of blcok hash must be 32")
}

res, err := getBlockByHash(s.clientCtx, req.Hash)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 289ca6b

Please sign in to comment.