From 2350c1aed953643af32b5add3b63cd7405fe8022 Mon Sep 17 00:00:00 2001 From: Jaeseung Lee <41176085+tkxkd0159@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:29:06 +0900 Subject: [PATCH] fix: remove grpc replace directive and refactor grpc-web/rosetta/grpc-gw (backport #1153, #1418) (#1423) * backport finschia-sdk#1153 * backport finschia-sdk#1418 * Keep using Ostracon under tm naming --- .github/workflows/test.yml | 18 - CHANGELOG.md | 1 + Makefile | 13 +- baseapp/deliver_tx_test.go | 2 + baseapp/grpcrouter.go | 23 +- baseapp/grpcrouter_helpers.go | 8 +- client/config/config_test.go | 5 +- client/context.go | 10 +- client/grpc_query.go | 72 +- codec/codec.go | 9 + codec/proto_codec.go | 56 +- contrib/rosetta/README.md | 29 - contrib/rosetta/configuration/bootstrap.json | 12 - contrib/rosetta/configuration/data.sh | 59 -- contrib/rosetta/configuration/faucet.py | 25 - contrib/rosetta/configuration/rosetta.json | 51 -- contrib/rosetta/configuration/run_tests.sh | 17 - contrib/rosetta/configuration/send_funds.sh | 5 - contrib/rosetta/configuration/transfer.ros | 105 --- contrib/rosetta/docker-compose.yaml | 39 - contrib/rosetta/node/Dockerfile | 31 - contrib/rosetta/node/data.tar.gz | Bin 36795 -> 0 bytes contrib/rosetta/rosetta-cli/Dockerfile | 18 - docs/run-node/rosetta.md | 133 --- go.mod | 27 +- go.sum | 332 +------- init_node.sh | 6 +- server/api/server.go | 71 +- server/config/config.go | 65 -- server/config/toml.go | 40 - .../grpc/gogoreflection/serverreflection.go | 38 +- server/grpc/grpc_web.go | 46 -- server/grpc/grpc_web_test.go | 315 ------- server/grpc/server.go | 51 +- server/grpc/server_test.go | 2 + server/rosetta.go | 43 - server/rosetta/client_offline.go | 135 --- server/rosetta/client_online.go | 520 ------------ server/rosetta/client_online_test.go | 15 - server/rosetta/codec.go | 22 - server/rosetta/config.go | 204 ----- server/rosetta/converter.go | 767 ------------------ server/rosetta/converter_test.go | 388 --------- server/rosetta/lib/errors/errors.go | 146 ---- server/rosetta/lib/errors/errors_test.go | 68 -- server/rosetta/lib/errors/registry.go | 48 -- .../lib/internal/service/construction.go | 137 ---- server/rosetta/lib/internal/service/data.go | 159 ---- .../rosetta/lib/internal/service/offline.go | 63 -- server/rosetta/lib/internal/service/online.go | 71 -- server/rosetta/lib/server/server.go | 117 --- server/rosetta/lib/types/types.go | 164 ---- server/rosetta/types.go | 104 --- server/rosetta/util.go | 43 - server/start.go | 541 ++++++------ server/types/app.go | 5 - server/util.go | 71 +- simapp/simd/cmd/root.go | 3 - telemetry/metrics.go | 4 +- telemetry/metrics_test.go | 2 +- telemetry/wrapper.go | 2 +- testutil/network/network.go | 32 +- testutil/network/util.go | 52 +- x/auth/vesting/msg_server.go | 5 +- x/bank/keeper/msg_server.go | 2 +- x/distribution/keeper/msg_server.go | 2 +- x/gov/keeper/msg_server.go | 2 +- x/staking/keeper/msg_server.go | 2 +- 68 files changed, 717 insertions(+), 4956 deletions(-) delete mode 100644 contrib/rosetta/README.md delete mode 100644 contrib/rosetta/configuration/bootstrap.json delete mode 100644 contrib/rosetta/configuration/data.sh delete mode 100644 contrib/rosetta/configuration/faucet.py delete mode 100644 contrib/rosetta/configuration/rosetta.json delete mode 100755 contrib/rosetta/configuration/run_tests.sh delete mode 100644 contrib/rosetta/configuration/send_funds.sh delete mode 100644 contrib/rosetta/configuration/transfer.ros delete mode 100644 contrib/rosetta/docker-compose.yaml delete mode 100644 contrib/rosetta/node/Dockerfile delete mode 100644 contrib/rosetta/node/data.tar.gz delete mode 100644 contrib/rosetta/rosetta-cli/Dockerfile delete mode 100644 docs/run-node/rosetta.md delete mode 100644 server/grpc/grpc_web.go delete mode 100644 server/grpc/grpc_web_test.go delete mode 100644 server/rosetta.go delete mode 100644 server/rosetta/client_offline.go delete mode 100644 server/rosetta/client_online.go delete mode 100644 server/rosetta/client_online_test.go delete mode 100644 server/rosetta/codec.go delete mode 100644 server/rosetta/config.go delete mode 100644 server/rosetta/converter.go delete mode 100644 server/rosetta/converter_test.go delete mode 100644 server/rosetta/lib/errors/errors.go delete mode 100644 server/rosetta/lib/errors/errors_test.go delete mode 100644 server/rosetta/lib/errors/registry.go delete mode 100644 server/rosetta/lib/internal/service/construction.go delete mode 100644 server/rosetta/lib/internal/service/data.go delete mode 100644 server/rosetta/lib/internal/service/offline.go delete mode 100644 server/rosetta/lib/internal/service/online.go delete mode 100644 server/rosetta/lib/server/server.go delete mode 100644 server/rosetta/lib/types/types.go delete mode 100644 server/rosetta/types.go delete mode 100644 server/rosetta/util.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0fc97fd99..a82a907103 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -232,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/CHANGELOG.md b/CHANGELOG.md index 1ecb3c2a2b..522b49fd5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Removed ### Breaking Changes +* (server) [\#1423](https://github.com/Finschia/finschia-sdk/pull/1423) Remove grpc replace directive and refactor grpc-web/rosetta/grpc-gw ### State Machine Breaking diff --git a/Makefile b/Makefile index 250003f436..2f9eb0198f 100644 --- a/Makefile +++ b/Makefile @@ -530,17 +530,12 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes localnet-build-dlv localnet-build-nodes ############################################################################### -### rosetta ### +### tools ### ############################################################################### -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 +error-doc-gen: + cd ./tools/error_doc && go run ./ +.PHONY: error-doc-gen ############################################################################### ### release ### diff --git a/baseapp/deliver_tx_test.go b/baseapp/deliver_tx_test.go index 268329a0fd..24cfc03426 100644 --- a/baseapp/deliver_tx_test.go +++ b/baseapp/deliver_tx_test.go @@ -22,6 +22,7 @@ import ( "github.com/Finschia/ostracon/libs/log" "github.com/Finschia/finschia-sdk/codec" + codectypes "github.com/Finschia/finschia-sdk/codec/types" "github.com/Finschia/finschia-sdk/snapshots" snapshottypes "github.com/Finschia/finschia-sdk/snapshots/types" "github.com/Finschia/finschia-sdk/store/rootmulti" @@ -336,6 +337,7 @@ func TestGRPCQuery(t *testing.T) { } app := setupBaseApp(t, grpcQueryOpt) + app.GRPCQueryRouter().SetInterfaceRegistry(codectypes.NewInterfaceRegistry()) app.InitChain(abci.RequestInitChain{}) header := tmproto.Header{Height: app.LastBlockHeight() + 1} diff --git a/baseapp/grpcrouter.go b/baseapp/grpcrouter.go index 2ed77f03b9..4c50f0817b 100644 --- a/baseapp/grpcrouter.go +++ b/baseapp/grpcrouter.go @@ -4,24 +4,21 @@ import ( "fmt" gogogrpc "github.com/gogo/protobuf/grpc" + abci "github.com/tendermint/tendermint/abci/types" "google.golang.org/grpc" "google.golang.org/grpc/encoding" - "google.golang.org/grpc/encoding/proto" - - abci "github.com/tendermint/tendermint/abci/types" "github.com/Finschia/finschia-sdk/client/grpc/reflection" + "github.com/Finschia/finschia-sdk/codec" codectypes "github.com/Finschia/finschia-sdk/codec/types" sdk "github.com/Finschia/finschia-sdk/types" ) -var protoCodec = encoding.GetCodec(proto.Name) - // GRPCQueryRouter routes ABCI Query requests to GRPC handlers type GRPCQueryRouter struct { - routes map[string]GRPCQueryHandler - interfaceRegistry codectypes.InterfaceRegistry - serviceData []serviceData + routes map[string]GRPCQueryHandler + cdc encoding.Codec + serviceData []serviceData } // serviceData represents a gRPC service, along with its handler. @@ -83,13 +80,10 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf // call the method handler from the service description with the handler object, // a wrapped sdk.Context with proto-unmarshaled data from the ABCI request data res, err := methodHandler(handler, sdk.WrapSDKContext(ctx), func(i interface{}) error { - err := protoCodec.Unmarshal(req.Data, i) + err := qrt.cdc.Unmarshal(req.Data, i) if err != nil { return err } - if qrt.interfaceRegistry != nil { - return codectypes.UnpackInterfaces(i, qrt.interfaceRegistry) - } return nil }, nil) if err != nil { @@ -97,7 +91,7 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf } // proto marshal the result bytes - resBytes, err := protoCodec.Marshal(res) + resBytes, err := qrt.cdc.Marshal(res) if err != nil { return abci.ResponseQuery{}, err } @@ -119,7 +113,8 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf // SetInterfaceRegistry sets the interface registry for the router. This will // also register the interface reflection gRPC service. func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry) { - qrt.interfaceRegistry = interfaceRegistry + // instantiate the codec + qrt.cdc = codec.NewProtoCodec(interfaceRegistry).GRPCCodec() // Once we have an interface registry, we can register the interface // registry reflection gRPC service. reflection.RegisterReflectionServiceServer( diff --git a/baseapp/grpcrouter_helpers.go b/baseapp/grpcrouter_helpers.go index 6445d096f1..432dd7ece8 100644 --- a/baseapp/grpcrouter_helpers.go +++ b/baseapp/grpcrouter_helpers.go @@ -40,7 +40,7 @@ func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args if querier == nil { return fmt.Errorf("handler not found for %s", method) } - reqBz, err := protoCodec.Marshal(args) + reqBz, err := q.cdc.Marshal(args) if err != nil { return err } @@ -50,15 +50,11 @@ func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args return err } - err = protoCodec.Unmarshal(res.Value, reply) + err = q.cdc.Unmarshal(res.Value, reply) if err != nil { return err } - if q.interfaceRegistry != nil { - return types.UnpackInterfaces(reply, q.interfaceRegistry) - } - return nil } diff --git a/client/config/config_test.go b/client/config/config_test.go index 674e88aabf..46a1dadc89 100644 --- a/client/config/config_test.go +++ b/client/config/config_test.go @@ -12,6 +12,8 @@ import ( "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/config" "github.com/Finschia/finschia-sdk/client/flags" + "github.com/Finschia/finschia-sdk/codec" + codectypes "github.com/Finschia/finschia-sdk/codec/types" clitestutil "github.com/Finschia/finschia-sdk/testutil/cli" "github.com/Finschia/finschia-sdk/x/staking/client/cli" ) @@ -27,7 +29,8 @@ func initClientContext(t *testing.T, envVar string) (client.Context, func()) { home := t.TempDir() clientCtx := client.Context{}. WithHomeDir(home). - WithViper("") + WithViper(""). + WithCodec(codec.NewProtoCodec(codectypes.NewInterfaceRegistry())) clientCtx.Viper.BindEnv(nodeEnv) if envVar != "" { diff --git a/client/context.go b/client/context.go index 181e563afa..74cff41775 100644 --- a/client/context.go +++ b/client/context.go @@ -7,7 +7,7 @@ import ( "os" "github.com/spf13/viper" - + "google.golang.org/grpc" "gopkg.in/yaml.v2" rpcclient "github.com/Finschia/ostracon/rpc/client" @@ -25,6 +25,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 @@ -147,6 +148,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/grpc_query.go b/client/grpc_query.go index 197cf6f29f..adb4775be6 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -2,17 +2,19 @@ package client import ( gocontext "context" + "errors" "fmt" "reflect" "strconv" gogogrpc "github.com/gogo/protobuf/grpc" + "github.com/gogo/protobuf/proto" abci "github.com/tendermint/tendermint/abci/types" "google.golang.org/grpc" "google.golang.org/grpc/encoding" - "google.golang.org/grpc/encoding/proto" "google.golang.org/grpc/metadata" + "github.com/Finschia/finschia-sdk/codec" "github.com/Finschia/finschia-sdk/codec/types" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" grpctypes "github.com/Finschia/finschia-sdk/types/grpc" @@ -21,13 +23,17 @@ import ( var _ gogogrpc.ClientConn = Context{} -var protoCodec = encoding.GetCodec(proto.Name) +// fallBackCodec is used by Context in case Codec is not set. +// it can process every gRPC type, except the ones which contain +// interfaces in their types. +var fallBackCodec = codec.NewProtoCodec(failingInterfaceRegistry{}) // Invoke implements the grpc ClientConn.Invoke method 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() { @@ -50,8 +56,13 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i return err } - // Case 2. Querying state. - reqBz, err := protoCodec.Marshal(req) + 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 } @@ -83,7 +94,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i return err } - err = protoCodec.Unmarshal(res.Value, reply) + err = ctx.gRPCCodec().Unmarshal(res.Value, reply) if err != nil { return err } @@ -114,3 +125,52 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i func (Context) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { return nil, fmt.Errorf("streaming rpc not supported") } + +// gRPCCodec checks if Context's Codec is codec.GRPCCodecProvider +// otherwise it returns fallBackCodec. +func (ctx Context) gRPCCodec() encoding.Codec { + if ctx.Codec == nil { + return fallBackCodec.GRPCCodec() + } + + pc, ok := ctx.Codec.(codec.GRPCCodecProvider) + if !ok { + return fallBackCodec.GRPCCodec() + } + + return pc.GRPCCodec() +} + +var _ types.InterfaceRegistry = failingInterfaceRegistry{} + +// failingInterfaceRegistry is used by the fallback codec +// in case Context's Codec is not set. +type failingInterfaceRegistry struct{} + +// errCodecNotSet is return by failingInterfaceRegistry in case there are attempt to decode +// or encode a type which contains an interface field. +var errCodecNotSet = errors.New("client: cannot encode or decode type which requires the application specific codec") + +func (f failingInterfaceRegistry) UnpackAny(any *types.Any, iface interface{}) error { + return errCodecNotSet +} + +func (f failingInterfaceRegistry) Resolve(typeURL string) (proto.Message, error) { + return nil, errCodecNotSet +} + +func (f failingInterfaceRegistry) RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) { + panic("cannot be called") +} + +func (f failingInterfaceRegistry) RegisterImplementations(iface interface{}, impls ...proto.Message) { + panic("cannot be called") +} + +func (f failingInterfaceRegistry) ListAllInterfaces() []string { + panic("cannot be called") +} + +func (f failingInterfaceRegistry) ListImplementations(ifaceTypeURL string) []string { + panic("cannot be called") +} diff --git a/codec/codec.go b/codec/codec.go index f1c4c92b0c..35ef4bef2f 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -2,6 +2,7 @@ package codec import ( "github.com/gogo/protobuf/proto" + "google.golang.org/grpc/encoding" "github.com/Finschia/finschia-sdk/codec/types" ) @@ -95,4 +96,12 @@ type ( MarshalAminoJSON() ([]byte, error) UnmarshalAminoJSON([]byte) error } + + // GRPCCodecProvider is implemented by the Codec + // implementations which return a gRPC encoding.Codec. + // And it is used to decode requests and encode responses + // passed through gRPC. + GRPCCodecProvider interface { + GRPCCodec() encoding.Codec + } ) diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 5e31d7b2f0..c07b4f3f4e 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -7,7 +7,9 @@ import ( "strings" "github.com/gogo/protobuf/jsonpb" - "github.com/gogo/protobuf/proto" + gogoproto "github.com/gogo/protobuf/proto" + "google.golang.org/grpc/encoding" + legacyproto "google.golang.org/protobuf/proto" "github.com/Finschia/finschia-sdk/codec/types" ) @@ -128,7 +130,7 @@ func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr ProtoMarshaler) // it marshals to JSON using proto codec. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.MarshalInterfaceJSON -func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error) { +func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error) { m, ok := o.(ProtoMarshaler) if !ok { return nil, fmt.Errorf("cannot protobuf JSON encode unsupported type: %T", o) @@ -141,7 +143,7 @@ func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error) { // it executes MarshalJSON except it panics upon failure. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.MarshalInterfaceJSON -func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte { +func (pc *ProtoCodec) MustMarshalJSON(o gogoproto.Message) []byte { bz, err := pc.MarshalJSON(o) if err != nil { panic(err) @@ -154,7 +156,7 @@ func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte { // it unmarshals from JSON using proto codec. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON -func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error { +func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr gogoproto.Message) error { m, ok := ptr.(ProtoMarshaler) if !ok { return fmt.Errorf("cannot protobuf JSON decode unsupported type: %T", ptr) @@ -173,7 +175,7 @@ func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error { // it executes UnmarshalJSON except it panics upon failure. // NOTE: this function must be used with a concrete type which // implements proto.Message. For interface please use the codec.UnmarshalInterfaceJSON -func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message) { +func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr gogoproto.Message) { if err := pc.UnmarshalJSON(bz, ptr); err != nil { panic(err) } @@ -182,7 +184,7 @@ func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message) { // MarshalInterface is a convenience function for proto marshalling interfaces. It packs // the provided value, which must be an interface, in an Any and then marshals it to bytes. // NOTE: to marshal a concrete type, you should use Marshal instead -func (pc *ProtoCodec) MarshalInterface(i proto.Message) ([]byte, error) { +func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) { if err := assertNotNil(i); err != nil { return nil, err } @@ -216,7 +218,7 @@ func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error { // MarshalInterfaceJSON is a convenience function for proto marshalling interfaces. It // packs the provided value in an Any and then marshals it to bytes. // NOTE: to marshal a concrete type, you should use MarshalJSON instead -func (pc *ProtoCodec) MarshalInterfaceJSON(x proto.Message) ([]byte, error) { +func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error) { any, err := types.NewAnyWithValue(x) if err != nil { return nil, err @@ -254,6 +256,46 @@ func (pc *ProtoCodec) InterfaceRegistry() types.InterfaceRegistry { return pc.interfaceRegistry } +// GRPCCodec returns the gRPC Codec for this specific ProtoCodec +func (pc *ProtoCodec) GRPCCodec() encoding.Codec { + return &grpcProtoCodec{cdc: pc} +} + +var errUnknownProtoType = errors.New("codec: unknown proto type") // sentinel error + +// grpcProtoCodec is the implementation of the gRPC proto codec. +type grpcProtoCodec struct { + cdc *ProtoCodec +} + +func (g grpcProtoCodec) Marshal(v interface{}) ([]byte, error) { + // TODO(fdymylja): maybe this is the correct place to support protov2 types too for gRPC + switch m := v.(type) { + case ProtoMarshaler: + return g.cdc.Marshal(m) + case legacyproto.Message: + return legacyproto.Marshal(m) + default: + return nil, fmt.Errorf("%w: cannot marshal type %T", errUnknownProtoType, v) + } +} + +func (g grpcProtoCodec) Unmarshal(data []byte, v interface{}) error { + // TODO(fdymylja): maybe this is the correct place to support protov2 types too for gRPC + switch m := v.(type) { + case ProtoMarshaler: + return g.cdc.Unmarshal(data, m) + case legacyproto.Message: + return legacyproto.Unmarshal(data, m) + default: + return fmt.Errorf("%w: cannot unmarshal type %T", errUnknownProtoType, v) + } +} + +func (g grpcProtoCodec) Name() string { + return "cosmos-sdk-grpc-codec" +} + func assertNotNil(i interface{}) error { if i == nil { return errors.New("can't marshal value") 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 3913012da7..0000000000 --- a/contrib/rosetta/node/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM golang:1.22-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 291681c89dc091faa0a0962c341eca0a8642eab1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36795 zcmV(}K+wM*iwFP!000001MFM}ToY#-&m{rkffdgk70;;EQi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S!k<1Jh$*nOCtA*BlH!(}qjFi+S`_6n@t!JO6W^uYm4d)qi8_HEP zdQIx8(_1Z*i)h)qa!Om}4`da&yeq`}`B9=t7RrlOsF~jvjZU|tR&T16cx2OPPe(l| zmk5QX#q_)yh^_01<}$N6nEhI@xH)KjH5UAsXg;ow>*M;ke(v=@Ob^>|09XP5lA|<$ diff --git a/contrib/rosetta/rosetta-cli/Dockerfile b/contrib/rosetta/rosetta-cli/Dockerfile deleted file mode 100644 index 0ecdba072e..0000000000 --- a/contrib/rosetta/rosetta-cli/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM golang:1.22-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/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 e472de87ff..8492939bdd 100644 --- a/go.mod +++ b/go.mod @@ -6,11 +6,8 @@ require ( github.com/99designs/keyring v1.1.6 github.com/Finschia/ostracon v1.1.4 github.com/VictoriaMetrics/fastcache v1.12.2 - github.com/armon/go-metrics v0.4.1 github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.22.1 - github.com/coinbase/rosetta-sdk-go v0.8.3 - 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 @@ -20,15 +17,15 @@ require ( github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.3 github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.3 + github.com/golang/protobuf v1.5.4 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 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.2.0 - github.com/improbable-eng/grpc-web v0.15.0 - github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b + 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 @@ -38,9 +35,9 @@ require ( github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/spf13/cast v1.6.0 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.18.2 + github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 @@ -49,9 +46,10 @@ require ( github.com/tendermint/tm-db v0.6.7 golang.org/x/crypto v0.24.0 golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 - google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 + 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.31.0 + google.golang.org/protobuf v1.34.1 gopkg.in/yaml.v2 v2.4.0 ) @@ -61,13 +59,11 @@ require ( github.com/Finschia/r2ishiguro_vrf v0.1.2 // indirect github.com/Workiva/go-datastructures v1.1.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // 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/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 @@ -86,6 +82,7 @@ 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 @@ -125,17 +122,15 @@ require ( 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-20231106174013-bbf56f31fb17 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect + google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - nhooyr.io/websocket v1.8.6 // indirect ) replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/jhump/protoreflect => github.com/jhump/protoreflect v1.10.3 - google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index fa34e8e0cb..cd181da3ec 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,10 @@ +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= -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-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/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= @@ -13,15 +12,12 @@ github.com/Finschia/ostracon v1.1.4 h1:untqhChZjktLoMo/b94q6bmeedDfvCV+d+t7yO0I1 github.com/Finschia/ostracon v1.1.4/go.mod h1:kuW9en37Z9+6dGzdoA8+xdCil42wZGZNtrcJe9ugRx8= github.com/Finschia/r2ishiguro_vrf v0.1.2 h1:lDBz6NQMx1pw5I3End6xFmXpM//7KcmTr3Ka983e7v8= github.com/Finschia/r2ishiguro_vrf v0.1.2/go.mod h1:OHRtvzcJnfIrcJ0bvPNktJozRFAyZFuv56E9R3/qB+Y= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= 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= @@ -30,27 +26,14 @@ github.com/Workiva/go-datastructures v1.1.1 h1:9G5u1UqKt6ABseAffHGNfbNQd7omRlWE5 github.com/Workiva/go-datastructures v1.1.1/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= github.com/adlio/schema v1.3.4 h1:8K+41sfQkxfT6a79aLBxx+dBKcid6Raw2JPk5COqeqE= github.com/adlio/schema v1.3.4/go.mod h1:gFMaHYzLkZRfaIqZ5u96LLXPt+DdXSFWUwtr6YBz0kk= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= 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= @@ -66,12 +49,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOF 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/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= -github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= 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/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/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= @@ -80,14 +59,8 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 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/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.3 h1:IYqd+Ser5NVh0s7p8p2Ir82iCvi75E1l0NH2H4NEr0Y= -github.com/coinbase/rosetta-sdk-go v0.8.3/go.mod h1:ChOHc+BNq7zqJDDkui0DA124GOvlAiRbdgAc1U9GMDQ= -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= @@ -95,9 +68,7 @@ github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1A 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= @@ -112,9 +83,7 @@ github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIo github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0= github.com/cosmos/ledger-cosmos-go v0.13.2/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/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 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= @@ -123,14 +92,11 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -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/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= @@ -138,15 +104,12 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh 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/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 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.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/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= @@ -155,14 +118,11 @@ github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojt 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/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= 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/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -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.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= @@ -170,14 +130,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 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/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= @@ -188,29 +142,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/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/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 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= @@ -226,15 +165,11 @@ 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.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +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.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 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -242,7 +177,6 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw 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.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/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= @@ -251,28 +185,17 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ 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/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/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.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -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.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -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= @@ -282,75 +205,44 @@ 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.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/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/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -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.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/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= @@ -359,34 +251,24 @@ 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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -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/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/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/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= @@ -394,129 +276,76 @@ github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0Em 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/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 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/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce h1:/pEpMk55wH0X+E5zedGEMOdLuWmV8P4+4W3+LZaM6kg= github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= -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/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= -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-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= -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/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/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -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/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.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= 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/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.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= 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.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 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.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= 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/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= -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= @@ -528,35 +357,23 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L 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/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 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.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= github.com/rs/zerolog v1.31.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.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.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -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/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= @@ -568,21 +385,16 @@ github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNo github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 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.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 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.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= -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= @@ -615,17 +427,9 @@ 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/yahoo/coname v0.0.0-20170609175141-84592ddf8673 h1:PSg2cEFd+9Ae/r5x5iO8cJ3VmTbZNQp6X8tHDmVJAbA= github.com/yahoo/coname v0.0.0-20170609175141-84592ddf8673/go.mod h1:Wq2sZrP++Us4tAw1h58MHS8BGIpC4NmKHfvw2QWBe9U= @@ -637,29 +441,15 @@ 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.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -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= @@ -671,54 +461,40 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh 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-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= 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/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/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-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -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.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.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 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-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-20190813141303-74dc4d7220e7/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-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-20200520004742-59133d7f0dd7/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-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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= 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-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 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= @@ -731,46 +507,30 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +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-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-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/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-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/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-20200814200057-3d37ad5750ed/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-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-20210510120138-977fb7262007/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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -784,25 +544,16 @@ 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.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.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 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/time v0.0.0-20180412165947-fbb02b2291d2/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-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-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-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -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-20191119224855-298f0cb1881e/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-20200103221440-774c71fcf114/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-20200522201501-cb1345f3a375/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= @@ -817,28 +568,31 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 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-20190425155659-357c62f0e4bb/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-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= -google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= +google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= +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.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/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.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +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= @@ -847,23 +601,17 @@ 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.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= 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/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= @@ -871,7 +619,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs 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= @@ -888,9 +635,4 @@ 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-20190102054323-c2f93a96b099/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.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= -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/init_node.sh b/init_node.sh index a193cc9e55..11ba34c3ac 100644 --- 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/server/api/server.go b/server/api/server.go index c319ec6c9e..9bce7ff2cc 100644 --- a/server/api/server.go +++ b/server/api/server.go @@ -1,6 +1,7 @@ package api import ( + "context" "fmt" "net" "net/http" @@ -14,7 +15,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/Finschia/ostracon/libs/log" - ostrpcserver "github.com/Finschia/ostracon/rpc/jsonrpc/server" + tmrpcserver "github.com/Finschia/ostracon/rpc/jsonrpc/server" "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/codec/legacy" @@ -31,9 +32,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 @@ -89,35 +90,63 @@ 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() - ostCfg := ostrpcserver.DefaultConfig() - ostCfg.MaxOpenConnections = int(cfg.API.MaxOpenConnections) - ostCfg.ReadTimeout = time.Duration(cfg.API.RPCReadTimeout) * time.Second - ostCfg.WriteTimeout = time.Duration(cfg.API.RPCWriteTimeout) * time.Second - ostCfg.IdleTimeout = time.Duration(cfg.API.RPCIdleTimeout) * time.Second - ostCfg.MaxBodyBytes = int64(cfg.API.RPCMaxBodyBytes) + tmCfg := tmrpcserver.DefaultConfig() + tmCfg.MaxOpenConnections = int(cfg.API.MaxOpenConnections) + tmCfg.ReadTimeout = time.Duration(cfg.API.RPCReadTimeout) * time.Second + tmCfg.WriteTimeout = time.Duration(cfg.API.RPCWriteTimeout) * time.Second + tmCfg.IdleTimeout = time.Duration(cfg.API.RPCIdleTimeout) * time.Second + tmCfg.MaxBodyBytes = int64(cfg.API.RPCMaxBodyBytes) - listener, err := ostrpcserver.Listen(cfg.API.Address, ostCfg) + listener, err := tmrpcserver.Listen(cfg.API.Address, tmCfg) if err != nil { s.mtx.Unlock() 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 ostrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, ostCfg) - } + // register grpc-gateway routes + s.Router.PathPrefix("/").Handler(s.GRPCGatewayRouter) + + errCh := make(chan error) - s.logger.Info("starting API server...") - return ostrpcserver.Serve(s.listener, s.Router, s.logger, ostCfg) + // 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. @@ -127,10 +156,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 dea3effc4d..3663d99c91 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -21,9 +21,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" - // DefaultChanCheckTxSize defines the default size of channel check tx in Baseapp DefaultChanCheckTxSize = 10000 @@ -135,29 +132,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. @@ -175,18 +149,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. @@ -206,8 +168,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"` } @@ -267,18 +227,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, @@ -340,25 +288,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 4a041bab0a..f5e44deae7 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -158,30 +158,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 ### ############################################################################### @@ -202,22 +178,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/grpc/gogoreflection/serverreflection.go b/server/grpc/gogoreflection/serverreflection.go index ac1e3c2d05..7576ba5f63 100644 --- a/server/grpc/gogoreflection/serverreflection.go +++ b/server/grpc/gogoreflection/serverreflection.go @@ -387,60 +387,60 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio return err } - out := &rpb.ServerReflectionResponse{ - ValidHost: in.Host, + out := &rpb.ServerReflectionResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha + ValidHost: in.Host, //nolint:staticcheck // SA1019: we want to keep using v1alpha OriginalRequest: in, } switch req := in.MessageRequest.(type) { case *rpb.ServerReflectionRequest_FileByFilename: - b, err := s.fileDescEncodingByFilename(req.FileByFilename, sentFileDescriptors) + b, err := s.fileDescEncodingByFilename(req.FileByFilename, sentFileDescriptors) //nolint:staticcheck // SA1019: we want to keep using v1alpha if err != nil { out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &rpb.ErrorResponse{ + ErrorResponse: &rpb.ErrorResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha ErrorCode: int32(codes.NotFound), ErrorMessage: err.Error(), }, } } else { out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, + FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, //nolint:staticcheck // SA1019: we want to keep using v1alpha } } case *rpb.ServerReflectionRequest_FileContainingSymbol: - b, err := s.fileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors) + b, err := s.fileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors) //nolint:staticcheck // SA1019: we want to keep using v1alpha if err != nil { out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &rpb.ErrorResponse{ + ErrorResponse: &rpb.ErrorResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha ErrorCode: int32(codes.NotFound), ErrorMessage: err.Error(), }, } } else { out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, + FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, //nolint:staticcheck // SA1019: we want to keep using v1alpha } } case *rpb.ServerReflectionRequest_FileContainingExtension: - typeName := req.FileContainingExtension.ContainingType - extNum := req.FileContainingExtension.ExtensionNumber + typeName := req.FileContainingExtension.ContainingType //nolint:staticcheck // SA1019: we want to keep using v1alpha + extNum := req.FileContainingExtension.ExtensionNumber //nolint:staticcheck // SA1019: we want to keep using v1alpha b, err := s.fileDescEncodingContainingExtension(typeName, extNum, sentFileDescriptors) if err != nil { out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &rpb.ErrorResponse{ + ErrorResponse: &rpb.ErrorResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha ErrorCode: int32(codes.NotFound), ErrorMessage: err.Error(), }, } } else { out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, + FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b}, //nolint:staticcheck // SA1019: we want to keep using v1alpha } } case *rpb.ServerReflectionRequest_AllExtensionNumbersOfType: - extNums, err := s.allExtensionNumbersForTypeName(req.AllExtensionNumbersOfType) + extNums, err := s.allExtensionNumbersForTypeName(req.AllExtensionNumbersOfType) //nolint:staticcheck // SA1019: we want to keep using v1alpha if err != nil { out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &rpb.ErrorResponse{ + ErrorResponse: &rpb.ErrorResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha ErrorCode: int32(codes.NotFound), ErrorMessage: err.Error(), }, @@ -448,22 +448,22 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio log.Printf("OH NO: %s", err) } else { out.MessageResponse = &rpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &rpb.ExtensionNumberResponse{ - BaseTypeName: req.AllExtensionNumbersOfType, + AllExtensionNumbersResponse: &rpb.ExtensionNumberResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha + BaseTypeName: req.AllExtensionNumbersOfType, //nolint:staticcheck // SA1019: we want to keep using v1alpha ExtensionNumber: extNums, }, } } case *rpb.ServerReflectionRequest_ListServices: svcNames, _ := s.getSymbols() - serviceResponses := make([]*rpb.ServiceResponse, len(svcNames)) + serviceResponses := make([]*rpb.ServiceResponse, len(svcNames)) //nolint:staticcheck // SA1019: we want to keep using v1alpha for i, n := range svcNames { - serviceResponses[i] = &rpb.ServiceResponse{ + serviceResponses[i] = &rpb.ServiceResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha Name: n, } } out.MessageResponse = &rpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &rpb.ListServiceResponse{ + ListServicesResponse: &rpb.ListServiceResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha Service: serviceResponses, }, } 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 1739fc7bd5..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( - "/lbm.base.ostracon.v1.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 58c9896caa..39d10394f1 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -1,13 +1,15 @@ package grpc import ( + "context" "fmt" "net" - "time" + "github.com/Finschia/ostracon/libs/log" "google.golang.org/grpc" "github.com/Finschia/finschia-sdk/client" + "github.com/Finschia/finschia-sdk/codec" "github.com/Finschia/finschia-sdk/server/config" "github.com/Finschia/finschia-sdk/server/grpc/gogoreflection" reflection "github.com/Finschia/finschia-sdk/server/grpc/reflection/v2" @@ -15,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 @@ -28,9 +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), ) + app.RegisterGRPCServer(grpcSrv) // Reflection allows consumers to build dynamic clients that can write to any @@ -49,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/grpc/server_test.go b/server/grpc/server_test.go index 707c813243..c397843c1e 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -21,6 +21,7 @@ import ( "github.com/Finschia/finschia-sdk/client" reflectionv1 "github.com/Finschia/finschia-sdk/client/grpc/reflection" clienttx "github.com/Finschia/finschia-sdk/client/tx" + "github.com/Finschia/finschia-sdk/codec" reflectionv2 "github.com/Finschia/finschia-sdk/server/grpc/reflection/v2" "github.com/Finschia/finschia-sdk/simapp" "github.com/Finschia/finschia-sdk/testutil/network" @@ -60,6 +61,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.conn, err = grpc.Dial( val0.AppConfig.GRPC.Address, grpc.WithInsecure(), // Or else we get "no transport security set" + grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(s.app.InterfaceRegistry()).GRPCCodec())), ) s.Require().NoError(err) } 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 25bac15326..0000000000 --- a/server/rosetta/client_offline.go +++ /dev/null @@ -1,135 +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 37e5ddc4a8..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" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - - ocrpc "github.com/Finschia/ostracon/rpc/client" - "github.com/Finschia/ostracon/rpc/client/http" - abci "github.com/tendermint/tendermint/abci/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" - 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 ocrpc.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.WithInsecure()) - 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+)\"") //nolint:gocritic - 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 c4ece31c19..0000000000 --- a/server/rosetta/config.go +++ /dev/null @@ -1,204 +0,0 @@ -package rosetta - -import ( - "fmt" - "strings" - "time" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/spf13/pflag" - - crg "github.com/Finschia/finschia-sdk/server/rosetta/lib/server" - - "github.com/Finschia/finschia-sdk/codec" - codectypes "github.com/Finschia/finschia-sdk/codec/types" -) - -// 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 ee6f1db2f3..0000000000 --- a/server/rosetta/converter.go +++ /dev/null @@ -1,767 +0,0 @@ -package rosetta - -import ( - "bytes" - "encoding/json" - "fmt" - "reflect" - - "github.com/btcsuite/btcd/btcec" - rosettatypes "github.com/coinbase/rosetta-sdk-go/types" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/Finschia/ostracon/crypto" - ostcoretypes "github.com/Finschia/ostracon/rpc/core/types" - octypes "github.com/Finschia/ostracon/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 *ostcoretypes.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 octypes.Tx, txResult *abci.ResponseDeliverTx) (*rosettatypes.Transaction, error) - // TxIdentifiers converts a tendermint tx to transaction identifiers - TxIdentifiers(txs []octypes.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 *ostcoretypes.ResultStatus) *rosettatypes.SyncStatus - // Peers converts tendermint peers to rosetta - Peers(peers []ostcoretypes.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 octypes.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 []*rosettatypes.Operation, 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 *ostcoretypes.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 []octypes.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 *ostcoretypes.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 []ostcoretypes.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 := btcec.ParsePubKey(pubKey.Bytes, btcec.S256()) - 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 92f6cea573..0000000000 --- a/server/rosetta/converter_test.go +++ /dev/null @@ -1,388 +0,0 @@ -package rosetta_test - -import ( - "encoding/hex" - "encoding/json" - "testing" - - "github.com/Finschia/finschia-sdk/testutil/testdata" - "github.com/Finschia/finschia-sdk/types/tx/signing" - authtx "github.com/Finschia/finschia-sdk/x/auth/tx" - - 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" - 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 -} - -// generateMsgSend generate sample unsignedTxHex and pubKeyHex -func generateMsgSend() (unsignedTxHex []byte, pubKeyHex []byte) { - cdc, _ := rosetta.MakeCodec() - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) - - _, fromPk, fromAddr := testdata.KeyTestPubAddr() - _, _, toAddr := testdata.KeyTestPubAddr() - - sendMsg := bank.MsgSend{ - FromAddress: fromAddr.String(), - ToAddress: toAddr.String(), - Amount: sdk.NewCoins(sdk.NewInt64Coin("stake", 16)), - } - - txBuilder := txConfig.NewTxBuilder() - err := txBuilder.SetMsgs(&sendMsg) - if err != nil { - return nil, nil - } - txBuilder.SetGasLimit(200000) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewInt64Coin("stake", 1))) - - sigData := signing.SingleSignatureData{ - SignMode: signing.SignMode_SIGN_MODE_DIRECT, - Signature: nil, - } - sig := signing.SignatureV2{ - PubKey: fromPk, - Data: &sigData, - Sequence: 1, - } - err = txBuilder.SetSignatures(sig) - if err != nil { - return nil, nil - } - - stdTx := txBuilder.GetTx() - unsignedTxHex, err = txConfig.TxEncoder()(stdTx) - if err != nil { - return nil, nil - } - - return unsignedTxHex, fromPk.Bytes() -} - -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 f2e31b44af..0000000000 --- a/server/rosetta/lib/errors/errors.go +++ /dev/null @@ -1,146 +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" - - grpccodes "google.golang.org/grpc/codes" - grpcstatus "google.golang.org/grpc/status" - - "github.com/coinbase/rosetta-sdk-go/types" -) - -// 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 marshalling 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 84be297e0b..0000000000 --- a/server/rosetta/lib/errors/errors_test.go +++ /dev/null @@ -1,68 +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.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 88796e4659..ce0530949e 100644 --- a/server/start.go +++ b/server/start.go @@ -3,25 +3,31 @@ package server // DONTCOVER import ( + "context" "fmt" - "net/http" + "io" + "net" "os" "runtime/pprof" "strings" - "time" + "github.com/hashicorp/go-metrics" "github.com/spf13/cobra" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "github.com/Finschia/ostracon/abci/server" ostcmd "github.com/Finschia/ostracon/cmd/ostracon/commands" - "github.com/Finschia/ostracon/config" - ostos "github.com/Finschia/ostracon/libs/os" + tmcfg "github.com/Finschia/ostracon/config" + tmlog "github.com/Finschia/ostracon/libs/log" "github.com/Finschia/ostracon/node" "github.com/Finschia/ostracon/p2p" pvm "github.com/Finschia/ostracon/privval" "github.com/Finschia/ostracon/proxy" + rpchttp "github.com/Finschia/ostracon/rpc/client/http" "github.com/Finschia/ostracon/rpc/client/local" + tmtypes "github.com/Finschia/ostracon/types" "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/flags" @@ -29,13 +35,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" ) // Ostracon full-node start flags @@ -70,11 +75,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 @@ -123,29 +126,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 } - withOST, _ := cmd.Flags().GetBool(flagWithOstracon) - if !withOST { - serverCtx.Logger.Info("starting ABCI without Ostracon") - return startStandAlone(serverCtx, appCreator) + svrCfg, err := getAndValidateConfig(svrCtx) + if err != nil { + return err } - serverCtx.Logger.Info("starting ABCI with Ostracon") + tmetrics, err := startTelemetry(svrCfg) + if err != nil { + return err + } - // amino is needed here for backwards compatibility of REST routes - err = startInProcess(serverCtx, clientCtx, appCreator) - errCode, ok := err.(ErrorCode) - if !ok { + emitServerInfoMetrics() + + 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(flagWithOstracon) + 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) + }) }, } @@ -174,9 +197,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") @@ -191,298 +211,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: %v", 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 { - ostos.Exit(err.Error()) + return err } - defer func() { - if err = svr.Stop(); err != nil { - ostos.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 +} + +// 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) +} - app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper) +// 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() {} - nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile()) + traceWriter, err = openTraceWriter(traceWriterFile) if err != nil { - return err + return traceWriter, cleanup, err } - genDocProvider := node.DefaultGenesisDocProviderFunc(cfg) - - var ( - ocNode *node.Node - gRPCOnly = ctx.Viper.GetBool(flagGRPCOnly) - ) - - if gRPCOnly { - ctx.Logger.Info("starting node in gRPC only mode; Ostracon is disabled") - config.GRPC.Enable = true - } else { - ctx.Logger.Info("starting node with ABCI Ostracon in-process") - - pv := genPvFileOnlyWhenKmsAddressEmpty(cfg) - - ocNode, 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: ocNode created") - if err := ocNode.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: ocNode 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 ostracon RPC client. - if (config.API.Enable || config.GRPC.Enable) && ocNode != nil { - clientCtx = clientCtx.WithClient(local.New(ocNode)) - - 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 + } + + maxRecvMsgSize := config.MaxRecvMsgSize + if maxRecvMsgSize == 0 { + maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize } - var ( - grpcSrv *grpc.Server - grpcWebSrv *http.Server + // 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 ocNode.IsRunning() { - _ = ocNode.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/types/app.go b/server/types/app.go index 38bf01b632..21a1a8d589 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" @@ -20,10 +19,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 0a6597d725..74c163335e 100644 --- a/server/util.go +++ b/server/util.go @@ -1,6 +1,7 @@ package server import ( + "context" "errors" "fmt" "io" @@ -14,13 +15,14 @@ import ( "syscall" "time" - ostcmd "github.com/Finschia/ostracon/cmd/ostracon/commands" - ostcfg "github.com/Finschia/ostracon/config" - ostlog "github.com/Finschia/ostracon/libs/log" + tmcmd "github.com/Finschia/ostracon/cmd/ostracon/commands" + tmcfg "github.com/Finschia/ostracon/config" + tmlog "github.com/Finschia/ostracon/libs/log" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" 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" @@ -38,8 +40,8 @@ const ServerContextKey = sdk.ContextKey("server.context") // server context type Context struct { Viper *viper.Viper - Config *ostcfg.Config - Logger ostlog.Logger + Config *tmcfg.Config + Logger tmlog.Logger } // ErrorCode contains the exit code for server exit. @@ -54,12 +56,12 @@ func (e ErrorCode) Error() string { func NewDefaultContext() *Context { return NewContext( viper.New(), - ostcfg.DefaultConfig(), - ostlog.ZeroLogWrapper{}, + tmcfg.DefaultConfig(), + tmlog.ZeroLogWrapper{}, ) } -func NewContext(v *viper.Viper, config *ostcfg.Config, logger ostlog.Logger) *Context { +func NewContext(v *viper.Viper, config *tmcfg.Config, logger tmlog.Logger) *Context { return &Context{v, config, logger} } @@ -141,16 +143,16 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s } isLogPlain := false - if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == ostcfg.LogFormatPlain { + if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == tmcfg.LogFormatPlain { isLogPlain = true } logLevel := serverCtx.Viper.GetString(flags.FlagLogLevel) if logLevel == "" { - logLevel = ostcfg.DefaultPackageLogLevels() + logLevel = tmcfg.DefaultPackageLogLevels() } - zerologCfg := ostlog.NewZeroLogConfig( + zerologCfg := tmlog.NewZeroLogConfig( isLogPlain, logLevel, serverCtx.Viper.GetString(flags.FlagLogPath), @@ -159,7 +161,7 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s serverCtx.Viper.GetInt(flags.FlagLogMaxBackups), ) - serverCtx.Logger, err = ostlog.NewZeroLogLogger(zerologCfg, os.Stderr) + serverCtx.Logger, err = tmlog.NewZeroLogLogger(zerologCfg, os.Stderr) if err != nil { return fmt.Errorf("failed to initialize logger: %w", err) } @@ -196,16 +198,16 @@ func SetCmdServerContext(cmd *cobra.Command, serverCtx *Context) error { // configuration file. The Tendermint configuration file is parsed given a root // Viper object, whereas the application is parsed with the private package-aware // viperCfg object. -func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customConfig interface{}) (*ostcfg.Config, error) { +func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customConfig interface{}) (*tmcfg.Config, error) { rootDir := rootViper.GetString(flags.FlagHome) configPath := filepath.Join(rootDir, "config") tmCfgFile := filepath.Join(configPath, "config.toml") - conf := ostcfg.DefaultConfig() + conf := tmcfg.DefaultConfig() switch _, err := os.Stat(tmCfgFile); { case os.IsNotExist(err): - ostcfg.EnsureRoot(rootDir) + tmcfg.EnsureRoot(rootDir) if err = conf.ValidateBasic(); err != nil { return nil, fmt.Errorf("error in config file: %v", err) @@ -220,7 +222,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo conf.P2P.ConsensusRecvBufSize = 10000 conf.P2P.BlockchainRecvBufSize = 10000 conf.Consensus.TimeoutCommit = 5 * time.Second - ostcfg.WriteConfigFile(tmCfgFile, conf) + tmcfg.WriteConfigFile(tmCfgFile, conf) case err != nil: return nil, err @@ -287,8 +289,8 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type ShowValidatorCmd(), ShowAddressCmd(), VersionCmd(), - ostcmd.ResetAllCmd, - ostcmd.ResetStateCmd, + tmcmd.ResetAllCmd, + tmcmd.ResetStateCmd, ) startCmd := StartCmd(appCreator, defaultNodeHome) @@ -359,12 +361,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 { @@ -396,7 +417,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/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index d63915389e..89133376a7 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -148,9 +148,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/telemetry/metrics.go b/telemetry/metrics.go index 53235e012b..426897fda4 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 39ffd85b90..c04704c116 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/prometheus/common/expfmt" "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 7d3fba63db..e59f58ab25 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" @@ -21,6 +20,7 @@ import ( ostclient "github.com/Finschia/ostracon/rpc/client" "github.com/stretchr/testify/require" dbm "github.com/tendermint/tm-db" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" "github.com/Finschia/finschia-sdk/baseapp" @@ -159,10 +159,12 @@ type ( ValAddress sdk.ValAddress RPCClient ostclient.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 } ) @@ -216,7 +218,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) @@ -234,11 +235,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) @@ -520,9 +525,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 7fcffd865b..71dd4c0126 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -1,9 +1,9 @@ package network import ( + "context" "encoding/json" "path/filepath" - "time" ostos "github.com/Finschia/ostracon/libs/os" "github.com/Finschia/ostracon/node" @@ -13,6 +13,7 @@ import ( "github.com/Finschia/ostracon/rpc/client/local" "github.com/Finschia/ostracon/types" osttime "github.com/Finschia/ostracon/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/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index f8fd835db0..4dd3df3951 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -3,14 +3,13 @@ package vesting import ( "context" - authtypes "github.com/Finschia/finschia-sdk/x/auth/types" - - "github.com/armon/go-metrics" + "github.com/hashicorp/go-metrics" "github.com/Finschia/finschia-sdk/telemetry" sdk "github.com/Finschia/finschia-sdk/types" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" "github.com/Finschia/finschia-sdk/x/auth/keeper" + authtypes "github.com/Finschia/finschia-sdk/x/auth/types" "github.com/Finschia/finschia-sdk/x/auth/vesting/types" ) 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/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/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/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 8ffb189a2f..40d124ee3e 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( "time" oststrings "github.com/Finschia/ostracon/libs/strings" - metrics "github.com/armon/go-metrics" + metrics "github.com/hashicorp/go-metrics" cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" "github.com/Finschia/finschia-sdk/telemetry"