diff --git a/.dockerignore b/.dockerignore index 554af06..92a68fd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,5 @@ /.idea/ /.github/ +/CODE_OF_CONDUCT.md +/bin/ +/build/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2d340a3..124352c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store* /.idea/ /bin/ -/vendor/ +/build/ +/vendor/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 863b2f1..00f8bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine3.17 AS build +FROM golang:1.20-alpine3.17 AS build COPY . /go/src/github.com/sentinel-official/dvpn-node/ @@ -17,7 +17,6 @@ FROM alpine:3.17 COPY --from=build /go/bin/sentinelnode /usr/local/bin/process COPY --from=build /root/hnsd/hnsd /usr/local/bin/hnsd -RUN apk add --no-cache ip6tables unbound-dev v2ray wireguard-tools && \ - rm -rf /tmp/* /var/tmp/* +RUN apk add --no-cache ip6tables unbound-libs v2ray wireguard-tools CMD ["process"] diff --git a/Makefile b/Makefile index 83ee813..f6f853c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PACKAGES := $(shell go list ./...) -VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') +VERSION := $(shell git describe --tags | sed 's/^v//' | rev | cut -d - -f 2- | rev) COMMIT := $(shell git log -1 --format='%H') BUILD_TAGS := $(strip netgo) @@ -16,13 +16,17 @@ benchmark: .PHONY: clean clean: - rm -rf ./build + rm -rf ./bin ./build ./vendor .PHONY: install install: go build -mod=readonly -tags="${BUILD_TAGS}" -ldflags="${LD_FLAGS}" \ -o ${GOPATH}/bin/sentinelnode main.go +.PHONY: build-image +build-image: + @docker build --compress --file Dockerfile --force-rm --no-cache --tag sentinel-dvpn-node . + .PHONY: go-lint go-lint: @golangci-lint run --fix diff --git a/README.md b/README.md index 3f21614..d68e571 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Sentinel dVPN Node +[![Go](https://img.shields.io/github/go-mod/go-version/sentinel-official/dvpn-node)]() +[![GoReport](https://goreportcard.com/badge/github.com/sentinel-official/dvpn-node)](https://goreportcard.com/report/github.com/sentinel-official/dvpn-node) +[![Licence](https://img.shields.io/github/license/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/blob/master/LICENSE) [![Tag](https://img.shields.io/github/tag/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/releases/latest) -[![GoReportCard](https://goreportcard.com/badge/github.com/sentinel-official/dvpn-node)](https://goreportcard.com/report/github.com/sentinel-official/dvpn-node) -[![Licence](https://img.shields.io/github/license/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/blob/development/LICENSE) -[![LoC](https://tokei.rs/b1/github/sentinel-official/dvpn-node)](https://github.com/sentinel-official/dvpn-node) +[![TotalLines](https://img.shields.io/tokei/lines/github/sentinel-official/dvpn-node)]() For documentation click [here](https://docs.sentinel.co/dVPN-node/setup "here") diff --git a/cmd/start.go b/cmd/start.go index d8248f9..fad3f62 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -10,13 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keyring" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/go-kit/kit/transport/http/jsonrpc" "github.com/spf13/cobra" "github.com/spf13/viper" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" "gorm.io/driver/sqlite" "gorm.io/gorm" "gorm.io/gorm/logger" @@ -100,18 +98,12 @@ func StartCmd() *cobra.Command { } var ( - encoding = types.MakeEncodingConfig() - reader = bufio.NewReader(cmd.InOrStdin()) + input = bufio.NewReader(cmd.InOrStdin()) + remotes = strings.Split(config.Chain.RPCAddresses, ",") ) - log.Info("Initializing the RPC client", "address", config.Chain.RPCAddress, "endpoint", "/websocket") - rpcClient, err := rpchttp.New(config.Chain.RPCAddress, "/websocket") - if err != nil { - return err - } - log.Info("Initializing the keyring", "name", types.KeyringName, "backend", config.Keyring.Backend) - kr, err := keyring.New(types.KeyringName, config.Keyring.Backend, home, reader) + kr, err := keyring.New(types.KeyringName, config.Keyring.Backend, home, input) if err != nil { return err } @@ -122,24 +114,21 @@ func StartCmd() *cobra.Command { } client := lite.NewDefaultClient(). - WithAccountRetriever(authtypes.AccountRetriever{}). WithChainID(config.Chain.ID). - WithClient(rpcClient). - WithFrom(config.Keyring.From). WithFromAddress(info.GetAddress()). WithFromName(config.Keyring.From). WithGas(config.Chain.Gas). WithGasAdjustment(config.Chain.GasAdjustment). WithGasPrices(config.Chain.GasPrices). - WithInterfaceRegistry(encoding.InterfaceRegistry). WithKeyring(kr). - WithLegacyAmino(encoding.Amino). WithLogger(log). - WithNodeURI(config.Chain.RPCAddress). + WithQueryTimeout(config.Chain.RPCQueryTimeout). + WithRemotes(remotes). + WithSignModeStr(""). WithSimulateAndExecute(config.Chain.SimulateAndExecute). - WithTxConfig(encoding.TxConfig) + WithTxTimeout(config.Chain.RPCTxTimeout) - account, err := client.QueryAccount(info.GetAddress()) + account, err := client.QueryAccount(client.FromAddress()) if err != nil { return err } @@ -166,7 +155,7 @@ func StartCmd() *cobra.Command { for { log.Info("Starting the Handshake process...") if err := runHandshake(config.Handshake.Peers); err != nil { - log.Error("Handshake process exited unexpectedly", "error", err) + log.Error("handshake process exited unexpectedly", "error", err) } } }() diff --git a/context/context.go b/context/context.go index 684839d..89f145e 100644 --- a/context/context.go +++ b/context/context.go @@ -15,14 +15,14 @@ import ( ) type Context struct { - logger tmlog.Logger - service types.Service - handler http.Handler bandwidth *hubtypes.Bandwidth client *lite.Client config *types.Config database *gorm.DB + handler http.Handler location *types.GeoIPLocation + logger tmlog.Logger + service types.Service } func NewContext() *Context { @@ -32,16 +32,17 @@ func NewContext() *Context { func (c *Context) WithBandwidth(v *hubtypes.Bandwidth) *Context { c.bandwidth = v; return c } func (c *Context) WithClient(v *lite.Client) *Context { c.client = v; return c } func (c *Context) WithConfig(v *types.Config) *Context { c.config = v; return c } +func (c *Context) WithDatabase(v *gorm.DB) *Context { c.database = v; return c } func (c *Context) WithHandler(v http.Handler) *Context { c.handler = v; return c } func (c *Context) WithLocation(v *types.GeoIPLocation) *Context { c.location = v; return c } func (c *Context) WithLogger(v tmlog.Logger) *Context { c.logger = v; return c } func (c *Context) WithService(v types.Service) *Context { c.service = v; return c } -func (c *Context) WithDatabase(v *gorm.DB) *Context { c.database = v; return c } func (c *Context) Address() hubtypes.NodeAddress { return c.Operator().Bytes() } func (c *Context) Bandwidth() *hubtypes.Bandwidth { return c.bandwidth } func (c *Context) Client() *lite.Client { return c.client } func (c *Context) Config() *types.Config { return c.config } +func (c *Context) Database() *gorm.DB { return c.database } func (c *Context) Handler() http.Handler { return c.handler } func (c *Context) IntervalSetSessions() time.Duration { return c.Config().Node.IntervalSetSessions } func (c *Context) IntervalUpdateStatus() time.Duration { return c.Config().Node.IntervalUpdateStatus } @@ -52,7 +53,6 @@ func (c *Context) Moniker() string { return c.Config().Node. func (c *Context) Operator() sdk.AccAddress { return c.client.FromAddress() } func (c *Context) RemoteURL() string { return c.Config().Node.RemoteURL } func (c *Context) Service() types.Service { return c.service } -func (c *Context) Database() *gorm.DB { return c.database } func (c *Context) IntervalUpdateSessions() time.Duration { return c.Config().Node.IntervalUpdateSessions diff --git a/context/service.go b/context/service.go index 27118a9..4539f61 100644 --- a/context/service.go +++ b/context/service.go @@ -9,12 +9,12 @@ func (c *Context) RemovePeer(key string) error { data, err := base64.StdEncoding.DecodeString(key) if err != nil { - c.Log().Error("Failed to decode the key", "error", err, "key", key) + c.Log().Error("failed to decode the key", "error", err, "key", key) return err } if err = c.Service().RemovePeer(data); err != nil { - c.Log().Error("Failed to remove the peer from service", "error", err, "data", data) + c.Log().Error("failed to remove the peer from service", "error", err, "data", data) return err } @@ -24,7 +24,7 @@ func (c *Context) RemovePeer(key string) error { func (c *Context) HasPeer(key string) (bool, error) { data, err := base64.StdEncoding.DecodeString(key) if err != nil { - c.Log().Error("Failed to decode the key", "error", err, "key", key) + c.Log().Error("failed to decode the key", "error", err, "key", key) return false, err } @@ -37,7 +37,7 @@ func (c *Context) RemovePeerIfExists(key string) error { return err } if !ok { - c.Log().Info("Peer does not exist", "key", key) + c.Log().Debug("Peer does not exist", "key", key) return nil } diff --git a/context/tx.go b/context/tx.go index c06f660..2b54773 100644 --- a/context/tx.go +++ b/context/tx.go @@ -21,7 +21,7 @@ func (c *Context) RegisterNode() error { ), ) if err != nil { - c.Log().Error("Failed to register the node", "error", err) + c.Log().Error("failed to register the node", "error", err) return err } @@ -40,7 +40,7 @@ func (c *Context) UpdateNodeInfo() error { ), ) if err != nil { - c.Log().Error("Failed to update the node info", "error", err) + c.Log().Error("failed to update the node info", "error", err) return err } @@ -57,7 +57,7 @@ func (c *Context) UpdateNodeStatus() error { ), ) if err != nil { - c.Log().Error("Failed to update the node status", "error", err) + c.Log().Error("failed to update the node status", "error", err) return err } @@ -86,7 +86,7 @@ func (c *Context) UpdateSessions(items ...types.Session) error { messages..., ) if err != nil { - c.Log().Error("Failed to update the sessions", "error", err) + c.Log().Error("failed to update the sessions", "error", err) return err } diff --git a/go.mod b/go.mod index b585eac..bf67390 100644 --- a/go.mod +++ b/go.mod @@ -3,27 +3,27 @@ module github.com/sentinel-official/dvpn-node go 1.20 require ( - github.com/avast/retry-go v3.0.0+incompatible + github.com/avast/retry-go/v4 v4.3.3 github.com/cosmos/cosmos-sdk v0.45.11 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/ibc-go/v3 v3.4.0 github.com/gin-contrib/cors v1.4.0 - github.com/gin-gonic/gin v1.8.1 + github.com/gin-gonic/gin v1.9.0 github.com/go-kit/kit v0.12.0 github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.28.0 + github.com/rs/zerolog v1.29.0 github.com/sentinel-official/hub v0.10.1 - github.com/showwin/speedtest-go v1.3.0 + github.com/showwin/speedtest-go v1.5.0 github.com/soheilhy/cmux v0.1.5 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.14.0 github.com/tendermint/tendermint v0.34.23 github.com/v2fly/v2ray-core/v5 v5.1.0 - golang.org/x/crypto v0.1.0 + golang.org/x/crypto v0.5.0 google.golang.org/grpc v1.50.1 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 - gorm.io/driver/sqlite v1.4.3 - gorm.io/gorm v1.24.2 + gorm.io/driver/sqlite v1.4.4 + gorm.io/gorm v1.24.5 ) require ( @@ -37,8 +37,10 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/btcsuite/btcd v0.22.1 // indirect + github.com/bytedance/sonic v1.8.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect @@ -61,10 +63,10 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.0 // indirect - github.com/goccy/go-json v0.9.7 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.11.2 // indirect + github.com/goccy/go-json v0.10.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect github.com/gogo/protobuf v1.3.3 // indirect @@ -92,12 +94,13 @@ require ( github.com/jmhodges/levigo v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.11 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/lib/pq v1.10.6 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-sqlite3 v1.14.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect @@ -106,9 +109,9 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/onsi/gomega v1.13.0 // indirect + github.com/onsi/gomega v1.27.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pires/go-proxyproto v0.6.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -134,16 +137,17 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tendermint/tm-db v0.6.7 // indirect - github.com/ugorji/go/codec v1.2.7 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.9 // indirect github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect + golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/net v0.1.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.1.0 // indirect - golang.org/x/term v0.1.0 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/term v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 853e2bf..edc6a14 100644 --- a/go.sum +++ b/go.sum @@ -89,7 +89,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy 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/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= 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= @@ -102,8 +101,8 @@ github.com/armon/go-metrics v0.4.0 h1:yCQqn7dwca4ITXb+CbubHmedzaQYHhNhrEXLYUeEe8 github.com/armon/go-metrics v0.4.0/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/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= -github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= +github.com/avast/retry-go/v4 v4.3.3 h1:G56Bp6mU0b5HE1SkaoVjscZjlQb0oy4mezwY/cGH19w= +github.com/avast/retry-go/v4 v4.3.3/go.mod h1:rg6XFaiuFYII0Xu3RDbZQkxCofFwruZKW8oEF1jpWiU= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -136,6 +135,9 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= +github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= 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= @@ -147,6 +149,9 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -268,8 +273,9 @@ github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURU 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/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= +github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= github.com/go-chi/render v1.0.2 h1:4ER/udB0+fMWB2Jlf15RV3F4A2FDuYi/9f+lFttR/Lg= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -290,31 +296,33 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= -github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= +github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= 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/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= 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/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= 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= @@ -516,6 +524,8 @@ github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8 github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid v1.2.3 h1:CCtW0xUnWGVINKvE/WWOYKdsPV6mawAtvQuSl8guwQs= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/reedsolomon v1.9.3 h1:N/VzgeMfHmLc+KHMD1UL/tNkfXAt8FnUqlgXGIduwAY= 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= @@ -564,8 +574,9 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/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.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -619,7 +630,6 @@ github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= 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/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -630,14 +640,13 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W 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/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 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.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= -github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= +github.com/onsi/gomega v1.27.0 h1:QLidEla4bXUuZVFa4KX6JHCsuGgbi85LC/pCHrt/O08= +github.com/onsi/gomega v1.27.0/go.mod h1:i189pavgK95OSIipFBa74gC2V4qrQuvjuyGEr3GmbXA= 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/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= @@ -663,8 +672,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= -github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= @@ -750,8 +759,8 @@ github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= 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= @@ -767,8 +776,8 @@ github.com/seiflotfy/cuckoofilter v0.0.0-20220312154859-af7fbb8e765b/go.mod h1:b github.com/sentinel-official/hub v0.10.1 h1:DcXrd7dGJnbRS0r7uOltzjATo2ImuPqLrRsSfaxa6G4= github.com/sentinel-official/hub v0.10.1/go.mod h1:WX64FXc/7qNnE2I3yOMjcKeek02zE/mZFbZvJBweOHk= github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/showwin/speedtest-go v1.3.0 h1:sXc/fJbZYiu+OxMXO5ZmxMPwv1pXikr9Drg+lH8plqM= -github.com/showwin/speedtest-go v1.3.0/go.mod h1:dJugxvC/AQDt4HQQKZ9lKNa2+b1c8nzj9IL0a/F8l1U= +github.com/showwin/speedtest-go v1.5.0 h1:g+oy5HeemQ0LusWOYY1UHiasC6EsHsut76u4Hqq8alY= +github.com/showwin/speedtest-go v1.5.0/go.mod h1:Y7c+pxzaNAlo4mYP+x83pnYY8IM3bkHGDhTdrgUnkNE= 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= @@ -848,14 +857,17 @@ github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk1 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/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU= +github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= 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/v2fly/BrowserBridge v0.0.0-20210430233438-0570fc1d7d08 h1:4Yh46CVE3k/lPq6hUbEdbB1u1anRBXLewm3k+L0iOMc= @@ -901,6 +913,8 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE= go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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= @@ -921,9 +935,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1011,13 +1024,11 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1039,9 +1050,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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= @@ -1099,7 +1108,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1118,12 +1126,12 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1133,8 +1141,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1191,7 +1199,6 @@ golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1350,11 +1357,11 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU= -gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= +gorm.io/driver/sqlite v1.4.4 h1:gIufGoR0dQzjkyqDyYSCvsYR6fba1Gw5YKDqKeChxFc= +gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= -gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0= -gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE= +gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1368,6 +1375,7 @@ inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 h1:acCzuUSQ79tGsM/O50VRFySfMm nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/lite/client.go b/lite/client.go index ce93169..b522621 100644 --- a/lite/client.go +++ b/lite/client.go @@ -2,143 +2,152 @@ package lite import ( "io" - "os" "sync" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" tmlog "github.com/tendermint/tendermint/libs/log" - rpcclient "github.com/tendermint/tendermint/rpc/client" ) type Client struct { - ctx client.Context - txf tx.Factory - logger tmlog.Logger - mutex sync.Mutex + ctx client.Context + log tmlog.Logger + mutex *sync.Mutex + queryTimeout uint + remotes []string + txf tx.Factory + txTimeout uint } func NewClient() *Client { - return &Client{} + return &Client{ + mutex: &sync.Mutex{}, + } } func NewDefaultClient() *Client { + var ( + cfg = EncodingConfig() + ctx = client.Context{}. + WithBroadcastMode(flags.BroadcastBlock). + WithCodec(cfg.Marshaler). + WithInterfaceRegistry(cfg.InterfaceRegistry). + WithLegacyAmino(cfg.Amino). + WithOutputFormat("text"). + WithOutput(io.Discard). + WithSkipConfirmation(true) + ) + return NewClient(). - WithBroadcastMode("block"). - WithGenerateOnly(false). - WithHeight(0). - WithOutput(os.Stdout). - WithOutputFormat("text"). - WithUseLedger(false). - WithSimulate(false). - WithSkipConfirm(true). - WithMemo("") -} - -func (c *Client) Copy() *Client { - return &Client{ - ctx: c.ctx, - txf: c.txf, - } + WithContext(ctx). + WithAccountRetriever(authtypes.AccountRetriever{}). + WithTxConfig(cfg.TxConfig) } -func (c *Client) WithBroadcastMode(v string) *Client { c.ctx.BroadcastMode = v; return c } -func (c *Client) WithClient(v rpcclient.Client) *Client { c.ctx.Client = v; return c } -func (c *Client) WithFrom(v string) *Client { c.ctx.From = v; return c } -func (c *Client) WithFromAddress(v sdk.AccAddress) *Client { c.ctx.FromAddress = v; return c } -func (c *Client) WithFromName(v string) *Client { c.ctx.FromName = v; return c } -func (c *Client) WithGenerateOnly(v bool) *Client { c.ctx.GenerateOnly = v; return c } -func (c *Client) WithHeight(v int64) *Client { c.ctx.Height = v; return c } -func (c *Client) WithHomeDir(v string) *Client { c.ctx.HomeDir = v; return c } -func (c *Client) WithInput(v io.Reader) *Client { c.ctx.Input = v; return c } -func (c *Client) WithJSONCodec(v codec.JSONCodec) *Client { c.ctx.JSONCodec = v; return c } -func (c *Client) WithKeyringDir(v string) *Client { c.ctx.KeyringDir = v; return c } -func (c *Client) WithLegacyAmino(v *codec.LegacyAmino) *Client { c.ctx.LegacyAmino = v; return c } -func (c *Client) WithLogger(v tmlog.Logger) *Client { c.logger = v; return c } -func (c *Client) WithNodeURI(v string) *Client { c.ctx.NodeURI = v; return c } -func (c *Client) WithOffline(v bool) *Client { c.ctx.Offline = v; return c } -func (c *Client) WithOutput(v io.Writer) *Client { c.ctx.Output = v; return c } -func (c *Client) WithOutputFormat(v string) *Client { c.ctx.OutputFormat = v; return c } -func (c *Client) WithSimulate(v bool) *Client { c.ctx.Simulate = v; return c } -func (c *Client) WithSkipConfirm(v bool) *Client { c.ctx.SkipConfirm = v; return c } -func (c *Client) WithUseLedger(v bool) *Client { c.ctx.UseLedger = v; return c } +func (c *Client) WithContext(v client.Context) *Client { + c.ctx = v + return c +} -func (c *Client) WithAccountRetriever(v client.AccountRetriever) *Client { - c.ctx.AccountRetriever = v - c.txf = c.txf.WithAccountRetriever(v) +func (c *Client) WithLogger(v tmlog.Logger) *Client { + c.log = v + return c +} +func (c *Client) WithQueryTimeout(v uint) *Client { + c.queryTimeout = v return c } -func (c *Client) WithInterfaceRegistry(v codectypes.InterfaceRegistry) *Client { - c.ctx.InterfaceRegistry = v +func (c *Client) WithRemotes(v []string) *Client { + c.remotes = v return c } -func (c *Client) WithAccountNumber(v uint64) *Client { c.txf = c.txf.WithAccountNumber(v); return c } -func (c *Client) WithFees(v string) *Client { c.txf = c.txf.WithFees(v); return c } -func (c *Client) WithGas(v uint64) *Client { c.txf = c.txf.WithGas(v); return c } -func (c *Client) WithGasAdjustment(v float64) *Client { c.txf = c.txf.WithGasAdjustment(v); return c } -func (c *Client) WithGasPrices(v string) *Client { c.txf = c.txf.WithGasPrices(v); return c } -func (c *Client) WithMemo(v string) *Client { c.txf = c.txf.WithMemo(v); return c } -func (c *Client) WithSequence(v uint64) *Client { c.txf = c.txf.WithSequence(v); return c } -func (c *Client) WithTimeoutHeight(v uint64) *Client { c.txf = c.txf.WithTimeoutHeight(v); return c } +func (c *Client) WithTxTimeout(v uint) *Client { + c.txTimeout = v + return c +} -func (c *Client) WithSimulateAndExecute(v bool) *Client { - c.txf = c.txf.WithSimulateAndExecute(v) +func (c *Client) WithAccountRetriever(v client.AccountRetriever) *Client { + c.ctx = c.ctx.WithAccountRetriever(v) + c.txf = c.txf.WithAccountRetriever(v) return c } func (c *Client) WithChainID(v string) *Client { - c.ctx.ChainID = v + c.ctx = c.ctx.WithChainID(v) c.txf = c.txf.WithChainID(v) + return c +} +func (c *Client) WithFeeGranterAddress(v sdk.AccAddress) *Client { + c.ctx = c.ctx.WithFeeGranterAddress(v) return c } -func (c *Client) WithKeyring(v keyring.Keyring) *Client { - c.ctx.Keyring = v - c.txf = c.txf.WithKeybase(v) +func (c *Client) WithFromAddress(v sdk.AccAddress) *Client { + c.ctx = c.ctx.WithFromAddress(v) + return c +} + +func (c *Client) WithFromName(v string) *Client { + c.ctx = c.ctx.WithFromName(v) + return c +} +func (c *Client) WithGas(v uint64) *Client { + c.txf = c.txf.WithGas(v) return c } -func (c *Client) WithSignMode(v string) *Client { - c.ctx.SignModeStr = v +func (c *Client) WithGasAdjustment(v float64) *Client { + c.txf = c.txf.WithGasAdjustment(v) + return c +} + +func (c *Client) WithGasPrices(v string) *Client { + c.txf = c.txf.WithGasPrices(v) + return c +} + +func (c *Client) WithKeyring(v keyring.Keyring) *Client { + c.ctx = c.ctx.WithKeyring(v) + c.txf = c.txf.WithKeybase(v) + return c +} - var mode signing.SignMode +func (c *Client) WithSignModeStr(v string) *Client { + m := signing.SignMode_SIGN_MODE_UNSPECIFIED switch v { case flags.SignModeDirect: - mode = signing.SignMode_SIGN_MODE_DIRECT + m = signing.SignMode_SIGN_MODE_DIRECT case flags.SignModeLegacyAminoJSON: - mode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON - default: - mode = signing.SignMode_SIGN_MODE_UNSPECIFIED + m = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON } - c.txf.WithSignMode(mode) + c.ctx = c.ctx.WithSignModeStr(v) + c.txf = c.txf.WithSignMode(m) + return c +} + +func (c *Client) WithSimulateAndExecute(v bool) *Client { + c.txf = c.txf.WithSimulateAndExecute(v) return c } func (c *Client) WithTxConfig(v client.TxConfig) *Client { - c.ctx.TxConfig = v + c.ctx = c.ctx.WithTxConfig(v) c.txf = c.txf.WithTxConfig(v) - return c } -func (c *Client) BroadcastMode() string { return c.ctx.BroadcastMode } -func (c *Client) ChainID() string { return c.ctx.ChainID } -func (c *Client) Client() rpcclient.Client { return c.ctx.Client } -func (c *Client) From() string { return c.ctx.From } func (c *Client) FromAddress() sdk.AccAddress { return c.ctx.FromAddress } -func (c *Client) Keyring() keyring.Keyring { return c.ctx.Keyring } -func (c *Client) Log() tmlog.Logger { return c.logger } -func (c *Client) TxConfig() client.TxConfig { return c.ctx.TxConfig } +func (c *Client) FromName() string { return c.ctx.FromName } func (c *Client) SimulateAndExecute() bool { return c.txf.SimulateAndExecute() } +func (c *Client) TxConfig() client.TxConfig { return c.ctx.TxConfig } diff --git a/types/encoding.go b/lite/encoding.go similarity index 54% rename from types/encoding.go rename to lite/encoding.go index ab4e3d0..2ed2e79 100644 --- a/types/encoding.go +++ b/lite/encoding.go @@ -1,4 +1,4 @@ -package types +package lite import ( sdkstd "github.com/cosmos/cosmos-sdk/std" @@ -32,47 +32,46 @@ import ( "github.com/sentinel-official/hub/x/vpn" ) -var ( - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - authvesting.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModule{}, - crisis.AppModuleBasic{}, - distribution.AppModuleBasic{}, - evidence.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - genutil.AppModuleBasic{}, - gov.NewAppModuleBasic( - distributionclient.ProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, - paramsclient.ProposalHandler, - upgradeclient.ProposalHandler, - upgradeclient.CancelProposalHandler, - ), - ibc.AppModuleBasic{}, - ibcica.AppModuleBasic{}, - ibctransfer.AppModuleBasic{}, - mint.AppModuleBasic{}, - params.AppModuleBasic{}, - slashing.AppModuleBasic{}, - staking.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - custommint.AppModule{}, - swap.AppModuleBasic{}, - vpn.AppModuleBasic{}, +func EncodingConfig() hubparams.EncodingConfig { + var ( + cfg = hubparams.MakeEncodingConfig() + modules = module.NewBasicManager( + auth.AppModuleBasic{}, + authvesting.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + bank.AppModuleBasic{}, + capability.AppModule{}, + crisis.AppModuleBasic{}, + distribution.AppModuleBasic{}, + evidence.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + genutil.AppModuleBasic{}, + gov.NewAppModuleBasic( + distributionclient.ProposalHandler, + ibcclientclient.UpdateClientProposalHandler, + ibcclientclient.UpgradeProposalHandler, + paramsclient.ProposalHandler, + upgradeclient.ProposalHandler, + upgradeclient.CancelProposalHandler, + ), + ibc.AppModuleBasic{}, + ibcica.AppModuleBasic{}, + ibctransfer.AppModuleBasic{}, + mint.AppModuleBasic{}, + params.AppModuleBasic{}, + slashing.AppModuleBasic{}, + staking.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + custommint.AppModule{}, + swap.AppModuleBasic{}, + vpn.AppModuleBasic{}, + ) ) -) - -func MakeEncodingConfig() hubparams.EncodingConfig { - config := hubparams.MakeEncodingConfig() - sdkstd.RegisterLegacyAminoCodec(config.Amino) - sdkstd.RegisterInterfaces(config.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(config.Amino) - ModuleBasics.RegisterInterfaces(config.InterfaceRegistry) + sdkstd.RegisterLegacyAminoCodec(cfg.Amino) + sdkstd.RegisterInterfaces(cfg.InterfaceRegistry) + modules.RegisterLegacyAminoCodec(cfg.Amino) + modules.RegisterInterfaces(cfg.InterfaceRegistry) - return config + return cfg } diff --git a/lite/query.go b/lite/query.go index 04dc442..97cda02 100644 --- a/lite/query.go +++ b/lite/query.go @@ -11,105 +11,225 @@ import ( sessiontypes "github.com/sentinel-official/hub/x/session/types" subscriptiontypes "github.com/sentinel-official/hub/x/subscription/types" vpntypes "github.com/sentinel-official/hub/x/vpn/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" "github.com/sentinel-official/dvpn-node/utils" ) -func (c *Client) QueryAccount(address sdk.AccAddress) (authtypes.AccountI, error) { +func (c *Client) queryAccount(remote string, accAddr sdk.AccAddress) (authtypes.AccountI, error) { + c.log.Debug("Querying the account", "remote", remote, "address", accAddr) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return nil, err + } + var ( - account authtypes.AccountI - qc = authtypes.NewQueryClient(c.ctx) + ctx = c.ctx.WithClient(client) + qc = authtypes.NewQueryClient(ctx) ) - c.Log().Info("Querying the account", "address", address) - res, err := qc.Account( - context.Background(), - &authtypes.QueryAccountRequest{Address: address.String()}, + resp, err := qc.Account( + context.TODO(), + &authtypes.QueryAccountRequest{ + Address: accAddr.String(), + }, ) if err != nil { - return nil, utils.ValidError(err) + return nil, utils.QueryError(err) } - if err := c.ctx.InterfaceRegistry.UnpackAny(res.Account, &account); err != nil { + var result authtypes.AccountI + if err = c.ctx.InterfaceRegistry.UnpackAny(resp.Account, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (c *Client) QueryAccount(accAddr sdk.AccAddress) (result authtypes.AccountI, err error) { + c.log.Info("Querying the account", "address", accAddr) + for i := 0; i < len(c.remotes); i++ { + result, err = c.queryAccount(c.remotes[i], accAddr) + if err == nil { + break + } + } + if err != nil { return nil, err } - return account, nil + return result, nil } -func (c *Client) QueryNode(address hubtypes.NodeAddress) (*nodetypes.Node, error) { +func (c *Client) queryNode(remote string, nodeAddr hubtypes.NodeAddress) (*nodetypes.Node, error) { + c.log.Debug("Querying the node", "remote", remote, "address", nodeAddr) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return nil, err + } + var ( - qc = nodetypes.NewQueryServiceClient(c.ctx) + ctx = c.ctx.WithClient(client) + qc = nodetypes.NewQueryServiceClient(ctx) ) - c.Log().Info("Querying the node", "address", address) res, err := qc.QueryNode( - context.Background(), - nodetypes.NewQueryNodeRequest(address), + context.TODO(), + nodetypes.NewQueryNodeRequest(nodeAddr), ) if err != nil { - return nil, utils.ValidError(err) + return nil, utils.QueryError(err) } return &res.Node, nil } -func (c *Client) QuerySubscription(id uint64) (*subscriptiontypes.Subscription, error) { +func (c *Client) QueryNode(nodeAddr hubtypes.NodeAddress) (result *nodetypes.Node, err error) { + c.log.Info("Querying the node", "address", nodeAddr) + for i := 0; i < len(c.remotes); i++ { + result, err = c.queryNode(c.remotes[i], nodeAddr) + if err == nil { + break + } + } + if err != nil { + return nil, err + } + + return result, nil +} + +func (c *Client) querySubscription(remote string, id uint64) (*subscriptiontypes.Subscription, error) { + c.log.Debug("Querying the subscription", "remote", remote, "id", id) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return nil, err + } + var ( - qc = subscriptiontypes.NewQueryServiceClient(c.ctx) + ctx = c.ctx.WithClient(client) + qc = subscriptiontypes.NewQueryServiceClient(ctx) ) - c.Log().Info("Querying the subscription", "id", id) res, err := qc.QuerySubscription( - context.Background(), + context.TODO(), subscriptiontypes.NewQuerySubscriptionRequest(id), ) if err != nil { - return nil, utils.ValidError(err) + return nil, utils.QueryError(err) } return &res.Subscription, nil } -func (c *Client) QueryQuota(id uint64, address sdk.AccAddress) (*subscriptiontypes.Quota, error) { +func (c *Client) QuerySubscription(id uint64) (result *subscriptiontypes.Subscription, err error) { + c.log.Info("Querying the subscription", "id", id) + for i := 0; i < len(c.remotes); i++ { + result, err = c.querySubscription(c.remotes[i], id) + if err == nil { + break + } + } + if err != nil { + return nil, err + } + + return result, nil +} + +func (c *Client) queryQuota(remote string, id uint64, accAddr sdk.AccAddress) (*subscriptiontypes.Quota, error) { + c.log.Debug("Querying the quota", "remote", remote, "id", id, "address", accAddr) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return nil, err + } + var ( - qc = subscriptiontypes.NewQueryServiceClient(c.ctx) + ctx = c.ctx.WithClient(client) + qc = subscriptiontypes.NewQueryServiceClient(ctx) ) - c.Log().Info("Querying the quota", "id", id, "address", address) res, err := qc.QueryQuota( - context.Background(), - subscriptiontypes.NewQueryQuotaRequest(id, address), + context.TODO(), + subscriptiontypes.NewQueryQuotaRequest(id, accAddr), ) if err != nil { - return nil, utils.ValidError(err) + return nil, utils.QueryError(err) } return &res.Quota, nil } -func (c *Client) QuerySession(id uint64) (*sessiontypes.Session, error) { +func (c *Client) QueryQuota(id uint64, accAddr sdk.AccAddress) (result *subscriptiontypes.Quota, err error) { + c.log.Info("Querying the quota", "id", id, "address", accAddr) + for i := 0; i < len(c.remotes); i++ { + result, err = c.queryQuota(c.remotes[i], id, accAddr) + if err == nil { + break + } + } + if err != nil { + return nil, err + } + + return result, nil +} + +func (c *Client) querySession(remote string, id uint64) (*sessiontypes.Session, error) { + c.log.Debug("Querying the session", "remote", remote, "id", id) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return nil, err + } + var ( - qc = sessiontypes.NewQueryServiceClient(c.ctx) + ctx = c.ctx.WithClient(client) + qc = sessiontypes.NewQueryServiceClient(ctx) ) - c.Log().Info("Querying the session", "id", id) res, err := qc.QuerySession( - context.Background(), + context.TODO(), sessiontypes.NewQuerySessionRequest(id), ) if err != nil { - return nil, utils.ValidError(err) + return nil, utils.QueryError(err) } return &res.Session, nil } -func (c *Client) HasNodeForPlan(id uint64, address hubtypes.NodeAddress) (bool, error) { - value, _, err := c.ctx.QueryStore( +func (c *Client) QuerySession(id uint64) (result *sessiontypes.Session, err error) { + c.log.Info("Querying the session", "id", id) + for i := 0; i < len(c.remotes); i++ { + result, err = c.querySession(c.remotes[i], id) + if err == nil { + break + } + } + if err != nil { + return nil, err + } + + return result, nil +} + +func (c *Client) hasNodeForPlan(remote string, id uint64, nodeAddr hubtypes.NodeAddress) (bool, error) { + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.queryTimeout) + if err != nil { + return false, err + } + + ctx := c.ctx.WithClient(client) + + value, _, err := ctx.QueryStore( append( []byte(plantypes.ModuleName+"/"), - plantypes.NodeForPlanKey(id, address)..., + plantypes.NodeForPlanKey(id, nodeAddr)..., ), vpntypes.ModuleName, ) @@ -122,3 +242,17 @@ func (c *Client) HasNodeForPlan(id uint64, address hubtypes.NodeAddress) (bool, return true, nil } + +func (c *Client) HasNodeForPlan(id uint64, nodeAddr hubtypes.NodeAddress) (result bool, err error) { + for i := 0; i < len(c.remotes); i++ { + result, err = c.hasNodeForPlan(c.remotes[i], id, nodeAddr) + if err == nil { + break + } + } + if err != nil { + return false, err + } + + return result, nil +} diff --git a/lite/tx.go b/lite/tx.go index 4973abc..b16c647 100644 --- a/lite/tx.go +++ b/lite/tx.go @@ -1,91 +1,135 @@ package lite import ( - "github.com/avast/retry-go" + "github.com/avast/retry-go/v4" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/pkg/errors" abcitypes "github.com/tendermint/tendermint/abci/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) -func (c *Client) prepareTxFactory(messages ...sdk.Msg) (txf tx.Factory, err error) { +func (c *Client) broadcastTx(remote string, txBytes []byte) (*sdk.TxResponse, error) { + c.log.Debug("Broadcasting the transaction", "remote", remote, "size", len(txBytes)) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.txTimeout) + if err != nil { + return nil, err + } + + ctx := c.ctx.WithClient(client) + + resp, err := ctx.BroadcastTx(txBytes) + if err != nil { + return nil, err + } + + switch resp.Code { + case abcitypes.CodeTypeOK: + return resp, nil + case sdkerrors.ErrTxInMempoolCache.ABCICode(): + return resp, nil + default: + return nil, errors.New(resp.RawLog) + } +} + +func (c *Client) BroadcastTx(txBytes []byte) (res *sdk.TxResponse, err error) { defer func() { if err != nil { - c.Log().Error("Failed to prepare the transaction", "error", err) + c.log.Error("failed to broadcast the transaction", "error", err) } }() - account, err := c.QueryAccount(c.FromAddress()) + for i := 0; i < len(c.remotes); i++ { + res, err = c.broadcastTx(c.remotes[i], txBytes) + if err == nil { + break + } + } if err != nil { - return txf, err + return nil, err } - txf = c.txf. - WithAccountNumber(account.GetAccountNumber()). - WithSequence(account.GetSequence()) + return res, nil +} - if c.SimulateAndExecute() { - _, adjusted, err := tx.CalculateGas(c.ctx, txf, messages...) - if err != nil { - return txf, err +func (c *Client) calculateGas(remote string, txf tx.Factory, messages ...sdk.Msg) (uint64, error) { + c.log.Debug("Calculating the gas", "remote", remote, "messages", len(messages)) + + client, err := rpchttp.NewWithTimeout(remote, "/websocket", c.txTimeout) + if err != nil { + return 0, err + } + + ctx := c.ctx.WithClient(client) + + _, gas, err := tx.CalculateGas(ctx, txf, messages...) + if err != nil { + return 0, err + } + + return gas, nil +} + +func (c *Client) CalculateGas(txf tx.Factory, messages ...sdk.Msg) (gas uint64, err error) { + for i := 0; i < len(c.remotes); i++ { + gas, err = c.calculateGas(c.remotes[i], txf, messages...) + if err == nil { + break } + } - txf = txf.WithGas(adjusted) + if err != nil { + return 0, err } - return txf, nil + return gas, nil } -func (c *Client) broadcastTx(txBytes []byte) (res *sdk.TxResponse, err error) { +func (c *Client) PrepareTxFactory(messages ...sdk.Msg) (txf tx.Factory, err error) { defer func() { if err != nil { - c.Log().Error("Failed to broadcast the transaction", "error", err) + c.log.Error("failed to prepare the transaction", "error", err) } }() - res, err = c.ctx.BroadcastTx(txBytes) + acc, err := c.QueryAccount(c.FromAddress()) if err != nil { - return nil, err - } - - switch res.Code { - case abcitypes.CodeTypeOK: - return res, nil - case sdkerrors.ErrTxInMempoolCache.ABCICode(): - return res, nil - default: - return nil, errors.New(res.RawLog) + return txf, err } -} -func (c *Client) Tx(messages ...sdk.Msg) (res *sdk.TxResponse, err error) { - c.mutex.Lock() - defer c.mutex.Unlock() - - var ( - txf tx.Factory - ) + txf = c.txf. + WithAccountNumber(acc.GetAccountNumber()). + WithSequence(acc.GetSequence()) - c.Log().Info("Preparing the transaction", "messages", len(messages)) - if err := retry.Do(func() error { - txf, err = c.prepareTxFactory(messages...) + if c.SimulateAndExecute() { + gas, err := c.CalculateGas(txf, messages...) if err != nil { - return err + return txf, err } - c.Log().Info("Transaction info", "gas", txf.Gas(), "sequence", txf.Sequence()) - return nil - }, retry.Attempts(5)); err != nil { + txf = txf.WithGas(gas) + } + + return txf, nil +} + +func (c *Client) tx(messages ...sdk.Msg) (res *sdk.TxResponse, err error) { + c.log.Info("Preparing the transaction", "messages", len(messages)) + txf, err := c.PrepareTxFactory(messages...) + if err != nil { return nil, err } + c.log.Info("Transaction info", "gas", txf.Gas(), "sequence", txf.Sequence()) txb, err := tx.BuildUnsignedTx(txf, messages...) if err != nil { return nil, err } - if err := tx.Sign(txf, c.From(), txb, true); err != nil { + if err = tx.Sign(txf, c.FromName(), txb, true); err != nil { return nil, err } @@ -94,17 +138,33 @@ func (c *Client) Tx(messages ...sdk.Msg) (res *sdk.TxResponse, err error) { return nil, err } - c.Log().Info("Broadcasting the transaction", "size", len(txBytes)) - if err := retry.Do(func() error { - res, err = c.broadcastTx(txBytes) - if err != nil { - return err - } + c.log.Info("Broadcasting the transaction", "size", len(txBytes)) + res, err = c.BroadcastTx(txBytes) + if err != nil { + return nil, err + } - c.Log().Info("Transaction result", "code", res.Code, - "codespace", res.Codespace, "height", res.Height, "tx_hash", res.TxHash) - return nil - }, retry.Attempts(5)); err != nil { + return res, nil +} + +func (c *Client) Tx(messages ...sdk.Msg) (res *sdk.TxResponse, err error) { + c.mutex.Lock() + defer c.mutex.Unlock() + + err = retry.Do( + func() error { + res, err = c.tx(messages...) + if err != nil { + return err + } + + c.log.Info("Transaction result", "code", res.Code, + "codespace", res.Codespace, "height", res.Height, "tx_hash", res.TxHash) + return nil + }, + retry.Attempts(5), + ) + if err != nil { return nil, err } diff --git a/main.go b/main.go index 5858044..49eb0de 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ func main() { version.NewVersionCommand(), ) - root.PersistentFlags().String(flags.FlagHome, types.DefaultHomeDirectory, "home") + root.PersistentFlags().String(flags.FlagHome, types.DefaultHomeDirectory, "home directory") root.PersistentFlags().String(flags.FlagLogFormat, "plain", "log format") root.PersistentFlags().String(flags.FlagLogLevel, "info", "log level") diff --git a/node/jobs.go b/node/jobs.go index 4840b37..d142ffb 100644 --- a/node/jobs.go +++ b/node/jobs.go @@ -21,7 +21,10 @@ func (n *Node) jobSetSessions() error { return err } - for i := 0; i < len(peers); i++ { + count := len(peers) + n.Log().Debug("Validating the peers", "count", count) + + for i := 0; i < count; i++ { var item types.Session n.Database().Model( &types.Session{}, @@ -90,9 +93,7 @@ func (n *Node) jobUpdateSessions() error { ).Find(&items) count := len(items) - if count > 0 { - n.Log().Info("Validating the sessions", "count", count) - } + n.Log().Info("Validating the sessions", "count", count) for i := count - 1; i >= 0; i-- { session, err := n.Client().QuerySession(items[i].ID) diff --git a/scripts/runner.sh b/scripts/runner.sh index 8b1231f..c91866f 100755 --- a/scripts/runner.sh +++ b/scripts/runner.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail +set -Eeou pipefail CONTAINER_NAME=sentinelnode NODE_DIR="${HOME}/.sentinelnode" @@ -85,6 +85,13 @@ function cmd_init { } function cmd_init_config { + function generate_moniker { + id=$(docker create "${NODE_IMAGE}") && + name=$(docker inspect --format "{{ .Name }}" "${id}" | cut -c 2-) && + docker rm --force --volumes "${id}" >/dev/null 2>&1 && + echo "${name}" + } + function query_min_price { "${TOOLS_DIR}/buf" curl \ --data '{"subspace":"vpn/node","key":"MinPrice"}' \ @@ -123,12 +130,12 @@ function cmd_init { PUBLIC_IP=$(curl --silent https://ifconfig.me) - local chain_rpc_address=https://rpc.sentinel.co:443 + local chain_rpc_addresses="https://rpc.sentinel.co:443,https://rpc.sentinel.quokkastake.io:443,https://sentinel-rpc.badgerbite.io:443" local handshake_enable=false local keyring_backend=file local node_ipv4_address= local node_listen_on="0.0.0.0:${PORTS[0]}" - local node_moniker= + local node_moniker && node_moniker=$(generate_moniker) local node_price && node_price=$(query_min_price) local node_provider= local node_remote_url="https://${PUBLIC_IP}:${PORTS[0]}" @@ -137,9 +144,9 @@ function cmd_init { echo "Initializing the configuration..." must_run config init --force="${force}" - read -p "Enter chain_rpc_address [${chain_rpc_address}]:" -r input - if [[ -n "${input}" ]]; then chain_rpc_address="${input}"; fi - config_set "chain.rpc_address" "${chain_rpc_address}" + read -p "Enter chain_rpc_addresses [${chain_rpc_addresses}]:" -r input + if [[ -n "${input}" ]]; then chain_rpc_addresses="${input}"; fi + config_set "chain.rpc_addresses" "${chain_rpc_addresses}" read -p "Enter handshake_enable [${handshake_enable}]:" -r input if [[ -n "${input}" ]]; then handshake_enable="${input}"; fi @@ -157,7 +164,7 @@ function cmd_init { if [[ -n "${input}" ]]; then node_listen_on="${input}"; fi config_set "node.listen_on" "${node_listen_on}" - read -p "Enter node_moniker:" -r input + read -p "Enter node_moniker [${node_moniker}]:" -r input if [[ -n "${input}" ]]; then node_moniker="${input}"; fi config_set "node.moniker" "${node_moniker}" @@ -408,7 +415,7 @@ EOF } apt-get update - install_packages curl git openssl + install_packages curl git jq openssl install_tools setup_docker setup_iptables diff --git a/types/config.go b/types/config.go index 0f12d25..4d46d72 100644 --- a/types/config.go +++ b/types/config.go @@ -35,20 +35,26 @@ const ( var ( ct = strings.TrimSpace(` [chain] -# Gas adjustment factor -gas_adjustment = {{ .Chain.GasAdjustment }} - # Gas limit to set per transaction gas = {{ .Chain.Gas }} +# Gas adjustment factor +gas_adjustment = {{ .Chain.GasAdjustment }} + # Gas prices to determine the transaction fee gas_prices = "{{ .Chain.GasPrices }}" # The network chain ID id = "{{ .Chain.ID }}" -# Tendermint RPC interface for the chain -rpc_address = "{{ .Chain.RPCAddress }}" +# Comma separated Tendermint RPC addresses for the chain +rpc_addresses = "{{ .Chain.RPCAddresses }}" + +# Timeout seconds for querying the data from the RPC server +rpc_query_timeout = {{ .Chain.RPCQueryTimeout }} + +# Timeout seconds for broadcasting the transaction through RPC server +rpc_tx_timeout = {{ .Chain.RPCTxTimeout }} # Calculate the transaction fee by simulating it simulate_and_execute = {{ .Chain.SimulateAndExecute }} @@ -114,11 +120,13 @@ max_peers = {{ .QOS.MaxPeers }} ) type ChainConfig struct { + Gas uint64 `json:"gas" mapstructure:"gas"` GasAdjustment float64 `json:"gas_adjustment" mapstructure:"gas_adjustment"` GasPrices string `json:"gas_prices" mapstructure:"gas_prices"` - Gas uint64 `json:"gas" mapstructure:"gas"` ID string `json:"id" mapstructure:"id"` - RPCAddress string `json:"rpc_address" mapstructure:"rpc_address"` + RPCAddresses string `json:"rpc_addresses" mapstructure:"rpc_addresses"` + RPCQueryTimeout uint `json:"rpc_query_timeout" mapstructure:"rpc_query_timeout"` + RPCTxTimeout uint `json:"rpc_tx_timeout" mapstructure:"rpc_tx_timeout"` SimulateAndExecute bool `json:"simulate_and_execute" mapstructure:"simulate_and_execute"` } @@ -127,42 +135,54 @@ func NewChainConfig() *ChainConfig { } func (c *ChainConfig) Validate() error { + if c.Gas <= 0 { + return errors.New("gas must be positive") + } if c.GasAdjustment <= 0 { return errors.New("gas_adjustment must be positive") } if _, err := sdk.ParseCoinsNormalized(c.GasPrices); err != nil { return errors.Wrap(err, "invalid gas_prices") } - if c.Gas <= 0 { - return errors.New("gas must be positive") - } if c.ID == "" { return errors.New("id cannot be empty") } - if c.RPCAddress == "" { - return errors.New("rpc_address cannot be empty") + if c.RPCAddresses == "" { + return errors.New("rpc_addresses cannot be empty") } - rpcAddress, err := url.ParseRequestURI(c.RPCAddress) - if err != nil { - return errors.Wrap(err, "invalid rpc_address") + items := strings.Split(c.RPCAddresses, ",") + for i := 0; i < len(items); i++ { + uri, err := url.ParseRequestURI(items[i]) + if err != nil { + return errors.Wrapf(err, "invalid rpc_address %s", items[i]) + } + if uri.Scheme != "http" && uri.Scheme != "https" { + return errors.New("rpc_address scheme must be either http or https") + } + if uri.Port() == "" { + return errors.New("rpc_address port cannot be empty") + } } - if rpcAddress.Scheme != "http" && rpcAddress.Scheme != "https" { - return errors.New("rpc_address scheme must be either http or https") + + if c.RPCQueryTimeout == 0 { + return errors.New("rpc_query_timeout cannot be 0") } - if rpcAddress.Port() == "" { - return errors.New("rpc_address port cannot be empty") + if c.RPCTxTimeout == 0 { + return errors.New("rpc_tx_timeout cannot be 0") } return nil } func (c *ChainConfig) WithDefaultValues() *ChainConfig { + c.Gas = 200_000 c.GasAdjustment = 1.05 c.GasPrices = "0.1udvpn" - c.Gas = 200000 c.ID = "sentinelhub-2" - c.RPCAddress = "https://rpc.sentinel.co:443" + c.RPCAddresses = "https://rpc.sentinel.co:443" + c.RPCQueryTimeout = 10 + c.RPCTxTimeout = 30 c.SimulateAndExecute = true return c diff --git a/types/session.go b/types/session.go index ae80157..89f1867 100644 --- a/types/session.go +++ b/types/session.go @@ -8,9 +8,9 @@ import ( type Session struct { gorm.Model ID uint64 `gorm:"primaryKey;uniqueIndex:idx_sessions_id"` - Subscription uint64 `gorm:"index:idx_sessions_subscription_for_address"` + Subscription uint64 `gorm:"index:idx_sessions_subscription_address"` Key string `gorm:"uniqueIndex:idx_sessions_key"` - Address string `gorm:"index:idx_sessions_address;index:idx_sessions_subscription_for_address"` + Address string `gorm:"index:idx_sessions_address;index:idx_sessions_subscription_address"` Available int64 Download int64 Upload int64 diff --git a/utils/errors.go b/utils/errors.go index f88e911..6c7198c 100644 --- a/utils/errors.go +++ b/utils/errors.go @@ -5,7 +5,7 @@ import ( "google.golang.org/grpc/status" ) -func ValidError(v error) error { +func QueryError(v error) error { if status.Code(v) == codes.NotFound { return nil }