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 291681c89d..0000000000 Binary files a/contrib/rosetta/node/data.tar.gz and /dev/null differ diff --git a/contrib/rosetta/rosetta-cli/Dockerfile b/contrib/rosetta/rosetta-cli/Dockerfile deleted file mode 100644 index 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"