From 1ab500bb1de9ac6a00902df1eea3ccf39e1fa5bb Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:38:43 +0000 Subject: [PATCH 01/10] bump to v0.46.11; migrate (by replace) to cometbft (v0.34.27) --- cmd/quicksilverd/forceprune.go | 2 +- go.mod | 268 +++++++++++++++++---------------- go.sum | 23 +-- 3 files changed, 151 insertions(+), 142 deletions(-) diff --git a/cmd/quicksilverd/forceprune.go b/cmd/quicksilverd/forceprune.go index ffb95380e..80a9d4ac9 100644 --- a/cmd/quicksilverd/forceprune.go +++ b/cmd/quicksilverd/forceprune.go @@ -12,7 +12,7 @@ import ( "github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/util" tmstore "github.com/tendermint/tendermint/store" - tmdb "github.com/tendermint/tm-db" + tmdb "github.com/cometbft/cometbft-db" "github.com/cosmos/cosmos-sdk/client" "github.com/tendermint/tendermint/config" diff --git a/go.mod b/go.mod index 9061a29fc..a6091377d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/math v1.0.0-beta.4 github.com/CosmWasm/wasmd v0.29.2 github.com/cosmos/cosmos-proto v1.0.0-alpha8 - github.com/cosmos/cosmos-sdk v0.46.9 + github.com/cosmos/cosmos-sdk v0.46.11 github.com/cosmos/ibc-go/v5 v5.2.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 @@ -20,33 +20,58 @@ require ( github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.13.0 github.com/stretchr/testify v1.8.1 - github.com/tendermint/tendermint v0.34.26 + github.com/tendermint/tendermint v0.34.27 github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b go.opencensus.io v0.23.0 golang.org/x/exp v0.0.0-20220914170420-dc92f8653013 golang.org/x/tools v0.5.0 google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 - google.golang.org/grpc v1.50.1 + google.golang.org/grpc v1.52.0 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 gopkg.in/yaml.v2 v2.4.0 mvdan.cc/gofumpt v0.4.0 ) +require ( + github.com/cometbft/cometbft-db v0.7.0 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect +) + require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.12.1 // indirect + cloud.google.com/go/compute/metadata v0.2.1 // indirect + cloud.google.com/go/iam v0.7.0 // indirect + cloud.google.com/go/storage v1.27.0 // indirect + cosmossdk.io/errors v1.0.0-beta.7 + filippo.io/edwards25519 v1.0.0-rc.1 // indirect + github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect + github.com/99designs/keyring v1.2.1 // indirect github.com/Abirdcfly/dupword v0.0.9 // indirect github.com/Antonboom/errname v0.1.7 // indirect github.com/Antonboom/nilnil v0.1.1 // indirect github.com/BurntSushi/toml v1.2.1 // indirect + github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect + github.com/CosmWasm/wasmvm v1.1.1 + github.com/DataDog/zstd v1.5.0 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/OpenPeeDeeP/depguard v1.1.1 // indirect + github.com/Workiva/go-datastructures v1.0.53 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect + github.com/armon/go-metrics v0.4.1 // indirect github.com/ashanbrown/forbidigo v1.3.0 // indirect github.com/ashanbrown/makezero v1.1.1 // indirect + github.com/aws/aws-sdk-go v1.44.122 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect + github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/bkielbasa/cyclop v1.2.0 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v3 v3.3.0 // indirect @@ -54,19 +79,49 @@ require ( github.com/breml/errchkjson v0.3.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/butuzov/ireturn v0.1.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/charithe/durationcheck v0.0.9 // indirect github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348 // indirect + github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect + github.com/cockroachdb/apd/v2 v2.0.2 // indirect + github.com/cockroachdb/errors v1.8.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect + github.com/cockroachdb/pebble v0.0.0-20230213222125-5d8daed0ac88 // indirect + github.com/cockroachdb/redact v1.0.8 // indirect + github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect + github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect + github.com/confio/ics23/go v0.9.0 // indirect + github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/go-bip39 v1.0.0 // indirect + github.com/cosmos/gogoproto v1.4.2 // indirect + github.com/cosmos/iavl v0.19.5 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect + github.com/creachadair/taskgroup v0.3.2 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.9.0 // indirect + github.com/danieljoos/wincred v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/denis-tingaikin/go-header v0.4.3 // indirect + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect + github.com/dgraph-io/badger/v3 v3.2103.2 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect + github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect + github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/esimonov/ifshort v1.0.4 // indirect github.com/ettle/strcase v0.1.1 // indirect github.com/fatih/color v1.14.1 // indirect github.com/fatih/structtag v1.2.0 // indirect + github.com/felixge/httpsnoop v1.0.1 // indirect github.com/firefart/nonamedreturns v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect + github.com/go-kit/kit v0.12.0 // indirect + github.com/go-kit/log v0.2.1 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-toolsmith/astcast v1.0.0 // indirect github.com/go-toolsmith/astcopy v1.0.3 // indirect github.com/go-toolsmith/astequal v1.0.3 // indirect @@ -76,7 +131,12 @@ require ( github.com/go-toolsmith/typep v1.0.2 // indirect github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect github.com/gobwas/glob v0.2.3 // indirect + github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect + github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v1.0.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect @@ -86,50 +146,107 @@ require ( github.com/golangci/misspell v0.4.0 // indirect github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect + github.com/google/btree v1.1.2 // indirect + github.com/google/flatbuffers v2.0.0+incompatible // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/orderedcode v0.0.1 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/gax-go/v2 v2.6.0 // indirect github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect + github.com/gorilla/handlers v1.5.1 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/comment v1.4.2 // indirect github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect + github.com/gtank/merlin v0.1.1 // indirect + github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-getter v1.7.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-safetemp v1.0.0 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect + github.com/improbable-eng/grpc-web v0.15.0 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jgautheron/goconst v1.5.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/jmhodges/levigo v1.0.0 // indirect github.com/julz/importas v0.1.0 // indirect github.com/junk1tm/musttag v0.4.4 // indirect github.com/kisielk/errcheck v1.6.3 // indirect github.com/kisielk/gotool v1.0.0 // indirect github.com/kkHAIKE/contextcheck v1.1.3 // indirect + github.com/klauspost/compress v1.15.15 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.6 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect github.com/ldez/gomoddirectives v0.2.3 // indirect github.com/ldez/tagliatelle v0.4.0 // indirect github.com/leonklingele/grouper v1.1.1 // indirect + github.com/lib/pq v1.10.7 // indirect + github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/linxGnu/grocksdb v1.7.10 // indirect github.com/lufeee/execinquery v1.2.1 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/manifoldco/promptui v0.9.0 // indirect github.com/maratori/testableexamples v1.0.0 // indirect github.com/maratori/testpackage v1.1.0 // indirect github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.2.5 // indirect + github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect + github.com/minio/highwayhash v1.0.2 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.2.1 // indirect + github.com/mtibben/percent v0.2.1 // indirect github.com/nakabonne/nestif v0.3.1 // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect github.com/nishanths/exhaustive v0.9.5 // indirect github.com/nishanths/predeclared v0.2.2 // indirect github.com/nunnatsa/ginkgolinter v0.8.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.5 // indirect + github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.0.6 // indirect + github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect github.com/quasilyte/go-ruleguard v0.3.18 // indirect github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/regen-network/cosmos-proto v0.3.1 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/rs/cors v1.8.2 // indirect + github.com/rs/zerolog v1.27.0 // indirect github.com/ryancurrah/gomodguard v1.3.0 // indirect github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect + github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.21.1 // indirect github.com/securego/gosec/v2 v2.14.0 // indirect @@ -140,159 +257,42 @@ require ( github.com/sivchari/tenv v1.7.1 // indirect github.com/sonatard/noctx v0.0.1 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect + github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.0 // indirect + github.com/subosito/gotenv v1.4.1 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.1.1 // indirect + github.com/tendermint/go-amino v0.16.0 // indirect github.com/tetafro/godot v1.4.11 // indirect - github.com/linxGnu/grocksdb v1.7.10 // indirect github.com/tidwall/btree v1.5.0 // indirect github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e // indirect github.com/timonwong/loggercheck v0.9.3 // indirect github.com/tomarrell/wrapcheck/v2 v2.8.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect + github.com/ulikunitz/xz v0.5.10 // indirect github.com/ultraware/funlen v0.0.3 // indirect github.com/ultraware/whitespace v0.0.5 // indirect github.com/uudashr/gocognit v1.0.6 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect + github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect gitlab.com/bosi/decorder v0.2.3 // indirect + go.etcd.io/bbolt v1.3.6 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.23.0 // indirect + golang.org/x/crypto v0.5.0 // indirect golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect golang.org/x/mod v0.7.0 // indirect - golang.org/x/sync v0.1.0 // indirect - honnef.co/go/tools v0.4.0 // indirect - mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect - mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect - mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect -) - -require ( - cloud.google.com/go v0.105.0 // indirect - cloud.google.com/go/compute v1.12.1 // indirect - cloud.google.com/go/compute/metadata v0.2.1 // indirect - cloud.google.com/go/iam v0.7.0 // indirect - cloud.google.com/go/storage v1.27.0 // indirect - cosmossdk.io/errors v1.0.0-beta.7 - filippo.io/edwards25519 v1.0.0-rc.1 // indirect - github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect - github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/CosmWasm/wasmvm v1.1.1 - github.com/DataDog/zstd v1.5.0 // indirect - github.com/Workiva/go-datastructures v1.0.53 // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.44.122 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // 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/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect - github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.8.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect - github.com/cockroachdb/pebble v0.0.0-20230213222125-5d8daed0ac88 // indirect - github.com/cockroachdb/redact v1.0.8 // indirect - github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect - github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect - github.com/confio/ics23/go v0.9.0 // indirect - github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogoproto v1.4.2 // indirect - github.com/cosmos/iavl v0.19.5 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect - github.com/creachadair/taskgroup v0.3.2 // indirect - github.com/danieljoos/wincred v1.1.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v3 v3.2103.2 // indirect - github.com/dgraph-io/ristretto v0.1.0 // indirect - github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect - github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect - github.com/go-kit/kit v0.12.0 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v1.0.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.1.2 // indirect - github.com/google/flatbuffers v2.0.0+incompatible // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/orderedcode v0.0.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect - github.com/googleapis/gax-go/v2 v2.6.0 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.0 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect - github.com/improbable-eng/grpc-web v0.15.0 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.15.15 // indirect - github.com/kr/pretty v0.3.0 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.7 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/magiconair/properties v1.8.6 // indirect - github.com/manifoldco/promptui v0.9.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect - github.com/minio/highwayhash v1.0.2 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/mtibben/percent v0.2.1 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.5 // indirect - github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect - github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/regen-network/cosmos-proto v0.3.1 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/rs/cors v1.8.2 // indirect - github.com/rs/zerolog v1.27.0 // indirect - github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/spf13/afero v1.8.2 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 - github.com/subosito/gotenv v1.4.1 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tendermint/go-amino v0.16.0 // indirect - github.com/ulikunitz/xz v0.5.10 // indirect - github.com/zondax/hid v0.9.1 // indirect - go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/crypto v0.5.0 // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.1.0 // indirect + golang.org/x/sync v0.1.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 @@ -301,6 +301,10 @@ require ( google.golang.org/appengine v1.6.7 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + honnef.co/go/tools v0.4.0 // indirect + mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect + mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect + mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect nhooyr.io/websocket v1.8.7 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) @@ -313,7 +317,7 @@ replace ( github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/iqlusioninc/liquidity-staking-module => github.com/notional-labs/liquidity-staking-module v0.0.3-0.20220914043211-d4675d9af6ae - github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.26 + github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27 // pebbledb - https://gist.github.com/faddat/673107b72eccdd869b242338dd17e9d9 github.com/tendermint/tm-db => github.com/notional-labs/tm-db v0.6.8-0.20230214123107-77c191d0f7ee ) diff --git a/go.sum b/go.sum index 8bb53c95b..3d0203f60 100644 --- a/go.sum +++ b/go.sum @@ -237,8 +237,6 @@ github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rW github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 h1:+r1rSv4gvYn0wmRjC8X7IAzX8QezqtFV9m0MUHFJgts= github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0/go.mod h1:b3g59n2Y+T5xmcxJL+UEG2f8cQploZm1mR/v6BW0mU0= -github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= -github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -368,12 +366,12 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charithe/durationcheck v0.0.9 h1:mPP4ucLrf/rKZiIG/a9IPXHGlh8p4CzgpyTy6EEutYk= github.com/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348 h1:cy5GCEZLUCshCGCRRUjxHrDUqkB4l5cuUt3ShEckQEo= github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348/go.mod h1:f/miWtG3SSuTxKsNK3o58H1xl+XV6ZIfbC6p7lPPB8U= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -416,6 +414,10 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= +github.com/cometbft/cometbft v0.34.27 h1:ri6BvmwjWR0gurYjywcBqRe4bbwc3QVs9KRcCzgh/J0= +github.com/cometbft/cometbft v0.34.27/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw= +github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= +github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= 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/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= @@ -433,8 +435,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw= github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31eoYqemTT4C1hLCWsO7I= -github.com/cosmos/cosmos-sdk v0.46.9 h1:s19zY5vX0kjV2eJOzR0Y3P6EqgtgpwMdPmXM05TQsXM= -github.com/cosmos/cosmos-sdk v0.46.9/go.mod h1:ZFL/yjcIZq67H8FiWoLCnnaChkXnbRRYEEhGrFq8fzE= +github.com/cosmos/cosmos-sdk v0.46.11 h1:csMJQHtcb/EIu2EJmeg/2NaGkGw3ZScFwa4CRpCCw18= +github.com/cosmos/cosmos-sdk v0.46.11/go.mod h1:bG4AkW9bqc8ycrryyKGQEl3YV9BY2wr6HggGq8kvcgM= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -480,6 +482,7 @@ github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYB 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 v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +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/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= @@ -913,8 +916,6 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/informalsystems/tendermint v0.34.26 h1:89XvVexAy62geGWxmDmdmmJvfindx+Su2oTuwfSWMeU= -github.com/informalsystems/tendermint v0.34.26/go.mod h1:q3uAZ/t5+MblQhFuHSd4flqaLDx7iUtWpwWbwvHAFhs= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= @@ -1418,6 +1419,8 @@ github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplB github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk= github.com/tdakkota/asciicheck v0.1.1 h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A= github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= @@ -2196,8 +2199,9 @@ google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= +google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 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= @@ -2220,6 +2224,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks 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-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/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= From 318edeae305c1852e58eb41678c9b6fb06c37177 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:39:53 +0000 Subject: [PATCH 02/10] dont rewrite the wheel for CoinFromRequestKey --- utils/coins.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/utils/coins.go b/utils/coins.go index af0f00df5..7ef2a1ba3 100644 --- a/utils/coins.go +++ b/utils/coins.go @@ -1,10 +1,10 @@ package utils import ( - "bytes" - "errors" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) // coinFromRequestKey parses @@ -17,14 +17,15 @@ func CoinFromRequestKey(query []byte, accAddr sdk.AccAddress) (sdk.Coin, error) } func DenomFromRequestKey(query []byte, accAddr sdk.AccAddress) (string, error) { - idx := bytes.Index(query, accAddr) - if idx == -1 { - return "", errors.New("AccountBalanceCallback: invalid request query") - } - denom := string(query[idx+len(accAddr):]) - if err := sdk.ValidateDenom(denom); err != nil { + balancesStore := query[1:] + accAddr2, denom, err := banktypes.AddressAndDenomFromBalancesStore(balancesStore) + if err != nil { return "", err } + if !accAddr2.Equals(accAddr) { + return "", fmt.Errorf("account mismatch; expected %s, got %s", accAddr.String(), accAddr2.String()) + } + return denom, nil } From c4bd16986f7adff93fcd39266d24f2068fed77dc Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:44:13 +0000 Subject: [PATCH 03/10] fix off by one error in local claim validation - fixes QCK-29 --- x/claimsmanager/keeper/keeper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/claimsmanager/keeper/keeper.go b/x/claimsmanager/keeper/keeper.go index e3c652d17..95add805d 100644 --- a/x/claimsmanager/keeper/keeper.go +++ b/x/claimsmanager/keeper/keeper.go @@ -52,13 +52,13 @@ func (k Keeper) StoreSelfConsensusState(ctx sdk.Context, key string) error { height = ibcclienttypes.Height{ RevisionNumber: revisionNum, - RevisionHeight: uint64(ctx.BlockHeight() - 1), + RevisionHeight: uint64(ctx.BlockHeight()), } } else { // ONLY FOR TESTING - ibctesting module chains donot follow standard [chainname]-[num] structure height = ibcclienttypes.Height{ RevisionNumber: 0, // revision number for testchain1 is 0 (because parseChainId splits on '-') - RevisionHeight: uint64(ctx.BlockHeight() - 1), + RevisionHeight: uint64(ctx.BlockHeight()), } } From 9415cb98ccca48c698ba6bef5869d544a2748425 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:44:42 +0000 Subject: [PATCH 04/10] add tests for local claim validation - ref QCK-29 --- .../keeper/msg_server_test.go | 208 +++++++++++++++++- 1 file changed, 204 insertions(+), 4 deletions(-) diff --git a/x/participationrewards/keeper/msg_server_test.go b/x/participationrewards/keeper/msg_server_test.go index ac6764a81..c12e9edbd 100644 --- a/x/participationrewards/keeper/msg_server_test.go +++ b/x/participationrewards/keeper/msg_server_test.go @@ -1,17 +1,22 @@ package keeper_test import ( + "encoding/json" + "fmt" "time" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/proto/tendermint/crypto" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/ingenuity-build/quicksilver/app" osmolockup "github.com/ingenuity-build/quicksilver/osmosis-types/lockup" "github.com/ingenuity-build/quicksilver/utils" cmtypes "github.com/ingenuity-build/quicksilver/x/claimsmanager/types" "github.com/ingenuity-build/quicksilver/x/participationrewards/keeper" "github.com/ingenuity-build/quicksilver/x/participationrewards/types" + abci "github.com/tendermint/tendermint/abci/types" ) func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { @@ -175,7 +180,7 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { "valid_liquid", func() { address := utils.GenerateAccAddressForTest() - key := append(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")...) + key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")) cd := sdk.Coin{ Denom: "", @@ -195,7 +200,7 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { Data: bz, ProofOps: &crypto.ProofOps{}, Height: 0, - ProofType: "lockup", + ProofType: "bank", }, }, } @@ -207,7 +212,7 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { "valid_liquid", func() { address := utils.GenerateAccAddressForTest() - key := append(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")...) + key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")) cd := sdk.Coin{ Denom: "", @@ -227,7 +232,7 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { Data: bz, ProofOps: &crypto.ProofOps{}, Height: 11, - ProofType: "lockup", + ProofType: "bank", }, }, } @@ -261,3 +266,198 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { }) } } + +func (suite *KeeperTestSuite) Test_msgServer_SubmitLocalClaim() { + address := utils.GenerateAccAddressForTest() + + var msg *types.MsgSubmitClaim + tests := []struct { + name string + malleate func(ctx sdk.Context, appA *app.Quicksilver) + generate func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim + want *types.MsgSubmitClaimResponse + wantErr string + claims []cmtypes.Claim + }{ + { + "local_callback_nil", + func(ctx sdk.Context, appA *app.Quicksilver) {}, + func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { + + address := utils.GenerateAccAddressForTest() + key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")) + + query := abci.RequestQuery{ + Data: key, + Path: "/store/bank/key", + Height: ctx.BlockHeight() - 1, + Prove: true, + } + + resp := appA.BaseApp.Query(query) + + return &types.MsgSubmitClaim{ + UserAddress: address.String(), + Zone: suite.chainB.ChainID, + SrcZone: suite.chainA.ChainID, + ClaimType: cmtypes.ClaimTypeLiquidToken, + Proofs: []*cmtypes.Proof{ + { + Key: resp.Key, + Data: resp.Value, + ProofOps: resp.ProofOps, + Height: resp.Height, + ProofType: "bank", + }, + }, + } + }, + &types.MsgSubmitClaimResponse{}, + "", + []cmtypes.Claim{}, + }, + { + "local_callback_value_invalid_denom", + func(ctx sdk.Context, appA *app.Quicksilver) { + suite.Require().NoError(appA.BankKeeper.MintCoins(ctx, "mint", sdk.NewCoins(sdk.NewCoin("uqatom", sdk.NewInt(100))))) + suite.Require().NoError(appA.BankKeeper.SendCoinsFromModuleToAccount(ctx, "mint", address, sdk.NewCoins(sdk.NewCoin("uqatom", sdk.NewInt(100))))) + }, + func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { + + key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("uqatom")) + + query := abci.RequestQuery{ + Data: key, + Path: "/store/bank/key", + Height: ctx.BlockHeight() - 1, + Prove: true, + } + + resp := appA.BaseApp.Query(query) + + return &types.MsgSubmitClaim{ + UserAddress: address.String(), + Zone: suite.chainB.ChainID, + SrcZone: suite.chainA.ChainID, + ClaimType: cmtypes.ClaimTypeLiquidToken, + Proofs: []*cmtypes.Proof{ + { + Key: resp.Key, + Data: resp.Value, + ProofOps: resp.ProofOps, + Height: resp.Height, + ProofType: "bank", + }, + }, + } + }, + &types.MsgSubmitClaimResponse{}, + "", + []cmtypes.Claim{}, + }, + { + "local_callback_value_valid_denom", + func(ctx sdk.Context, appA *app.Quicksilver) { + suite.Require().NoError(appA.BankKeeper.MintCoins(ctx, "mint", sdk.NewCoins(sdk.NewCoin("uqatom", sdk.NewInt(100))))) + suite.Require().NoError(appA.BankKeeper.SendCoinsFromModuleToAccount(ctx, "mint", address, sdk.NewCoins(sdk.NewCoin("uqatom", sdk.NewInt(100))))) + + // add uqatom to the list of allowed denoms for this zone + blob, err := json.Marshal(types.LiquidAllowedDenomProtocolData{ + ChainID: suite.chainA.ChainID, + IbcDenom: "uqatom", + QAssetDenom: "uqatom", + RegisteredZoneChainID: suite.chainB.ChainID, + }) + suite.Require().NoError(err) + pd := keeper.NewProtocolData(types.ProtocolDataType_name[int32(types.ProtocolDataTypeLiquidToken)], blob) + + appA.ParticipationRewardsKeeper.SetProtocolData(ctx, fmt.Sprintf("%s/uqatom", suite.chainA.ChainID), pd) + }, + func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { + + key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("uqatom")) + + query := abci.RequestQuery{ + Data: key, + Path: "/store/bank/key", + Height: ctx.BlockHeight() - 1, + Prove: true, + } + + resp := appA.BaseApp.Query(query) + + return &types.MsgSubmitClaim{ + UserAddress: address.String(), + Zone: suite.chainB.ChainID, + SrcZone: suite.chainA.ChainID, + ClaimType: cmtypes.ClaimTypeLiquidToken, + Proofs: []*cmtypes.Proof{ + { + Key: resp.Key, + Data: resp.Value, + ProofOps: resp.ProofOps, + Height: resp.Height, + ProofType: "bank", + }, + }, + } + }, + &types.MsgSubmitClaimResponse{}, + "", + []cmtypes.Claim{{ + UserAddress: address.String(), + ChainId: suite.chainB.ChainID, + Module: cmtypes.ClaimTypeLiquidToken, + SourceChainId: suite.chainA.ChainID, + Amount: 100, + }}, + }, + } + for _, tt := range tests { + tt := tt + + suite.Run(tt.name, func() { + suite.SetupTest() + + appA := suite.GetQuicksilverApp(suite.chainA) + // override disabled proof verification; lets test actual proofs :) + appA.ParticipationRewardsKeeper.ValidateProofOps = utils.ValidateProofOps + appA.ParticipationRewardsKeeper.ValidateSelfProofOps = utils.ValidateSelfProofOps + + suite.coordinator.CommitNBlocks(suite.chainA, 3) + ctx := suite.chainA.GetContext() + tt.malleate(ctx, appA) + suite.coordinator.CommitNBlocks(suite.chainA, 3) + ctx = suite.chainA.GetContext() + suite.Require().NoError(appA.ClaimsManagerKeeper.StoreSelfConsensusState(ctx, "epoch")) + suite.coordinator.CommitNBlocks(suite.chainA, 1) + + ctx = suite.chainA.GetContext() + msg = tt.generate(ctx, appA) + params := appA.ParticipationRewardsKeeper.GetParams(ctx) + params.ClaimsEnabled = true + appA.ParticipationRewardsKeeper.SetParams(ctx, params) + appA.ParticipationRewardsKeeper.CallbackHandler().RegisterCallbacks() + + k := keeper.NewMsgServerImpl(appA.ParticipationRewardsKeeper) + resp, err := k.SubmitClaim(sdk.WrapSDKContext(ctx), msg) + if tt.wantErr != "" { + suite.Require().Errorf(err, tt.wantErr) + suite.Require().Nil(resp) + suite.T().Logf("Error: %v", err) + return + } + + for _, expectedClaim := range tt.claims { + actualClaim, found := appA.ClaimsManagerKeeper.GetClaim(ctx, expectedClaim.ChainId, expectedClaim.UserAddress, expectedClaim.Module, expectedClaim.SourceChainId) + suite.Require().True(found) + suite.Require().Equal(expectedClaim.Amount, actualClaim.Amount) + + } + + suite.Require().NoError(err) + suite.Require().NotNil(resp) + suite.Require().Equal(tt.want, resp) + }) + } +} From eab55271672c57c8a3c5c4252304d07ec104a776 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:45:32 +0000 Subject: [PATCH 05/10] ensure liquid token submodule can support 0.46 balances --- x/participationrewards/keeper/submodule_liquid.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x/participationrewards/keeper/submodule_liquid.go b/x/participationrewards/keeper/submodule_liquid.go index 619dffdd3..494746277 100644 --- a/x/participationrewards/keeper/submodule_liquid.go +++ b/x/participationrewards/keeper/submodule_liquid.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" - + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/ingenuity-build/quicksilver/utils" "github.com/ingenuity-build/quicksilver/x/participationrewards/types" ) @@ -65,14 +65,12 @@ func (m *LiquidTokensModule) ValidateClaim(ctx sdk.Context, k *Keeper, msg *type return 0, err } if denomData.QAssetDenom == zone.LocalDenom && denomData.IbcDenom == denom { - coin := sdk.Coin{} - err = k.cdc.Unmarshal(proof.Data, &coin) + coin, err := bankkeeper.UnmarshalBalanceCompat(k.cdc, proof.Data, denomData.IbcDenom) if err != nil { return 0, err } amount += coin.Amount.Uint64() } - } return amount, nil } From 70318b92bdd6fa4cf8be7ed4112bd3b0cf16060e Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 11:45:59 +0000 Subject: [PATCH 06/10] remove println --- x/participationrewards/keeper/callbacks_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/participationrewards/keeper/callbacks_test.go b/x/participationrewards/keeper/callbacks_test.go index dd19634ac..bed5bfdc6 100644 --- a/x/participationrewards/keeper/callbacks_test.go +++ b/x/participationrewards/keeper/callbacks_test.go @@ -132,7 +132,6 @@ func (suite *KeeperTestSuite) executeSetEpochBlockCallback() { respJSON := `{"block_id":{"hash":"74pkkjg7u1eLtXxFCinnCmln3aVZVOqLCT3OnE3D+VA=","part_set_header":{"total":1,"hash":"UiLM70PpplmmZ85qC0ZKva5kYJmSZ2TTEZ4a7g9G92Q="}},"block":{"header":{"version":{"block":"11","app":"0"},"chain_id":"quickgaia-1","height":"90767","time":"2022-11-03T09:12:23.109926769Z","last_block_id":{"hash":"wCK5QmPuGJiRpn06Xu7ZjhxHwzBXVZrGqngMMzeRq8w=","part_set_header":{"total":1,"hash":"xYxXM7rX6Qcq/Yx3MpZeQA+FCeUbKSVr/FEuzfAFFQk="}},"last_commit_hash":"1Ev2iL1pTgyItBtSFbCRzxwdCtJfaCC1P+zWaDkJ/nU=","data_hash":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","validators_hash":"kQ9NNQ26Q3l5aXF2IwraaweoLzusIVDUA53AycOe1PI=","next_validators_hash":"kQ9NNQ26Q3l5aXF2IwraaweoLzusIVDUA53AycOe1PI=","consensus_hash":"BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=","app_hash":"j3x5PuEH14QVBqWUv6BhKitzXMTJ2w47h2Nj99JKtlI=","last_results_hash":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","evidence_hash":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","proposer_address":"YVEp2+U79qlwIpwaKr4rObvWbHo="},"data":{"txs":[]},"evidence":{"evidence":[]},"last_commit":{"height":"90766","round":0,"block_id":{"hash":"wCK5QmPuGJiRpn06Xu7ZjhxHwzBXVZrGqngMMzeRq8w=","part_set_header":{"total":1,"hash":"xYxXM7rX6Qcq/Yx3MpZeQA+FCeUbKSVr/FEuzfAFFQk="}},"signatures":[{"block_id_flag":"BLOCK_ID_FLAG_COMMIT","validator_address":"WRBCW5t/kdjOaTvYz9TaySfc8xU=","timestamp":"2022-11-03T09:12:23.109926769Z","signature":"LAbAFCM2MlT1QeNnhZoD8xPe6fO6GExtDNdwa8sokr9UZjurHWn3ad9U2BhTLFVKUF6j7r9G9ILKshljKn4/Aw=="},{"block_id_flag":"BLOCK_ID_FLAG_COMMIT","validator_address":"YVEp2+U79qlwIpwaKr4rObvWbHo=","timestamp":"2022-11-03T09:12:23.104507119Z","signature":"KxHLYnn97GG9prtLA+qurq5GvZogcoExpCvWmOOd8uS3m1Tug5qptSxZ2AObiUfyDwl23oqNNEhkp2XxsxcOCA=="},{"block_id_flag":"BLOCK_ID_FLAG_COMMIT","validator_address":"agVlYuY3F6RGyBUe5zgd0oFhoCM=","timestamp":"2022-11-03T09:12:23.109928409Z","signature":"vvL6yIdxyT4Eus/xw8/RWvFymUFNiOsJ+hHM/qwSJQt427hdUiIh/iH6+yZGz5bdpChW4/Y4bB1QnIA8q1SjBw=="}]}}}` glbrResp := tmservice.GetLatestBlockResponse{} suite.GetQuicksilverApp(suite.chainA).AppCodec().UnmarshalJSON([]byte(respJSON), &glbrResp) - fmt.Println(glbrResp) resp, err := glbrResp.Marshal() suite.Require().NoError(err) From 62b092cb1cf6405202e153e100f425d6a31812c3 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 12:50:17 +0000 Subject: [PATCH 07/10] Update utils/coins.go Co-authored-by: Alex Johnson --- utils/coins.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/coins.go b/utils/coins.go index 7ef2a1ba3..131bb82c7 100644 --- a/utils/coins.go +++ b/utils/coins.go @@ -18,13 +18,13 @@ func CoinFromRequestKey(query []byte, accAddr sdk.AccAddress) (sdk.Coin, error) func DenomFromRequestKey(query []byte, accAddr sdk.AccAddress) (string, error) { balancesStore := query[1:] - accAddr2, denom, err := banktypes.AddressAndDenomFromBalancesStore(balancesStore) + gotAccAddress, denom, err := banktypes.AddressAndDenomFromBalancesStore(balancesStore) if err != nil { return "", err } - if !accAddr2.Equals(accAddr) { - return "", fmt.Errorf("account mismatch; expected %s, got %s", accAddr.String(), accAddr2.String()) + if !gotAccAddress.Equals(accAddr) { + return "", fmt.Errorf("account mismatch; expected %s, got %s", accAddr.String(), gotAccAddress.String()) } return denom, nil From 6707f346195fd2cdaf50d75bc0a1c63e2eec29ce Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 12:59:30 +0000 Subject: [PATCH 08/10] chore: formatting --- cmd/quicksilverd/forceprune.go | 2 +- go.mod | 3 ++- go.sum | 1 + x/interchainstaking/types/delegation_test.go | 1 - x/interchainstaking/types/proposals_test.go | 3 ++- x/interchainstaking/types/validator_test.go | 3 ++- x/interchainstaking/types/zones_test.go | 1 - x/participationrewards/keeper/msg_server_test.go | 6 ++---- x/participationrewards/keeper/submodule_liquid.go | 1 + 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/quicksilverd/forceprune.go b/cmd/quicksilverd/forceprune.go index 80a9d4ac9..d8193a029 100644 --- a/cmd/quicksilverd/forceprune.go +++ b/cmd/quicksilverd/forceprune.go @@ -7,12 +7,12 @@ import ( "os/exec" "strconv" + tmdb "github.com/cometbft/cometbft-db" "github.com/spf13/cobra" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/util" tmstore "github.com/tendermint/tendermint/store" - tmdb "github.com/cometbft/cometbft-db" "github.com/cosmos/cosmos-sdk/client" "github.com/tendermint/tendermint/config" diff --git a/go.mod b/go.mod index a6091377d..a2bc739f1 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.19 require ( cosmossdk.io/math v1.0.0-beta.4 github.com/CosmWasm/wasmd v0.29.2 + github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-proto v1.0.0-alpha8 github.com/cosmos/cosmos-sdk v0.46.11 github.com/cosmos/ibc-go/v5 v5.2.0 @@ -33,7 +34,7 @@ require ( ) require ( - github.com/cometbft/cometbft-db v0.7.0 // indirect + github.com/client9/misspell v0.3.4 // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect diff --git a/go.sum b/go.sum index 3d0203f60..29e939fdf 100644 --- a/go.sum +++ b/go.sum @@ -382,6 +382,7 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn 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 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= diff --git a/x/interchainstaking/types/delegation_test.go b/x/interchainstaking/types/delegation_test.go index 10021643f..0e340f0bf 100644 --- a/x/interchainstaking/types/delegation_test.go +++ b/x/interchainstaking/types/delegation_test.go @@ -103,7 +103,6 @@ func TestNormalizeValidatorIntentsDeterminism(t *testing.T) { } }) } - } func TestDetermineAllocationsForDelegation(t *testing.T) { diff --git a/x/interchainstaking/types/proposals_test.go b/x/interchainstaking/types/proposals_test.go index 0b6eca921..59d8eecc2 100644 --- a/x/interchainstaking/types/proposals_test.go +++ b/x/interchainstaking/types/proposals_test.go @@ -1,10 +1,11 @@ package types_test import ( - "github.com/ingenuity-build/quicksilver/x/interchainstaking/types" "strings" "testing" + "github.com/ingenuity-build/quicksilver/x/interchainstaking/types" + "github.com/stretchr/testify/require" ) diff --git a/x/interchainstaking/types/validator_test.go b/x/interchainstaking/types/validator_test.go index e3c9e4faf..e00e03a20 100644 --- a/x/interchainstaking/types/validator_test.go +++ b/x/interchainstaking/types/validator_test.go @@ -1,10 +1,11 @@ package types_test import ( + "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "testing" "github.com/ingenuity-build/quicksilver/utils" "github.com/ingenuity-build/quicksilver/x/interchainstaking/types" diff --git a/x/interchainstaking/types/zones_test.go b/x/interchainstaking/types/zones_test.go index 818c4d2d4..ad7151be6 100644 --- a/x/interchainstaking/types/zones_test.go +++ b/x/interchainstaking/types/zones_test.go @@ -497,7 +497,6 @@ func TestUpdateIntentWithCoins(t *testing.T) { } } } - } func TestZone_GetBondedValidatorAddressesAsSlice(t *testing.T) { diff --git a/x/participationrewards/keeper/msg_server_test.go b/x/participationrewards/keeper/msg_server_test.go index c12e9edbd..0840f982e 100644 --- a/x/participationrewards/keeper/msg_server_test.go +++ b/x/participationrewards/keeper/msg_server_test.go @@ -10,13 +10,14 @@ import ( "github.com/tendermint/tendermint/proto/tendermint/crypto" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/ingenuity-build/quicksilver/app" osmolockup "github.com/ingenuity-build/quicksilver/osmosis-types/lockup" "github.com/ingenuity-build/quicksilver/utils" cmtypes "github.com/ingenuity-build/quicksilver/x/claimsmanager/types" "github.com/ingenuity-build/quicksilver/x/participationrewards/keeper" "github.com/ingenuity-build/quicksilver/x/participationrewards/types" - abci "github.com/tendermint/tendermint/abci/types" ) func (suite *KeeperTestSuite) Test_msgServer_SubmitClaim() { @@ -283,7 +284,6 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitLocalClaim() { "local_callback_nil", func(ctx sdk.Context, appA *app.Quicksilver) {}, func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { - address := utils.GenerateAccAddressForTest() key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("ibc/3020922B7576FC75BBE057A0290A9AEEFF489BB1113E6E365CE472D4BFB7FFA3")) @@ -323,7 +323,6 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitLocalClaim() { suite.Require().NoError(appA.BankKeeper.SendCoinsFromModuleToAccount(ctx, "mint", address, sdk.NewCoins(sdk.NewCoin("uqatom", sdk.NewInt(100))))) }, func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { - key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("uqatom")) query := abci.RequestQuery{ @@ -374,7 +373,6 @@ func (suite *KeeperTestSuite) Test_msgServer_SubmitLocalClaim() { appA.ParticipationRewardsKeeper.SetProtocolData(ctx, fmt.Sprintf("%s/uqatom", suite.chainA.ChainID), pd) }, func(ctx sdk.Context, appA *app.Quicksilver) *types.MsgSubmitClaim { - key := banktypes.CreatePrefixedAccountStoreKey(address, []byte("uqatom")) query := abci.RequestQuery{ diff --git a/x/participationrewards/keeper/submodule_liquid.go b/x/participationrewards/keeper/submodule_liquid.go index 494746277..cf13f34da 100644 --- a/x/participationrewards/keeper/submodule_liquid.go +++ b/x/participationrewards/keeper/submodule_liquid.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/ingenuity-build/quicksilver/utils" "github.com/ingenuity-build/quicksilver/x/participationrewards/types" ) From a0fc86f42c77b78e04299ab047008c45ea6789c4 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 13:45:14 +0000 Subject: [PATCH 09/10] remove unused CoinFromRequestKey method; add tests for DenomFromRequestKey; handle case where key is invalid and contains no denom --- utils/coins.go | 13 ++-- utils/coins_test.go | 74 ++++++++++++++++++++ x/interchainstaking/keeper/callbacks_test.go | 12 +--- 3 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 utils/coins_test.go diff --git a/utils/coins.go b/utils/coins.go index 131bb82c7..3e691309e 100644 --- a/utils/coins.go +++ b/utils/coins.go @@ -7,15 +7,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) -// coinFromRequestKey parses -func CoinFromRequestKey(query []byte, accAddr sdk.AccAddress) (sdk.Coin, error) { - denom, err := DenomFromRequestKey(query, accAddr) - if err != nil { - return sdk.Coin{}, err - } - return sdk.NewCoin(denom, sdk.ZeroInt()), nil -} - func DenomFromRequestKey(query []byte, accAddr sdk.AccAddress) (string, error) { balancesStore := query[1:] gotAccAddress, denom, err := banktypes.AddressAndDenomFromBalancesStore(balancesStore) @@ -23,6 +14,10 @@ func DenomFromRequestKey(query []byte, accAddr sdk.AccAddress) (string, error) { return "", err } + if len(denom) == 0 { + return "", fmt.Errorf("key contained no denom") + } + if !gotAccAddress.Equals(accAddr) { return "", fmt.Errorf("account mismatch; expected %s, got %s", accAddr.String(), gotAccAddress.String()) } diff --git a/utils/coins_test.go b/utils/coins_test.go new file mode 100644 index 000000000..e77f1bb22 --- /dev/null +++ b/utils/coins_test.go @@ -0,0 +1,74 @@ +package utils_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" + + utils "github.com/ingenuity-build/quicksilver/utils" +) + +func TestDenomFromRequestKey(t *testing.T) { + cases := []struct { + name string + fn func() (sdk.AccAddress, string, []byte) + err string + }{ + { + "valid", + func() (sdk.AccAddress, string, []byte) { + accAddr := utils.GenerateAccAddressForTest() + prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) + key := append(prefix, []byte("denom")...) + return accAddr, "denom", key + }, + "", + }, + { + "invalid - address mismatch", + func() (sdk.AccAddress, string, []byte) { + keyAddr, err := utils.AccAddressFromBech32("cosmos135rd8ft0dyq8fv3w3hhmaa55qu3pe668j99qh67mg747ew4ad03qsgq8vh", "cosmos") + require.NoError(t, err) + checkAddr, err := utils.AccAddressFromBech32("cosmos1ent5eg0xn3pskf3fhdw8mky88ry7t4kx628ru3pzp4nqjp6eufusphlldy", "cosmos") + require.NoError(t, err) + prefix := banktypes.CreateAccountBalancesPrefix(keyAddr.Bytes()) + key := append(prefix, []byte("denom")...) + return checkAddr, "denom", key + }, + "account mismatch; expected cosmos135rd8ft0dyq8fv3w3hhmaa55qu3pe668j99qh67mg747ew4ad03qsgq8vh, got cosmos1ent5eg0xn3pskf3fhdw8mky88ry7t4kx628ru3pzp4nqjp6eufusphlldy", + }, + { + "invalid - empty address", + func() (sdk.AccAddress, string, []byte) { + accAddr := sdk.AccAddress{} + prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) + key := append(prefix, []byte("denom")...) + return accAddr, "denom", key + }, + "invalid key", + }, + { + "invalid - empty denom", + func() (sdk.AccAddress, string, []byte) { + accAddr := utils.GenerateAccAddressForTest() + prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) + key := append(prefix, []byte("")...) + return accAddr, "", key + }, + "key contained no denom", + }, + } + + for _, c := range cases { + address, expectedDenom, key := c.fn() + actualDenom, error := utils.DenomFromRequestKey(key, address) + if len(c.err) == 0 { + require.NoError(t, error) + require.Equal(t, expectedDenom, actualDenom) + } else { + require.Errorf(t, error, c.err) + } + } +} diff --git a/x/interchainstaking/keeper/callbacks_test.go b/x/interchainstaking/keeper/callbacks_test.go index 7560a6c1d..77f31f288 100644 --- a/x/interchainstaking/keeper/callbacks_test.go +++ b/x/interchainstaking/keeper/callbacks_test.go @@ -23,16 +23,6 @@ import ( icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types" ) -func TestCoinFromRequestKey(t *testing.T) { - accAddr := utils.GenerateAccAddressForTest() - prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) - query := append(prefix, []byte("denom")...) - - coin, err := utils.CoinFromRequestKey(query, accAddr) - require.NoError(t, err) - require.Equal(t, "denom", coin.Denom) -} - // ValSetCallback func (s *KeeperTestSuite) TestHandleValsetCallback() { @@ -681,7 +671,7 @@ func (s *KeeperTestSuite) TestHandleValidatorCallbackJailedWithSlashing() { // s.Require().NoError(err) // expected := test.expected(zone.Validators) -// fmt.Println(app.InterchainstakingKeeper.GetAllDelegations(ctx, &zone)) +// 9(app.InterchainstakingKeeper.GetAllDelegations(ctx, &zone)) // _, found = app.InterchainstakingKeeper.GetDelegation(ctx, &zone, expected.DelegationAddress, expected.ValidatorAddress) // s.Require().True(found) // }) From be715a8eddb58dd3836e7f4037058a7728190611 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Fri, 10 Mar 2023 13:50:38 +0000 Subject: [PATCH 10/10] inadvertently changed comment --- x/interchainstaking/keeper/callbacks_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/interchainstaking/keeper/callbacks_test.go b/x/interchainstaking/keeper/callbacks_test.go index 77f31f288..92d8ef729 100644 --- a/x/interchainstaking/keeper/callbacks_test.go +++ b/x/interchainstaking/keeper/callbacks_test.go @@ -671,7 +671,7 @@ func (s *KeeperTestSuite) TestHandleValidatorCallbackJailedWithSlashing() { // s.Require().NoError(err) // expected := test.expected(zone.Validators) -// 9(app.InterchainstakingKeeper.GetAllDelegations(ctx, &zone)) +// fmt.Println(app.InterchainstakingKeeper.GetAllDelegations(ctx, &zone)) // _, found = app.InterchainstakingKeeper.GetDelegation(ctx, &zone, expected.DelegationAddress, expected.ValidatorAddress) // s.Require().True(found) // })