diff --git a/app/upgradev3x3/gov_legacy.pb.go b/app/upgradev3x3/gov_legacy.pb.go index d6fa92337e..52293c174e 100644 --- a/app/upgradev3x3/gov_legacy.pb.go +++ b/app/upgradev3x3/gov_legacy.pb.go @@ -29,8 +29,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // registry can be updated in the Umee capital facility. Note, the registry // defined in the proposal replaces the current registry in its entirety. type UpdateRegistryProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` Registry []types.Token `protobuf:"bytes,3,rep,name=registry,proto3" json:"registry"` } diff --git a/docs/design_docs/011-historacle-pricing.md b/docs/design_docs/011-historacle-pricing.md index ec025ac2b4..afc9d41a1d 100644 --- a/docs/design_docs/011-historacle-pricing.md +++ b/docs/design_docs/011-historacle-pricing.md @@ -63,12 +63,12 @@ We define two Maximum values, which correspond to the most we will store of a me Modules will have access to the following `keeper` functions from the `x/oracle` module: -- `HistoricMedian(denom) ([]sdk.Dec, error)` returns list median prices of an asset in the last `Pruning Period` -- `WithinHistoricDeviation(denom) (bool, error)` returns whether or not the current price of an asset is within the Standard Deviation around the Median. -- `MedianOfMedians(denom string, blockNum int) sdk.Dec` returns the Median of the all the Medians recorded within the past `blockNum`. TODO: what does it mean "within the past blockNum"? -- `AverageOfMedians(denom string, blockNum int) sdk.Dec` returns the Average of all the Medians recorded within the past `blockNum`. -- `MaxMedian(denom string, blockNum int) sdk.Dec` returns the Maximum of all the Medians recorded within the past `blockNum`. -- `MinMedian(denom string, blockNum int) sdk.Dec` returns the Minimum of all the Medians recorded within the past `blockNum`. +- `HistoricMedians(denom string, numStamps uint64) []sdk.Dec` returns list of last `numStamps` amount of median prices of an asset +- `WithinHistoricDeviation(denom string) (bool, error)` returns whether or not the current price of an asset is within the Standard Deviation around the Median. +- `MedianOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Median of the all the Medians recorded within the past `numStamps` of medians. +- `AverageOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Average of all the Medians recorded within the past `numStamps` of medians. +- `MaxOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Maximum of all the Medians recorded within the past `numStamps` of medians. +- `MinOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Minimum of all the Medians recorded within the past `numStamps` of medians. ### Outcomes diff --git a/price-feeder/go.mod b/price-feeder/go.mod index 96fd695cbf..838b1e75a0 100644 --- a/price-feeder/go.mod +++ b/price-feeder/go.mod @@ -25,13 +25,13 @@ require ( require ( 4d63.com/gochecknoglobals v0.1.0 // indirect - cloud.google.com/go v0.104.0 // 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.4.0 // indirect - cloud.google.com/go/storage v1.23.0 // 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 // indirect - cosmossdk.io/math v1.0.0-beta.3 // indirect + cosmossdk.io/math v1.0.0-beta.4 // indirect 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 @@ -74,7 +74,7 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect - github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect + github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogoproto v1.4.2 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect @@ -143,7 +143,6 @@ require ( 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/googleapis/go-type-adapters v1.0.0 // indirect github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect @@ -282,16 +281,16 @@ require ( golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect golang.org/x/mod v0.6.0 // indirect - golang.org/x/net v0.1.0 // indirect - golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect - golang.org/x/sys v0.1.0 // indirect - golang.org/x/term v0.1.0 // indirect + golang.org/x/net v0.2.0 // indirect + golang.org/x/oauth2 v0.2.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/term v0.2.0 // indirect golang.org/x/text v0.4.0 // indirect golang.org/x/tools v0.2.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.102.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect + google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -313,4 +312,5 @@ replace ( github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/osmosis-labs/bech32-ibc => github.com/umee-network/bech32-ibc v0.3.1 + github.com/umee-network/umee/v3 => ../ ) diff --git a/price-feeder/go.sum b/price-feeder/go.sum index 1f87304114..eb14b2cda3 100644 --- a/price-feeder/go.sum +++ b/price-feeder/go.sum @@ -21,22 +21,8 @@ cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHOb cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0 h1:gSmWO7DY1vOm0MVU6DNXM11BWHHsTUmsC5cv1fuW5X8= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= +cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= +cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -44,21 +30,15 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.12.1 h1:gKVJMEyqV5c/UnpzjjQbo3Rjvvqpr9B1DFSbJC4OXr0= cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= cloud.google.com/go/compute/metadata v0.2.1 h1:efOwf5ymceDhK6PKMnnrTHP4pppY5L22mle96M1yP48= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.4.0 h1:YBYU00SCDzZJdHqVc4I5d6lsklcYIjQZa1YmEz4jlSE= -cloud.google.com/go/iam v0.4.0/go.mod h1:cbaZxyScUhxl7ZAkNWiALgihfP75wS/fUsVNaa1r3vA= +cloud.google.com/go/iam v0.7.0 h1:k4MuwOsS7zGJJ+QfZ5vBK8SgHBAvYN/23BWsiihJ1vs= +cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= +cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -69,14 +49,13 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0 h1:wWRIaDURQA8xxHguFCshYepGlrWIrbBnAmc7wfg07qY= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= +cloud.google.com/go/storage v1.27.0 h1:YOO045NZI9RKfCj1c5A/ZtuuENUc8OAW+gHdGnDgyMQ= +cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= -cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= +cosmossdk.io/math v1.0.0-beta.4 h1:JtKedVLGzA0vv84xjYmZ75RKG35Kf2WwcFu8IjRkIIw= +cosmossdk.io/math v1.0.0-beta.4/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -257,12 +236,6 @@ github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3h github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -283,8 +256,8 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -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-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0= +github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -371,10 +344,6 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/esimonov/ifshort v1.0.4 h1:6SID4yGWfRae/M7hkVDVVyppy8q/v9OuxNdmjLQStBA= github.com/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= @@ -512,9 +481,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -531,7 +498,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -575,8 +541,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -590,7 +554,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -603,11 +566,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -615,21 +573,12 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/gax-go/v2 v2.6.0 h1:SXk3ABtQYDT/OH8jAyvEOQ58mgawq5C4o/4/89qN2ZU= github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/go-type-adapters v1.0.0 h1:9XdMn+d/G57qq1s8dNc5IesGCXHf6V2HZ2JwRxfA2tA= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 h1:PVRE9d4AQKmbelZ7emNig1+NT27DUmKZn5qXxfio54U= @@ -1278,8 +1227,6 @@ github.com/umee-network/bech32-ibc v0.3.1 h1:vn2+iXvHRcFLafbjyx9xf4DNqIa9I7ib30E github.com/umee-network/bech32-ibc v0.3.1/go.mod h1:5aoZoZsxSVBXxHfGGw6lfysJI+No9+aLFdHuE+Xo0EI= github.com/umee-network/cosmos-sdk v0.46.6-umee h1:8VkgbtpWfmsqfdJjd9nu+DH9GRwI8mPCpFhENDh/J7w= github.com/umee-network/cosmos-sdk v0.46.6-umee/go.mod h1:JNklMfXo7MhDF1j/jxZCmDyOYyqhVoKB22e8p1ATEqA= -github.com/umee-network/umee/v3 v3.2.0 h1:HMwSpJALLhGIn2zH7xzdT+hlcsiIdpB2ROPChe+vDpk= -github.com/umee-network/umee/v3 v3.2.0/go.mod h1:SKhY+pUPp/ozkicLz0z2+vfQdBySGJwB66zpar72fnE= 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/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= @@ -1325,7 +1272,6 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1402,7 +1348,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -1466,9 +1411,7 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1477,14 +1420,9 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx 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.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -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.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= 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= @@ -1494,19 +1432,10 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= +golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1518,7 +1447,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ 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.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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= @@ -1583,60 +1511,40 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/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.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 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.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= 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= @@ -1737,9 +1645,6 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= @@ -1752,9 +1657,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= @@ -1783,27 +1685,6 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= google.golang.org/api v0.102.0 h1:JxJl2qQ85fRMPNvlZY/enexbxpCjLwGhZUtgfGeQ51I= google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -1858,53 +1739,9 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e h1:S9GbmC1iCgvbLyAokVCwiO6tVIrU9Y7c5oMx1V/ki/Y= -google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= +google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 h1:jCw9YRd2s40X9Vxi4zKsPRvSPlHWNqadVkpbMsCPzPQ= +google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1929,23 +1766,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -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= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1958,8 +1780,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/proto/umee/oracle/v1/genesis.proto b/proto/umee/oracle/v1/genesis.proto index 4c38e270e7..b779fd5f0f 100644 --- a/proto/umee/oracle/v1/genesis.proto +++ b/proto/umee/oracle/v1/genesis.proto @@ -22,9 +22,9 @@ message GenesisState { [(gogoproto.nullable) = false]; repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6 [(gogoproto.nullable) = false]; - repeated HistoricPrice historic_prices = 8 [(gogoproto.nullable) = false]; - repeated ExchangeRateTuple medians = 7 [(gogoproto.nullable) = false]; - repeated ExchangeRateTuple medianDeviations = 9 [(gogoproto.nullable) = false]; + repeated Price historic_prices = 8 [(gogoproto.nullable) = false]; + repeated Price medians = 7 [(gogoproto.nullable) = false]; + repeated Price medianDeviations = 9 [(gogoproto.nullable) = false]; } // FeederDelegation is the address for where oracle feeder authority are @@ -42,8 +42,8 @@ message MissCounter { uint64 miss_counter = 2; } -// HistoricPrice is an instance of a price "stamp" -message HistoricPrice { +// Price is an instance of a price "stamp" +message Price { ExchangeRateTuple exchange_rate_tuple = 1 [ (gogoproto.nullable) = false ]; diff --git a/proto/umee/oracle/v1/oracle.proto b/proto/umee/oracle/v1/oracle.proto index af9f56114e..e5ba9da992 100644 --- a/proto/umee/oracle/v1/oracle.proto +++ b/proto/umee/oracle/v1/oracle.proto @@ -41,23 +41,19 @@ message Params { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // Stamp Period represents the amount of blocks the historacle module - // waits before recording a set of prices from the oracle. - uint64 stamp_period = 9; - // Prune Period represents the maximum amount of blocks which we want - // to keep a record of our set of exchange rates. - uint64 prune_period = 10; - // Median Period represents the amount blocks we will wait between - // calculating the median and standard deviation of the median of - // historic prices in the last Prune Period. - uint64 median_period = 11; - // Historic Asset List is a list of assets which will use the historic - // price stamping protection methodology (mainly manipulatable assets). - // Any assets not on this list will not be stamped. - repeated Denom historic_accept_list = 12 [ - (gogoproto.castrepeated) = "DenomList", - (gogoproto.nullable) = false - ]; + // Historic Stamp Period represents the amount of blocks the oracle + // module waits before recording a new historic price. + uint64 historic_stamp_period = 9; + // Median Stamp Period represents the amount blocks the oracle module + // waits between calculating and stamping a new median and standard + // deviation of that median. + uint64 median_stamp_period = 10; + // Maximum Price Stamps represents the maximum amount of historic prices + // the oracle module will store before pruning via FIFO. + uint64 maximum_price_stamps = 11; + // Maximum Median Stamps represents the maximum amount of medians the + // oracle module will store before pruning via FIFO. + uint64 maximum_median_stamps = 12; } // Denom - the object to hold configurations of each denom diff --git a/util/bytes.go b/util/bytes.go index c2fe55a88e..f4ae18dc24 100644 --- a/util/bytes.go +++ b/util/bytes.go @@ -1,5 +1,9 @@ package util +import ( + "encoding/binary" +) + // ConcatBytes creates a new slice by merging list of bytes and leaving empty amount of margin // bytes at the end func ConcatBytes(margin int, bzs ...[]byte) []byte { @@ -15,3 +19,9 @@ func ConcatBytes(margin int, bzs ...[]byte) []byte { } return out } + +func UintWithNullPrefix(n uint64) []byte { + bz := make([]byte, 9) + binary.LittleEndian.PutUint64(bz[1:], n) + return bz +} diff --git a/util/bytes_test.go b/util/bytes_test.go index ab72668e7c..c3d4eeb873 100644 --- a/util/bytes_test.go +++ b/util/bytes_test.go @@ -1,7 +1,12 @@ package util -import "testing" -import "github.com/stretchr/testify/require" +import ( + "encoding/binary" + "math" + "testing" + + "github.com/stretchr/testify/require" +) func TestMergeBytes(t *testing.T) { require := require.New(t) @@ -22,3 +27,13 @@ func TestMergeBytes(t *testing.T) { require.Equal(tc.out, ConcatBytes(tc.inMargin, tc.in...), i) } } + +func TestUintWithNullPrefix(t *testing.T) { + expected := []byte{0} + num := make([]byte, 8) + binary.LittleEndian.PutUint64(num, math.MaxUint64) + expected = append(expected, num...) + + out := UintWithNullPrefix(math.MaxUint64) + require.Equal(t, expected, out) +} diff --git a/util/decmath/decmath.go b/util/decmath/decmath.go new file mode 100644 index 0000000000..b464a52739 --- /dev/null +++ b/util/decmath/decmath.go @@ -0,0 +1,98 @@ +package decmath + +import ( + "fmt" + "sort" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + ErrEmptyList = fmt.Errorf("empty price list passed in") +) + +// Median returns the median of a list of sdk.Dec. Returns error +// if ds is empty list. +func Median(ds []sdk.Dec) (sdk.Dec, error) { + if len(ds) == 0 { + return sdk.ZeroDec(), ErrEmptyList + } + + sort.Slice(ds, func(i, j int) bool { + return ds[i].BigInt(). + Cmp(ds[j].BigInt()) < 0 + }) + + if len(ds)%2 == 0 { + return ds[len(ds)/2-1]. + Add(ds[len(ds)/2]). + QuoInt64(2), nil + } + return ds[len(ds)/2], nil +} + +// MedianDeviation returns the standard deviation around the +// median of a list of sdk.Dec. Returns error if ds is empty list. +// MedianDeviation = ∑((d - median)^2 / len(ds)) +func MedianDeviation(median sdk.Dec, ds []sdk.Dec) (sdk.Dec, error) { + medianDeviation := sdk.ZeroDec() + if len(ds) == 0 { + return medianDeviation, ErrEmptyList + } + + for _, d := range ds { + medianDeviation = medianDeviation.Add( + d.Sub(median).Abs().Power(2).QuoInt64(int64(len(ds)))) + } + + return medianDeviation, nil +} + +// Average returns the average value of a list of sdk.Dec. Returns error +// if ds is empty list. +func Average(ds []sdk.Dec) (sdk.Dec, error) { + if len(ds) == 0 { + return sdk.ZeroDec(), ErrEmptyList + } + + sumPrices := sdk.ZeroDec() + for _, d := range ds { + sumPrices = sumPrices.Add(d) + } + + return sumPrices.QuoInt64(int64(len(ds))), nil +} + +// Max returns the max value of a list of sdk.Dec. Returns error +// if ds is empty list. +func Max(ds []sdk.Dec) (sdk.Dec, error) { + if len(ds) == 0 { + return sdk.ZeroDec(), ErrEmptyList + } + + max := ds[0] + for _, d := range ds[1:] { + if d.GT(max) { + max = d + } + } + + return max, nil +} + +// Min returns the min value of a list of sdk.Dec. Returns error +// if ds is empty list. +func Min(ds []sdk.Dec) (sdk.Dec, error) { + if len(ds) == 0 { + return sdk.ZeroDec(), ErrEmptyList + } + + min := ds[0] + for _, d := range ds[1:] { + if d.LT(min) { + min = d + } + } + + return min, nil +} diff --git a/util/decmath/decmath_test.go b/util/decmath/decmath_test.go new file mode 100644 index 0000000000..c52dc3b725 --- /dev/null +++ b/util/decmath/decmath_test.go @@ -0,0 +1,99 @@ +package decmath + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestMedian(t *testing.T) { + require := require.New(t) + prices := []sdk.Dec{ + sdk.MustNewDecFromStr("1.12"), + sdk.MustNewDecFromStr("1.07"), + sdk.MustNewDecFromStr("1.11"), + sdk.MustNewDecFromStr("1.2"), + } + + median, err := Median(prices) + require.NoError(err) + require.Equal(sdk.MustNewDecFromStr("1.115"), median) + + // test empty prices list + median, err = Median([]sdk.Dec{}) + require.ErrorIs(err, ErrEmptyList) +} + +func TestMedianDeviation(t *testing.T) { + require := require.New(t) + prices := []sdk.Dec{ + sdk.MustNewDecFromStr("1.12"), + sdk.MustNewDecFromStr("1.07"), + sdk.MustNewDecFromStr("1.11"), + sdk.MustNewDecFromStr("1.2"), + } + median := sdk.MustNewDecFromStr("1.115") + + medianDeviation, err := MedianDeviation(median, prices) + require.NoError(err) + require.Equal(sdk.MustNewDecFromStr("0.002325"), medianDeviation) + + // test empty prices list + medianDeviation, err = MedianDeviation(median, []sdk.Dec{}) + require.ErrorIs(err, ErrEmptyList) +} + +func TestAverage(t *testing.T) { + require := require.New(t) + prices := []sdk.Dec{ + sdk.MustNewDecFromStr("1.12"), + sdk.MustNewDecFromStr("1.07"), + sdk.MustNewDecFromStr("1.11"), + sdk.MustNewDecFromStr("1.2"), + } + + average, err := Average(prices) + require.NoError(err) + require.Equal(sdk.MustNewDecFromStr("1.125"), average) + + // test empty prices list + average, err = Average([]sdk.Dec{}) + require.ErrorIs(err, ErrEmptyList) +} + +func TestMin(t *testing.T) { + require := require.New(t) + prices := []sdk.Dec{ + sdk.MustNewDecFromStr("1.12"), + sdk.MustNewDecFromStr("1.07"), + sdk.MustNewDecFromStr("1.11"), + sdk.MustNewDecFromStr("1.2"), + } + + min, err := Min(prices) + require.NoError(err) + require.Equal(sdk.MustNewDecFromStr("1.07"), min) + + // test empty prices list + min, err = Min([]sdk.Dec{}) + require.ErrorIs(err, ErrEmptyList) +} + +func TestMax(t *testing.T) { + require := require.New(t) + prices := []sdk.Dec{ + sdk.MustNewDecFromStr("1.12"), + sdk.MustNewDecFromStr("1.07"), + sdk.MustNewDecFromStr("1.11"), + sdk.MustNewDecFromStr("1.2"), + } + + max, err := Max(prices) + require.NoError(err) + require.Equal(sdk.MustNewDecFromStr("1.2"), max) + + // test empty prices list + max, err = Max([]sdk.Dec{}) + require.ErrorIs(err, ErrEmptyList) +} diff --git a/x/oracle/abci.go b/x/oracle/abci.go index f358b91606..37f83ae267 100644 --- a/x/oracle/abci.go +++ b/x/oracle/abci.go @@ -41,11 +41,6 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper, experimental bool) error { k.ClearExchangeRates(ctx) - if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { - k.ClearMedians(ctx) - k.ClearMedianDeviations(ctx) - } - // NOTE: it filters out inactive or jailed validators ballotDenomSlice := k.OrganizeBallotByDenom(ctx, validatorClaimMap) @@ -63,14 +58,15 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper, experimental bool) error { } if experimental { - // Stamp rate every stamp period if asset is set to have historic stats tracked - if isPeriodLastBlock(ctx, params.StampPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { + if isPeriodLastBlock(ctx, params.HistoricStampPeriod) { k.AddHistoricPrice(ctx, ballotDenom.Denom, exchangeRate) } - // Set median price every median period if asset is set to have historic stats tracked - if isPeriodLastBlock(ctx, params.MedianPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { - k.CalcAndSetMedian(ctx, ballotDenom.Denom) + // Calculate and stamp median/median deviation if median stamp period has passed + if isPeriodLastBlock(ctx, params.MedianStampPeriod) { + if err = k.CalcAndSetHistoricMedian(ctx, ballotDenom.Denom); err != nil { + return err + } } } } @@ -108,11 +104,15 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper, experimental bool) error { k.SlashAndResetMissCounters(ctx) } - // Prune historic prices every prune period - if isPeriodLastBlock(ctx, params.PrunePeriod) && experimental { - pruneBlock := uint64(ctx.BlockHeight()) - params.PrunePeriod - for _, v := range params.HistoricAcceptList { - k.DeleteHistoricPrice(ctx, v.String(), pruneBlock) + // Prune historic prices and medians outside pruning period determined by + // the stamp period multiplied by the max stamps. + if experimental && isPeriodLastBlock(ctx, params.HistoricStampPeriod) { + pruneHistoricPeriod := params.HistoricStampPeriod*(params.MaximumPriceStamps) - params.VotePeriod + pruneMedianPeriod := params.MedianStampPeriod*(params.MaximumMedianStamps) - params.VotePeriod + for _, v := range params.AcceptList { + k.DeleteHistoricPrice(ctx, v.SymbolDenom, uint64(ctx.BlockHeight())-pruneHistoricPeriod) + k.DeleteHistoricMedian(ctx, v.SymbolDenom, uint64(ctx.BlockHeight())-pruneMedianPeriod) + k.DeleteHistoricMedianDeviation(ctx, v.SymbolDenom, uint64(ctx.BlockHeight())-pruneMedianPeriod) } } diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go index cc2c7f4992..35de769e50 100644 --- a/x/oracle/abci_test.go +++ b/x/oracle/abci_test.go @@ -42,7 +42,6 @@ func (s *IntegrationTestSuite) SetupTest() { app := umeeapp.Setup(s.T()) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{ ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), - Height: int64(types.DefaultMedianPeriod) - 1, }) oracle.InitGenesis(ctx, app.OracleKeeper, *types.DefaultGenesisState()) @@ -89,19 +88,33 @@ func (s *IntegrationTestSuite) TestEndblockerExperimentalFlag() { // add historic price and calcSet median stats app.OracleKeeper.AddHistoricPrice(s.ctx, displayDenom, sdk.MustNewDecFromStr("1.0")) - app.OracleKeeper.CalcAndSetMedian(s.ctx, displayDenom) + app.OracleKeeper.CalcAndSetHistoricMedian(s.ctx, displayDenom) + medianPruneBlock := ctx.BlockHeight() + int64(types.DefaultMaximumMedianStamps*types.DefaultMedianStampPeriod) + ctx = ctx.WithBlockHeight(medianPruneBlock) - // with experimental flag off median stats don't get cleared + // with experimental flag off median doesn't get deleted oracle.EndBlocker(ctx, app.OracleKeeper, false) - median, err := app.OracleKeeper.GetMedian(s.ctx, displayDenom) - s.Require().NoError(err) - s.Require().Equal(sdk.MustNewDecFromStr("1.0"), median) - - // with experimental flag on median stats get cleared + medians := []types.Price{} + app.OracleKeeper.IterateAllMedianPrices( + ctx, + func(median types.Price) bool { + medians = append(medians, median) + return false + }, + ) + s.Require().Equal(1, len(medians)) + + // with experimental flag on median gets deleted oracle.EndBlocker(ctx, app.OracleKeeper, true) - median, err = app.OracleKeeper.GetMedian(s.ctx, displayDenom) - s.Require().Error(err) - s.Require().Equal(sdk.ZeroDec(), median) + experimentalMedians := []types.Price{} + app.OracleKeeper.IterateAllMedianPrices( + ctx, + func(median types.Price) bool { + medians = append(experimentalMedians, median) + return false + }, + ) + s.Require().Equal(0, len(experimentalMedians)) } func TestOracleTestSuite(t *testing.T) { diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go index af2f3519bf..f8c0a81ba2 100644 --- a/x/oracle/genesis.go +++ b/x/oracle/genesis.go @@ -62,11 +62,16 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, genState types.GenesisSt } for _, median := range genState.Medians { - keeper.SetMedian(ctx, median.Denom, median.ExchangeRate) + keeper.SetHistoricMedian(ctx, median.ExchangeRateTuple.Denom, median.BlockNum, median.ExchangeRateTuple.ExchangeRate) } for _, medianDeviation := range genState.MedianDeviations { - keeper.SetMedianDeviation(ctx, medianDeviation.Denom, medianDeviation.ExchangeRate) + keeper.SetHistoricMedianDeviation( + ctx, + medianDeviation.ExchangeRateTuple.Denom, + medianDeviation.BlockNum, + medianDeviation.ExchangeRateTuple.ExchangeRate, + ) } keeper.SetParams(ctx, genState.Params) @@ -130,28 +135,28 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { }, ) - historicPrices := []types.HistoricPrice{} + historicPrices := []types.Price{} keeper.IterateAllHistoricPrices( ctx, - func(historicPrice types.HistoricPrice) bool { + func(historicPrice types.Price) bool { historicPrices = append(historicPrices, historicPrice) return false }, ) - medianPrices := []types.ExchangeRateTuple{} + medianPrices := []types.Price{} keeper.IterateAllMedianPrices( ctx, - func(medianPrice types.ExchangeRateTuple) bool { + func(medianPrice types.Price) bool { medianPrices = append(medianPrices, medianPrice) return false }, ) - medianDeviationPrices := []types.ExchangeRateTuple{} + medianDeviationPrices := []types.Price{} keeper.IterateAllMedianDeviationPrices( ctx, - func(medianDeviationPrice types.ExchangeRateTuple) bool { + func(medianDeviationPrice types.Price) bool { medianDeviationPrices = append(medianDeviationPrices, medianDeviationPrice) return false }, diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 1544c234b7..6c92219e2b 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -9,7 +9,7 @@ import ( // Iterator stops when exhausting the source, or when the handler returns `true`. func (k Keeper) IterateAllHistoricPrices( ctx sdk.Context, - handler func(types.HistoricPrice) bool, + handler func(types.Price) bool, ) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixHistoricPrice) @@ -18,9 +18,8 @@ func (k Keeper) IterateAllHistoricPrices( for ; iter.Valid(); iter.Next() { var decProto sdk.DecProto k.cdc.MustUnmarshal(iter.Value(), &decProto) - denom := types.ParseDenomFromHistoricPriceKey(iter.Key()) - blockNum := types.ParseBlockFromHistoricPriceKey(iter.Key()) - historicPrice := types.HistoricPrice{ + denom, blockNum := types.ParseDenomAndBlockFromKey(iter.Key(), types.KeyPrefixHistoricPrice) + historicPrice := types.Price{ ExchangeRateTuple: types.ExchangeRateTuple{ExchangeRate: decProto.Dec, Denom: denom}, BlockNum: blockNum, } @@ -34,7 +33,7 @@ func (k Keeper) IterateAllHistoricPrices( // Iterator stops when exhausting the source, or when the handler returns `true`. func (k Keeper) IterateAllMedianPrices( ctx sdk.Context, - handler func(types.ExchangeRateTuple) bool, + handler func(types.Price) bool, ) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixMedian) @@ -43,8 +42,11 @@ func (k Keeper) IterateAllMedianPrices( for ; iter.Valid(); iter.Next() { var decProto sdk.DecProto k.cdc.MustUnmarshal(iter.Value(), &decProto) - denom := types.ParseDenomFromMedianKey(iter.Key()) - median := types.ExchangeRateTuple{ExchangeRate: decProto.Dec, Denom: denom} + denom, blockNum := types.ParseDenomAndBlockFromKey(iter.Key(), types.KeyPrefixMedian) + median := types.Price{ + ExchangeRateTuple: types.ExchangeRateTuple{ExchangeRate: decProto.Dec, Denom: denom}, + BlockNum: blockNum, + } if handler(median) { break @@ -56,7 +58,7 @@ func (k Keeper) IterateAllMedianPrices( // Iterator stops when exhausting the source, or when the handler returns `true`. func (k Keeper) IterateAllMedianDeviationPrices( ctx sdk.Context, - handler func(types.ExchangeRateTuple) bool, + handler func(types.Price) bool, ) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixMedianDeviation) @@ -65,8 +67,12 @@ func (k Keeper) IterateAllMedianDeviationPrices( for ; iter.Valid(); iter.Next() { var decProto sdk.DecProto k.cdc.MustUnmarshal(iter.Value(), &decProto) - denom := types.ParseDenomFromMedianKey(iter.Key()) - medianDeviation := types.ExchangeRateTuple{ExchangeRate: decProto.Dec, Denom: denom} + denom, blockNum := types.ParseDenomAndBlockFromKey(iter.Key(), types.KeyPrefixMedianDeviation) + medianDeviation := types.Price{ + ExchangeRateTuple: types.ExchangeRateTuple{ExchangeRate: decProto.Dec, Denom: denom}, + BlockNum: blockNum, + } + if handler(medianDeviation) { break } diff --git a/x/oracle/keeper/genesis_test.go b/x/oracle/keeper/genesis_test.go index bee41dc51e..a4e019a0cb 100644 --- a/x/oracle/keeper/genesis_test.go +++ b/x/oracle/keeper/genesis_test.go @@ -9,7 +9,7 @@ import ( func (s *IntegrationTestSuite) TestIterateAllHistoricPrices() { keeper, ctx := s.app.OracleKeeper, s.ctx - historicPrices := []types.HistoricPrice{ + historicPrices := []types.Price{ {BlockNum: 10, ExchangeRateTuple: types.ExchangeRateTuple{ Denom: "umee", ExchangeRate: sdk.MustNewDecFromStr("20.45"), }}, @@ -28,10 +28,10 @@ func (s *IntegrationTestSuite) TestIterateAllHistoricPrices() { keeper.SetHistoricPrice(ctx, hp.ExchangeRateTuple.Denom, hp.BlockNum, hp.ExchangeRateTuple.ExchangeRate) } - newPrices := []types.HistoricPrice{} + newPrices := []types.Price{} keeper.IterateAllHistoricPrices( ctx, - func(historicPrice types.HistoricPrice) bool { + func(historicPrice types.Price) bool { newPrices = append(newPrices, historicPrice) return false }, @@ -62,13 +62,13 @@ func (s *IntegrationTestSuite) TestIterateAllMedianPrices() { } for _, m := range medians { - keeper.SetMedian(ctx, m.Denom, m.ExchangeRate) + keeper.SetHistoricMedian(ctx, m.Denom, uint64(s.ctx.BlockHeight()), m.ExchangeRate) } - newMedians := []types.ExchangeRateTuple{} + newMedians := []types.Price{} keeper.IterateAllMedianPrices( ctx, - func(median types.ExchangeRateTuple) bool { + func(median types.Price) bool { newMedians = append(newMedians, median) return false }, @@ -78,8 +78,8 @@ func (s *IntegrationTestSuite) TestIterateAllMedianPrices() { FOUND: for _, oldMedian := range medians { for _, newMedian := range newMedians { - if oldMedian.Denom == newMedian.Denom { - s.Require().Equal(oldMedian.ExchangeRate, newMedian.ExchangeRate) + if oldMedian.Denom == newMedian.ExchangeRateTuple.Denom { + s.Require().Equal(oldMedian.ExchangeRate, newMedian.ExchangeRateTuple.ExchangeRate) continue FOUND } } @@ -96,13 +96,13 @@ func (s *IntegrationTestSuite) TestIterateAllMedianDeviationPrices() { } for _, m := range medians { - keeper.SetMedianDeviation(ctx, m.Denom, m.ExchangeRate) + keeper.SetHistoricMedianDeviation(ctx, m.Denom, uint64(s.ctx.BlockHeight()), m.ExchangeRate) } - newMedians := []types.ExchangeRateTuple{} + newMedians := []types.Price{} keeper.IterateAllMedianDeviationPrices( ctx, - func(median types.ExchangeRateTuple) bool { + func(median types.Price) bool { newMedians = append(newMedians, median) return false }, @@ -112,8 +112,8 @@ func (s *IntegrationTestSuite) TestIterateAllMedianDeviationPrices() { FOUND: for _, oldMedian := range medians { for _, newMedian := range newMedians { - if oldMedian.Denom == newMedian.Denom { - s.Require().Equal(oldMedian.ExchangeRate, newMedian.ExchangeRate) + if oldMedian.Denom == newMedian.ExchangeRateTuple.Denom { + s.Require().Equal(oldMedian.ExchangeRate, newMedian.ExchangeRateTuple.ExchangeRate) continue FOUND } } diff --git a/x/oracle/keeper/grpc_query.go b/x/oracle/keeper/grpc_query.go index 876323805a..0292e3c6d3 100644 --- a/x/oracle/keeper/grpc_query.go +++ b/x/oracle/keeper/grpc_query.go @@ -265,15 +265,16 @@ func (q querier) Medians( var medians sdk.DecCoins if len(req.Denom) > 0 { - exchangeRate, err := q.GetMedian(ctx, req.Denom) - if err != nil { - return nil, err - } + // TODO: Add numStamps param to request to enable responding with a variable amount + // of last medians rather than just returning the most recent stamp + medianList := q.HistoricMedians(ctx, req.Denom, 1) - medians = medians.Add(sdk.NewDecCoinFromDec(req.Denom, exchangeRate)) + if len(medianList) != 0 { + medians = medians.Add(sdk.NewDecCoinFromDec(req.Denom, medianList[0])) + } } else { - q.IterateAllMedianPrices(ctx, func(exchangeRateTuple types.ExchangeRateTuple) (stop bool) { - medians = medians.Add(sdk.NewDecCoinFromDec(exchangeRateTuple.Denom, exchangeRateTuple.ExchangeRate)) + q.IterateAllMedianPrices(ctx, func(median types.Price) (stop bool) { + medians = medians.Add(sdk.NewDecCoinFromDec(median.ExchangeRateTuple.Denom, median.ExchangeRateTuple.ExchangeRate)) return false }) } @@ -296,15 +297,18 @@ func (q querier) MedianDeviations( var medians sdk.DecCoins if len(req.Denom) > 0 { - exchangeRate, err := q.GetMedianDeviation(ctx, req.Denom) + exchangeRate, err := q.HistoricMedianDeviation(ctx, req.Denom) if err != nil { return nil, err } medians = medians.Add(sdk.NewDecCoinFromDec(req.Denom, exchangeRate)) } else { - q.IterateAllMedianDeviationPrices(ctx, func(exchangeRateTuple types.ExchangeRateTuple) (stop bool) { - medians = medians.Add(sdk.NewDecCoinFromDec(exchangeRateTuple.Denom, exchangeRateTuple.ExchangeRate)) + q.IterateAllMedianDeviationPrices(ctx, func(medianDeviation types.Price) (stop bool) { + medians = medians.Add(sdk.NewDecCoinFromDec( + medianDeviation.ExchangeRateTuple.Denom, + medianDeviation.ExchangeRateTuple.ExchangeRate, + )) return false }) } diff --git a/x/oracle/keeper/grpc_query_test.go b/x/oracle/keeper/grpc_query_test.go index 50d86f081a..38f51feb02 100644 --- a/x/oracle/keeper/grpc_query_test.go +++ b/x/oracle/keeper/grpc_query_test.go @@ -203,33 +203,39 @@ func (s *IntegrationTestSuite) TestQuerier_AggregateVotesAppendVotes() { } func (s *IntegrationTestSuite) TestQuerier_Medians() { + app, ctx := s.app, s.ctx + atomMedian := sdk.DecCoin{Denom: "atom", Amount: sdk.MustNewDecFromStr("49.99")} umeeMedian := sdk.DecCoin{Denom: "umee", Amount: sdk.MustNewDecFromStr("6541.48")} - s.app.OracleKeeper.SetMedian(s.ctx, atomMedian.Denom, atomMedian.Amount) - s.app.OracleKeeper.SetMedian(s.ctx, umeeMedian.Denom, umeeMedian.Amount) + app.OracleKeeper.SetMedianStampPeriod(ctx, 1) + app.OracleKeeper.SetHistoricMedian(ctx, atomMedian.Denom, uint64(ctx.BlockHeight()-1), atomMedian.Amount) + app.OracleKeeper.SetHistoricMedian(ctx, umeeMedian.Denom, uint64(ctx.BlockHeight()-1), umeeMedian.Amount) - res, err := s.queryClient.Medians(s.ctx.Context(), &types.QueryMedians{}) + res, err := s.queryClient.Medians(ctx.Context(), &types.QueryMedians{}) s.Require().NoError(err) s.Require().Equal(res.Medians, sdk.NewDecCoins(atomMedian, umeeMedian)) - res, err = s.queryClient.Medians(s.ctx.Context(), &types.QueryMedians{Denom: atomMedian.Denom}) + res, err = s.queryClient.Medians(ctx.Context(), &types.QueryMedians{Denom: atomMedian.Denom}) s.Require().NoError(err) s.Require().Equal(res.Medians, sdk.NewDecCoins(atomMedian)) } func (s *IntegrationTestSuite) TestQuerier_MedianDeviations() { + app, ctx := s.app, s.ctx + atomMedianDeviation := sdk.DecCoin{Denom: "atom", Amount: sdk.MustNewDecFromStr("39.99")} umeeMedianDeviation := sdk.DecCoin{Denom: "umee", Amount: sdk.MustNewDecFromStr("9541.48")} - s.app.OracleKeeper.SetMedianDeviation(s.ctx, atomMedianDeviation.Denom, atomMedianDeviation.Amount) - s.app.OracleKeeper.SetMedianDeviation(s.ctx, umeeMedianDeviation.Denom, umeeMedianDeviation.Amount) + app.OracleKeeper.SetMedianStampPeriod(ctx, 1) + app.OracleKeeper.SetHistoricMedianDeviation(ctx, atomMedianDeviation.Denom, uint64(ctx.BlockHeight()-1), atomMedianDeviation.Amount) + app.OracleKeeper.SetHistoricMedianDeviation(ctx, umeeMedianDeviation.Denom, uint64(ctx.BlockHeight()-1), umeeMedianDeviation.Amount) - res, err := s.queryClient.MedianDeviations(s.ctx.Context(), &types.QueryMedianDeviations{}) + res, err := s.queryClient.MedianDeviations(ctx.Context(), &types.QueryMedianDeviations{}) s.Require().NoError(err) s.Require().Equal(res.MedianDeviations, sdk.NewDecCoins(atomMedianDeviation, umeeMedianDeviation)) - res, err = s.queryClient.MedianDeviations(s.ctx.Context(), &types.QueryMedianDeviations{Denom: atomMedianDeviation.Denom}) + res, err = s.queryClient.MedianDeviations(ctx.Context(), &types.QueryMedianDeviations{Denom: atomMedianDeviation.Denom}) s.Require().NoError(err) s.Require().Equal(res.MedianDeviations, sdk.NewDecCoins(atomMedianDeviation)) } diff --git a/x/oracle/keeper/historic_price.go b/x/oracle/keeper/historic_price.go index 70da90ebb0..95ba3e7976 100644 --- a/x/oracle/keeper/historic_price.go +++ b/x/oracle/keeper/historic_price.go @@ -2,100 +2,69 @@ package keeper import ( "fmt" - "sort" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/umee-network/umee/v3/util" + "github.com/umee-network/umee/v3/util/decmath" "github.com/umee-network/umee/v3/x/oracle/types" ) -// median returns the median of a list of historic prices. -func median(prices []sdk.Dec) sdk.Dec { - lenPrices := len(prices) - if lenPrices == 0 { - return sdk.ZeroDec() - } +// HistoricMedians returns a list of a given denom's last numStamps medians. +func (k Keeper) HistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint64, +) []sdk.Dec { + medians := []sdk.Dec{} - sort.Slice(prices, func(i, j int) bool { - return prices[i].BigInt(). - Cmp(prices[j].BigInt()) > 0 + k.IterateHistoricMedians(ctx, denom, uint(numStamps), func(median sdk.Dec) bool { + medians = append(medians, median) + return false }) - if lenPrices%2 == 0 { - return prices[lenPrices/2-1]. - Add(prices[lenPrices/2]). - QuoInt64(2) - } - return prices[lenPrices/2] -} - -// medianDeviation returns the standard deviation around the -// median of a list of prices. -// medianDeviation = ∑((price - median)^2 / len(prices)) -func medianDeviation(median sdk.Dec, prices []sdk.Dec) sdk.Dec { - lenPrices := len(prices) - medianDeviation := sdk.ZeroDec() - - for _, price := range prices { - medianDeviation = medianDeviation.Add(price. - Sub(median).Abs().Power(2). - QuoInt64(int64(lenPrices))) - } - - return medianDeviation + return medians } -// GetMedian returns a given denom's median price in the last prune -// period since a given block. -func (k Keeper) GetMedian( +// CalcAndSetHistoricMedian uses all the historic prices of a given denom to +// calculate its median price at the current block and set it to the store. +// It will also call setMedianDeviation with the calculated median. +func (k Keeper) CalcAndSetHistoricMedian( ctx sdk.Context, denom string, -) (sdk.Dec, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyMedian(denom)) - if bz == nil { - return sdk.ZeroDec(), sdkerrors.Wrap(types.ErrNoMedian, fmt.Sprintf("denom: %s", denom)) +) error { + historicPrices := k.historicPrices(ctx, denom, k.MaximumPriceStamps(ctx)) + median, err := decmath.Median(historicPrices) + if err != nil { + return sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) } - median := sdk.DecProto{} - k.cdc.MustUnmarshal(bz, &median) - return median.Dec, nil -} - -// SetMedian uses all the historic prices of a given denom to calculate -// its median price in the last prune period since the current block and -// set it to the store. It will also call setMedianDeviation with the -// calculated median. -func (k Keeper) CalcAndSetMedian( - ctx sdk.Context, - denom string, -) { - historicPrices := k.getHistoricPrices(ctx, denom) - median := median(historicPrices) - k.SetMedian(ctx, denom, median) - k.calcAndSetMedianDeviation(ctx, denom, median, historicPrices) + block := uint64(ctx.BlockHeight()) + k.SetHistoricMedian(ctx, denom, block, median) + return k.calcAndSetHistoricMedianDeviation(ctx, denom, median, historicPrices) } -func (k Keeper) SetMedian( +func (k Keeper) SetHistoricMedian( ctx sdk.Context, denom string, + blockNum uint64, median sdk.Dec, ) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&sdk.DecProto{Dec: median}) - store.Set(types.KeyMedian(denom), bz) + store.Set(types.KeyMedian(denom, blockNum), bz) } -// GetMedianDeviation returns a given denom's standard deviation around -// its median price in the last prune period since a given block. -func (k Keeper) GetMedianDeviation( +// HistoricMedianDeviation returns a given denom's most recently stamped +// standard deviation around its median price at a given block. +func (k Keeper) HistoricMedianDeviation( ctx sdk.Context, denom string, ) (sdk.Dec, error) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyMedianDeviation(denom)) + blockDiff := uint64(ctx.BlockHeight())%k.MedianStampPeriod(ctx) + 1 + bz := store.Get(types.KeyMedianDeviation(denom, uint64(ctx.BlockHeight())-blockDiff)) if bz == nil { return sdk.ZeroDec(), sdkerrors.Wrap(types.ErrNoMedianDeviation, fmt.Sprintf("denom: %s", denom)) } @@ -106,19 +75,28 @@ func (k Keeper) GetMedianDeviation( return decProto.Dec, nil } -// WithinMedianDeviation returns whether or not a given price of a given -// denom is within the Standard Deviation around the Median. -func (k Keeper) WithinMedianDeviation( +// WithinHistoricMedianDeviation returns whether or not the current price of a +// given denom is within the latest stamped Standard Deviation around +// the Median. +func (k Keeper) WithinHistoricMedianDeviation( ctx sdk.Context, denom string, - price sdk.Dec, ) (bool, error) { - median, err := k.GetMedian(ctx, denom) - if err != nil { - return false, err + // get latest median + medians := k.HistoricMedians(ctx, denom, 1) + if len(medians) == 0 { + return false, sdkerrors.Wrap(types.ErrNoMedian, fmt.Sprintf("denom: %s", denom)) + } + median := medians[0] + + // get latest historic price + prices := k.historicPrices(ctx, denom, 1) + if len(prices) == 0 { + return false, sdkerrors.Wrap(types.ErrNoHistoricPrice, fmt.Sprintf("denom: %s", denom)) } + price := prices[0] - medianDeviation, err := k.GetMedianDeviation(ctx, denom) + medianDeviation, err := k.HistoricMedianDeviation(ctx, denom) if err != nil { return false, err } @@ -126,36 +104,105 @@ func (k Keeper) WithinMedianDeviation( return price.Sub(median).Abs().LTE(medianDeviation), nil } -// setMedianDeviation sets a given denom's standard deviation around -// its median price in the last prune period since the current block. -func (k Keeper) calcAndSetMedianDeviation( +// calcAndSetHistoricMedianDeviation calculates and sets a given denom's standard +// deviation around its median price in the current block. +func (k Keeper) calcAndSetHistoricMedianDeviation( ctx sdk.Context, denom string, median sdk.Dec, prices []sdk.Dec, -) { - medianDeviation := medianDeviation(median, prices) - k.SetMedianDeviation(ctx, denom, medianDeviation) +) error { + medianDeviation, err := decmath.MedianDeviation(median, prices) + if err != nil { + return sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) + } + + block := uint64(ctx.BlockHeight()) + k.SetHistoricMedianDeviation(ctx, denom, block, medianDeviation) + return nil } -func (k Keeper) SetMedianDeviation( +func (k Keeper) SetHistoricMedianDeviation( ctx sdk.Context, denom string, + blockNum uint64, medianDeviation sdk.Dec, ) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&sdk.DecProto{Dec: medianDeviation}) - store.Set(types.KeyMedianDeviation(denom), bz) + store.Set(types.KeyMedianDeviation(denom, blockNum), bz) +} + +// MedianOfHistoricMedians calculates and returns the median of the last stampNum +// historic medians. +func (k Keeper) MedianOfHistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint64, +) (sdk.Dec, error) { + medians := k.HistoricMedians(ctx, denom, numStamps) + median, err := decmath.Median(medians) + if err != nil { + return sdk.ZeroDec(), sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) + } + return median, nil +} + +// AverageOfHistoricMedians calculates and returns the average of the last stampNum +// historic medians. +func (k Keeper) AverageOfHistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint64, +) (sdk.Dec, error) { + medians := k.HistoricMedians(ctx, denom, numStamps) + average, err := decmath.Average(medians) + if err != nil { + return sdk.ZeroDec(), sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) + } + return average, nil +} + +// MaxOfHistoricMedian calculates and returns the maximum value of the last stampNum +// historic medians. +func (k Keeper) MaxOfHistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint64, +) (sdk.Dec, error) { + medians := k.HistoricMedians(ctx, denom, numStamps) + max, err := decmath.Max(medians) + if err != nil { + return sdk.ZeroDec(), sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) + } + return max, nil +} + +// MinOfHistoricMedians calculates and returns the minimum value of the last stampNum +// historic medians. +func (k Keeper) MinOfHistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint64, +) (sdk.Dec, error) { + medians := k.HistoricMedians(ctx, denom, numStamps) + min, err := decmath.Min(medians) + if err != nil { + return sdk.ZeroDec(), sdkerrors.Wrap(err, fmt.Sprintf("denom: %s", denom)) + } + return min, nil } -// getHistoricPrices returns all the historic prices of a given denom. -func (k Keeper) getHistoricPrices( +// historicPrices returns all the historic prices of a given denom. +func (k Keeper) historicPrices( ctx sdk.Context, denom string, + numStamps uint64, ) []sdk.Dec { + // calculate start block to iterate from historicPrices := []sdk.Dec{} - k.IterateHistoricPrices(ctx, denom, func(exchangeRate sdk.Dec) bool { + k.IterateHistoricPrices(ctx, denom, uint(numStamps), func(exchangeRate sdk.Dec) bool { historicPrices = append(historicPrices, exchangeRate) return false }) @@ -164,18 +211,44 @@ func (k Keeper) getHistoricPrices( } // IterateHistoricPrices iterates over historic prices of a given -// denom in the store. +// denom in the store in reverse. // Iterator stops when exhausting the source, or when the handler returns `true`. func (k Keeper) IterateHistoricPrices( ctx sdk.Context, denom string, + numStamps uint, handler func(sdk.Dec) bool, ) { store := ctx.KVStore(k.storeKey) // make sure we have one zero byte to correctly separate denoms prefix := util.ConcatBytes(1, types.KeyPrefixHistoricPrice, []byte(denom)) - iter := sdk.KVStorePrefixIterator(store, prefix) + iter := sdk.KVStoreReversePrefixIteratorPaginated(store, prefix, 1, numStamps) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + decProto := sdk.DecProto{} + k.cdc.MustUnmarshal(iter.Value(), &decProto) + if handler(decProto.Dec) { + break + } + } +} + +// IterateHistoricMediansSinceBlock iterates over medians of a given +// denom in the store in reverse. +// Iterator stops when exhausting the source, or when the handler returns `true`. +func (k Keeper) IterateHistoricMedians( + ctx sdk.Context, + denom string, + numStamps uint, + handler func(sdk.Dec) bool, +) { + store := ctx.KVStore(k.storeKey) + + // make sure we have one zero byte to correctly separate denoms + prefix := util.ConcatBytes(1, types.KeyPrefixMedian, []byte(denom)) + iter := sdk.KVStoreReversePrefixIteratorPaginated(store, prefix, 1, numStamps) defer iter.Close() for ; iter.Valid(); iter.Next() { @@ -220,27 +293,30 @@ func (k Keeper) DeleteHistoricPrice( store.Delete(types.KeyHistoricPrice(denom, blockNum)) } -// DeleteMedian deletes a given denom's median price. -func (k Keeper) DeleteMedian( +// DeleteHistoricMedian deletes a given denom's median price at a given block. +func (k Keeper) DeleteHistoricMedian( ctx sdk.Context, denom string, + blockNum uint64, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyMedian(denom)) + store.Delete(types.KeyMedian(denom, blockNum)) } -// DeleteMedianDeviation deletes a given denom's standard deviation around -// its median price. -func (k Keeper) DeleteMedianDeviation( +// DeleteHistoricMedianDeviation deletes a given denom's standard deviation +// around its median price at a given block. +func (k Keeper) DeleteHistoricMedianDeviation( ctx sdk.Context, denom string, + blockNum uint64, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyMedianDeviation(denom)) + store.Delete(types.KeyMedianDeviation(denom, blockNum)) } -// ClearMedians iterates through all medians in the store and deletes them. -func (k Keeper) ClearMedians(ctx sdk.Context) { +// ClearHistoricMedians iterates through all medians in the store and deletes +// them. +func (k Keeper) ClearHistoricMedians(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixMedian) defer iter.Close() @@ -249,9 +325,9 @@ func (k Keeper) ClearMedians(ctx sdk.Context) { } } -// ClearMedianDeviations iterates through all median deviations in the store -// and deletes them. -func (k Keeper) ClearMedianDeviations(ctx sdk.Context) { +// ClearHistoricMedianDeviations iterates through all median deviations in +// the store and deletes them. +func (k Keeper) ClearHistoricMedianDeviations(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixMedianDeviation) defer iter.Close() diff --git a/x/oracle/keeper/historic_price_test.go b/x/oracle/keeper/historic_price_test.go index ff99872941..f0237c4911 100644 --- a/x/oracle/keeper/historic_price_test.go +++ b/x/oracle/keeper/historic_price_test.go @@ -2,58 +2,88 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/umee-network/umee/v3/x/oracle/types" ) func (s *IntegrationTestSuite) TestSetHistoraclePricing() { app, ctx := s.app, s.ctx + // update stamp params + app.OracleKeeper.SetHistoricStampPeriod(ctx, 1) + app.OracleKeeper.SetMedianStampPeriod(ctx, 3) + + // set historic prices and medians for denom with a similar + // prefix to test unique prefix safety when iterating for + // similar prefixes + displayDenomVariation := displayDenom + "test" + // add multiple historic prices to store - exchangeRates := []string{"1.0", "1.2", "1.1", "1.4"} + exchangeRates := []string{"1.0", "1.2", "1.1", "1.4", "1.1", "1.15", "1.2", "1.3", "1.2"} for i, exchangeRate := range exchangeRates { - // update blockheight - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + int64(i)) - app.OracleKeeper.AddHistoricPrice(ctx, displayDenom, sdk.MustNewDecFromStr(exchangeRate)) - app.OracleKeeper.CalcAndSetMedian(ctx, displayDenom) + app.OracleKeeper.AddHistoricPrice(ctx, displayDenomVariation, sdk.MustNewDecFromStr(exchangeRate)) + if ((i + 1) % int(app.OracleKeeper.MedianStampPeriod(ctx))) == 0 { + err := app.OracleKeeper.CalcAndSetHistoricMedian(ctx, displayDenom) + s.Require().NoError(err) + err = app.OracleKeeper.CalcAndSetHistoricMedian(ctx, displayDenomVariation) + s.Require().NoError(err) + } + + // update blockheight + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) } - // set and check median and median standard deviation - app.OracleKeeper.CalcAndSetMedian(ctx, displayDenom) - median, err := app.OracleKeeper.GetMedian(ctx, displayDenom) - s.Require().NoError(err) - s.Require().Equal(median, sdk.MustNewDecFromStr("1.15")) + // check median and median standard deviation + medians := app.OracleKeeper.HistoricMedians(ctx, displayDenom, 3) + s.Require().Equal(len(medians), 3) + s.Require().Equal(medians[0], sdk.MustNewDecFromStr("1.2")) + s.Require().Equal(medians[1], sdk.MustNewDecFromStr("1.125")) + s.Require().Equal(medians[2], sdk.MustNewDecFromStr("1.1")) - medianDeviation, err := app.OracleKeeper.GetMedianDeviation(ctx, displayDenom) + medianDeviation, err := app.OracleKeeper.HistoricMedianDeviation(ctx, displayDenom) s.Require().NoError(err) - s.Require().Equal(medianDeviation, sdk.MustNewDecFromStr("0.0225")) + s.Require().Equal(medianDeviation, sdk.MustNewDecFromStr("0.012499999999999998")) - // check prices are within the median deviation - price1 := sdk.MustNewDecFromStr("1.13") - price2 := sdk.MustNewDecFromStr("1.12") - result, err := app.OracleKeeper.WithinMedianDeviation(ctx, displayDenom, price1) + // check current price is within the median deviation + result, err := app.OracleKeeper.WithinHistoricMedianDeviation(ctx, displayDenom) s.Require().Equal(result, true) s.Require().NoError(err) - result, err = app.OracleKeeper.WithinMedianDeviation(ctx, displayDenom, price2) - s.Require().Equal(result, false) - s.Require().NoError(err) - // delete first historic price, median, and median standard deviation - app.OracleKeeper.DeleteHistoricPrice(ctx, displayDenom, uint64(ctx.BlockHeight()-3)) - app.OracleKeeper.DeleteMedian(ctx, displayDenom) - app.OracleKeeper.DeleteMedianDeviation(ctx, displayDenom) + // check median stats of last 3 stamps + medianOfMedians, err := app.OracleKeeper.MedianOfHistoricMedians(ctx, displayDenom, 3) + s.Require().NoError(err) + s.Require().Equal(medianOfMedians, sdk.MustNewDecFromStr("1.125")) + averageOfMedians, err := app.OracleKeeper.AverageOfHistoricMedians(ctx, displayDenom, 3) + s.Require().NoError(err) + s.Require().Equal(averageOfMedians, sdk.MustNewDecFromStr("1.141666666666666666")) + maxMedian, err := app.OracleKeeper.MaxOfHistoricMedians(ctx, displayDenom, 3) + s.Require().NoError(err) + s.Require().Equal(maxMedian, sdk.MustNewDecFromStr("1.2")) + minMedian, err := app.OracleKeeper.MinOfHistoricMedians(ctx, displayDenom, 3) + s.Require().NoError(err) + s.Require().Equal(minMedian, sdk.MustNewDecFromStr("1.1")) - median, err = app.OracleKeeper.GetMedian(ctx, displayDenom) - s.Require().Error(err, sdkerrors.Wrap(types.ErrUnknownDenom, displayDenom)) - s.Require().Equal(median, sdk.ZeroDec()) + // check median stats of last 1 stamps + medianOfMedians, err = app.OracleKeeper.MedianOfHistoricMedians(ctx, displayDenom, 1) + s.Require().NoError(err) + s.Require().Equal(medianOfMedians, sdk.MustNewDecFromStr("1.2")) + averageOfMedians, err = app.OracleKeeper.AverageOfHistoricMedians(ctx, displayDenom, 1) + s.Require().NoError(err) + s.Require().Equal(averageOfMedians, sdk.MustNewDecFromStr("1.2")) + maxMedian, err = app.OracleKeeper.MaxOfHistoricMedians(ctx, displayDenom, 1) + s.Require().NoError(err) + s.Require().Equal(maxMedian, sdk.MustNewDecFromStr("1.2")) + minMedian, err = app.OracleKeeper.MinOfHistoricMedians(ctx, displayDenom, 1) + s.Require().NoError(err) + s.Require().Equal(minMedian, sdk.MustNewDecFromStr("1.2")) - medianDeviation, err = app.OracleKeeper.GetMedianDeviation(ctx, displayDenom) - s.Require().Error(err, sdkerrors.Wrap(types.ErrUnknownDenom, displayDenom)) - s.Require().Equal(median, sdk.ZeroDec()) + // delete first median + blockPeriod := (3 - 1) * app.OracleKeeper.MedianStampPeriod(ctx) + lastStampBlock := uint64(ctx.BlockHeight()) - (uint64(ctx.BlockHeight())%app.OracleKeeper.MedianStampPeriod(ctx) + 1) + firstStampBlock := lastStampBlock - blockPeriod + app.OracleKeeper.DeleteHistoricMedian(ctx, displayDenom, firstStampBlock) - result, err = app.OracleKeeper.WithinMedianDeviation(ctx, displayDenom, price1) - s.Require().Error(err, sdkerrors.Wrap(types.ErrUnknownDenom, displayDenom)) - s.Require().Equal(result, false) + medians = app.OracleKeeper.HistoricMedians(ctx, displayDenom, 3) + s.Require().Equal(len(medians), 2) + s.Require().Equal(medians[0], sdk.MustNewDecFromStr("1.2")) + s.Require().Equal(medians[1], sdk.MustNewDecFromStr("1.125")) } diff --git a/x/oracle/keeper/migrations.go b/x/oracle/keeper/migrations.go index ef023720ee..70b33d5459 100644 --- a/x/oracle/keeper/migrations.go +++ b/x/oracle/keeper/migrations.go @@ -2,8 +2,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/umee-network/umee/v3/x/oracle/types" ) // Migrator is a struct for handling in-place store migrations. @@ -18,9 +16,9 @@ func NewMigrator(keeper *Keeper) Migrator { // Migrate1to2 migrates from version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - m.keeper.SetStampPeriod(ctx, 1) - m.keeper.SetPrunePeriod(ctx, 1) - m.keeper.SetMedianPeriod(ctx, 1) - m.keeper.SetHistoricAcceptList(ctx, types.DenomList{}) + m.keeper.SetHistoricStampPeriod(ctx, 1) + m.keeper.SetMedianStampPeriod(ctx, 1) + m.keeper.SetMaximumPriceStamps(ctx, 1) + m.keeper.SetMaximumMedianStamps(ctx, 1) return nil } diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 72d0329ff2..17fb81bfe4 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -45,25 +45,6 @@ func (k Keeper) SetAcceptList(ctx sdk.Context, acceptList types.DenomList) { k.paramSpace.Set(ctx, types.KeyAcceptList, acceptList) } -// HistoricAcceptList returns the list of assets whose historic prices and -// medians are getting tracked. -func (k Keeper) HistoricAcceptList(ctx sdk.Context) (res types.DenomList) { - k.paramSpace.Get(ctx, types.KeyHistoricAcceptList, &res) - return -} - -// IsHistoricAsset returns whether or not a given denom is being tracked as -// a historic asset. -func (k Keeper) IsHistoricAsset(ctx sdk.Context, denom string) bool { - return k.HistoricAcceptList(ctx).Contains(denom) -} - -// SetHistoricAcceptList updates the the list of assets whose historic prices and -// medians are getting tracked. -func (k Keeper) SetHistoricAcceptList(ctx sdk.Context, historicAcceptList types.DenomList) { - k.paramSpace.Set(ctx, types.KeyHistoricAcceptList, historicAcceptList) -} - // SlashFraction returns oracle voting penalty rate func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec) { k.paramSpace.Get(ctx, types.KeySlashFraction, &res) @@ -82,45 +63,56 @@ func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec) { return } -// StampPeriod returns the amount of blocks the oracle module waits -// between recording a set of prices. -func (k Keeper) StampPeriod(ctx sdk.Context) (res uint64) { - k.paramSpace.Get(ctx, types.KeyStampPeriod, &res) +// HistoricStampPeriod returns the amount of blocks the oracle module waits +// before recording a new historic price. +func (k Keeper) HistoricStampPeriod(ctx sdk.Context) (res uint64) { + k.paramSpace.Get(ctx, types.KeyHistoricStampPeriod, &res) + return +} + +// SetHistoricStampPeriod updates the amount of blocks the oracle module waits +// before recording a new historic price. +func (k Keeper) SetHistoricStampPeriod(ctx sdk.Context, historicPriceStampPeriod uint64) { + k.paramSpace.Set(ctx, types.KeyHistoricStampPeriod, historicPriceStampPeriod) +} + +// MedianStampPeriod returns the amount blocks the oracle module waits between +// calculating a new median and standard deviation of that median. +func (k Keeper) MedianStampPeriod(ctx sdk.Context) (res uint64) { + k.paramSpace.Get(ctx, types.KeyMedianStampPeriod, &res) return } -// SetStampPeriod updates the amount of blocks the oracle module waits -// between recording a set of prices. -func (k Keeper) SetStampPeriod(ctx sdk.Context, stampPeriod uint64) { - k.paramSpace.Set(ctx, types.KeyStampPeriod, stampPeriod) +// SetMedianStampPeriod updates the amount blocks the oracle module waits between +// calculating a new median and standard deviation of that median. +func (k Keeper) SetMedianStampPeriod(ctx sdk.Context, medianStampPeriod uint64) { + k.paramSpace.Set(ctx, types.KeyMedianStampPeriod, medianStampPeriod) } -// PrunePeriod returns the max amount of blocks that a record of the set -// of exchanges is kept. -func (k Keeper) PrunePeriod(ctx sdk.Context) (res uint64) { - k.paramSpace.Get(ctx, types.KeyPrunePeriod, &res) +// MaximumMedianStamps returns the maximum amount of historic prices the oracle +// module will hold. +func (k Keeper) MaximumPriceStamps(ctx sdk.Context) (res uint64) { + k.paramSpace.Get(ctx, types.KeyMaximumPriceStamps, &res) return } -// SetPrunePeriod updates the max amount of blocks that a record of the set -// of exchanges is kept. -func (k Keeper) SetPrunePeriod(ctx sdk.Context, prunePeriod uint64) { - k.paramSpace.Set(ctx, types.KeyPrunePeriod, prunePeriod) +// SetMaximumPriceStamps updates the the maximum amount of historic prices the +// oracle module will hold. +func (k Keeper) SetMaximumPriceStamps(ctx sdk.Context, maximumPriceStamps uint64) { + k.paramSpace.Set(ctx, types.KeyMaximumPriceStamps, maximumPriceStamps) } -// MedianPeriod returns the amount blocks we will wait between calculating the -// median and standard deviation of the median of historic prices in the -// last Prune Period. -func (k Keeper) MedianPeriod(ctx sdk.Context) (res uint64) { - k.paramSpace.Get(ctx, types.KeyMedianPeriod, &res) +// MaximumMedianStamps returns the maximum amount of medians the oracle module will +// hold. +func (k Keeper) MaximumMedianStamps(ctx sdk.Context) (res uint64) { + k.paramSpace.Get(ctx, types.KeyMaximumMedianStamps, &res) return } -// MedianPeriod updates the amount blocks we will wait between calculating the -// median and standard deviation of the median of historic prices in the -// last Prune Period. -func (k Keeper) SetMedianPeriod(ctx sdk.Context, medianPeriod uint64) { - k.paramSpace.Set(ctx, types.KeyMedianPeriod, medianPeriod) +// SetMaximumMedianStamps updates the the maximum amount of medians the oracle module will +// hold. +func (k Keeper) SetMaximumMedianStamps(ctx sdk.Context, maximumMedianStamps uint64) { + k.paramSpace.Set(ctx, types.KeyMaximumMedianStamps, maximumMedianStamps) } // GetParams returns the total set of oracle parameters. diff --git a/x/oracle/simulations/genesis.go b/x/oracle/simulations/genesis.go index d3783fdb5c..553f1c42b9 100644 --- a/x/oracle/simulations/genesis.go +++ b/x/oracle/simulations/genesis.go @@ -19,9 +19,10 @@ const ( slashFractionKey = "slash_fraction" slashWindowKey = "slash_window" minValidPerWindowKey = "min_valid_per_window" - stampPeriodKey = "stamp_period" - prunePeriodKey = "prune_period" - medianPeriodKey = "median_period" + historicStampPeriodKey = "historic_stamp_period" + medianStampPeriodKey = "median_stamp_period" + maximumPriceStampsKey = "maximum_price_stamps" + maximumMedianStampsKey = "maximum_median_stamps" ) // GenVotePeriod produces a randomized VotePeriod in the range of [5, 100] @@ -59,19 +60,24 @@ func GenMinValidPerWindow(r *rand.Rand) sdk.Dec { return sdk.ZeroDec().Add(sdk.NewDecWithPrec(int64(r.Intn(500)), 3)) } -// GenStampPeriod produces a randomized StampPeriod in the range of [100, 1000] -func GenStampPeriod(r *rand.Rand) uint64 { +// GenHistoricStampPeriod produces a randomized HistoricStampPeriod in the range of [100, 1000] +func GenHistoricStampPeriod(r *rand.Rand) uint64 { return uint64(100 + r.Intn(1000)) } -// GenPrunePeriod produces a randomized PrunePeriod in the range of [10001, 100000] -func GenPrunePeriod(r *rand.Rand) uint64 { +// GenMedianStampPeriod produces a randomized MedianStampPeriod in the range of [100, 1000] +func GenMedianStampPeriod(r *rand.Rand) uint64 { return uint64(10001 + r.Intn(100000)) } -// GenMedianPeriod produces a randomized MedianPeriod in the range of [1001, 10000] -func GenMedianPeriod(r *rand.Rand) uint64 { - return uint64(1001 + r.Intn(10000)) +// GenMaximumPriceStamps produces a randomized MaximumPriceStamps in the range of [10, 100] +func GenMaximumPriceStamps(r *rand.Rand) uint64 { + return uint64(11 + r.Intn(100)) +} + +// GenMaximumMedianStamps produces a randomized MaximumMedianStamps in the range of [10, 100] +func GenMaximumMedianStamps(r *rand.Rand) uint64 { + return uint64(11 + r.Intn(100)) } // RandomizedGenState generates a random GenesisState for oracle @@ -118,22 +124,28 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minValidPerWindow = GenMinValidPerWindow(r) }, ) - var stampPeriod uint64 + var historicStampPeriod uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, stampPeriodKey, &stampPeriod, simState.Rand, - func(r *rand.Rand) { stampPeriod = GenStampPeriod(r) }, + simState.Cdc, historicStampPeriodKey, &historicStampPeriod, simState.Rand, + func(r *rand.Rand) { historicStampPeriod = GenHistoricStampPeriod(r) }, ) - var prunePeriod uint64 + var medianStampPeriod uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, prunePeriodKey, &prunePeriod, simState.Rand, - func(r *rand.Rand) { prunePeriod = GenPrunePeriod(r) }, + simState.Cdc, medianStampPeriodKey, &medianStampPeriod, simState.Rand, + func(r *rand.Rand) { medianStampPeriod = GenMedianStampPeriod(r) }, ) - var medianPeriod uint64 + var maximumPriceStamps uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, medianPeriodKey, &medianPeriod, simState.Rand, - func(r *rand.Rand) { medianPeriod = GenMedianPeriod(r) }, + simState.Cdc, maximumPriceStampsKey, &maximumPriceStamps, simState.Rand, + func(r *rand.Rand) { maximumPriceStamps = GenMaximumPriceStamps(r) }, + ) + + var maximumMedianStamps uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, maximumMedianStampsKey, &maximumMedianStamps, simState.Rand, + func(r *rand.Rand) { maximumMedianStamps = GenMaximumMedianStamps(r) }, ) oracleGenesis := types.DefaultGenesisState() @@ -145,15 +157,13 @@ func RandomizedGenState(simState *module.SimulationState) { AcceptList: types.DenomList{ {SymbolDenom: types.UmeeSymbol, BaseDenom: types.UmeeDenom}, }, - SlashFraction: slashFraction, - SlashWindow: slashWindow, - MinValidPerWindow: minValidPerWindow, - HistoricAcceptList: types.DenomList{ - {SymbolDenom: types.UmeeSymbol, BaseDenom: types.UmeeDenom}, - }, - StampPeriod: stampPeriod, - PrunePeriod: prunePeriod, - MedianPeriod: medianPeriod, + SlashFraction: slashFraction, + SlashWindow: slashWindow, + MinValidPerWindow: minValidPerWindow, + HistoricStampPeriod: historicStampPeriod, + MedianStampPeriod: medianStampPeriod, + MaximumPriceStamps: historicStampPeriod, + MaximumMedianStamps: historicStampPeriod, } bz, err := json.MarshalIndent(&oracleGenesis.Params, "", " ") diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index a97e9f7657..97c03a42de 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -26,6 +26,7 @@ var ( ErrExistingPrevote = sdkerrors.Register(ModuleName, 15, "prevote already submitted for this voting period") ErrBallotNotSorted = sdkerrors.Register(ModuleName, 16, "ballot must be sorted before this operation") ErrNotImplemented = sdkerrors.Register(ModuleName, 17, "functon not implemented") - ErrNoMedian = sdkerrors.Register(ModuleName, 18, "no median for this denom at this block") - ErrNoMedianDeviation = sdkerrors.Register(ModuleName, 19, "no median deviation for this denom at this block") + ErrNoHistoricPrice = sdkerrors.Register(ModuleName, 18, "no historic price for this denom at this block") + ErrNoMedian = sdkerrors.Register(ModuleName, 19, "no median for this denom at this block") + ErrNoMedianDeviation = sdkerrors.Register(ModuleName, 20, "no median deviation for this denom at this block") ) diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index d2635e45e3..6c72b6dc4c 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -14,9 +14,9 @@ func NewGenesisState( missCounters []MissCounter, aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote, aggregateExchangeRateVotes []AggregateExchangeRateVote, - historicPrices []HistoricPrice, - medianPrices []ExchangeRateTuple, - medianDeviationPrices []ExchangeRateTuple, + historicPrices []Price, + medianPrices []Price, + medianDeviationPrices []Price, ) *GenesisState { return &GenesisState{ Params: params, @@ -41,9 +41,9 @@ func DefaultGenesisState() *GenesisState { MissCounters: []MissCounter{}, AggregateExchangeRatePrevotes: []AggregateExchangeRatePrevote{}, AggregateExchangeRateVotes: []AggregateExchangeRateVote{}, - HistoricPrices: []HistoricPrice{}, - Medians: []ExchangeRateTuple{}, - MedianDeviations: []ExchangeRateTuple{}, + HistoricPrices: []Price{}, + Medians: []Price{}, + MedianDeviations: []Price{}, } } diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index a4e2adb6e6..80da8d64d6 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -31,9 +31,9 @@ type GenesisState struct { MissCounters []MissCounter `protobuf:"bytes,4,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"` AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,5,rep,name=aggregate_exchange_rate_prevotes,json=aggregateExchangeRatePrevotes,proto3" json:"aggregate_exchange_rate_prevotes"` AggregateExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,6,rep,name=aggregate_exchange_rate_votes,json=aggregateExchangeRateVotes,proto3" json:"aggregate_exchange_rate_votes"` - HistoricPrices []HistoricPrice `protobuf:"bytes,8,rep,name=historic_prices,json=historicPrices,proto3" json:"historic_prices"` - Medians []ExchangeRateTuple `protobuf:"bytes,7,rep,name=medians,proto3" json:"medians"` - MedianDeviations []ExchangeRateTuple `protobuf:"bytes,9,rep,name=medianDeviations,proto3" json:"medianDeviations"` + HistoricPrices []Price `protobuf:"bytes,8,rep,name=historic_prices,json=historicPrices,proto3" json:"historic_prices"` + Medians []Price `protobuf:"bytes,7,rep,name=medians,proto3" json:"medians"` + MedianDeviations []Price `protobuf:"bytes,9,rep,name=medianDeviations,proto3" json:"medianDeviations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -150,24 +150,24 @@ func (m *MissCounter) XXX_DiscardUnknown() { var xxx_messageInfo_MissCounter proto.InternalMessageInfo -// HistoricPrice is an instance of a price "stamp" -type HistoricPrice struct { +// Price is an instance of a price "stamp" +type Price struct { ExchangeRateTuple ExchangeRateTuple `protobuf:"bytes,1,opt,name=exchange_rate_tuple,json=exchangeRateTuple,proto3" json:"exchange_rate_tuple"` BlockNum uint64 `protobuf:"varint,2,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` } -func (m *HistoricPrice) Reset() { *m = HistoricPrice{} } -func (m *HistoricPrice) String() string { return proto.CompactTextString(m) } -func (*HistoricPrice) ProtoMessage() {} -func (*HistoricPrice) Descriptor() ([]byte, []int) { +func (m *Price) Reset() { *m = Price{} } +func (m *Price) String() string { return proto.CompactTextString(m) } +func (*Price) ProtoMessage() {} +func (*Price) Descriptor() ([]byte, []int) { return fileDescriptor_c99b4af40468acc1, []int{3} } -func (m *HistoricPrice) XXX_Unmarshal(b []byte) error { +func (m *Price) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *HistoricPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Price) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_HistoricPrice.Marshal(b, m, deterministic) + return xxx_messageInfo_Price.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -177,66 +177,65 @@ func (m *HistoricPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *HistoricPrice) XXX_Merge(src proto.Message) { - xxx_messageInfo_HistoricPrice.Merge(m, src) +func (m *Price) XXX_Merge(src proto.Message) { + xxx_messageInfo_Price.Merge(m, src) } -func (m *HistoricPrice) XXX_Size() int { +func (m *Price) XXX_Size() int { return m.Size() } -func (m *HistoricPrice) XXX_DiscardUnknown() { - xxx_messageInfo_HistoricPrice.DiscardUnknown(m) +func (m *Price) XXX_DiscardUnknown() { + xxx_messageInfo_Price.DiscardUnknown(m) } -var xxx_messageInfo_HistoricPrice proto.InternalMessageInfo +var xxx_messageInfo_Price proto.InternalMessageInfo func init() { proto.RegisterType((*GenesisState)(nil), "umee.oracle.v1.GenesisState") proto.RegisterType((*FeederDelegation)(nil), "umee.oracle.v1.FeederDelegation") proto.RegisterType((*MissCounter)(nil), "umee.oracle.v1.MissCounter") - proto.RegisterType((*HistoricPrice)(nil), "umee.oracle.v1.HistoricPrice") + proto.RegisterType((*Price)(nil), "umee.oracle.v1.Price") } func init() { proto.RegisterFile("umee/oracle/v1/genesis.proto", fileDescriptor_c99b4af40468acc1) } var fileDescriptor_c99b4af40468acc1 = []byte{ - // 584 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, - 0x14, 0xc5, 0xe3, 0xb6, 0xff, 0xb4, 0x9d, 0x34, 0xf9, 0xb7, 0x03, 0x42, 0x56, 0x4a, 0xdd, 0x34, - 0x12, 0x52, 0x11, 0x60, 0xab, 0x2d, 0x2f, 0xd0, 0x50, 0x0a, 0x8b, 0x82, 0xa2, 0x94, 0x0f, 0x09, - 0x09, 0x59, 0x13, 0xfb, 0xc6, 0xb1, 0x1a, 0x7b, 0xac, 0x99, 0xb1, 0x29, 0x62, 0xcd, 0x9e, 0x47, - 0x60, 0xcd, 0x93, 0x64, 0xd9, 0x25, 0x2b, 0x3e, 0x92, 0x17, 0x41, 0x1e, 0x4f,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0xfd, 0x52, 0x50, 0x70, 0xf3, 0x3d, 0xaa, 0xe4, 0x36, - 0xec, 0xfa, 0x5e, 0xed, 0xfa, 0x5e, 0xbc, 0x83, 0xd6, 0xf2, 0x2b, 0x2c, 0x33, 0x96, 0x3a, 0x95, - 0xdc, 0x7a, 0x36, 0x3f, 0x6b, 0xa8, 0x3a, 0xf3, 0x1b, 0xf0, 0x5b, 0x74, 0x6b, 0x76, 0x51, 0x44, - 0xfa, 0x1d, 0xd4, 0xb9, 0x9f, 0xfb, 0x83, 0x6d, 0x40, 0x51, 0xc0, 0x9b, 0x68, 0xb5, 0x3b, 0xa0, - 0xce, 0x99, 0x1d, 0xc6, 0x81, 0x1a, 0x65, 0x45, 0x16, 0x5e, 0xc6, 0x41, 0xeb, 0x64, 0xf8, 0xdb, - 0x28, 0x0d, 0x47, 0x86, 0x76, 0x31, 0x32, 0xb4, 0x5f, 0x23, 0x43, 0xfb, 0x32, 0x36, 0x4a, 0x17, - 0x63, 0xa3, 0xf4, 0x7d, 0x6c, 0x94, 0xde, 0x99, 0x9e, 0x2f, 0xfa, 0x71, 0xd7, 0x74, 0x68, 0x60, - 0xa5, 0x03, 0x3c, 0x0a, 0x41, 0x7c, 0xa0, 0xec, 0x4c, 0xbe, 0x58, 0xc9, 0x81, 0x75, 0x3e, 0xb9, - 0xc9, 0xc4, 0xc7, 0x08, 0x78, 0xb7, 0x2c, 0xaf, 0xb1, 0x83, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x05, 0xf1, 0x47, 0x75, 0x29, 0x05, 0x00, 0x00, + // 575 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x5b, 0x6e, 0xd3, 0x4c, + 0x14, 0x8e, 0x7b, 0x49, 0xdb, 0x49, 0x9b, 0x3f, 0x9d, 0x1f, 0x90, 0x95, 0x50, 0x37, 0x8d, 0x84, + 0x54, 0x04, 0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9, 0x46, 0xe2, 0x7b, + 0xa8, 0xac, 0xfa, 0x4c, 0x5c, 0x97, 0x01, 0xcf, 0xae, 0x61, 0xad, 0xbd, 0x91, 0x4d, 0x0f, 0xb3, + 0x21, 0x7e, 0x80, 0x36, 0x13, 0xd2, 0xf7, 0x5d, 0x22, 0xe8, 0x84, 0xb9, 0x20, 0x99, 0x95, 0x0b, + 0x40, 0x91, 0x1b, 0x1f, 0x50, 0x69, 0xaa, 0x41, 0x97, 0x6b, 0xb5, 0xcb, 0xb5, 0x78, 0x07, 0xad, + 0x4f, 0x57, 0x54, 0x66, 0x2c, 0xb5, 0x4b, 0x53, 0xf5, 0x6b, 0x7c, 0x41, 0xcb, 0xf2, 0x7f, 0xe2, + 0x77, 0xe8, 0xff, 0xd9, 0xf7, 0x2f, 0xd2, 0xd6, 0xab, 0x73, 0xbe, 0xc1, 0xe5, 0xa8, 0x6b, 0x84, + 0x3c, 0x80, 0x6b, 0x68, 0xad, 0xd3, 0xa7, 0xce, 0xa9, 0x1d, 0xc6, 0x81, 0xda, 0x60, 0x55, 0x0e, + 0x5e, 0xc6, 0x41, 0xf3, 0xf9, 0xe0, 0x8f, 0x51, 0x18, 0x0c, 0x0d, 0xed, 0x7c, 0x68, 0x68, 0xbf, + 0x87, 0x86, 0xf6, 0x6d, 0x64, 0x14, 0xce, 0x47, 0x46, 0xe1, 0xc7, 0xc8, 0x28, 0xbc, 0x37, 0x3d, + 0x5f, 0xf4, 0xe2, 0x8e, 0xe9, 0xd0, 0xc0, 0x4a, 0x17, 0x78, 0x14, 0x82, 0xf8, 0x48, 0xd9, 0xa9, + 0xfc, 0x61, 0x25, 0x07, 0xd6, 0xd9, 0xf8, 0x03, 0x25, 0x3e, 0x45, 0xc0, 0x3b, 0x45, 0xf9, 0x75, + 0x3a, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x07, 0x4b, 0xed, 0x08, 0x00, 0x05, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -456,7 +455,7 @@ func (m *MissCounter) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *HistoricPrice) Marshal() (dAtA []byte, err error) { +func (m *Price) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -466,12 +465,12 @@ func (m *HistoricPrice) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *HistoricPrice) MarshalTo(dAtA []byte) (int, error) { +func (m *Price) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *HistoricPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Price) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -597,7 +596,7 @@ func (m *MissCounter) Size() (n int) { return n } -func (m *HistoricPrice) Size() (n int) { +func (m *Price) Size() (n int) { if m == nil { return 0 } @@ -878,7 +877,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Medians = append(m.Medians, ExchangeRateTuple{}) + m.Medians = append(m.Medians, Price{}) if err := m.Medians[len(m.Medians)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -912,7 +911,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.HistoricPrices = append(m.HistoricPrices, HistoricPrice{}) + m.HistoricPrices = append(m.HistoricPrices, Price{}) if err := m.HistoricPrices[len(m.HistoricPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -946,7 +945,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MedianDeviations = append(m.MedianDeviations, ExchangeRateTuple{}) + m.MedianDeviations = append(m.MedianDeviations, Price{}) if err := m.MedianDeviations[len(m.MedianDeviations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1187,7 +1186,7 @@ func (m *MissCounter) Unmarshal(dAtA []byte) error { } return nil } -func (m *HistoricPrice) Unmarshal(dAtA []byte) error { +func (m *Price) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1210,10 +1209,10 @@ func (m *HistoricPrice) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: HistoricPrice: wiretype end group for non-group") + return fmt.Errorf("proto: Price: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: HistoricPrice: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Price: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 56b43b2a59..25041b86f3 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -61,34 +61,22 @@ func KeyAggregateExchangeRateVote(v sdk.ValAddress) []byte { } // KeyMedian - stored by *denom* -func KeyMedian(denom string) (key []byte) { - return util.ConcatBytes(0, KeyPrefixMedian, []byte(denom)) +func KeyMedian(denom string, blockNum uint64) (key []byte) { + return util.ConcatBytes(0, KeyPrefixMedian, []byte(denom), util.UintWithNullPrefix(blockNum)) } // KeyMedianDeviation - stored by *denom* -func KeyMedianDeviation(denom string) (key []byte) { - return util.ConcatBytes(0, KeyPrefixMedianDeviation, []byte(denom)) +func KeyMedianDeviation(denom string, blockNum uint64) (key []byte) { + return util.ConcatBytes(0, KeyPrefixMedianDeviation, []byte(denom), util.UintWithNullPrefix(blockNum)) } // KeyHistoricPrice - stored by *denom* and *block* func KeyHistoricPrice(denom string, blockNum uint64) (key []byte) { - return util.ConcatBytes(0, KeyPrefixHistoricPrice, []byte(denom), uintWithNullPrefix(blockNum)) + return util.ConcatBytes(0, KeyPrefixHistoricPrice, []byte(denom), util.UintWithNullPrefix(blockNum)) } -func uintWithNullPrefix(n uint64) []byte { - bz := make([]byte, 9) - binary.LittleEndian.PutUint64(bz[1:], n) - return bz -} - -func ParseDenomFromHistoricPriceKey(key []byte) string { - return string(key[len(KeyPrefixHistoricPrice) : len(key)-9]) -} - -func ParseBlockFromHistoricPriceKey(key []byte) uint64 { - return binary.LittleEndian.Uint64(key[len(key)-8:]) -} - -func ParseDenomFromMedianKey(key []byte) string { - return string(key[len(KeyPrefixMedian):]) +// ParseDenomAndBlockFromKey returns the denom and block contained in the *key* +// that has a uint64 at the end with a null prefix (length 9). +func ParseDenomAndBlockFromKey(key []byte, prefix []byte) (string, uint64) { + return string(key[len(prefix) : len(key)-9]), binary.LittleEndian.Uint64(key[len(key)-8:]) } diff --git a/x/oracle/types/keys_test.go b/x/oracle/types/keys_test.go index 1555a15d07..ecfcd24a08 100644 --- a/x/oracle/types/keys_test.go +++ b/x/oracle/types/keys_test.go @@ -1,8 +1,6 @@ package types import ( - "encoding/binary" - "math" "testing" sdk "github.com/cosmos/cosmos-sdk/types" @@ -109,38 +107,32 @@ func TestKeyAggregateExchangeRateVote(t *testing.T) { } } -func TestUintWithNullPrefix(t *testing.T) { - expected := []byte{0} - num := make([]byte, 8) - binary.LittleEndian.PutUint64(num, math.MaxUint64) - expected = append(expected, num...) - - out := uintWithNullPrefix(math.MaxUint64) - require.Equal(t, expected, out) -} - -func TestParseBlockFromHistoricPriceKey(t *testing.T) { +func TestParseDenomAndBlockFromHistoricPriceKey(t *testing.T) { denom := "umee" blockNum := uint64(4567) key := KeyHistoricPrice(denom, blockNum) - parsedBlockNum := ParseBlockFromHistoricPriceKey(key) + parsedDenom, parsedBlockNum := ParseDenomAndBlockFromKey(key, KeyPrefixHistoricPrice) + require.Equal(t, denom, parsedDenom) require.Equal(t, blockNum, parsedBlockNum) } -func TestParseDenomFromHistoricPriceKey(t *testing.T) { +func TestParseDenomAndBlockFromMedianKey(t *testing.T) { denom := "umee" blockNum := uint64(4567) - key := KeyHistoricPrice(denom, blockNum) + key := KeyMedian(denom, blockNum) - parsedDenom := ParseDenomFromHistoricPriceKey(key) + parsedDenom, parsedBlockNum := ParseDenomAndBlockFromKey(key, KeyPrefixMedian) require.Equal(t, denom, parsedDenom) + require.Equal(t, blockNum, parsedBlockNum) } -func TestParseDenomFromMedianKey(t *testing.T) { +func TestParseDenomAndBlockFromMedianDeviationKey(t *testing.T) { denom := "umee" - key := KeyMedian(denom) + blockNum := uint64(4567) + key := KeyMedianDeviation(denom, blockNum) - parsedDenom := ParseDenomFromMedianKey(key) + parsedDenom, parsedBlockNum := ParseDenomAndBlockFromKey(key, KeyPrefixMedianDeviation) require.Equal(t, denom, parsedDenom) + require.Equal(t, blockNum, parsedBlockNum) } diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index b00bf40efd..982265d68a 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -34,20 +34,19 @@ type Params struct { SlashFraction github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction" yaml:"slash_fraction"` SlashWindow uint64 `protobuf:"varint,7,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"` MinValidPerWindow github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window" yaml:"min_valid_per_window"` - // Stamp Period represents the amount of blocks the historacle module - // waits before recording a set of prices from the oracle. - StampPeriod uint64 `protobuf:"varint,9,opt,name=stamp_period,json=stampPeriod,proto3" json:"stamp_period,omitempty"` - // Prune Period represents the maximum amount of blocks which we want - // to keep a record of our set of exchange rates. - PrunePeriod uint64 `protobuf:"varint,10,opt,name=prune_period,json=prunePeriod,proto3" json:"prune_period,omitempty"` - // Median Period represents the amount blocks we will wait between - // calculating the median and standard deviation of the median of - // historic prices in the last Prune Period. - MedianPeriod uint64 `protobuf:"varint,11,opt,name=median_period,json=medianPeriod,proto3" json:"median_period,omitempty"` - // Historic Asset List is a list of assets which will use the historic - // price stamping protection methodology (mainly manipulatable assets). - // Any assets not on this list will not be stamped. - HistoricAcceptList DenomList `protobuf:"bytes,12,rep,name=historic_accept_list,json=historicAcceptList,proto3,castrepeated=DenomList" json:"historic_accept_list"` + // Historic Stamp Period represents the amount of blocks the oracle + // module waits before recording a new historic price. + HistoricStampPeriod uint64 `protobuf:"varint,9,opt,name=historic_stamp_period,json=historicStampPeriod,proto3" json:"historic_stamp_period,omitempty"` + // Median Stamp Period represents the amount blocks the oracle module + // waits between calculating and stamping a new median and standard + // deviation of that median. + MedianStampPeriod uint64 `protobuf:"varint,10,opt,name=median_stamp_period,json=medianStampPeriod,proto3" json:"median_stamp_period,omitempty"` + // Maximum Price Stamps represents the maximum amount of historic prices + // the oracle module will store before pruning via FIFO. + MaximumPriceStamps uint64 `protobuf:"varint,11,opt,name=maximum_price_stamps,json=maximumPriceStamps,proto3" json:"maximum_price_stamps,omitempty"` + // Maximum Median Stamps represents the maximum amount of medians the + // oracle module will store before pruning via FIFO. + MaximumMedianStamps uint64 `protobuf:"varint,12,opt,name=maximum_median_stamps,json=maximumMedianStamps,proto3" json:"maximum_median_stamps,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -252,61 +251,61 @@ func init() { func init() { proto.RegisterFile("umee/oracle/v1/oracle.proto", fileDescriptor_8893c9e0e94ceb54) } var fileDescriptor_8893c9e0e94ceb54 = []byte{ - // 853 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xb6, 0x69, 0x92, 0x66, 0xc7, 0xde, 0x96, 0xb8, 0x1b, 0x30, 0x0d, 0x5a, 0x27, 0x53, 0x51, - 0x72, 0xe9, 0x5a, 0xa5, 0x48, 0x88, 0xdc, 0x6a, 0x85, 0x72, 0x29, 0x52, 0x64, 0x55, 0x45, 0xea, - 0xc5, 0x1a, 0xdb, 0xc3, 0xda, 0x8a, 0xed, 0xb1, 0x66, 0x66, 0x37, 0xc9, 0x85, 0x33, 0x27, 0xc4, - 0x91, 0x63, 0xce, 0xdc, 0x41, 0xfc, 0x09, 0x39, 0xe6, 0x88, 0x40, 0x32, 0x90, 0x5c, 0x38, 0xfb, - 0x2f, 0x40, 0xf3, 0xc3, 0x89, 0x37, 0x89, 0x10, 0x51, 0x4f, 0xeb, 0xf7, 0xbe, 0x6f, 0xde, 0xfb, - 0xde, 0x8f, 0x99, 0x05, 0x1b, 0xb3, 0x12, 0x63, 0x9f, 0x50, 0x94, 0x14, 0xd8, 0x9f, 0x3f, 0xd5, - 0x5f, 0x93, 0x9a, 0x12, 0x4e, 0x9c, 0x7b, 0x02, 0x9c, 0x68, 0xd7, 0xfc, 0xe9, 0xc3, 0xd1, 0x94, - 0x4c, 0x89, 0x84, 0x7c, 0xf1, 0xa5, 0x58, 0xf0, 0x8f, 0xbb, 0x60, 0x65, 0x0f, 0x51, 0x54, 0x32, - 0xe7, 0x33, 0x60, 0xcd, 0x09, 0xc7, 0x51, 0x8d, 0x69, 0x4e, 0x52, 0xd7, 0xdc, 0x34, 0xb7, 0x97, - 0x82, 0xf7, 0xda, 0xc6, 0x73, 0x8e, 0x50, 0x59, 0xec, 0xc0, 0x1e, 0x08, 0x43, 0x20, 0xac, 0x3d, - 0x69, 0x38, 0x15, 0xb8, 0x27, 0x31, 0x9e, 0x51, 0xcc, 0x32, 0x52, 0xa4, 0xee, 0x3b, 0x9b, 0xe6, - 0xf6, 0x20, 0xf8, 0xf2, 0xa4, 0xf1, 0x8c, 0xdf, 0x1b, 0xef, 0xf1, 0x34, 0xe7, 0xd9, 0x2c, 0x9e, - 0x24, 0xa4, 0xf4, 0x13, 0xc2, 0x4a, 0xc2, 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, 0x07, 0xfd, 0xf3, 0x5d, 0x67, - 0x2c, 0x69, 0xea, 0x66, 0x7c, 0x0b, 0x46, 0x65, 0x5e, 0x45, 0x73, 0x54, 0xe4, 0xa9, 0xd8, 0xb4, - 0x2e, 0xc6, 0xaa, 0x54, 0xfc, 0xd5, 0xad, 0x15, 0x6f, 0xa8, 0x8c, 0x37, 0xc5, 0x84, 0xe1, 0x5a, - 0x99, 0x57, 0xaf, 0x85, 0x77, 0x0f, 0x53, 0x9d, 0x7f, 0x0b, 0xd8, 0x8c, 0xa3, 0xb2, 0xee, 0xae, - 0xc0, 0x40, 0x68, 0x0f, 0x2d, 0xe9, 0xd3, 0xbb, 0xbe, 0x05, 0xec, 0x9a, 0xce, 0xaa, 0x8b, 0x5b, - 0x02, 0x14, 0x45, 0xfa, 0x34, 0xe5, 0x11, 0x18, 0x96, 0x38, 0xcd, 0x51, 0xd5, 0x71, 0x2c, 0xc9, - 0xb1, 0x95, 0x53, 0x93, 0xde, 0x80, 0x51, 0x96, 0x33, 0x4e, 0x68, 0x9e, 0x44, 0xfd, 0x05, 0xb0, - 0xff, 0x6b, 0x01, 0xd6, 0x44, 0x07, 0x16, 0x47, 0xed, 0x74, 0x51, 0x9e, 0x5f, 0x8c, 0x7c, 0x67, - 0xf5, 0xc7, 0x63, 0xcf, 0xf8, 0xe7, 0xd8, 0x33, 0xe1, 0xaf, 0x26, 0x58, 0x96, 0x5c, 0xe7, 0x53, - 0x00, 0x62, 0xc4, 0x70, 0x94, 0x0a, 0x4b, 0xde, 0xed, 0x41, 0xb0, 0xde, 0x36, 0xde, 0x9a, 0x6a, - 0xd1, 0x25, 0x06, 0xc3, 0x81, 0x30, 0xd4, 0x29, 0x31, 0xcc, 0xa3, 0x32, 0x26, 0x85, 0x3e, 0xa7, - 0xee, 0x75, 0x7f, 0x98, 0x3d, 0x54, 0x0c, 0x53, 0x9a, 0xea, 0xac, 0x0f, 0x56, 0xf1, 0x61, 0x4d, - 0x2a, 0x5c, 0x71,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 0xd8, 0xd9, 0x07, 0xc3, 0x05, 0xd9, 0x3a, - 0xf7, 0x8b, 0x5b, 0xdf, 0xef, 0xd1, 0x0d, 0x3d, 0x80, 0xa1, 0xdd, 0x2f, 0x73, 0x51, 0x78, 0xf0, - 0xf2, 0xe4, 0xef, 0xb1, 0x71, 0x72, 0x36, 0x36, 0x4f, 0xcf, 0xc6, 0xe6, 0x5f, 0x67, 0x63, 0xf3, - 0x87, 0xf3, 0xb1, 0x71, 0x7a, 0x3e, 0x36, 0x7e, 0x3b, 0x1f, 0x1b, 0x6f, 0x26, 0xbd, 0xcc, 0x62, - 0x10, 0x4f, 0x2a, 0xcc, 0x0f, 0x08, 0xdd, 0x97, 0x86, 0x3f, 0x7f, 0xe6, 0x1f, 0x76, 0x7f, 0xb6, - 0x52, 0x45, 0xbc, 0x22, 0xff, 0x43, 0x9f, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x66, 0xd1, - 0x0e, 0x88, 0x07, 0x00, 0x00, + // 863 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbf, 0x6f, 0xe4, 0x44, + 0x14, 0x5e, 0x73, 0x49, 0x2e, 0x3b, 0xbb, 0xb9, 0x23, 0xce, 0x06, 0xcc, 0x05, 0xad, 0x73, 0x83, + 0x38, 0xd2, 0xdc, 0x2e, 0x77, 0x87, 0x84, 0x48, 0x87, 0x15, 0x8e, 0xe6, 0x4e, 0x5a, 0x99, 0xd3, + 0x21, 0xd1, 0x58, 0x63, 0x7b, 0x58, 0x8f, 0x62, 0x7b, 0xac, 0x99, 0xd9, 0x4d, 0xd2, 0x50, 0x53, + 0x21, 0x4a, 0xca, 0xd4, 0xf4, 0x20, 0xfe, 0x84, 0x94, 0x57, 0x22, 0x0a, 0x03, 0x49, 0x43, 0xed, + 0xbf, 0x00, 0xcd, 0x0f, 0x27, 0xb3, 0xc9, 0x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3, 0xfb, 0xc5, 0xb0, 0xf3, 0xcd, 0xc8, 0xca, 0x2c, 0x07, 0xf1, 0xb8, 0xc4, 0xe2, 0x88, 0xb2, + 0x43, 0x65, 0x8c, 0xe7, 0xcf, 0xc6, 0xc7, 0xed, 0xff, 0xad, 0x52, 0x11, 0xaf, 0xa9, 0xbf, 0xd1, + 0x67, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xfa, 0xd8, 0xf3, 0x8b, 0x07, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -357,23 +356,18 @@ func (this *Params) Equal(that interface{}) bool { if !this.MinValidPerWindow.Equal(that1.MinValidPerWindow) { return false } - if this.StampPeriod != that1.StampPeriod { + if this.HistoricStampPeriod != that1.HistoricStampPeriod { return false } - if this.PrunePeriod != that1.PrunePeriod { + if this.MedianStampPeriod != that1.MedianStampPeriod { return false } - if this.MedianPeriod != that1.MedianPeriod { + if this.MaximumPriceStamps != that1.MaximumPriceStamps { return false } - if len(this.HistoricAcceptList) != len(that1.HistoricAcceptList) { + if this.MaximumMedianStamps != that1.MaximumMedianStamps { return false } - for i := range this.HistoricAcceptList { - if !this.HistoricAcceptList[i].Equal(&that1.HistoricAcceptList[i]) { - return false - } - } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -396,32 +390,23 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.HistoricAcceptList) > 0 { - for iNdEx := len(m.HistoricAcceptList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.HistoricAcceptList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintOracle(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - } + if m.MaximumMedianStamps != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaximumMedianStamps)) + i-- + dAtA[i] = 0x60 } - if m.MedianPeriod != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.MedianPeriod)) + if m.MaximumPriceStamps != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MaximumPriceStamps)) i-- dAtA[i] = 0x58 } - if m.PrunePeriod != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.PrunePeriod)) + if m.MedianStampPeriod != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.MedianStampPeriod)) i-- dAtA[i] = 0x50 } - if m.StampPeriod != 0 { - i = encodeVarintOracle(dAtA, i, uint64(m.StampPeriod)) + if m.HistoricStampPeriod != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.HistoricStampPeriod)) i-- dAtA[i] = 0x48 } @@ -705,20 +690,17 @@ func (m *Params) Size() (n int) { } l = m.MinValidPerWindow.Size() n += 1 + l + sovOracle(uint64(l)) - if m.StampPeriod != 0 { - n += 1 + sovOracle(uint64(m.StampPeriod)) + if m.HistoricStampPeriod != 0 { + n += 1 + sovOracle(uint64(m.HistoricStampPeriod)) } - if m.PrunePeriod != 0 { - n += 1 + sovOracle(uint64(m.PrunePeriod)) + if m.MedianStampPeriod != 0 { + n += 1 + sovOracle(uint64(m.MedianStampPeriod)) } - if m.MedianPeriod != 0 { - n += 1 + sovOracle(uint64(m.MedianPeriod)) + if m.MaximumPriceStamps != 0 { + n += 1 + sovOracle(uint64(m.MaximumPriceStamps)) } - if len(m.HistoricAcceptList) > 0 { - for _, e := range m.HistoricAcceptList { - l = e.Size() - n += 1 + l + sovOracle(uint64(l)) - } + if m.MaximumMedianStamps != 0 { + n += 1 + sovOracle(uint64(m.MaximumMedianStamps)) } return n } @@ -1061,9 +1043,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 9: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StampPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field HistoricStampPeriod", wireType) } - m.StampPeriod = 0 + m.HistoricStampPeriod = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOracle @@ -1073,16 +1055,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StampPeriod |= uint64(b&0x7F) << shift + m.HistoricStampPeriod |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 10: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PrunePeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MedianStampPeriod", wireType) } - m.PrunePeriod = 0 + m.MedianStampPeriod = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOracle @@ -1092,16 +1074,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PrunePeriod |= uint64(b&0x7F) << shift + m.MedianStampPeriod |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 11: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MedianPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaximumPriceStamps", wireType) } - m.MedianPeriod = 0 + m.MaximumPriceStamps = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOracle @@ -1111,16 +1093,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MedianPeriod |= uint64(b&0x7F) << shift + m.MaximumPriceStamps |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HistoricAcceptList", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaximumMedianStamps", wireType) } - var msglen int + m.MaximumMedianStamps = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOracle @@ -1130,26 +1112,11 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.MaximumMedianStamps |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthOracle - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthOracle - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.HistoricAcceptList = append(m.HistoricAcceptList, Denom{}) - if err := m.HistoricAcceptList[len(m.HistoricAcceptList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOracle(dAtA[iNdEx:]) diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index e31284f3af..14cd96f71f 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -18,10 +18,10 @@ var ( KeySlashFraction = []byte("SlashFraction") KeySlashWindow = []byte("SlashWindow") KeyMinValidPerWindow = []byte("MinValidPerWindow") - KeyHistoricAcceptList = []byte("HistoricAcceptList") - KeyStampPeriod = []byte("StampPeriod") - KeyPrunePeriod = []byte("PrunePeriod") - KeyMedianPeriod = []byte("MedianPeriod") + KeyHistoricStampPeriod = []byte("HistoricStampPeriod") + KeyMedianStampPeriod = []byte("MedianStampPeriod") + KeyMaximumPriceStamps = []byte("MaximumPriceStamps") + KeyMaximumMedianStamps = []byte("MedianStampAmount") ) // Default parameter values @@ -29,9 +29,10 @@ const ( DefaultVotePeriod = BlocksPerMinute / 2 // 30 seconds DefaultSlashWindow = BlocksPerWeek // window for a week DefaultRewardDistributionWindow = BlocksPerYear // window for a year - DefaultStampPeriod = BlocksPerHour / 2 // window for 30 minutes - DefaultPrunePeriod = BlocksPerMonth // window for a month - DefaultMedianPeriod = BlocksPerDay // window for a day + DefaultHistoricStampPeriod = BlocksPerHour / 2 // window for 30 minutes + DefaultMedianStampPeriod = BlocksPerHour * 6 // window for 6 hours + DefaultMaximumPriceStamps = 12 // pruning window of 6 hours + DefaultMaximumMedianStamps = 28 // pruning window of 1 week ) // Default parameter values @@ -50,9 +51,8 @@ var ( Exponent: AtomExponent, }, } - DefaultSlashFraction = sdk.NewDecWithPrec(1, 4) // 0.01% - DefaultMinValidPerWindow = sdk.NewDecWithPrec(5, 2) // 5% - DefaultHistoricAcceptList = DenomList(nil) + DefaultSlashFraction = sdk.NewDecWithPrec(1, 4) // 0.01% + DefaultMinValidPerWindow = sdk.NewDecWithPrec(5, 2) // 5% ) var _ paramstypes.ParamSet = &Params{} @@ -68,10 +68,10 @@ func DefaultParams() Params { SlashFraction: DefaultSlashFraction, SlashWindow: DefaultSlashWindow, MinValidPerWindow: DefaultMinValidPerWindow, - HistoricAcceptList: DefaultHistoricAcceptList, - StampPeriod: DefaultStampPeriod, - PrunePeriod: DefaultPrunePeriod, - MedianPeriod: DefaultMedianPeriod, + HistoricStampPeriod: DefaultHistoricStampPeriod, + MedianStampPeriod: DefaultMedianStampPeriod, + MaximumPriceStamps: DefaultMaximumPriceStamps, + MaximumMedianStamps: DefaultMaximumMedianStamps, } } @@ -125,24 +125,24 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { validateMinValidPerWindow, ), paramstypes.NewParamSetPair( - KeyHistoricAcceptList, - &p.HistoricAcceptList, - validateHistoricAcceptList, + KeyHistoricStampPeriod, + &p.HistoricStampPeriod, + validateHistoricStampPeriod, ), paramstypes.NewParamSetPair( - KeyStampPeriod, - &p.StampPeriod, - validateStampPeriod, + KeyMedianStampPeriod, + &p.MedianStampPeriod, + validateMedianStampPeriod, ), paramstypes.NewParamSetPair( - KeyPrunePeriod, - &p.PrunePeriod, - validatePrunePeriod, + KeyMaximumPriceStamps, + &p.MaximumPriceStamps, + validateMaximumPriceStamps, ), paramstypes.NewParamSetPair( - KeyMedianPeriod, - &p.MedianPeriod, - validateMedianPeriod, + KeyMaximumMedianStamps, + &p.MaximumMedianStamps, + validateMaximumMedianStamps, ), } } @@ -182,20 +182,12 @@ func (p Params) Validate() error { return fmt.Errorf("oracle parameter MinValidPerWindow must be between [0, 1]") } - if p.PrunePeriod < p.StampPeriod { - return fmt.Errorf("oracle parameter PrunePeriod must be greater than or equal with StampPeriod") + if p.HistoricStampPeriod > p.MedianStampPeriod { + return fmt.Errorf("oracle parameter MedianStampPeriod must be greater than or equal with HistoricStampPeriod") } - if p.PrunePeriod < p.MedianPeriod { - return fmt.Errorf("oracle parameter PrunePeriod must be greater than or equal with MedianPeriod") - } - - if p.MedianPeriod < p.StampPeriod { - return fmt.Errorf("oracle parameter MedianPeriod must be greater than or equal with StampPeriod") - } - - if p.StampPeriod%p.VotePeriod != 0 || p.MedianPeriod%p.VotePeriod != 0 || p.PrunePeriod%p.VotePeriod != 0 { - return fmt.Errorf("oracle parameters StampPeriod, MedianPeriod, and PrunePeriod must be exact multiples of VotePeiod") + if p.HistoricStampPeriod%p.VotePeriod != 0 || p.MedianStampPeriod%p.VotePeriod != 0 { + return fmt.Errorf("oracle parameters HistoricStampPeriod and MedianStampPeriod must be exact multiples of VotePeiod") } for _, denom := range p.AcceptList { @@ -207,15 +199,6 @@ func (p Params) Validate() error { } } - for _, denom := range p.HistoricAcceptList { - if len(denom.BaseDenom) == 0 { - return fmt.Errorf("oracle parameter HistoricAcceptList Denom must have BaseDenom") - } - if len(denom.SymbolDenom) == 0 { - return fmt.Errorf("oracle parameter HistoricAcceptList Denom must have SymbolDenom") - } - } - return nil } @@ -344,58 +327,53 @@ func validateMinValidPerWindow(i interface{}) error { return nil } -func validateHistoricAcceptList(i interface{}) error { - v, ok := i.(DenomList) +func validateHistoricStampPeriod(i interface{}) error { + v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - for _, d := range v { - if len(d.BaseDenom) == 0 { - return fmt.Errorf("oracle parameter HistoricAcceptList Denom must have BaseDenom") - } - if len(d.SymbolDenom) == 0 { - return fmt.Errorf("oracle parameter HistoricAcceptList Denom must have SymbolDenom") - } + if v < 1 { + return fmt.Errorf("historic stamp period must be positive: %d", v) } return nil } -func validateStampPeriod(i interface{}) error { +func validateMedianStampPeriod(i interface{}) error { v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v < 1 { - return fmt.Errorf("stamp period must be positive: %d", v) + return fmt.Errorf("median stamp period must be positive: %d", v) } return nil } -func validatePrunePeriod(i interface{}) error { +func validateMaximumPriceStamps(i interface{}) error { v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v < 1 { - return fmt.Errorf("prune period must be positive: %d", v) + return fmt.Errorf("maximum price stamps must be positive: %d", v) } return nil } -func validateMedianPeriod(i interface{}) error { +func validateMaximumMedianStamps(i interface{}) error { v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } if v < 1 { - return fmt.Errorf("median period must be positive: %d", v) + return fmt.Errorf("maximum median stamps must be positive: %d", v) } return nil diff --git a/x/oracle/types/params_test.go b/x/oracle/types/params_test.go index 2f37ae28f0..d6505fb78f 100644 --- a/x/oracle/types/params_test.go +++ b/x/oracle/types/params_test.go @@ -121,56 +121,47 @@ func TestValidateMinValidPerWindow(t *testing.T) { require.Nil(t, err) } -func TestValidateHistoricAcceptList(t *testing.T) { - err := validateHistoricAcceptList("invalidUint64") +func TestValidateHistoricStampPeriod(t *testing.T) { + err := validateHistoricStampPeriod("invalidUint64") require.ErrorContains(t, err, "invalid parameter type: string") - err = validateHistoricAcceptList(DenomList{ - {BaseDenom: ""}, - }) - require.ErrorContains(t, err, "oracle parameter HistoricAcceptList Denom must have BaseDenom") - - err = validateHistoricAcceptList(DenomList{ - {BaseDenom: DenomUmee.BaseDenom, SymbolDenom: ""}, - }) - require.ErrorContains(t, err, "oracle parameter HistoricAcceptList Denom must have SymbolDenom") + err = validateHistoricStampPeriod(uint64(0)) + require.ErrorContains(t, err, "historic stamp period must be positive: 0") - err = validateHistoricAcceptList(DenomList{ - {BaseDenom: DenomUmee.BaseDenom, SymbolDenom: DenomUmee.SymbolDenom}, - }) + err = validateHistoricStampPeriod(uint64(10)) require.Nil(t, err) } -func TestValidateStampPeriod(t *testing.T) { - err := validateStampPeriod("invalidUint64") +func TestValidateMedianStampPeriod(t *testing.T) { + err := validateMedianStampPeriod("invalidUint64") require.ErrorContains(t, err, "invalid parameter type: string") - err = validateStampPeriod(uint64(0)) - require.ErrorContains(t, err, "stamp period must be positive: 0") + err = validateMedianStampPeriod(uint64(0)) + require.ErrorContains(t, err, "median stamp period must be positive: 0") - err = validateStampPeriod(uint64(10)) + err = validateMedianStampPeriod(uint64(10)) require.Nil(t, err) } -func TestValidatePrunePeriod(t *testing.T) { - err := validatePrunePeriod("invalidUint64") +func TestValidateMaximumPriceStamps(t *testing.T) { + err := validateMaximumPriceStamps("invalidUint64") require.ErrorContains(t, err, "invalid parameter type: string") - err = validatePrunePeriod(uint64(0)) - require.ErrorContains(t, err, "prune period must be positive: 0") + err = validateMaximumPriceStamps(uint64(0)) + require.ErrorContains(t, err, "maximum price stamps must be positive: 0") - err = validatePrunePeriod(uint64(10)) + err = validateMaximumPriceStamps(uint64(10)) require.Nil(t, err) } -func TestValidateMedianPeriod(t *testing.T) { - err := validateMedianPeriod("invalidUint64") +func TestValidateMaximumMedianStamps(t *testing.T) { + err := validateMaximumMedianStamps("invalidUint64") require.ErrorContains(t, err, "invalid parameter type: string") - err = validateMedianPeriod(uint64(0)) - require.ErrorContains(t, err, "median period must be positive: 0") + err = validateMaximumMedianStamps(uint64(0)) + require.ErrorContains(t, err, "maximum median stamps must be positive: 0") - err = validateMedianPeriod(uint64(10)) + err = validateMaximumMedianStamps(uint64(10)) require.Nil(t, err) } @@ -220,55 +211,38 @@ func TestParamsEqual(t *testing.T) { err = p7.Validate() require.Error(t, err) - // PrunePeriod < StampPeriod + // HistoricStampPeriod < MedianStampPeriod p8 := DefaultParams() - p8.StampPeriod = 10 - p8.PrunePeriod = 1 + p8.HistoricStampPeriod = 10 + p8.MedianStampPeriod = 1 err = p8.Validate() require.Error(t, err) - // PrunePeriod < MedianPeriod + // HistoricStampPeriod and MedianStampPeriod are multiples of VotePeriod p9 := DefaultParams() - p9.MedianPeriod = 10 - p9.PrunePeriod = 1 + p9.HistoricStampPeriod = 10 + p9.VotePeriod = 3 + err = p9.Validate() + require.Error(t, err) + p9.MedianStampPeriod = 10 err = p9.Validate() require.Error(t, err) - // MedianPeriod < StampPeriod + // empty name p10 := DefaultParams() - p10.StampPeriod = 10 - p10.MedianPeriod = 1 + p10.AcceptList[0].BaseDenom = "" + p10.AcceptList[0].SymbolDenom = "ATOM" err = p10.Validate() require.Error(t, err) - // StampPeriod, MedianPeriod, PrunePeriod are multiples of VotePeriod + // empty p11 := DefaultParams() - p11.StampPeriod = 10 - p11.VotePeriod = 3 + p11.AcceptList[0].BaseDenom = "uatom" + p11.AcceptList[0].SymbolDenom = "" err = p11.Validate() require.Error(t, err) - p11.MedianPeriod = 10 - err = p11.Validate() - require.Error(t, err) - p11.PrunePeriod = 10 - err = p11.Validate() - require.Error(t, err) - - // empty name - p12 := DefaultParams() - p12.AcceptList[0].BaseDenom = "" - p12.AcceptList[0].SymbolDenom = "ATOM" - err = p12.Validate() - require.Error(t, err) - // empty p13 := DefaultParams() - p13.AcceptList[0].BaseDenom = "uatom" - p13.AcceptList[0].SymbolDenom = "" - err = p13.Validate() - require.Error(t, err) - - p14 := DefaultParams() - require.NotNil(t, p14.ParamSetPairs()) - require.NotNil(t, p14.String()) + require.NotNil(t, p13.ParamSetPairs()) + require.NotNil(t, p13.String()) }