diff --git a/.github/workflows/check-generated.yml b/.github/workflows/check-generated.yml index 63537a3f5b..b1deaff991 100644 --- a/.github/workflows/check-generated.yml +++ b/.github/workflows/check-generated.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 286e026f52..e82383a4f7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,7 +33,7 @@ jobs: tags: | type=semver,pattern={{version}} - name: docker build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: push: ${{github.event_name != 'pull_request'}} build-args: ARCH=x86_64 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 558b8f3962..831ddeb22f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v6.1.2 with: @@ -30,7 +30,7 @@ jobs: - uses: golangci/golangci-lint-action@v6 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.55 + version: v1.59 args: --timeout 10m github-token: ${{ secrets.GITHUB_TOKEN }} if: env.GIT_DIFF diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 09b1814724..747d0bc93d 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: ./.github/actions/generate-swagger - name: diff run: git diff diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml index 2009c15c8e..fbfb191ce8 100644 --- a/.github/workflows/release-sims.yml +++ b/.github/workflows/release-sims.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - run: | make build @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: install runsim run: | export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/runsim@v1.0.0 @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: actions/cache@v4.0.2 with: path: ~/go/bin @@ -75,7 +75,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: actions/cache@v4.0.2 with: path: ~/go/bin @@ -95,7 +95,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: actions/cache@v4.0.2 with: path: ~/go/bin diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index f03031f1a0..6e0f4ca9b3 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - run: make build @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - name: Install runsim @@ -54,7 +54,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.1.2 @@ -81,7 +81,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.1.2 @@ -110,7 +110,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.1.2 @@ -139,7 +139,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.1.2 diff --git a/.github/workflows/sims_normal.yml b/.github/workflows/sims_normal.yml index 8a0f92e925..a7a5388eef 100644 --- a/.github/workflows/sims_normal.yml +++ b/.github/workflows/sims_normal.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - run: make build @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - name: Install runsim @@ -41,7 +41,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: actions/cache@v4.0.2 @@ -59,7 +59,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: actions/cache@v4.0.2 @@ -77,7 +77,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: actions/cache@v4.0.2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bac38e2f2..d0e56de27f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - name: install tparse @@ -51,7 +51,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: technote-space/get-diff-action@v6.1.2 id: git_diff with: @@ -70,7 +70,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.1.2 @@ -89,6 +89,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' - name: Create a file with all the pkgs run: go list ./... > pkgs.txt - name: Split pkgs into 4 files @@ -122,7 +125,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: technote-space/get-diff-action@v6.1.2 with: PATTERNS: | @@ -187,7 +190,7 @@ jobs: sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt done if: env.GIT_DIFF - - uses: codecov/codecov-action@v4.4.1 + - uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt @@ -204,7 +207,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - uses: technote-space/get-diff-action@v6.1.2 with: PATTERNS: | @@ -229,24 +232,6 @@ jobs: name: "${{ github.sha }}-${{ matrix.part }}-race-output" path: ./${{ matrix.part }}-race-output.txt -# TODO finschia: enable this test -# test-rosetta: -# runs-on: ubuntu-latest -# timeout-minutes: 10 -# steps: -# - uses: actions/checkout@v2 -# - uses: technote-space/get-diff-action@v4 -# id: git_diff -# with: -# PATTERNS: | -# **/**.go -# go.mod -# go.sum -# - name: test rosetta -# run: | -# make test-rosetta -# if: env.GIT_DIFF - # TODO ebony: enable this test # liveness-test: # runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml index 96c08da061..19a9ce33b0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,47 +1,59 @@ run: tests: true timeout: 15m - sort-results: true allow-parallel-runners: true - exclude-dir: testutil/testdata - skip-files: - - server/grpc/gogoreflection/fix_registration.go - - "fix_registration.go" - - ".*\\.pb\\.go$" - - ".*\\.pb\\.gw\\.go$" - - ".*\\.pulsar\\.go$" - - crypto/keys/secp256k1/internal/* build-tags: - ledger - goleveldb - test_ledger_mock +output: + sort-results: true + linters: disable-all: true enable: - errcheck - - dogsled - - exportloopref - - goconst - - gocritic - - gci - - gofumpt - - gosec - gosimple - govet - ineffassign - - misspell + - staticcheck + - unused + - dogsled + - gosec + - gci + - gofumpt + - goconst + - gocritic - nakedret - nolintlint - - staticcheck - revive + - misspell - stylecheck - typecheck - thelper - unconvert - - unused + - asasalint + - asciicheck + - bidichk + - bodyclose + - copyloopvar + - errchkjson + - errorlint + - tenv + - wastedassign + - fatcontext issues: + exclude-dirs: + - "testdata$" + exclude-files: + - server/grpc/gogoreflection/fix_registration.go + - "fix_registration.go" + - ".*\\.pb\\.go$" + - ".*\\.pb\\.gw\\.go$" + - ".*\\.pulsar\\.go$" + - crypto/keys/secp256k1/internal/* exclude-rules: - text: "Use of weak random number generator" linters: @@ -156,8 +168,6 @@ linters-settings: extra-rules: true dogsled: max-blank-identifiers: 6 - maligned: - suggest-new: true nolintlint: allow-unused: false require-explanation: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6e67636c..728a192f4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/fbridge) [\#1395](https://github.com/Finschia/finschia-sdk/pull/1395) Return error instead of panic for behaviors triggered by client * (x/fswap) [\#1396](https://github.com/Finschia/finschia-sdk/pull/1396) refactor to use snake_case in proto * (x/fswap) [\#1391](https://github.com/Finschia/finschia-sdk/pull/1391) add cli_test for fswap module +* (x/fswap) [\#1415](https://github.com/Finschia/finschia-sdk/pull/1415) add more testcases for fswap module ### Bug Fixes * chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue @@ -96,11 +97,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/fswap) [\#1379](https://github.com/Finschia/finschia-sdk/pull/1379) add missing router registration * (x/fswap) [\#1385](https://github.com/Finschia/finschia-sdk/pull/1385) add accidentally deleted event emissions(EventSetSwap, EventAddDenomMetadata) * (x/fswap) [\#1392](https://github.com/Finschia/finschia-sdk/pull/1392) fix dummy denom coin data for test in fswap +* (style) [\#1414](https://github.com/Finschia/finschia-sdk/pull/1414) improve code quality with new linters ### Removed ### Breaking Changes -* (consensus) [\#1178](https://github.com/Finschia/finschia-sdk/pull/1178) change the consensus from Ostracon to Tendermint v0.34.24 +* (consensus) [\#1178](https://github.com/Finschia/finschia-sdk/pull/1178) change the consensus from Ostracon to Tendermint v0.34.24 +* (server) [\#1418](https://github.com/Finschia/finschia-sdk/pull/1418) Remove grpc-web/rosetta and modify grpc-gateway ### State Machine Breaking @@ -111,9 +114,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (repo) [\#1157](https://github.com/Finschia/finschia-sdk/pull/1157) setup CODEOWNERS and backport action * (ci) [\#1160](https://github.com/Finschia/finschia-sdk/pull/1160) remove autopr ci * (repo) [\#1356](https://github.com/Finschia/finschia-sdk/pull/1356) add v0.49.x for backport action +* (build, ci) [\#1410](https://github.com/Finschia/finschia-sdk/pull/1410) Bump Go from 1.20 to 1.22 +* (build) [\#1412](https://github.com/Finschia/finschia-sdk/pull/1412) Update outdated dependencies ### Document Updates * (docs) [\#1059](https://github.com/Finschia/finschia-sdk/pull/1059) create ERRORS.md for x/module * (docs) [\#1083](https://github.com/Finschia/finschia-sdk/pull/1083) Add detailed explanation about default events * (x/token,collection) [#1201](https://github.com/Finschia/finschia-sdk/pull/1201) Deprecate legacy features on x/token,collection -* (build) [\#1393](https://github.com/Finschia/finschia-sdk/pull/1393) add current directory as suffix for docker container \ No newline at end of file +* (build) [\#1393](https://github.com/Finschia/finschia-sdk/pull/1393) add current directory as suffix for docker container +* (docs) [\#1419](https://github.com/Finschia/finschia-sdk/pull/1419) correct spec docs of fswap module diff --git a/Dockerfile b/Dockerfile index 2382ff56f2..8964690534 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ # > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys add foo # > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys list # TODO: demo connecting rest-server (or is this in server now?) -FROM golang:1.20-alpine AS build-env +FROM golang:1.22-alpine AS build-env ARG ARCH=$ARCH # Install minimum necessary dependencies, diff --git a/Makefile b/Makefile index 9ff1bc3c1d..f42e8e834b 100644 --- a/Makefile +++ b/Makefile @@ -342,7 +342,7 @@ lint: golangci-lint find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -d -s golangci-lint: - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59 lint-fix: golangci-lint golangci-lint run --fix --out-format=tab --issues-exit-code=0 @@ -517,19 +517,6 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes .PHONY: localnet-start localnet-stop localnet-debug localnet-build-env \ localnet-build-dlv localnet-build-nodes -############################################################################### -### rosetta ### -############################################################################### - -rosetta-data: - -docker container rm data_dir_build - docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile . - docker run --name data_dir_build -t rosetta-ci:latest sh /rosetta/data.sh - docker cp data_dir_build:/tmp/data.tar.gz "$(CURDIR)/contrib/rosetta/node/data.tar.gz" - docker container rm data_dir_build - -.PHONY: rosetta-data - ############################################################################### ### tools ### ############################################################################### diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 9b3f5cd661..addd1545a0 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -110,8 +110,6 @@ func TestGetBlockRentionHeight(t *testing.T) { } for name, tc := range testCases { - tc := tc - tc.bapp.SetParamStore(¶mStore{db: dbm.NewMemDB()}) tc.bapp.InitChain(abci.RequestInitChain{ ConsensusParams: &abci.ConsensusParams{ diff --git a/baseapp/deliver_tx_test.go b/baseapp/deliver_tx_test.go index 3194728e7d..ce907120ad 100644 --- a/baseapp/deliver_tx_test.go +++ b/baseapp/deliver_tx_test.go @@ -49,7 +49,6 @@ func TestLoadSnapshotChunk(t *testing.T) { "Zero chunk": {2, 1, 0, false}, } for name, tc := range testcases { - tc := tc t.Run(name, func(t *testing.T) { resp := app.LoadSnapshotChunk(abci.RequestLoadSnapshotChunk{ Height: tc.height, @@ -94,7 +93,6 @@ func TestOfferSnapshot_Errors(t *testing.T) { }, abci.ResponseOfferSnapshot_REJECT}, } for name, tc := range testcases { - tc := tc t.Run(name, func(t *testing.T) { resp := app.OfferSnapshot(abci.RequestOfferSnapshot{Snapshot: tc.snapshot}) assert.Equal(t, tc.result, resp.Result) @@ -1819,7 +1817,6 @@ func TestSetLoader(t *testing.T) { v := []byte("value") for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { // prepare a db with some data db := dbm.NewMemDB() diff --git a/client/cmd_test.go b/client/cmd_test.go index d3bfcfd9f9..54ec9a41ef 100644 --- a/client/cmd_test.go +++ b/client/cmd_test.go @@ -94,8 +94,6 @@ func TestSetCmdClientContextHandler(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { ctx := context.WithValue(context.Background(), client.ClientContextKey, &client.Context{}) diff --git a/client/config/cmd.go b/client/config/cmd.go index 1aa00b44bd..5e43193687 100644 --- a/client/config/cmd.go +++ b/client/config/cmd.go @@ -30,7 +30,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error { conf, err := getClientConfig(configPath, clientCtx.Viper) if err != nil { - return fmt.Errorf("couldn't get client config: %v", err) + return fmt.Errorf("couldn't get client config: %w", err) } switch len(args) { @@ -59,7 +59,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error { cmd.Println(conf.BroadcastMode) default: err := errUnknownConfigKey(key) - return fmt.Errorf("couldn't get the value for the key: %v, error: %v", key, err) + return fmt.Errorf("couldn't get the value for the key: %v, error: %w", key, err) } case 2: @@ -83,7 +83,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error { confFile := filepath.Join(configPath, "client.toml") if err := writeConfigToFile(confFile, conf); err != nil { - return fmt.Errorf("could not write client config to the file: %v", err) + return fmt.Errorf("could not write client config to the file: %w", err) } default: diff --git a/client/config/config.go b/client/config/config.go index bfc4c92d78..c98ab9840b 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -59,17 +59,17 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) { // if config.toml file does not exist we create it and write default ClientConfig values into it. if _, err := os.Stat(configFilePath); os.IsNotExist(err) { if err := ensureConfigPath(configPath); err != nil { - return ctx, fmt.Errorf("couldn't make client config: %v", err) + return ctx, fmt.Errorf("couldn't make client config: %w", err) } if err := writeConfigToFile(configFilePath, conf); err != nil { - return ctx, fmt.Errorf("could not write client config to the file: %v", err) + return ctx, fmt.Errorf("could not write client config to the file: %w", err) } } conf, err := getClientConfig(configPath, ctx.Viper) if err != nil { - return ctx, fmt.Errorf("couldn't get client config: %v", err) + return ctx, fmt.Errorf("couldn't get client config: %w", err) } // we need to update KeyringDir field on Client Context first cause it is used in NewKeyringFromBackend ctx = ctx.WithOutputFormat(conf.Output). @@ -78,7 +78,7 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) { keyring, err := client.NewKeyringFromBackend(ctx, conf.KeyringBackend) if err != nil { - return ctx, fmt.Errorf("couldn't get key ring: %v", err) + return ctx, fmt.Errorf("couldn't get key ring: %w", err) } ctx = ctx.WithKeyring(keyring) @@ -86,7 +86,7 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) { // https://github.com/cosmos/cosmos-sdk/issues/8986 client, err := client.NewClientFromNode(conf.Node) if err != nil { - return ctx, fmt.Errorf("couldn't get client from nodeURI: %v", err) + return ctx, fmt.Errorf("couldn't get client from nodeURI: %w", err) } ctx = ctx.WithNodeURI(conf.Node). diff --git a/client/config/config_test.go b/client/config/config_test.go index d766a800f1..e7b46274c6 100644 --- a/client/config/config_test.go +++ b/client/config/config_test.go @@ -88,7 +88,6 @@ func TestConfigCmdEnvFlag(t *testing.T) { } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { clientCtx, cleanup := initClientContext(t, tc.envVar) defer func() { diff --git a/client/context.go b/client/context.go index bb4858e7fd..7678942508 100644 --- a/client/context.go +++ b/client/context.go @@ -10,6 +10,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/viper" rpcclient "github.com/tendermint/tendermint/rpc/client" + "google.golang.org/grpc" "gopkg.in/yaml.v2" "github.com/Finschia/finschia-sdk/codec" @@ -23,6 +24,7 @@ import ( type Context struct { FromAddress sdk.AccAddress Client rpcclient.Client + GRPCClient *grpc.ClientConn ChainID string // Deprecated: Codec codec will be changed to Codec: codec.Codec JSONCodec codec.JSONCodec @@ -145,6 +147,13 @@ func (ctx Context) WithClient(client rpcclient.Client) Context { return ctx } +// WithGRPCClient returns a copy of the context with an updated GRPC client +// instance. +func (ctx Context) WithGRPCClient(grpcClient *grpc.ClientConn) Context { + ctx.GRPCClient = grpcClient + return ctx +} + // WithUseLedger returns a copy of the context with an updated UseLedger flag. func (ctx Context) WithUseLedger(useLedger bool) Context { ctx.UseLedger = useLedger diff --git a/client/debug/main.go b/client/debug/main.go index 163aa87f8f..1b443b5d49 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -84,7 +84,7 @@ $ %s debug addr link19wgf6ymq2ur6r59st95e04e49m69z4al4fc982 addr, err3 = sdk.ValAddressFromBech32(addrString) if err3 != nil { - return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3) + return fmt.Errorf("expected hex or bech32. Got errors: hex: %w, bech32 acc: %w, bech32 val: %w", err, err2, err3) } } } diff --git a/client/flags/flags_test.go b/client/flags/flags_test.go index f86ff64a58..54aa591e0d 100644 --- a/client/flags/flags_test.go +++ b/client/flags/flags_test.go @@ -23,8 +23,6 @@ func TestParseGasSetting(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { gs, err := flags.ParseGasSetting(tc.input) diff --git a/client/grpc/tmservice/service_test.go b/client/grpc/tmservice/service_test.go index ff5d1189c3..c05e86a135 100644 --- a/client/grpc/tmservice/service_test.go +++ b/client/grpc/tmservice/service_test.go @@ -146,7 +146,6 @@ func (s *IntegrationTestSuite) TestLatestValidatorSet_GRPC() { {"with pagination", &tmservice.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{Offset: 0, Limit: uint64(len(vals))}}, false, ""}, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { grpcRes, err := s.queryClient.GetLatestValidatorSet(context.Background(), tc.req) if tc.expErr { @@ -177,7 +176,6 @@ func (s *IntegrationTestSuite) TestLatestValidatorSet_GRPCGateway() { {"with pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/latest?pagination.offset=0&pagination.limit=2", vals[0].APIAddress), false, ""}, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { res, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -210,7 +208,6 @@ func (s *IntegrationTestSuite) TestValidatorSetByHeight_GRPC() { {"with pagination", &tmservice.GetValidatorSetByHeightRequest{Height: 1, Pagination: &qtypes.PageRequest{Offset: 0, Limit: 1}}, false, ""}, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { grpcRes, err := s.queryClient.GetValidatorSetByHeight(context.Background(), tc.req) if tc.expErr { @@ -239,7 +236,6 @@ func (s *IntegrationTestSuite) TestValidatorSetByHeight_GRPCGateway() { {"with pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d?pagination.offset=0&pagination.limit=2", vals[0].APIAddress, 1), false, ""}, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { res, err := rest.GetRequest(tc.url) s.Require().NoError(err) diff --git a/client/grpc_query.go b/client/grpc_query.go index a19a1bc11f..adb4775be6 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -32,7 +32,8 @@ var fallBackCodec = codec.NewProtoCodec(failingInterfaceRegistry{}) func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) { // Two things can happen here: // 1. either we're broadcasting a Tx, in which call we call Tendermint's broadcast endpoint directly, - // 2. or we are querying for state, in which case we call ABCI's Query. + // 2-1. or we are querying for state, in which case we call grpc if grpc client set. + // 2-2. or we are querying for state, in which case we call ABCI's Query if grpc client not set. // In both cases, we don't allow empty request args (it will panic unexpectedly). if reflect.ValueOf(req).IsNil() { @@ -55,7 +56,12 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i return err } - // Case 2. Querying state. + if ctx.GRPCClient != nil { + // Case 2-1. Invoke grpc. + return ctx.GRPCClient.Invoke(grpcCtx, method, req, reply, opts...) + } + + // Case 2-2. Querying state via abci query. reqBz, err := ctx.gRPCCodec().Marshal(req) if err != nil { return err diff --git a/client/keys/add_ledger_test.go b/client/keys/add_ledger_test.go index 31685d1ee9..2ade0ab508 100644 --- a/client/keys/add_ledger_test.go +++ b/client/keys/add_ledger_test.go @@ -154,7 +154,6 @@ func Test_runAddCmdLedgerDryRun(t *testing.T) { }, } for _, tt := range testData { - tt := tt t.Run(tt.name, func(t *testing.T) { cmd := AddKeyCommand() cmd.Flags().AddFlagSet(Commands("home").PersistentFlags()) diff --git a/client/keys/add_test.go b/client/keys/add_test.go index 67233b3263..6aafc1f0ab 100644 --- a/client/keys/add_test.go +++ b/client/keys/add_test.go @@ -307,7 +307,6 @@ func Test_runAddCmdDryRun(t *testing.T) { }, } for _, tt := range testData { - tt := tt t.Run(tt.name, func(t *testing.T) { cmd := AddKeyCommand() cmd.Flags().AddFlagSet(Commands("home").PersistentFlags()) diff --git a/client/keys/codec_test.go b/client/keys/codec_test.go index 7d91884a13..eb4a5abc0c 100644 --- a/client/keys/codec_test.go +++ b/client/keys/codec_test.go @@ -56,7 +56,6 @@ func TestMarshalJSON(t *testing.T) { {"empty object", args{data.Keys[3]}, data.JSON[3], false}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got, err := keys.MarshalJSON(tt.args.o) require.Equal(t, tt.wantErr, err != nil) @@ -86,7 +85,6 @@ func TestUnmarshalJSON(t *testing.T) { {"empty object", args{data.JSON[3], &data.Answers[3]}, false}, } for idx, tt := range tests { - idx, tt := idx, tt t.Run(tt.name, func(t *testing.T) { err := keys.UnmarshalJSON(tt.args.bz, tt.args.ptr) require.Equal(t, tt.wantErr, err != nil) diff --git a/client/keys/list_test.go b/client/keys/list_test.go index 6a0d4fdf18..9f7184602e 100644 --- a/client/keys/list_test.go +++ b/client/keys/list_test.go @@ -47,7 +47,6 @@ func Test_runListCmd(t *testing.T) { {"keybase: w/key", kbHome2, false}, } for _, tt := range testData { - tt := tt t.Run(tt.name, func(t *testing.T) { cmd.SetArgs([]string{ fmt.Sprintf("--%s=%s", flags.FlagHome, tt.kbDir), diff --git a/client/keys/parse_test.go b/client/keys/parse_test.go index 5f8fd6022b..fe8c26d099 100644 --- a/client/keys/parse_test.go +++ b/client/keys/parse_test.go @@ -25,7 +25,6 @@ func TestParseKey(t *testing.T) { {"hex", []string{hexstr}, false}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), config, tt.args) != nil) }) diff --git a/client/keys/show.go b/client/keys/show.go index 3106510413..f401c46004 100644 --- a/client/keys/show.go +++ b/client/keys/show.go @@ -62,7 +62,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) { if len(args) == 1 { info, err = fetchKey(clientCtx.Keyring, args[0]) if err != nil { - return fmt.Errorf("%s is not a valid name or address: %v", args[0], err) + return fmt.Errorf("%s is not a valid name or address: %w", args[0], err) } if info.GetType() == keyring.TypeMulti { info, err = keyring.NewMultiInfo(info.GetName(), info.GetPubKey()) @@ -75,7 +75,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) { for i, keyref := range args { info, err := fetchKey(clientCtx.Keyring, keyref) if err != nil { - return fmt.Errorf("%s is not a valid name or address: %v", keyref, err) + return fmt.Errorf("%s is not a valid name or address: %w", keyref, err) } pks[i] = info.GetPubKey() diff --git a/client/keys/show_test.go b/client/keys/show_test.go index 56394b10bb..05d945bdda 100644 --- a/client/keys/show_test.go +++ b/client/keys/show_test.go @@ -178,7 +178,6 @@ func Test_validateMultisigThreshold(t *testing.T) { {"1-2", args{2, 1}, true}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { if err := validateMultisigThreshold(tt.args.k, tt.args.nKeys); (err != nil) != tt.wantErr { t.Errorf("validateMultisigThreshold() error = %v, wantErr %v", err, tt.wantErr) @@ -204,7 +203,6 @@ func Test_getBechKeyOut(t *testing.T) { {"cons", args{sdk.PrefixConsensus}, keyring.MkConsKeyOutput, false}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got, err := getBechKeyOut(tt.args.bechPrefix) if tt.wantErr { diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index b9eb969055..cabeab29f2 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -71,23 +71,22 @@ func TestCalculateGas(t *testing.T) { } for _, tc := range testCases { - stc := tc txCfg := NewTestTxConfig() txf := tx.Factory{}. WithChainID("test-chain"). WithTxConfig(txCfg).WithSignMode(txCfg.SignModeHandler().DefaultMode()) - t.Run(stc.name, func(t *testing.T) { + t.Run(tc.name, func(t *testing.T) { mockClientCtx := mockContext{ gasUsed: tc.args.mockGasUsed, wantErr: tc.args.mockWantErr, } - simRes, gotAdjusted, err := tx.CalculateGas(mockClientCtx, txf.WithGasAdjustment(stc.args.adjustment)) - if stc.expPass { + simRes, gotAdjusted, err := tx.CalculateGas(mockClientCtx, txf.WithGasAdjustment(tc.args.adjustment)) + if tc.expPass { require.NoError(t, err) - require.Equal(t, simRes.GasInfo.GasUsed, stc.wantEstimate) - require.Equal(t, gotAdjusted, stc.wantAdjusted) + require.Equal(t, simRes.GasInfo.GasUsed, tc.wantEstimate) + require.Equal(t, gotAdjusted, tc.wantAdjusted) require.NotNil(t, simRes.Result) } else { require.Error(t, err) diff --git a/client/utils_test.go b/client/utils_test.go index 840af06fff..a0381f787d 100644 --- a/client/utils_test.go +++ b/client/utils_test.go @@ -70,7 +70,6 @@ func TestPaginate(t *testing.T) { } for i, tc := range testCases { - i, tc := i, tc t.Run(tc.name, func(t *testing.T) { start, end := client.Paginate(tc.numObjs, tc.page, tc.limit, tc.defLimit) require.Equal(t, tc.expectedStart, start, "invalid result; test case #%d", i) diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index 2e305a0686..7ecc75ce51 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -74,8 +74,6 @@ func TestAminoCodecMarshalJSONIndent(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { cdc := codec.NewAminoCodec(createTestCodec()) bz, err := cdc.MarshalJSONIndent(tc.input, "", " ") diff --git a/codec/codec_common_test.go b/codec/codec_common_test.go index dc08f0fb24..ec3eefb424 100644 --- a/codec/codec_common_test.go +++ b/codec/codec_common_test.go @@ -119,7 +119,6 @@ func testMarshaling(t *testing.T, cdc codec.Codec) { } for _, tc := range testCases { - tc := tc m1 := mustMarshaler{cdc.Marshal, cdc.MustMarshal, cdc.Unmarshal, cdc.MustUnmarshal} m2 := mustMarshaler{cdc.MarshalLengthPrefixed, cdc.MustMarshalLengthPrefixed, cdc.UnmarshalLengthPrefixed, cdc.MustUnmarshalLengthPrefixed} m3 := mustMarshaler{ diff --git a/codec/proto_codec_test.go b/codec/proto_codec_test.go index 8e653b0d1a..ba26ddfc3e 100644 --- a/codec/proto_codec_test.go +++ b/codec/proto_codec_test.go @@ -58,8 +58,6 @@ func TestProtoCodecUnmarshalLengthPrefixedChecks(t *testing.T) { } for _, falseSize := range falseSizes { - falseSize := falseSize - t.Run(fmt.Sprintf("ByMarshaling falseSize=%d", falseSize), func(t *testing.T) { lpm := &lyingProtoMarshaler{ ProtoMarshaler: &testdata.Cat{Lives: 9, Moniker: "glowing"}, diff --git a/codec/unknownproto/unit_helpers_test.go b/codec/unknownproto/unit_helpers_test.go index 9c408a6d1f..b156422489 100644 --- a/codec/unknownproto/unit_helpers_test.go +++ b/codec/unknownproto/unit_helpers_test.go @@ -22,7 +22,6 @@ func TestWireTypeToString(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(fmt.Sprintf("wireType=%d", tt.typ), func(t *testing.T) { if g, w := wireTypeToString(tt.typ), tt.want; g != w { t.Fatalf("Mismatch:\nGot: %q\nWant: %q\n", g, w) diff --git a/codec/unknownproto/unknown_fields_test.go b/codec/unknownproto/unknown_fields_test.go index 9b14c77287..8f9a9af7f7 100644 --- a/codec/unknownproto/unknown_fields_test.go +++ b/codec/unknownproto/unknown_fields_test.go @@ -223,7 +223,6 @@ func TestRejectUnknownFieldsRepeated(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { protoBlob, err := proto.Marshal(tt.in) if err != nil { @@ -280,7 +279,6 @@ func TestRejectUnknownFields_allowUnknownNonCriticals(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { blob, err := proto.Marshal(tt.in) if err != nil { @@ -483,7 +481,6 @@ func TestRejectUnknownFieldsNested(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { protoBlob, err := proto.Marshal(tt.in) if err != nil { @@ -634,7 +631,6 @@ func TestRejectUnknownFieldsFlat(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { blob, err := proto.Marshal(tt.in) if err != nil { diff --git a/contrib/devtools/dockerfile b/contrib/devtools/dockerfile index 10be413453..47f27d47e0 100644 --- a/contrib/devtools/dockerfile +++ b/contrib/devtools/dockerfile @@ -1,6 +1,6 @@ FROM bufbuild/buf:latest as BUILDER -FROM golang:alpine +FROM golang:1.22-alpine ENV GOLANG_PROTOBUF_VERSION=1.3.5 \ GOGO_PROTOBUF_VERSION=1.3.2 \ diff --git a/contrib/images/simd-dlv/Dockerfile b/contrib/images/simd-dlv/Dockerfile index e9a23cf1cd..7c2ea70d58 100644 --- a/contrib/images/simd-dlv/Dockerfile +++ b/contrib/images/simd-dlv/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine AS build +FROM golang:1.22-alpine AS build RUN apk add build-base git linux-headers libc-dev RUN go install github.com/go-delve/delve/cmd/dlv@latest WORKDIR /work diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index 3d699f7fcb..6af3536bad 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine AS build +FROM golang:1.22-alpine AS build RUN apk add build-base git linux-headers WORKDIR /work COPY go.mod go.sum /work/ diff --git a/contrib/rosetta/README.md b/contrib/rosetta/README.md deleted file mode 100644 index f408729581..0000000000 --- a/contrib/rosetta/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# rosetta - -This directory contains the files required to run the rosetta CI. It builds `simapp` based on the current codebase. - -## docker-compose.yaml - -Builds: - -- cosmos-sdk simapp node, with prefixed data directory, keys etc. This is required to test historical balances. -- faucet is required so we can test construction API, it was literally impossible to put there a deterministic address to request funds for -- rosetta is the rosetta node used by rosetta-cli to interact with the cosmos-sdk app -- test_rosetta runs the rosetta-cli test against construction API and data API - -## configuration - -Contains the required files to set up rosetta cli and make it work against its workflows - -## node - -Contains the files for a deterministic network, with fixed keys and some actions on there, to test parsing of msgs and historical balances. This image is used to run a simapp node and to run the rosetta server. - -## Rosetta-cli - -The docker image for ./rosetta-cli/Dockerfile is on [docker hub](https://hub.docker.com/r/tendermintdev/rosetta-cli). Whenever rosetta-cli releases a new version, rosetta-cli/Dockerfile should be updated to reflect the new version and pushed to docker hub. - -## Notes - -- Keyring password is 12345678 -- data.sh creates node data, it's required in case consensus breaking changes are made to quickly recreate replicable node data for rosetta diff --git a/contrib/rosetta/configuration/bootstrap.json b/contrib/rosetta/configuration/bootstrap.json deleted file mode 100644 index ebac03c43b..0000000000 --- a/contrib/rosetta/configuration/bootstrap.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "account_identifier": { - "address":"link1ujtnemf6jmfm995j000qdry064n5lq854gfe3j" - }, - "currency":{ - "symbol":"stake", - "decimals":0 - }, - "value": "999990000000" - } -] \ No newline at end of file diff --git a/contrib/rosetta/configuration/data.sh b/contrib/rosetta/configuration/data.sh deleted file mode 100644 index 4d7d5ff0b0..0000000000 --- a/contrib/rosetta/configuration/data.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -set -e - -wait_simd() { - timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 9090 -} -# this script is used to recreate the data dir -echo clearing /root/.simapp -rm -rf /root/.simapp -echo initting new chain -# init config files -simd init simd --chain-id testing - -# create accounts -simd keys add fd --keyring-backend=test - -addr=$(simd keys show fd -a --keyring-backend=test) -val_addr=$(simd keys show fd --keyring-backend=test --bech val -a) - -# give the accounts some money -simd add-genesis-account "$addr" 1000000000000stake --keyring-backend=test - -# save configs for the daemon -simd gentx fd 10000000stake --chain-id testing --keyring-backend=test - -# input genTx to the genesis file -simd collect-gentxs -# verify genesis file is fine -simd validate-genesis -echo changing network settings -sed -i 's/127.0.0.1/0.0.0.0/g' /root/.simapp/config/config.toml - -# start simd -echo starting simd... -simd start --pruning=nothing & -pid=$! -echo simd started with PID $pid - -echo awaiting for simd to be ready -wait_simd -echo simd is ready -sleep 10 - - -# send transaction to deterministic address -echo sending transaction with addr $addr -simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing - -sleep 10 - -echo stopping simd... -kill -9 $pid - -echo zipping data dir and saving to /tmp/data.tar.gz - -tar -czvf /tmp/data.tar.gz /root/.simapp - -echo new address for bootstrap.json "$addr" "$val_addr" diff --git a/contrib/rosetta/configuration/faucet.py b/contrib/rosetta/configuration/faucet.py deleted file mode 100644 index 44536a84bb..0000000000 --- a/contrib/rosetta/configuration/faucet.py +++ /dev/null @@ -1,25 +0,0 @@ -from http.server import HTTPServer, BaseHTTPRequestHandler -import subprocess - -import os - - -class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - - def do_POST(self): - try: - content_len = int(self.headers.get('Content-Length')) - addr = self.rfile.read(content_len).decode("utf-8") - print("sending funds to " + addr) - subprocess.call(['sh', './send_funds.sh', addr]) - self.send_response(200) - self.end_headers() - except Exception as e: - print("failed " + str(e)) - os._exit(1) - - -if __name__ == "__main__": - print("starting faucet server...") - httpd = HTTPServer(('0.0.0.0', 8000), SimpleHTTPRequestHandler) - httpd.serve_forever() diff --git a/contrib/rosetta/configuration/rosetta.json b/contrib/rosetta/configuration/rosetta.json deleted file mode 100644 index b4adc6a756..0000000000 --- a/contrib/rosetta/configuration/rosetta.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "network": { - "blockchain": "app", - "network": "network" - }, - "online_url": "http://rosetta:8080", - "data_directory": "", - "http_timeout": 300, - "max_retries": 5, - "retry_elapsed_time": 0, - "max_online_connections": 0, - "max_sync_concurrency": 0, - "tip_delay": 60, - "log_configuration": true, - "construction": { - "offline_url": "http://rosetta:8080", - "max_offline_connections": 0, - "stale_depth": 0, - "broadcast_limit": 0, - "ignore_broadcast_failures": false, - "clear_broadcasts": false, - "broadcast_behind_tip": false, - "block_broadcast_limit": 0, - "rebroadcast_all": false, - "constructor_dsl_file": "transfer.ros", - "end_conditions": { - "create_account": 1, - "transfer": 1 - } - }, - "data": { - "active_reconciliation_concurrency": 0, - "inactive_reconciliation_concurrency": 0, - "inactive_reconciliation_frequency": 0, - "log_blocks": false, - "log_transactions": false, - "log_balance_changes": false, - "log_reconciliations": false, - "ignore_reconciliation_error": false, - "exempt_accounts": "", - "bootstrap_balances": "bootstrap.json", - "interesting_accounts": "", - "reconciliation_disabled": false, - "inactive_discrepency_search_disabled": false, - "balance_tracking_disabled": false, - "coin_tracking_disabled": false, - "end_conditions": { - "tip": true - } - } -} \ No newline at end of file diff --git a/contrib/rosetta/configuration/run_tests.sh b/contrib/rosetta/configuration/run_tests.sh deleted file mode 100755 index c53f89ff88..0000000000 --- a/contrib/rosetta/configuration/run_tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e - -wait_for_rosetta() { - timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' rosetta 8080 -} - -echo "waiting for rosetta instance to be up" -wait_for_rosetta - -echo "checking data API" -rosetta-cli check:data --configuration-file ./config/rosetta.json - -echo "checking construction API" -rosetta-cli check:construction --configuration-file ./config/rosetta.json - diff --git a/contrib/rosetta/configuration/send_funds.sh b/contrib/rosetta/configuration/send_funds.sh deleted file mode 100644 index 3a897539d2..0000000000 --- a/contrib/rosetta/configuration/send_funds.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -set -e -addr=$(simd keys show fd -a --keyring-backend=test) -echo "12345678" | simd tx bank send "$addr" "$1" 100stake --chain-id="testing" --node tcp://cosmos:26657 --yes --keyring-backend=test \ No newline at end of file diff --git a/contrib/rosetta/configuration/transfer.ros b/contrib/rosetta/configuration/transfer.ros deleted file mode 100644 index 201a8ab7c4..0000000000 --- a/contrib/rosetta/configuration/transfer.ros +++ /dev/null @@ -1,105 +0,0 @@ -request_funds(1){ - find_account{ - currency = {"symbol":"stake", "decimals":0}; - random_account = find_balance({ - "minimum_balance":{ - "value": "0", - "currency": {{currency}} - }, - "create_limit":1 - }); - }, - send_funds{ - account_identifier = {{random_account.account_identifier}}; - address = {{account_identifier.address}}; - idk = http_request({ - "method": "POST", - "url": "http:\/\/faucet:8000", - "timeout": 10, - "body": {{random_account.account_identifier.address}} - }); - }, - // Create a separate scenario to request funds so that - // the address we are using to request funds does not - // get rolled back if funds do not yet exist. - request{ - loaded_account = find_balance({ - "account_identifier": {{random_account.account_identifier}}, - "minimum_balance":{ - "value": "50", - "currency": {{currency}} - } - }); - } -} -create_account(1){ - create{ - network = {"network":"network", "blockchain":"app"}; - key = generate_key({"curve_type": "secp256k1"}); - account = derive({ - "network_identifier": {{network}}, - "public_key": {{key.public_key}} - }); - // If the account is not saved, the key will be lost! - save_account({ - "account_identifier": {{account.account_identifier}}, - "keypair": {{key}} - }); - } -} -transfer(3){ - transfer{ - transfer.network = {"network":"network", "blockchain":"app"}; - currency = {"symbol":"stake", "decimals":0}; - sender = find_balance({ - "minimum_balance":{ - "value": "100", - "currency": {{currency}} - } - }); - acc_identifier = {{sender.account_identifier}}; - sender_address = {{acc_identifier.address}}; - // Set the recipient_amount as some value <= sender.balance-max_fee - max_fee = "0"; - fee_amount = "1"; - fee_value = 0 - {{fee_amount}}; - available_amount = {{sender.balance.value}} - {{max_fee}}; - recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}}); - print_message({"recipient_amount":{{recipient_amount}}}); - // Find recipient and construct operations - sender_amount = 0 - {{recipient_amount}}; - recipient = find_balance({ - "not_account_identifier":[{{sender.account_identifier}}], - "minimum_balance":{ - "value": "0", - "currency": {{currency}} - }, - "create_limit": 100, - "create_probability": 50 - }); - transfer.confirmation_depth = "1"; - recipient_account_identifier = {{recipient.account_identifier}}; - recipient_address = {{recipient_account_identifier.address}}; - transfer.operations = [ - { - "operation_identifier":{"index":0}, - "type":"/cosmos.bank.v1beta1.MsgSend", - "account":{{sender.account_identifier}}, - "metadata": { - "amount": [ - { - "amount": {{recipient_amount}}, - "denom": {{currency.symbol}} - } - ], - "from_address": {{sender_address}}, - "to_address": {{recipient_address}} - } - } - ]; - transfer.preprocess_metadata = { - "gas_price": "1stake", - "gas_limit": 250000 - }; - } -} diff --git a/contrib/rosetta/docker-compose.yaml b/contrib/rosetta/docker-compose.yaml deleted file mode 100644 index fabb36b0aa..0000000000 --- a/contrib/rosetta/docker-compose.yaml +++ /dev/null @@ -1,39 +0,0 @@ -version: "3" - -services: - cosmos: - image: rosetta-ci:latest - command: ["simd", "start", "--pruning", "nothing", "--grpc-web.enable", "true", "--grpc-web.address", "0.0.0.0:9091"] - ports: - - 9090:9090 - - 26657:26657 - logging: - driver: "none" - - rosetta: - image: rosetta-ci:latest - command: [ - "simd", - "rosetta", - "--blockchain", "app", - "--network", "network", - "--tendermint", "cosmos:26657", - "--grpc", "cosmos:9090", - "--addr", ":8080", - ] - ports: - - 8080:8080 - - faucet: - image: rosetta-ci:latest - working_dir: /rosetta - command: ["python3", "faucet.py"] - expose: - - 8080 - - test_rosetta: - image: tendermintdev/rosetta-cli:v0.6.7 - volumes: - - ./configuration:/rosetta/config:z - command: ["./config/run_tests.sh"] - working_dir: /rosetta diff --git a/contrib/rosetta/node/Dockerfile b/contrib/rosetta/node/Dockerfile deleted file mode 100644 index e520ede01c..0000000000 --- a/contrib/rosetta/node/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM golang:1.20-alpine as build - -RUN apk add --no-cache tar - -# prepare node data -WORKDIR /node -COPY ./contrib/rosetta/node/data.tar.gz data.tar.gz -RUN tar -zxvf data.tar.gz -C . - -# build simd -WORKDIR /simd -COPY . ./ -RUN go build -o simd ./simapp/simd/ - -FROM alpine -RUN apk add gcc libc-dev python3 --no-cache - -ENV PATH=$PATH:/bin - -COPY --from=build /simd/simd /bin/simd - -WORKDIR /rosetta -COPY ./contrib/rosetta/configuration ./ -RUN chmod +x run_tests.sh -RUN chmod +x send_funds.sh -RUN chmod +x faucet.py - -COPY --from=build /node/root /root/ -WORKDIR /root/.simapp - -RUN chmod -R 0777 ./ diff --git a/contrib/rosetta/node/data.tar.gz b/contrib/rosetta/node/data.tar.gz deleted file mode 100644 index 291681c89d..0000000000 Binary files a/contrib/rosetta/node/data.tar.gz and /dev/null differ diff --git a/contrib/rosetta/rosetta-cli/Dockerfile b/contrib/rosetta/rosetta-cli/Dockerfile deleted file mode 100644 index 5b84a4ee62..0000000000 --- a/contrib/rosetta/rosetta-cli/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM golang:1.20-alpine as build - -RUN apk add git gcc libc-dev --no-cache - -ARG ROSETTA_VERSION="v0.6.7" - -# build rosetta CLI -WORKDIR /rosetta -RUN git clone https://github.com/coinbase/rosetta-cli . -RUN git checkout tags/$ROSETTA_VERSION -RUN go build -o rosetta-cli ./main.go - -FROM alpine -RUN apk add gcc libc-dev python3 --no-cache - -ENV PATH=$PATH:/bin - -COPY --from=build /rosetta/rosetta-cli /bin/rosetta-cli diff --git a/crypto/armor.go b/crypto/armor.go index e88944bfa6..172ffd63b6 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -87,7 +87,7 @@ func UnarmorInfoBytes(armorStr string) ([]byte, error) { func UnarmorPubKeyBytes(armorStr string) (bz []byte, algo string, err error) { bz, header, err := unarmorBytes(armorStr, blockTypePubKey) if err != nil { - return nil, "", fmt.Errorf("couldn't unarmor bytes: %v", err) + return nil, "", fmt.Errorf("couldn't unarmor bytes: %w", err) } switch header[headerVersion] { diff --git a/crypto/hd/hdpath_test.go b/crypto/hd/hdpath_test.go index 86b0388235..4fcc46220c 100644 --- a/crypto/hd/hdpath_test.go +++ b/crypto/hd/hdpath_test.go @@ -107,9 +107,7 @@ func TestCreateHDPath(t *testing.T) { {"m/44'/114'/1'/1/0", args{114, 1, 1}, hd.BIP44Params{Purpose: 44, CoinType: 114, Account: 1, AddressIndex: 1}}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - tt := tt require.Equal(t, tt.want, *hd.CreateHDPath(tt.args.coinType, tt.args.account, tt.args.index)) }) } @@ -170,7 +168,6 @@ func TestDeriveHDPathRange(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.path, func(t *testing.T) { master, ch := hd.ComputeMastersFromSeed(seed) _, err := hd.DerivePrivateKeyForPath(master, ch, tt.path) @@ -297,7 +294,6 @@ func TestDerivePrivateKeyForPathDoNotCrash(t *testing.T) { } for _, path := range paths { - path := path t.Run(path, func(t *testing.T) { _, _ = hd.DerivePrivateKeyForPath([32]byte{}, [32]byte{}, path) }) diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index fa89682961..0f41dc3da1 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -463,7 +463,7 @@ func (ks keystore) KeyByAddress(address sdk.Address) (Info, error) { } func wrapKeyNotFound(err error, msg string) error { - if err == keyring.ErrKeyNotFound { + if errors.Is(err, keyring.ErrKeyNotFound) { return sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, msg) } return err @@ -691,7 +691,7 @@ func newFileBackendKeyringConfig(name, dir string, buf io.Reader) keyring.Config func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { return func(prompt string) (string, error) { - keyhashStored := false + var keyhashStored bool keyhashFilePath := filepath.Join(dir, "keyhash") var keyhash []byte @@ -702,7 +702,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { case err == nil: keyhash, err = os.ReadFile(keyhashFilePath) if err != nil { - return "", fmt.Errorf("failed to read %s: %v", keyhashFilePath, err) + return "", fmt.Errorf("failed to read %s: %w", keyhashFilePath, err) } keyhashStored = true @@ -711,7 +711,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { keyhashStored = false default: - return "", fmt.Errorf("failed to open %s: %v", keyhashFilePath, err) + return "", fmt.Errorf("failed to open %s: %w", keyhashFilePath, err) } failureCounter := 0 @@ -820,13 +820,13 @@ func (ks keystore) writeInfo(info Info) error { func (ks keystore) existsInDb(info Info) (bool, error) { if _, err := ks.db.Get(addrHexKeyAsString(info.GetAddress())); err == nil { return true, nil // address lookup succeeds - info exists - } else if err != keyring.ErrKeyNotFound { + } else if !errors.Is(err, keyring.ErrKeyNotFound) { return false, err // received unexpected error - returns error } if _, err := ks.db.Get(infoKey(info.GetName())); err == nil { return true, nil // uid lookup succeeds - info exists - } else if err != keyring.ErrKeyNotFound { + } else if !errors.Is(err, keyring.ErrKeyNotFound) { return false, err // received unexpected error - returns } diff --git a/crypto/keyring/signing_algorithms_test.go b/crypto/keyring/signing_algorithms_test.go index 7259e45ce8..e4c549d65a 100644 --- a/crypto/keyring/signing_algorithms_test.go +++ b/crypto/keyring/signing_algorithms_test.go @@ -35,7 +35,6 @@ func TestNewSigningAlgoByString(t *testing.T) { list := SigningAlgoList{hd.Secp256k1} for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { algorithm, err := NewSigningAlgoFromString(tt.algoStr, list) if tt.isSupported { diff --git a/crypto/keys/multisig/codec.go b/crypto/keys/multisig/codec.go index 2153acfb79..7a18b51aed 100644 --- a/crypto/keys/multisig/codec.go +++ b/crypto/keys/multisig/codec.go @@ -15,7 +15,6 @@ const ( PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold" ) -// nolint // Deprecated: Amino is being deprecated in the SDK. But even if you need to // use Amino for some reason, please use `codec/legacy.Cdc` instead. var AminoCdc = codec.NewLegacyAmino() diff --git a/crypto/keys/secp256k1/secp256k1_internal_test.go b/crypto/keys/secp256k1/secp256k1_internal_test.go index 539420d00e..b2360d7552 100644 --- a/crypto/keys/secp256k1/secp256k1_internal_test.go +++ b/crypto/keys/secp256k1/secp256k1_internal_test.go @@ -27,7 +27,6 @@ func Test_genPrivKey(t *testing.T) { {"valid because 0 < 1 < N", validOne, false}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { if tt.shouldPanic { require.Panics(t, func() { diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 86b1b2f5e8..2face47179 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -255,7 +255,6 @@ func TestGenPrivKeyFromSecret(t *testing.T) { {"another seed used in cosmos tests #3", []byte("")}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { gotPrivKey := secp256k1.GenPrivKeyFromSecret(tt.secret) require.NotNil(t, gotPrivKey) diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index f65bc69e40..526e8c8048 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -72,7 +72,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3 // re-serialize in the 33-byte compressed format cmp, err := secp.ParsePubKey(pk) if err != nil { - return nil, "", fmt.Errorf("error parsing public key: %v", err) + return nil, "", fmt.Errorf("error parsing public key: %w", err) } compressedPublicKey := make([]byte, csecp256k1.PubKeySize) diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index f6f65589ec..d90b504333 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -258,13 +258,13 @@ func sign(device SECP256K1, pkl PrivKeyLedgerSecp256k1, msg []byte) ([]byte, err func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (types.PubKey, error) { publicKey, err := device.GetPublicKeySECP256K1(path.DerivationPath()) if err != nil { - return nil, fmt.Errorf("please open Cosmos app on the Ledger device - error: %v", err) + return nil, fmt.Errorf("please open Cosmos app on the Ledger device - error: %w", err) } // re-serialize in the 33-byte compressed format cmp, err := secp.ParsePubKey(publicKey) if err != nil { - return nil, fmt.Errorf("error parsing public key: %v", err) + return nil, fmt.Errorf("error parsing public key: %w", err) } compressedPublicKey := make([]byte, secp256k1.PubKeySize) @@ -288,7 +288,7 @@ func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (types // re-serialize in the 33-byte compressed format cmp, err := secp.ParsePubKey(publicKey) if err != nil { - return nil, "", fmt.Errorf("error parsing public key: %v", err) + return nil, "", fmt.Errorf("error parsing public key: %w", err) } compressedPublicKey := make([]byte, secp256k1.PubKeySize) diff --git a/crypto/types/compact_bit_array_test.go b/crypto/types/compact_bit_array_test.go index e3a84832a9..8a0a8f93bc 100644 --- a/crypto/types/compact_bit_array_test.go +++ b/crypto/types/compact_bit_array_test.go @@ -57,7 +57,6 @@ func TestBitArrayEqual(t *testing.T) { {name: "different should not be equal", b1: big1, b2: big2, eq: false}, } for _, tc := range cases { - tc := tc t.Run(tc.name, func(t *testing.T) { eq := tc.b1.Equal(tc.b2) require.Equal(t, tc.eq, eq) @@ -101,7 +100,6 @@ func TestJSONMarshalUnmarshal(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.bA.String(), func(t *testing.T) { bz, err := json.Marshal(tc.bA) require.NoError(t, err) @@ -161,7 +159,6 @@ func TestCompactMarshalUnmarshal(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.bA.String(), func(t *testing.T) { bz := tc.bA.CompactMarshal() @@ -207,8 +204,6 @@ func TestCompactBitArrayNumOfTrueBitsBefore(t *testing.T) { {`"______________xx"`, []int{14, 15}, []int{0, 1}}, } for tcIndex, tc := range testCases { - tc := tc - tcIndex := tcIndex t.Run(tc.marshalledBA, func(t *testing.T) { var bA *CompactBitArray err := json.Unmarshal([]byte(tc.marshalledBA), &bA) @@ -281,7 +276,6 @@ func TestNewCompactBitArrayCrashWithLimits(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(fmt.Sprintf("%d", tt.in), func(t *testing.T) { got := NewCompactBitArray(tt.in) if g := got != nil; g != tt.mustPass { diff --git a/docs/run-node/rosetta.md b/docs/run-node/rosetta.md deleted file mode 100644 index 617bd86af8..0000000000 --- a/docs/run-node/rosetta.md +++ /dev/null @@ -1,133 +0,0 @@ -# Rosetta - -The `rosetta` package implements Coinbase's [Rosetta API](https://www.rosetta-api.org). This document provides instructions on how to use the Rosetta API integration. For information about the motivation and design choices, refer to [ADR 035](../architecture/adr-035-rosetta-api-support.md). - -## Add Rosetta Command - -The Rosetta API server is a stand-alone server that connects to a node of a chain developed with Cosmos SDK. - -To enable Rosetta API support, it's required to add the `RosettaCommand` to your application's root command file (e.g. `appd/cmd/root.go`). - -Import the `server` package: - -```go - "github.com/Finschia/finschia-sdk/server" -``` - -Find the following line: - -```go -initRootCmd(rootCmd, encodingConfig) -``` - -After that line, add the following: - -```go -rootCmd.AddCommand( - server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler) -) -``` - -The `RosettaCommand` function builds the `rosetta` root command and is defined in the `server` package within Cosmos SDK. - -Since we’ve updated the Cosmos SDK to work with the Rosetta API, updating the application's root command file is all you need to do. - -An implementation example can be found in `simapp` package. - -## Use Rosetta Command - -To run Rosetta in your application CLI, use the following command: - -``` -appd rosetta --help -``` - -To test and run Rosetta API endpoints for applications that are running and exposed, use the following command: - -``` -appd rosetta - --blockchain "your application name (ex: gaia)" - --network "your chain identifier (ex: testnet-1)" - --tendermint "tendermint endpoint (ex: localhost:26657)" - --grpc "gRPC endpoint (ex: localhost:9090)" - --addr "rosetta binding address (ex: :8080)" -``` - -## Extension - -There are two ways in which you can customize and extend the implementation with your custom settings. - -### Message extension - -In order to make an `sdk.Msg` understandable by rosetta the only thing which is required is adding the methods to your message that satisfy the `rosetta.Msg` interface. -Examples on how to do so can be found in the staking types such as `MsgDelegate`, or in bank types such as `MsgSend`. - -### Client interface override - -In case more customization is required, it's possible to embed the Client type and override the methods which require customizations. - -Example: - -```go -package custom_client -import ( - -"context" -"github.com/coinbase/rosetta-sdk-go/types" -"github.com/Finschia/finschia-sdk/server/rosetta/lib" -) - -// CustomClient embeds the standard cosmos client -// which means that it implements the cosmos-rosetta-gateway Client -// interface while at the same time allowing to customize certain methods -type CustomClient struct { - *rosetta.Client -} - -func (c *CustomClient) ConstructionPayload(_ context.Context, request *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error) { - // provide custom signature bytes - panic("implement me") -} -``` - -### Error extension - -Since rosetta requires to provide 'returned' errors to network options. In order to declare a new rosetta error, we use the `errors` package in cosmos-rosetta-gateway. - -Example: - -```go -package custom_errors -import crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - -var customErrRetriable = true -var CustomError = crgerrs.RegisterError(100, "custom message", customErrRetriable, "description") -``` - -Note: errors must be registered before cosmos-rosetta-gateway's `Server`.`Start` method is called. Otherwise the registration will be ignored. Errors with same code will be ignored too. - -## Integration in app.go - -To integrate rosetta as a command in your application, in app.go, in your root command simply use the `server.RosettaCommand` method. - -Example: - -```go -package app -import ( - -"github.com/Finschia/finschia-sdk/server" -"github.com/spf13/cobra" -) - -func buildAppCommand(rootCmd *cobra.Command) { - // more app.go init stuff - // ... - // add rosetta command - rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler)) -} -``` - -A full implementation example can be found in `simapp` package. - -NOTE: when using a customized client, the command cannot be used as the constructors required **may** differ, so it's required to create a new one. We intend to provide a way to init a customized client without writing extra code in the future. diff --git a/go.mod b/go.mod index 5702d749c0..c22dac378b 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,17 @@ -go 1.20 +go 1.22 module github.com/Finschia/finschia-sdk require ( github.com/99designs/keyring v1.1.6 github.com/VictoriaMetrics/fastcache v1.12.2 - github.com/armon/go-metrics v0.4.1 github.com/bgentry/speakeasy v0.1.0 - github.com/coinbase/rosetta-sdk-go v0.8.5 - github.com/coinbase/rosetta-sdk-go/types v1.0.0 github.com/confio/ics23/go v0.9.0 github.com/cosmos/btcutil v1.0.5 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.19.4 github.com/cosmos/ledger-cosmos-go v0.13.3 - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/go-kit/kit v0.13.0 github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.3 @@ -24,32 +21,33 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/hashicorp/go-metrics v0.5.3 github.com/hashicorp/golang-lru v1.0.2 - github.com/hdevalence/ed25519consensus v0.1.0 - github.com/improbable-eng/grpc-web v0.15.0 + github.com/hdevalence/ed25519consensus v0.2.0 github.com/jhump/protoreflect v1.15.3 github.com/magiconair/properties v1.8.7 github.com/mailru/easyjson v0.7.7 github.com/mattn/go-isatty v0.0.20 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.19.0 - github.com/prometheus/common v0.53.0 + github.com/prometheus/client_golang v1.19.1 + github.com/prometheus/common v0.54.0 github.com/regen-network/cosmos-proto v0.3.1 - github.com/rs/zerolog v1.32.0 - github.com/spf13/cast v1.5.1 - github.com/spf13/cobra v1.8.0 + github.com/rs/zerolog v1.33.0 + github.com/spf13/cast v1.6.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.17.0 + github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.24 github.com/tendermint/tm-db v0.6.7 - golang.org/x/crypto v0.21.0 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de - google.golang.org/grpc v1.63.2 - google.golang.org/protobuf v1.34.1 + golang.org/x/crypto v0.24.0 + golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 + golang.org/x/sync v0.7.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 ) @@ -59,21 +57,19 @@ require ( github.com/Workiva/go-datastructures v1.1.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd v0.22.1 // indirect - github.com/cenkalti/backoff/v4 v4.1.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/creachadair/taskgroup v0.6.1 // indirect github.com/danieljoos/wincred v1.0.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect - github.com/felixge/httpsnoop v1.0.3 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect @@ -85,12 +81,13 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect - github.com/klauspost/compress v1.17.0 // indirect + github.com/klauspost/compress v1.17.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -98,33 +95,32 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/cors v1.10.1 // indirect - github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.10.0 // indirect + github.com/spf13/afero v1.11.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - nhooyr.io/websocket v1.8.6 // indirect ) replace ( diff --git a/go.sum b/go.sum index fd158df02c..564bcfcac0 100644 --- a/go.sum +++ b/go.sum @@ -1,56 +1,19 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= @@ -58,27 +21,15 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/ github.com/Workiva/go-datastructures v1.1.1 h1:9G5u1UqKt6ABseAffHGNfbNQd7omRlWE5QaxNruzhE0= github.com/Workiva/go-datastructures v1.1.1/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -89,44 +40,31 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= +github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= -github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= -github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go v0.8.5 h1:spP8996SFsRnfU8k12dxOHqDyeLXnFOpqshkclo4tMc= -github.com/coinbase/rosetta-sdk-go v0.8.5/go.mod h1:hFaqXH62zEgjZ/NFj58Sip1+JCEckTLM+xgmAUkbSIQ= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -141,11 +79,9 @@ github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIo github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creachadair/taskgroup v0.6.1 h1:KQfRG4VhSj2qoXPkzXrsTaT8oZsMCZD0+KRll2jbF78= github.com/creachadair/taskgroup v0.6.1/go.mod h1:2vCkZ5a+HVcvDl3llMpox2lTw0+MSzrkGsddxRAHXOo= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -153,62 +89,48 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= -github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= -github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -219,39 +141,14 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -259,7 +156,6 @@ github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -268,71 +164,37 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= @@ -342,231 +204,138 @@ github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= +github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= -github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= +github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= -github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jhump/protoreflect v1.10.3 h1:8ogeubpKh2TiulA0apmGlW5YAH4U1Vi4TINIP+gpNfQ= github.com/jhump/protoreflect v1.10.3/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= -github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= +github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= @@ -577,70 +346,55 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= -github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= -github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= -github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -661,19 +415,10 @@ github.com/tendermint/tendermint v0.34.24/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fG github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -682,408 +427,158 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= -go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM= +golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 h1:+rdxYoE3E5htTEWIe15GlN6IfvbURM//Jt0mmkmm6ZU= +google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117/go.mod h1:OimBR/bc1wPO9iV4NC2bpyjy3VnAwZh5EBPQdtaE5oo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1092,26 +587,22 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1126,18 +617,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= -nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/ics23/go/go.mod b/ics23/go/go.mod index d6356aa40e..6ccca0a54f 100644 --- a/ics23/go/go.mod +++ b/ics23/go/go.mod @@ -1,6 +1,6 @@ module github.com/confio/ics23/go -go 1.14 +go 1.22 require ( github.com/gogo/protobuf v1.3.2 diff --git a/init_node.sh b/init_node.sh index a193cc9e55..11ba34c3ac 100755 --- a/init_node.sh +++ b/init_node.sh @@ -94,7 +94,6 @@ RPC_PORT=26657 P2P_PORT=26656 PROF_PORT=6060 GRPC_PORT=9090 -GRPC_WEB_PORT=9091 # Set genesis file and config(port, peer, ...) CHAIN_0_DIR="${CHAIN_DIR_PREFIX}0" @@ -127,7 +126,6 @@ for ((i = 0; i < N; i++)) sed -i 's#'"${MEMO}"'#'"${MEMO_SPLIT[1]}"':'"${P2P_PORT}"'#g' ${CHAIN_0_DIR}/config/config.toml # change port of persistent_peers sed -i 's/pruning = "default"/pruning = "nothing"/g' ${CHAIN_DIR}/config/app.toml - sed -i 's#"0.0.0.0:9091"#"0.0.0.0:'"${GRPC_WEB_PORT}"'"#g' ${CHAIN_DIR}/config/app.toml sed -i 's#"0.0.0.0:9090"#"0.0.0.0:'"${GRPC_PORT}"'"#g' ${CHAIN_DIR}/config/app.toml else sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"${RPC_PORT}"'"#g' ${CHAIN_DIR}/config/config.toml @@ -141,15 +139,13 @@ for ((i = 0; i < N; i++)) sed -i '' 's#'"${MEMO}"'#'"${MEMO_SPLIT[1]}"':'"${P2P_PORT}"'#g' ${CHAIN_0_DIR}/config/config.toml # change port of persistent_peers sed -i '' 's/pruning = "default"/pruning = "nothing"/g' ${CHAIN_DIR}/config/app.toml - sed -i '' 's#"0.0.0.0:9091"#"0.0.0.0:'"${GRPC_WEB_PORT}"'"#g' ${CHAIN_DIR}/config/app.toml sed -i '' 's#"0.0.0.0:9090"#"0.0.0.0:'"${GRPC_PORT}"'"#g' ${CHAIN_DIR}/config/app.toml fi - echo "${BINARY} instance: home ${CHAIN_DIR} | chain-id ${CHAIN_ID} | p2p=:${P2P_PORT} | rpc=:${RPC_PORT} | profiling=:${PROF_PORT} | grpc=:${GRPC_PORT} | grpc-web=:${GRPC_WEB_PORT}" + echo "${BINARY} instance: home ${CHAIN_DIR} | chain-id ${CHAIN_ID} | p2p=:${P2P_PORT} | rpc=:${RPC_PORT} | profiling=:${PROF_PORT} | grpc=:${GRPC_PORT}" RPC_PORT=`expr ${RPC_PORT} + 2` P2P_PORT=`expr ${P2P_PORT} + 2` PROF_PORT=`expr ${PROF_PORT} + 1` GRPC_PORT=`expr ${GRPC_PORT} + 2` - GRPC_WEB_PORT=`expr ${GRPC_WEB_PORT} + 2` done diff --git a/internal/conv/string.go b/internal/conv/string.go index ab2b7f44b3..96d89c3a5f 100644 --- a/internal/conv/string.go +++ b/internal/conv/string.go @@ -1,20 +1,13 @@ package conv import ( - "reflect" "unsafe" ) // UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes // must not be altered after this function is called as it will cause a segmentation fault. func UnsafeStrToBytes(s string) []byte { - var buf []byte - sHdr := (*reflect.StringHeader)(unsafe.Pointer(&s)) - bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) - bufHdr.Data = sHdr.Data - bufHdr.Cap = sHdr.Len - bufHdr.Len = sHdr.Len - return buf + return unsafe.Slice(unsafe.StringData(s), len(s)) // ref https://github.com/golang/go/issues/53003#issuecomment-1140276077 } // UnsafeBytesToStr is meant to make a zero allocation conversion diff --git a/server/api/server.go b/server/api/server.go index e5febbfd7c..bc2fad65e3 100644 --- a/server/api/server.go +++ b/server/api/server.go @@ -1,6 +1,7 @@ package api import ( + "context" "fmt" "net" "net/http" @@ -27,9 +28,9 @@ type Server struct { Router *mux.Router GRPCGatewayRouter *runtime.ServeMux ClientCtx client.Context + logger log.Logger + metrics *telemetry.Metrics - logger log.Logger - metrics *telemetry.Metrics // Start() is blocking and generally called from a separate goroutine. // Close() can be called asynchronously and access shared memory // via the listener. Therefore, we sync access to Start and Close with @@ -85,7 +86,12 @@ func New(clientCtx client.Context, logger log.Logger) *Server { // JSON RPC server. Configuration options are provided via config.APIConfig // and are delegated to the Tendermint JSON RPC server. The process is // non-blocking, so an external signal handler must be used. -func (s *Server) Start(cfg config.Config) error { +// and are delegated to the CometBFT JSON RPC server. +// +// Note, this creates a blocking process if the server is started successfully. +// Otherwise, an error is returned. The caller is expected to provide a Context +// that is properly canceled or closed to indicate the server should be stopped. +func (s *Server) Start(ctx context.Context, cfg config.Config) error { s.mtx.Lock() tmCfg := tmrpcserver.DefaultConfig() @@ -100,19 +106,42 @@ func (s *Server) Start(cfg config.Config) error { return err } - s.registerGRPCGatewayRoutes() s.listener = listener - var h http.Handler = s.Router s.mtx.Unlock() - if cfg.API.EnableUnsafeCORS { - allowAllCORS := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"})) - return tmrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, tmCfg) - } + // register grpc-gateway routes + s.Router.PathPrefix("/").Handler(s.GRPCGatewayRouter) + + errCh := make(chan error) - s.logger.Info("starting API server...") - return tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg) + // Start the API in an external goroutine as Serve is blocking and will return + // an error upon failure, which we'll send on the error channel that will be + // consumed by the for block below. + go func(enableUnsafeCORS bool) { + s.logger.Info("starting API server...", "address", cfg.API.Address) + + if enableUnsafeCORS { + allowAllCORS := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"})) + errCh <- tmrpcserver.Serve(s.listener, allowAllCORS(s.Router), s.logger, tmCfg) + } else { + errCh <- tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg) + } + }(cfg.API.EnableUnsafeCORS) + + // Start a blocking select to wait for an indication to stop the server or that + // the server failed to start properly. + select { + case <-ctx.Done(): + // The calling process canceled or closed the provided context, so we must + // gracefully stop the API server. + s.logger.Info("stopping API server...", "address", cfg.API.Address) + return s.Close() + + case err := <-errCh: + s.logger.Error("failed to start API server", "err", err) + return err + } } // Close closes the API server. @@ -122,10 +151,6 @@ func (s *Server) Close() error { return s.listener.Close() } -func (s *Server) registerGRPCGatewayRoutes() { - s.Router.PathPrefix("/").Handler(s.GRPCGatewayRouter) -} - func (s *Server) SetTelemetry(m *telemetry.Metrics) { s.mtx.Lock() s.metrics = m diff --git a/server/config/config.go b/server/config/config.go index 9422e8e4ab..e7491ab38d 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -20,9 +20,6 @@ const ( // DefaultGRPCAddress defines the default address to bind the gRPC server to. DefaultGRPCAddress = "0.0.0.0:9090" - // DefaultGRPCWebAddress defines the default address to bind the gRPC-web server to. - DefaultGRPCWebAddress = "0.0.0.0:9091" - // DefaultGRPCMaxRecvMsgSize defines the default gRPC max message size in // bytes the server can receive. DefaultGRPCMaxRecvMsgSize = 1024 * 1024 * 10 @@ -125,29 +122,6 @@ type APIConfig struct { // Ref: https://github.com/cosmos/cosmos-sdk/issues/6420 } -// RosettaConfig defines the Rosetta API listener configuration. -type RosettaConfig struct { - // Address defines the API server to listen on - Address string `mapstructure:"address"` - - // Blockchain defines the blockchain name - // defaults to DefaultBlockchain - Blockchain string `mapstructure:"blockchain"` - - // Network defines the network name - Network string `mapstructure:"network"` - - // Retries defines the maximum number of retries - // rosetta will do before quitting - Retries int `mapstructure:"retries"` - - // Enable defines if the API server should be enabled. - Enable bool `mapstructure:"enable"` - - // Offline defines if the server must be run in offline mode - Offline bool `mapstructure:"offline"` -} - // GRPCConfig defines configuration for the gRPC server. type GRPCConfig struct { // Enable defines if the gRPC server should be enabled. @@ -165,18 +139,6 @@ type GRPCConfig struct { MaxSendMsgSize int `mapstructure:"max-send-msg-size"` } -// GRPCWebConfig defines configuration for the gRPC-web server. -type GRPCWebConfig struct { - // Enable defines if the gRPC-web should be enabled. - Enable bool `mapstructure:"enable"` - - // Address defines the gRPC-web server to listen on - Address string `mapstructure:"address"` - - // EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk) - EnableUnsafeCORS bool `mapstructure:"enable-unsafe-cors"` -} - // StateSyncConfig defines the state sync snapshot configuration. type StateSyncConfig struct { // SnapshotInterval sets the interval at which state sync snapshots are taken. @@ -196,8 +158,6 @@ type Config struct { Telemetry telemetry.Config `mapstructure:"telemetry"` API APIConfig `mapstructure:"api"` GRPC GRPCConfig `mapstructure:"grpc"` - Rosetta RosettaConfig `mapstructure:"rosetta"` - GRPCWeb GRPCWebConfig `mapstructure:"grpc-web"` StateSync StateSyncConfig `mapstructure:"state-sync"` } @@ -255,18 +215,6 @@ func DefaultConfig() *Config { MaxRecvMsgSize: DefaultGRPCMaxRecvMsgSize, MaxSendMsgSize: DefaultGRPCMaxSendMsgSize, }, - Rosetta: RosettaConfig{ - Enable: false, - Address: ":8080", - Blockchain: "app", - Network: "network", - Retries: 3, - Offline: false, - }, - GRPCWeb: GRPCWebConfig{ - Enable: true, - Address: DefaultGRPCWebAddress, - }, StateSync: StateSyncConfig{ SnapshotInterval: 0, SnapshotKeepRecent: 2, @@ -326,25 +274,12 @@ func GetConfig(v *viper.Viper) (Config, error) { RPCMaxBodyBytes: v.GetUint("api.rpc-max-body-bytes"), EnableUnsafeCORS: v.GetBool("api.enabled-unsafe-cors"), }, - Rosetta: RosettaConfig{ - Enable: v.GetBool("rosetta.enable"), - Address: v.GetString("rosetta.address"), - Blockchain: v.GetString("rosetta.blockchain"), - Network: v.GetString("rosetta.network"), - Retries: v.GetInt("rosetta.retries"), - Offline: v.GetBool("rosetta.offline"), - }, GRPC: GRPCConfig{ Enable: v.GetBool("grpc.enable"), Address: v.GetString("grpc.address"), MaxRecvMsgSize: v.GetInt("grpc.max-recv-msg-size"), MaxSendMsgSize: v.GetInt("grpc.max-send-msg-size"), }, - GRPCWeb: GRPCWebConfig{ - Enable: v.GetBool("grpc-web.enable"), - Address: v.GetString("grpc-web.address"), - EnableUnsafeCORS: v.GetBool("grpc-web.enable-unsafe-cors"), - }, StateSync: StateSyncConfig{ SnapshotInterval: v.GetUint64("state-sync.snapshot-interval"), SnapshotKeepRecent: v.GetUint32("state-sync.snapshot-keep-recent"), diff --git a/server/config/toml.go b/server/config/toml.go index 960caee664..4bc8b51d56 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -151,30 +151,6 @@ rpc-max-body-bytes = {{ .API.RPCMaxBodyBytes }} # EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). enabled-unsafe-cors = {{ .API.EnableUnsafeCORS }} -############################################################################### -### Rosetta Configuration ### -############################################################################### - -[rosetta] - -# Enable defines if the Rosetta API server should be enabled. -enable = {{ .Rosetta.Enable }} - -# Address defines the Rosetta API server to listen on. -address = "{{ .Rosetta.Address }}" - -# Network defines the name of the blockchain that will be returned by Rosetta. -blockchain = "{{ .Rosetta.Blockchain }}" - -# Network defines the name of the network that will be returned by Rosetta. -network = "{{ .Rosetta.Network }}" - -# Retries defines the number of retries when connecting to the node before failing. -retries = {{ .Rosetta.Retries }} - -# Offline defines if Rosetta server should run in offline mode. -offline = {{ .Rosetta.Offline }} - ############################################################################### ### gRPC Configuration ### ############################################################################### @@ -195,22 +171,6 @@ max-recv-msg-size = "{{ .GRPC.MaxRecvMsgSize }}" # The default value is math.MaxInt32. max-send-msg-size = "{{ .GRPC.MaxSendMsgSize }}" -############################################################################### -### gRPC Web Configuration ### -############################################################################### - -[grpc-web] - -# GRPCWebEnable defines if the gRPC-web should be enabled. -# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. -enable = {{ .GRPCWeb.Enable }} - -# Address defines the gRPC-web server address to bind to. -address = "{{ .GRPCWeb.Address }}" - -# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). -enable-unsafe-cors = {{ .GRPCWeb.EnableUnsafeCORS }} - ############################################################################### ### State Sync Configuration ### ############################################################################### diff --git a/server/export.go b/server/export.go index 8824be663e..c02e42adb6 100644 --- a/server/export.go +++ b/server/export.go @@ -69,7 +69,7 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com exported, err := appExporter(serverCtx.Logger, db, traceWriter, height, forZeroHeight, jailAllowedAddrs, serverCtx.Viper) if err != nil { - return fmt.Errorf("error exporting state: %v", err) + return fmt.Errorf("error exporting state: %w", err) } doc, err := tmtypes.GenesisDocFromFile(serverCtx.Config.GenesisFile()) diff --git a/server/grpc/gogoreflection/serverreflection.go b/server/grpc/gogoreflection/serverreflection.go index 3ce667d9fe..1937870ca0 100644 --- a/server/grpc/gogoreflection/serverreflection.go +++ b/server/grpc/gogoreflection/serverreflection.go @@ -39,6 +39,7 @@ package gogoreflection // import "google.golang.org/grpc/reflection" import ( "bytes" "compress/gzip" + "errors" "fmt" "io" "log" @@ -201,12 +202,12 @@ func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDesc func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { raw, err := decompress(enc) if err != nil { - return nil, fmt.Errorf("failed to decompress enc: %v", err) + return nil, fmt.Errorf("failed to decompress enc: %w", err) } fd := new(dpb.FileDescriptorProto) if err := proto.Unmarshal(raw, fd); err != nil { - return nil, fmt.Errorf("bad descriptor: %v", err) + return nil, fmt.Errorf("bad descriptor: %w", err) } return fd, nil } @@ -215,11 +216,11 @@ func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { func decompress(b []byte) ([]byte, error) { r, err := gzip.NewReader(bytes.NewReader(b)) if err != nil { - return nil, fmt.Errorf("bad gzipped descriptor: %v", err) + return nil, fmt.Errorf("bad gzipped descriptor: %w", err) } out, err := io.ReadAll(r) if err != nil { - return nil, fmt.Errorf("bad gzipped descriptor: %v", err) + return nil, fmt.Errorf("bad gzipped descriptor: %w", err) } return out, nil } @@ -379,7 +380,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 { diff --git a/server/grpc/grpc_web.go b/server/grpc/grpc_web.go deleted file mode 100644 index d03c20e3e9..0000000000 --- a/server/grpc/grpc_web.go +++ /dev/null @@ -1,46 +0,0 @@ -package grpc - -import ( - "fmt" - "net/http" - "time" - - "github.com/improbable-eng/grpc-web/go/grpcweb" - "google.golang.org/grpc" - - "github.com/Finschia/finschia-sdk/server/config" - "github.com/Finschia/finschia-sdk/server/types" -) - -// StartGRPCWeb starts a gRPC-Web server on the given address. -func StartGRPCWeb(grpcSrv *grpc.Server, config config.Config) (*http.Server, error) { - var options []grpcweb.Option - if config.GRPCWeb.EnableUnsafeCORS { - options = append(options, - grpcweb.WithOriginFunc(func(origin string) bool { - return true - }), - ) - } - - wrappedServer := grpcweb.WrapServer(grpcSrv, options...) - grpcWebSrv := &http.Server{ - Addr: config.GRPCWeb.Address, - Handler: wrappedServer, - ReadHeaderTimeout: 500 * time.Millisecond, - } - - errCh := make(chan error) - go func() { - if err := grpcWebSrv.ListenAndServe(); err != nil { - errCh <- fmt.Errorf("[grpc] failed to serve: %w", err) - } - }() - - select { - case err := <-errCh: - return nil, err - case <-time.After(types.ServerStartTime): // assume server started successfully - return grpcWebSrv, nil - } -} diff --git a/server/grpc/grpc_web_test.go b/server/grpc/grpc_web_test.go deleted file mode 100644 index 1c88422ccf..0000000000 --- a/server/grpc/grpc_web_test.go +++ /dev/null @@ -1,315 +0,0 @@ -//go:build norace -// +build norace - -package grpc_test - -import ( - "bufio" - "bytes" - "encoding/base64" - "encoding/binary" - "fmt" - "io" - "net/http" - "net/textproto" - "strconv" - "strings" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - "google.golang.org/grpc/codes" - - "github.com/Finschia/finschia-sdk/client/grpc/tmservice" - "github.com/Finschia/finschia-sdk/codec" - cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" - "github.com/Finschia/finschia-sdk/testutil/network" - banktypes "github.com/Finschia/finschia-sdk/x/bank/types" -) - -// https://github.com/improbable-eng/grpc-web/blob/master/go/grpcweb/wrapper_test.go used as a reference -// to setup grpcRequest config. - -const grpcWebContentType = "application/grpc-web" - -type GRPCWebTestSuite struct { - suite.Suite - - cfg network.Config - network *network.Network - protoCdc *codec.ProtoCodec -} - -func (s *GRPCWebTestSuite) SetupSuite() { - s.T().Log("setting up integration test suite") - - cfg := network.DefaultConfig() - cfg.NumValidators = 1 - s.cfg = cfg - s.network = network.New(s.T(), s.cfg) - s.Require().NotNil(s.network) - - _, err := s.network.WaitForHeight(2) - s.Require().NoError(err) - - s.protoCdc = codec.NewProtoCodec(s.cfg.InterfaceRegistry) -} - -func (s *GRPCWebTestSuite) TearDownSuite() { - s.T().Log("tearing down integration test suite") - s.network.Cleanup() -} - -func (s *GRPCWebTestSuite) Test_Latest_Validators() { - val := s.network.Validators[0] - for _, contentType := range []string{grpcWebContentType} { - headers, trailers, responses, err := s.makeGrpcRequest( - "/cosmos.base.tendermint.v1beta1.Service/GetLatestValidatorSet", - headerWithFlag(), - serializeProtoMessages([]proto.Message{&tmservice.GetLatestValidatorSetRequest{}}), false) - - s.Require().NoError(err) - s.Require().Equal(1, len(responses)) - s.assertTrailerGrpcCode(trailers, codes.OK, "") - s.assertContentTypeSet(headers, contentType) - var valsSet tmservice.GetLatestValidatorSetResponse - err = s.protoCdc.Unmarshal(responses[0], &valsSet) - s.Require().NoError(err) - pubKey, ok := valsSet.Validators[0].PubKey.GetCachedValue().(cryptotypes.PubKey) - s.Require().Equal(true, ok) - s.Require().Equal(pubKey, val.PubKey) - } -} - -func (s *GRPCWebTestSuite) Test_Total_Supply() { - for _, contentType := range []string{grpcWebContentType} { - headers, trailers, responses, err := s.makeGrpcRequest( - "/cosmos.bank.v1beta1.Query/TotalSupply", - headerWithFlag(), - serializeProtoMessages([]proto.Message{&banktypes.QueryTotalSupplyRequest{}}), false) - - s.Require().NoError(err) - s.Require().Equal(1, len(responses)) - s.assertTrailerGrpcCode(trailers, codes.OK, "") - s.assertContentTypeSet(headers, contentType) - var totalSupply banktypes.QueryTotalSupplyResponse - _ = s.protoCdc.Unmarshal(responses[0], &totalSupply) - } -} - -func (s *GRPCWebTestSuite) assertContentTypeSet(headers http.Header, contentType string) { - s.Require().Equal(contentType, headers.Get("content-type"), `Expected there to be content-type=%v`, contentType) -} - -func (s *GRPCWebTestSuite) assertTrailerGrpcCode(trailers Trailer, code codes.Code, desc string) { - s.Require().NotEmpty(trailers.Get("grpc-status"), "grpc-status must not be empty in trailers") - statusCode, err := strconv.Atoi(trailers.Get("grpc-status")) - s.Require().NoError(err, "no error parsing grpc-status") - s.Require().EqualValues(code, statusCode, "grpc-status must match expected code") - s.Require().EqualValues(desc, trailers.Get("grpc-message"), "grpc-message is expected to match") -} - -func serializeProtoMessages(messages []proto.Message) [][]byte { - out := [][]byte{} - for _, m := range messages { - b, _ := proto.Marshal(m) - out = append(out, b) - } - return out -} - -func (s *GRPCWebTestSuite) makeRequest( - verb string, method string, headers http.Header, body io.Reader, isText bool, -) (*http.Response, error) { - val := s.network.Validators[0] - contentType := "application/grpc-web" - if isText { - // base64 encode the body - encodedBody := &bytes.Buffer{} - encoder := base64.NewEncoder(base64.StdEncoding, encodedBody) - _, err := io.Copy(encoder, body) - if err != nil { - return nil, err - } - err = encoder.Close() - if err != nil { - return nil, err - } - body = encodedBody - contentType = "application/grpc-web-text" - } - - url := fmt.Sprintf("http://%s%s", val.AppConfig.GRPCWeb.Address, method) - req, err := http.NewRequest(verb, url, body) - s.Require().NoError(err, "failed creating a request") - req.Header = headers - - req.Header.Set("Content-Type", contentType) - client := &http.Client{} - resp, err := client.Do(req) - return resp, err -} - -func decodeMultipleBase64Chunks(b []byte) ([]byte, error) { - // grpc-web allows multiple base64 chunks: the implementation may send base64-encoded - // "chunks" with potential padding whenever the runtime needs to flush a byte buffer. - // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md - output := make([]byte, base64.StdEncoding.DecodedLen(len(b))) - outputEnd := 0 - - for inputEnd := 0; inputEnd < len(b); { - chunk := b[inputEnd:] - paddingIndex := bytes.IndexByte(chunk, '=') - if paddingIndex != -1 { - // find the consecutive = - for { - paddingIndex += 1 - if paddingIndex >= len(chunk) || chunk[paddingIndex] != '=' { - break - } - } - chunk = chunk[:paddingIndex] - } - inputEnd += len(chunk) - - n, err := base64.StdEncoding.Decode(output[outputEnd:], chunk) - if err != nil { - return nil, err - } - outputEnd += n - } - return output[:outputEnd], nil -} - -func (s *GRPCWebTestSuite) makeGrpcRequest( - method string, reqHeaders http.Header, requestMessages [][]byte, isText bool, -) (headers http.Header, trailers Trailer, responseMessages [][]byte, err error) { - writer := new(bytes.Buffer) - for _, msgBytes := range requestMessages { - grpcPreamble := []byte{0, 0, 0, 0, 0} - binary.BigEndian.PutUint32(grpcPreamble[1:], uint32(len(msgBytes))) - writer.Write(grpcPreamble) - writer.Write(msgBytes) - } - resp, err := s.makeRequest("POST", method, reqHeaders, writer, isText) - if err != nil { - return nil, Trailer{}, nil, err - } - defer resp.Body.Close() - contents, err := io.ReadAll(resp.Body) - if err != nil { - return nil, Trailer{}, nil, err - } - - if isText { - contents, err = decodeMultipleBase64Chunks(contents) - if err != nil { - return nil, Trailer{}, nil, err - } - } - - reader := bytes.NewReader(contents) - for { - grpcPreamble := []byte{0, 0, 0, 0, 0} - readCount, err := reader.Read(grpcPreamble) - if err == io.EOF { - break - } - if readCount != 5 || err != nil { - return nil, Trailer{}, nil, fmt.Errorf("Unexpected end of body in preamble: %v", err) - } - payloadLength := binary.BigEndian.Uint32(grpcPreamble[1:]) - payloadBytes := make([]byte, payloadLength) - - readCount, err = reader.Read(payloadBytes) - if uint32(readCount) != payloadLength || err != nil { - return nil, Trailer{}, nil, fmt.Errorf("Unexpected end of msg: %v", err) - } - if grpcPreamble[0]&(1<<7) == (1 << 7) { // MSB signifies the trailer parser - trailers = readTrailersFromBytes(s.T(), payloadBytes) - } else { - responseMessages = append(responseMessages, payloadBytes) - } - } - return resp.Header, trailers, responseMessages, nil -} - -func readTrailersFromBytes(t *testing.T, dataBytes []byte) Trailer { - bufferReader := bytes.NewBuffer(dataBytes) - tp := textproto.NewReader(bufio.NewReader(bufferReader)) - - // First, read bytes as MIME headers. - // However, it normalizes header names by textproto.CanonicalMIMEHeaderKey. - // In the next step, replace header names by raw one. - mimeHeader, err := tp.ReadMIMEHeader() - if err == nil { - return Trailer{} - } - - trailers := make(http.Header) - bufferReader = bytes.NewBuffer(dataBytes) - tp = textproto.NewReader(bufio.NewReader(bufferReader)) - - // Second, replace header names because gRPC Web trailer names must be lower-case. - for { - line, err := tp.ReadLine() - if err == io.EOF { - break - } - require.NoError(t, err, "failed to read header line") - - i := strings.IndexByte(line, ':') - if i == -1 { - require.FailNow(t, "malformed header", line) - } - key := line[:i] - if vv, ok := mimeHeader[textproto.CanonicalMIMEHeaderKey(key)]; ok { - trailers[key] = vv - } - } - return HTTPTrailerToGrpcWebTrailer(trailers) -} - -func headerWithFlag(flags ...string) http.Header { - h := http.Header{} - for _, f := range flags { - h.Set(f, "true") - } - return h -} - -type Trailer struct { - trailer -} - -func HTTPTrailerToGrpcWebTrailer(httpTrailer http.Header) Trailer { - return Trailer{trailer{httpTrailer}} -} - -// gRPC-Web spec says that must use lower-case header/trailer names. -// See "HTTP wire protocols" section in -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2 -type trailer struct { - http.Header -} - -func (t trailer) Add(key, value string) { - key = strings.ToLower(key) - t.Header[key] = append(t.Header[key], value) -} - -func (t trailer) Get(key string) string { - if t.Header == nil { - return "" - } - v := t.Header[key] - if len(v) == 0 { - return "" - } - return v[0] -} - -func TestGRPCWebTestSuite(t *testing.T) { - suite.Run(t, new(GRPCWebTestSuite)) -} diff --git a/server/grpc/server.go b/server/grpc/server.go index 0e2877b53a..f57dd196f8 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -1,10 +1,11 @@ package grpc import ( + "context" "fmt" "net" - "time" + "github.com/tendermint/tendermint/libs/log" "google.golang.org/grpc" "github.com/Finschia/finschia-sdk/client" @@ -16,8 +17,9 @@ import ( sdk "github.com/Finschia/finschia-sdk/types" ) -// StartGRPCServer starts a gRPC server on the given address. -func StartGRPCServer(clientCtx client.Context, app types.Application, cfg config.GRPCConfig) (*grpc.Server, error) { +// NewGRPCServer returns a correctly configured and initialized gRPC server. +// Note, the caller is responsible for starting the server. See StartGRPCServer. +func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.GRPCConfig) (*grpc.Server, error) { maxSendMsgSize := cfg.MaxSendMsgSize if maxSendMsgSize == 0 { maxSendMsgSize = config.DefaultGRPCMaxSendMsgSize @@ -29,10 +31,11 @@ func StartGRPCServer(clientCtx client.Context, app types.Application, cfg config } grpcSrv := grpc.NewServer( + grpc.ForceServerCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), grpc.MaxSendMsgSize(maxSendMsgSize), grpc.MaxRecvMsgSize(maxRecvMsgSize), - grpc.ForceServerCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), ) + app.RegisterGRPCServer(grpcSrv) // Reflection allows consumers to build dynamic clients that can write to any @@ -51,30 +54,50 @@ func StartGRPCServer(clientCtx client.Context, app types.Application, cfg config InterfaceRegistry: clientCtx.InterfaceRegistry, }) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to register reflection service: %w", err) } + // Reflection allows external clients to see what services and methods // the gRPC server exposes. gogoreflection.Register(grpcSrv) + return grpcSrv, nil +} + +// StartGRPCServer starts the provided gRPC server on the address specified in cfg. +// +// Note, this creates a blocking process if the server is started successfully. +// Otherwise, an error is returned. The caller is expected to provide a Context +// that is properly canceled or closed to indicate the server should be stopped. +func StartGRPCServer(ctx context.Context, logger log.Logger, cfg config.GRPCConfig, grpcSrv *grpc.Server) error { listener, err := net.Listen("tcp", cfg.Address) if err != nil { - return nil, err + return fmt.Errorf("failed to listen on address %s: %w", cfg.Address, err) } errCh := make(chan error) + + // Start the gRPC in an external goroutine as Serve is blocking and will return + // an error upon failure, which we'll send on the error channel that will be + // consumed by the for block below. go func() { - err = grpcSrv.Serve(listener) - if err != nil { - errCh <- fmt.Errorf("failed to serve: %w", err) - } + logger.Info("starting gRPC server...", "address", cfg.Address) + errCh <- grpcSrv.Serve(listener) }() + // Start a blocking select to wait for an indication to stop the server or that + // the server failed to start properly. select { + case <-ctx.Done(): + // The calling process canceled or closed the provided context, so we must + // gracefully stop the gRPC server. + logger.Info("stopping gRPC server...", "address", cfg.Address) + grpcSrv.GracefulStop() + + return nil + case err := <-errCh: - return nil, err - case <-time.After(types.ServerStartTime): - // assume server started successfully - return grpcSrv, nil + logger.Error("failed to start gRPC server", "err", err) + return err } } diff --git a/server/pruning_test.go b/server/pruning_test.go index 9c462379ad..adf098face 100644 --- a/server/pruning_test.go +++ b/server/pruning_test.go @@ -54,8 +54,6 @@ func TestGetPruningOptionsFromFlags(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(j *testing.T) { viper.Reset() viper.SetDefault(FlagPruning, types.PruningOptionDefault) diff --git a/server/rosetta.go b/server/rosetta.go deleted file mode 100644 index ad44637156..0000000000 --- a/server/rosetta.go +++ /dev/null @@ -1,43 +0,0 @@ -package server - -import ( - "fmt" - - "github.com/spf13/cobra" - - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" - "github.com/Finschia/finschia-sdk/server/rosetta" -) - -// RosettaCommand builds the rosetta root command given -// a protocol buffers serializer/deserializer -func RosettaCommand(ir codectypes.InterfaceRegistry, cdc codec.Codec) *cobra.Command { - cmd := &cobra.Command{ - Use: "rosetta", - Short: "spin up a rosetta server", - RunE: func(cmd *cobra.Command, args []string) error { - cmd.Println("WARNING: The Rosetta server is still a beta feature. Please do not use it in production.") - - conf, err := rosetta.FromFlags(cmd.Flags()) - if err != nil { - return err - } - - protoCodec, ok := cdc.(*codec.ProtoCodec) - if !ok { - return fmt.Errorf("exoected *codec.ProtoMarshaler, got: %T", cdc) - } - conf.WithCodec(ir, protoCodec) - - rosettaSrv, err := rosetta.ServerFromConfig(conf) - if err != nil { - return err - } - return rosettaSrv.Start() - }, - } - rosetta.SetFlags(cmd.Flags()) - - return cmd -} diff --git a/server/rosetta/client_offline.go b/server/rosetta/client_offline.go deleted file mode 100644 index eda78291eb..0000000000 --- a/server/rosetta/client_offline.go +++ /dev/null @@ -1,134 +0,0 @@ -package rosetta - -import ( - "context" - "encoding/hex" - - "github.com/coinbase/rosetta-sdk-go/types" - - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - sdk "github.com/Finschia/finschia-sdk/types" -) - -// ---------- cosmos-rosetta-gateway.types.NetworkInformationProvider implementation ------------ // - -func (c *Client) OperationStatuses() []*types.OperationStatus { - return []*types.OperationStatus{ - { - Status: StatusTxSuccess, - Successful: true, - }, - { - Status: StatusTxReverted, - Successful: false, - }, - } -} - -func (c *Client) Version() string { - return c.version -} - -func (c *Client) SupportedOperations() []string { - return c.supportedOperations -} - -// ---------- cosmos-rosetta-gateway.types.OfflineClient implementation ------------ // - -func (c *Client) SignedTx(_ context.Context, txBytes []byte, signatures []*types.Signature) (signedTxBytes []byte, err error) { - return c.converter.ToSDK().SignedTx(txBytes, signatures) -} - -func (c *Client) ConstructionPayload(_ context.Context, request *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error) { - // check if there is at least one operation - if len(request.Operations) < 1 { - return nil, crgerrs.WrapError(crgerrs.ErrInvalidOperation, "expected at least one operation") - } - - tx, err := c.converter.ToSDK().UnsignedTx(request.Operations) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrInvalidOperation, err.Error()) - } - - metadata := new(ConstructionMetadata) - if err = metadata.FromMetadata(request.Metadata); err != nil { - return nil, err - } - - txBytes, payloads, err := c.converter.ToRosetta().SigningComponents(tx, metadata, request.PublicKeys) - if err != nil { - return nil, err - } - - return &types.ConstructionPayloadsResponse{ - UnsignedTransaction: hex.EncodeToString(txBytes), - Payloads: payloads, - }, nil -} - -func (c *Client) PreprocessOperationsToOptions(_ context.Context, req *types.ConstructionPreprocessRequest) (response *types.ConstructionPreprocessResponse, err error) { - if len(req.Operations) == 0 { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "no operations") - } - - // now we need to parse the operations to cosmos sdk messages - tx, err := c.converter.ToSDK().UnsignedTx(req.Operations) - if err != nil { - return nil, err - } - - // get the signers - signers := tx.GetSigners() - signersStr := make([]string, len(signers)) - accountIdentifiers := make([]*types.AccountIdentifier, len(signers)) - - for i, sig := range signers { - addr := sig.String() - signersStr[i] = addr - accountIdentifiers[i] = &types.AccountIdentifier{ - Address: addr, - } - } - // get the metadata request information - meta := new(ConstructionPreprocessMetadata) - err = meta.FromMetadata(req.Metadata) - if err != nil { - return nil, err - } - - if meta.GasPrice == "" { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "no gas prices") - } - - if meta.GasLimit == 0 { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "no gas limit") - } - - // prepare the options to return - options := &PreprocessOperationsOptionsResponse{ - ExpectedSigners: signersStr, - Memo: meta.Memo, - GasLimit: meta.GasLimit, - GasPrice: meta.GasPrice, - } - - metaOptions, err := options.ToMetadata() - if err != nil { - return nil, err - } - return &types.ConstructionPreprocessResponse{ - Options: metaOptions, - RequiredPublicKeys: accountIdentifiers, - }, nil -} - -func (c *Client) AccountIdentifierFromPublicKey(pubKey *types.PublicKey) (*types.AccountIdentifier, error) { - pk, err := c.converter.ToSDK().PubKey(pubKey) - if err != nil { - return nil, err - } - - return &types.AccountIdentifier{ - Address: sdk.AccAddress(pk.Address()).String(), - }, nil -} diff --git a/server/rosetta/client_online.go b/server/rosetta/client_online.go deleted file mode 100644 index 744d584d05..0000000000 --- a/server/rosetta/client_online.go +++ /dev/null @@ -1,520 +0,0 @@ -package rosetta - -import ( - "bytes" - "context" - "encoding/base64" - "encoding/hex" - "errors" - "fmt" - "regexp" - "strconv" - "time" - - rosettatypes "github.com/coinbase/rosetta-sdk-go/types" - abci "github.com/tendermint/tendermint/abci/types" - tmrpc "github.com/tendermint/tendermint/rpc/client" - "github.com/tendermint/tendermint/rpc/client/http" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/metadata" - - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" - sdk "github.com/Finschia/finschia-sdk/types" - grpctypes "github.com/Finschia/finschia-sdk/types/grpc" - "github.com/Finschia/finschia-sdk/version" - authtx "github.com/Finschia/finschia-sdk/x/auth/tx" - auth "github.com/Finschia/finschia-sdk/x/auth/types" - bank "github.com/Finschia/finschia-sdk/x/bank/types" -) - -// interface assertion -var _ crgtypes.Client = (*Client)(nil) - -const ( - tmWebsocketPath = "/websocket" - defaultNodeTimeout = 15 * time.Second -) - -// Client implements a single network client to interact with cosmos based chains -type Client struct { - supportedOperations []string - - config *Config - - auth auth.QueryClient - bank bank.QueryClient - tmRPC tmrpc.Client - - version string - - converter Converter -} - -// NewClient instantiates a new online servicer -func NewClient(cfg *Config) (*Client, error) { - info := version.NewInfo() - - v := info.Version - if v == "" { - v = "unknown" - } - - txConfig := authtx.NewTxConfig(cfg.Codec, authtx.DefaultSignModes) - - var supportedOperations []string - for _, ii := range cfg.InterfaceRegistry.ListImplementations(sdk.MsgInterfaceProtoName) { - resolvedMsg, err := cfg.InterfaceRegistry.Resolve(ii) - if err != nil { - continue - } - - if _, ok := resolvedMsg.(sdk.Msg); ok { - supportedOperations = append(supportedOperations, ii) - } - } - - supportedOperations = append( - supportedOperations, - bank.EventTypeCoinSpent, - bank.EventTypeCoinReceived, - bank.EventTypeCoinBurn, - ) - - return &Client{ - supportedOperations: supportedOperations, - config: cfg, - auth: nil, - bank: nil, - tmRPC: nil, - version: fmt.Sprintf("%s/%s", info.AppName, v), - converter: NewConverter(cfg.Codec, cfg.InterfaceRegistry, txConfig), - }, nil -} - -// ---------- cosmos-rosetta-gateway.types.Client implementation ------------ // - -// Bootstrap is gonna connect the client to the endpoints -func (c *Client) Bootstrap() error { - grpcConn, err := grpc.Dial(c.config.GRPCEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - return err - } - - tmRPC, err := http.New(c.config.TendermintRPC, tmWebsocketPath) - if err != nil { - return err - } - - authClient := auth.NewQueryClient(grpcConn) - bankClient := bank.NewQueryClient(grpcConn) - - c.auth = authClient - c.bank = bankClient - c.tmRPC = tmRPC - - return nil -} - -// Ready performs a health check and returns an error if the client is not ready. -func (c *Client) Ready() error { - ctx, cancel := context.WithTimeout(context.Background(), defaultNodeTimeout) - defer cancel() - _, err := c.tmRPC.Health(ctx) - if err != nil { - return err - } - _, err = c.bank.TotalSupply(ctx, &bank.QueryTotalSupplyRequest{}) - if err != nil { - return err - } - return nil -} - -func (c *Client) accountInfo(ctx context.Context, addr string, height *int64) (*SignerData, error) { - if height != nil { - strHeight := strconv.FormatInt(*height, 10) - ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, strHeight) - } - - accountInfo, err := c.auth.Account(ctx, &auth.QueryAccountRequest{ - Address: addr, - }) - if err != nil { - return nil, crgerrs.FromGRPCToRosettaError(err) - } - - signerData, err := c.converter.ToRosetta().SignerData(accountInfo.Account) - if err != nil { - return nil, err - } - return signerData, nil -} - -func (c *Client) Balances(ctx context.Context, addr string, height *int64) ([]*rosettatypes.Amount, error) { - if height != nil { - strHeight := strconv.FormatInt(*height, 10) - ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, strHeight) - } - - balance, err := c.bank.AllBalances(ctx, &bank.QueryAllBalancesRequest{ - Address: addr, - }) - if err != nil { - return nil, crgerrs.FromGRPCToRosettaError(err) - } - - availableCoins, err := c.coins(ctx) - if err != nil { - return nil, err - } - - return c.converter.ToRosetta().Amounts(balance.Balances, availableCoins), nil -} - -func (c *Client) BlockByHash(ctx context.Context, hash string) (crgtypes.BlockResponse, error) { - bHash, err := hex.DecodeString(hash) - if err != nil { - return crgtypes.BlockResponse{}, fmt.Errorf("invalid block hash: %s", err) - } - - block, err := c.tmRPC.BlockByHash(ctx, bHash) - if err != nil { - return crgtypes.BlockResponse{}, crgerrs.WrapError(crgerrs.ErrBadGateway, err.Error()) - } - - return c.converter.ToRosetta().BlockResponse(block), nil -} - -func (c *Client) BlockByHeight(ctx context.Context, height *int64) (crgtypes.BlockResponse, error) { - height, err := c.getHeight(ctx, height) - if err != nil { - return crgtypes.BlockResponse{}, crgerrs.WrapError(crgerrs.ErrBadGateway, err.Error()) - } - block, err := c.tmRPC.Block(ctx, height) - if err != nil { - return crgtypes.BlockResponse{}, crgerrs.WrapError(crgerrs.ErrBadGateway, err.Error()) - } - - return c.converter.ToRosetta().BlockResponse(block), nil -} - -func (c *Client) BlockTransactionsByHash(ctx context.Context, hash string) (crgtypes.BlockTransactionsResponse, error) { - // TODO(fdymylja): use a faster path, by searching the block by hash, instead of doing a double query operation - blockResp, err := c.BlockByHash(ctx, hash) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, err - } - - return c.blockTxs(ctx, &blockResp.Block.Index) -} - -func (c *Client) BlockTransactionsByHeight(ctx context.Context, height *int64) (crgtypes.BlockTransactionsResponse, error) { - height, err := c.getHeight(ctx, height) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, crgerrs.WrapError(crgerrs.ErrBadGateway, err.Error()) - } - blockTxResp, err := c.blockTxs(ctx, height) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, err - } - return blockTxResp, nil -} - -// Coins fetches the existing coins in the application -func (c *Client) coins(ctx context.Context) (sdk.Coins, error) { - supply, err := c.bank.TotalSupply(ctx, &bank.QueryTotalSupplyRequest{}) - if err != nil { - return nil, crgerrs.FromGRPCToRosettaError(err) - } - return supply.Supply, nil -} - -func (c *Client) TxOperationsAndSignersAccountIdentifiers(signed bool, txBytes []byte) (ops []*rosettatypes.Operation, signers []*rosettatypes.AccountIdentifier, err error) { - switch signed { - case false: - rosTx, err := c.converter.ToRosetta().Tx(txBytes, nil) - if err != nil { - return nil, nil, err - } - return rosTx.Operations, nil, err - default: - ops, signers, err = c.converter.ToRosetta().OpsAndSigners(txBytes) - return - } -} - -// GetTx returns a transaction given its hash. For Rosetta we make a synthetic transaction for BeginBlock -// and EndBlock to adhere to balance tracking rules. -func (c *Client) GetTx(ctx context.Context, hash string) (*rosettatypes.Transaction, error) { - hashBytes, err := hex.DecodeString(hash) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, fmt.Sprintf("bad tx hash: %s", err)) - } - - // get tx type and hash - txType, hashBytes := c.converter.ToSDK().HashToTxType(hashBytes) - - // construct rosetta tx - switch txType { - // handle begin block hash - case BeginBlockTx: - // get block height by hash - block, err := c.tmRPC.BlockByHash(ctx, hashBytes) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - - // get block txs - fullBlock, err := c.blockTxs(ctx, &block.Block.Height) - if err != nil { - return nil, err - } - - return fullBlock.Transactions[0], nil - // handle deliver tx hash - case DeliverTxTx: - rawTx, err := c.tmRPC.Tx(ctx, hashBytes, true) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - return c.converter.ToRosetta().Tx(rawTx.Tx, &rawTx.TxResult) - // handle end block hash - case EndBlockTx: - // get block height by hash - block, err := c.tmRPC.BlockByHash(ctx, hashBytes) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - - // get block txs - fullBlock, err := c.blockTxs(ctx, &block.Block.Height) - if err != nil { - return nil, err - } - - // get last tx - return fullBlock.Transactions[len(fullBlock.Transactions)-1], nil - // unrecognized tx - default: - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, fmt.Sprintf("invalid tx hash provided: %s", hash)) - } -} - -// GetUnconfirmedTx gets an unconfirmed transaction given its hash -func (c *Client) GetUnconfirmedTx(ctx context.Context, hash string) (*rosettatypes.Transaction, error) { - res, err := c.tmRPC.UnconfirmedTxs(ctx, nil) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrNotFound, "unconfirmed tx not found") - } - - hashAsBytes, err := hex.DecodeString(hash) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrInterpreting, "invalid hash") - } - - // assert that correct tx length is provided - switch len(hashAsBytes) { - default: - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, fmt.Sprintf("unrecognized tx size: %d", len(hashAsBytes))) - case BeginEndBlockTxSize: - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "endblock and begin block txs cannot be unconfirmed") - case DeliverTxSize: - break - } - - // iterate over unconfirmed txs to find the one with matching hash - for _, unconfirmedTx := range res.Txs { - if !bytes.Equal(unconfirmedTx.Hash(), hashAsBytes) { - continue - } - - return c.converter.ToRosetta().Tx(unconfirmedTx, nil) - } - return nil, crgerrs.WrapError(crgerrs.ErrNotFound, "transaction not found in mempool: "+hash) -} - -// Mempool returns the unconfirmed transactions in the mempool -func (c *Client) Mempool(ctx context.Context) ([]*rosettatypes.TransactionIdentifier, error) { - txs, err := c.tmRPC.UnconfirmedTxs(ctx, nil) - if err != nil { - return nil, err - } - - return c.converter.ToRosetta().TxIdentifiers(txs.Txs), nil -} - -// Peers gets the number of peers -func (c *Client) Peers(ctx context.Context) ([]*rosettatypes.Peer, error) { - netInfo, err := c.tmRPC.NetInfo(ctx) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - return c.converter.ToRosetta().Peers(netInfo.Peers), nil -} - -func (c *Client) Status(ctx context.Context) (*rosettatypes.SyncStatus, error) { - status, err := c.tmRPC.Status(ctx) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - return c.converter.ToRosetta().SyncStatus(status), err -} - -func (c *Client) PostTx(txBytes []byte) (*rosettatypes.TransactionIdentifier, map[string]interface{}, error) { - // sync ensures it will go through checkTx - res, err := c.tmRPC.BroadcastTxSync(context.Background(), txBytes) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error()) - } - // check if tx was broadcast successfully - if res.Code != abci.CodeTypeOK { - return nil, nil, crgerrs.WrapError( - crgerrs.ErrUnknown, - fmt.Sprintf("transaction broadcast failure: (%d) %s ", res.Code, res.Log), - ) - } - - return &rosettatypes.TransactionIdentifier{ - Hash: fmt.Sprintf("%X", res.Hash), - }, - map[string]interface{}{ - Log: res.Log, - }, nil -} - -// construction endpoints - -// ConstructionMetadataFromOptions builds the metadata given the options -func (c *Client) ConstructionMetadataFromOptions(ctx context.Context, options map[string]interface{}) (meta map[string]interface{}, err error) { - if len(options) == 0 { - return nil, crgerrs.ErrBadArgument - } - - constructionOptions := new(PreprocessOperationsOptionsResponse) - - err = constructionOptions.FromMetadata(options) - if err != nil { - return nil, err - } - - signersData := make([]*SignerData, len(constructionOptions.ExpectedSigners)) - - for i, signer := range constructionOptions.ExpectedSigners { - accountInfo, err := c.accountInfo(ctx, signer, nil) - if err != nil { - return nil, err - } - - signersData[i] = accountInfo - } - - status, err := c.tmRPC.Status(ctx) - if err != nil { - return nil, err - } - - metadataResp := ConstructionMetadata{ - ChainID: status.NodeInfo.Network, - SignersData: signersData, - GasLimit: constructionOptions.GasLimit, - GasPrice: constructionOptions.GasPrice, - Memo: constructionOptions.Memo, - } - - return metadataResp.ToMetadata() -} - -func (c *Client) blockTxs(ctx context.Context, height *int64) (crgtypes.BlockTransactionsResponse, error) { - // get block info - blockInfo, err := c.tmRPC.Block(ctx, height) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, err - } - // get block events - blockResults, err := c.tmRPC.BlockResults(ctx, height) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, err - } - - if len(blockResults.TxsResults) != len(blockInfo.Block.Txs) { - // wtf? - panic("block results transactions do now match block transactions") - } - // process begin and end block txs - beginBlockTx := &rosettatypes.Transaction{ - TransactionIdentifier: &rosettatypes.TransactionIdentifier{Hash: c.converter.ToRosetta().BeginBlockTxHash(blockInfo.BlockID.Hash)}, - Operations: AddOperationIndexes( - nil, - c.converter.ToRosetta().BalanceOps(StatusTxSuccess, blockResults.BeginBlockEvents), - ), - } - - endBlockTx := &rosettatypes.Transaction{ - TransactionIdentifier: &rosettatypes.TransactionIdentifier{Hash: c.converter.ToRosetta().EndBlockTxHash(blockInfo.BlockID.Hash)}, - Operations: AddOperationIndexes( - nil, - c.converter.ToRosetta().BalanceOps(StatusTxSuccess, blockResults.EndBlockEvents), - ), - } - - deliverTx := make([]*rosettatypes.Transaction, len(blockInfo.Block.Txs)) - // process normal txs - for i, tx := range blockInfo.Block.Txs { - rosTx, err := c.converter.ToRosetta().Tx(tx, blockResults.TxsResults[i]) - if err != nil { - return crgtypes.BlockTransactionsResponse{}, err - } - deliverTx[i] = rosTx - } - - finalTxs := make([]*rosettatypes.Transaction, 0, 2+len(deliverTx)) - finalTxs = append(finalTxs, beginBlockTx) - finalTxs = append(finalTxs, deliverTx...) - finalTxs = append(finalTxs, endBlockTx) - - return crgtypes.BlockTransactionsResponse{ - BlockResponse: c.converter.ToRosetta().BlockResponse(blockInfo), - Transactions: finalTxs, - }, nil -} - -func (c *Client) getHeight(ctx context.Context, height *int64) (realHeight *int64, err error) { - if height != nil && *height == -1 { - genesisChunk, err := c.tmRPC.GenesisChunked(ctx, 0) - if err != nil { - return nil, err - } - - heightNum, err := extractInitialHeightFromGenesisChunk(genesisChunk.Data) - if err != nil { - return nil, err - } - - realHeight = &heightNum - } else { - realHeight = height - } - return -} - -func extractInitialHeightFromGenesisChunk(genesisChunk string) (int64, error) { - firstChunk, err := base64.StdEncoding.DecodeString(genesisChunk) - if err != nil { - return 0, err - } - - re, err := regexp.Compile("\"initial_height\":\"(\\d+)\"") - if err != nil { - return 0, err - } - - matches := re.FindStringSubmatch(string(firstChunk)) - if len(matches) != 2 { - return 0, errors.New("failed to fetch initial_height") - } - - heightStr := matches[1] - return strconv.ParseInt(heightStr, 10, 64) -} diff --git a/server/rosetta/client_online_test.go b/server/rosetta/client_online_test.go deleted file mode 100644 index 9aa8965cf6..0000000000 --- a/server/rosetta/client_online_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package rosetta - -import ( - "encoding/base64" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestRegex(t *testing.T) { - genesisChuck := base64.StdEncoding.EncodeToString([]byte(`"genesis_time":"2021-09-28T09:00:00Z","chain_id":"bombay-12","initial_height":"5900001","consensus_params":{"block":{"max_bytes":"5000000","max_gas":"1000000000","time_iota_ms":"1000"},"evidence":{"max_age_num_blocks":"100000","max_age_duration":"172800000000000","max_bytes":"50000"},"validator":{"pub_key_types":["ed25519"]},"version":{}},"validators":[{"address":"EEA4891F5F8D523A6B4B3EAC84B5C08655A00409","pub_key":{"type":"tendermint/PubKeyEd25519","value":"UX71gTBNumQq42qRd6j/K8XN/y3/HAcuAJxj97utawI="},"power":"60612","name":"BTC.Secure"},{"address":"973F589DE1CC8A54ABE2ABE0E0A4ABF13A9EBAE4","pub_key":{"type":"tendermint/PubKeyEd25519","value":"AmGQvQSAAXzSIscx/6o4rVdRMT9QvairQHaCXsWhY+c="},"power":"835","name":"MoonletWallet"},{"address":"831F402BDA0C9A3F260D4F221780BC22A4C3FB23","pub_key":{"type":"tendermint/PubKeyEd25519","value":"Tw8yKbPNEo113ZNbJJ8joeXokoMdBoazRTwb1NQ77WA="},"power":"102842","name":"BlockNgine"},{"address":"F2683F267D2B4C8714B44D68612DB37A8DD2EED7","pub_key":{"type":"tendermint/PubKeyEd25519","value":"PVE4IcWDE6QEqJSEkx55IDkg5zxBo8tVRzKFMJXYFSQ="},"power":"23200","name":"Luna Station 88"},{"address":"9D2428CBAC68C654BE11BE405344C560E6A0F626","pub_key":{"type":"tendermint/PubKeyEd25519","value":"93hzGmZjPRqOnQkb8BULjqanW3M2p1qIcLVTGkf1Zhk="},"power":"35420","name":"Terra-India"},{"address":"DC9897F22E74BF1B66E2640FA461F785F9BA7627","pub_key":{"type":"tendermint/PubKeyEd25519","value":"mlYb/Dzqwh0YJjfH59OZ4vtp+Zhdq5Oj5MNaGHq1X0E="},"power":"25163","name":"SolidStake"},{"address":"AA1A027E270A2BD7AF154999E6DE9D39C5711DE7","pub_key":{"type":"tendermint/PubKeyEd25519","value":"28z8FlpbC7sR0f1Q8OWFASDNi0FAmdldzetwQ07JJzg="},"power":"34529","name":"syncnode"},{"address":"E548735750DC5015ADDE3B0E7A1294C3B868680B","pub_key":{"type":"tendermint/PubKeyEd25519","value":"BTDtLSKp4wpQrWBwmGvp9isWC5jXaAtX1nrJtsCEWew="},"power":"36082","name":"OneStar"}`)) - height, err := extractInitialHeightFromGenesisChunk(genesisChuck) - require.NoError(t, err) - require.Equal(t, height, int64(5900001)) -} diff --git a/server/rosetta/codec.go b/server/rosetta/codec.go deleted file mode 100644 index d5d2cce38e..0000000000 --- a/server/rosetta/codec.go +++ /dev/null @@ -1,22 +0,0 @@ -package rosetta - -import ( - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" - cryptocodec "github.com/Finschia/finschia-sdk/crypto/codec" - authcodec "github.com/Finschia/finschia-sdk/x/auth/types" - bankcodec "github.com/Finschia/finschia-sdk/x/bank/types" -) - -// MakeCodec generates the codec required to interact -// with the cosmos APIs used by the rosetta gateway -func MakeCodec() (*codec.ProtoCodec, codectypes.InterfaceRegistry) { - ir := codectypes.NewInterfaceRegistry() - cdc := codec.NewProtoCodec(ir) - - authcodec.RegisterInterfaces(ir) - bankcodec.RegisterInterfaces(ir) - cryptocodec.RegisterInterfaces(ir) - - return cdc, ir -} diff --git a/server/rosetta/config.go b/server/rosetta/config.go deleted file mode 100644 index 1e50acd64a..0000000000 --- a/server/rosetta/config.go +++ /dev/null @@ -1,203 +0,0 @@ -package rosetta - -import ( - "fmt" - "strings" - "time" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/spf13/pflag" - - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" - crg "github.com/Finschia/finschia-sdk/server/rosetta/lib/server" -) - -// configuration defaults constants -const ( - // DefaultBlockchain defines the default blockchain identifier name - DefaultBlockchain = "app" - // DefaultAddr defines the default rosetta binding address - DefaultAddr = ":8080" - // DefaultRetries is the default number of retries - DefaultRetries = 5 - // DefaultTendermintEndpoint is the default value for the tendermint endpoint - DefaultTendermintEndpoint = "localhost:26657" - // DefaultGRPCEndpoint is the default value for the gRPC endpoint - DefaultGRPCEndpoint = "localhost:9090" - // DefaultNetwork defines the default network name - DefaultNetwork = "network" - // DefaultOffline defines the default offline value - DefaultOffline = false -) - -// configuration flags -const ( - FlagBlockchain = "blockchain" - FlagNetwork = "network" - FlagTendermintEndpoint = "tendermint" - FlagGRPCEndpoint = "grpc" - FlagAddr = "addr" - FlagRetries = "retries" - FlagOffline = "offline" -) - -// Config defines the configuration of the rosetta server -type Config struct { - // Blockchain defines the blockchain name - // defaults to DefaultBlockchain - Blockchain string - // Network defines the network name - Network string - // TendermintRPC defines the endpoint to connect to - // tendermint RPC, specifying 'tcp://' before is not - // required, usually it's at port 26657 of the - TendermintRPC string - // GRPCEndpoint defines the cosmos application gRPC endpoint - // usually it is located at 9090 port - GRPCEndpoint string - // Addr defines the default address to bind the rosetta server to - // defaults to DefaultAddr - Addr string - // Retries defines the maximum number of retries - // rosetta will do before quitting - Retries int - // Offline defines if the server must be run in offline mode - Offline bool - // Codec overrides the default data and construction api client codecs - Codec *codec.ProtoCodec - // InterfaceRegistry overrides the default data and construction api interface registry - InterfaceRegistry codectypes.InterfaceRegistry -} - -// NetworkIdentifier returns the network identifier given the configuration -func (c *Config) NetworkIdentifier() *types.NetworkIdentifier { - return &types.NetworkIdentifier{ - Blockchain: c.Blockchain, - Network: c.Network, - } -} - -// validate validates a configuration and sets -// its defaults in case they were not provided -func (c *Config) validate() error { - if (c.Codec == nil) != (c.InterfaceRegistry == nil) { - return fmt.Errorf("codec and interface registry must be both different from nil or nil") - } - - if c.Addr == "" { - c.Addr = DefaultAddr - } - if c.Blockchain == "" { - c.Blockchain = DefaultBlockchain - } - if c.Retries == 0 { - c.Retries = DefaultRetries - } - // these are must - if c.Network == "" { - return fmt.Errorf("network not provided") - } - if c.Offline { - return fmt.Errorf("offline mode is not supported for stargate implementation due to how sigv2 works") - } - - // these are optional but it must be online - if c.GRPCEndpoint == "" { - return fmt.Errorf("grpc endpoint not provided") - } - if c.TendermintRPC == "" { - return fmt.Errorf("tendermint rpc not provided") - } - if !strings.HasPrefix(c.TendermintRPC, "tcp://") { - c.TendermintRPC = fmt.Sprintf("tcp://%s", c.TendermintRPC) - } - - return nil -} - -// WithCodec extends the configuration with a predefined Codec -func (c *Config) WithCodec(ir codectypes.InterfaceRegistry, cdc *codec.ProtoCodec) { - c.Codec = cdc - c.InterfaceRegistry = ir -} - -// FromFlags gets the configuration from flags -func FromFlags(flags *pflag.FlagSet) (*Config, error) { - blockchain, err := flags.GetString(FlagBlockchain) - if err != nil { - return nil, err - } - network, err := flags.GetString(FlagNetwork) - if err != nil { - return nil, err - } - tendermintRPC, err := flags.GetString(FlagTendermintEndpoint) - if err != nil { - return nil, err - } - gRPCEndpoint, err := flags.GetString(FlagGRPCEndpoint) - if err != nil { - return nil, err - } - addr, err := flags.GetString(FlagAddr) - if err != nil { - return nil, err - } - retries, err := flags.GetInt(FlagRetries) - if err != nil { - return nil, err - } - offline, err := flags.GetBool(FlagOffline) - if err != nil { - return nil, err - } - conf := &Config{ - Blockchain: blockchain, - Network: network, - TendermintRPC: tendermintRPC, - GRPCEndpoint: gRPCEndpoint, - Addr: addr, - Retries: retries, - Offline: offline, - } - err = conf.validate() - if err != nil { - return nil, err - } - return conf, nil -} - -func ServerFromConfig(conf *Config) (crg.Server, error) { - err := conf.validate() - if err != nil { - return crg.Server{}, err - } - client, err := NewClient(conf) - if err != nil { - return crg.Server{}, err - } - return crg.NewServer( - crg.Settings{ - Network: &types.NetworkIdentifier{ - Blockchain: conf.Blockchain, - Network: conf.Network, - }, - Client: client, - Listen: conf.Addr, - Offline: conf.Offline, - Retries: conf.Retries, - RetryWait: 15 * time.Second, - }) -} - -// SetFlags sets the configuration flags to the given flagset -func SetFlags(flags *pflag.FlagSet) { - flags.String(FlagBlockchain, DefaultBlockchain, "the blockchain type") - flags.String(FlagNetwork, DefaultNetwork, "the network name") - flags.String(FlagTendermintEndpoint, DefaultTendermintEndpoint, "the tendermint rpc endpoint, without tcp://") - flags.String(FlagGRPCEndpoint, DefaultGRPCEndpoint, "the app gRPC endpoint") - flags.String(FlagAddr, DefaultAddr, "the address rosetta will bind to") - flags.Int(FlagRetries, DefaultRetries, "the number of retries that will be done before quitting") - flags.Bool(FlagOffline, DefaultOffline, "run rosetta only with construction API") -} diff --git a/server/rosetta/converter.go b/server/rosetta/converter.go deleted file mode 100644 index 0a227adf59..0000000000 --- a/server/rosetta/converter.go +++ /dev/null @@ -1,765 +0,0 @@ -package rosetta - -import ( - "bytes" - "encoding/json" - "fmt" - "reflect" - - rosettatypes "github.com/coinbase/rosetta-sdk-go/types" - secp "github.com/decred/dcrd/dcrec/secp256k1/v4" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" - tmcoretypes "github.com/tendermint/tendermint/rpc/core/types" - tmtypes "github.com/tendermint/tendermint/types" - - sdkclient "github.com/Finschia/finschia-sdk/client" - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" - "github.com/Finschia/finschia-sdk/crypto/keys/secp256k1" - cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" - sdk "github.com/Finschia/finschia-sdk/types" - "github.com/Finschia/finschia-sdk/types/tx/signing" - authsigning "github.com/Finschia/finschia-sdk/x/auth/signing" - auth "github.com/Finschia/finschia-sdk/x/auth/types" - banktypes "github.com/Finschia/finschia-sdk/x/bank/types" -) - -// Converter is a utility that can be used to convert -// back and forth from rosetta to sdk and tendermint types -// IMPORTANT NOTES: -// - IT SHOULD BE USED ONLY TO DEAL WITH THINGS -// IN A STATELESS WAY! IT SHOULD NEVER INTERACT DIRECTLY -// WITH TENDERMINT RPC AND COSMOS GRPC -// -// - IT SHOULD RETURN cosmos rosetta gateway error types! -type Converter interface { - // ToSDK exposes the methods that convert - // rosetta types to cosmos sdk and tendermint types - ToSDK() ToSDKConverter - // ToRosetta exposes the methods that convert - // sdk and tendermint types to rosetta types - ToRosetta() ToRosettaConverter -} - -// ToRosettaConverter is an interface that exposes -// all the functions used to convert sdk and -// tendermint types to rosetta known types -type ToRosettaConverter interface { - // BlockResponse returns a block response given a result block - BlockResponse(block *tmcoretypes.ResultBlock) crgtypes.BlockResponse - // BeginBlockToTx converts the given begin block hash to rosetta transaction hash - BeginBlockTxHash(blockHash []byte) string - // EndBlockTxHash converts the given endblock hash to rosetta transaction hash - EndBlockTxHash(blockHash []byte) string - // Amounts converts sdk.Coins to rosetta.Amounts - Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*rosettatypes.Amount - // Ops converts an sdk.Msg to rosetta operations - Ops(status string, msg sdk.Msg) ([]*rosettatypes.Operation, error) - // OpsAndSigners takes raw transaction bytes and returns rosetta operations and the expected signers - OpsAndSigners(txBytes []byte) (ops []*rosettatypes.Operation, signers []*rosettatypes.AccountIdentifier, err error) - // Meta converts an sdk.Msg to rosetta metadata - Meta(msg sdk.Msg) (meta map[string]interface{}, err error) - // SignerData returns account signing data from a queried any account - SignerData(anyAccount *codectypes.Any) (*SignerData, error) - // SigningComponents returns rosetta's components required to build a signable transaction - SigningComponents(tx authsigning.Tx, metadata *ConstructionMetadata, rosPubKeys []*rosettatypes.PublicKey) (txBytes []byte, payloadsToSign []*rosettatypes.SigningPayload, err error) - // Tx converts a tendermint transaction and tx result if provided to a rosetta tx - Tx(rawTx tmtypes.Tx, txResult *abci.ResponseDeliverTx) (*rosettatypes.Transaction, error) - // TxIdentifiers converts a tendermint tx to transaction identifiers - TxIdentifiers(txs []tmtypes.Tx) []*rosettatypes.TransactionIdentifier - // BalanceOps converts events to balance operations - BalanceOps(status string, events []abci.Event) []*rosettatypes.Operation - // SyncStatus converts a tendermint status to sync status - SyncStatus(status *tmcoretypes.ResultStatus) *rosettatypes.SyncStatus - // Peers converts tendermint peers to rosetta - Peers(peers []tmcoretypes.Peer) []*rosettatypes.Peer -} - -// ToSDKConverter is an interface that exposes -// all the functions used to convert rosetta types -// to tendermint and sdk types -type ToSDKConverter interface { - // UnsignedTx converts rosetta operations to an unsigned cosmos sdk transactions - UnsignedTx(ops []*rosettatypes.Operation) (tx authsigning.Tx, err error) - // SignedTx adds the provided signatures after decoding the unsigned transaction raw bytes - // and returns the signed tx bytes - SignedTx(txBytes []byte, signatures []*rosettatypes.Signature) (signedTxBytes []byte, err error) - // Msg converts metadata to an sdk message - Msg(meta map[string]interface{}, msg sdk.Msg) (err error) - // HashToTxType returns the transaction type (end block, begin block or deliver tx) - // and the real hash to query in order to get information - HashToTxType(hashBytes []byte) (txType TransactionType, realHash []byte) - // PubKey attempts to convert a rosetta public key to cosmos sdk one - PubKey(pk *rosettatypes.PublicKey) (cryptotypes.PubKey, error) -} - -type converter struct { - newTxBuilder func() sdkclient.TxBuilder - txBuilderFromTx func(tx sdk.Tx) (sdkclient.TxBuilder, error) - txDecode sdk.TxDecoder - txEncode sdk.TxEncoder - bytesToSign func(tx authsigning.Tx, signerData authsigning.SignerData) (b []byte, err error) - ir codectypes.InterfaceRegistry - cdc *codec.ProtoCodec -} - -func NewConverter(cdc *codec.ProtoCodec, ir codectypes.InterfaceRegistry, cfg sdkclient.TxConfig) Converter { - return converter{ - newTxBuilder: cfg.NewTxBuilder, - txBuilderFromTx: cfg.WrapTxBuilder, - txDecode: cfg.TxDecoder(), - txEncode: cfg.TxEncoder(), - bytesToSign: func(tx authsigning.Tx, signerData authsigning.SignerData) (b []byte, err error) { - bytesToSign, err := cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx) - if err != nil { - return nil, err - } - - return crypto.Sha256(bytesToSign), nil - }, - ir: ir, - cdc: cdc, - } -} - -func (c converter) ToSDK() ToSDKConverter { - return c -} - -func (c converter) ToRosetta() ToRosettaConverter { - return c -} - -// OpsToUnsignedTx returns all the sdk.Msgs given the operations -func (c converter) UnsignedTx(ops []*rosettatypes.Operation) (tx authsigning.Tx, err error) { - builder := c.newTxBuilder() - - var msgs []sdk.Msg - - for i := 0; i < len(ops); i++ { - op := ops[i] - - protoMessage, err := c.ir.Resolve(op.Type) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "operation not found: "+op.Type) - } - - msg, ok := protoMessage.(sdk.Msg) - if !ok { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "operation is not a valid supported sdk.Msg: "+op.Type) - } - - err = c.Msg(op.Metadata, msg) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - // verify message correctness - if err = msg.ValidateBasic(); err != nil { - return nil, crgerrs.WrapError( - crgerrs.ErrBadArgument, - fmt.Sprintf("validation of operation at index %d failed: %s", op.OperationIdentifier.Index, err), - ) - } - signers := msg.GetSigners() - // check if there are enough signers - if len(signers) == 0 { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, fmt.Sprintf("operation at index %d got no signers", op.OperationIdentifier.Index)) - } - // append the msg - msgs = append(msgs, msg) - // if there's only one signer then simply continue - if len(signers) == 1 { - continue - } - // after we have got the msg, we need to verify if the message has multiple signers - // if it has got multiple signers, then we need to fetch all the related operations - // which involve the other signers of the msg, we expect to find them in order - // so if the msg is named "v1.test.Send" and it expects 3 signers, the next 3 operations - // must be with the same name "v1.test.Send" and contain the other signers - // then we can just skip their processing - for j := 0; j < len(signers)-1; j++ { - skipOp := ops[i+j] // get the next index - // verify that the operation is equal to the new one - if skipOp.Type != op.Type { - return nil, crgerrs.WrapError( - crgerrs.ErrBadArgument, - fmt.Sprintf("operation at index %d should have had type %s got: %s", i+j, op.Type, skipOp.Type), - ) - } - - if !reflect.DeepEqual(op.Metadata, skipOp.Metadata) { - return nil, crgerrs.WrapError( - crgerrs.ErrBadArgument, - fmt.Sprintf("operation at index %d should have had metadata equal to %#v, got: %#v", i+j, op.Metadata, skipOp.Metadata)) - } - - i++ // increase so we skip it - } - } - - if err := builder.SetMsgs(msgs...); err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, err.Error()) - } - - return builder.GetTx(), nil -} - -// Msg unmarshals the rosetta metadata to the given sdk.Msg -func (c converter) Msg(meta map[string]interface{}, msg sdk.Msg) error { - metaBytes, err := json.Marshal(meta) - if err != nil { - return err - } - return c.cdc.UnmarshalJSON(metaBytes, msg) -} - -func (c converter) Meta(msg sdk.Msg) (meta map[string]interface{}, err error) { - b, err := c.cdc.MarshalJSON(msg) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - err = json.Unmarshal(b, &meta) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - return -} - -// Ops will create an operation for each msg signer -// with the message proto name as type, and the raw fields -// as metadata -func (c converter) Ops(status string, msg sdk.Msg) ([]*rosettatypes.Operation, error) { - opName := sdk.MsgTypeURL(msg) - - meta, err := c.Meta(msg) - if err != nil { - return nil, err - } - - ops := make([]*rosettatypes.Operation, len(msg.GetSigners())) - for i, signer := range msg.GetSigners() { - op := &rosettatypes.Operation{ - Type: opName, - Status: &status, - Account: &rosettatypes.AccountIdentifier{Address: signer.String()}, - Metadata: meta, - } - - ops[i] = op - } - - return ops, nil -} - -// Tx converts a tendermint raw transaction and its result (if provided) to a rosetta transaction -func (c converter) Tx(rawTx tmtypes.Tx, txResult *abci.ResponseDeliverTx) (*rosettatypes.Transaction, error) { - // decode tx - tx, err := c.txDecode(rawTx) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - // get initial status, as per sdk design, if one msg fails - // the whole TX will be considered failing, so we can't have - // 1 msg being success and 1 msg being reverted - status := StatusTxSuccess - switch txResult { - // if nil, we're probably checking an unconfirmed tx - // or trying to build a new transaction, so status - // is not put inside - case nil: - status = "" - // set the status - default: - if txResult.Code != abci.CodeTypeOK { - status = StatusTxReverted - } - } - // get operations from msgs - msgs := tx.GetMsgs() - var rawTxOps []*rosettatypes.Operation - - for _, msg := range msgs { - ops, err := c.Ops(status, msg) - if err != nil { - return nil, err - } - rawTxOps = append(rawTxOps, ops...) - } - - // now get balance events from response deliver tx - var balanceOps []*rosettatypes.Operation - // tx result might be nil, in case we're querying an unconfirmed tx from the mempool - if txResult != nil { - balanceOps = c.BalanceOps(status, txResult.Events) - } - - // now normalize indexes - totalOps := AddOperationIndexes(rawTxOps, balanceOps) - - return &rosettatypes.Transaction{ - TransactionIdentifier: &rosettatypes.TransactionIdentifier{Hash: fmt.Sprintf("%X", rawTx.Hash())}, - Operations: totalOps, - }, nil -} - -func (c converter) BalanceOps(status string, events []abci.Event) []*rosettatypes.Operation { - var ops []*rosettatypes.Operation - - for _, e := range events { - balanceOps, ok := sdkEventToBalanceOperations(status, e) - if !ok { - continue - } - ops = append(ops, balanceOps...) - } - - return ops -} - -// sdkEventToBalanceOperations converts an event to a rosetta balance operation -// it will panic if the event is malformed because it might mean the sdk spec -// has changed and rosetta needs to reflect those changes too. -// The balance operations are multiple, one for each denom. -func sdkEventToBalanceOperations(status string, event abci.Event) (operations []*rosettatypes.Operation, isBalanceEvent bool) { - var ( - accountIdentifier string - coinChange sdk.Coins - isSub bool - ) - - switch event.Type { - default: - return nil, false - case banktypes.EventTypeCoinSpent: - spender := sdk.MustAccAddressFromBech32((string)(event.Attributes[0].Value)) - coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value)) - if err != nil { - panic(err) - } - - isSub = true - coinChange = coins - accountIdentifier = spender.String() - - case banktypes.EventTypeCoinReceived: - receiver := sdk.MustAccAddressFromBech32((string)(event.Attributes[0].Value)) - coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value)) - if err != nil { - panic(err) - } - - isSub = false - coinChange = coins - accountIdentifier = receiver.String() - - // rosetta does not have the concept of burning coins, so we need to mock - // the burn as a send to an address that cannot be resolved to anything - case banktypes.EventTypeCoinBurn: - coins, err := sdk.ParseCoinsNormalized((string)(event.Attributes[1].Value)) - if err != nil { - panic(err) - } - - coinChange = coins - accountIdentifier = BurnerAddressIdentifier - } - - operations = make([]*rosettatypes.Operation, len(coinChange)) - - for i, coin := range coinChange { - - value := coin.Amount.String() - // in case the event is a subtract balance one the rewrite value with - // the negative coin identifier - if isSub { - value = "-" + value - } - - op := &rosettatypes.Operation{ - Type: event.Type, - Status: &status, - Account: &rosettatypes.AccountIdentifier{Address: accountIdentifier}, - Amount: &rosettatypes.Amount{ - Value: value, - Currency: &rosettatypes.Currency{ - Symbol: coin.Denom, - Decimals: 0, - }, - }, - } - - operations[i] = op - } - return operations, true -} - -// Amounts converts []sdk.Coin to rosetta amounts -func (c converter) Amounts(ownedCoins []sdk.Coin, availableCoins sdk.Coins) []*rosettatypes.Amount { - amounts := make([]*rosettatypes.Amount, len(availableCoins)) - ownedCoinsMap := make(map[string]sdk.Int, len(availableCoins)) - - for _, ownedCoin := range ownedCoins { - ownedCoinsMap[ownedCoin.Denom] = ownedCoin.Amount - } - - for i, coin := range availableCoins { - value, owned := ownedCoinsMap[coin.Denom] - if !owned { - amounts[i] = &rosettatypes.Amount{ - Value: sdk.NewInt(0).String(), - Currency: &rosettatypes.Currency{ - Symbol: coin.Denom, - }, - } - continue - } - amounts[i] = &rosettatypes.Amount{ - Value: value.String(), - Currency: &rosettatypes.Currency{ - Symbol: coin.Denom, - }, - } - } - - return amounts -} - -// AddOperationIndexes adds the indexes to operations adhering to specific rules: -// operations related to messages will be always before than the balance ones -func AddOperationIndexes(msgOps, balanceOps []*rosettatypes.Operation) (finalOps []*rosettatypes.Operation) { - lenMsgOps := len(msgOps) - lenBalanceOps := len(balanceOps) - finalOps = make([]*rosettatypes.Operation, 0, lenMsgOps+lenBalanceOps) - - var currentIndex int64 - // add indexes to msg ops - for _, op := range msgOps { - op.OperationIdentifier = &rosettatypes.OperationIdentifier{ - Index: currentIndex, - } - - finalOps = append(finalOps, op) - currentIndex++ - } - - // add indexes to balance ops - for _, op := range balanceOps { - op.OperationIdentifier = &rosettatypes.OperationIdentifier{ - Index: currentIndex, - } - - finalOps = append(finalOps, op) - currentIndex++ - } - - return finalOps -} - -// EndBlockTxHash produces a mock endblock hash that rosetta can query -// for endblock operations, it also serves the purpose of representing -// part of the state changes happening at endblock level (balance ones) -func (c converter) EndBlockTxHash(hash []byte) string { - final := append([]byte{EndBlockHashStart}, hash...) - return fmt.Sprintf("%X", final) -} - -// BeginBlockTxHash produces a mock beginblock hash that rosetta can query -// for beginblock operations, it also serves the purpose of representing -// part of the state changes happening at beginblock level (balance ones) -func (c converter) BeginBlockTxHash(hash []byte) string { - final := append([]byte{BeginBlockHashStart}, hash...) - return fmt.Sprintf("%X", final) -} - -// HashToTxType takes the provided hash bytes from rosetta and discerns if they are -// a deliver tx type or endblock/begin block hash, returning the real hash afterwards -func (c converter) HashToTxType(hashBytes []byte) (txType TransactionType, realHash []byte) { - switch len(hashBytes) { - case DeliverTxSize: - return DeliverTxTx, hashBytes - - case BeginEndBlockTxSize: - switch hashBytes[0] { - case BeginBlockHashStart: - return BeginBlockTx, hashBytes[1:] - case EndBlockHashStart: - return EndBlockTx, hashBytes[1:] - default: - return UnrecognizedTx, nil - } - - default: - return UnrecognizedTx, nil - } -} - -// StatusToSyncStatus converts a tendermint status to rosetta sync status -func (c converter) SyncStatus(status *tmcoretypes.ResultStatus) *rosettatypes.SyncStatus { - // determine sync status - stage := StatusPeerSynced - if status.SyncInfo.CatchingUp { - stage = StatusPeerSyncing - } - - return &rosettatypes.SyncStatus{ - CurrentIndex: &status.SyncInfo.LatestBlockHeight, - TargetIndex: nil, // sync info does not allow us to get target height - Stage: &stage, - } -} - -// TxIdentifiers converts a tendermint raw transactions into an array of rosetta tx identifiers -func (c converter) TxIdentifiers(txs []tmtypes.Tx) []*rosettatypes.TransactionIdentifier { - converted := make([]*rosettatypes.TransactionIdentifier, len(txs)) - for i, tx := range txs { - converted[i] = &rosettatypes.TransactionIdentifier{Hash: fmt.Sprintf("%X", tx.Hash())} - } - - return converted -} - -// tmResultBlockToRosettaBlockResponse converts a tendermint result block to block response -func (c converter) BlockResponse(block *tmcoretypes.ResultBlock) crgtypes.BlockResponse { - var parentBlock *rosettatypes.BlockIdentifier - - switch block.Block.Height { - case 1: - parentBlock = &rosettatypes.BlockIdentifier{ - Index: 1, - Hash: fmt.Sprintf("%X", block.BlockID.Hash.Bytes()), - } - default: - parentBlock = &rosettatypes.BlockIdentifier{ - Index: block.Block.Height - 1, - Hash: fmt.Sprintf("%X", block.Block.LastBlockID.Hash.Bytes()), - } - } - return crgtypes.BlockResponse{ - Block: &rosettatypes.BlockIdentifier{ - Index: block.Block.Height, - Hash: block.Block.Hash().String(), - }, - ParentBlock: parentBlock, - MillisecondTimestamp: timeToMilliseconds(block.Block.Time), - TxCount: int64(len(block.Block.Txs)), - } -} - -// Peers converts tm peers to rosetta peers -func (c converter) Peers(peers []tmcoretypes.Peer) []*rosettatypes.Peer { - converted := make([]*rosettatypes.Peer, len(peers)) - - for i, peer := range peers { - converted[i] = &rosettatypes.Peer{ - PeerID: peer.NodeInfo.Moniker, - Metadata: map[string]interface{}{ - "addr": peer.NodeInfo.ListenAddr, - }, - } - } - - return converted -} - -// OpsAndSigners takes transactions bytes and returns the operation, is signed is true it will return -// the account identifiers which have signed the transaction -func (c converter) OpsAndSigners(txBytes []byte) (ops []*rosettatypes.Operation, signers []*rosettatypes.AccountIdentifier, err error) { - rosTx, err := c.ToRosetta().Tx(txBytes, nil) - if err != nil { - return nil, nil, err - } - ops = rosTx.Operations - - // get the signers - sdkTx, err := c.txDecode(txBytes) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - txBuilder, err := c.txBuilderFromTx(sdkTx) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - for _, signer := range txBuilder.GetTx().GetSigners() { - signers = append(signers, &rosettatypes.AccountIdentifier{ - Address: signer.String(), - }) - } - - return -} - -func (c converter) SignedTx(txBytes []byte, signatures []*rosettatypes.Signature) (signedTxBytes []byte, err error) { - rawTx, err := c.txDecode(txBytes) - if err != nil { - return nil, err - } - - txBuilder, err := c.txBuilderFromTx(rawTx) - if err != nil { - return nil, err - } - - notSignedSigs, err := txBuilder.GetTx().GetSignaturesV2() // - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - if len(notSignedSigs) != len(signatures) { - return nil, crgerrs.WrapError( - crgerrs.ErrInvalidTransaction, - fmt.Sprintf("expected transaction to have signers data matching the provided signatures: %d <-> %d", len(notSignedSigs), len(signatures))) - } - - signedSigs := make([]signing.SignatureV2, len(notSignedSigs)) - for i, signature := range signatures { - // TODO(fdymylja): here we should check that the public key matches... - signedSigs[i] = signing.SignatureV2{ - PubKey: notSignedSigs[i].PubKey, - Data: &signing.SingleSignatureData{ - SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, - Signature: signature.Bytes, - }, - Sequence: notSignedSigs[i].Sequence, - } - } - - if err = txBuilder.SetSignatures(signedSigs...); err != nil { - return nil, err - } - - txBytes, err = c.txEncode(txBuilder.GetTx()) - if err != nil { - return nil, err - } - - return txBytes, nil -} - -func (c converter) PubKey(pubKey *rosettatypes.PublicKey) (cryptotypes.PubKey, error) { - if pubKey.CurveType != "secp256k1" { - return nil, crgerrs.WrapError(crgerrs.ErrUnsupportedCurve, "only secp256k1 supported") - } - - cmp, err := secp.ParsePubKey(pubKey.Bytes) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, err.Error()) - } - - compressedPublicKey := make([]byte, secp256k1.PubKeySize) - copy(compressedPublicKey, cmp.SerializeCompressed()) - - pk := &secp256k1.PubKey{Key: compressedPublicKey} - - return pk, nil -} - -// SigningComponents takes a sdk tx and construction metadata and returns signable components -func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMetadata, rosPubKeys []*rosettatypes.PublicKey) (txBytes []byte, payloadsToSign []*rosettatypes.SigningPayload, err error) { - // verify metadata correctness - feeAmount, err := sdk.ParseCoinsNormalized(metadata.GasPrice) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrBadArgument, err.Error()) - } - - signers := tx.GetSigners() - // assert the signers data provided in options are the same as the expected signing accounts - // and that the number of rosetta provided public keys equals the one of the signers - if len(metadata.SignersData) != len(signers) || len(signers) != len(rosPubKeys) { - return nil, nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "signers data and account identifiers mismatch") - } - - // add transaction metadata - builder, err := c.txBuilderFromTx(tx) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - builder.SetFeeAmount(feeAmount) - builder.SetGasLimit(metadata.GasLimit) - builder.SetMemo(metadata.Memo) - - // build signatures - partialSignatures := make([]signing.SignatureV2, len(signers)) - payloadsToSign = make([]*rosettatypes.SigningPayload, len(signers)) - - // pub key ordering matters, in a future release this check might be relaxed - for i, signer := range signers { - // assert that the provided public keys are correctly ordered - // by checking if the signer at index i matches the pubkey at index - pubKey, err := c.ToSDK().PubKey(rosPubKeys[0]) - if err != nil { - return nil, nil, err - } - if !bytes.Equal(pubKey.Address().Bytes(), signer.Bytes()) { - return nil, nil, crgerrs.WrapError( - crgerrs.ErrBadArgument, - fmt.Sprintf("public key at index %d does not match the expected transaction signer: %X <-> %X", i, rosPubKeys[i].Bytes, signer.Bytes()), - ) - } - - // set the signer data - signerData := authsigning.SignerData{ - ChainID: metadata.ChainID, - AccountNumber: metadata.SignersData[i].AccountNumber, - Sequence: metadata.SignersData[i].Sequence, - } - - // get signature bytes - signBytes, err := c.bytesToSign(tx, signerData) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrUnknown, fmt.Sprintf("unable to sign tx: %s", err.Error())) - } - - // set payload - payloadsToSign[i] = &rosettatypes.SigningPayload{ - AccountIdentifier: &rosettatypes.AccountIdentifier{Address: signer.String()}, - Bytes: signBytes, - SignatureType: rosettatypes.Ecdsa, - } - - // set partial signature - partialSignatures[i] = signing.SignatureV2{ - PubKey: pubKey, - Data: &signing.SingleSignatureData{}, // needs to be set to empty otherwise the codec will cry - Sequence: metadata.SignersData[i].Sequence, - } - - } - - // now we set the partial signatures in the tx - // because we will need to decode the sequence - // information of each account in a stateless way - err = builder.SetSignatures(partialSignatures...) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - // finally encode the tx - txBytes, err = c.txEncode(builder.GetTx()) - if err != nil { - return nil, nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - return txBytes, payloadsToSign, nil -} - -// SignerData converts the given any account to signer data -func (c converter) SignerData(anyAccount *codectypes.Any) (*SignerData, error) { - var acc auth.AccountI - err := c.ir.UnpackAny(anyAccount, &acc) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - return &SignerData{ - AccountNumber: acc.GetAccountNumber(), - Sequence: acc.GetSequence(), - }, nil -} diff --git a/server/rosetta/converter_test.go b/server/rosetta/converter_test.go deleted file mode 100644 index 608d7e9f24..0000000000 --- a/server/rosetta/converter_test.go +++ /dev/null @@ -1,339 +0,0 @@ -package rosetta_test - -import ( - "encoding/hex" - "encoding/json" - "testing" - - rosettatypes "github.com/coinbase/rosetta-sdk-go/types" - "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/Finschia/finschia-sdk/client" - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" - "github.com/Finschia/finschia-sdk/server/rosetta" - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - sdk "github.com/Finschia/finschia-sdk/types" - authsigning "github.com/Finschia/finschia-sdk/x/auth/signing" - authtx "github.com/Finschia/finschia-sdk/x/auth/tx" - bank "github.com/Finschia/finschia-sdk/x/bank/types" -) - -type ConverterTestSuite struct { - suite.Suite - - c rosetta.Converter - unsignedTxBytes []byte - unsignedTx authsigning.Tx - - ir codectypes.InterfaceRegistry - cdc *codec.ProtoCodec - txConf client.TxConfig -} - -func (s *ConverterTestSuite) SetupTest() { - // create an unsigned tx - const unsignedTxHex = "0a8a010a87010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412670a2b6c696e6b3136773064766c61716e34727779706739757a36713878643778343434687568756d636370756e122b6c696e6b316c33757538657364636c6a3876706a72757737357535666a34773479746475396e6c6b6538721a0b0a057374616b651202313612640a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210377365794209eab396f74316bb32ecb507c0e3788c14edf164f96b25cc4ef624112040a020801180112100a0a0a057374616b6512013110c09a0c1a00" - unsignedTxBytes, err := hex.DecodeString(unsignedTxHex) - s.Require().NoError(err) - s.unsignedTxBytes = unsignedTxBytes - // instantiate converter - cdc, ir := rosetta.MakeCodec() - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) - s.c = rosetta.NewConverter(cdc, ir, txConfig) - // add utils - s.ir = ir - s.cdc = cdc - s.txConf = txConfig - // add authsigning tx - sdkTx, err := txConfig.TxDecoder()(unsignedTxBytes) - s.Require().NoError(err) - builder, err := txConfig.WrapTxBuilder(sdkTx) - s.Require().NoError(err) - - s.unsignedTx = builder.GetTx() -} - -func (s *ConverterTestSuite) TestFromRosettaOpsToTxSuccess() { - addr1 := sdk.AccAddress("address1").String() - addr2 := sdk.AccAddress("address2").String() - - msg1 := &bank.MsgSend{ - FromAddress: addr1, - ToAddress: addr2, - Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 10)), - } - - msg2 := &bank.MsgSend{ - FromAddress: addr2, - ToAddress: addr1, - Amount: sdk.NewCoins(sdk.NewInt64Coin("utxo", 10)), - } - - ops, err := s.c.ToRosetta().Ops("", msg1) - s.Require().NoError(err) - - ops2, err := s.c.ToRosetta().Ops("", msg2) - s.Require().NoError(err) - - ops = append(ops, ops2...) - - tx, err := s.c.ToSDK().UnsignedTx(ops) - s.Require().NoError(err) - - getMsgs := tx.GetMsgs() - - s.Require().Equal(2, len(getMsgs)) - - s.Require().Equal(getMsgs[0], msg1) - s.Require().Equal(getMsgs[1], msg2) -} - -func (s *ConverterTestSuite) TestFromRosettaOpsToTxErrors() { - s.Run("unrecognized op", func() { - op := &rosettatypes.Operation{ - Type: "non-existent", - } - - _, err := s.c.ToSDK().UnsignedTx([]*rosettatypes.Operation{op}) - - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - - s.Run("codec type but not sdk.Msg", func() { - op := &rosettatypes.Operation{ - Type: "cosmos.crypto.ed25519.PubKey", - } - - _, err := s.c.ToSDK().UnsignedTx([]*rosettatypes.Operation{op}) - - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) -} - -func (s *ConverterTestSuite) TestMsgToMetaMetaToMsg() { - msg := &bank.MsgSend{ - FromAddress: "addr1", - ToAddress: "addr2", - Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 10)), - } - msg.Route() - - meta, err := s.c.ToRosetta().Meta(msg) - s.Require().NoError(err) - - copyMsg := new(bank.MsgSend) - err = s.c.ToSDK().Msg(meta, copyMsg) - s.Require().NoError(err) - s.Require().Equal(msg, copyMsg) -} - -func (s *ConverterTestSuite) TestSignedTx() { - s.Run("success", func() { - const payloadsJSON = `[{"hex_bytes":"82ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5","public_key":{"curve_type":"secp256k1","hex_bytes":"0377365794209eab396f74316bb32ecb507c0e3788c14edf164f96b25cc4ef6241"},"signature_type":"ecdsa","signing_payload":{"account_identifier":{"address":"link16w0dvlaqn4rwypg9uz6q8xd7x444huhumccpun"},"address":"link16w0dvlaqn4rwypg9uz6q8xd7x444huhumccpun","hex_bytes":"ea43c4019ee3c888a7f99acb57513f708bb8915bc84e914cf4ecbd08ab2d9e51","signature_type":"ecdsa"}}]` - const expectedSignedTxHex = "0a8a010a87010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412670a2b6c696e6b3136773064766c61716e34727779706739757a36713878643778343434687568756d636370756e122b6c696e6b316c33757538657364636c6a3876706a72757737357535666a34773479746475396e6c6b6538721a0b0a057374616b651202313612640a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210377365794209eab396f74316bb32ecb507c0e3788c14edf164f96b25cc4ef624112040a02087f180112100a0a0a057374616b6512013110c09a0c1a4082ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5" - - var payloads []*rosettatypes.Signature - s.Require().NoError(json.Unmarshal([]byte(payloadsJSON), &payloads)) - - signedTx, err := s.c.ToSDK().SignedTx(s.unsignedTxBytes, payloads) - s.Require().NoError(err) - - signedTxHex := hex.EncodeToString(signedTx) - - s.Require().Equal(signedTxHex, expectedSignedTxHex) - }) - - s.Run("signers data and signing payloads mismatch", func() { - _, err := s.c.ToSDK().SignedTx(s.unsignedTxBytes, nil) - s.Require().ErrorIs(err, crgerrs.ErrInvalidTransaction) - }) -} - -func (s *ConverterTestSuite) TestOpsAndSigners() { - s.Run("success", func() { - addr1 := sdk.AccAddress("address1").String() - addr2 := sdk.AccAddress("address2").String() - - msg := &bank.MsgSend{ - FromAddress: addr1, - ToAddress: addr2, - Amount: sdk.NewCoins(sdk.NewInt64Coin("test", 10)), - } - - builder := s.txConf.NewTxBuilder() - s.Require().NoError(builder.SetMsgs(msg)) - - sdkTx := builder.GetTx() - txBytes, err := s.txConf.TxEncoder()(sdkTx) - s.Require().NoError(err) - - ops, signers, err := s.c.ToRosetta().OpsAndSigners(txBytes) - s.Require().NoError(err) - - s.Require().Equal(len(ops), len(sdkTx.GetMsgs())*len(sdkTx.GetSigners()), "operation number mismatch") - - s.Require().Equal(len(signers), len(sdkTx.GetSigners()), "signers number mismatch") - }) -} - -func (s *ConverterTestSuite) TestBeginEndBlockAndHashToTxType() { - const deliverTxHex = "5229A67AA008B5C5F1A0AEA77D4DEBE146297A30AAEF01777AF10FAD62DD36AB" - - deliverTxBytes, err := hex.DecodeString(deliverTxHex) - s.Require().NoError(err) - - endBlockTxHex := s.c.ToRosetta().EndBlockTxHash(deliverTxBytes) - beginBlockTxHex := s.c.ToRosetta().BeginBlockTxHash(deliverTxBytes) - - txType, hash := s.c.ToSDK().HashToTxType(deliverTxBytes) - - s.Require().Equal(rosetta.DeliverTxTx, txType) - s.Require().Equal(deliverTxBytes, hash, "deliver tx hash should not change") - - endBlockTxBytes, err := hex.DecodeString(endBlockTxHex) - s.Require().NoError(err) - - txType, hash = s.c.ToSDK().HashToTxType(endBlockTxBytes) - - s.Require().Equal(rosetta.EndBlockTx, txType) - s.Require().Equal(deliverTxBytes, hash, "end block tx hash should be equal to a block hash") - - beginBlockTxBytes, err := hex.DecodeString(beginBlockTxHex) - s.Require().NoError(err) - - txType, hash = s.c.ToSDK().HashToTxType(beginBlockTxBytes) - - s.Require().Equal(rosetta.BeginBlockTx, txType) - s.Require().Equal(deliverTxBytes, hash, "begin block tx hash should be equal to a block hash") - - txType, hash = s.c.ToSDK().HashToTxType([]byte("invalid")) - - s.Require().Equal(rosetta.UnrecognizedTx, txType) - s.Require().Nil(hash) - - txType, hash = s.c.ToSDK().HashToTxType(append([]byte{0x3}, deliverTxBytes...)) - s.Require().Equal(rosetta.UnrecognizedTx, txType) - s.Require().Nil(hash) -} - -func (s *ConverterTestSuite) TestSigningComponents() { - s.Run("invalid metadata coins", func() { - _, _, err := s.c.ToRosetta().SigningComponents(nil, &rosetta.ConstructionMetadata{GasPrice: "invalid"}, nil) - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - - s.Run("length signers data does not match signers", func() { - _, _, err := s.c.ToRosetta().SigningComponents(s.unsignedTx, &rosetta.ConstructionMetadata{GasPrice: "10stake"}, nil) - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - - s.Run("length pub keys does not match signers", func() { - _, _, err := s.c.ToRosetta().SigningComponents( - s.unsignedTx, - &rosetta.ConstructionMetadata{GasPrice: "10stake", SignersData: []*rosetta.SignerData{ - { - AccountNumber: 0, - Sequence: 0, - }, - }}, - nil) - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - - s.Run("ros pub key is valid but not the one we expect", func() { - validButUnexpected, err := hex.DecodeString("030da9096a40eb1d6c25f1e26e9cbf8941fc84b8f4dc509c8df5e62a29ab8f2415") - s.Require().NoError(err) - - _, _, err = s.c.ToRosetta().SigningComponents( - s.unsignedTx, - &rosetta.ConstructionMetadata{GasPrice: "10stake", SignersData: []*rosetta.SignerData{ - { - AccountNumber: 0, - Sequence: 0, - }, - }}, - []*rosettatypes.PublicKey{ - { - Bytes: validButUnexpected, - CurveType: rosettatypes.Secp256k1, - }, - }) - s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - - s.Run("success", func() { - expectedPubKey, err := hex.DecodeString("0377365794209eab396f74316bb32ecb507c0e3788c14edf164f96b25cc4ef6241") - s.Require().NoError(err) - - _, _, err = s.c.ToRosetta().SigningComponents( - s.unsignedTx, - &rosetta.ConstructionMetadata{GasPrice: "10stake", SignersData: []*rosetta.SignerData{ - { - AccountNumber: 0, - Sequence: 0, - }, - }}, - []*rosettatypes.PublicKey{ - { - Bytes: expectedPubKey, - CurveType: rosettatypes.Secp256k1, - }, - }) - s.Require().NoError(err) - }) -} - -func (s *ConverterTestSuite) TestBalanceOps() { - s.Run("not a balance op", func() { - notBalanceOp := abci.Event{ - Type: "not-a-balance-op", - } - - ops := s.c.ToRosetta().BalanceOps("", []abci.Event{notBalanceOp}) - s.Len(ops, 0, "expected no balance ops") - }) - - s.Run("multiple balance ops from 2 multicoins event", func() { - subBalanceOp := bank.NewCoinSpentEvent( - sdk.AccAddress("test"), - sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)), - ) - - addBalanceOp := bank.NewCoinReceivedEvent( - sdk.AccAddress("test"), - sdk.NewCoins(sdk.NewInt64Coin("test", 10), sdk.NewInt64Coin("utxo", 10)), - ) - - ops := s.c.ToRosetta().BalanceOps("", []abci.Event{(abci.Event)(subBalanceOp), (abci.Event)(addBalanceOp)}) - s.Len(ops, 4) - }) - - s.Run("spec broken", func() { - s.Require().Panics(func() { - specBrokenSub := abci.Event{ - Type: bank.EventTypeCoinSpent, - } - _ = s.c.ToRosetta().BalanceOps("", []abci.Event{specBrokenSub}) - }) - - s.Require().Panics(func() { - specBrokenSub := abci.Event{ - Type: bank.EventTypeCoinBurn, - } - _ = s.c.ToRosetta().BalanceOps("", []abci.Event{specBrokenSub}) - }) - - s.Require().Panics(func() { - specBrokenSub := abci.Event{ - Type: bank.EventTypeCoinReceived, - } - _ = s.c.ToRosetta().BalanceOps("", []abci.Event{specBrokenSub}) - }) - }) -} - -func TestConverterTestSuite(t *testing.T) { - suite.Run(t, new(ConverterTestSuite)) -} diff --git a/server/rosetta/lib/errors/errors.go b/server/rosetta/lib/errors/errors.go deleted file mode 100644 index 15a8470752..0000000000 --- a/server/rosetta/lib/errors/errors.go +++ /dev/null @@ -1,145 +0,0 @@ -package errors - -// errors.go contains all the errors returned by the adapter implementation -// plus some extra utilities to parse those errors - -import ( - "fmt" - - "github.com/coinbase/rosetta-sdk-go/types" - grpccodes "google.golang.org/grpc/codes" - grpcstatus "google.golang.org/grpc/status" -) - -// ListErrors lists all the registered errors -func ListErrors() []*types.Error { - return registry.list() -} - -// SealAndListErrors seals the registry and lists its errors -func SealAndListErrors() []*types.Error { - registry.seal() - return registry.list() -} - -// Error defines an error that can be converted to a Rosetta API error. -type Error struct { - rosErr *types.Error -} - -func (e *Error) Error() string { - if e.rosErr == nil { - return ErrUnknown.Error() - } - return fmt.Sprintf("rosetta: (%d) %s", e.rosErr.Code, e.rosErr.Message) -} - -// Is implements errors.Is for *Error, two errors are considered equal -// if their error codes are identical -func (e *Error) Is(err error) bool { - // assert it can be casted - rosErr, ok := err.(*Error) - if rosErr == nil || !ok { - return false - } - // check that both *Error's are correctly initialized to avoid dereference panics - if rosErr.rosErr == nil || e.rosErr == nil { - return false - } - // messages are equal if their error codes match - return rosErr.rosErr.Code == e.rosErr.Code -} - -// WrapError wraps the rosetta error with additional context -func WrapError(err *Error, msg string) *Error { - return &Error{rosErr: &types.Error{ - Code: err.rosErr.Code, - Message: err.rosErr.Message, - Description: err.rosErr.Description, - Retriable: err.rosErr.Retriable, - Details: map[string]interface{}{ - "info": msg, - }, - }} -} - -// ToRosetta attempts to converting an error into a rosetta -// error, if the error cannot be converted it will be parsed as unknown -func ToRosetta(err error) *types.Error { - // if it's null or not known - rosErr, ok := err.(*Error) - if rosErr == nil || !ok { - return ToRosetta(WrapError(ErrUnknown, ErrUnknown.Error())) - } - return rosErr.rosErr -} - -// FromGRPCToRosettaError converts a gRPC error to rosetta error -func FromGRPCToRosettaError(err error) *Error { - status, ok := grpcstatus.FromError(err) - if !ok { - return WrapError(ErrUnknown, err.Error()) - } - switch status.Code() { - case grpccodes.NotFound: - return WrapError(ErrNotFound, status.Message()) - case grpccodes.FailedPrecondition: - return WrapError(ErrBadArgument, status.Message()) - case grpccodes.InvalidArgument: - return WrapError(ErrBadArgument, status.Message()) - case grpccodes.Internal: - return WrapError(ErrInternal, status.Message()) - default: - return WrapError(ErrUnknown, status.Message()) - } -} - -func RegisterError(code int32, message string, retryable bool, description string) *Error { - e := &Error{rosErr: &types.Error{ - Code: code, - Message: message, - Description: &description, - Retriable: retryable, - Details: nil, - }} - registry.add(e) - return e -} - -// Default error list -var ( - // ErrUnknown defines an unknown error, if this is returned it means - // the library is ignoring an error - ErrUnknown = RegisterError(0, "unknown", false, "unknown error") - // ErrOffline is returned when there is an attempt to query an endpoint in offline mode - ErrOffline = RegisterError(1, "cannot query endpoint in offline mode", false, "returned when querying an online endpoint in offline mode") - // ErrNetworkNotSupported is returned when there is an attempt to query a network which is not supported - ErrNetworkNotSupported = RegisterError(2, "network is not supported", false, "returned when querying a non supported network") - // ErrCodec is returned when there's an error while marshaling or unmarshalling data - ErrCodec = RegisterError(3, "encode/decode error", true, "returned when there are errors encoding or decoding information to and from the node") - // ErrInvalidOperation is returned when the operation supplied to rosetta is not a valid one - ErrInvalidOperation = RegisterError(4, "invalid operation", false, "returned when the operation is not valid") - // ErrInvalidTransaction is returned when the provided hex bytes of a TX are not valid - ErrInvalidTransaction = RegisterError(5, "invalid transaction", false, "returned when the transaction is invalid") - // ErrInvalidAddress is returned when the byte of the address are bad - ErrInvalidAddress = RegisterError(7, "invalid address", false, "returned when the address is malformed") - // ErrInvalidPubkey is returned when the public key is invalid - ErrInvalidPubkey = RegisterError(8, "invalid pubkey", false, "returned when the public key is invalid") - // ErrInterpreting is returned when there are errors interpreting the data from the node, most likely related to breaking changes, version incompatibilities - ErrInterpreting = RegisterError(9, "error interpreting data from node", false, "returned when there are issues interpreting requests or response from node") - ErrInvalidMemo = RegisterError(11, "invalid memo", false, "returned when the memo is invalid") - // ErrBadArgument is returned when the request is malformed - ErrBadArgument = RegisterError(400, "bad argument", false, "request is malformed") - // ErrNotFound is returned when the required object was not found - // retry is set to true because something that is not found now - // might be found later, example: a TX - ErrNotFound = RegisterError(404, "not found", true, "returned when the node does not find what the client is asking for") - // ErrInternal is returned when the node is experiencing internal errors - ErrInternal = RegisterError(500, "internal error", false, "returned when the node experiences internal errors") - // ErrBadGateway is returned when there are problems interacting with the nodes - ErrBadGateway = RegisterError(502, "bad gateway", true, "return when the node is unreachable") - // ErrNotImplemented is returned when a method is not implemented yet - ErrNotImplemented = RegisterError(14, "not implemented", false, "returned when querying an endpoint which is not implemented") - // ErrUnsupportedCurve is returned when the curve specified is not supported - ErrUnsupportedCurve = RegisterError(15, "unsupported curve, expected secp256k1", false, "returned when using an unsupported crypto curve") -) diff --git a/server/rosetta/lib/errors/errors_test.go b/server/rosetta/lib/errors/errors_test.go deleted file mode 100644 index f3fa6a7923..0000000000 --- a/server/rosetta/lib/errors/errors_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package errors - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestRegisterError(t *testing.T) { - var error *Error - // this is the number of errors registered by default in errors.go - registeredErrorsCount := 16 - assert.Equal(t, len(registry.list()), registeredErrorsCount) - assert.ElementsMatch(t, registry.list(), ListErrors()) - // add a new Error - error = RegisterError(69, "nice!", false, "nice!") - assert.NotNil(t, error) - // now we have a new error - registeredErrorsCount++ - assert.Equal(t, len(ListErrors()), registeredErrorsCount) - // re-register an error should not change anything - error = RegisterError(69, "nice!", false, "nice!") - assert.NotNil(t, error) - assert.Equal(t, len(ListErrors()), registeredErrorsCount) - - // test sealing - assert.Equal(t, registry.sealed, false) - errors := SealAndListErrors() - assert.Equal(t, registry.sealed, true) - assert.Equal(t, len(errors), registeredErrorsCount) - // add a new error on a sealed registry - error = RegisterError(1024, "bytes", false, "bytes") - assert.NotNil(t, error) -} - -func TestError_Error(t *testing.T) { - var error *Error - // nil cases - assert.False(t, ErrOffline.Is(error)) - error = &Error{} - assert.False(t, ErrOffline.Is(error)) - // wrong type - assert.False(t, ErrOffline.Is(&MyError{})) - // test with wrapping an error - error = WrapError(ErrOffline, "offline") - assert.True(t, ErrOffline.Is(error)) - - // test equality - assert.False(t, ErrOffline.Is(ErrBadGateway)) - assert.True(t, ErrBadGateway.Is(ErrBadGateway)) -} - -func TestToRosetta(t *testing.T) { - var error *Error - // nil case - assert.NotNil(t, ToRosetta(error)) - // wrong type - assert.NotNil(t, ToRosetta(&MyError{})) -} - -type MyError struct{} - -func (e *MyError) Error() string { - return "" -} - -func (e *MyError) Is(err error) bool { - return true -} diff --git a/server/rosetta/lib/errors/registry.go b/server/rosetta/lib/errors/registry.go deleted file mode 100644 index 9cbafcacf7..0000000000 --- a/server/rosetta/lib/errors/registry.go +++ /dev/null @@ -1,48 +0,0 @@ -package errors - -import ( - "fmt" - "os" - "sync" - - "github.com/coinbase/rosetta-sdk-go/types" -) - -type errorRegistry struct { - mu *sync.RWMutex - sealed bool - errors map[int32]*types.Error -} - -func (r *errorRegistry) add(err *Error) { - r.mu.Lock() - defer r.mu.Unlock() - if r.sealed { - _, _ = fmt.Fprintln(os.Stderr, "[ROSETTA] WARNING: attempts to register errors after seal will be ignored") - } - if _, ok := r.errors[err.rosErr.Code]; ok { - _, _ = fmt.Fprintln(os.Stderr, "[ROSETTA] WARNING: attempts to register an already registered error will be ignored, code: ", err.rosErr.Code) - } - r.errors[err.rosErr.Code] = err.rosErr -} - -func (r errorRegistry) list() []*types.Error { - r.mu.RLock() - defer r.mu.RUnlock() - rosErrs := make([]*types.Error, 0, len(registry.errors)) - for _, v := range r.errors { - rosErrs = append(rosErrs, v) - } - return rosErrs -} - -func (r *errorRegistry) seal() { - r.mu.Lock() - defer r.mu.Unlock() - r.sealed = true -} - -var registry = errorRegistry{ - mu: new(sync.RWMutex), - errors: make(map[int32]*types.Error), -} diff --git a/server/rosetta/lib/internal/service/construction.go b/server/rosetta/lib/internal/service/construction.go deleted file mode 100644 index 4b53941a8f..0000000000 --- a/server/rosetta/lib/internal/service/construction.go +++ /dev/null @@ -1,137 +0,0 @@ -package service - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "strings" - - "github.com/coinbase/rosetta-sdk-go/types" - - "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" -) - -// ConstructionCombine Combine creates a network-specific transaction from an unsigned transaction -// and an array of provided signatures. The signed transaction returned from this method will be -// sent to the /construction/submit endpoint by the caller. -func (on OnlineNetwork) ConstructionCombine(ctx context.Context, request *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error) { - txBytes, err := hex.DecodeString(request.UnsignedTransaction) - if err != nil { - return nil, errors.ToRosetta(err) - } - - signedTx, err := on.client.SignedTx(ctx, txBytes, request.Signatures) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.ConstructionCombineResponse{ - SignedTransaction: hex.EncodeToString(signedTx), - }, nil -} - -// ConstructionDerive Derive returns the AccountIdentifier associated with a public key. -func (on OnlineNetwork) ConstructionDerive(_ context.Context, request *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error) { - account, err := on.client.AccountIdentifierFromPublicKey(request.PublicKey) - if err != nil { - return nil, errors.ToRosetta(err) - } - return &types.ConstructionDeriveResponse{ - AccountIdentifier: account, - Metadata: nil, - }, nil -} - -// ConstructionHash TransactionHash returns the network-specific transaction hash for a signed -// transaction. -func (on OnlineNetwork) ConstructionHash(ctx context.Context, request *types.ConstructionHashRequest) (*types.TransactionIdentifierResponse, *types.Error) { - bz, err := hex.DecodeString(request.SignedTransaction) - if err != nil { - return nil, errors.ToRosetta(errors.WrapError(errors.ErrInvalidTransaction, "error decoding tx")) - } - - hash := sha256.Sum256(bz) - bzHash := hash[:] - hashString := hex.EncodeToString(bzHash) - - return &types.TransactionIdentifierResponse{ - TransactionIdentifier: &types.TransactionIdentifier{ - Hash: strings.ToUpper(hashString), - }, - }, nil -} - -// ConstructionMetadata Get any information required to construct a transaction for a specific -// network (i.e. ChainID, Gas, Memo, ...). -func (on OnlineNetwork) ConstructionMetadata(ctx context.Context, request *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error) { - metadata, err := on.client.ConstructionMetadataFromOptions(ctx, request.Options) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.ConstructionMetadataResponse{ - Metadata: metadata, - }, nil -} - -// ConstructionParse Parse is called on both unsigned and signed transactions to understand the -// intent of the formulated transaction. This is run as a sanity check before signing (after -// /construction/payloads) and before broadcast (after /construction/combine). -func (on OnlineNetwork) ConstructionParse(ctx context.Context, request *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error) { - txBytes, err := hex.DecodeString(request.Transaction) - if err != nil { - err := errors.WrapError(errors.ErrInvalidTransaction, err.Error()) - return nil, errors.ToRosetta(err) - } - ops, signers, err := on.client.TxOperationsAndSignersAccountIdentifiers(request.Signed, txBytes) - if err != nil { - return nil, errors.ToRosetta(err) - } - return &types.ConstructionParseResponse{ - Operations: ops, - AccountIdentifierSigners: signers, - Metadata: nil, - }, nil -} - -// ConstructionPayloads Payloads is called with an array of operations and the response from -// /construction/metadata. It returns an unsigned transaction blob and a collection of payloads that -// must be signed by particular AccountIdentifiers using a certain SignatureType. -func (on OnlineNetwork) ConstructionPayloads(ctx context.Context, request *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error) { - payload, err := on.client.ConstructionPayload(ctx, request) - if err != nil { - return nil, errors.ToRosetta(err) - } - return payload, nil -} - -// ConstructionPreprocess Preprocess is called prior to /construction/payloads to construct a -// request for any metadata that is needed for transaction construction given (i.e. account nonce). -func (on OnlineNetwork) ConstructionPreprocess(ctx context.Context, request *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error) { - options, err := on.client.PreprocessOperationsToOptions(ctx, request) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return options, nil -} - -// ConstructionSubmit Submit a pre-signed transaction to the node. This call does not block on the -// transaction being included in a block. Rather, it returns immediately with an indication of -// whether or not the transaction was included in the mempool. -func (on OnlineNetwork) ConstructionSubmit(ctx context.Context, request *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error) { - txBytes, err := hex.DecodeString(request.SignedTransaction) - if err != nil { - return nil, errors.ToRosetta(err) - } - - res, meta, err := on.client.PostTx(txBytes) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.TransactionIdentifierResponse{ - TransactionIdentifier: res, - Metadata: meta, - }, nil -} diff --git a/server/rosetta/lib/internal/service/data.go b/server/rosetta/lib/internal/service/data.go deleted file mode 100644 index 57e27e2cc2..0000000000 --- a/server/rosetta/lib/internal/service/data.go +++ /dev/null @@ -1,159 +0,0 @@ -package service - -import ( - "context" - - "github.com/coinbase/rosetta-sdk-go/types" - - "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" -) - -// AccountBalance retrieves the account balance of an address -// rosetta requires us to fetch the block information too -func (on OnlineNetwork) AccountBalance(ctx context.Context, request *types.AccountBalanceRequest) (*types.AccountBalanceResponse, *types.Error) { - var ( - height int64 - block crgtypes.BlockResponse - err error - ) - - switch { - case request.BlockIdentifier == nil: - block, err = on.client.BlockByHeight(ctx, nil) - if err != nil { - return nil, errors.ToRosetta(err) - } - case request.BlockIdentifier.Hash != nil: - block, err = on.client.BlockByHash(ctx, *request.BlockIdentifier.Hash) - if err != nil { - return nil, errors.ToRosetta(err) - } - height = block.Block.Index - case request.BlockIdentifier.Index != nil: - height = *request.BlockIdentifier.Index - block, err = on.client.BlockByHeight(ctx, &height) - if err != nil { - return nil, errors.ToRosetta(err) - } - } - - accountCoins, err := on.client.Balances(ctx, request.AccountIdentifier.Address, &height) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.AccountBalanceResponse{ - BlockIdentifier: block.Block, - Balances: accountCoins, - Metadata: nil, - }, nil -} - -// Block gets the transactions in the given block -func (on OnlineNetwork) Block(ctx context.Context, request *types.BlockRequest) (*types.BlockResponse, *types.Error) { - var ( - blockResponse crgtypes.BlockTransactionsResponse - err error - ) - // block identifier is assumed not to be nil as rosetta will do this check for us - // check if we have to query via hash or block number - switch { - case request.BlockIdentifier.Hash != nil: - blockResponse, err = on.client.BlockTransactionsByHash(ctx, *request.BlockIdentifier.Hash) - if err != nil { - return nil, errors.ToRosetta(err) - } - case request.BlockIdentifier.Index != nil: - blockResponse, err = on.client.BlockTransactionsByHeight(ctx, request.BlockIdentifier.Index) - if err != nil { - return nil, errors.ToRosetta(err) - } - default: - err := errors.WrapError(errors.ErrBadArgument, "at least one of hash or index needs to be specified") - return nil, errors.ToRosetta(err) - } - - return &types.BlockResponse{ - Block: &types.Block{ - BlockIdentifier: blockResponse.Block, - ParentBlockIdentifier: blockResponse.ParentBlock, - Timestamp: blockResponse.MillisecondTimestamp, - Transactions: blockResponse.Transactions, - Metadata: nil, - }, - OtherTransactions: nil, - }, nil -} - -// BlockTransaction gets the given transaction in the specified block, we do not need to check the block itself too -// due to the fact that tendermint achieves instant finality -func (on OnlineNetwork) BlockTransaction(ctx context.Context, request *types.BlockTransactionRequest) (*types.BlockTransactionResponse, *types.Error) { - tx, err := on.client.GetTx(ctx, request.TransactionIdentifier.Hash) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.BlockTransactionResponse{ - Transaction: tx, - }, nil -} - -// Mempool fetches the transactions contained in the mempool -func (on OnlineNetwork) Mempool(ctx context.Context, _ *types.NetworkRequest) (*types.MempoolResponse, *types.Error) { - txs, err := on.client.Mempool(ctx) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.MempoolResponse{ - TransactionIdentifiers: txs, - }, nil -} - -// MempoolTransaction fetches a single transaction in the mempool -// NOTE: it is not implemented yet -func (on OnlineNetwork) MempoolTransaction(ctx context.Context, request *types.MempoolTransactionRequest) (*types.MempoolTransactionResponse, *types.Error) { - tx, err := on.client.GetUnconfirmedTx(ctx, request.TransactionIdentifier.Hash) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.MempoolTransactionResponse{ - Transaction: tx, - }, nil -} - -func (on OnlineNetwork) NetworkList(_ context.Context, _ *types.MetadataRequest) (*types.NetworkListResponse, *types.Error) { - return &types.NetworkListResponse{NetworkIdentifiers: []*types.NetworkIdentifier{on.network}}, nil -} - -func (on OnlineNetwork) NetworkOptions(_ context.Context, _ *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error) { - return on.networkOptions, nil -} - -func (on OnlineNetwork) NetworkStatus(ctx context.Context, _ *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error) { - block, err := on.client.BlockByHeight(ctx, nil) - if err != nil { - return nil, errors.ToRosetta(err) - } - - peers, err := on.client.Peers(ctx) - if err != nil { - return nil, errors.ToRosetta(err) - } - - syncStatus, err := on.client.Status(ctx) - if err != nil { - return nil, errors.ToRosetta(err) - } - - return &types.NetworkStatusResponse{ - CurrentBlockIdentifier: block.Block, - CurrentBlockTimestamp: block.MillisecondTimestamp, - GenesisBlockIdentifier: on.genesisBlockIdentifier, - OldestBlockIdentifier: nil, - SyncStatus: syncStatus, - Peers: peers, - }, nil -} diff --git a/server/rosetta/lib/internal/service/offline.go b/server/rosetta/lib/internal/service/offline.go deleted file mode 100644 index eb882466a2..0000000000 --- a/server/rosetta/lib/internal/service/offline.go +++ /dev/null @@ -1,63 +0,0 @@ -package service - -import ( - "context" - - "github.com/coinbase/rosetta-sdk-go/types" - - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" -) - -// NewOffline instantiates the instance of an offline network -// whilst the offline network does not support the DataAPI, -// it supports a subset of the construction API. -func NewOffline(network *types.NetworkIdentifier, client crgtypes.Client) (crgtypes.API, error) { - return OfflineNetwork{ - OnlineNetwork{ - client: client, - network: network, - networkOptions: networkOptionsFromClient(client, nil), - }, - }, nil -} - -// OfflineNetwork implements an offline data API -// which is basically a data API that constantly -// returns errors, because it cannot be used if offline -type OfflineNetwork struct { - OnlineNetwork -} - -// Implement DataAPI in offline mode, which means no method is available -func (o OfflineNetwork) AccountBalance(_ context.Context, _ *types.AccountBalanceRequest) (*types.AccountBalanceResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) Block(_ context.Context, _ *types.BlockRequest) (*types.BlockResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) BlockTransaction(_ context.Context, _ *types.BlockTransactionRequest) (*types.BlockTransactionResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) Mempool(_ context.Context, _ *types.NetworkRequest) (*types.MempoolResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) MempoolTransaction(_ context.Context, _ *types.MempoolTransactionRequest) (*types.MempoolTransactionResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) NetworkStatus(_ context.Context, _ *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) ConstructionSubmit(_ context.Context, _ *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -func (o OfflineNetwork) ConstructionMetadata(_ context.Context, _ *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} diff --git a/server/rosetta/lib/internal/service/online.go b/server/rosetta/lib/internal/service/online.go deleted file mode 100644 index 1bb69d5011..0000000000 --- a/server/rosetta/lib/internal/service/online.go +++ /dev/null @@ -1,71 +0,0 @@ -package service - -import ( - "context" - "time" - - "github.com/coinbase/rosetta-sdk-go/types" - - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" -) - -// genesisBlockFetchTimeout defines a timeout to fetch the genesis block -const genesisBlockFetchTimeout = 15 * time.Second - -// NewOnlineNetwork builds a single network adapter. -// It will get the Genesis block on the beginning to avoid calling it everytime. -func NewOnlineNetwork(network *types.NetworkIdentifier, client crgtypes.Client) (crgtypes.API, error) { - ctx, cancel := context.WithTimeout(context.Background(), genesisBlockFetchTimeout) - defer cancel() - - var genesisHeight int64 = -1 // to use initial_height in genesis.json - block, err := client.BlockByHeight(ctx, &genesisHeight) - if err != nil { - return OnlineNetwork{}, err - } - - return OnlineNetwork{ - client: client, - network: network, - networkOptions: networkOptionsFromClient(client, block.Block), - genesisBlockIdentifier: block.Block, - }, nil -} - -// OnlineNetwork groups together all the components required for the full rosetta implementation -type OnlineNetwork struct { - client crgtypes.Client // used to query cosmos app + tendermint - - network *types.NetworkIdentifier // identifies the network, it's static - networkOptions *types.NetworkOptionsResponse // identifies the network options, it's static - - genesisBlockIdentifier *types.BlockIdentifier // identifies genesis block, it's static -} - -// AccountsCoins - relevant only for UTXO based chain -// see https://www.rosetta-api.org/docs/AccountApi.html#accountcoins -func (o OnlineNetwork) AccountCoins(_ context.Context, _ *types.AccountCoinsRequest) (*types.AccountCoinsResponse, *types.Error) { - return nil, crgerrs.ToRosetta(crgerrs.ErrOffline) -} - -// networkOptionsFromClient builds network options given the client -func networkOptionsFromClient(client crgtypes.Client, genesisBlock *types.BlockIdentifier) *types.NetworkOptionsResponse { - var tsi *int64 - if genesisBlock != nil { - tsi = &(genesisBlock.Index) - } - return &types.NetworkOptionsResponse{ - Version: &types.Version{ - RosettaVersion: crgtypes.SpecVersion, - NodeVersion: client.Version(), - }, - Allow: &types.Allow{ - OperationStatuses: client.OperationStatuses(), - OperationTypes: client.SupportedOperations(), - Errors: crgerrs.SealAndListErrors(), - HistoricalBalanceLookup: true, - TimestampStartIndex: tsi, - }, - } -} diff --git a/server/rosetta/lib/server/server.go b/server/rosetta/lib/server/server.go deleted file mode 100644 index 560275bdf2..0000000000 --- a/server/rosetta/lib/server/server.go +++ /dev/null @@ -1,117 +0,0 @@ -package server - -import ( - "fmt" - "net/http" - "time" - - assert "github.com/coinbase/rosetta-sdk-go/asserter" - "github.com/coinbase/rosetta-sdk-go/server" - "github.com/coinbase/rosetta-sdk-go/types" - - "github.com/Finschia/finschia-sdk/server/rosetta/lib/internal/service" - crgtypes "github.com/Finschia/finschia-sdk/server/rosetta/lib/types" -) - -const ( - DefaultRetries = 5 - DefaultRetryWait = 5 * time.Second -) - -// Settings define the rosetta server settings -type Settings struct { - // Network contains the information regarding the network - Network *types.NetworkIdentifier - // Client is the online API handler - Client crgtypes.Client - // Listen is the address the handler will listen at - Listen string - // Offline defines if the rosetta service should be exposed in offline mode - Offline bool - // Retries is the number of readiness checks that will be attempted when instantiating the handler - // valid only for online API - Retries int - // RetryWait is the time that will be waited between retries - RetryWait time.Duration -} - -type Server struct { - h http.Handler - addr string -} - -func (h Server) Start() error { - return http.ListenAndServe(h.addr, h.h) //nolint:gosec -} - -func NewServer(settings Settings) (Server, error) { - asserter, err := assert.NewServer( - settings.Client.SupportedOperations(), - true, - []*types.NetworkIdentifier{settings.Network}, - nil, - false, - "", - ) - if err != nil { - return Server{}, fmt.Errorf("cannot build asserter: %w", err) - } - - var adapter crgtypes.API - switch settings.Offline { - case true: - adapter, err = newOfflineAdapter(settings) - case false: - adapter, err = newOnlineAdapter(settings) - } - if err != nil { - return Server{}, err - } - h := server.NewRouter( - server.NewAccountAPIController(adapter, asserter), - server.NewBlockAPIController(adapter, asserter), - server.NewNetworkAPIController(adapter, asserter), - server.NewMempoolAPIController(adapter, asserter), - server.NewConstructionAPIController(adapter, asserter), - ) - - return Server{ - h: h, - addr: settings.Listen, - }, nil -} - -func newOfflineAdapter(settings Settings) (crgtypes.API, error) { - if settings.Client == nil { - return nil, fmt.Errorf("client is nil") - } - return service.NewOffline(settings.Network, settings.Client) -} - -func newOnlineAdapter(settings Settings) (crgtypes.API, error) { - if settings.Client == nil { - return nil, fmt.Errorf("client is nil") - } - if settings.Retries <= 0 { - settings.Retries = DefaultRetries - } - if settings.RetryWait == 0 { - settings.RetryWait = DefaultRetryWait - } - - var err error - err = settings.Client.Bootstrap() - if err != nil { - return nil, err - } - - for i := 0; i < settings.Retries; i++ { - err = settings.Client.Ready() - if err != nil { - time.Sleep(settings.RetryWait) - continue - } - return service.NewOnlineNetwork(settings.Network, settings.Client) - } - return nil, fmt.Errorf("maximum number of retries exceeded, last error: %w", err) -} diff --git a/server/rosetta/lib/types/types.go b/server/rosetta/lib/types/types.go deleted file mode 100644 index 4f734c34fb..0000000000 --- a/server/rosetta/lib/types/types.go +++ /dev/null @@ -1,164 +0,0 @@ -package types - -import ( - "context" - - "github.com/coinbase/rosetta-sdk-go/server" - "github.com/coinbase/rosetta-sdk-go/types" -) - -// SpecVersion defines the specification of rosetta -const SpecVersion = "" - -// NetworkInformationProvider defines the interface used to provide information regarding -// the network and the version of the cosmos sdk used -type NetworkInformationProvider interface { - // SupportedOperations lists the operations supported by the implementation - SupportedOperations() []string - // OperationStatuses returns the list of statuses supported by the implementation - OperationStatuses() []*types.OperationStatus - // Version returns the version of the node - Version() string -} - -// Client defines the API the client implementation should provide. -type Client interface { - // Bootstrap Needed if the client needs to perform some action before connecting. - Bootstrap() error - // Ready checks if the servicer constraints for queries are satisfied - // for example the node might still not be ready, it's useful in process - // when the rosetta instance might come up before the node itself - // the servicer must return nil if the node is ready - Ready() error - - // Data API - - // Balances fetches the balance of the given address - // if height is not nil, then the balance will be displayed - // at the provided height, otherwise last block balance will be returned - Balances(ctx context.Context, addr string, height *int64) ([]*types.Amount, error) - // BlockByHash gets a block and its transaction at the provided height - BlockByHash(ctx context.Context, hash string) (BlockResponse, error) - // BlockByHeight gets a block given its height, if height is nil then last block is returned - BlockByHeight(ctx context.Context, height *int64) (BlockResponse, error) - // BlockTransactionsByHash gets the block, parent block and transactions - // given the block hash. - BlockTransactionsByHash(ctx context.Context, hash string) (BlockTransactionsResponse, error) - // BlockTransactionsByHeight gets the block, parent block and transactions - // given the block hash. - BlockTransactionsByHeight(ctx context.Context, height *int64) (BlockTransactionsResponse, error) - // GetTx gets a transaction given its hash - GetTx(ctx context.Context, hash string) (*types.Transaction, error) - // GetUnconfirmedTx gets an unconfirmed Tx given its hash - // NOTE(fdymylja): NOT IMPLEMENTED YET! - GetUnconfirmedTx(ctx context.Context, hash string) (*types.Transaction, error) - // Mempool returns the list of the current non confirmed transactions - Mempool(ctx context.Context) ([]*types.TransactionIdentifier, error) - // Peers gets the peers currently connected to the node - Peers(ctx context.Context) ([]*types.Peer, error) - // Status returns the node status, such as sync data, version etc - Status(ctx context.Context) (*types.SyncStatus, error) - - // Construction API - - // PostTx posts txBytes to the node and returns the transaction identifier plus metadata related - // to the transaction itself. - PostTx(txBytes []byte) (res *types.TransactionIdentifier, meta map[string]interface{}, err error) - // ConstructionMetadataFromOptions builds metadata map from an option map - ConstructionMetadataFromOptions(ctx context.Context, options map[string]interface{}) (meta map[string]interface{}, err error) - OfflineClient -} - -// OfflineClient defines the functionalities supported without having access to the node -type OfflineClient interface { - NetworkInformationProvider - // SignedTx returns the signed transaction given the tx bytes (msgs) plus the signatures - SignedTx(ctx context.Context, txBytes []byte, sigs []*types.Signature) (signedTxBytes []byte, err error) - // TxOperationsAndSignersAccountIdentifiers returns the operations related to a transaction and the account - // identifiers if the transaction is signed - TxOperationsAndSignersAccountIdentifiers(signed bool, hexBytes []byte) (ops []*types.Operation, signers []*types.AccountIdentifier, err error) - // ConstructionPayload returns the construction payload given the request - ConstructionPayload(ctx context.Context, req *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error) - // PreprocessOperationsToOptions returns the options given the preprocess operations - PreprocessOperationsToOptions(ctx context.Context, req *types.ConstructionPreprocessRequest) (resp *types.ConstructionPreprocessResponse, err error) - // AccountIdentifierFromPublicKey returns the account identifier given the public key - AccountIdentifierFromPublicKey(pubKey *types.PublicKey) (*types.AccountIdentifier, error) -} - -type BlockTransactionsResponse struct { - BlockResponse - Transactions []*types.Transaction -} - -type BlockResponse struct { - Block *types.BlockIdentifier - ParentBlock *types.BlockIdentifier - MillisecondTimestamp int64 - TxCount int64 -} - -// API defines the exposed APIs -// if the service is online -type API interface { - DataAPI - ConstructionAPI -} - -// DataAPI defines the full data API implementation -type DataAPI interface { - server.NetworkAPIServicer - server.AccountAPIServicer - server.BlockAPIServicer - server.MempoolAPIServicer -} - -var _ server.ConstructionAPIServicer = ConstructionAPI(nil) - -// ConstructionAPI defines the full construction API with -// the online and offline endpoints -type ConstructionAPI interface { - ConstructionOnlineAPI - ConstructionOfflineAPI -} - -// ConstructionOnlineAPI defines the construction methods -// allowed in an online implementation -type ConstructionOnlineAPI interface { - ConstructionMetadata( - context.Context, - *types.ConstructionMetadataRequest, - ) (*types.ConstructionMetadataResponse, *types.Error) - ConstructionSubmit( - context.Context, - *types.ConstructionSubmitRequest, - ) (*types.TransactionIdentifierResponse, *types.Error) -} - -// ConstructionOfflineAPI defines the construction methods -// allowed -type ConstructionOfflineAPI interface { - ConstructionCombine( - context.Context, - *types.ConstructionCombineRequest, - ) (*types.ConstructionCombineResponse, *types.Error) - ConstructionDerive( - context.Context, - *types.ConstructionDeriveRequest, - ) (*types.ConstructionDeriveResponse, *types.Error) - ConstructionHash( - context.Context, - *types.ConstructionHashRequest, - ) (*types.TransactionIdentifierResponse, *types.Error) - ConstructionParse( - context.Context, - *types.ConstructionParseRequest, - ) (*types.ConstructionParseResponse, *types.Error) - ConstructionPayloads( - context.Context, - *types.ConstructionPayloadsRequest, - ) (*types.ConstructionPayloadsResponse, *types.Error) - ConstructionPreprocess( - context.Context, - *types.ConstructionPreprocessRequest, - ) (*types.ConstructionPreprocessResponse, *types.Error) -} diff --git a/server/rosetta/types.go b/server/rosetta/types.go deleted file mode 100644 index 0d1eada892..0000000000 --- a/server/rosetta/types.go +++ /dev/null @@ -1,104 +0,0 @@ -package rosetta - -import ( - "crypto/sha256" -) - -// statuses -const ( - StatusTxSuccess = "Success" - StatusTxReverted = "Reverted" - StatusPeerSynced = "synced" - StatusPeerSyncing = "syncing" -) - -// In rosetta all state transitions must be represented as transactions -// since in tendermint begin block and end block are state transitions -// which are not represented as transactions we mock only the balance changes -// happening at those levels as transactions. (check BeginBlockTxHash for more info) -const ( - DeliverTxSize = sha256.Size - BeginEndBlockTxSize = DeliverTxSize + 1 - EndBlockHashStart = 0x0 - BeginBlockHashStart = 0x1 -) - -const ( - // BurnerAddressIdentifier mocks the account identifier of a burner address - // all coins burned in the sdk will be sent to this identifier, which per sdk.AccAddress - // design we will never be able to query (as of now). - // Rosetta does not understand supply contraction. - BurnerAddressIdentifier = "burner" -) - -// TransactionType is used to distinguish if a rosetta provided hash -// represents endblock, beginblock or deliver tx -type TransactionType int - -const ( - UnrecognizedTx TransactionType = iota - BeginBlockTx - EndBlockTx - DeliverTxTx -) - -// metadata options - -// misc -const ( - Log = "log" -) - -// ConstructionPreprocessMetadata is used to represent -// the metadata rosetta can provide during preprocess options -type ConstructionPreprocessMetadata struct { - Memo string `json:"memo"` - GasLimit uint64 `json:"gas_limit"` - GasPrice string `json:"gas_price"` -} - -func (c *ConstructionPreprocessMetadata) FromMetadata(meta map[string]interface{}) error { - return unmarshalMetadata(meta, c) -} - -// PreprocessOperationsOptionsResponse is the structured metadata options returned by the preprocess operations endpoint -type PreprocessOperationsOptionsResponse struct { - ExpectedSigners []string `json:"expected_signers"` - Memo string `json:"memo"` - GasLimit uint64 `json:"gas_limit"` - GasPrice string `json:"gas_price"` -} - -func (c PreprocessOperationsOptionsResponse) ToMetadata() (map[string]interface{}, error) { - return marshalMetadata(c) -} - -func (c *PreprocessOperationsOptionsResponse) FromMetadata(meta map[string]interface{}) error { - return unmarshalMetadata(meta, c) -} - -// SignerData contains information on the signers when the request -// is being created, used to populate the account information -type SignerData struct { - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` -} - -// ConstructionMetadata are the metadata options used to -// construct a transaction. It is returned by ConstructionMetadataFromOptions -// and fed to ConstructionPayload to process the bytes to sign. -type ConstructionMetadata struct { - ChainID string `json:"chain_id"` - SignersData []*SignerData `json:"signer_data"` - GasLimit uint64 `json:"gas_limit"` - GasPrice string `json:"gas_price"` - Memo string `json:"memo"` -} - -func (c ConstructionMetadata) ToMetadata() (map[string]interface{}, error) { - return marshalMetadata(c) -} - -func (c *ConstructionMetadata) FromMetadata(meta map[string]interface{}) error { - return unmarshalMetadata(meta, c) -} diff --git a/server/rosetta/util.go b/server/rosetta/util.go deleted file mode 100644 index e45bbdece4..0000000000 --- a/server/rosetta/util.go +++ /dev/null @@ -1,43 +0,0 @@ -package rosetta - -import ( - "encoding/json" - "time" - - crgerrs "github.com/Finschia/finschia-sdk/server/rosetta/lib/errors" -) - -// timeToMilliseconds converts time to milliseconds timestamp -func timeToMilliseconds(t time.Time) int64 { - return t.UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond)) -} - -// unmarshalMetadata unmarshals the given meta to the target -func unmarshalMetadata(meta map[string]interface{}, target interface{}) error { - b, err := json.Marshal(meta) - if err != nil { - return crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - err = json.Unmarshal(b, target) - if err != nil { - return crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - - return nil -} - -// marshalMetadata marshals the given interface to map[string]interface{} -func marshalMetadata(o interface{}) (meta map[string]interface{}, err error) { - b, err := json.Marshal(o) - if err != nil { - return nil, crgerrs.WrapError(crgerrs.ErrCodec, err.Error()) - } - meta = make(map[string]interface{}) - err = json.Unmarshal(b, &meta) - if err != nil { - return nil, err - } - - return -} diff --git a/server/start.go b/server/start.go index 8313fe41ee..54484f4d4c 100644 --- a/server/start.go +++ b/server/start.go @@ -3,24 +3,30 @@ package server // DONTCOVER import ( + "context" "fmt" - "net/http" + "io" + "net" "os" "runtime/pprof" "strings" - "time" + "github.com/hashicorp/go-metrics" "github.com/spf13/cobra" "github.com/tendermint/tendermint/abci/server" tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" - "github.com/tendermint/tendermint/config" - tmos "github.com/tendermint/tendermint/libs/os" + tmcfg "github.com/tendermint/tendermint/config" + tmlog "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/p2p" pvm "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" "github.com/tendermint/tendermint/rpc/client/local" + tmtypes "github.com/tendermint/tendermint/types" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/flags" @@ -28,13 +34,12 @@ import ( "github.com/Finschia/finschia-sdk/server/api" serverconfig "github.com/Finschia/finschia-sdk/server/config" servergrpc "github.com/Finschia/finschia-sdk/server/grpc" - "github.com/Finschia/finschia-sdk/server/rosetta" - crgserver "github.com/Finschia/finschia-sdk/server/rosetta/lib/server" "github.com/Finschia/finschia-sdk/server/types" "github.com/Finschia/finschia-sdk/store/cache" "github.com/Finschia/finschia-sdk/store/iavl" storetypes "github.com/Finschia/finschia-sdk/store/types" "github.com/Finschia/finschia-sdk/telemetry" + "github.com/Finschia/finschia-sdk/version" ) // Tendermint full-node start flags @@ -68,11 +73,9 @@ const ( FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent" // gRPC-related flags - flagGRPCOnly = "grpc-only" - flagGRPCEnable = "grpc.enable" - flagGRPCAddress = "grpc.address" - flagGRPCWebEnable = "grpc-web.enable" - flagGRPCWebAddress = "grpc-web.address" + flagGRPCOnly = "grpc-only" + flagGRPCEnable = "grpc.enable" + flagGRPCAddress = "grpc.address" ) // StartCmd runs the service passed in, either stand-alone or in-process with @@ -121,29 +124,49 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. return err }, RunE: func(cmd *cobra.Command, _ []string) error { - serverCtx := GetServerContextFromCmd(cmd) + svrCtx := GetServerContextFromCmd(cmd) clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } - withTM, _ := cmd.Flags().GetBool(flagWithTendermint) - if !withTM { - serverCtx.Logger.Info("starting ABCI without Tendermint") - return startStandAlone(serverCtx, appCreator) + svrCfg, err := getAndValidateConfig(svrCtx) + if err != nil { + return err } - serverCtx.Logger.Info("starting ABCI with Tendermint") + tmetrics, err := startTelemetry(svrCfg) + if err != nil { + return err + } + + emitServerInfoMetrics() - // amino is needed here for backwards compatibility of REST routes - err = startInProcess(serverCtx, clientCtx, appCreator) - errCode, ok := err.(ErrorCode) - if !ok { + db, err := openDB(svrCtx.Config.RootDir) + if err != nil { return err } - serverCtx.Logger.Debug(fmt.Sprintf("received quit signal: %d", errCode.Code)) - return nil + traceWriter, traceCleanupFn, err := SetupTraceWriter(svrCtx.Logger, svrCtx.Viper.GetString(flagTraceStore)) + if err != nil { + return err + } + defer traceCleanupFn() + + app := appCreator(svrCtx.Logger, db, traceWriter, svrCtx.Viper) + + withTM, _ := cmd.Flags().GetBool(flagWithTendermint) + if !withTM { + svrCtx.Logger.Info("starting ABCI without Tendermint") + + return wrapCPUProfile(svrCtx, func() error { + return startStandAlone(svrCtx, svrCfg, clientCtx, app, tmetrics) + }) + } + + return wrapCPUProfile(svrCtx, func() error { + return startInProcess(svrCtx, svrCfg, clientCtx, app, tmetrics) + }) }, } @@ -172,9 +195,6 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Bool(flagGRPCEnable, true, "Define if the gRPC server should be enabled") cmd.Flags().String(flagGRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on") - cmd.Flags().Bool(flagGRPCWebEnable, true, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)") - cmd.Flags().String(flagGRPCWebAddress, serverconfig.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on") - cmd.Flags().Uint64(FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval") cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") @@ -187,298 +207,355 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. return cmd } -func startStandAlone(ctx *Context, appCreator types.AppCreator) error { - addr := ctx.Viper.GetString(flagAddress) - transport := ctx.Viper.GetString(flagTransport) - home := ctx.Viper.GetString(flags.FlagHome) - - db, err := openDB(home) +func startStandAlone(svrCtx *Context, svrCfg serverconfig.Config, clientCtx client.Context, app types.Application, tmetrics *telemetry.Metrics) error { + svr, err := server.NewServer(svrCtx.Viper.GetString(flagAddress), svrCtx.Viper.GetString(flagTransport), app) if err != nil { - return err + return fmt.Errorf("error creating listener: %w", err) } - traceWriterFile := ctx.Viper.GetString(flagTraceStore) - traceWriter, err := openTraceWriter(traceWriterFile) - if err != nil { - return err - } + svr.SetLogger(svrCtx.Logger.With("module", "abci-server")) - app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper) + g, ctx := getCtx(svrCtx, false) - config, err := serverconfig.GetConfig(ctx.Viper) - if err != nil { - return err - } + // Add the tx service to the gRPC router. We only need to register this + // service if API or gRPC is enabled, and avoid doing so in the general + // case, because it spawns a new local CometBFT RPC client. + if svrCfg.API.Enable || svrCfg.GRPC.Enable { + // create tendermint client + // assumes the rpc listen address is where tendermint has its rpc server + rpcclient, err := rpchttp.New(svrCtx.Config.RPC.ListenAddress, "/websocket") + if err != nil { + return err + } + // re-assign for making the client available below + // do not use := to avoid shadowing clientCtx + clientCtx = clientCtx.WithClient(rpcclient) - _, err = startTelemetry(config) - if err != nil { - return err + // use the provided clientCtx to register the services + app.RegisterTxService(clientCtx) + app.RegisterTendermintService(clientCtx) + if a, ok := app.(types.ApplicationQueryService); ok { + a.RegisterNodeService(clientCtx) + } } - svr, err := server.NewServer(addr, transport, app) + clientCtx, err = startGrpcServer(ctx, g, svrCfg.GRPC, clientCtx, svrCtx, app) if err != nil { - return fmt.Errorf("error creating listener: %v", err) + return err } - svr.SetLogger(ctx.Logger.With("module", "abci-server")) - - err = svr.Start() + err = startAPIServer(ctx, g, clientCtx, svrCfg, svrCtx, app, svrCtx.Config.RootDir, tmetrics) if err != nil { - tmos.Exit(err.Error()) + return err } - defer func() { - if err = svr.Stop(); err != nil { - tmos.Exit(err.Error()) + g.Go(func() error { + if err := svr.Start(); err != nil { + svrCtx.Logger.Error("failed to start out-of-process ABCI server", "err", err) + return err } - }() - // Wait for SIGINT or SIGTERM signal - return WaitForQuitSignals() + // Wait for the calling process to be canceled or close the provided context, + // so we can gracefully stop the ABCI server. + <-ctx.Done() + svrCtx.Logger.Info("stopping the ABCI server...") + return svr.Stop() + }) + + return g.Wait() } -func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error { - cfg := ctx.Config - home := cfg.RootDir - var cpuProfileCleanup func() +func startInProcess(svrCtx *Context, svrCfg serverconfig.Config, clientCtx client.Context, app types.Application, + tmetrics *telemetry.Metrics, +) error { + tmCfg := svrCtx.Config + gRPCOnly := svrCtx.Viper.GetBool(flagGRPCOnly) - if cpuProfile := ctx.Viper.GetString(flagCPUProfile); cpuProfile != "" { - f, err := os.Create(cpuProfile) + g, ctx := getCtx(svrCtx, true) + + if gRPCOnly { + // TODO: Generalize logic so that gRPC only is really in startStandAlone + svrCtx.Logger.Info("starting node in gRPC only mode; Tendermint is disabled") + svrCfg.GRPC.Enable = true + } else { + svrCtx.Logger.Info("starting node with ABCI Tendermint in-process") + tmNode, cleanupFn, err := startTmNode(ctx, tmCfg, app, svrCtx) if err != nil { return err } + defer cleanupFn() - ctx.Logger.Info("starting CPU profiler", "profile", cpuProfile) - if err := pprof.StartCPUProfile(f); err != nil { - return err - } + // Add the tx service to the gRPC router. We only need to register this + // service if API or gRPC is enabled, and avoid doing so in the general + // case, because it spawns a new local tendermint RPC client. + if svrCfg.API.Enable || svrCfg.GRPC.Enable { + // Re-assign for making the client available below do not use := to avoid + // shadowing the clientCtx variable. + clientCtx = clientCtx.WithClient(local.New(tmNode)) - cpuProfileCleanup = func() { - ctx.Logger.Info("stopping CPU profiler", "profile", cpuProfile) - pprof.StopCPUProfile() - f.Close() + app.RegisterTxService(clientCtx) + app.RegisterTendermintService(clientCtx) + + if a, ok := app.(types.ApplicationQueryService); ok { + a.RegisterNodeService(clientCtx) + } } } - traceWriterFile := ctx.Viper.GetString(flagTraceStore) - db, err := openDB(home) + clientCtx, err := startGrpcServer(ctx, g, svrCfg.GRPC, clientCtx, svrCtx, app) if err != nil { return err } - traceWriter, err := openTraceWriter(traceWriterFile) + err = startAPIServer(ctx, g, clientCtx, svrCfg, svrCtx, app, svrCtx.Config.RootDir, tmetrics) if err != nil { return err } - config, err := serverconfig.GetConfig(ctx.Viper) + // wait for signal capture and gracefully return + // we are guaranteed to be waiting for the "ListenForQuitSignals" goroutine. + return g.Wait() +} + +func genPvFileOnlyWhenKmsAddressEmpty(cfg *tmcfg.Config) *pvm.FilePV { + if len(strings.TrimSpace(cfg.PrivValidatorListenAddr)) == 0 { + return pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()) + } + return nil +} + +func getAndValidateConfig(svrCtx *Context) (serverconfig.Config, error) { + svrcfg, err := serverconfig.GetConfig(svrCtx.Viper) if err != nil { - return err + return svrcfg, err } - if err := config.ValidateBasic(); err != nil { - ctx.Logger.Error("WARNING: The minimum-gas-prices config in app.toml is set to the empty string. " + - "This defaults to 0 in the current version, but will error in the next version " + - "(SDK v0.45). Please explicitly put the desired minimum-gas-prices in your app.toml.") + if err := svrcfg.ValidateBasic(); err != nil { + return svrcfg, err } + return svrcfg, nil +} - app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper) +// returns a function which returns the genesis doc from the genesis file. +func getGenDocProvider(cfg *tmcfg.Config) func() (*tmtypes.GenesisDoc, error) { + return node.DefaultGenesisDocProviderFunc(cfg) +} - nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile()) +// SetupTraceWriter sets up the trace writer and returns a cleanup function. +func SetupTraceWriter(logger tmlog.Logger, traceWriterFile string) (traceWriter io.WriteCloser, cleanup func(), err error) { + // clean up the traceWriter when the server is shutting down + cleanup = func() {} + + traceWriter, err = openTraceWriter(traceWriterFile) if err != nil { - return err + return traceWriter, cleanup, err } - genDocProvider := node.DefaultGenesisDocProviderFunc(cfg) - - var ( - tmNode *node.Node - gRPCOnly = ctx.Viper.GetBool(flagGRPCOnly) - ) - - if gRPCOnly { - ctx.Logger.Info("starting node in gRPC only mode; Tendermint is disabled") - config.GRPC.Enable = true - } else { - ctx.Logger.Info("starting node with ABCI Tendermint in-process") - - pv := genPvFileOnlyWhenKmsAddressEmpty(cfg) - - tmNode, err = node.NewNode( - cfg, - pv, - nodeKey, - proxy.NewLocalClientCreator(app), - genDocProvider, - node.DefaultDBProvider, - node.DefaultMetricsProvider(cfg.Instrumentation), - ctx.Logger, - ) - if err != nil { - return err - } - ctx.Logger.Debug("initialization: tmNode created") - if err := tmNode.Start(); err != nil { - return err + // if flagTraceStore is not used then traceWriter is nil + if traceWriter != nil { + cleanup = func() { + if err = traceWriter.Close(); err != nil { + logger.Error("failed to close trace writer", "err", err) + } } - ctx.Logger.Debug("initialization: tmNode started") } - // Add the tx service to the gRPC router. We only need to register this - // service if API or gRPC is enabled, and avoid doing so in the general - // case, because it spawns a new local tendermint RPC client. - if (config.API.Enable || config.GRPC.Enable) && tmNode != nil { - clientCtx = clientCtx.WithClient(local.New(tmNode)) - - app.RegisterTxService(clientCtx) - app.RegisterTendermintService(clientCtx) + return traceWriter, cleanup, nil +} - if a, ok := app.(types.ApplicationQueryService); ok { - a.RegisterNodeService(clientCtx) - } +// TODO: Move nodeKey into being created within the function. +func startTmNode( + _ context.Context, + cfg *tmcfg.Config, + app types.Application, + svrCtx *Context, +) (tmNode *node.Node, cleanupFn func(), err error) { + nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile()) + if err != nil { + return nil, cleanupFn, err } - metrics, err := startTelemetry(config) + tmNode, err = node.NewNode( + cfg, + genPvFileOnlyWhenKmsAddressEmpty(cfg), + nodeKey, + proxy.NewLocalClientCreator(app), + getGenDocProvider(cfg), + node.DefaultDBProvider, + node.DefaultMetricsProvider(cfg.Instrumentation), + svrCtx.Logger, + ) if err != nil { - return err + return tmNode, cleanupFn, err } - var apiSrv *api.Server - if config.API.Enable { - genDoc, err := genDocProvider() - if err != nil { - return err - } - - clientCtx := clientCtx.WithHomeDir(home).WithChainID(genDoc.ChainID) + svrCtx.Logger.Debug("initialization: tmNode created") + if err := tmNode.Start(); err != nil { + return tmNode, cleanupFn, err + } + svrCtx.Logger.Debug("initialization: tmNode started") - apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server")) - app.RegisterAPIRoutes(apiSrv, config.API) - if config.Telemetry.Enabled { - apiSrv.SetTelemetry(metrics) + cleanupFn = func() { + if tmNode != nil && tmNode.IsRunning() { + _ = tmNode.Stop() } - errCh := make(chan error) + } - go func() { - if err := apiSrv.Start(config); err != nil { - errCh <- err - } - }() + return tmNode, cleanupFn, nil +} - select { - case err := <-errCh: - return err +func startGrpcServer( + ctx context.Context, + g *errgroup.Group, + config serverconfig.GRPCConfig, + clientCtx client.Context, + svrCtx *Context, + app types.Application, +) (client.Context, error) { + if !config.Enable { + // return grpcServer as nil if gRPC is disabled + return clientCtx, nil + } + _, _, err := net.SplitHostPort(config.Address) + if err != nil { + return clientCtx, err + } - case <-time.After(types.ServerStartTime): // assume server started successfully - } + maxSendMsgSize := config.MaxSendMsgSize + if maxSendMsgSize == 0 { + maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize } - var ( - grpcSrv *grpc.Server - grpcWebSrv *http.Server + maxRecvMsgSize := config.MaxRecvMsgSize + if maxRecvMsgSize == 0 { + maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize + } + + // if gRPC is enabled, configure gRPC client for gRPC gateway + grpcClient, err := grpc.NewClient( + config.Address, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithDefaultCallOptions( + grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), + grpc.MaxCallRecvMsgSize(maxRecvMsgSize), + grpc.MaxCallSendMsgSize(maxSendMsgSize), + ), ) + if err != nil { + return clientCtx, err + } - if config.GRPC.Enable { - grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC) - if err != nil { - return err - } + clientCtx = clientCtx.WithGRPCClient(grpcClient) + svrCtx.Logger.Debug("gRPC client assigned to client context", "target", config.Address) - if config.GRPCWeb.Enable { - grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, config) - if err != nil { - ctx.Logger.Error("failed to start grpc-web http server: ", err) - return err - } - } + grpcSrv, err := servergrpc.NewGRPCServer(clientCtx, app, config) + if err != nil { + return clientCtx, err } - // At this point it is safe to block the process if we're in gRPC only mode as - // we do not need to start Rosetta or handle any Tendermint related processes. - if gRPCOnly { - // wait for signal capture and gracefully return - return WaitForQuitSignals() + // Start the gRPC server in a goroutine. Note, the provided ctx will ensure + // that the server is gracefully shut down. + g.Go(func() error { + return servergrpc.StartGRPCServer(ctx, svrCtx.Logger.With("module", "grpc-server"), config, grpcSrv) + }) + return clientCtx, nil +} + +func startAPIServer( + ctx context.Context, + g *errgroup.Group, + clientCtx client.Context, + svrCfg serverconfig.Config, + svrCtx *Context, + app types.Application, + home string, + metrics *telemetry.Metrics, +) error { + if !svrCfg.API.Enable { + return nil } - var rosettaSrv crgserver.Server - if config.Rosetta.Enable { - offlineMode := config.Rosetta.Offline + clientCtx = clientCtx.WithHomeDir(home) - // If GRPC is not enabled rosetta cannot work in online mode, so it works in - // offline mode. - if !config.GRPC.Enable { - offlineMode = true - } + apiSrv := api.New(clientCtx, svrCtx.Logger.With("module", "api-server")) + app.RegisterAPIRoutes(apiSrv, svrCfg.API) - conf := &rosetta.Config{ - Blockchain: config.Rosetta.Blockchain, - Network: config.Rosetta.Network, - TendermintRPC: ctx.Config.RPC.ListenAddress, - GRPCEndpoint: config.GRPC.Address, - Addr: config.Rosetta.Address, - Retries: config.Rosetta.Retries, - Offline: offlineMode, - Codec: clientCtx.Codec.(*codec.ProtoCodec), - InterfaceRegistry: clientCtx.InterfaceRegistry, - } + if svrCfg.Telemetry.Enabled { + apiSrv.SetTelemetry(metrics) + } - rosettaSrv, err = rosetta.ServerFromConfig(conf) - if err != nil { - return err - } + g.Go(func() error { + return apiSrv.Start(ctx, svrCfg) + }) + return nil +} - errCh := make(chan error) - go func() { - if err := rosettaSrv.Start(); err != nil { - errCh <- err - } - }() +func startTelemetry(cfg serverconfig.Config) (*telemetry.Metrics, error) { + if !cfg.Telemetry.Enabled { + return nil, nil + } + return telemetry.New(cfg.Telemetry) +} - select { - case err := <-errCh: +// wrapCPUProfile starts CPU profiling, if enabled, and executes the provided +// callbackFn in a separate goroutine, then will wait for that callback to +// return. +// +// NOTE: We expect the caller to handle graceful shutdown and signal handling. +func wrapCPUProfile(svrCtx *Context, callbackFn func() error) error { + if cpuProfile := svrCtx.Viper.GetString(flagCPUProfile); cpuProfile != "" { + f, err := os.Create(cpuProfile) + if err != nil { return err - - case <-time.After(types.ServerStartTime): // assume server started successfully } - } - defer func() { - if tmNode.IsRunning() { - _ = tmNode.Stop() - } + svrCtx.Logger.Info("starting CPU profiler", "profile", cpuProfile) - if cpuProfileCleanup != nil { - cpuProfileCleanup() + if err := pprof.StartCPUProfile(f); err != nil { + return err } - if apiSrv != nil { - _ = apiSrv.Close() - } + defer func() { + svrCtx.Logger.Info("stopping CPU profiler", "profile", cpuProfile) + pprof.StopCPUProfile() - if grpcSrv != nil { - grpcSrv.Stop() - if grpcWebSrv != nil { - grpcWebSrv.Close() + if err := f.Close(); err != nil { + svrCtx.Logger.Info("failed to close cpu-profile file", "profile", cpuProfile, "err", err.Error()) } - } + }() + } - ctx.Logger.Info("exiting...") + errCh := make(chan error) + go func() { + errCh <- callbackFn() }() - // wait for signal capture and gracefully return - return WaitForQuitSignals() + return <-errCh } -func genPvFileOnlyWhenKmsAddressEmpty(cfg *config.Config) *pvm.FilePV { - if len(strings.TrimSpace(cfg.PrivValidatorListenAddr)) == 0 { - return pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()) +// emitServerInfoMetrics emits server info related metrics using application telemetry. +func emitServerInfoMetrics() { + var ls []metrics.Label + + versionInfo := version.NewInfo() + if len(versionInfo.GoVersion) > 0 { + ls = append(ls, telemetry.NewLabel("go", versionInfo.GoVersion)) + } + if len(versionInfo.LbmSdkVersion) > 0 { + ls = append(ls, telemetry.NewLabel("version", versionInfo.LbmSdkVersion)) } - return nil -} -func startTelemetry(cfg serverconfig.Config) (*telemetry.Metrics, error) { - if !cfg.Telemetry.Enabled { - return nil, nil + if len(ls) == 0 { + return } - return telemetry.New(cfg.Telemetry) + + telemetry.SetGaugeWithLabels([]string{"server", "info"}, 1, ls) +} + +func getCtx(svrCtx *Context, block bool) (*errgroup.Group, context.Context) { + ctx, cancelFn := context.WithCancel(context.Background()) + g, ctx := errgroup.WithContext(ctx) + // listen for quit signals so the calling parent process can gracefully exit + ListenForQuitSignals(g, block, cancelFn, svrCtx.Logger) + return g, ctx } diff --git a/server/tm_cmds_test.go b/server/tm_cmds_test.go index efb67fb7fc..8dfb6eccfb 100644 --- a/server/tm_cmds_test.go +++ b/server/tm_cmds_test.go @@ -3,6 +3,7 @@ package server import ( "bytes" "context" + "errors" "fmt" "os" "testing" @@ -27,7 +28,7 @@ func TestShowValidator(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -52,7 +53,7 @@ func TestShowValidatorWithInefficientKMSAddress(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } diff --git a/server/types/app.go b/server/types/app.go index 397d2c1030..0e2ca5dc39 100644 --- a/server/types/app.go +++ b/server/types/app.go @@ -3,7 +3,6 @@ package types import ( "encoding/json" "io" - "time" "github.com/gogo/protobuf/grpc" "github.com/spf13/cobra" @@ -18,10 +17,6 @@ import ( sdk "github.com/Finschia/finschia-sdk/types" ) -// ServerStartTime defines the time duration that the server need to stay running after startup -// for the startup be considered successful -const ServerStartTime = 5 * time.Second - type ( // AppOptions defines an interface that is passed into an application // constructor, typically used to set BaseApp options that are either supplied diff --git a/server/util.go b/server/util.go index 78fa9fb670..40a5cdd38b 100644 --- a/server/util.go +++ b/server/util.go @@ -1,6 +1,7 @@ package server import ( + "context" "errors" "fmt" "io" @@ -23,6 +24,7 @@ import ( tmcfg "github.com/tendermint/tendermint/config" tmlog "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" + "golang.org/x/sync/errgroup" "github.com/Finschia/finschia-sdk/client/flags" "github.com/Finschia/finschia-sdk/server/config" @@ -203,7 +205,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo tmcfg.EnsureRoot(rootDir) if err = conf.ValidateBasic(); err != nil { - return nil, fmt.Errorf("error in config file: %v", err) + return nil, fmt.Errorf("error in config file: %w", err) } conf.RPC.PprofListenAddress = "localhost:6060" @@ -349,12 +351,31 @@ func TrapSignal(cleanupFunc func()) { }() } -// WaitForQuitSignals waits for SIGINT and SIGTERM and returns. -func WaitForQuitSignals() ErrorCode { - sigs := make(chan os.Signal, 1) - signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - sig := <-sigs - return ErrorCode{Code: int(sig.(syscall.Signal)) + 128} +// ListenForQuitSignals listens for SIGINT and SIGTERM. When a signal is received, +// the cleanup function is called, indicating the caller can gracefully exit or +// return. +// +// Note, the blocking behavior of this depends on the block argument. +// The caller must ensure the corresponding context derived from the cancelFn is used correctly. +func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.CancelFunc, logger tmlog.Logger) { + sigCh := make(chan os.Signal, 1) + signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) + + f := func() { + sig := <-sigCh + cancelFn() + + logger.Info("caught signal", "signal", sig.String()) + } + + if block { + g.Go(func() error { + f() + return nil + }) + } else { + go f() + } } func skipInterface(iface net.Interface) bool { @@ -386,7 +407,7 @@ func openDB(rootDir string) (dbm.DB, error) { return sdk.NewLevelDB("application", dataDir) } -func openTraceWriter(traceWriterFile string) (w io.Writer, err error) { +func openTraceWriter(traceWriterFile string) (w io.WriteCloser, err error) { if traceWriterFile == "" { return } diff --git a/server/util_test.go b/server/util_test.go index 02931b6183..60024c5df6 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -39,7 +39,7 @@ func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -116,7 +116,7 @@ func TestInterceptConfigsPreRunHandlerReadsConfigToml(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -153,7 +153,7 @@ func TestInterceptConfigsPreRunHandlerReadsAppToml(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -181,7 +181,7 @@ func TestInterceptConfigsPreRunHandlerReadsFlags(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -206,17 +206,13 @@ func TestInterceptConfigsPreRunHandlerReadsEnvVars(t *testing.T) { basename = strings.ReplaceAll(basename, ".", "_") // This is added by tendermint envVarName := fmt.Sprintf("%s_RPC_LADDR", strings.ToUpper(basename)) - os.Setenv(envVarName, testAddr) - t.Cleanup(func() { - os.Unsetenv(envVarName) - }) - + t.Setenv(envVarName, testAddr) cmd.PreRunE = preRunETestImpl serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -322,7 +318,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceFlag(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -338,7 +334,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceEnvVar(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -354,7 +350,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigFile(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } @@ -370,7 +366,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigDefault(t *testing.T) { serverCtx := &Context{} ctx := context.WithValue(context.Background(), ServerContextKey, serverCtx) - if err := testCommon.cmd.ExecuteContext(ctx); err != errCancelledInPreRun { + if err := testCommon.cmd.ExecuteContext(ctx); !errors.Is(err, errCancelledInPreRun) { t.Fatalf("function failed with [%T] %v", err, err) } diff --git a/simapp/genesis_account_test.go b/simapp/genesis_account_test.go index 1100e49459..7d9f82af1d 100644 --- a/simapp/genesis_account_test.go +++ b/simapp/genesis_account_test.go @@ -80,7 +80,6 @@ func TestSimGenesisAccountValidate(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.wantErr, tc.sga.Validate() != nil) }) diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 7f8451637f..f4666c8876 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -117,7 +117,6 @@ func BenchmarkInvariants(b *testing.B) { // NOTE: We use the crisis keeper as it has all the invariants registered with // their respective metadata which makes it useful for testing/benchmarking. for _, cr := range app.CrisisKeeper.Routes() { - cr := cr b.Run(fmt.Sprintf("%s/%s", cr.ModuleName, cr.Route), func(b *testing.B) { if res, stop := cr.Invar(ctx); stop { b.Fatalf( diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index 154a4e0abe..0d14c40ce6 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -65,7 +65,6 @@ func TestAddGenesisAccountCmd(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index ec26123320..7d1b8b2ecf 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -147,9 +147,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { txCommand(), keys.Commands(simapp.DefaultNodeHome), ) - - // add rosetta - rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler)) } func addModuleInitFlags(startCmd *cobra.Command) { diff --git a/simapp/simd/cmd/root_test.go b/simapp/simd/cmd/root_test.go index d45a66e6cb..7575084313 100644 --- a/simapp/simd/cmd/root_test.go +++ b/simapp/simd/cmd/root_test.go @@ -75,7 +75,6 @@ func TestAppExport(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { exported, err := a.appExport(logger, db, nil, tc.height, false, []string{}, ctx.Viper) if tc.expectErr { diff --git a/simapp/simd/main.go b/simapp/simd/main.go index 6220cc701f..2dfddc3292 100644 --- a/simapp/simd/main.go +++ b/simapp/simd/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "os" "github.com/Finschia/finschia-sdk/server" @@ -13,10 +14,10 @@ func main() { rootCmd, _ := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd, simapp.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: + var e server.ErrorCode + switch { + case errors.As(err, &e): os.Exit(e.Code) - default: os.Exit(1) } diff --git a/simapp/utils_test.go b/simapp/utils_test.go index c63716dfa1..f1e3f32cfa 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -69,7 +69,6 @@ func TestGetSimulationLog(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.store, func(t *testing.T) { require.Equal(t, tt.expectedLog, GetSimulationLog(tt.store, decoders, tt.kvPairs, tt.kvPairs), tt.store) }) diff --git a/snapshots/chunk.go b/snapshots/chunk.go index 7e1239ec8c..f9b1692b0f 100644 --- a/snapshots/chunk.go +++ b/snapshots/chunk.go @@ -1,6 +1,7 @@ package snapshots import ( + "errors" "io" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" @@ -144,7 +145,7 @@ func (r *ChunkReader) Read(p []byte) (int, error) { } } n, err := r.reader.Read(p) - if err == io.EOF { + if errors.Is(err, io.EOF) { err = r.reader.Close() r.reader = nil if err != nil { diff --git a/snapshots/helpers_test.go b/snapshots/helpers_test.go index 12d0be6bfc..84983f73b6 100644 --- a/snapshots/helpers_test.go +++ b/snapshots/helpers_test.go @@ -116,7 +116,7 @@ func (m *mockSnapshotter) Restore( for { item := &snapshottypes.SnapshotItem{} err := protoReader.ReadMsg(item) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } else if err != nil { return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message") diff --git a/store/cachekv/search_test.go b/store/cachekv/search_test.go index 41321c076e..aedc066903 100644 --- a/store/cachekv/search_test.go +++ b/store/cachekv/search_test.go @@ -60,7 +60,6 @@ func TestFindStartIndex(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { body := tt.sortedL got := findStartIndex(body, tt.query) @@ -129,7 +128,6 @@ func TestFindEndIndex(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { body := tt.sortedL got := findEndIndex(body, tt.query) diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index fcdcbc50da..bd23462e78 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -656,8 +656,6 @@ func TestSetInitialVersion(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { db := dbm.NewMemDB() store := tc.storeFn(db) diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go index 14d0374fee..29b07f4c74 100644 --- a/store/rootmulti/snapshot_test.go +++ b/store/rootmulti/snapshot_test.go @@ -142,7 +142,6 @@ func TestMultistoreSnapshot_Checksum(t *testing.T) { }}, } for _, tc := range testcases { - tc := tc t.Run(fmt.Sprintf("Format %v", tc.format), func(t *testing.T) { ch := make(chan io.ReadCloser) go func() { @@ -177,7 +176,6 @@ func TestMultistoreSnapshot_Errors(t *testing.T) { "unknown height": {9, nil}, } for name, tc := range testcases { - tc := tc t.Run(name, func(t *testing.T) { err := store.Snapshot(tc.height, nil) require.Error(t, err) diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 61063a0da0..615379b640 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -469,7 +469,7 @@ func (rs *Store) PruneStores(clearStorePruningHeihgts bool, pruningHeights []int store = rs.GetCommitKVStore(key) if err := store.(*iavl.Store).DeleteVersions(pruningHeights...); err != nil { - if errCause := errors.Cause(err); errCause != nil && errCause != iavltree.ErrVersionDoesNotExist { + if errCause := errors.Cause(err); errCause != nil && !errors.Is(errCause, iavltree.ErrVersionDoesNotExist) { panic(err) } } @@ -744,7 +744,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { for { node, err := exporter.Next() - if err == iavltree.ExportDone { + if errors.Is(err, iavltree.ExportDone) { break } else if err != nil { return err @@ -783,7 +783,7 @@ loop: for { snapshotItem = snapshottypes.SnapshotItem{} err := protoReader.ReadMsg(&snapshotItem) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } else if err != nil { return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message") diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 944075c803..39714a49a4 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -506,8 +506,6 @@ func TestMultiStore_Pruning(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { db := dbm.NewMemDB() ms := newMultiStoreWithMounts(db, tc.po) diff --git a/store/types/gas_test.go b/store/types/gas_test.go index 8a02df4cfa..80ca8adf9e 100644 --- a/store/types/gas_test.go +++ b/store/types/gas_test.go @@ -44,7 +44,6 @@ func TestGasMeter(t *testing.T) { used := uint64(0) for unum, usage := range tc.usage { - usage := usage used += usage require.NotPanics(t, func() { meter.ConsumeGas(usage, "") }, "Not exceeded limit but panicked. tc #%d, usage #%d", tcnum, unum) require.Equal(t, used, meter.GasConsumed(), "Gas consumption not match. tc #%d, usage #%d", tcnum, unum) diff --git a/store/types/iterator_test.go b/store/types/iterator_test.go index 9e3be06fe3..65e70306d8 100644 --- a/store/types/iterator_test.go +++ b/store/types/iterator_test.go @@ -83,7 +83,6 @@ func TestPaginatedIterator(t *testing.T) { reverse: true, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { var iter types.Iterator if tc.reverse { diff --git a/store/types/store_test.go b/store/types/store_test.go index 8dac7f5394..ff9765dbe8 100644 --- a/store/types/store_test.go +++ b/store/types/store_test.go @@ -47,7 +47,6 @@ func TestStoreUpgrades(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { for _, d := range tc.expectDelete { assert.Equal(t, tc.upgrades.IsDeleted(d.key), d.delete) diff --git a/telemetry/metrics.go b/telemetry/metrics.go index dcf90e0aa2..0878d9f262 100644 --- a/telemetry/metrics.go +++ b/telemetry/metrics.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - metrics "github.com/armon/go-metrics" - metricsprom "github.com/armon/go-metrics/prometheus" + metrics "github.com/hashicorp/go-metrics" + metricsprom "github.com/hashicorp/go-metrics/prometheus" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/expfmt" ) diff --git a/telemetry/metrics_test.go b/telemetry/metrics_test.go index ca8ea8a337..9112c06a39 100644 --- a/telemetry/metrics_test.go +++ b/telemetry/metrics_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - metrics "github.com/armon/go-metrics" + metrics "github.com/hashicorp/go-metrics" "github.com/stretchr/testify/require" ) diff --git a/telemetry/wrapper.go b/telemetry/wrapper.go index 24722a7d63..56e85a7dfc 100644 --- a/telemetry/wrapper.go +++ b/telemetry/wrapper.go @@ -3,7 +3,7 @@ package telemetry import ( "time" - metrics "github.com/armon/go-metrics" + metrics "github.com/hashicorp/go-metrics" ) // Common metric key constants diff --git a/testutil/network/network.go b/testutil/network/network.go index ef35d20924..701210d914 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "net/http" "net/url" "os" "path/filepath" @@ -22,6 +21,7 @@ import ( "github.com/tendermint/tendermint/node" tmclient "github.com/tendermint/tendermint/rpc/client" dbm "github.com/tendermint/tm-db" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" "github.com/Finschia/finschia-sdk/baseapp" @@ -160,10 +160,12 @@ type ( ValAddress sdk.ValAddress RPCClient tmclient.Client - tmNode *node.Node - api *api.Server - grpc *grpc.Server - grpcWeb *http.Server + app servertypes.Application + tmNode *node.Node + api *api.Server + grpc *grpc.Server + errGroup *errgroup.Group + cancelFn context.CancelFunc } ) @@ -217,7 +219,6 @@ func New(t *testing.T, cfg Config) *Network { apiAddr := "" tmCfg.RPC.ListenAddress = "" appCfg.GRPC.Enable = false - appCfg.GRPCWeb.Enable = false if i == 0 { apiListenAddr, _, err := server.FreeTCPAddr() require.NoError(t, err) @@ -235,11 +236,6 @@ func New(t *testing.T, cfg Config) *Network { require.NoError(t, err) appCfg.GRPC.Address = fmt.Sprintf("0.0.0.0:%s", grpcPort) appCfg.GRPC.Enable = true - - _, grpcWebPort, err := server.FreeTCPAddr() - require.NoError(t, err) - appCfg.GRPCWeb.Address = fmt.Sprintf("0.0.0.0:%s", grpcWebPort) - appCfg.GRPCWeb.Enable = true } logger := log.NewNopLogger() @@ -358,7 +354,8 @@ func New(t *testing.T, cfg Config) *Network { WithCodec(cfg.Codec). WithLegacyAmino(cfg.LegacyAmino). WithTxConfig(cfg.TxConfig). - WithAccountRetriever(cfg.AccountRetriever) + WithAccountRetriever(cfg.AccountRetriever). + WithNodeURI(tmCfg.RPC.ListenAddress) network.Validators[i] = &Validator{ AppConfig: appCfg, @@ -384,6 +381,14 @@ func New(t *testing.T, cfg Config) *Network { } t.Log("started test network") + require.NoError(t, network.WaitForNextBlock()) + height, err := network.LatestHeight() + if err != nil { + return nil + } + + t.Log("started test network at height:", height) + // Ensure we cleanup incase any test was abruptly halted (e.g. SIGINT) as any // defer in a test would not be called. server.TrapSignal(network.Cleanup) @@ -522,9 +527,6 @@ func (n *Network) Cleanup() { if v.grpc != nil { v.grpc.Stop() - if v.grpcWeb != nil { - _ = v.grpcWeb.Close() - } } } diff --git a/testutil/network/util.go b/testutil/network/util.go index c599a59ec3..020051ad58 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -1,9 +1,9 @@ package network import ( + "context" "encoding/json" "path/filepath" - "time" tmos "github.com/tendermint/tendermint/libs/os" "github.com/tendermint/tendermint/node" @@ -13,6 +13,7 @@ import ( "github.com/tendermint/tendermint/rpc/client/local" "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" + "golang.org/x/sync/errgroup" "github.com/Finschia/finschia-sdk/server/api" servergrpc "github.com/Finschia/finschia-sdk/server/grpc" @@ -38,6 +39,7 @@ func startInProcess(cfg Config, val *Validator) error { } app := cfg.AppConstructor(*val) + val.app = app genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) pv := pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()) @@ -78,41 +80,35 @@ func startInProcess(cfg Config, val *Validator) error { } } - if val.APIAddress != "" { - apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server")) - app.RegisterAPIRoutes(apiSrv, val.AppConfig.API) - - errCh := make(chan error) - - go func() { - if err := apiSrv.Start(*val.AppConfig); err != nil { - errCh <- err - } - }() + ctx := context.Background() + ctx, val.cancelFn = context.WithCancel(ctx) + val.errGroup, ctx = errgroup.WithContext(ctx) + grpcCfg := val.AppConfig.GRPC - select { - case err := <-errCh: + if grpcCfg.Enable { + grpcSrv, err := servergrpc.NewGRPCServer(val.ClientCtx, app, grpcCfg) + if err != nil { return err - case <-time.After(srvtypes.ServerStartTime): // assume server started successfully } - val.api = apiSrv + // Start the gRPC server in a goroutine. Note, the provided ctx will ensure + // that the server is gracefully shut down. + val.errGroup.Go(func() error { + return servergrpc.StartGRPCServer(ctx, logger.With("module", "grpc-server"), grpcCfg, grpcSrv) + }) + + val.grpc = grpcSrv } - if val.AppConfig.GRPC.Enable { - grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC) - if err != nil { - return err - } + if val.APIAddress != "" { + apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server")) + app.RegisterAPIRoutes(apiSrv, val.AppConfig.API) - val.grpc = grpcSrv + val.errGroup.Go(func() error { + return apiSrv.Start(ctx, *val.AppConfig) + }) - if val.AppConfig.GRPCWeb.Enable { - val.grpcWeb, err = servergrpc.StartGRPCWeb(grpcSrv, *val.AppConfig) - if err != nil { - return err - } - } + val.api = apiSrv } return nil diff --git a/tools/error_doc/go.mod b/tools/error_doc/go.mod index 6ca1dbad7f..d78c61370a 100644 --- a/tools/error_doc/go.mod +++ b/tools/error_doc/go.mod @@ -1,5 +1,5 @@ module github.com/Finschia/finschia-sdk/tools/error_doc -go 1.20 +go 1.22 require golang.org/x/text v0.11.0 diff --git a/types/address/store_key_test.go b/types/address/store_key_test.go index ca3b4d8ec2..6f04121baf 100644 --- a/types/address/store_key_test.go +++ b/types/address/store_key_test.go @@ -32,7 +32,6 @@ func (suite *StoreKeySuite) TestLengthPrefix() { } for _, tt := range tests { - tt := tt suite.Run(tt.name, func() { storeKey, err := address.LengthPrefix(tt.addr) if tt.expErr { diff --git a/types/address_test.go b/types/address_test.go index 61bf36318e..cbd09dbfa6 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -392,7 +392,6 @@ func (s *addressTestSuite) TestBech32ifyAddressBytes() { {"20-byte address", args{"prefixb", addr20byte}, "prefixb1qqqsyqcyq5rqwzqfpg9scrgwpugpzysnrujsuw", false}, } for _, tt := range tests { - tt := tt s.T().Run(tt.name, func(t *testing.T) { got, err := types.Bech32ifyAddressBytes(tt.args.prefix, tt.args.bs) if (err != nil) != tt.wantErr { @@ -425,7 +424,6 @@ func (s *addressTestSuite) TestMustBech32ifyAddressBytes() { {"20-byte address", args{"prefixb", addr20byte}, "prefixb1qqqsyqcyq5rqwzqfpg9scrgwpugpzysnrujsuw", false}, } for _, tt := range tests { - tt := tt s.T().Run(tt.name, func(t *testing.T) { if tt.wantPanic { require.Panics(t, func() { types.MustBech32ifyAddressBytes(tt.args.prefix, tt.args.bs) }) diff --git a/types/coin_test.go b/types/coin_test.go index 4af7a46e00..d64a51131c 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -135,7 +135,6 @@ func (s *coinTestSuite) TestAddCoin() { } for tcIndex, tc := range cases { - tc := tc if tc.shouldPanic { s.Require().Panics(func() { tc.inputOne.Add(tc.inputTwo) }) } else { @@ -175,7 +174,6 @@ func (s *coinTestSuite) TestSubCoin() { } for tcIndex, tc := range cases { - tc := tc if tc.shouldPanic { s.Require().Panics(func() { tc.inputOne.Sub(tc.inputTwo) }) } else { @@ -230,7 +228,6 @@ func (s *coinTestSuite) TestIsGTECoin() { } for tcIndex, tc := range cases { - tc := tc if tc.panics { s.Require().Panics(func() { tc.inputOne.IsGTE(tc.inputTwo) }) } else { @@ -256,7 +253,6 @@ func (s *coinTestSuite) TestIsLTCoin() { } for tcIndex, tc := range cases { - tc := tc if tc.panics { s.Require().Panics(func() { tc.inputOne.IsLT(tc.inputTwo) }) } else { @@ -485,7 +481,6 @@ func (s *coinTestSuite) TestSubCoins() { assert := s.Assert() for i, tc := range testCases { - tc := tc if tc.shouldPanic { assert.Panics(func() { tc.inputOne.Sub(tc.inputTwo) }) } else { @@ -1065,7 +1060,6 @@ func (s *coinTestSuite) TestCoinValidate() { } for _, tc := range testCases { - tc := tc t := s.T() t.Run(tc.name, func(t *testing.T) { err := tc.coin.Validate() diff --git a/types/context_test.go b/types/context_test.go index 5688cfe61f..4530cf92eb 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -191,7 +191,6 @@ func (s *contextTestSuite) TestContextHeaderClone() { } for name, tc := range cases { - tc := tc s.T().Run(name, func(t *testing.T) { ctx := types.NewContext(nil, tc.h, false, nil) s.Require().Equal(tc.h.Height, ctx.BlockHeight()) diff --git a/types/dec_coin.go b/types/dec_coin.go index 86b53f1607..9c8e6cf47d 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -630,7 +630,7 @@ func ParseDecCoin(coinStr string) (coin DecCoin, err error) { } if err := ValidateDenom(denomStr); err != nil { - return DecCoin{}, fmt.Errorf("invalid denom cannot contain upper case characters or spaces: %s", err) + return DecCoin{}, fmt.Errorf("invalid denom cannot contain upper case characters or spaces: %w", err) } return NewDecCoinFromDec(denomStr, amount), nil diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index 71673f9815..bb9addef5e 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -187,7 +187,6 @@ func (s *decCoinTestSuite) TestIsValid() { } for _, tc := range tests { - tc := tc if tc.expectPass { s.Require().True(tc.coin.IsValid(), tc.msg) } else { @@ -222,7 +221,6 @@ func (s *decCoinTestSuite) TestSubDecCoin() { decCoin := sdk.NewDecCoin("mytoken", sdk.NewInt(10)) for _, tc := range tests { - tc := tc if tc.expectPass { equal := tc.coin.Sub(decCoin) s.Require().Equal(equal, decCoin, tc.msg) @@ -258,7 +256,6 @@ func (s *decCoinTestSuite) TestSubDecCoins() { decCoins := sdk.NewDecCoinsFromCoins(sdk.NewCoin("btc", sdk.NewInt(10)), sdk.NewCoin("eth", sdk.NewInt(15)), sdk.NewCoin("mytoken", sdk.NewInt(5))) for _, tc := range tests { - tc := tc if tc.expectPass { equal := tc.coins.Sub(decCoins) s.Require().Equal(equal, decCoins, tc.msg) @@ -500,7 +497,6 @@ func (s *decCoinTestSuite) TestDecCoinsQuoDecTruncate() { } for i, tc := range testCases { - tc := tc if tc.panics { s.Require().Panics(func() { tc.coins.QuoDecTruncate(tc.input) }) } else { @@ -537,7 +533,6 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { } for _, tc := range tests { - tc := tc if tc.expectPass { s.Require().True(tc.coin.IsValid(), tc.msg) } else { @@ -564,7 +559,6 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithZeroCoins() { } for _, tc := range tests { - tc := tc s.Require().Equal(sdk.NewDecCoinsFromCoins(tc.coins...).Len(), tc.expectLength) } } @@ -596,7 +590,6 @@ func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { } for _, tc := range tests { - tc := tc if tc.expectPass { s.Require().True(tc.coin.IsValid(), tc.msg) } else { diff --git a/types/decimal.go b/types/decimal.go index 8be1f3820f..c1d056e9a6 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -671,7 +671,11 @@ var nilJSON []byte func init() { empty := new(big.Int) bz, _ := empty.MarshalText() - nilJSON, _ = json.Marshal(string(bz)) + var err error + nilJSON, err = json.Marshal(string(bz)) + if err != nil { + panic(err) + } } // MarshalJSON marshals the decimal @@ -740,7 +744,7 @@ func (d *Dec) MarshalTo(data []byte) (n int, err error) { // Unmarshal implements the gogo proto custom type interface. func (d *Dec) Unmarshal(data []byte) error { if len(data) == 0 { - d = nil + d = nil //nolint: wastedassign return nil } diff --git a/types/decimal_internal_test.go b/types/decimal_internal_test.go index 9aa31affe1..23805998b1 100644 --- a/types/decimal_internal_test.go +++ b/types/decimal_internal_test.go @@ -67,7 +67,6 @@ func (s *decimalInternalTestSuite) TestDecMarshalJSON() { {"12340Int", NewDec(12340), "\"12340.000000000000000000\"", false}, } for _, tt := range tests { - tt := tt s.T().Run(tt.name, func(t *testing.T) { got, err := tt.d.MarshalJSON() if (err != nil) != tt.wantErr { diff --git a/types/decimal_test.go b/types/decimal_test.go index 6c1e50ab4d..8c49a3c066 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -236,7 +236,6 @@ func (s *decimalTestSuite) TestArithmetic() { } for tcIndex, tc := range tests { - tc := tc resAdd := tc.d1.Add(tc.d2) resSub := tc.d1.Sub(tc.d2) resMul := tc.d1.Mul(tc.d2) diff --git a/types/errors/abci_test.go b/types/errors/abci_test.go index 13e7c8455c..c886e3917c 100644 --- a/types/errors/abci_test.go +++ b/types/errors/abci_test.go @@ -181,7 +181,6 @@ func (s *abciTestSuite) TestABCIInfoSerializeErr() { }, } for msg, spec := range specs { - spec := spec _, _, log := ABCIInfo(spec.src, spec.debug) s.Require().Equal(spec.exp, log, msg) } diff --git a/types/events_test.go b/types/events_test.go index 45513e6fd9..334846981e 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -247,7 +247,6 @@ func (s *eventsTestSuite) TestMarkEventsToIndex() { } for name, tc := range testCases { - tc := tc s.T().Run(name, func(_ *testing.T) { s.Require().Equal(tc.expected, sdk.MarkEventsToIndex(tc.events, tc.indexSet)) }) diff --git a/types/int.go b/types/int.go index b18be80776..a79da3456f 100644 --- a/types/int.go +++ b/types/int.go @@ -403,7 +403,7 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) { // Unmarshal implements the gogo proto custom type interface. func (i *Int) Unmarshal(data []byte) error { if len(data) == 0 { - i = nil + i = nil //nolint: wastedassign return nil } diff --git a/types/int_test.go b/types/int_test.go index bdf7a62eca..59513f258c 100644 --- a/types/int_test.go +++ b/types/int_test.go @@ -404,7 +404,6 @@ func TestRoundTripMarshalToInt(t *testing.T) { } for _, value := range values { - value := value t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { t.Parallel() diff --git a/types/simulation/account_test.go b/types/simulation/account_test.go index 210a8b9c8b..fa3229ca14 100644 --- a/types/simulation/account_test.go +++ b/types/simulation/account_test.go @@ -24,7 +24,6 @@ func TestRandomAccounts(t *testing.T) { {"100-accounts", 100, 100}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := simulation.RandomAccounts(r, tt.n) require.Equal(t, tt.want, len(got)) @@ -65,8 +64,6 @@ func TestRandomFees(t *testing.T) { {"0 coins", sdk.NewCoins(sdk.NewInt64Coin("aaa", 10), sdk.NewInt64Coin("bbb", 5)), false, false}, } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got, err := simulation.RandomFees(r, sdk.Context{}, tt.spendableCoins) if (err != nil) != tt.wantErr { diff --git a/types/simulation/rand_util_test.go b/types/simulation/rand_util_test.go index d46f481fda..860bfb172f 100644 --- a/types/simulation/rand_util_test.go +++ b/types/simulation/rand_util_test.go @@ -23,7 +23,6 @@ func TestRandSubsetCoins(t *testing.T) { {"seed=99", rand.New(rand.NewSource(99)), mustParseCoins("100stake,2testtoken")}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := simulation.RandSubsetCoins(tt.r, tt.coins) gotStringRep := got.String() @@ -46,8 +45,6 @@ func TestRandStringOfLength(t *testing.T) { {"1_000_000-size", 1_000_000, 1_000_000}, } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got := simulation.RandStringOfLength(r, tt.n) require.Equal(t, tt.want, len(got)) diff --git a/types/uint.go b/types/uint.go index 5e59780e76..4eeb3cd9ec 100644 --- a/types/uint.go +++ b/types/uint.go @@ -22,7 +22,7 @@ func (u Uint) BigInt() *big.Int { 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 } @@ -178,7 +178,7 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) { // Unmarshal implements the gogo proto custom type interface. func (u *Uint) Unmarshal(data []byte) error { if len(data) == 0 { - u = nil + u = nil //nolint: wastedassign return nil } diff --git a/types/uint_test.go b/types/uint_test.go index 796dd2b428..dd46e16ae9 100644 --- a/types/uint_test.go +++ b/types/uint_test.go @@ -216,7 +216,6 @@ func (s *uintTestSuite) TestSafeSub() { } for i, tc := range testCases { - tc := tc if tc.panic { s.Require().Panics(func() { tc.x.Sub(tc.y) }) continue @@ -304,7 +303,6 @@ func TestRoundTripMarshalToUint(t *testing.T) { } for _, value := range values { - value := value t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { t.Parallel() diff --git a/types/utils_test.go b/types/utils_test.go index 253db8e696..391dc4eb71 100644 --- a/types/utils_test.go +++ b/types/utils_test.go @@ -54,7 +54,6 @@ func (s *utilsTestSuite) TestSortJSON() { } for tcIndex, tc := range cases { - tc := tc got, err := sdk.SortJSON([]byte(tc.unsortedJSON)) if tc.wantErr { s.Require().NotNil(err, "tc #%d", tcIndex) @@ -79,7 +78,6 @@ func (s *utilsTestSuite) TestTimeFormatAndParse() { {"2011-01-10T23:10:05.758230235Z", "2011-01-10T23:10:05.758230235", true}, } for _, tc := range cases { - tc := tc timeFromRFC, err := time.Parse(time.RFC3339Nano, tc.RFC3339NanoStr) s.Require().Nil(err) timeFromSDKFormat, err := time.Parse(sdk.SortableTimeFormat, tc.SDKSortableTimeStr) diff --git a/x/auth/ante/basic_test.go b/x/auth/ante/basic_test.go index 995b3efe9b..5ac84f506a 100644 --- a/x/auth/ante/basic_test.go +++ b/x/auth/ante/basic_test.go @@ -198,8 +198,6 @@ func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index d168be7eec..49529ac348 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -308,11 +308,11 @@ func (svd *SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu if !simulate { if !genesis { sigKey := fmt.Sprintf("%d:%d", signerData.AccountNumber, signerData.Sequence) - // TODO could we use `tx.(*wrapper).getBodyBytes()` instead of `ctx.TxBytes()`? + // TODO: could we use `tx.(*wrapper).getBodyBytes()` instead of `ctx.TxBytes()`? txHash := sha256.Sum256(ctx.TxBytes()) - stored := false + var stored bool - // TODO(duong2): Does this really improve performance? + // TODO: Does this really improve performance? stored, err = svd.verifySignatureWithCache(ctx, pubKey, signerData, sig.Data, tx, sigKey, txHash[:]) if stored { diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 41a3a599fa..5bdf11122a 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -331,7 +331,6 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByHash() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := authcli.QueryTxCmd() clientCtx := val.ClientCtx @@ -447,7 +446,6 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := authcli.QueryTxCmd() clientCtx := val.ClientCtx @@ -526,7 +524,6 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := authcli.QueryTxsByEventsCmd() clientCtx := val.ClientCtx @@ -1166,7 +1163,6 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -1205,7 +1201,6 @@ func (s *IntegrationTestSuite) TestGetAccountsCmd() { } for name, tc := range testCases { - tc := tc s.Run(name, func() { cmd := authcli.GetAccountsCmd() clientCtx := val.ClientCtx @@ -1245,7 +1240,6 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountByNameCmd() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -1274,7 +1268,7 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountByNameCmd() { func TestGetBroadcastCommandOfflineFlag(t *testing.T) { clientCtx := client.Context{}.WithOffline(true) - clientCtx = clientCtx.WithTxConfig(simapp.MakeTestEncodingConfig().TxConfig) //nolint:staticcheck + _ = clientCtx.WithTxConfig(simapp.MakeTestEncodingConfig().TxConfig) cmd := authcli.GetBroadcastCommand() _ = testutil.ApplyMockIODiscardOutErr(cmd) @@ -1335,7 +1329,6 @@ func (s *IntegrationTestSuite) TestQueryParamsCmd() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := authcli.QueryParamsCmd() clientCtx := val.ClientCtx diff --git a/x/auth/client/tx.go b/x/auth/client/tx.go index 9f4690f639..2f45549e45 100644 --- a/x/auth/client/tx.go +++ b/x/auth/client/tx.go @@ -52,7 +52,7 @@ func SignTx(txFactory tx.Factory, clientCtx client.Context, name string, txBuild addr := sdk.AccAddress(info.GetPubKey().Address()) if !isTxSigner(addr, txBuilder.GetTx().GetSigners()) { - return fmt.Errorf("%s: %s", sdkerrors.ErrorInvalidSigner, name) + return fmt.Errorf("%w: %s", sdkerrors.ErrorInvalidSigner, name) } if !offline { txFactory, err = populateAccountFromState(txFactory, clientCtx, addr) @@ -79,7 +79,7 @@ func SignTxWithSignerAddress(txFactory tx.Factory, clientCtx client.Context, add // check whether the address is a signer if !isTxSigner(addr, txBuilder.GetTx().GetSigners()) { - return fmt.Errorf("%s: %s", sdkerrors.ErrorInvalidSigner, name) + return fmt.Errorf("%w: %s", sdkerrors.ErrorInvalidSigner, name) } if !offline { diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index de086fe19b..2a027753cf 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -39,7 +39,7 @@ func TestParseQueryResponse(t *testing.T) { require.Equal(t, 10, int(res.GasInfo.GasUsed)) require.NotNil(t, res.Result) - res, err = authclient.ParseQueryResponse([]byte("fuzzy")) + _, err = authclient.ParseQueryResponse([]byte("fuzzy")) require.Error(t, err) } @@ -123,7 +123,6 @@ func TestBatchScanner_Scan(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { scanner, i := authclient.NewBatchScanner(clientCtx.TxConfig, strings.NewReader(tt.batch)), 0 for scanner.Scan() { diff --git a/x/auth/legacy/v043/store_test.go b/x/auth/legacy/v043/store_test.go index 2d72024791..1ed227a9d7 100644 --- a/x/auth/legacy/v043/store_test.go +++ b/x/auth/legacy/v043/store_test.go @@ -537,7 +537,6 @@ func TestMigrateVestingAccounts(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{ diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index d4a5bc353a..7b8bcee89c 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -57,7 +57,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/auth/tx/encode_decode_test.go b/x/auth/tx/encode_decode_test.go index 9c546cdb5e..4eab9a3fed 100644 --- a/x/auth/tx/encode_decode_test.go +++ b/x/auth/tx/encode_decode_test.go @@ -101,7 +101,6 @@ func TestUnknownFields(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { bodyBz, err := tt.body.Marshal() require.NoError(t, err) @@ -244,7 +243,6 @@ func TestRejectNonADR027(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { _, err = decoder(tt.txBz) if tt.shouldErr { @@ -282,7 +280,6 @@ func TestVarintMinLength(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(fmt.Sprintf("test %d", tt.n), func(t *testing.T) { l1 := varintMinLength(tt.n) buf := make([]byte, binary.MaxVarintLen64) diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index 8089f74fee..0b65b2d2cd 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -135,7 +135,6 @@ func (s *IntegrationTestSuite) TestSimulateTx_GRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { // Broadcast the tx via gRPC via the validator's clientCtx (which goes // through Tendermint). @@ -457,7 +456,6 @@ func (s *IntegrationTestSuite) TestBroadcastTx_GRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { // Broadcast the tx via gRPC via the validator's clientCtx (which goes // through Tendermint). diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index a90a633051..8f4b1cc9af 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -104,8 +104,6 @@ func TestGenesisAccountValidate(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expErr, tt.acc.Validate() != nil) }) @@ -170,7 +168,6 @@ func TestValidate(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { err := tt.acc.Validate() require.Equal(t, tt.expErr, err) diff --git a/x/auth/types/params_test.go b/x/auth/types/params_test.go index b4bbce8ba0..aeb5c48d6a 100644 --- a/x/auth/types/params_test.go +++ b/x/auth/types/params_test.go @@ -37,7 +37,6 @@ func TestParams_Validate(t *testing.T) { types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx size cost per byte: 0")}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := tt.params.Validate() if tt.wantErr == nil { diff --git a/x/auth/types/permissions_test.go b/x/auth/types/permissions_test.go index de5c256457..78133007da 100644 --- a/x/auth/types/permissions_test.go +++ b/x/auth/types/permissions_test.go @@ -41,7 +41,6 @@ func TestValidatePermissions(t *testing.T) { } for i, tc := range cases { - i, tc := i, tc t.Run(tc.name, func(t *testing.T) { err := validatePermissions(tc.permissions...) if tc.expectPass { diff --git a/x/auth/vesting/client/testutil/suite.go b/x/auth/vesting/client/testutil/suite.go index 7f8be8d668..a486b5ee84 100644 --- a/x/auth/vesting/client/testutil/suite.go +++ b/x/auth/vesting/client/testutil/suite.go @@ -112,8 +112,6 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { clientCtx := val.ClientCtx diff --git a/x/auth/vesting/handler_test.go b/x/auth/vesting/handler_test.go index 9bd3c2ca6b..ceaa19e6e9 100644 --- a/x/auth/vesting/handler_test.go +++ b/x/auth/vesting/handler_test.go @@ -62,8 +62,6 @@ func (suite *HandlerTestSuite) TestMsgCreateVestingAccount() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { res, err := suite.handler(ctx, tc.msg) if tc.expectErr { diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 4c359c40a6..4dd3df3951 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -3,7 +3,7 @@ package vesting import ( "context" - "github.com/armon/go-metrics" + "github.com/hashicorp/go-metrics" "github.com/Finschia/finschia-sdk/telemetry" sdk "github.com/Finschia/finschia-sdk/types" diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 26cbbcdeb7..40e48bbf4c 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -728,8 +728,6 @@ func TestGenesisAccountValidate(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expErr, tt.acc.Validate() != nil) }) diff --git a/x/authz/client/testutil/grpc.go b/x/authz/client/testutil/grpc.go index 7b5bbb6adf..43cbca59cd 100644 --- a/x/authz/client/testutil/grpc.go +++ b/x/authz/client/testutil/grpc.go @@ -60,7 +60,6 @@ func (s *IntegrationTestSuite) TestQueryGrantGRPC() { }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, _ := rest.GetRequest(tc.url) require := s.Require() @@ -146,7 +145,6 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { tc.preRun() resp, _ := rest.GetRequest(tc.url) diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 07ffb10315..698c832d6d 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -73,8 +73,6 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() { }, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryGrants() clientCtx := val.ClientCtx @@ -165,8 +163,6 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { }, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryGrants() clientCtx := val.ClientCtx diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index fdf3d150b4..831e26e6d8 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -311,7 +311,6 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { clientCtx := val.ClientCtx out, err := ExecGrant( @@ -464,7 +463,6 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdRevokeAuthorization() clientCtx := val.ClientCtx @@ -606,7 +604,6 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -691,7 +688,6 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -787,7 +783,6 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -864,7 +859,6 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -1008,7 +1002,6 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -1087,7 +1080,6 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx diff --git a/x/authz/keeper/grpc_query_test.go b/x/authz/keeper/grpc_query_test.go index efc5b1226a..a65c48e83b 100644 --- a/x/authz/keeper/grpc_query_test.go +++ b/x/authz/keeper/grpc_query_test.go @@ -228,8 +228,6 @@ func (suite *TestSuite) TestGRPCQueryGranterGrants() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { tc.preRun() result, err := queryClient.GranterGrants(gocontext.Background(), &tc.request) @@ -315,8 +313,6 @@ func (suite *TestSuite) TestGRPCQueryGranteeGrants() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { tc.preRun() result, err := queryClient.GranteeGrants(gocontext.Background(), &tc.request) diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index fc43ef917d..244a9722c4 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -41,7 +41,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { if tt.expectErr { require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) diff --git a/x/bank/client/testutil/grpc.go b/x/bank/client/testutil/grpc.go index 3d9651eff9..d3b418dc27 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/testutil/grpc.go @@ -88,7 +88,6 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) @@ -209,7 +208,6 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) @@ -273,7 +271,6 @@ func (s *IntegrationTestSuite) TestBalancesGRPCHandler() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 6358107cdf..abab55d41c 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -145,8 +145,6 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetBalancesCmd() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args) @@ -225,8 +223,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryTotalSupply() clientCtx := val.ClientCtx @@ -367,8 +363,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdDenomsMetadata() clientCtx := val.ClientCtx @@ -475,8 +469,6 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { clientCtx := val.ClientCtx diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go index fe680e04ee..065bd8d37b 100644 --- a/x/bank/keeper/genesis.go +++ b/x/bank/keeper/genesis.go @@ -42,7 +42,7 @@ func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { func (k BaseKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { totalSupply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) if err != nil { - panic(fmt.Errorf("unable to fetch total supply %v", err)) + panic(fmt.Errorf("unable to fetch total supply: %w", err)) } return types.NewGenesisState( diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 4c5c6ea86b..36aee9a1a9 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -99,7 +99,6 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { } for _, tc := range testcases { - tc := tc suite.Run(tc.name, func() { if tc.expPanic { suite.PanicsWithError(tc.expPanicMsg, func() { suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) }) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 3e004a1e31..e66d63f267 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -72,7 +72,7 @@ func (k BaseKeeper) GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.P var amount sdk.Int err := amount.Unmarshal(value) if err != nil { - return fmt.Errorf("unable to convert amount string to Int %v", err) + return fmt.Errorf("unable to convert amount string to Int: %w", err) } // `Add` omits the 0 coins addition to the `supply`. @@ -231,7 +231,7 @@ func (k BaseKeeper) GetSupply(ctx sdk.Context, denom string) sdk.Coin { var amount sdk.Int err := amount.Unmarshal(bz) if err != nil { - panic(fmt.Errorf("unable to unmarshal supply value %v", err)) + panic(fmt.Errorf("unable to unmarshal supply value: %w", err)) } return sdk.Coin{ @@ -466,7 +466,7 @@ func (k BaseKeeper) BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Co func (k BaseKeeper) setSupply(ctx sdk.Context, coin sdk.Coin) { intBytes, err := coin.Amount.Marshal() if err != nil { - panic(fmt.Errorf("unable to marshal amount value %v", err)) + panic(fmt.Errorf("unable to marshal amount value: %w", err)) } store := ctx.KVStore(k.storeKey) @@ -528,7 +528,7 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bo var amount sdk.Int err := amount.Unmarshal(iterator.Value()) if err != nil { - panic(fmt.Errorf("unable to unmarshal supply value %v", err)) + panic(fmt.Errorf("unable to unmarshal supply value: %w", err)) } balance := sdk.Coin{ diff --git a/x/bank/keeper/msg_server.go b/x/bank/keeper/msg_server.go index a19186231b..b869bf4b00 100644 --- a/x/bank/keeper/msg_server.go +++ b/x/bank/keeper/msg_server.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/armon/go-metrics" + "github.com/hashicorp/go-metrics" "github.com/Finschia/finschia-sdk/telemetry" sdk "github.com/Finschia/finschia-sdk/types" diff --git a/x/bank/simulation/genesis_test.go b/x/bank/simulation/genesis_test.go index 40d9afe119..efbdf4cf42 100644 --- a/x/bank/simulation/genesis_test.go +++ b/x/bank/simulation/genesis_test.go @@ -70,8 +70,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index b18a0f7b13..7080371306 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -102,7 +102,6 @@ func TestBalanceValidate(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.balance.Validate() @@ -126,7 +125,6 @@ func TestBalance_GetAddress(t *testing.T) { {"valid address", "link1vy0ga0klndqy92ceqehfkvgmn4t94ete4mhemy", false}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { b := bank.Balance{Address: tt.Address} if tt.wantPanic { diff --git a/x/bank/types/genesis_test.go b/x/bank/types/genesis_test.go index d5588245b2..637306464a 100644 --- a/x/bank/types/genesis_test.go +++ b/x/bank/types/genesis_test.go @@ -143,7 +143,6 @@ func TestGenesisStateValidate(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.genesisState.Validate() diff --git a/x/bank/types/key_test.go b/x/bank/types/key_test.go index 54a2ee64a9..193001f4f5 100644 --- a/x/bank/types/key_test.go +++ b/x/bank/types/key_test.go @@ -39,7 +39,6 @@ func TestAddressFromBalancesStore(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() addr, err := types.AddressFromBalancesStore(tc.key) diff --git a/x/bank/types/metadata_test.go b/x/bank/types/metadata_test.go index 1201e0473b..d895a0226d 100644 --- a/x/bank/types/metadata_test.go +++ b/x/bank/types/metadata_test.go @@ -216,7 +216,6 @@ func TestMetadataValidate(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.metadata.Validate() @@ -258,7 +257,6 @@ func TestMarshalJSONMetaData(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { bz, err := cdc.MarshalJSON(tc.input) require.NoError(t, err) diff --git a/x/bank/types/params_test.go b/x/bank/types/params_test.go index 0962d125c1..1ca04f6474 100644 --- a/x/bank/types/params_test.go +++ b/x/bank/types/params_test.go @@ -29,7 +29,6 @@ func Test_validateSendEnabledParam(t *testing.T) { {"invalid denom send disabled", args{*NewSendEnabled("0FOO", false)}, true}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.wantErr, validateSendEnabled(tt.args.i) != nil) }) diff --git a/x/bankplus/keeper/keeper_test.go b/x/bankplus/keeper/keeper_test.go index 3486106a61..37f271d7c7 100644 --- a/x/bankplus/keeper/keeper_test.go +++ b/x/bankplus/keeper/keeper_test.go @@ -294,7 +294,6 @@ func (suite *IntegrationTestSuite) TestInputOutputCoins() { } for name, tc := range tcs { - tc := tc suite.T().Run(name, func(t *testing.T) { if tc.err != nil { suite.EqualError(targetKeeper(tc.deactMultiSend).InputOutputCoins(ctx, input, output), tc.err.Error()) diff --git a/x/capability/simulation/decoder_test.go b/x/capability/simulation/decoder_test.go index d12e8b5044..ce87e508e6 100644 --- a/x/capability/simulation/decoder_test.go +++ b/x/capability/simulation/decoder_test.go @@ -47,7 +47,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/capability/simulation/genesis_test.go b/x/capability/simulation/genesis_test.go index ab49833f1d..46b2687b50 100644 --- a/x/capability/simulation/genesis_test.go +++ b/x/capability/simulation/genesis_test.go @@ -66,8 +66,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/capability/types/genesis_test.go b/x/capability/types/genesis_test.go index 5208a2b590..41525fb827 100644 --- a/x/capability/types/genesis_test.go +++ b/x/capability/types/genesis_test.go @@ -112,7 +112,6 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { - tc := tc genState := DefaultGenesis() tc.malleate(genState) err := genState.Validate() diff --git a/x/collection/client/testutil/query.go b/x/collection/client/testutil/query.go index 0ca3c830b0..4c01a95320 100644 --- a/x/collection/client/testutil/query.go +++ b/x/collection/client/testutil/query.go @@ -65,8 +65,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdBalance() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdBalances() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -141,8 +139,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdFTSupply() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdFTSupply() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -217,8 +213,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdFTMinted() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdFTMinted() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -293,8 +287,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdFTBurnt() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdFTBurnt() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -368,8 +360,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdNFTSupply() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdNFTSupply() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -443,8 +433,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdNFTMinted() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdNFTMinted() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -518,8 +506,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdNFTBurnt() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdNFTBurnt() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -573,8 +559,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdContract() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdContract() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -643,8 +627,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdTokenType() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdTokenType() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -719,8 +701,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdToken() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdToken() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -793,8 +773,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdRoot() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdRoot() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -865,8 +843,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdParent() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdParent() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -941,8 +917,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdChildren() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdChildren() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1020,8 +994,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdGranteeGrants() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdGranteeGrants() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1082,8 +1054,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdIsOperatorFor() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdIsOperatorFor() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1142,8 +1112,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdHoldersByOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdHoldersByOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/collection/client/testutil/tx.go b/x/collection/client/testutil/tx.go index a0aee34cde..b7c18d0e0a 100644 --- a/x/collection/client/testutil/tx.go +++ b/x/collection/client/testutil/tx.go @@ -71,8 +71,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdSendFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdSendFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -155,8 +153,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorSendFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorSendFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -234,8 +230,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdSendNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdSendNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -318,8 +312,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorSendNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorSendNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -374,8 +366,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdCreateContract() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdCreateContract() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -441,8 +431,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdIssueFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdIssueFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -502,8 +490,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdIssueNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdIssueNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -575,8 +561,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdMintFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -645,8 +629,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdMintNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -711,8 +693,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdBurnFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdBurnFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -781,8 +761,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorBurnFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorBurnFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -847,8 +825,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdBurnNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdBurnNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -917,8 +893,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorOperatorBurnNFT() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorBurnNFT() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -994,8 +968,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdModify() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdModify() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1065,8 +1037,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdAttach() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdAttach() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1131,8 +1101,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdDetach() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdDetach() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1206,8 +1174,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorAttach() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorAttach() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1276,8 +1242,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorDetach() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorDetach() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1336,8 +1300,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdGrantPermission() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdGrantPermission() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1393,8 +1355,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdRevokePermission() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdRevokePermission() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1450,8 +1410,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdAuthorizeOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdAuthorizeOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -1507,8 +1465,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdRevokeOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdRevokeOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/collection/msgs_test.go b/x/collection/msgs_test.go index 04de79a91c..3a094d899d 100644 --- a/x/collection/msgs_test.go +++ b/x/collection/msgs_test.go @@ -2067,7 +2067,6 @@ func TestAminoJSON(t *testing.T) { } for name, tc := range testCase { - tc := tc t.Run(name, func(t *testing.T) { tx.Msgs = []sdk.Msg{tc.msg} require.Equal(t, collection.RouterKey, tc.msg.Route()) diff --git a/x/crisis/client/testsuite/suite.go b/x/crisis/client/testsuite/suite.go index 8ac29d8ad3..75c06177c4 100644 --- a/x/crisis/client/testsuite/suite.go +++ b/x/crisis/client/testsuite/suite.go @@ -83,8 +83,6 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewMsgVerifyInvariantTxCmd() clientCtx := val.ClientCtx diff --git a/x/crisis/handler_test.go b/x/crisis/handler_test.go index c174ce536c..dc646d5338 100644 --- a/x/crisis/handler_test.go +++ b/x/crisis/handler_test.go @@ -58,7 +58,6 @@ func TestHandleMsgVerifyInvariant(t *testing.T) { } for _, tc := range cases { - tc := tc t.Run(tc.name, func(t *testing.T) { h := crisis.NewHandler(app.CrisisKeeper) diff --git a/x/distribution/client/common/common_test.go b/x/distribution/client/common/common_test.go index f81db2b6d4..168cb16fd5 100644 --- a/x/distribution/client/common/common_test.go +++ b/x/distribution/client/common/common_test.go @@ -30,7 +30,6 @@ func TestQueryDelegationRewardsAddrValidation(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { _, _, err := QueryDelegationRewards(clientCtx, tt.args.delAddr, tt.args.valAddr) require.True(t, err != nil, tt.wantErr) diff --git a/x/distribution/client/testutil/grpc.go b/x/distribution/client/testutil/grpc.go index 76fc652c15..ceaf4627a1 100644 --- a/x/distribution/client/testutil/grpc.go +++ b/x/distribution/client/testutil/grpc.go @@ -56,7 +56,6 @@ func (s *GRPCQueryTestSuite) TestQueryParamsGRPC() { } for _, tc := range testCases { - tc := tc resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { s.Require().NoError(err) @@ -106,7 +105,6 @@ func (s *GRPCQueryTestSuite) TestQueryOutstandingRewardsGRPC() { } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { if tc.expErr { @@ -160,7 +158,6 @@ func (s *GRPCQueryTestSuite) TestQueryValidatorCommissionGRPC() { } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { if tc.expErr { @@ -218,7 +215,6 @@ func (s *GRPCQueryTestSuite) TestQuerySlashesGRPC() { } for _, tc := range testCases { - tc := tc resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { @@ -294,7 +290,6 @@ func (s *GRPCQueryTestSuite) TestQueryDelegatorRewardsGRPC() { } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { @@ -346,7 +341,6 @@ func (s *GRPCQueryTestSuite) TestQueryDelegatorValidatorsGRPC() { } for _, tc := range testCases { - tc := tc resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { @@ -398,7 +392,6 @@ func (s *GRPCQueryTestSuite) TestQueryWithdrawAddressGRPC() { } for _, tc := range testCases { - tc := tc resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { @@ -443,7 +436,6 @@ func (s *GRPCQueryTestSuite) TestQueryValidatorCommunityPoolGRPC() { } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index 4f9513580a..1e10b432be 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -86,8 +86,6 @@ withdraw_addr_enabled: true`, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryParams() clientCtx := val.ClientCtx @@ -145,8 +143,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidatorOutstandingRewards() clientCtx := val.ClientCtx @@ -208,8 +204,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidatorCommission() clientCtx := val.ClientCtx @@ -287,8 +281,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidatorSlashes() clientCtx := val.ClientCtx @@ -388,8 +380,6 @@ total: } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryDelegatorRewards() clientCtx := val.ClientCtx @@ -431,8 +421,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryCommunityPool() clientCtx := val.ClientCtx @@ -492,8 +480,6 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -544,8 +530,6 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewWithdrawAllRewardsCmd() clientCtx := val.ClientCtx @@ -599,8 +583,6 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewSetWithdrawAddrCmd() clientCtx := val.ClientCtx @@ -654,8 +636,6 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewFundCommunityPoolCmd() clientCtx := val.ClientCtx @@ -727,8 +707,6 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdSubmitProposal() clientCtx := val.ClientCtx diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 62bc93f4bf..28c8e7869c 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -142,7 +142,7 @@ func TestAllocateTokensTruncation(t *testing.T) { Address: valConsPk2.Address(), Power: 10, } - abciValС := abci.Validator{ + abciValC := abci.Validator{ Address: valConsPk3.Address(), Power: 10, } @@ -177,7 +177,7 @@ func TestAllocateTokensTruncation(t *testing.T) { SignedLastBlock: true, }, { - Validator: abciValС, + Validator: abciValC, SignedLastBlock: true, }, } diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index 107f8a5d96..d7fbe87723 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/armon/go-metrics" + "github.com/hashicorp/go-metrics" "github.com/Finschia/finschia-sdk/telemetry" sdk "github.com/Finschia/finschia-sdk/types" diff --git a/x/distribution/legacy/v043/store_test.go b/x/distribution/legacy/v043/store_test.go index fff87528a9..4c8ff1d522 100644 --- a/x/distribution/legacy/v043/store_test.go +++ b/x/distribution/legacy/v043/store_test.go @@ -88,7 +88,6 @@ func TestStoreMigration(t *testing.T) { // Make sure the new keys are set and old keys are deleted. for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { if !bytes.Equal(tc.oldKey, tc.newKey) { require.Nil(t, store.Get(tc.oldKey)) diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index f37bb4fab8..841aaf5f17 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -66,7 +66,6 @@ func TestDecodeDistributionStore(t *testing.T) { {"other", ""}, } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/distribution/simulation/genesis_test.go b/x/distribution/simulation/genesis_test.go index 8db6652da6..1724ef5fa9 100644 --- a/x/distribution/simulation/genesis_test.go +++ b/x/distribution/simulation/genesis_test.go @@ -76,8 +76,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/distribution/types/params_internal_test.go b/x/distribution/types/params_internal_test.go index 234a79fbd1..152845f00c 100644 --- a/x/distribution/types/params_internal_test.go +++ b/x/distribution/types/params_internal_test.go @@ -24,7 +24,6 @@ func Test_validateAuxFuncs(t *testing.T) { {"two dec", args{sdk.NewDec(2)}, true}, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.wantErr, validateCommunityTax(tt.args.i) != nil) require.Equal(t, tt.wantErr, validateBaseProposerReward(tt.args.i) != nil) diff --git a/x/evidence/client/testutil/suite.go b/x/evidence/client/testutil/suite.go index 3fdba740e9..80e2ce89b4 100644 --- a/x/evidence/client/testutil/suite.go +++ b/x/evidence/client/testutil/suite.go @@ -56,8 +56,6 @@ func (s *IntegrationTestSuite) TestGetQueryCmd() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.GetQueryCmd() clientCtx := val.ClientCtx diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index 3e18656b6c..eeca030223 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -52,7 +52,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/evidence/types/evidence_test.go b/x/evidence/types/evidence_test.go index 696600d0ad..c7a0be8e53 100644 --- a/x/evidence/types/evidence_test.go +++ b/x/evidence/types/evidence_test.go @@ -52,7 +52,6 @@ func TestEquivocationValidateBasic(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.expectErr, tc.e.ValidateBasic() != nil) }) diff --git a/x/fbridge/keeper/transfer.go b/x/fbridge/keeper/transfer.go index 333fa72f23..2eabb45cb5 100644 --- a/x/fbridge/keeper/transfer.go +++ b/x/fbridge/keeper/transfer.go @@ -27,7 +27,7 @@ func (k Keeper) handleBridgeTransfer(ctx sdk.Context, sender sdk.AccAddress, amo } if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, token); err != nil { - panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %s", err)) + panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %w", err)) } seq := k.GetNextSequence(ctx) diff --git a/x/fbridge/types/msgs_test.go b/x/fbridge/types/msgs_test.go index 87166e0ad4..b339c7d592 100644 --- a/x/fbridge/types/msgs_test.go +++ b/x/fbridge/types/msgs_test.go @@ -137,7 +137,6 @@ func TestAminoJSON(t *testing.T) { } for name, tc := range testCase { - tc := tc t.Run(name, func(t *testing.T) { tx.Msgs = []sdk.Msg{tc.msg} require.Equal(t, fbridgetypes.RouterKey, tc.msg.Route()) diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index cac943e7b7..3e75a99d2d 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -168,8 +168,6 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -234,8 +232,6 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryFeeGrantsByGrantee() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -290,8 +286,6 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryFeeGrantsByGranter() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -583,8 +577,6 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -690,8 +682,6 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewCmdRevokeFeegrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -829,8 +819,6 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewCmdFeeGrant() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -924,8 +912,6 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() { } for _, tc := range cases { - tc := tc - s.Run(tc.name, func() { out, err := tc.malleate() s.Require().NoError(err) diff --git a/x/feegrant/grant_test.go b/x/feegrant/grant_test.go index 2368c77d3d..af0f1873c9 100644 --- a/x/feegrant/grant_test.go +++ b/x/feegrant/grant_test.go @@ -73,7 +73,6 @@ func TestGrant(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { grant, err := feegrant.NewGrant(tc.granter, tc.grantee, &feegrant.BasicAllowance{ SpendLimit: tc.limit, diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go index ea2731cb4b..9f659bf30c 100644 --- a/x/feegrant/keeper/genesis_test.go +++ b/x/feegrant/keeper/genesis_test.go @@ -100,7 +100,6 @@ func (suite *GenesisTestSuite) TestInitGenesis() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := suite.keeper.InitGenesis(suite.ctx, &feegrant.GenesisState{Allowances: tc.feeAllowances}) suite.Require().Error(err) diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 5851f8e978..b6f843a6c7 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -120,7 +120,6 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { } for name, tc := range cases { - tc := tc suite.Run(name, func() { allow, _ := suite.keeper.GetAllowance(suite.sdkCtx, tc.granter, tc.grantee) @@ -196,7 +195,6 @@ func (suite *KeeperTestSuite) TestUseGrantedFee() { } for name, tc := range cases { - tc := tc suite.Run(name, func() { err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], future) suite.Require().NoError(err) diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 989387f831..c13e75111f 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -49,7 +49,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/feegrant/types/grant_test.go b/x/feegrant/types/grant_test.go index 687fe37351..2831eb09ec 100644 --- a/x/feegrant/types/grant_test.go +++ b/x/feegrant/types/grant_test.go @@ -71,7 +71,6 @@ func TestGrant(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { grant, err := feegrant.NewGrant(tc.granter, tc.grantee, &feegrant.BasicAllowance{ SpendLimit: tc.limit, diff --git a/x/foundation/client/testutil/grpc.go b/x/foundation/client/testutil/grpc.go index 7f16e5675f..b0103983ef 100644 --- a/x/foundation/client/testutil/grpc.go +++ b/x/foundation/client/testutil/grpc.go @@ -34,7 +34,6 @@ func (s *IntegrationTestSuite) TestGRPCParams() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) diff --git a/x/foundation/client/testutil/query.go b/x/foundation/client/testutil/query.go index a7d16e38d2..0703d382ee 100644 --- a/x/foundation/client/testutil/query.go +++ b/x/foundation/client/testutil/query.go @@ -44,8 +44,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdParams() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdParams() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -86,8 +84,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdTreasury() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdTreasury() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -127,8 +123,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdFoundationInfo() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdFoundationInfo() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -184,8 +178,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdMember() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdMember() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -226,8 +218,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdMembers() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdMembers() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -276,8 +266,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdProposal() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdProposal() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -317,8 +305,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdProposals() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdProposals() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -377,8 +363,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVote() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdVote() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -427,8 +411,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdVotes() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdVotes() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -477,8 +459,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdTallyResult() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdTallyResult() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -521,8 +501,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdCensorships() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdCensorships() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -586,8 +564,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdGrants() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdGrants() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/foundation/client/testutil/tx.go b/x/foundation/client/testutil/tx.go index ccc283cb8c..b73acc158e 100644 --- a/x/foundation/client/testutil/tx.go +++ b/x/foundation/client/testutil/tx.go @@ -44,8 +44,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdFundTreasury() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdFundTreasury() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -92,8 +90,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdWithdrawFromTreasury() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdWithdrawFromTreasury() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -138,8 +134,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdUpdateMembers() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdUpdateMembers() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -198,8 +192,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdUpdateDecisionPolicy() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdUpdateDecisionPolicy() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -249,8 +241,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdSubmitProposal() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdSubmitProposal() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -299,8 +289,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdWithdrawProposal() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdWithdrawProposal() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -353,8 +341,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdVote() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdVote() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -402,8 +388,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdExec() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdExec() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -466,8 +450,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdUpdateCensorship() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdUpdateCensorship() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -512,8 +494,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdLeaveFoundation() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdLeaveFoundation() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -565,8 +545,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdGrant() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdGrant() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -612,8 +590,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdRevoke() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdRevoke() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/foundation/genesis_test.go b/x/foundation/genesis_test.go index ba0807f6b6..6da5692ffa 100644 --- a/x/foundation/genesis_test.go +++ b/x/foundation/genesis_test.go @@ -407,8 +407,6 @@ func TestValidateGenesis(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { var unmarshalled foundation.GenesisState err := cdc.UnmarshalJSON(tc.raw, &unmarshalled) diff --git a/x/foundation/keeper/internal/keeper_test.go b/x/foundation/keeper/internal/keeper_test.go index 1b81a82a20..de255389b1 100644 --- a/x/foundation/keeper/internal/keeper_test.go +++ b/x/foundation/keeper/internal/keeper_test.go @@ -278,7 +278,6 @@ func TestNewKeeper(t *testing.T) { } for name, tc := range testCases { - tc := tc t.Run(name, func(t *testing.T) { newKeeper := func() keeper.Keeper { app := simapp.Setup(false) diff --git a/x/foundation/keeper/internal/proposal.go b/x/foundation/keeper/internal/proposal.go index 2003e83f07..0495f45769 100644 --- a/x/foundation/keeper/internal/proposal.go +++ b/x/foundation/keeper/internal/proposal.go @@ -180,8 +180,6 @@ func (k Keeper) UpdateTallyOfVPEndProposals(ctx sdk.Context) { }) for _, proposal := range proposals { - proposal := proposal - if proposal.Status == foundation.PROPOSAL_STATUS_ABORTED || proposal.Status == foundation.PROPOSAL_STATUS_WITHDRAWN { k.pruneProposal(ctx, proposal) continue diff --git a/x/foundation/msgs_test.go b/x/foundation/msgs_test.go index ff79d17620..4480243dfc 100644 --- a/x/foundation/msgs_test.go +++ b/x/foundation/msgs_test.go @@ -713,8 +713,6 @@ func TestAminoJSON(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { require.Equal(t, tc.expected, string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{tc.msg}, "memo"))) }) @@ -778,8 +776,6 @@ func TestMsgSubmitProposalAminoJSON(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { proposalMsg := &foundation.MsgSubmitProposal{ Proposers: []string{proposer.String()}, @@ -824,8 +820,6 @@ func TestMsgUpdateDecisionPolicyAminoJson(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { policyMsg := &foundation.MsgUpdateDecisionPolicy{ Authority: authority.String(), @@ -867,8 +861,6 @@ func TestMsgGrantAminoJson(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { grantMsg := &foundation.MsgGrant{ Authority: operator.String(), diff --git a/x/fswap/client/testutil/grpc.go b/x/fswap/client/testutil/grpc.go index 74e81b200a..1443f03401 100644 --- a/x/fswap/client/testutil/grpc.go +++ b/x/fswap/client/testutil/grpc.go @@ -52,7 +52,6 @@ func (s *IntegrationTestSuite) TestGRPCQuerySwap() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -91,7 +90,6 @@ func (s *IntegrationTestSuite) TestGRPCQuerySwaps() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -148,7 +146,6 @@ func (s *IntegrationTestSuite) TestGRPCQuerySwapped() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, map[string]string{ grpctypes.GRPCBlockHeightHeader: "1", @@ -206,7 +203,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryTotalSwappableAmount() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, map[string]string{ grpctypes.GRPCBlockHeightHeader: "1", diff --git a/x/fswap/client/testutil/query.go b/x/fswap/client/testutil/query.go index 4e4004f8b5..ff124613f4 100644 --- a/x/fswap/client/testutil/query.go +++ b/x/fswap/client/testutil/query.go @@ -55,8 +55,6 @@ func (s *IntegrationTestSuite) TestCmdQuerySwapped() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdQuerySwapped() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -117,8 +115,6 @@ func (s *IntegrationTestSuite) TestCmdQueryTotalSwappableAmount() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdQueryTotalSwappableAmount() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -179,8 +175,6 @@ func (s *IntegrationTestSuite) TestCmdQuerySwap() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdQuerySwap() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) @@ -227,8 +221,6 @@ func (s *IntegrationTestSuite) TestCmdQuerySwaps() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdQuerySwaps() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) diff --git a/x/fswap/client/testutil/tx.go b/x/fswap/client/testutil/tx.go index 31fd363446..73628fa037 100644 --- a/x/fswap/client/testutil/tx.go +++ b/x/fswap/client/testutil/tx.go @@ -74,8 +74,6 @@ func (s *IntegrationTestSuite) TestCmdTxMsgSwap() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdTxMsgSwap() bz, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, append(tc.args, commonArgs...)) @@ -141,8 +139,6 @@ func (s *IntegrationTestSuite) TestCmdTxMsgSwapAll() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdTxMsgSwapAll() bz, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, append(tc.args, commonArgs...)) @@ -279,8 +275,6 @@ func (s *IntegrationTestSuite) TestMsgSetSwap() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.CmdMsgSetSwap() bz, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/fswap/keeper/genesis_test.go b/x/fswap/keeper/genesis_test.go index 1df6f28c75..f9a8e415ed 100644 --- a/x/fswap/keeper/genesis_test.go +++ b/x/fswap/keeper/genesis_test.go @@ -2,15 +2,81 @@ package keeper_test import ( "fmt" + "testing" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/Finschia/finschia-sdk/simapp" + "github.com/Finschia/finschia-sdk/testutil/testdata" sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/x/fswap/types" ) func (s *KeeperTestSuite) TestInitAndExportGenesis() { ctx, _ := s.ctx.CacheContext() + testGenesis := stubGenesisState() + err := s.keeper.InitGenesis(ctx, testGenesis) + s.Require().NoError(err) + + exportGenesis := s.keeper.ExportGenesis(ctx) + fmt.Println(len(exportGenesis.GetSwaps())) + s.Require().Equal(testGenesis, exportGenesis) + s.Require().Equal(testGenesis.GetSwaps(), exportGenesis.GetSwaps()) + s.Require().Equal(testGenesis.GetSwapStats(), exportGenesis.GetSwapStats()) + s.Require().Equal(testGenesis.GetSwappeds(), exportGenesis.GetSwappeds()) +} + +func TestInitGenesis(t *testing.T) { + checkTx := false + app := simapp.Setup(checkTx) + testdata.RegisterInterfaces(app.InterfaceRegistry()) + testdata.RegisterMsgServer(app.MsgServiceRouter(), testdata.MsgServerImpl{}) + ctx := app.BaseApp.NewContext(checkTx, tmproto.Header{}) + keeper := app.FswapKeeper + + tests := []struct { + name string + genState *types.GenesisState + expectedError error + }{ + { + name: "valid", + genState: stubGenesisState(), + expectedError: nil, + }, + { + name: "invalid: swapCount", + genState: func() *types.GenesisState { + state := stubGenesisState() + state.SwapStats.SwapCount = -1 + return state + }(), + expectedError: types.ErrInvalidState, + }, + { + name: "invalid: swaps count exceeds limit", + genState: func() *types.GenesisState { + state := stubGenesisState() + state.Swaps = append(state.Swaps, state.Swaps[0]) + state.Swappeds = append(state.Swappeds, state.Swappeds[0]) + state.SwapStats.SwapCount = 2 + return state + }(), + expectedError: types.ErrCanNotHaveMoreSwap, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + err := keeper.InitGenesis(ctx, tc.genState) + require.ErrorIs(t, tc.expectedError, err) + }) + } +} + +func stubGenesisState() *types.GenesisState { testSwapRate, _ := sdk.NewDecFromStr("1234567890") - testGenesis := &types.GenesisState{ + return &types.GenesisState{ Swaps: []types.Swap{ { FromDenom: "aaa", @@ -35,13 +101,4 @@ func (s *KeeperTestSuite) TestInitAndExportGenesis() { }, }, } - err := s.keeper.InitGenesis(ctx, testGenesis) - s.Require().NoError(err) - - exportGenesis := s.keeper.ExportGenesis(ctx) - fmt.Println(len(exportGenesis.GetSwaps())) - s.Require().Equal(testGenesis, exportGenesis) - s.Require().Equal(testGenesis.GetSwaps(), exportGenesis.GetSwaps()) - s.Require().Equal(testGenesis.GetSwapStats(), exportGenesis.GetSwapStats()) - s.Require().Equal(testGenesis.GetSwappeds(), exportGenesis.GetSwappeds()) } diff --git a/x/fswap/keeper/grpc_query_test.go b/x/fswap/keeper/grpc_query_test.go index d947121578..f9499b1dc7 100644 --- a/x/fswap/keeper/grpc_query_test.go +++ b/x/fswap/keeper/grpc_query_test.go @@ -11,6 +11,7 @@ import ( "github.com/Finschia/finschia-sdk/baseapp" "github.com/Finschia/finschia-sdk/simapp" sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/types/query" bank "github.com/Finschia/finschia-sdk/x/bank/types" "github.com/Finschia/finschia-sdk/x/fswap/keeper" "github.com/Finschia/finschia-sdk/x/fswap/types" @@ -42,7 +43,7 @@ func (s *FSwapQueryTestSuite) SetupTest() { s.queryClient = types.NewQueryClient(queryHelper) s.keeper = s.app.FswapKeeper - pebSwapRateForCony, err := sdk.NewDecFromStr("148079656000000") + keiSwapRateForCony, err := sdk.NewDecFromStr("148079656000000") s.Require().NoError(err) swapCap := sdk.NewInt(1000) s.Require().NoError(err) @@ -52,7 +53,7 @@ func (s *FSwapQueryTestSuite) SetupTest() { FromDenom: s.fromDenom, ToDenom: s.toDenom, AmountCapForToDenom: swapCap, - SwapRate: pebSwapRateForCony, + SwapRate: keiSwapRateForCony, } s.toDenomMetadata = bank.Metadata{ Description: "This is metadata for to-coin", @@ -88,48 +89,227 @@ func (s *FSwapQueryTestSuite) SetupTest() { func (s *FSwapQueryTestSuite) TestQuerySwapRequest() { tests := []struct { name string - FromDenom string - ToDenom string - wantErr bool + request *types.QuerySwapRequest + expectedResponse *types.QuerySwapResponse expectedGrpcCode codes.Code }{ { - name: "valid", - FromDenom: s.fromDenom, - ToDenom: s.toDenom, - wantErr: false, + name: "valid", + request: &types.QuerySwapRequest{ + FromDenom: s.fromDenom, + ToDenom: s.toDenom, + }, + expectedResponse: &types.QuerySwapResponse{ + Swap: types.Swap{ + FromDenom: s.swap.FromDenom, + ToDenom: s.swap.ToDenom, + AmountCapForToDenom: s.swap.AmountCapForToDenom, + SwapRate: s.swap.SwapRate, + }, + }, expectedGrpcCode: codes.OK, }, { - name: "invalid: empty fromDenom", - FromDenom: "", - ToDenom: s.toDenom, - wantErr: true, + name: "invalid: empty fromDenom", + request: &types.QuerySwapRequest{ + FromDenom: "", + ToDenom: s.toDenom, + }, expectedGrpcCode: codes.InvalidArgument, }, { - name: "invalid: empty toDenom", - FromDenom: s.fromDenom, - ToDenom: "", - wantErr: true, + name: "invalid: empty toDenom", + request: &types.QuerySwapRequest{ + FromDenom: s.fromDenom, + ToDenom: "", + }, expectedGrpcCode: codes.InvalidArgument, }, { - name: "invalid: the same fromDenom and toDenom", - FromDenom: s.fromDenom, - ToDenom: s.fromDenom, - wantErr: true, + name: "invalid: the same fromDenom and toDenom", + request: &types.QuerySwapRequest{ + FromDenom: s.fromDenom, + ToDenom: s.fromDenom, + }, expectedGrpcCode: codes.InvalidArgument, }, + { + name: "invalid: unregistered swap", + request: &types.QuerySwapRequest{ + FromDenom: s.toDenom, + ToDenom: s.fromDenom, + }, + expectedGrpcCode: codes.NotFound, + }, + } + for _, tc := range tests { + s.Run(tc.name, func() { + response, err := s.queryClient.Swap(s.ctx.Context(), tc.request) + s.Require().Equal(tc.expectedResponse, response) + actualGrpcCode := status.Code(err) + s.Require().Equal(tc.expectedGrpcCode, actualGrpcCode, actualGrpcCode.String()) + }) + } +} + +func (s *FSwapQueryTestSuite) TestQuerySwappedRequest() { + tests := []struct { + name string + request *types.QuerySwappedRequest + expectedResponse *types.QuerySwappedResponse + expectedGrpcCode codes.Code + }{ + { + name: "valid", + request: &types.QuerySwappedRequest{ + FromDenom: s.fromDenom, + ToDenom: s.toDenom, + }, + expectedResponse: &types.QuerySwappedResponse{ + FromCoinAmount: sdk.NewCoin(s.fromDenom, sdk.ZeroInt()), + ToCoinAmount: sdk.NewCoin(s.toDenom, sdk.ZeroInt()), + }, + expectedGrpcCode: codes.OK, + }, + { + name: "invalid: empty fromDenom", + request: &types.QuerySwappedRequest{ + FromDenom: "", + ToDenom: s.toDenom, + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + { + name: "invalid: empty toDenom", + request: &types.QuerySwappedRequest{ + FromDenom: s.fromDenom, + ToDenom: "", + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + { + name: "invalid: unregistered swap", + request: &types.QuerySwappedRequest{ + FromDenom: s.toDenom, + ToDenom: s.fromDenom, + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, } for _, tc := range tests { s.Run(tc.name, func() { - m := &types.QuerySwapRequest{ - FromDenom: tc.FromDenom, - ToDenom: tc.ToDenom, - } + response, err := s.queryClient.Swapped(s.ctx.Context(), tc.request) + s.Require().Equal(tc.expectedResponse, response) + actualGrpcCode := status.Code(err) + s.Require().Equal(tc.expectedGrpcCode, actualGrpcCode, actualGrpcCode.String()) + }) + } +} - _, err := s.queryClient.Swap(s.ctx.Context(), m) +func (s *FSwapQueryTestSuite) TestQueryTotalSwappableToCoinAmountRequest() { + tests := []struct { + name string + request *types.QueryTotalSwappableToCoinAmountRequest + expectedResponse *types.QueryTotalSwappableToCoinAmountResponse + expectedGrpcCode codes.Code + }{ + { + name: "valid", + request: &types.QueryTotalSwappableToCoinAmountRequest{ + FromDenom: s.fromDenom, + ToDenom: s.toDenom, + }, + expectedResponse: &types.QueryTotalSwappableToCoinAmountResponse{ + SwappableAmount: sdk.NewCoin(s.toDenom, s.swap.AmountCapForToDenom), + }, + expectedGrpcCode: codes.OK, + }, + { + name: "invalid: empty fromDenom", + request: &types.QueryTotalSwappableToCoinAmountRequest{ + FromDenom: "", + ToDenom: s.toDenom, + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + { + name: "invalid: empty toDenom", + request: &types.QueryTotalSwappableToCoinAmountRequest{ + FromDenom: s.fromDenom, + ToDenom: "", + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + { + name: "invalid: unregistered swap", + request: &types.QueryTotalSwappableToCoinAmountRequest{ + FromDenom: s.toDenom, + ToDenom: s.fromDenom, + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + } + for _, tc := range tests { + s.Run(tc.name, func() { + response, err := s.queryClient.TotalSwappableToCoinAmount(s.ctx.Context(), tc.request) + s.Require().Equal(tc.expectedResponse, response) + actualGrpcCode := status.Code(err) + s.Require().Equal(tc.expectedGrpcCode, actualGrpcCode, actualGrpcCode.String()) + }) + } +} + +func (s *FSwapQueryTestSuite) TestQuerySwapsRequest() { + tests := []struct { + name string + request *types.QuerySwapsRequest + expectedResponse *types.QuerySwapsResponse + expectedGrpcCode codes.Code + }{ + { + name: "valid", + request: &types.QuerySwapsRequest{ + Pagination: nil, + }, + expectedResponse: &types.QuerySwapsResponse{ + Swaps: []types.Swap{ + { + FromDenom: s.swap.FromDenom, + ToDenom: s.swap.ToDenom, + AmountCapForToDenom: s.swap.AmountCapForToDenom, + SwapRate: s.swap.SwapRate, + }, + }, + Pagination: &query.PageResponse{ + NextKey: nil, + Total: 1, + }, + }, + expectedGrpcCode: codes.OK, + }, + { + name: "invalid request", + request: &types.QuerySwapsRequest{ + Pagination: &query.PageRequest{ + Key: []byte("invalid-key"), + Offset: 1, + Limit: 0, + }, + }, + expectedResponse: nil, + expectedGrpcCode: codes.Unknown, + }, + } + for _, tc := range tests { + s.Run(tc.name, func() { + response, err := s.queryClient.Swaps(s.ctx.Context(), tc.request) + s.Require().Equal(tc.expectedResponse, response) actualGrpcCode := status.Code(err) s.Require().Equal(tc.expectedGrpcCode, actualGrpcCode, actualGrpcCode.String()) }) diff --git a/x/fswap/keeper/keeper_test.go b/x/fswap/keeper/keeper_test.go index 1ebffa116a..f5f45c3c9f 100644 --- a/x/fswap/keeper/keeper_test.go +++ b/x/fswap/keeper/keeper_test.go @@ -242,6 +242,22 @@ func (s *KeeperTestSuite) TestSwap() { true, sdkerrors.ErrInsufficientFunds, }, + "invalid: unregistered swap": { + s.accWithToCoin, + sdk.NewCoin(s.swap.GetFromDenom(), sdk.NewInt(100)), + "nono", + sdk.ZeroInt(), + true, + sdkerrors.ErrNotFound, + }, + "invalid: amount exceed": { + s.accWithToCoin, + sdk.NewCoin(s.swap.GetFromDenom(), s.swap.AmountCapForToDenom.Add(sdk.OneInt())), + s.swap.GetToDenom(), + sdk.ZeroInt(), + true, + types.ErrExceedSwappableToCoinAmount, + }, } for name, tc := range testCases { s.Run(name, func() { diff --git a/x/fswap/keeper/keys.go b/x/fswap/keeper/keys.go index e9a4652926..6bdedffd8d 100644 --- a/x/fswap/keeper/keys.go +++ b/x/fswap/keeper/keys.go @@ -6,7 +6,7 @@ var ( swappedKeyPrefix = []byte{0x03} ) -// swapKey key(prefix + fromDenom + toDenom) +// swapKey key(prefix + (lengthPrefixed+)fromDenom + (lengthPrefixed+)toDenom) func swapKey(fromDenom, toDenom string) []byte { denoms := combineDenoms(fromDenom, toDenom) return append(swapPrefix, denoms...) diff --git a/x/fswap/keeper/msg_server_test.go b/x/fswap/keeper/msg_server_test.go index ab8be87e04..81ce7529ac 100644 --- a/x/fswap/keeper/msg_server_test.go +++ b/x/fswap/keeper/msg_server_test.go @@ -1,8 +1,19 @@ package keeper_test import ( + "testing" + + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/Finschia/finschia-sdk/simapp" + "github.com/Finschia/finschia-sdk/testutil/testdata" sdk "github.com/Finschia/finschia-sdk/types" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" + authtypes "github.com/Finschia/finschia-sdk/x/auth/types" + bank "github.com/Finschia/finschia-sdk/x/bank/types" + "github.com/Finschia/finschia-sdk/x/foundation" + fkeeper "github.com/Finschia/finschia-sdk/x/fswap/keeper" "github.com/Finschia/finschia-sdk/x/fswap/types" ) @@ -133,3 +144,117 @@ func (s *KeeperTestSuite) TestMsgSwapAll() { }) } } + +func TestMsgSetSwap(t *testing.T) { + authority := authtypes.NewModuleAddress(foundation.ModuleName) + checkTx := false + app := simapp.Setup(checkTx) + testdata.RegisterInterfaces(app.InterfaceRegistry()) + testdata.RegisterMsgServer(app.MsgServiceRouter(), testdata.MsgServerImpl{}) + ctx := app.BaseApp.NewContext(checkTx, tmproto.Header{}) + keeper := app.FswapKeeper + msgServer := fkeeper.NewMsgServer(keeper) + fromDenomStr := "cony" + fromDenom := bank.Metadata{ + Description: "This is metadata for from-coin", + DenomUnits: []*bank.DenomUnit{ + {Denom: fromDenomStr, Exponent: 0}, + }, + Base: fromDenomStr, + Display: fromDenomStr, + Name: "FROM", + Symbol: "FROM", + } + app.BankKeeper.SetDenomMetaData(ctx, fromDenom) + + testCases := map[string]struct { + request *types.MsgSetSwap + expectedError error + }{ + "valid": { + request: &types.MsgSetSwap{ + Authority: authority.String(), + Swap: types.Swap{ + FromDenom: fromDenomStr, + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(1), + }, + ToDenomMetadata: bank.Metadata{ + Description: "desc", + DenomUnits: []*bank.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: nil, + }, + "invalid: authority": { + request: &types.MsgSetSwap{ + Authority: "invalid-authority", + Swap: types.Swap{ + FromDenom: fromDenomStr, + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(1), + }, + ToDenomMetadata: bank.Metadata{ + Description: "desc", + DenomUnits: []*bank.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: sdkerrors.ErrUnauthorized, + }, + "invalid: Swap.ToDenom": { + request: &types.MsgSetSwap{ + Authority: authority.String(), + Swap: types.Swap{ + FromDenom: fromDenomStr, + ToDenom: fromDenomStr, + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(1), + }, + ToDenomMetadata: bank.Metadata{ + Description: "desc", + DenomUnits: []*bank.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: sdkerrors.ErrInvalidRequest, + }, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + context, _ := ctx.CacheContext() + _, err := msgServer.SetSwap(sdk.WrapSDKContext(context), tc.request) + require.ErrorIs(t, err, tc.expectedError) + }) + } +} diff --git a/x/fswap/spec/01_concepts.md b/x/fswap/spec/01_concepts.md new file mode 100644 index 0000000000..8a1076f7cd --- /dev/null +++ b/x/fswap/spec/01_concepts.md @@ -0,0 +1,63 @@ + + +# Concepts + +## Swap + + +The `x/fswap` module defines a `Swap` type in which a coin is allowed to be swapped into another coin on the chain. +You could find detailed information in the [Protobuf reference](../../../proto/lbm/fswap/v1/fswap.proto#L9-L16) + +```go +type Swap struct { + FromDenom string + ToDenom string + AmountCapForToDenom sdk.Int + SwapRate sdk.Dec +} +``` + +Anyone could use one of the following two transcations to swap `FromDedenom` to `ToDenom`. +1. `simd tx fswap swap [from] [from_coin_amount] [to_denom]` + - this transcation could swap a specified amount of `from_denom` via [`MsgSwap`](../../../proto/lbm/fswap/v1/tx.proto#L17-L24) +2. `simd tx fswap swap-all [from_address] [from_denom] [to_denom]` + - this transcation could swap all of `from_denom` under `from_address` via [`MsgSwapAll`](../../../proto/lbm/fswap/v1/tx.proto#L28-L33) + +When the swap is triggered, the following event will occur: +1. `from_denom` will be sent from `from_address` to `x/fswap` module +2. `x/fswap` module will burn `from_denom` +3. `x/fswap` module will mint `to_denom` as amount as `from_denom * swapRate` +4. these `to_denom` will sent to `from_address` +5. `EventSwapCoins` will be emitted + +## Config + +The `x/fswap` module defines a `Config` type for managing the maximum number of Swaps allowed on chain through `MaxSwaps`. Additionally, `UpdateAllowed` specifies whether `Swap` can be modified. + +```go +type Config struct { + MaxSwaps int + UpdateAllowed bool +} +``` + +## MsgSetSwap + +Other modules can include `MsgSetSwap` in their proposals to set `Swap`. If the proposal passes, the `Swap` can be used on chain. + +`ToDenomMetadata` is [`Metadata`](../../bank/types/bank.pb.go#L325) in `x/bank` module, and it MUST meet these [limitations](../../bank/types/metadata.go#L11). +In addition, `ToDenomMetadata` should also meet the following two additional constraints by x/swap. +1. `Base` should be consistent with `ToDenom` in `Swap` ([valiation](../types/msgs.go#L121-L123)) +2. It cannot override existing denom metadata ([valiation](../keeper/keeper.go#L169)) + +The following example illustrates the use of `MsgSetSwap` within the `x/foundation` module. `Authority` is a spec in the `x/foundation` module, and you can get more information [here](../../foundation/README.md#L54). + +```go +type MsgSetSwap struct { + Authority string + Swap Swap + ToDenomMetadata bank.Metadata +} +``` diff --git a/x/fswap/spec/02_state.md b/x/fswap/spec/02_state.md new file mode 100644 index 0000000000..12d44e3faf --- /dev/null +++ b/x/fswap/spec/02_state.md @@ -0,0 +1,21 @@ + + +# State + +The `x/fswap` module keeps state of three primary objects, Swap, SwapStats and Swapped. + +## Swap + +- Swap: `0x01 + (lengthPrefixed+)fromDenom + (lengthPrefixed+)toDenom` + + +## SwapStats + +- SwapStats: `0x02` + +## Swapped + +- Swapped: `0x03 + (lengthPrefixed+)fromDenom + (lengthPrefixed+)toDenom` + diff --git a/x/fswap/spec/03_events.md b/x/fswap/spec/03_events.md new file mode 100644 index 0000000000..73ae3f6047 --- /dev/null +++ b/x/fswap/spec/03_events.md @@ -0,0 +1,8 @@ + + +# Events + +The fswap module emits proto events defined in [the Protobuf reference](../../../docs/core/proto-docs.md#lbm/fswap/v1/event.proto). +`MsgSetSwap` is emitted through the `x/foundation` module. \ No newline at end of file diff --git a/x/fswap/spec/README.md b/x/fswap/spec/README.md deleted file mode 100644 index ee7423f27c..0000000000 --- a/x/fswap/spec/README.md +++ /dev/null @@ -1,16 +0,0 @@ -``` -make build -make install -zsh init_node.sh sim 1 -``` - -open the `./.simapp/simapp0/config/genesis.json` change the value of `voting_params.voting_period` to `10s` -``` -simd start --home ~/.simapp/simapp0 -simd tx gov submit-proposal swap-init --title "test" --description "test" --from link146asaycmtydq45kxc8evntqfgepagygelel00h --from-denom "cony" --to-denom "PDT" --swap-rate 123 --amount-limit 1000 --deposit 10000000stake --chain-id=sim --keyring-backend=test --gas-prices 1000stake --gas 10000000 --gas-adjustment 1.5 --home ~/.simapp/simapp0 -b block -y -simd tx gov vote 1 yes --from link146asaycmtydq45kxc8evntqfgepagygelel00h --chain-id=sim --keyring-backend=test --home ~/.simapp/simapp0 -b block -y -``` - -``` -simd query fswap swapped --chain-id=sim -``` \ No newline at end of file diff --git a/x/fswap/types/config_test.go b/x/fswap/types/config_test.go new file mode 100644 index 0000000000..90a078a4d7 --- /dev/null +++ b/x/fswap/types/config_test.go @@ -0,0 +1,14 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDefaultConfig(t *testing.T) { + config := DefaultConfig() + + require.Equal(t, false, config.UpdateAllowed) + require.Equal(t, 1, config.MaxSwaps) +} diff --git a/x/fswap/types/genesis_test.go b/x/fswap/types/genesis_test.go index fc2ed9a781..289e1626af 100644 --- a/x/fswap/types/genesis_test.go +++ b/x/fswap/types/genesis_test.go @@ -6,7 +6,10 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/Finschia/finschia-sdk/types" + authtypes "github.com/Finschia/finschia-sdk/x/auth/types" + "github.com/Finschia/finschia-sdk/x/foundation" "github.com/Finschia/finschia-sdk/x/fswap/types" + govtypes "github.com/Finschia/finschia-sdk/x/gov/types" ) func TestGenesisStateValidate(t *testing.T) { @@ -174,3 +177,22 @@ func TestGenesisStateValidate(t *testing.T) { }) } } + +func TestDefaultAuthority(t *testing.T) { + expectedDefaultAuthority := authtypes.NewModuleAddress(foundation.ModuleName) + + defaultAuthority := types.DefaultAuthority() + + require.Equal(t, expectedDefaultAuthority, defaultAuthority) +} + +func TestAuthorityCandidates(t *testing.T) { + defaultAuthorityCandidates := []sdk.AccAddress{ + authtypes.NewModuleAddress(govtypes.ModuleName), + authtypes.NewModuleAddress(foundation.ModuleName), + } + + authorityCandidates := types.AuthorityCandidates() + + require.Equal(t, defaultAuthorityCandidates, authorityCandidates) +} diff --git a/x/fswap/types/msgs_test.go b/x/fswap/types/msgs_test.go index e3dd86b7dd..c4516e1ef0 100644 --- a/x/fswap/types/msgs_test.go +++ b/x/fswap/types/msgs_test.go @@ -1,13 +1,14 @@ package types_test import ( + "errors" "testing" "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + "github.com/Finschia/finschia-sdk/crypto/keys/secp256k1" sdk "github.com/Finschia/finschia-sdk/types" + sdkerrors "github.com/Finschia/finschia-sdk/types/errors" "github.com/Finschia/finschia-sdk/x/auth/legacy/legacytx" banktypes "github.com/Finschia/finschia-sdk/x/bank/types" fswaptypes "github.com/Finschia/finschia-sdk/x/fswap/types" @@ -76,7 +77,6 @@ func TestAminoJSON(t *testing.T) { } for name, tc := range testCase { - tc := tc t.Run(name, func(t *testing.T) { tx.Msgs = []sdk.Msg{tc.msg} require.Equal(t, fswaptypes.RouterKey, tc.msg.Route()) @@ -86,52 +86,278 @@ func TestAminoJSON(t *testing.T) { } } -func TestQuerySwapRequestValidate(t *testing.T) { +func TestMsgSwapValidate(t *testing.T) { + pk := secp256k1.GenPrivKey().PubKey() + address, err := sdk.Bech32ifyAddressBytes("link", pk.Address()) + if err != nil { + return + } + tests := []struct { + name string + msg *fswaptypes.MsgSwap + expectedError error + }{ + { + name: "valid", + msg: &fswaptypes.MsgSwap{ + FromAddress: address, + FromCoinAmount: sdk.NewCoin("fromDenom", sdk.OneInt()), + ToDenom: "kei", + }, + expectedError: nil, + }, + { + name: "invalid: address", + msg: &fswaptypes.MsgSwap{ + FromAddress: "invalid-address", + FromCoinAmount: sdk.NewCoin("fromDenom", sdk.OneInt()), + ToDenom: "kei", + }, + expectedError: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid: FromCoinAmount empty denom", + msg: &fswaptypes.MsgSwap{ + FromAddress: address, + FromCoinAmount: sdk.Coin{ + Denom: "", + Amount: sdk.OneInt(), + }, + ToDenom: "kei", + }, + expectedError: sdkerrors.ErrInvalidCoins, + }, + { + name: "invalid: FromCoinAmount zero amount", + msg: &fswaptypes.MsgSwap{ + FromAddress: address, + FromCoinAmount: sdk.Coin{ + Denom: "cony", + Amount: sdk.ZeroInt(), + }, + ToDenom: "kei", + }, + expectedError: sdkerrors.ErrInvalidCoins, + }, + { + name: "invalid: ToDenom", + msg: &fswaptypes.MsgSwap{ + FromAddress: address, + FromCoinAmount: sdk.NewCoin("fromDenom", sdk.OneInt()), + ToDenom: "", + }, + expectedError: sdkerrors.ErrInvalidRequest, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + require.ErrorIs(t, err, tc.expectedError) + }) + } +} + +func TestMsgSwapAllValidate(t *testing.T) { + pk := secp256k1.GenPrivKey().PubKey() + address, err := sdk.Bech32ifyAddressBytes("link", pk.Address()) + if err != nil { + return + } + tests := []struct { + name string + msg *fswaptypes.MsgSwapAll + expectedError error + }{ + { + name: "valid", + msg: &fswaptypes.MsgSwapAll{ + FromAddress: address, + FromDenom: "cony", + ToDenom: "kei", + }, + expectedError: nil, + }, + { + name: "invalid: address", + msg: &fswaptypes.MsgSwapAll{ + FromAddress: "invalid-address", + FromDenom: "cony", + ToDenom: "kei", + }, + expectedError: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid: FromDenom", + msg: &fswaptypes.MsgSwapAll{ + FromAddress: address, + FromDenom: "", + ToDenom: "kei", + }, + expectedError: sdkerrors.ErrInvalidRequest, + }, + { + name: "invalid: ToDenom", + msg: &fswaptypes.MsgSwapAll{ + FromAddress: address, + FromDenom: "cony", + ToDenom: "", + }, + expectedError: sdkerrors.ErrInvalidRequest, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + require.ErrorIs(t, err, tc.expectedError) + }) + } +} + +func TestMsgSetSwapValidate(t *testing.T) { + pk := secp256k1.GenPrivKey().PubKey() + address, err := sdk.Bech32ifyAddressBytes("link", pk.Address()) + if err != nil { + return + } tests := []struct { - name string - FromDenom string - ToDenom string - wantErr bool - expectedGrpcCode codes.Code + name string + msg *fswaptypes.MsgSetSwap + expectedError error }{ { - name: "valid", - FromDenom: "cony", - ToDenom: "peb", - wantErr: false, - expectedGrpcCode: codes.OK, + name: "valid", + msg: &fswaptypes.MsgSetSwap{ + Authority: address, + Swap: fswaptypes.Swap{ + FromDenom: "cony", + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(123), + }, + ToDenomMetadata: banktypes.Metadata{ + Description: "desc", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: nil, + }, + { + name: "invalid: address", + msg: &fswaptypes.MsgSetSwap{ + Authority: "invalid-address", + Swap: fswaptypes.Swap{ + FromDenom: "cony", + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(123), + }, + ToDenomMetadata: banktypes.Metadata{ + Description: "desc", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: sdkerrors.ErrInvalidAddress, }, { - name: "invalid: empty fromDenom", - FromDenom: "", - ToDenom: "peb", - wantErr: true, - expectedGrpcCode: codes.InvalidArgument, + name: "invalid: Swap", + msg: &fswaptypes.MsgSetSwap{ + Authority: address, + Swap: fswaptypes.Swap{}, + ToDenomMetadata: banktypes.Metadata{ + Description: "desc", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "kei", + Display: "kei", + Name: "kei", + Symbol: "KAIA", + }, + }, + expectedError: sdkerrors.ErrInvalidRequest, }, { - name: "invalid: empty toDenom", - FromDenom: "cony", - ToDenom: "", - wantErr: true, - expectedGrpcCode: codes.InvalidArgument, + name: "invalid: ToDenomMetadata", + msg: &fswaptypes.MsgSetSwap{ + Authority: address, + Swap: fswaptypes.Swap{ + FromDenom: "cony", + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(123), + }, + ToDenomMetadata: banktypes.Metadata{ + Description: "", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "kei", + Exponent: 0, + Aliases: nil, + }, + }, + }, + }, + expectedError: errors.New("name field cannot be blank"), }, + { - name: "invalid: the same fromDenom and toDenom", - FromDenom: "cony", - ToDenom: "cony", - wantErr: true, - expectedGrpcCode: codes.InvalidArgument, + name: "invalid: mismatched toDenom", + msg: &fswaptypes.MsgSetSwap{ + Authority: address, + Swap: fswaptypes.Swap{ + FromDenom: "cony", + ToDenom: "kei", + AmountCapForToDenom: sdk.OneInt(), + SwapRate: sdk.NewDec(123), + }, + ToDenomMetadata: banktypes.Metadata{ + Description: "desc", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "fkei", + Exponent: 0, + Aliases: nil, + }, + }, + Base: "fkei", + Display: "fkei", + Name: "fkei", + Symbol: "KAIA", + }, + }, + expectedError: sdkerrors.ErrInvalidRequest, }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - m := &fswaptypes.QuerySwapRequest{ - FromDenom: tc.FromDenom, - ToDenom: tc.ToDenom, + err := tc.msg.ValidateBasic() + if tc.expectedError != nil { + require.Contains(t, err.Error(), tc.expectedError.Error()) } - err := m.Validate() - actualGrpcCode := status.Code(err) - require.Equal(t, tc.expectedGrpcCode, actualGrpcCode) }) } } diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index 5cc05093a1..91059db031 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -53,7 +53,6 @@ func TestInitCmd(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() diff --git a/x/genutil/client/testutil/helpers.go b/x/genutil/client/testutil/helpers.go index 80d88dae25..3fcbafd11b 100644 --- a/x/genutil/client/testutil/helpers.go +++ b/x/genutil/client/testutil/helpers.go @@ -46,7 +46,7 @@ func CreateDefaultTendermintConfig(rootDir string) (*tmcfg.Config, error) { tmcfg.EnsureRoot(rootDir) if err := conf.ValidateBasic(); err != nil { - return nil, fmt.Errorf("error in config file: %v", err) + return nil, fmt.Errorf("error in config file: %w", err) } return conf, nil diff --git a/x/genutil/client/testutil/migrate.go b/x/genutil/client/testutil/migrate.go index 62a035ca54..9c84cf12c4 100644 --- a/x/genutil/client/testutil/migrate.go +++ b/x/genutil/client/testutil/migrate.go @@ -37,7 +37,6 @@ func (s *IntegrationTestSuite) TestMigrateGenesis() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis) jsonOutput, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.MigrateGenesisCmd(), []string{tc.target, genesisFile.Name()}) diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index 051820015d..14f668b105 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -96,8 +96,6 @@ func (s *IntegrationTestSuite) TestGenTxCmd() { } for _, tc := range tests { - tc := tc - dir := s.T().TempDir() genTxFile := filepath.Join(dir, "myTx") tc.args = append(tc.args, fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile)) diff --git a/x/genutil/client/testutil/validate_genesis.go b/x/genutil/client/testutil/validate_genesis.go index 32181a95db..73cedc9753 100644 --- a/x/genutil/client/testutil/validate_genesis.go +++ b/x/genutil/client/testutil/validate_genesis.go @@ -87,7 +87,6 @@ func (s *IntegrationTestSuite) TestValidateGenesis() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis) _, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.ValidateGenesisCmd(nil), []string{genesisFile.Name()}) diff --git a/x/genutil/utils_test.go b/x/genutil/utils_test.go index b406ed3e98..198bf70386 100644 --- a/x/genutil/utils_test.go +++ b/x/genutil/utils_test.go @@ -49,7 +49,6 @@ func TestInitializeNodeValidatorFilesFromMnemonic(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { _, _, err := InitializeNodeValidatorFilesFromMnemonic(cfg, tt.mnemonic) diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index 252f7a3aa4..e789aa9e2b 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -214,7 +214,7 @@ $ %s query gov vote 1 link1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk &types.QueryProposalRequest{ProposalId: proposalID}, ) if err != nil { - return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err) + return fmt.Errorf("failed to fetch proposal-id %d: %w", proposalID, err) } voterAddr, err := sdk.AccAddressFromBech32(args[1]) @@ -288,7 +288,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100 &types.QueryProposalRequest{ProposalId: proposalID}, ) if err != nil { - return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err) + return fmt.Errorf("failed to fetch proposal-id %d: %w", proposalID, err) } propStatus := proposalRes.GetProposal().Status @@ -369,7 +369,7 @@ $ %s query gov deposit 1 link1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk &types.QueryProposalRequest{ProposalId: proposalID}, ) if err != nil { - return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err) + return fmt.Errorf("failed to fetch proposal-id %d: %w", proposalID, err) } depositorAddr, err := sdk.AccAddressFromBech32(args[1]) @@ -442,7 +442,7 @@ $ %s query gov deposits 1 &types.QueryProposalRequest{ProposalId: proposalID}, ) if err != nil { - return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err) + return fmt.Errorf("failed to fetch proposal-id %d: %w", proposalID, err) } propStatus := proposalRes.GetProposal().Status @@ -520,7 +520,7 @@ $ %s query gov tally 1 &types.QueryProposalRequest{ProposalId: proposalID}, ) if err != nil { - return fmt.Errorf("failed to fetch proposal-id %d: %s", proposalID, err) + return fmt.Errorf("failed to fetch proposal-id %d: %w", proposalID, err) } // Query store diff --git a/x/gov/client/testutil/grpc.go b/x/gov/client/testutil/grpc.go index e97273afdf..e421b48126 100644 --- a/x/gov/client/testutil/grpc.go +++ b/x/gov/client/testutil/grpc.go @@ -38,7 +38,6 @@ func (s *IntegrationTestSuite) TestGetProposalGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -92,7 +91,6 @@ func (s *IntegrationTestSuite) TestGetProposalsGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) @@ -159,7 +157,6 @@ func (s *IntegrationTestSuite) TestGetProposalVoteGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -203,7 +200,6 @@ func (s *IntegrationTestSuite) TestGetProposalVotesGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -252,7 +248,6 @@ func (s *IntegrationTestSuite) TestGetProposalDepositGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -291,7 +286,6 @@ func (s *IntegrationTestSuite) TestGetProposalDepositsGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -336,7 +330,6 @@ func (s *IntegrationTestSuite) TestGetTallyGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -399,7 +392,6 @@ func (s *IntegrationTestSuite) TestGetParamsGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) diff --git a/x/gov/client/testutil/suite.go b/x/gov/client/testutil/suite.go index b9be407318..0ff0055da4 100644 --- a/x/gov/client/testutil/suite.go +++ b/x/gov/client/testutil/suite.go @@ -108,8 +108,6 @@ voting_params: } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryParams() clientCtx := val.ClientCtx @@ -156,8 +154,6 @@ func (s *IntegrationTestSuite) TestCmdParam() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryParam() clientCtx := val.ClientCtx @@ -198,8 +194,6 @@ func (s *IntegrationTestSuite) TestCmdProposer() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryProposer() clientCtx := val.ClientCtx @@ -253,8 +247,6 @@ func (s *IntegrationTestSuite) TestCmdTally() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryTally() clientCtx := val.ClientCtx @@ -344,8 +336,6 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewCmdSubmitProposal() clientCtx := val.ClientCtx @@ -392,8 +382,6 @@ func (s *IntegrationTestSuite) TestCmdGetProposal() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryProposal() clientCtx := val.ClientCtx @@ -445,8 +433,6 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryProposals() clientCtx := val.ClientCtx @@ -491,7 +477,6 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposits() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryDeposits() clientCtx := val.ClientCtx @@ -547,7 +532,6 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposit() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryDeposit() clientCtx := val.ClientCtx @@ -625,7 +609,6 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { } for _, tc := range testCases { - tc := tc var resp sdk.TxResponse s.Run(tc.name, func() { @@ -676,7 +659,6 @@ func (s *IntegrationTestSuite) TestCmdQueryVotes() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryVotes() clientCtx := val.ClientCtx @@ -751,7 +733,6 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryVote() clientCtx := val.ClientCtx @@ -816,7 +797,6 @@ func (s *IntegrationTestSuite) TestNewCmdVote() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdVote() clientCtx := val.ClientCtx @@ -900,7 +880,6 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.NewCmdWeightedVote() clientCtx := val.ClientCtx diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 8510ee48de..09f8d582e6 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -160,8 +160,6 @@ func TestGetPaginatedVotes(t *testing.T) { }, }, } { - tc := tc - t.Run(tc.description, func(t *testing.T) { marshaled := make([]tmtypes.Tx, len(tc.msgs)) cli := TxSearchMock{txs: marshaled, txConfig: encCfg.TxConfig} diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 9564284dee..d4484baf2f 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -104,7 +104,7 @@ func TestImportExportQueues(t *testing.T) { // Run the endblocker. Check to make sure that proposal1 is removed from state, and proposal2 is finished VotingPeriod. gov.EndBlocker(ctx2, app2.GovKeeper) - proposal1, ok = app2.GovKeeper.GetProposal(ctx2, proposalID1) + _, ok = app2.GovKeeper.GetProposal(ctx2, proposalID1) require.False(t, ok) proposal2, ok = app2.GovKeeper.GetProposal(ctx2, proposalID2) diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 65cf29e116..df26ab6fb9 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -96,7 +96,7 @@ func TestDeposits(t *testing.T) { require.True(t, found) require.Equal(t, fourStake, deposit.Amount) app.GovKeeper.RefundDeposits(ctx, proposalID) - deposit, found = app.GovKeeper.GetDeposit(ctx, proposalID, TestAddrs[1]) + _, found = app.GovKeeper.GetDeposit(ctx, proposalID, TestAddrs[1]) require.False(t, found) require.Equal(t, addr0Initial, app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) require.Equal(t, addr1Initial, app.BankKeeper.GetAllBalances(ctx, TestAddrs[1])) diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index ea3078a41f..9e6b54f334 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/armon/go-metrics" + "github.com/hashicorp/go-metrics" "github.com/Finschia/finschia-sdk/telemetry" sdk "github.com/Finschia/finschia-sdk/types" diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index 3debd3da85..befef0d18f 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -380,7 +380,6 @@ func TestPaginatedVotesQuery(t *testing.T) { page: -1, }, } { - tc := tc t.Run(tc.description, func(t *testing.T) { votes := getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal.ProposalId, tc.page, tc.limit) require.Equal(t, len(tc.votes), len(votes)) diff --git a/x/gov/legacy/v043/store_test.go b/x/gov/legacy/v043/store_test.go index 6f7f0c9876..a9bbe4368c 100644 --- a/x/gov/legacy/v043/store_test.go +++ b/x/gov/legacy/v043/store_test.go @@ -80,7 +80,6 @@ func TestMigrateStore(t *testing.T) { // Make sure the new keys are set and old keys are deleted. for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { if !bytes.Equal(tc.oldKey, tc.newKey) { require.Nil(t, store.Get(tc.oldKey)) diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 049e0f4a6f..2629b5409b 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -81,7 +81,6 @@ func TestDecodeStore(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { if tt.wantPanic { require.Panics(t, func() { dec(tt.kvA, tt.kvB) }, tt.name) diff --git a/x/gov/simulation/genesis_test.go b/x/gov/simulation/genesis_test.go index 2e0fc7217f..5602c79b5f 100644 --- a/x/gov/simulation/genesis_test.go +++ b/x/gov/simulation/genesis_test.go @@ -79,8 +79,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 6ba9e985f3..bde953d6f2 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -58,7 +58,6 @@ func WeightedOperations( var wProposalOps simulation.WeightedOperations for _, wContent := range wContents { - wContent := wContent // pin variable var weight int appParams.GetOrGenerate(cdc, wContent.AppParamsKey(), &weight, nil, func(_ *rand.Rand) { weight = wContent.DefaultWeight() }) diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index 2104ef6842..2fe7840537 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -168,12 +168,18 @@ func (status *ProposalStatus) Unmarshal(data []byte) error { // Format implements the fmt.Formatter interface. func (status ProposalStatus) Format(s fmt.State, verb rune) { + var err error + switch verb { case 's': - s.Write([]byte(status.String())) + _, err = s.Write([]byte(status.String())) default: // TODO: Do this conversion more directly - s.Write([]byte(fmt.Sprintf("%v", byte(status)))) + _, err = s.Write([]byte(fmt.Sprintf("%v", byte(status)))) + } + + if err != nil { + panic(err) } } diff --git a/x/gov/types/vote.go b/x/gov/types/vote.go index ba2c6e6972..e722bced7b 100644 --- a/x/gov/types/vote.go +++ b/x/gov/types/vote.go @@ -62,7 +62,10 @@ func NewNonSplitVoteOption(option VoteOption) WeightedVoteOptions { } func (v WeightedVoteOption) String() string { - out, _ := json.Marshal(v) + out, err := json.Marshal(v) + if err != nil { + panic(err) + } return string(out) } @@ -141,10 +144,16 @@ func (vo *VoteOption) Unmarshal(data []byte) error { // Format implements the fmt.Formatter interface. func (vo VoteOption) Format(s fmt.State, verb rune) { + var err error + switch verb { case 's': - s.Write([]byte(vo.String())) + _, err = s.Write([]byte(vo.String())) default: - s.Write([]byte(fmt.Sprintf("%v", byte(vo)))) + _, err = s.Write([]byte(fmt.Sprintf("%v", byte(vo)))) + } + + if err != nil { + panic(err) } } diff --git a/x/mint/client/testutil/grpc.go b/x/mint/client/testutil/grpc.go index aa3cf59c51..52ead8c536 100644 --- a/x/mint/client/testutil/grpc.go +++ b/x/mint/client/testutil/grpc.go @@ -53,7 +53,6 @@ func (s *IntegrationTestSuite) TestQueryGRPC() { }, } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { s.Require().NoError(err) diff --git a/x/mint/client/testutil/suite.go b/x/mint/client/testutil/suite.go index a8a78637dd..9e7b6c21bb 100644 --- a/x/mint/client/testutil/suite.go +++ b/x/mint/client/testutil/suite.go @@ -81,8 +81,6 @@ mint_denom: stake`, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryParams() clientCtx := val.ClientCtx @@ -115,8 +113,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryInflation() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryInflation() clientCtx := val.ClientCtx @@ -149,8 +145,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryAnnualProvisions() clientCtx := val.ClientCtx diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 8fb33000db..790313a374 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -34,7 +34,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index 621426ad80..84101358c4 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -79,8 +79,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/params/client/testutil/grpc.go b/x/params/client/testutil/grpc.go index 64cde94976..9f00b3921c 100644 --- a/x/params/client/testutil/grpc.go +++ b/x/params/client/testutil/grpc.go @@ -80,7 +80,6 @@ func (s *IntegrationTestSuite) TestQueryParamsGRPC() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) diff --git a/x/params/client/testutil/suite.go b/x/params/client/testutil/suite.go index 74953d16b2..45558544f5 100644 --- a/x/params/client/testutil/suite.go +++ b/x/params/client/testutil/suite.go @@ -66,8 +66,6 @@ value: "100"`, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewQuerySubspaceParamsCmd() clientCtx := val.ClientCtx diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index c4ae41351f..6285d5fb1a 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -83,13 +83,11 @@ func TestKeeper(t *testing.T) { // Set params for i, kv := range kvs { - kv := kv require.NotPanics(t, func() { space.Set(ctx, []byte(kv.key), kv.param) }, "space.Set panics, tc #%d", i) } // Test space.Get for i, kv := range kvs { - i, kv := i, kv var param int64 require.NotPanics(t, func() { space.Get(ctx, []byte(kv.key), ¶m) }, "space.Get panics, tc #%d", i) require.Equal(t, kv.param, param, "stored param not equal, tc #%d", i) @@ -116,20 +114,17 @@ func TestKeeper(t *testing.T) { // Test invalid space.Get for i, kv := range kvs { - kv := kv var param bool require.Panics(t, func() { space.Get(ctx, []byte(kv.key), ¶m) }, "invalid space.Get not panics, tc #%d", i) } // Test invalid space.Set for i, kv := range kvs { - kv := kv require.Panics(t, func() { space.Set(ctx, []byte(kv.key), true) }, "invalid space.Set not panics, tc #%d", i) } // Test GetSubspace for i, kv := range kvs { - i, kv := i, kv var gparam, param int64 gspace, ok := keeper.GetSubspace("test") require.True(t, ok, "cannot retrieve subspace, tc #%d", i) @@ -191,13 +186,11 @@ func TestSubspace(t *testing.T) { // Test space.Set for i, kv := range kvs { - i, kv := i, kv require.NotPanics(t, func() { space.Set(ctx, []byte(kv.key), kv.param) }, "space.Set panics, tc #%d", i) } // Test space.Get, space.GetIfExists for i, kv := range kvs { - i, kv := i, kv require.NotPanics(t, func() { space.GetIfExists(ctx, []byte("invalid"), kv.ptr) }, "space.GetIfExists panics when no value exists, tc #%d", i) require.Equal(t, kv.zero, indirect(kv.ptr), "space.GetIfExists unmarshalls when no value exists, tc #%d", i) require.Panics(t, func() { space.Get(ctx, []byte("invalid"), kv.ptr) }, "invalid space.Get not panics when no value exists, tc #%d", i) diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index 81f42547e2..9162fea2f3 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -77,7 +77,6 @@ func (suite *HandlerTestSuite) TestProposalHandler() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := suite.govHandler(suite.ctx, tc.proposal) if tc.expErr { diff --git a/x/params/types/subspace.go b/x/params/types/subspace.go index 12bc0c2355..3e974ad3e2 100644 --- a/x/params/types/subspace.go +++ b/x/params/types/subspace.go @@ -82,7 +82,7 @@ func (s Subspace) Validate(ctx sdk.Context, key []byte, value interface{}) error } if err := attr.vfn(value); err != nil { - return fmt.Errorf("invalid parameter value: %s", err) + return fmt.Errorf("invalid parameter value: %w", err) } return nil diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index 1882f47b58..887246afa3 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -184,7 +184,6 @@ func (suite *SubspaceTestSuite) TestSetParamSet() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.Require().Panics(func() { suite.ss.SetParamSet(suite.ctx, tc.ps) diff --git a/x/simulation/operation.go b/x/simulation/operation.go index 82547c3891..433518f3dd 100644 --- a/x/simulation/operation.go +++ b/x/simulation/operation.go @@ -79,7 +79,6 @@ func queueOperations(queuedOps OperationQueue, queuedTimeOps, futureOps []simula } for _, futureOp := range futureOps { - futureOp := futureOp if futureOp.BlockHeight != 0 { if val, ok := queuedOps[futureOp.BlockHeight]; ok { queuedOps[futureOp.BlockHeight] = append(val, futureOp.Op) diff --git a/x/slashing/client/testutil/grpc.go b/x/slashing/client/testutil/grpc.go index a56583e355..245b4023b8 100644 --- a/x/slashing/client/testutil/grpc.go +++ b/x/slashing/client/testutil/grpc.go @@ -83,8 +83,6 @@ func (s *IntegrationTestSuite) TestGRPCQueries() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) diff --git a/x/slashing/client/testutil/suite.go b/x/slashing/client/testutil/suite.go index 718e84e5a7..885ee616ad 100644 --- a/x/slashing/client/testutil/suite.go +++ b/x/slashing/client/testutil/suite.go @@ -85,8 +85,6 @@ tombstoned: false`, sdk.ConsAddress(val.PubKey.Address())), } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQuerySigningInfo() clientCtx := val.ClientCtx @@ -127,8 +125,6 @@ slash_fraction_downtime: "0.010000000000000000"`, } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryParams() clientCtx := val.ClientCtx @@ -162,8 +158,6 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewUnjailTxCmd() clientCtx := val.ClientCtx diff --git a/x/slashing/legacy/v043/store_test.go b/x/slashing/legacy/v043/store_test.go index 69df9372c1..318bc16bd5 100644 --- a/x/slashing/legacy/v043/store_test.go +++ b/x/slashing/legacy/v043/store_test.go @@ -57,7 +57,6 @@ func TestStoreMigration(t *testing.T) { // Make sure the new keys are set and old keys are deleted. for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { if !bytes.Equal(tc.oldKey, tc.newKey) { require.Nil(t, store.Get(tc.oldKey)) diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index 9d5794a590..892fda56d8 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -53,7 +53,6 @@ func TestDecodeStore(t *testing.T) { {"other", "", true}, } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { if tt.panics { require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) diff --git a/x/slashing/simulation/genesis_test.go b/x/slashing/simulation/genesis_test.go index e63bc3c14c..c5d3615b94 100644 --- a/x/slashing/simulation/genesis_test.go +++ b/x/slashing/simulation/genesis_test.go @@ -78,8 +78,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 3638881217..eb7c35c894 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -655,7 +655,7 @@ $ %s query staking historical-info 5 height, err := strconv.ParseInt(args[0], 10, 64) if err != nil || height < 0 { - return fmt.Errorf("height argument provided must be a non-negative-integer: %v", err) + return fmt.Errorf("height argument provided must be a non-negative-integer: %w", err) } params := &types.QueryHistoricalInfoRequest{Height: height} diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index 994adcb740..64a693de93 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -111,7 +111,7 @@ func NewEditValidatorCmd() *cobra.Command { if commissionRate != "" { rate, err := sdk.NewDecFromStr(commissionRate) if err != nil { - return fmt.Errorf("invalid new commission rate: %v", err) + return fmt.Errorf("invalid new commission rate: %w", err) } newRate = &rate diff --git a/x/staking/client/cli/tx_test.go b/x/staking/client/cli/tx_test.go index e326e4490b..9153d126d5 100644 --- a/x/staking/client/cli/tx_test.go +++ b/x/staking/client/cli/tx_test.go @@ -85,7 +85,6 @@ func TestPrepareConfigForTxCreateValidator(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { fs, _ := CreateValidatorMsgFlagSet(ip) fs.String(flags.FlagName, "", "name of private key with which to sign the gentx") diff --git a/x/staking/client/testutil/grpc.go b/x/staking/client/testutil/grpc.go index 690443ffa7..03062377c8 100644 --- a/x/staking/client/testutil/grpc.go +++ b/x/staking/client/testutil/grpc.go @@ -43,7 +43,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidatorsHandler() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -91,7 +90,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidator() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -156,7 +154,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidatorDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) @@ -200,7 +197,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryValidatorUnbondingDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -279,7 +275,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegation() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -333,7 +328,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryUnbondingDelegation() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -418,7 +412,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) @@ -466,7 +459,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorUnbondingDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -528,7 +520,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryRedelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -577,7 +568,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorValidators() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -634,7 +624,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryDelegatorValidator() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -680,7 +669,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryHistoricalInfo() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) @@ -720,7 +708,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() { } for _, tc := range testCases { - tc := tc resp, err := rest.GetRequest(tc.url) s.Run(tc.name, func() { s.Require().NoError(err) @@ -758,7 +745,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryPool() { } for _, tc := range testCases { - tc := tc resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Run(tc.name, func() { s.Require().NoError(err) diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index 3109c95bf9..353a55dd30 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -189,8 +189,6 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewCreateValidatorCmd() clientCtx := val.ClientCtx @@ -244,7 +242,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidator() { }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidator() clientCtx := val.ClientCtx @@ -285,8 +282,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidators() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidators() clientCtx := val.ClientCtx @@ -351,7 +346,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryDelegation() clientCtx := val.ClientCtx @@ -407,7 +401,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryDelegations() clientCtx := val.ClientCtx @@ -463,7 +456,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryDelegations() clientCtx := val.ClientCtx @@ -507,7 +499,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryUnbondingDelegations() clientCtx := val.ClientCtx @@ -566,7 +557,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryUnbondingDelegation() clientCtx := val.ClientCtx @@ -615,7 +605,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorUnbondingDelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidatorUnbondingDelegations() clientCtx := val.ClientCtx @@ -664,7 +653,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryRedelegations() clientCtx := val.ClientCtx @@ -740,7 +728,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryRedelegation() clientCtx := val.ClientCtx @@ -792,7 +779,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorRedelegations() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryValidatorRedelegations() clientCtx := val.ClientCtx @@ -843,7 +829,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryHistoricalInfo() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryHistoricalInfo() clientCtx := val.ClientCtx @@ -885,7 +870,6 @@ unbonding_time: 1814400s`, }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryParams() clientCtx := val.ClientCtx @@ -922,7 +906,6 @@ not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), }, } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { cmd := cli.GetCmdQueryPool() clientCtx := val.ClientCtx @@ -1029,8 +1012,6 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewEditValidatorCmd() clientCtx := val.ClientCtx @@ -1111,8 +1092,6 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewDelegateCmd() clientCtx := val.ClientCtx @@ -1197,8 +1176,6 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewRedelegateCmd() clientCtx := val.ClientCtx @@ -1264,8 +1241,6 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { cmd := cli.NewUnbondCmd() clientCtx := val.ClientCtx diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index c61257a448..afcf3db100 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -230,7 +230,6 @@ func TestValidateGenesis(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { genesisState := types.DefaultGenesisState() tt.mutate(genesisState) diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index a969caf040..993c4d9b4f 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -893,7 +893,7 @@ func TestMultipleRedelegationAtSameTime(t *testing.T) { // move forward in time, should complete both redelegations ctx = tstaking.TurnBlockTimeDiff(1 * time.Second) - rd, found = app.StakingKeeper.GetRedelegation(ctx, selfDelAddr, valAddr, valAddr2) + _, found = app.StakingKeeper.GetRedelegation(ctx, selfDelAddr, valAddr, valAddr2) require.False(t, found) } @@ -940,7 +940,7 @@ func TestMultipleRedelegationAtUniqueTimes(t *testing.T) { // move forward in time, should complete the second redelegation ctx = tstaking.TurnBlockTimeDiff(5 * time.Second) - rd, found = app.StakingKeeper.GetRedelegation(ctx, selfDelAddr, valAddr, valAddr2) + _, found = app.StakingKeeper.GetRedelegation(ctx, selfDelAddr, valAddr, valAddr2) require.False(t, found) } @@ -980,7 +980,7 @@ func TestMultipleUnbondingDelegationAtSameTime(t *testing.T) { // move forwaubd in time, should complete both ubds ctx = tstaking.TurnBlockTimeDiff(1 * time.Second) - ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, selfDelAddr, valAddr) + _, found = app.StakingKeeper.GetUnbondingDelegation(ctx, selfDelAddr, valAddr) require.False(t, found) } @@ -1028,7 +1028,7 @@ func TestMultipleUnbondingDelegationAtUniqueTimes(t *testing.T) { // move forwaubd in time, should complete the second redelegation ctx = tstaking.TurnBlockTimeDiff(5 * time.Second) - ubd, found = app.StakingKeeper.GetUnbondingDelegation(ctx, selfDelAddr, valAddr) + _, found = app.StakingKeeper.GetUnbondingDelegation(ctx, selfDelAddr, valAddr) require.False(t, found) } diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index ca609e9c11..f81fa3d399 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -350,7 +350,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { require.NoError(t, simapp.FundModuleAccount(app, ctx, bondedPool.GetName(), delCoins)) app.AccountKeeper.SetModuleAccount(ctx, bondedPool) - validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true) + _ = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true) delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) app.StakingKeeper.SetDelegation(ctx, delegation) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 637dd6e403..eda115246c 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" "time" - metrics "github.com/armon/go-metrics" + metrics "github.com/hashicorp/go-metrics" tmstrings "github.com/tendermint/tendermint/libs/strings" cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 904c9c5898..b4b5b229b5 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -310,7 +310,7 @@ func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, tokensToBurn, err := k.Unbond(ctx, delegatorAddress, valDstAddr, sharesToUnbond) if err != nil { - panic(fmt.Errorf("error unbonding delegator: %v", err)) + panic(fmt.Errorf("error unbonding delegator: %w", err)) } dstValidator, found := k.GetValidator(ctx, valDstAddr) diff --git a/x/staking/legacy/v043/store_test.go b/x/staking/legacy/v043/store_test.go index cbc917103d..bad5fba9ba 100644 --- a/x/staking/legacy/v043/store_test.go +++ b/x/staking/legacy/v043/store_test.go @@ -127,7 +127,6 @@ func TestStoreMigration(t *testing.T) { // Make sure the new keys are set and old keys are deleted. for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { if !bytes.Equal(tc.oldKey, tc.newKey) { require.Nil(t, store.Get(tc.oldKey)) diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index cc4a936deb..bc486e7c88 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -57,7 +57,6 @@ func TestDecodeStore(t *testing.T) { {"other", ""}, } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { switch i { case len(tests) - 1: diff --git a/x/staking/simulation/genesis_test.go b/x/staking/simulation/genesis_test.go index 40ea16a9a2..c80a3a8a9d 100644 --- a/x/staking/simulation/genesis_test.go +++ b/x/staking/simulation/genesis_test.go @@ -101,8 +101,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tt := range tests { - tt := tt - require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) } } diff --git a/x/staking/types/authz_test.go b/x/staking/types/authz_test.go index a722adf6f6..1063dce831 100644 --- a/x/staking/types/authz_test.go +++ b/x/staking/types/authz_test.go @@ -267,7 +267,6 @@ func TestAuthzAuthorizations(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.msg, func(t *testing.T) { delAuth, err := stakingtypes.NewStakeAuthorization(tc.allowed, tc.denied, tc.msgType, tc.limit) require.NoError(t, err) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 328c0b4102..9929819d6b 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -105,8 +105,6 @@ func TestMsgEditValidator(t *testing.T) { } for _, tc := range tests { - tc := tc - description := types.NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) newRate := sdk.ZeroDec() diff --git a/x/token/client/testutil/query.go b/x/token/client/testutil/query.go index e8ba981d8a..df87b16d6b 100644 --- a/x/token/client/testutil/query.go +++ b/x/token/client/testutil/query.go @@ -62,8 +62,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdBalance() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdBalance() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -117,8 +115,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdToken() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdContract() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -192,8 +188,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdGranteeGrants() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdGranteeGrants() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -254,8 +248,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdIsOperatorFor() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdIsOperatorFor() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -314,8 +306,6 @@ func (s *IntegrationTestSuite) TestNewQueryCmdHoldersByOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewQueryCmdHoldersByOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/token/client/testutil/tx.go b/x/token/client/testutil/tx.go index e3e6746321..662606d97a 100644 --- a/x/token/client/testutil/tx.go +++ b/x/token/client/testutil/tx.go @@ -62,8 +62,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdSend() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdSend() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -136,8 +134,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorSend() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorSend() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -194,8 +190,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdAuthorizeOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdAuthorizeOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -252,8 +246,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdRevokeOperator() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdRevokeOperator() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -318,8 +310,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdIssue() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdIssue() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -379,8 +369,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdGrantPermission() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdGrantPermission() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -437,8 +425,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdRevokePermission() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdRevokePermission() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -498,8 +484,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdMint() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdMint() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -556,8 +540,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdBurn() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdBurn() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -617,8 +599,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdOperatorBurn() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdOperatorBurn() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) @@ -678,8 +658,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdModify() { } for name, tc := range testCases { - tc := tc - s.Run(name, func() { cmd := cli.NewTxCmdModify() out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, append(tc.args, commonArgs...)) diff --git a/x/token/msgs_test.go b/x/token/msgs_test.go index 9fe3dd4549..2a4ba5aeab 100644 --- a/x/token/msgs_test.go +++ b/x/token/msgs_test.go @@ -1026,8 +1026,6 @@ func TestAminoJSON(t *testing.T) { } for name, tc := range testCases { - tc := tc - t.Run(name, func(t *testing.T) { tx.Msgs = []sdk.Msg{tc.msg} require.Equal(t, token.RouterKey, tc.msg.Route()) diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 5c3c500f07..56a7087ca5 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -174,8 +174,6 @@ func (suite *UpgradeTestSuite) TestModuleVersions() { mv := suite.app.UpgradeKeeper.GetModuleVersions(suite.ctx) for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index 6558b0a893..56b97db97d 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -131,8 +131,6 @@ func (s *KeeperTestSuite) TestScheduleUpgrade() { } for _, tc := range cases { - tc := tc - s.Run(tc.name, func() { // reset suite s.SetupTest() diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go index 484a7ac5b0..37727ab45d 100644 --- a/x/upgrade/types/plan_test.go +++ b/x/upgrade/types/plan_test.go @@ -44,7 +44,6 @@ func TestPlanString(t *testing.T) { } for name, tc := range cases { - tc := tc // copy to local variable for scopelint t.Run(name, func(t *testing.T) { s := tc.p.String() require.Equal(t, tc.expect, s) @@ -90,7 +89,6 @@ func TestPlanValid(t *testing.T) { } for name, tc := range cases { - tc := tc // copy to local variable for scopelint t.Run(name, func(t *testing.T) { err := tc.p.ValidateBasic() if tc.valid { @@ -139,7 +137,6 @@ func TestShouldExecute(t *testing.T) { } for name, tc := range cases { - tc := tc // copy to local variable for scopelint t.Run(name, func(t *testing.T) { ctx := sdk.NewContext(nil, tmproto.Header{Height: tc.ctxHeight, Time: tc.ctxTime}, false, log.NewNopLogger()) should := tc.p.ShouldExecute(ctx) diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go index 6a576265c9..174a427200 100644 --- a/x/upgrade/types/proposal_test.go +++ b/x/upgrade/types/proposal_test.go @@ -49,7 +49,6 @@ func TestContentAccessors(t *testing.T) { types.RegisterLegacyAminoCodec(cdc) for name, tc := range cases { - tc := tc // copy to local variable for scopelint t.Run(name, func(t *testing.T) { assert.Equal(t, tc.title, tc.p.GetTitle()) assert.Equal(t, tc.desc, tc.p.GetDescription()) @@ -72,7 +71,6 @@ func TestContentAccessors(t *testing.T) { assert.Equal(t, "upgrade", unwrap.Prop.ProposalRoute()) assert.Equal(t, tc.str, unwrap.Prop.String()) }) - } } diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index 50d9dcf066..6bb64d7e3b 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -110,7 +110,6 @@ func TestSetLoader(t *testing.T) { v := []byte("value") for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { // prepare a db with some data db := dbm.NewMemDB()