diff --git a/Makefile b/Makefile index b97d2910a..64b9e9f64 100644 --- a/Makefile +++ b/Makefile @@ -313,7 +313,7 @@ test-race: ARGS=-race test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION) $(TEST_TARGETS): run-tests -test-unit-cover: ARGS=-timeout=15m -coverprofile=cover.out -covermode=atomic +test-unit-cover: ARGS=-timeout=15m -coverprofile=cover.out -covermode=atomic -gcflags=all=-l test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT) test-e2e: diff --git a/app/app.go b/app/app.go index 85b4ca57e..593ad0402 100644 --- a/app/app.go +++ b/app/app.go @@ -14,6 +14,10 @@ import ( avsTaskKeeper "github.com/ExocoreNetwork/exocore/x/avstask/keeper" avsTaskTypes "github.com/ExocoreNetwork/exocore/x/avstask/types" + "github.com/ExocoreNetwork/exocore/x/oracle" + oracleKeeper "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + oracleTypes "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/ExocoreNetwork/exocore/x/avs" "github.com/ExocoreNetwork/exocore/x/operator" operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" @@ -279,6 +283,7 @@ var ( exoslash.AppModuleBasic{}, avs.AppModuleBasic{}, avstask.AppModuleBasic{}, + oracle.AppModuleBasic{}, ) // module account permissions @@ -364,6 +369,8 @@ type ExocoreApp struct { ExoSlashKeeper slashKeeper.Keeper AVSManagerKeeper avsManagerKeeper.Keeper TaskKeeper avsTaskKeeper.Keeper + OracleKeeper oracleKeeper.Keeper + // the module manager mm *module.Manager @@ -448,15 +455,11 @@ func NewExocoreApp( operatorTypes.StoreKey, avsManagerTypes.StoreKey, avsTaskTypes.StoreKey, + oracleTypes.StoreKey, ) - // Add the EVM transient store key - tkeys := sdk.NewTransientStoreKeys( - paramstypes.TStoreKey, - evmtypes.TransientKey, - feemarkettypes.TransientKey, - ) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) + memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, oracleTypes.MemStoreKey) // load state streaming if enabled if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, logger, keys); err != nil { @@ -666,6 +669,7 @@ func NewExocoreApp( app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.AssetsKeeper) app.AVSManagerKeeper = *avsManagerKeeper.NewKeeper(appCodec, keys[avsManagerTypes.StoreKey], &app.OperatorKeeper, app.AssetsKeeper) app.TaskKeeper = avsTaskKeeper.NewKeeper(appCodec, keys[avsTaskTypes.StoreKey], app.AVSManagerKeeper) + app.OracleKeeper = oracleKeeper.NewKeeper(appCodec, keys[oracleTypes.StoreKey], memKeys[oracleTypes.MemStoreKey], app.GetSubspace(oracleTypes.ModuleName), app.StakingKeeper) // We call this after setting the hooks to ensure that the hooks are set on the keeper evmKeeper.WithPrecompiles( evmkeeper.AvailablePrecompiles( @@ -855,6 +859,7 @@ func NewExocoreApp( exoslash.NewAppModule(appCodec, app.ExoSlashKeeper), avs.NewAppModule(appCodec, app.AVSManagerKeeper), avstask.NewAppModule(appCodec, app.TaskKeeper), + oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), ) // During begin block slashing happens after reward.BeginBlocker so that @@ -900,6 +905,7 @@ func NewExocoreApp( exoslashTypes.ModuleName, avsManagerTypes.ModuleName, avsTaskTypes.ModuleName, + oracleTypes.ModuleName, ) // NOTE: fee market module must go last in order to retrieve the block gas used. @@ -940,6 +946,7 @@ func NewExocoreApp( exoslashTypes.ModuleName, avsManagerTypes.ModuleName, avsTaskTypes.ModuleName, + oracleTypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -977,6 +984,8 @@ func NewExocoreApp( withdrawTypes.ModuleName, rewardTypes.ModuleName, exoslashTypes.ModuleName, + // no particular order required + oracleTypes.ModuleName, // Evmos modules erc20types.ModuleName, epochstypes.ModuleName, @@ -1338,9 +1347,8 @@ func initParamsKeeper( paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) // ethermint subspaces - paramsKeeper.Subspace(evmtypes.ModuleName). - // nolint: staticcheck - WithKeyTable(evmtypes.ParamKeyTable()) + paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(oracleTypes.ModuleName).WithKeyTable(oracleTypes.ParamKeyTable()) return paramsKeeper } diff --git a/go.mod b/go.mod index 03a7c436f..1fe1686e8 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( cosmossdk.io/math v1.0.1 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d cosmossdk.io/tools/rosetta v0.2.1 + github.com/agiledragon/gomonkey/v2 v2.11.0 github.com/armon/go-metrics v0.4.1 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.8.0 @@ -21,16 +22,19 @@ require ( github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/onsi/ginkgo/v2 v2.15.0 github.com/onsi/gomega v1.31.1 github.com/pkg/errors v0.9.1 github.com/prysmaticlabs/prysm/v4 v4.2.1 github.com/rakyll/statik v0.1.7 + github.com/smartystreets/goconvey v1.6.4 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 go.opencensus.io v0.24.0 + go.uber.org/mock v0.4.0 golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 @@ -104,6 +108,7 @@ require ( github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect @@ -125,6 +130,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect + github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect @@ -146,6 +152,7 @@ require ( github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect + github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/klauspost/compress v1.17.2 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/lib/pq v1.10.9 // indirect @@ -183,6 +190,7 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.0 // indirect + github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect github.com/spf13/afero v1.10.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/go.sum b/go.sum index 4c31f8aa6..e5fe3ab9c 100644 --- a/go.sum +++ b/go.sum @@ -565,6 +565,8 @@ github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/agiledragon/gomonkey/v2 v2.11.0 h1:5oxSgA+tC1xuGsrIorR+sYiziYltmJyEZ9qA25b6l5U= +github.com/agiledragon/gomonkey/v2 v2.11.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -843,6 +845,7 @@ github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -1047,6 +1050,7 @@ github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cU github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= 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 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= @@ -1068,6 +1072,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= @@ -1166,6 +1171,7 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= @@ -1448,7 +1454,9 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= @@ -1585,6 +1593,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/proto/exocore/oracle/genesis.proto b/proto/exocore/oracle/genesis.proto new file mode 100644 index 000000000..ea3241169 --- /dev/null +++ b/proto/exocore/oracle/genesis.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package exocore.oracle; + +import "exocore/oracle/index_recent_msg.proto"; +import "exocore/oracle/index_recent_params.proto"; +import "exocore/oracle/params.proto"; +import "exocore/oracle/prices.proto"; +import "exocore/oracle/recent_msg.proto"; +import "exocore/oracle/recent_params.proto"; +import "exocore/oracle/validator_update_block.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// GenesisState defines the oracle module's genesis state. +message GenesisState { + // module params + Params params = 1 [(gogoproto.nullable) = false]; + // prices of all tokens + repeated Prices prices_list = 2 [(gogoproto.nullable) = false]; + + //TODO: userDefinedTokenFeeder + // latest block on which the validator set be updated + ValidatorUpdateBlock validator_update_block = 3; + // index for the cached recent params + IndexRecentParams index_recent_params = 4; + // index for the cached recent messages + IndexRecentMsg index_recent_msg = 5; + // cached recent messages + repeated RecentMsg recent_msg_list = 6 [(gogoproto.nullable) = false]; + // cached recent params + repeated RecentParams recent_params_list = 7 [(gogoproto.nullable) = false]; +} + diff --git a/proto/exocore/oracle/index_recent_msg.proto b/proto/exocore/oracle/index_recent_msg.proto new file mode 100644 index 000000000..e83909960 --- /dev/null +++ b/proto/exocore/oracle/index_recent_msg.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package exocore.oracle; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// index for the cached recent messages +message IndexRecentMsg { + // index list + repeated uint64 index = 1; +} diff --git a/proto/exocore/oracle/index_recent_params.proto b/proto/exocore/oracle/index_recent_params.proto new file mode 100644 index 000000000..a5505210c --- /dev/null +++ b/proto/exocore/oracle/index_recent_params.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package exocore.oracle; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// index for the cached recent params +message IndexRecentParams { + // index list + repeated uint64 index = 1; +} diff --git a/proto/exocore/oracle/info.proto b/proto/exocore/oracle/info.proto new file mode 100644 index 000000000..f3ddcb875 --- /dev/null +++ b/proto/exocore/oracle/info.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package exocore.oracle; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// Chain represents for the Chain on which token contracts deployed +message Chain{ + //eg."bitcoin" + string name = 1; + //TODO: metadata + string desc = 2; +} + +// Token represents the token info +message Token{ + // token name + string name = 1; + //id refer to chainList's index + uint64 chain_id = 2 [(gogoproto.customname) = "ChainID"]; + //if any, like erc20 tokens + string contract_address = 3; + // decimal of token price + int32 decimal = 4; + //set false when we stop official price oracle service for a specified token + bool active = 5; +} + +// Endpoint tells where to fetch the price info +message Endpoint{ + //url int refer to TokenList.ID, 0 reprents default for all (as fall back) + //key refer to tokenID, 1->"https://chainlink.../eth" + map offchain = 1; + //url int refer to TokenList.ID, 0 reprents default for all (as fall back) + //key refer to tokenID, 1->"eth://0xabc...def" + map onchain = 2; +} + +// Source represents price data source +message Source { + // name of price source, like 'chainlink' + string name = 1; + // endpoint of corresponding source to fetch price data from + Endpoint entry = 2; + //set false when the source is out of service or reject to accept this source for official service + bool valid = 3; + // if this source is deteministic or not + bool deterministic = 4; +} diff --git a/proto/exocore/oracle/params.proto b/proto/exocore/oracle/params.proto new file mode 100644 index 000000000..d2c4a3f95 --- /dev/null +++ b/proto/exocore/oracle/params.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package exocore.oracle; + +import "exocore/oracle/info.proto"; +import "exocore/oracle/token_feeder.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + // chains represents the blockchains info + repeated Chain chains = 1; + // tokens info + repeated Token tokens = 2; + // sources info from where the price data would be fetched + repeated Source sources = 3; + // rules specified on how to decide the provided price source to be accept + repeated RuleSource rules = 4; + // each tokenFeeder represents an active token whose price being updated + repeated TokenFeeder token_feeders = 5; +} diff --git a/proto/exocore/oracle/price.proto b/proto/exocore/oracle/price.proto new file mode 100644 index 000000000..86bec1247 --- /dev/null +++ b/proto/exocore/oracle/price.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package exocore.oracle; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// token price with timestamp fetched from source +// {price:"12345",decimal:"2"}->price: 123.45 usdt +message PriceTimeDetID { + // price at a specific point(timestamp of non-deterministic source, roundId of deteministic source) + string price = 1; + // decimal of the corresponding price + int32 decimal = 2; + // timestamp when the price corresponding to + string timestamp = 3; + // det_id is used for deterministic source to tell of which round from this source the price is corresponded + string det_id = 4 [(gogoproto.customname) = "DetID"]; +} + +// price with its corresponding source +message PriceSource{ + // source_id refers to id from Params.SourceList, where this price fetched from, 0 is reserved for custom usage + uint64 source_id = 1 [(gogoproto.customname) = "SourceID"]; + //if source is deteministic like chainlink with roundID, set this value with which returned from source + //up to 3 values in case of the async of network, to give more time for oracle nodes(validators) get into consensus + //eg.with deterministic source, this array will contian 3 continuous values up to latest + //for non-deterministic source, it's a choice by v2 rules. + repeated PriceTimeDetID prices = 2; + //used for 0-sourceID-customDefinedSource + string desc = 3; +} + +// price with its specified timestamp and roundid(if from deteministic source) +message PriceTimeRound { + // price + string price = 1; + // decimal of the corresponding price + int32 decimal = 2; + // timestamp when the price is corresponded + string timestamp = 3; + // roundid of the price if the source is deteministic + uint64 round_id = 4 [(gogoproto.customname) = "RoundID"]; +} diff --git a/proto/exocore/oracle/prices.proto b/proto/exocore/oracle/prices.proto new file mode 100644 index 000000000..8fed04fc7 --- /dev/null +++ b/proto/exocore/oracle/prices.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package exocore.oracle; + +import "exocore/oracle/price.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// prices of all rounds of a specific token +message Prices { + // for which token these prices are + uint64 token_id = 1 [(gogoproto.customname) = "TokenID"]; + // next round id of the price to be updated + uint64 next_round_id = 2 [(gogoproto.customname) = "NextRoundID"]; + // price list of all history round prices for the token + repeated PriceTimeRound price_list = 3; +} diff --git a/proto/exocore/oracle/query.proto b/proto/exocore/oracle/query.proto new file mode 100644 index 000000000..f9c5b76b1 --- /dev/null +++ b/proto/exocore/oracle/query.proto @@ -0,0 +1,193 @@ +syntax = "proto3"; + +package exocore.oracle; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "exocore/oracle/index_recent_msg.proto"; +import "exocore/oracle/index_recent_params.proto"; +import "exocore/oracle/params.proto"; +import "exocore/oracle/prices.proto"; +import "exocore/oracle/recent_msg.proto"; +import "exocore/oracle/recent_params.proto"; +import "exocore/oracle/validator_update_block.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// Query defines the gRPC querier service. +service Query { + + // Parameters queries the parameters of the module. + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/params"; + + } + + // Queries a list of Prices items. + rpc Prices (QueryGetPricesRequest) returns (QueryGetPricesResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/prices/{token_id}"; + + } + // rpc PricesAll (QueryAllPricesRequest) returns (QueryAllPricesResponse) { + // option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/prices"; + // + // } + + // Queries a ValidatorUpdateBlock by index. + rpc ValidatorUpdateBlock (QueryGetValidatorUpdateBlockRequest) returns (QueryGetValidatorUpdateBlockResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/validator_update_block"; + + } + + // Queries a IndexRecentParams by index. + rpc IndexRecentParams (QueryGetIndexRecentParamsRequest) returns (QueryGetIndexRecentParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/index_recent_params"; + + } + + // Queries a IndexRecentMsg by index. + rpc IndexRecentMsg (QueryGetIndexRecentMsgRequest) returns (QueryGetIndexRecentMsgResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/index_recent_msg"; + + } + + // Queries a list of RecentMsg items. + rpc RecentMsg (QueryGetRecentMsgRequest) returns (QueryGetRecentMsgResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/recent_msg/{block}"; + + } + + // RecentMsgAll all RecentMsg items. + rpc RecentMsgAll (QueryAllRecentMsgRequest) returns (QueryAllRecentMsgResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/recent_msg"; + + } + + // Queries a list of RecentParams items. + rpc RecentParams (QueryGetRecentParamsRequest) returns (QueryGetRecentParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/recent_params/{block}"; + + } + + // RecentParamsAll query all RecentParams. + rpc RecentParamsAll (QueryAllRecentParamsRequest) returns (QueryAllRecentParamsResponse) { + option (google.api.http).get = "/ExocoreNetwork/exocore/oracle/recent_params"; + + } +} +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryGetPricesRequest is request type for all prices of a specific token +message QueryGetPricesRequest { + // token_id represents which token's price will be retrieved + uint64 token_id = 1; //[(gogoproto.customname) = "TokenID"]; +} + +// QueryGetPricesResponse +message QueryGetPricesResponse { + // prices returned prices + Prices prices = 1 [(gogoproto.nullable) = false]; +} + +// QueryAllPricesRequest +message QueryAllPricesRequest { + // info of the pagination + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllPricesResponse +message QueryAllPricesResponse { + // prices retreived + repeated Prices prices = 1 [(gogoproto.nullable) = false]; + // info of the pagination + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGetValidatorUpdateBlockRequest +message QueryGetValidatorUpdateBlockRequest {} + +//QueryGetValidatorUpdateBlockResponse +message QueryGetValidatorUpdateBlockResponse { + // ValidatorUpdateBlock tells the latest block on which the valdiator set was updated + ValidatorUpdateBlock validator_update_block = 1 [(gogoproto.nullable) = false]; +} + +// QueryGetIndexRecentParamsRequest +message QueryGetIndexRecentParamsRequest {} + +// QueryGetIndexRecentParamsResponse +message QueryGetIndexRecentParamsResponse { + // index_recent_params index of cached recent params + IndexRecentParams index_recent_params = 1 [(gogoproto.nullable) = false]; +} + +// QueryGetIndexRecentMsgReque +message QueryGetIndexRecentMsgRequest {} + +// QueryIndexRecentMsgResponse +message QueryGetIndexRecentMsgResponse { + // index_recent_msg index of cached recent messages + IndexRecentMsg index_recent_msg = 1 [(gogoproto.nullable) = false]; +} + +// QueryGetRecentMsgRequest +message QueryGetRecentMsgRequest { + // block represents of which block the cached message query for + uint64 block = 1; +} + +// QueryGetRecentMsgResponse +message QueryGetRecentMsgResponse { + // cached recent message + RecentMsg recent_msg = 1 [(gogoproto.nullable) = false]; +} + +// QueryAllRecentMsgRequest +message QueryAllRecentMsgRequest { + // info of pagination + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllRecentMsgResponse +message QueryAllRecentMsgResponse { + // recent_msg represets the cached recent message + repeated RecentMsg recent_msg = 1 [(gogoproto.nullable) = false]; + // info of pagination + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGetRecentParamsRequest +message QueryGetRecentParamsRequest { + // block represents of which block the cached params from + uint64 block = 1; +} + +// QueryGetRecentParamsResponse +message QueryGetRecentParamsResponse { + // recent_params cached recent params + RecentParams recent_params = 1 [(gogoproto.nullable) = false]; +} + +// QueryAllRecentParamsRequest +message QueryAllRecentParamsRequest { + // info of pagination + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllRecentParamsResponse +message QueryAllRecentParamsResponse { + // recent_params cached recent params + repeated RecentParams recent_params = 1 [(gogoproto.nullable) = false]; + // info of pagination + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + diff --git a/proto/exocore/oracle/recent_msg.proto b/proto/exocore/oracle/recent_msg.proto new file mode 100644 index 000000000..aa38d795f --- /dev/null +++ b/proto/exocore/oracle/recent_msg.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package exocore.oracle; + +import "exocore/oracle/price.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// RecentMsg represent the messages to be cached for recent blocks +message RecentMsg { + // block height these messages from + uint64 block = 1; + // cached messages + repeated MsgItem msgs = 2; +} + +// MsgItem represents the message info of createPrice +message MsgItem{ + // feeder_id tells of wich feeder this price if corresponding to + uint64 feeder_id = 2 [(gogoproto.customname) = "FeederID"]; + // p_source price with its source info + repeated PriceSource p_sources = 3; + // validator tells which validator create this price + string validator = 4; +} + + + diff --git a/proto/exocore/oracle/recent_params.proto b/proto/exocore/oracle/recent_params.proto new file mode 100644 index 000000000..683e5aeba --- /dev/null +++ b/proto/exocore/oracle/recent_params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package exocore.oracle; + +import "exocore/oracle/params.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// RecentParams represents the params cached for recent blocks +message RecentParams { + // block height of which the params from + uint64 block = 1; + // params the module params + Params params = 2; +} + diff --git a/proto/exocore/oracle/token_feeder.proto b/proto/exocore/oracle/token_feeder.proto new file mode 100644 index 000000000..c62206e28 --- /dev/null +++ b/proto/exocore/oracle/token_feeder.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; +package exocore.oracle; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +//n out of m required source +message NOMSource{ + //required source set, refer to params.sourceList, 1st set to 0 means all valid sources + repeated uint64 source_ids = 1 [(gogoproto.customname) = "SourceIDs"]; + //minimum number from the required sources to be fullfiled + uint64 minimum = 2; +} + +//specify data from which source is needed +//rule_1: specified sources +//rule_2: n out of total sources are required +message RuleSource{ + //refer to params.sourceList.ID, when length>0, ignore the other field, when 1st set to 0, means all valid sources, + // length==0->check next field:minimum + repeated uint64 source_ids = 1 [(gogoproto.customname) = "SourceIDs"]; + //n out of total sources are required + NOMSource nom = 2; +} + +//Tokenfeeder represents a price oracle for one token +message TokenFeeder{ + //refer to params.tokenList, from 1 + uint64 token_id = 1 [(gogoproto.customname) = "TokenID"]; + //refer to params.ruleList, 0 means no restriction, accept any source including customer defined + uint64 rule_id = 2 [(gogoproto.customname) = "RuleID"]; + //include, from 1, when some token's feeder had been stop and then restart, + // the token_id will be continuous from previous one + uint64 start_round_id = 3 [(gogoproto.customname) = "StartRoundID"]; + //include, first block which start_round_id can be settled is at least start_base_block+1 + uint64 start_base_block = 4; + //set as count of blocks, for how many blocks interval the price will be update once + uint64 interval = 5; + //tokenfeeder is initialized with forever live, update the End parameters by voting, + // and will off service by the end + // this is set by updateParams, and the EndRoundID will be update by related. excluded, + // will not work if current height >=EndBlock + uint64 end_block = 6; +} diff --git a/proto/exocore/oracle/tx.proto b/proto/exocore/oracle/tx.proto new file mode 100644 index 000000000..6fadbfb2b --- /dev/null +++ b/proto/exocore/oracle/tx.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package exocore.oracle; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "exocore/oracle/params.proto"; +import "exocore/oracle/price.proto"; +import "gogoproto/gogo.proto"; +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// Msg defines the Msg service. +service Msg { + // CreatePrice creates price for a new oracle round + rpc CreatePrice (MsgCreatePrice) returns (MsgCreatePriceResponse); + // UpdateParams update params value + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgCreatePrice provide the price updating message +message MsgCreatePrice { + // creator tells which is the message sender and should sign this message + string creator = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; + //refer to id from Params.TokenFeeders, 0 is reserved, invalid to use + uint64 feeder_id = 2 [(gogoproto.customname) = "FeederID"]; + + // prices price with its corresponding source + repeated PriceSource prices = 3; + //on which block commit does this message be built on + uint64 based_block = 4; + // nonce represents the unique number to disginguish duplicated messages + int32 nonce = 5; +} + +// MsgCreatePriceResponse +message MsgCreatePriceResponse {} + +// MsgUpdateParms +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "cosmos-sdk/x/oracle/MsgUpdateParams"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // params defines the x/staking parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +}; + +// MsgUpdateParamsResponse +message MsgUpdateParamsResponse {}; diff --git a/proto/exocore/oracle/validator_update_block.proto b/proto/exocore/oracle/validator_update_block.proto new file mode 100644 index 000000000..b2d071e18 --- /dev/null +++ b/proto/exocore/oracle/validator_update_block.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package exocore.oracle; + +option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types"; + +// ValidatorUpdateBlock +message ValidatorUpdateBlock { + // block height on which the validator set changed + uint64 block = 1; +} diff --git a/testutil/keeper/oracle.go b/testutil/keeper/oracle.go new file mode 100644 index 000000000..de2877e8f --- /dev/null +++ b/testutil/keeper/oracle.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/stretchr/testify/require" +) + +func OracleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "OracleParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + stakingKeeper.Keeper{}, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + p4Test := types.DefaultParams() + p4Test.TokenFeeders[1].StartBaseBlock = 1 + k.SetParams(ctx, p4Test) + + return &k, ctx +} diff --git a/testutil/nullify/nullify.go b/testutil/nullify/nullify.go new file mode 100644 index 000000000..3b968c09c --- /dev/null +++ b/testutil/nullify/nullify.go @@ -0,0 +1,57 @@ +// Package nullify provides methods to init nil values structs for test assertion. +package nullify + +import ( + "reflect" + "unsafe" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + coinType = reflect.TypeOf(sdk.Coin{}) + coinsType = reflect.TypeOf(sdk.Coins{}) +) + +// Fill analyze all struct fields and slices with +// reflection and initialize the nil and empty slices, +// structs, and pointers. +func Fill(x interface{}) interface{} { + v := reflect.Indirect(reflect.ValueOf(x)) + switch v.Kind() { + case reflect.Slice: + for i := 0; i < v.Len(); i++ { + obj := v.Index(i) + objPt := reflect.NewAt(obj.Type(), unsafe.Pointer(obj.UnsafeAddr())).Interface() + objPt = Fill(objPt) + obj.Set(reflect.ValueOf(objPt)) + } + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + f := reflect.Indirect(v.Field(i)) + if !f.CanSet() { + continue + } + switch f.Kind() { + case reflect.Slice: + f.Set(reflect.MakeSlice(f.Type(), 0, 0)) + case reflect.Struct: + switch f.Type() { + case coinType: + coin := reflect.New(coinType).Interface() + s := reflect.ValueOf(coin).Elem() + f.Set(s) + case coinsType: + coins := reflect.New(coinsType).Interface() + s := reflect.ValueOf(coins).Elem() + f.Set(s) + default: + objPt := reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Interface() + s := Fill(objPt) + f.Set(reflect.ValueOf(s)) + } + } + } + } + return reflect.Indirect(v).Interface() +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go new file mode 100644 index 000000000..81e67c82b --- /dev/null +++ b/testutil/sample/sample.go @@ -0,0 +1,18 @@ +package sample + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AccAddress returns a sample account address +func AccAddress() string { + pk := ed25519.GenPrivKey().PubKey() + addr := pk.Address() + return sdk.AccAddress(addr).String() +} + +func ValAddress() string { + address, _ := sdk.AccAddressFromBech32(AccAddress()) + return sdk.ValAddress(address).String() +} diff --git a/testutil/utils.go b/testutil/utils.go index 1a3874c52..450580111 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -14,6 +14,7 @@ import ( "golang.org/x/exp/rand" testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" + oracletypes "github.com/ExocoreNetwork/exocore/x/oracle/types" exocoreapp "github.com/ExocoreNetwork/exocore/app" "github.com/ExocoreNetwork/exocore/utils" @@ -70,7 +71,7 @@ func (suite *BaseTestSuite) SetupTest() { suite.DoSetupTest() } -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// SetupWithGenesisValSet initializes a new ExocoreApp with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. @@ -84,6 +85,12 @@ func (suite *BaseTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) + oracleDefaultParams := oracletypes.DefaultParams() + oracleDefaultParams.TokenFeeders[1].StartBaseBlock = 1 + oracleGenesis := oracletypes.NewGenesisState(oracleDefaultParams) + + genesisState[oracletypes.ModuleName] = app.AppCodec().MustMarshalJSON(oracleGenesis) + // set genesis staking assets ethClientChain := assetstypes.ClientChainInfo{ Name: "ethereum", diff --git a/tools/tools.go b/tools/tools.go new file mode 100644 index 000000000..6e7a12d40 --- /dev/null +++ b/tools/tools.go @@ -0,0 +1,11 @@ +//go:build tools + +package tools + +import ( + _ "github.com/cosmos/gogoproto/protoc-gen-gocosmos" + _ "github.com/golang/protobuf/protoc-gen-go" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" +) diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go new file mode 100644 index 000000000..cba89247e --- /dev/null +++ b/x/oracle/client/cli/query.go @@ -0,0 +1,40 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group oracle queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // cmd.AddCommand(CmdListPrices()) + cmd.AddCommand(CmdShowPrices()) + cmd.AddCommand(CmdShowValidatorUpdateBlock()) + cmd.AddCommand(CmdShowIndexRecentParams()) + cmd.AddCommand(CmdShowIndexRecentMsg()) + cmd.AddCommand(CmdListRecentMsg()) + cmd.AddCommand(CmdShowRecentMsg()) + cmd.AddCommand(CmdListRecentParams()) + cmd.AddCommand(CmdShowRecentParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/oracle/client/cli/query_index_recent_msg.go b/x/oracle/client/cli/query_index_recent_msg.go new file mode 100644 index 000000000..053c22e9d --- /dev/null +++ b/x/oracle/client/cli/query_index_recent_msg.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func CmdShowIndexRecentMsg() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-index-recent-msg", + Short: "shows indexRecentMsg", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetIndexRecentMsgRequest{} + + res, err := queryClient.IndexRecentMsg(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_index_recent_params.go b/x/oracle/client/cli/query_index_recent_params.go new file mode 100644 index 000000000..fcb4a4f4c --- /dev/null +++ b/x/oracle/client/cli/query_index_recent_params.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func CmdShowIndexRecentParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-index-recent-params", + Short: "shows indexRecentParams", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetIndexRecentParamsRequest{} + + res, err := queryClient.IndexRecentParams(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_params.go b/x/oracle/client/cli/query_params.go new file mode 100644 index 000000000..e4f7a7734 --- /dev/null +++ b/x/oracle/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_prices.go b/x/oracle/client/cli/query_prices.go new file mode 100644 index 000000000..b2802d670 --- /dev/null +++ b/x/oracle/client/cli/query_prices.go @@ -0,0 +1,82 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/spf13/cast" +) + +// func CmdListPrices() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "list-prices", +// Short: "list all prices", +// RunE: func(cmd *cobra.Command, args []string) error { +// clientCtx, err := client.GetClientQueryContext(cmd) +// if err != nil { +// return err +// } +// +// pageReq, err := client.ReadPageRequest(cmd.Flags()) +// if err != nil { +// return err +// } +// +// queryClient := types.NewQueryClient(clientCtx) +// +// params := &types.QueryAllPricesRequest{ +// Pagination: pageReq, +// } +// +// res, err := queryClient.PricesAll(cmd.Context(), params) +// if err != nil { +// return err +// } +// +// return clientCtx.PrintProto(res) +// }, +// } +// +// flags.AddPaginationFlagsToCmd(cmd, cmd.Use) +// flags.AddQueryFlagsToCmd(cmd) +// +// return cmd +//} + +func CmdShowPrices() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-prices [token-id]", + Short: "shows a prices", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argTokenID, err := cast.ToUint64E(args[0]) + if err != nil { + return err + } + + params := &types.QueryGetPricesRequest{ + TokenId: argTokenID, + } + + res, err := queryClient.Prices(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_recent_msg.go b/x/oracle/client/cli/query_recent_msg.go new file mode 100644 index 000000000..a4a1478e0 --- /dev/null +++ b/x/oracle/client/cli/query_recent_msg.go @@ -0,0 +1,83 @@ +//nolint:dupl +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/spf13/cast" +) + +func CmdListRecentMsg() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-recent-msg", + Short: "list all recentMsg", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllRecentMsgRequest{ + Pagination: pageReq, + } + + res, err := queryClient.RecentMsgAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowRecentMsg() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-recent-msg [block]", + Short: "shows a recentMsg", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argBlock, err := cast.ToUint64E(args[0]) + if err != nil { + return err + } + + params := &types.QueryGetRecentMsgRequest{ + Block: argBlock, + } + + res, err := queryClient.RecentMsg(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_recent_params.go b/x/oracle/client/cli/query_recent_params.go new file mode 100644 index 000000000..cae58b460 --- /dev/null +++ b/x/oracle/client/cli/query_recent_params.go @@ -0,0 +1,83 @@ +//nolint:dupl +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/spf13/cast" +) + +func CmdListRecentParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-recent-params", + Short: "list all recentParams", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllRecentParamsRequest{ + Pagination: pageReq, + } + + res, err := queryClient.RecentParamsAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowRecentParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-recent-params [block]", + Short: "shows a recentParams", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argBlock, err := cast.ToUint64E(args[0]) + if err != nil { + return err + } + + params := &types.QueryGetRecentParamsRequest{ + Block: argBlock, + } + + res, err := queryClient.RecentParams(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/query_validator_update_block.go b/x/oracle/client/cli/query_validator_update_block.go new file mode 100644 index 000000000..6221db0ae --- /dev/null +++ b/x/oracle/client/cli/query_validator_update_block.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func CmdShowValidatorUpdateBlock() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-validator-update-block", + Short: "shows validatorUpdateBlock", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetValidatorUpdateBlockRequest{} + + res, err := queryClient.ValidatorUpdateBlock(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go new file mode 100644 index 000000000..4a60f6866 --- /dev/null +++ b/x/oracle/client/cli/tx.go @@ -0,0 +1,35 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) + +// const ( +// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" +// listSeparator = "," +//) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdCreatePrice()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/oracle/client/cli/tx_create_price.go b/x/oracle/client/cli/tx_create_price.go new file mode 100644 index 000000000..b308de70e --- /dev/null +++ b/x/oracle/client/cli/tx_create_price.go @@ -0,0 +1,91 @@ +package cli + +import ( + "errors" + "strconv" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdCreatePrice() *cobra.Command { + cmd := &cobra.Command{ + // TODO: support v1 single sourceID for temporary + Use: "create-price feederid basedblock nonce sourceid decimal price timestamp detid optinoal(price timestamp detid) optional(desc)", + Short: "Broadcast message create-price", + // Args: cobra.ExactArgs(0), + Args: cobra.MinimumNArgs(8), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + feederID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil || feederID < 1 { + return errors.New("feederID invalid") + } + basedBlock, err := strconv.ParseUint(args[1], 10, 64) + if err != nil || basedBlock < 1 { + return errors.New("basedBlock invalid") + } + nonce, err := strconv.ParseInt(args[2], 10, 32) + if err != nil || nonce < 1 || nonce > 3 { + return errors.New("nonce invalid") + } + sourceID, err := strconv.ParseUint(args[3], 10, 64) + if err != nil || sourceID < 1 { + return errors.New("sourceID invalid") + } + decimal, err := strconv.ParseInt(args[4], 10, 32) + if err != nil || decimal < 0 { + return errors.New("decimal invalid") + } + prices := []*types.PriceSource{ + { + SourceID: sourceID, + Prices: make([]*types.PriceTimeDetID, 0, 1), + Desc: "", + }, + } + argLength := len(args) - 5 + i := 5 + for argLength > 2 { + price := args[i] + timestamp := args[i+1] + detID := args[i+2] + argLength -= 3 + i += 3 + prices[0].Prices = append(prices[0].Prices, &types.PriceTimeDetID{ + Price: price, + Decimal: int32(decimal), + Timestamp: timestamp, + DetID: detID, + }) + } + if argLength == 1 { + prices[0].Desc = args[i+1] + } + + msg := types.NewMsgCreatePrice( + clientCtx.GetFromAddress().String(), + feederID, + prices, + basedBlock, + int32(nonce), + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go new file mode 100644 index 000000000..d3037f960 --- /dev/null +++ b/x/oracle/genesis.go @@ -0,0 +1,65 @@ +package oracle + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the prices + for _, elem := range genState.PricesList { + k.SetPrices(ctx, elem) + } + // Set if defined + if genState.ValidatorUpdateBlock != nil { + k.SetValidatorUpdateBlock(ctx, *genState.ValidatorUpdateBlock) + } + // Set if defined + if genState.IndexRecentParams != nil { + k.SetIndexRecentParams(ctx, *genState.IndexRecentParams) + } + // Set if defined + if genState.IndexRecentMsg != nil { + k.SetIndexRecentMsg(ctx, *genState.IndexRecentMsg) + } + // Set all the recentMsg + for _, elem := range genState.RecentMsgList { + k.SetRecentMsg(ctx, elem) + } + // Set all the recentParams + for _, elem := range genState.RecentParamsList { + k.SetRecentParams(ctx, elem) + } + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + genesis.PricesList = k.GetAllPrices(ctx) + // Get all validatorUpdateBlock + validatorUpdateBlock, found := k.GetValidatorUpdateBlock(ctx) + if found { + genesis.ValidatorUpdateBlock = &validatorUpdateBlock + } + // Get all indexRecentParams + indexRecentParams, found := k.GetIndexRecentParams(ctx) + if found { + genesis.IndexRecentParams = &indexRecentParams + } + // Get all indexRecentMsg + indexRecentMsg, found := k.GetIndexRecentMsg(ctx) + if found { + genesis.IndexRecentMsg = &indexRecentMsg + } + genesis.RecentMsgList = k.GetAllRecentMsg(ctx) + genesis.RecentParamsList = k.GetAllRecentParams(ctx) + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/oracle/genesis_test.go b/x/oracle/genesis_test.go new file mode 100644 index 000000000..8293f96e8 --- /dev/null +++ b/x/oracle/genesis_test.go @@ -0,0 +1,86 @@ +package oracle_test + +import ( + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + PricesList: []types.Prices{ + { + TokenID: 1, + PriceList: []*types.PriceTimeRound{ + { + Price: "100", + Decimal: 1, + Timestamp: "-", + RoundID: 1, + }, + }, + NextRoundID: 2, + }, + { + TokenID: 2, + PriceList: []*types.PriceTimeRound{ + { + Price: "109", + Decimal: 1, + Timestamp: "-", + RoundID: 1, + }, + { + Price: "119", + Decimal: 1, + Timestamp: "-", + RoundID: 2, + }, + }, + NextRoundID: 3, + }, + }, + ValidatorUpdateBlock: &types.ValidatorUpdateBlock{}, + IndexRecentParams: &types.IndexRecentParams{}, + IndexRecentMsg: &types.IndexRecentMsg{}, + RecentMsgList: []types.RecentMsg{ + { + Block: 0, + }, + { + Block: 1, + }, + }, + RecentParamsList: []types.RecentParams{ + { + Block: 0, + }, + { + Block: 1, + }, + }, + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.OracleKeeper(t) + oracle.InitGenesis(ctx, *k, genesisState) + got := oracle.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + require.ElementsMatch(t, genesisState.PricesList, got.PricesList) + require.Equal(t, genesisState.ValidatorUpdateBlock, got.ValidatorUpdateBlock) + require.Equal(t, genesisState.IndexRecentParams, got.IndexRecentParams) + require.Equal(t, genesisState.IndexRecentMsg, got.IndexRecentMsg) + require.ElementsMatch(t, genesisState.RecentMsgList, got.RecentMsgList) + require.ElementsMatch(t, genesisState.RecentParamsList, got.RecentParamsList) + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/oracle/keeper/aggregator/aggregator.go b/x/oracle/keeper/aggregator/aggregator.go new file mode 100644 index 000000000..991612cf8 --- /dev/null +++ b/x/oracle/keeper/aggregator/aggregator.go @@ -0,0 +1,171 @@ +package aggregator + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +type priceWithTimeAndRound struct { + price *big.Int + decimal int32 + timestamp string + detRoundID string // roundId from source if exists +} + +type reportPrice struct { + validator string + // final price, set to -1 as initial + price *big.Int + // sourceId->priceWithTimeAndRound + prices map[uint64]*priceWithTimeAndRound + power *big.Int +} + +func (r *reportPrice) aggregate() *big.Int { + if r.price != nil { + return r.price + } + tmp := make([]*big.Int, 0, len(r.prices)) + for _, p := range r.prices { + tmp = append(tmp, p.price) + } + r.price = common.BigIntList(tmp).Median() + return r.price +} + +type aggregator struct { + finalPrice *big.Int + reports []*reportPrice + // total valiadtor power who has submitted pice + reportPower *big.Int + totalPower *big.Int + // validator set total power + // totalPower string + // sourceId->roundId used to track the confirmed DS roundId + // updated by calculator, detId use string + dsPrices map[uint64]string +} + +// fill price from validator submitting into aggregator, and calculation the voting power and check with the consensus status of deterministic source value to decide when to do the aggregation +// TODO: currently apply mode=1 in V1, add swith modes +func (agg *aggregator) fillPrice(pSources []*types.PriceSource, validator string, power *big.Int) { + report := agg.getReport(validator) + if report == nil { + report = &reportPrice{ + validator: validator, + prices: make(map[uint64]*priceWithTimeAndRound), + power: power, + } + agg.reports = append(agg.reports, report) + agg.reportPower = new(big.Int).Add(agg.reportPower, power) + } + + for _, pSource := range pSources { + if len(pSource.Prices[0].DetID) == 0 { + // this is an NS price report, price will just be updated instead of append + if pTR := report.prices[pSource.SourceID]; pTR == nil { + pTmp := pSource.Prices[0] + priceBigInt, _ := (&big.Int{}).SetString(pTmp.Price, 10) + pTR = &priceWithTimeAndRound{ + price: priceBigInt, + decimal: pTmp.Decimal, + timestamp: pTmp.Timestamp, + // detRoundId: p.DetId, + } + report.prices[pSource.SourceID] = pTR + } else { + pTR.price, _ = (&big.Int{}).SetString(pSource.Prices[0].Price, 10) + } + } else { + // this is an DS price report + if pTR := report.prices[pSource.SourceID]; pTR == nil { + pTmp := pSource.Prices[0] + pTR = &priceWithTimeAndRound{ + // price: nil, + decimal: pTmp.Decimal, + // timestamp: "", + // detRoundId: "", + } + if len(agg.dsPrices[pSource.SourceID]) > 0 { + for _, reportTmp := range agg.reports { + if priceTmp := reportTmp.prices[pSource.SourceID]; priceTmp != nil && priceTmp.price != nil { + pTR.price = new(big.Int).Set(priceTmp.price) + pTR.detRoundID = priceTmp.detRoundID + pTR.timestamp = priceTmp.timestamp + } + } + } + report.prices[pSource.SourceID] = pTR + } + // skip if this DS's slot exists, DS's value only updated by calculator + } + } +} + +// TODO: for v1 use mode=1, which means agg.dsPrices with each key only be updated once, switch modes +func (agg *aggregator) confirmDSPrice(confirmedRounds []*confirmedPrice) { + for _, priceSourceRound := range confirmedRounds { + // update the latest round-detId for DS, TODO: in v1 we only update this value once since calculator will just ignore any further value once a detId has reached consensus + // agg.dsPrices[priceSourceRound.sourceId] = priceSourceRound.detId + // this id's comparison need to format id to make sure them be the same length + if id := agg.dsPrices[priceSourceRound.sourceID]; len(id) == 0 || (len(id) > 0 && id < priceSourceRound.detID) { + agg.dsPrices[priceSourceRound.sourceID] = priceSourceRound.detID + for _, report := range agg.reports { + if report.price != nil { + // price of IVA has completed + continue + } + if price := report.prices[priceSourceRound.sourceID]; price != nil { + price.detRoundID = priceSourceRound.detID + price.timestamp = priceSourceRound.timestamp + price.price = priceSourceRound.price + } // else TODO: panice in V1 + } + } + } +} + +func (agg *aggregator) getReport(validator string) *reportPrice { + for _, r := range agg.reports { + if r.validator == validator { + return r + } + } + return nil +} + +func (agg *aggregator) aggregate() *big.Int { + if agg.finalPrice != nil { + return agg.finalPrice + } + // TODO: implemetn different MODE for definition of consensus, + // currently: use rule_1+MODE_1: {rule:specified source:`chainlink`, MODE: asap when power exceeds the threshold} + // 1. check OVA threshold + // 2. check IVA consensus with rule, TODO: for v1 we only implement with mode=1&rule=1 + if common.ExceedsThreshold(agg.reportPower, agg.totalPower) { + // TODO: this is kind of a mock way to suite V1, need update to check with params.rule + // check if IVA all reached consensus + if len(agg.dsPrices) > 0 { + validatorPrices := make([]*big.Int, 0, len(agg.reports)) + // do the aggregation to find out the 'final price' + for _, validatorReport := range agg.reports { + validatorPrices = append(validatorPrices, validatorReport.aggregate()) + } + // vTmp := bigIntList(validatorPrices) + agg.finalPrice = common.BigIntList(validatorPrices).Median() + // clear relative aggregator for this feeder, all the aggregator,calculator, filter can be removed since this round has been sealed + } + } + return agg.finalPrice +} + +func newAggregator(validatorSetLength int, totalPower *big.Int) *aggregator { + return &aggregator{ + reports: make([]*reportPrice, 0, validatorSetLength), + reportPower: big.NewInt(0), + dsPrices: make(map[uint64]string), + totalPower: totalPower, + } +} diff --git a/x/oracle/keeper/aggregator/aggregator_test.go b/x/oracle/keeper/aggregator/aggregator_test.go new file mode 100644 index 000000000..4e12c12e5 --- /dev/null +++ b/x/oracle/keeper/aggregator/aggregator_test.go @@ -0,0 +1,68 @@ +package aggregator + +import ( + "math/big" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestAggregator(t *testing.T) { + Convey("fill prices into aggregator", t, func() { + a := newAggregator(5, big.NewInt(4)) + // a.fillPrice(pS1, "v1", one) //v1:{1, 2} + + Convey("fill v1's report", func() { + a.fillPrice(pS1, "v1", one) // v1:{1, 2} + report := a.getReport("v1") + So(report.prices[1].price, ShouldBeNil) + Convey("fill v2's report", func() { + a.fillPrice(pS2, "v2", one) + report := a.getReport("v2") + So(report.prices[1].price, ShouldBeNil) + Convey("fill more v1's report", func() { + a.fillPrice(pS21, "v1", one) + report := a.getReport("v1") + So(report.prices[1].price, ShouldBeNil) + So(report.prices[2].price, ShouldBeNil) + Convey("confirm deterministic source_1 and source 2", func() { + a.confirmDSPrice([]*confirmedPrice{ + { + sourceID: 1, + detID: "9", + price: ten, + timestamp: "-", + }, + { + sourceID: 2, + detID: "3", + price: twenty, + timestamp: "-", + }, + }) + reportV1 := a.getReport("v1") + reportV2 := a.getReport("v2") + So(reportV1.prices[1].price, ShouldResemble, ten) + So(reportV1.prices[1].detRoundID, ShouldEqual, "9") + + So(reportV2.prices[1].price, ShouldResemble, ten) + So(reportV2.prices[1].detRoundID, ShouldEqual, "9") + + So(reportV1.prices[2].price, ShouldResemble, twenty) + So(reportV1.prices[2].detRoundID, ShouldEqual, "3") + + // current implementation only support v1's single source + Convey("aggregate after all source confirmed", func() { + a.fillPrice(pS6, "v3", one) + a.aggregate() // v1:{s1:9-10, s2:3-20}:15, v2:{s1:9-10}:10 + So(a.getReport("v1").price, ShouldResemble, fifteen) + So(a.getReport("v2").price, ShouldResemble, ten) + So(a.getReport("v3").price, ShouldResemble, twenty) + So(a.finalPrice, ShouldResemble, fifteen) + }) + }) + }) + }) + }) + }) +} diff --git a/x/oracle/keeper/aggregator/calculator.go b/x/oracle/keeper/aggregator/calculator.go new file mode 100644 index 000000000..5cdc0f8df --- /dev/null +++ b/x/oracle/keeper/aggregator/calculator.go @@ -0,0 +1,165 @@ +package aggregator + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +type confirmedPrice struct { + sourceID uint64 + detID string + price *big.Int + timestamp string +} + +// internal struct +type priceAndPower struct { + price *big.Int + power *big.Int +} + +// for a specific DS round, it could have multiple values provided by different validators(should not be true if there's no malicious validator) +type roundPrices struct { // 0 means NS + detID string + prices []*priceAndPower + price *big.Int + timestamp string + // confirmed bool +} + +// udpate priceAndPower for a specific DSRoundID, if the price exists, increase its power with provided data +// return confirmed=true, when detect power exceeds the threshold +func (r *roundPrices) updatePriceAndPower(pw *priceAndPower, totalPower *big.Int) (updated bool, confirmed bool) { + if r.price != nil { + confirmed = true + return + } + for _, item := range r.prices { + if item.price.Cmp(pw.price) == 0 { + item.power = new(big.Int).Add(item.power, pw.power) + updated = true + if common.ExceedsThreshold(item.power, totalPower) { + r.price = item.price + confirmed = true + } + return + } + } + if len(r.prices) < cap(r.prices) { + r.prices = append(r.prices, pw) + updated = true + if common.ExceedsThreshold(pw.power, totalPower) { + r.price = pw.price + // r.confirmed = true + confirmed = true + } + } + return +} + +// each DS corresponding a roundPriceList to represent its multiple rounds(DS round) in one oracle-round +type roundPricesList struct { + roundPricesList []*roundPrices + // each round can have at most roundPricesCount priceAndPower + roundPricesCount int +} + +// to tell if any round of this DS has reached consensus/confirmed +func (r *roundPricesList) hasConfirmedDetID() bool { + for _, round := range r.roundPricesList { + if round.price != nil { + return true + } + } + return false +} + +// get the roundPriceList correspond to specifid detID of a DS +// if no required data and the pricesList has not reach its limitation, we will add a new slot for this detId +func (r *roundPricesList) getOrNewRound(detID string, timestamp string) (round *roundPrices) { + for _, round = range r.roundPricesList { + if round.detID == detID { + if round.price != nil { + round = nil + } + return + } + } + + if len(r.roundPricesList) < cap(r.roundPricesList) { + round = &roundPrices{ + detID: detID, + prices: make([]*priceAndPower, 0, r.roundPricesCount), + timestamp: timestamp, + } + r.roundPricesList = append(r.roundPricesList, round) + return + } + return +} + +// calculator used to get consensus on deterministic source based data from validator set reports of price +type calculator struct { + // sourceId->{[]{roundId, []{price,power}, confirmed}}, confirmed value will be set in [0] + deterministicSource map[uint64]*roundPricesList + validatorLength int + totalPower *big.Int +} + +func (c *calculator) newRoundPricesList() *roundPricesList { + return &roundPricesList{ + roundPricesList: make([]*roundPrices, 0, common.MaxDetID*c.validatorLength), + // for each DS-roundId, the count of prices provided is the number of validators at most + roundPricesCount: c.validatorLength, + } +} + +func (c *calculator) getOrNewSourceID(sourceID uint64) *roundPricesList { + rounds := c.deterministicSource[sourceID] + if rounds == nil { + rounds = c.newRoundPricesList() + c.deterministicSource[sourceID] = rounds + } + return rounds +} + +// fillPrice called upon new MsgCreatPrice arrived, to trigger the calculation to get to consensus on the same roundID_of_deterministic_source +// v1 use mode1, TODO: switch modes +func (c *calculator) fillPrice(pSources []*types.PriceSource, _ string, power *big.Int) (confirmedRounds []*confirmedPrice) { + for _, pSource := range pSources { + rounds := c.getOrNewSourceID(pSource.SourceID) + if rounds.hasConfirmedDetID() { + // TODO: this skip is just for V1 to do fast calculation and release EndBlocker pressure, may lead to 'not latest detId' be chosen + break + } + for _, pDetID := range pSource.Prices { + + round := rounds.getOrNewRound(pDetID.DetID, pDetID.Timestamp) + if round == nil { + // this sourceId has reach the limitation of different detId, or has confirmed + continue + } + + roundPrice, _ := new(big.Int).SetString(pDetID.Price, 10) + + updated, confirmed := round.updatePriceAndPower(&priceAndPower{roundPrice, power}, c.totalPower) + if updated && confirmed { + // sourceId, detId, price + confirmedRounds = append(confirmedRounds, &confirmedPrice{pSource.SourceID, round.detID, round.price, round.timestamp}) // TODO: just in v1 with mode==1, we use asap, so we just ignore any further data from this DS, even higher detId may get to consensus, in this way, in most case, we can complete the calculation in the transaction execution process. Release the pressure in EndBlocker + // TODO: this may delay to current block finish + break + } + } + } + return +} + +func newCalculator(validatorSetLength int, totalPower *big.Int) *calculator { + return &calculator{ + deterministicSource: make(map[uint64]*roundPricesList), + validatorLength: validatorSetLength, + totalPower: totalPower, + } +} diff --git a/x/oracle/keeper/aggregator/calculator_test.go b/x/oracle/keeper/aggregator/calculator_test.go new file mode 100644 index 000000000..9fa931687 --- /dev/null +++ b/x/oracle/keeper/aggregator/calculator_test.go @@ -0,0 +1,70 @@ +package aggregator + +import ( + "math/big" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +/* + 1-10, 2-12, 3-15 + +ps1: 1-10, 2-12 +ps2: 2-12, 3-15 +ps3: 1-10, 2-11(m) +--- +ps4: 2-12, 3-19(m) +ps5: 1-10, 3-19(m) +---- +ps1, ps2, ps3, ps4 ---> 2-12 +ps2, ps2, ps3, ps5 ---> 1-10 +*/ +func TestCalculator(t *testing.T) { + one := big.NewInt(1) + Convey("fill prices into calculator", t, func() { + c := newCalculator(5, big.NewInt(4)) + Convey("fill prices from single deterministic source", func() { + c.fillPrice(pS1, "v1", one) // 1-10, 2-12 + c.fillPrice(pS2, "v2", one) // 2-12, 3-15 + c.fillPrice(pS3, "v3", one) // 1-10, 2-11 + Convey("consensus on detid=2 and price=12", func() { + confirmed := c.fillPrice(pS4, "v4", one) // 2-12, 3-19 + So(confirmed[0].detID, ShouldEqual, "2") + So(confirmed[0].price, ShouldResemble, big.NewInt(12)) + }) + Convey("consensus on detid=1 and price=10", func() { + confirmed := c.fillPrice(pS5, "v5", one) // 1-10, 3-19 + So(confirmed[0].detID, ShouldEqual, "1") + So(confirmed[0].price, ShouldResemble, big.NewInt(10)) + + confirmed = c.fillPrice(pS4, "v4", one) + So(confirmed, ShouldBeNil) + }) + }) + Convey("fill prices from multiple deterministic sources", func() { + c.fillPrice(pS21, "v1", one) + c.fillPrice(pS22, "v2", one) + c.fillPrice(pS23, "v3", one) + Convey("consensus on both source 1 and source 2", func() { + confirmed := c.fillPrice(pS24, "v4", one) + So(len(confirmed), ShouldEqual, 2) + i := 0 + if confirmed[0].sourceID == 2 { + i = 1 + } + So(confirmed[i].detID, ShouldEqual, "2") + So(confirmed[i].price, ShouldResemble, big.NewInt(12)) + + So(confirmed[1-i].detID, ShouldEqual, "3") + So(confirmed[1-i].price, ShouldResemble, big.NewInt(15)) + }) + Convey("consenus on source 1 only", func() { + confirmed := c.fillPrice(pS25, "v5", one) + So(len(confirmed), ShouldEqual, 1) + So(confirmed[0].detID, ShouldEqual, "1") + So(confirmed[0].price, ShouldResemble, big.NewInt(10)) + }) + }) + }) +} diff --git a/x/oracle/keeper/aggregator/context.go b/x/oracle/keeper/aggregator/context.go new file mode 100644 index 000000000..d061daa07 --- /dev/null +++ b/x/oracle/keeper/aggregator/context.go @@ -0,0 +1,267 @@ +package aggregator + +import ( + "errors" + "math/big" + "time" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/cache" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type PriceItemKV struct { + TokenID uint64 + PriceTR types.PriceTimeRound +} + +type roundInfo struct { + // this round of price will start from block basedBlock+1, the basedBlock served as a trigger to notify validators to submit prices + basedBlock uint64 + // next round id of the price oracle service, price with the id will be record on block basedBlock+1 if all prices submitted by validators(for v1, validators serve as oracle nodes) get to consensus immediately + nextRoundID uint64 + // indicate if this round is open for collecting prices or closed in either condition that success with a consensused price or not + // 1: open, 2: closed + status int32 +} + +// AggregatorContext keeps memory cache for state params, validatorset, and updatedthese values as they updated on chain. And it keeps the information to track all tokenFeeders' status and data collection +// nolint +type AggregatorContext struct { + params *common.Params + + // validator->power + validatorsPower map[string]*big.Int + totalPower *big.Int + + // each active feederToken has a roundInfo + rounds map[uint64]*roundInfo + + // each roundInfo has a worker + aggregators map[uint64]*worker +} + +func (agc *AggregatorContext) sanityCheck(msg *types.MsgCreatePrice) error { + // sanity check + // TODO: check nonce [1,3] in anteHandler, related to params, may not able + // TODO: check the msgCreatePrice's Decimal is correct with params setting + // TODO: check len(price.prices)>0, len(price.prices._range_eachPriceSource.Prices)>0, at least has one source, and for each source has at least one price + // TODO: check for each source, at most maxDetId count price (now in filter, ->anteHandler) + + if agc.validatorsPower[msg.Creator] == nil { + return errors.New("signer is not validator") + } + + if msg.Nonce < 1 || msg.Nonce > common.MaxNonce { + return errors.New("nonce invalid") + } + + // TODO: sanity check for price(no more than maxDetId count for each source, this should be take care in anteHandler) + if msg.Prices == nil || len(msg.Prices) == 0 { + return errors.New("msg should provide at least one price") + } + + for _, pSource := range msg.Prices { + if pSource.Prices == nil || len(pSource.Prices) == 0 || len(pSource.Prices) > common.MaxDetID || !agc.params.IsValidSource(pSource.SourceID) { + return errors.New("source should be valid and provide at least one price") + } + // check with params is coressponding source is deteministic + if agc.params.IsDeterministicSource(pSource.SourceID) { + for _, pDetID := range pSource.Prices { + // TODO: verify the format of DetId is correct, since this is string, and we will make consensus with validator's power, so it's ok not to verify the format + // just make sure the DetId won't mess up with NS's placeholder id, the limitation of maximum count one validator can submit will be check by filter + if len(pDetID.DetID) == 0 { + // deterministic must have specified deterministicId + return errors.New("ds should have roundid") + } + // DS's price value will go through consensus process, so it's safe to skip the check here + } + // sanity check: NS submit only one price with detId=="" + } else if len(pSource.Prices) > 1 || len(pSource.Prices[0].DetID) > 0 { + return errors.New("ns should not have roundid") + } + } + return nil +} + +func (agc *AggregatorContext) checkMsg(msg *types.MsgCreatePrice) error { + if err := agc.sanityCheck(msg); err != nil { + return err + } + + // check feeder is active + feederContext := agc.rounds[msg.FeederID] + if feederContext == nil || feederContext.status != 1 { + // feederId does not exist or not alive + return errors.New("context not exist or not available") + } + // senity check on basedBlock + if msg.BasedBlock != feederContext.basedBlock { + return errors.New("baseblock not match") + } + + // check sources rule matches + if ok, err := agc.params.CheckRules(msg.FeederID, msg.Prices); !ok { + return err + } + return nil +} + +func (agc *AggregatorContext) FillPrice(msg *types.MsgCreatePrice) (*PriceItemKV, *cache.ItemM, error) { + feederWorker := agc.aggregators[msg.FeederID] + // worker initialzed here reduce workload for Endblocker + if feederWorker == nil { + feederWorker = newWorker(msg.FeederID, agc) + agc.aggregators[msg.FeederID] = feederWorker + } + + if feederWorker.sealed { + return nil, nil, types.ErrPriceProposalIgnored.Wrap("price aggregation for this round has sealed") + } + + if listFilled := feederWorker.do(msg); listFilled != nil { + if finalPrice := feederWorker.aggregate(); finalPrice != nil { + agc.rounds[msg.FeederID].status = 2 + feederWorker.seal() + return &PriceItemKV{agc.params.GetTokenFeeder(msg.FeederID).TokenID, types.PriceTimeRound{ + Price: finalPrice.String(), + Decimal: agc.params.GetTokenInfo(msg.FeederID).Decimal, + // TODO: check the format + Timestamp: time.Now().String(), + RoundID: agc.rounds[msg.FeederID].nextRoundID, + }}, &cache.ItemM{FeederID: msg.FeederID}, nil + } + return nil, &cache.ItemM{FeederID: msg.FeederID, PSources: listFilled, Validator: msg.Creator}, nil + } + + // return nil, nil, errors.New("no valid price proposal to add for aggregation") + return nil, nil, types.ErrPriceProposalIgnored +} + +// NewCreatePrice receives msgCreatePrice message, and goes process: filter->aggregator, filter->calculator->aggregator +// non-deterministic data will goes directly into aggregator, and deterministic data will goes into calculator first to get consensus on the deterministic id. +func (agc *AggregatorContext) NewCreatePrice(_ sdk.Context, msg *types.MsgCreatePrice) (*PriceItemKV, *cache.ItemM, error) { + if err := agc.checkMsg(msg); err != nil { + return nil, nil, types.ErrInvalidMsg.Wrap(err.Error()) + } + return agc.FillPrice(msg) +} + +// prepare for new roundInfo, just update the status kept in memory +// executed at EndBlock stage, seall all success or expired roundInfo +// including possible aggregation and state update +// when validatorSet update, set force to true, to seal all alive round +// returns: 1st successful sealed, need to be written to KVStore, 2nd: failed sealed tokenID, use previous price to write to KVStore +func (agc *AggregatorContext) SealRound(ctx sdk.Context, force bool) (success []*PriceItemKV, failed []uint64) { + // 1. check validatorSet udpate + // TODO: if validatoSet has been updated in current block, just seal all active rounds and return + // 1. for sealed worker, the KVStore has been updated + for feederID, round := range agc.rounds { + if round.status == 1 { + feeder := agc.params.GetTokenFeeder(feederID) + // TODO: for mode=1, we don't do aggregate() here, since if it donesn't success in the transaction execution stage, it won't success here + // but it's not always the same for other modes, switch modes + switch common.Mode { + case 1: + expired := feeder.EndBlock > 0 && uint64(ctx.BlockHeight()) >= feeder.EndBlock + outOfWindow := uint64(ctx.BlockHeight())-round.basedBlock >= uint64(common.MaxNonce) + if expired || outOfWindow || force { + failed = append(failed, feeder.TokenID) + if expired { + delete(agc.rounds, feederID) + delete(agc.aggregators, feederID) + } else { + round.status = 2 + agc.aggregators[feederID] = nil + } + } + default: + ctx.Logger().Info("mode other than 1 is not support now") + } + } + // all status: 1->2, remove its aggregator + if agc.aggregators[feederID] != nil && agc.aggregators[feederID].sealed { + agc.aggregators[feederID] = nil + } + } + return success, failed +} + +func (agc *AggregatorContext) PrepareRound(ctx sdk.Context, block uint64) { + // block>0 means recache initialization, all roundInfo is empty + if block == 0 { + block = uint64(ctx.BlockHeight()) + } + + for feederID, feeder := range agc.params.GetTokenFeeders() { + if feederID == 0 { + continue + } + if (feeder.EndBlock > 0 && feeder.EndBlock <= block) || feeder.StartBaseBlock > block { + // this feeder is inactive + continue + } + + delta := block - feeder.StartBaseBlock + left := delta % feeder.Interval + count := delta / feeder.Interval + latestBasedblock := block - left + latestNextRoundID := feeder.StartRoundID + count + + feederIDUint64 := uint64(feederID) + round := agc.rounds[feederIDUint64] + if round == nil { + round = &roundInfo{ + basedBlock: latestBasedblock, + nextRoundID: latestNextRoundID, + } + if left >= common.MaxNonce { + round.status = 2 + } else { + round.status = 1 + } + agc.rounds[feederIDUint64] = round + } else { + // prepare a new round for exist roundInfo + if left == 0 { + round.basedBlock = latestBasedblock + round.nextRoundID = latestNextRoundID + round.status = 1 + // drop previous worker + agc.aggregators[feederIDUint64] = nil + } else if round.status == 1 && left >= common.MaxNonce { + // this shouldn't happen, if do sealround properly before prepareRound, basically for test only + round.status = 2 + // TODO: just modify the status here, since sealRound should do all the related seal actios already when parepare invoked + } + } + } +} + +func (agc *AggregatorContext) SetParams(p *common.Params) { + agc.params = p +} + +func (agc *AggregatorContext) SetValidatorPowers(vp map[string]*big.Int) { + // t := big.NewInt(0) + agc.totalPower = big.NewInt(0) + agc.validatorsPower = make(map[string]*big.Int) + for addr, power := range vp { + agc.validatorsPower[addr] = power + agc.totalPower = new(big.Int).Add(agc.totalPower, power) + } +} + +func (agc *AggregatorContext) GetValidatorPowers() (vp map[string]*big.Int) { + return agc.validatorsPower +} + +func NewAggregatorContext() *AggregatorContext { + return &AggregatorContext{ + validatorsPower: make(map[string]*big.Int), + totalPower: big.NewInt(0), + rounds: make(map[uint64]*roundInfo), + aggregators: make(map[uint64]*worker), + } +} diff --git a/x/oracle/keeper/aggregator/context_test.go b/x/oracle/keeper/aggregator/context_test.go new file mode 100644 index 000000000..0a31b5320 --- /dev/null +++ b/x/oracle/keeper/aggregator/context_test.go @@ -0,0 +1,98 @@ +package aggregator + +import ( + "math/big" + "testing" + "time" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + . "github.com/agiledragon/gomonkey/v2" + sdk "github.com/cosmos/cosmos-sdk/types" + . "github.com/smartystreets/goconvey/convey" +) + +func TestAggregatorContext(t *testing.T) { + Convey("init aggregatorContext with default params", t, func() { + agc := initAggregatorContext4Test() + var ctx sdk.Context + Convey("prepare round to gengerate round info of feeders for next block", func() { + Convey("pepare within the window", func() { + p := patchBlockHeight(12) + agc.PrepareRound(ctx, 0) + + Convey("for empty round list", func() { + So(*agc.rounds[1], ShouldResemble, roundInfo{10, 2, 1}) + }) + + Convey("update already exist round info", func() { + p.Reset() + time.Sleep(1 * time.Second) + patchBlockHeight(10 + common.MaxNonce) + + agc.PrepareRound(ctx, 0) + So(agc.rounds[1].status, ShouldEqual, 2) + }) + p.Reset() + time.Sleep(1 * time.Second) + }) + Convey("pepare outside the window", func() { + Convey("for empty round list", func() { + p := patchBlockHeight(10 + common.MaxNonce) + agc.PrepareRound(ctx, 0) + So(agc.rounds[1].status, ShouldEqual, 2) + p.Reset() + time.Sleep(1 * time.Second) + }) + }) + }) + + Convey("seal existed round without any msg recieved", func() { + p := patchBlockHeight(11) + agc.PrepareRound(ctx, 0) + Convey("seal when exceed the window", func() { + So(agc.rounds[1].status, ShouldEqual, 1) + p.Reset() + time.Sleep(1 * time.Second) + patchBlockHeight(13) + agc.SealRound(ctx, false) + So(agc.rounds[1].status, ShouldEqual, 2) + }) + + Convey("force seal by required", func() { + p.Reset() + time.Sleep(1 * time.Second) + patchBlockHeight(12) + agc.SealRound(ctx, false) + So(agc.rounds[1].status, ShouldEqual, 1) + agc.SealRound(ctx, true) + So(agc.rounds[1].status, ShouldEqual, 2) + }) + p.Reset() + time.Sleep(1 * time.Second) + }) + + }) +} + +func initAggregatorContext4Test() *AggregatorContext { + agc := NewAggregatorContext() + + validatorPowers := map[string]*big.Int{ + "v1": big.NewInt(1), + "v2": big.NewInt(1), + "v3": big.NewInt(1), + } + + p := defaultParams + pWrapped := common.Params(p) + + agc.SetValidatorPowers(validatorPowers) + agc.SetParams(&pWrapped) + return agc +} + +func patchBlockHeight(h int64) *Patches { + return ApplyMethod(sdk.Context{}, "BlockHeight", func(sdk.Context) int64 { + return h + }) +} diff --git a/x/oracle/keeper/aggregator/filter.go b/x/oracle/keeper/aggregator/filter.go new file mode 100644 index 000000000..bbedd31b4 --- /dev/null +++ b/x/oracle/keeper/aggregator/filter.go @@ -0,0 +1,85 @@ +package aggregator + +import ( + "strconv" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +type filter struct { + maxNonce int + maxDetID int + // nonce start from 1 + validatorNonce map[string]*common.Set[int32] + // validator_sourceId -> roundID, NS use 0 + validatorSource map[string]*common.Set[string] +} + +func newFilter(maxNonce, maxDetID int) *filter { + return &filter{ + maxNonce: maxNonce, + maxDetID: maxDetID, + validatorNonce: make(map[string]*common.Set[int32]), + validatorSource: make(map[string]*common.Set[string]), + } +} + +func (f *filter) newVNSet() *common.Set[int32] { + return common.NewSet[int32](f.maxNonce) +} + +func (f *filter) newVSSet() *common.Set[string] { + return common.NewSet[string](f.maxDetID) +} + +// add priceWithSource into calculator list and aggregator list depends on the source type(deterministic/non-deterministic) +func (f *filter) addPSource(pSources []*types.PriceSource, validator string) (list4Calculator []*types.PriceSource, list4Aggregator []*types.PriceSource) { + for _, pSource := range pSources { + // check conflicts or duplicate data for the same roundID within the same source + if len(pSource.Prices[0].DetID) > 0 { + k := validator + strconv.Itoa(int(pSource.SourceID)) + detIDs := f.validatorSource[k] + if detIDs == nil { + detIDs = f.newVSSet() + f.validatorSource[k] = detIDs + } + + pSourceTmp := &types.PriceSource{ + SourceID: pSource.SourceID, + Prices: make([]*types.PriceTimeDetID, 0, len(pSource.Prices)), + Desc: pSource.Desc, + } + + for _, pDetID := range pSource.Prices { + if ok := detIDs.Add(pDetID.DetID); ok { + // deterministic id has not seen in filter and limitation of ids this souce has not reached + pSourceTmp.Prices = append(pSourceTmp.Prices, pDetID) + } + } + if len(pSourceTmp.Prices) > 0 { + list4Calculator = append(list4Calculator, pSourceTmp) + list4Aggregator = append(list4Aggregator, pSourceTmp) + } + } else { + // add non-deterministic pSource value into aggregator list + list4Aggregator = append(list4Aggregator, pSource) + } + } + return list4Calculator, list4Aggregator +} + +// filtrate checks data from MsgCreatePrice, and will drop the conflict or duplicate data, it will then fill data into calculator(for deterministic source data to get to consensus) and aggregator (for both deterministic and non0-deterministic source data run 2-layers aggregation to get the final price) +func (f *filter) filtrate(price *types.MsgCreatePrice) (list4Calculator []*types.PriceSource, list4Aggregator []*types.PriceSource) { + validator := price.Creator + nonces := f.validatorNonce[validator] + if nonces == nil { + nonces = f.newVNSet() + f.validatorNonce[validator] = nonces + } + + if ok := nonces.Add(price.Nonce); ok { + list4Calculator, list4Aggregator = f.addPSource(price.Prices, validator) + } + return +} diff --git a/x/oracle/keeper/aggregator/filter_test.go b/x/oracle/keeper/aggregator/filter_test.go new file mode 100644 index 000000000..085251f9b --- /dev/null +++ b/x/oracle/keeper/aggregator/filter_test.go @@ -0,0 +1,104 @@ +package aggregator + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + . "github.com/smartystreets/goconvey/convey" +) + +func TestFilter(t *testing.T) { + Convey("test aggregator_filter", t, func() { + f := newFilter(3, 5) + ptd1 := newPTD("1", "600000") + ptd2 := newPTD("2", "600050") + ptd3 := newPTD("3", "600070") + ptd4 := newPTD("4", "601000") + ptd5 := newPTD("5", "602000") + ptd6 := newPTD("6", "603000") + + ps1 := &types.PriceSource{ + SourceID: 1, + Prices: []*types.PriceTimeDetID{ + ptd1, + ptd2, + }, + } + + ps := []*types.PriceSource{ps1} + msg := &types.MsgCreatePrice{ + Creator: "v1", + FeederID: 1, + Prices: ps, + BasedBlock: 10, + Nonce: 1, + } + l4c, l4a := f.filtrate(msg) + + Convey("add first valid msg", func() { + So(l4c, ShouldResemble, ps) + So(l4a, ShouldResemble, ps) + }) + + Convey("add duplicate nonce msg", func() { + ps1.Prices[0] = ptd3 + l4c, l4a = f.filtrate(msg) + So(l4c, ShouldBeNil) + So(l4a, ShouldBeNil) + }) + + Convey("add duplicate detId", func() { + msg.Nonce = 2 + l4c, l4a = f.filtrate(msg) + Convey("add with new nonce", func() { + So(l4c, ShouldBeNil) + So(l4a, ShouldBeNil) + }) + Convey("update with new detId but use duplicate nonce", func() { + msg.Nonce = 2 + ps1.Prices[0] = ptd3 + l4c, l4a := f.filtrate(msg) + So(l4c, ShouldBeNil) + So(l4a, ShouldBeNil) + }) + }) + + Convey("add new detId with new nonce", func() { + msg.Nonce = 2 + ps1.Prices[0] = ptd3 + l4c, l4a = f.filtrate(msg) + ps1.Prices = ps1.Prices[:1] + ps1.Prices[0] = ptd3 + psReturn := []*types.PriceSource{ps1} + So(l4c, ShouldResemble, psReturn) + So(l4a, ShouldResemble, psReturn) + }) + + Convey("add too many nonce", func() { + msg.Nonce = 2 + ps1.Prices[0] = ptd3 + f.filtrate(msg) + + msg.Nonce = 3 + ps1.Prices[0] = ptd4 + l4c, _ = f.filtrate(msg) + So(l4c[0].Prices, ShouldContain, ptd4) + + msg.Nonce = 4 + ps1.Prices[0] = ptd5 + l4c, _ = f.filtrate(msg) + So(l4c, ShouldBeNil) + }) + + Convey("add too many DetIds", func() { + msg.Nonce = 2 + ps1.Prices = []*types.PriceTimeDetID{ptd3, ptd4, ptd5, ptd6} + l4c, l4a = f.filtrate(msg) + So(l4c, ShouldResemble, l4a) + So(l4c[0].Prices, ShouldContain, ptd3) + So(l4c[0].Prices, ShouldContain, ptd4) + So(l4c[0].Prices, ShouldContain, ptd5) + So(l4c[0].Prices, ShouldNotContain, ptd6) + }) + }) +} diff --git a/x/oracle/keeper/aggregator/helper_test.go b/x/oracle/keeper/aggregator/helper_test.go new file mode 100644 index 000000000..f993c6b8e --- /dev/null +++ b/x/oracle/keeper/aggregator/helper_test.go @@ -0,0 +1,19 @@ +package aggregator + +import "github.com/ExocoreNetwork/exocore/x/oracle/types" + +func newPTD(detID, price string) *types.PriceTimeDetID { + return &types.PriceTimeDetID{ + Price: price, + Decimal: 1, + Timestamp: "-", + DetID: detID, + } +} + +func newPS(sourceID uint64, prices ...*types.PriceTimeDetID) *types.PriceSource { + return &types.PriceSource{ + SourceID: sourceID, + Prices: prices, + } +} diff --git a/x/oracle/keeper/aggregator/info_test.go b/x/oracle/keeper/aggregator/info_test.go new file mode 100644 index 000000000..72b0e647d --- /dev/null +++ b/x/oracle/keeper/aggregator/info_test.go @@ -0,0 +1,55 @@ +package aggregator + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +var ( + one = big.NewInt(1) + zero = big.NewInt(0) + ten = big.NewInt(10) + eleven = big.NewInt(11) + fifteen = big.NewInt(15) + twenty = big.NewInt(20) +) + +var ( + pTD1 = newPTD("1", "10") + pTD2 = newPTD("2", "12") + pTD3 = newPTD("3", "15") + pTD2M = newPTD("2", "11") + pTD3M = newPTD("3", "19") + // 1-10, 2-12 + pS1 = []*types.PriceSource{newPS(1, pTD1, pTD2)} + // 2-12, 3-1 + pS2 = []*types.PriceSource{newPS(1, pTD3, pTD2)} + // 1-10, 2-11(m) + pS3 = []*types.PriceSource{newPS(1, pTD1, pTD2M)} + // 2-12, 3-19(m) + pS4 = []*types.PriceSource{newPS(1, pTD2, pTD3M)} + // 1-10, 3-19(m) + pS5 = []*types.PriceSource{newPS(1, pTD1, pTD3M)} + + pS6 = []*types.PriceSource{newPS(2, pTD1)} + + // 1-10, 2-12 + pS21 = []*types.PriceSource{newPS(1, pTD1, pTD2), newPS(2, pTD1, pTD3)} + // 2-12, 3-15 + pS22 = []*types.PriceSource{newPS(1, pTD3, pTD2), newPS(2, pTD2, pTD3)} + // 1-10, 2-11(m) + pS23 = []*types.PriceSource{newPS(1, pTD1, pTD2M), newPS(2, pTD2M, pTD1)} + // 2-12, 3-19(m) + pS24 = []*types.PriceSource{newPS(1, pTD2, pTD3M), newPS(2, pTD3, pTD2M)} + // 1-10, 3-19(m) + pS25 = []*types.PriceSource{newPS(1, pTD1, pTD3M), newPS(2, pTD2M, pTD3M)} +) + +var defaultParams = types.Params{ + Chains: []*types.Chain{{Name: "-", Desc: "-"}, {Name: "Ethereum", Desc: "-"}}, + Tokens: []*types.Token{{}, {Name: "eth", ChainID: 1, ContractAddress: "0xabc", Decimal: 18, Active: true}}, + Sources: []*types.Source{{}, {Name: "chainLink", Entry: &types.Endpoint{}, Valid: true, Deterministic: true}}, + Rules: []*types.RuleSource{{}, {SourceIDs: []uint64{1}}}, + TokenFeeders: []*types.TokenFeeder{{}, {TokenID: 1, RuleID: 1, StartRoundID: 1, StartBaseBlock: 0, Interval: 10, EndBlock: 0}}, +} diff --git a/x/oracle/keeper/aggregator/worker.go b/x/oracle/keeper/aggregator/worker.go new file mode 100644 index 000000000..1dfe76351 --- /dev/null +++ b/x/oracle/keeper/aggregator/worker.go @@ -0,0 +1,62 @@ +package aggregator + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +// worker is the actual instance used to calculate final price for each tokenFeeder's round. Which means, every tokenFeeder corresponds to a specified token, and for that tokenFeeder, each round we use a worker instance to calculate the final price +type worker struct { + sealed bool + price string + decimal int32 + // mainly used for deterministic source data to check conflicts and validation + f *filter + // used to get to consensus on deterministic source's data + c *calculator + // when enough data(exceeds threshold) collected, aggregate to conduct the final price + a *aggregator + ctx *AggregatorContext +} + +func (w *worker) do(msg *types.MsgCreatePrice) []*types.PriceSource { + validator := msg.Creator + power := w.ctx.validatorsPower[validator] + list4Calculator, list4Aggregator := w.f.filtrate(msg) + if list4Aggregator != nil { + w.a.fillPrice(list4Aggregator, validator, power) + if confirmedRounds := w.c.fillPrice(list4Calculator, validator, power); confirmedRounds != nil { + w.a.confirmDSPrice(confirmedRounds) + } + } + return list4Aggregator +} + +func (w *worker) aggregate() *big.Int { + return w.a.aggregate() +} + +// not concurrency safe +func (w *worker) seal() { + if w.sealed { + return + } + w.sealed = true + w.price = w.a.aggregate().String() + w.f = nil + w.c = nil + w.a = nil +} + +// newWorker new a instance for a tokenFeeder's specific round +func newWorker(feederID uint64, agc *AggregatorContext) *worker { + return &worker{ + f: newFilter(common.MaxNonce, common.MaxDetID), + c: newCalculator(len(agc.validatorsPower), agc.totalPower), + a: newAggregator(len(agc.validatorsPower), agc.totalPower), + decimal: agc.params.GetTokenInfo(feederID).Decimal, + ctx: agc, + } +} diff --git a/x/oracle/keeper/cache/caches.go b/x/oracle/keeper/cache/caches.go new file mode 100644 index 000000000..400849077 --- /dev/null +++ b/x/oracle/keeper/cache/caches.go @@ -0,0 +1,227 @@ +package cache + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var zeroBig = big.NewInt(0) + +type ( + ItemV map[string]*big.Int + ItemP *common.Params + ItemM struct { + FeederID uint64 + PSources []*types.PriceSource + Validator string + } +) + +type Cache struct { + msg cacheMsgs + validators *cacheValidator + params *cacheParams +} + +type cacheMsgs map[uint64][]*ItemM + +// used to track validator change +type cacheValidator struct { + validators map[string]*big.Int + update bool +} + +// used to track params change +type cacheParams struct { + params *common.Params + update bool +} + +func (c cacheMsgs) add(item *ItemM) { + if ims, ok := c[item.FeederID]; ok { + for _, im := range ims { + if im.Validator == item.Validator { + for _, p := range im.PSources { + for _, pInput := range item.PSources { + if p.SourceID == pInput.SourceID { + p.Prices = append(p.Prices, pInput.Prices...) + return + } + } + } + im.PSources = append(im.PSources, item.PSources...) + return + } + } + } + c[item.FeederID] = append(c[item.FeederID], item) +} + +func (c cacheMsgs) remove(item *ItemM) { + delete(c, item.FeederID) +} + +func (c cacheMsgs) commit(ctx sdk.Context, k common.KeeperOracle) { + block := uint64(ctx.BlockHeight()) + recentMsgs := types.RecentMsg{ + Block: block, + Msgs: make([]*types.MsgItem, 0), + } + for _, msgs4Feeder := range c { + for _, msg := range msgs4Feeder { + recentMsgs.Msgs = append(recentMsgs.Msgs, &types.MsgItem{ + FeederID: msg.FeederID, + PSources: msg.PSources, + Validator: msg.Validator, + }) + } + } + index, _ := k.GetIndexRecentMsg(ctx) + for i, b := range index.Index { + if b >= block-common.MaxNonce { + index.Index = index.Index[i:] + break + } + k.RemoveRecentMsg(ctx, b) + } + k.SetRecentMsg(ctx, recentMsgs) + index.Index = append(index.Index, block) + k.SetIndexRecentMsg(ctx, index) +} + +func (c *cacheValidator) add(validators map[string]*big.Int) { + for operator, newPower := range validators { + if power, ok := c.validators[operator]; ok { + if newPower.Cmp(zeroBig) == 0 { + delete(c.validators, operator) + c.update = true + } else if power.Cmp(newPower) != 0 { + c.validators[operator].Set(newPower) + c.update = true + } + } else { + c.update = true + np := *newPower + c.validators[operator] = &np + } + } +} + +func (c *cacheValidator) commit(ctx sdk.Context, k common.KeeperOracle) { + block := uint64(ctx.BlockHeight()) + k.SetValidatorUpdateBlock(ctx, types.ValidatorUpdateBlock{Block: block}) +} + +func (c *cacheParams) add(p *common.Params) { + // params' update is triggered when params is actually updated, so no need to do comparison here, just udpate and mark the flag + // TODO: add comparison check, that's something should be done for validation + c.params = p + c.update = true +} + +func (c *cacheParams) commit(ctx sdk.Context, k common.KeeperOracle) { + block := uint64(ctx.BlockHeight()) + index, _ := k.GetIndexRecentParams(ctx) + for i, b := range index.Index { + if b >= block-common.MaxNonce { + index.Index = index.Index[i:] + break + } + k.RemoveRecentParams(ctx, b) + } + // remove and append for KVStore + k.SetIndexRecentParams(ctx, index) + index.Index = append(index.Index, block) + k.SetIndexRecentParams(ctx, index) +} + +// memory cache +// func (c *Cache) AddCache(i any, k common.KeeperOracle) { +func (c *Cache) AddCache(i any) { + switch item := i.(type) { + case *ItemM: + c.msg.add(item) + // case *params: + case ItemP: + c.params.add(item) + case ItemV: + c.validators.add(item) + default: + panic("no other types are support") + } +} + +// func (c *Cache) RemoveCache(i any, k common.KeeperOracle) { +func (c *Cache) RemoveCache(i any) { + if item, isItemM := i.(*ItemM); isItemM { + c.msg.remove(item) + } +} + +func (c *Cache) GetCache(i any) bool { + switch item := i.(type) { + case ItemV: + if item == nil { + return false + } + for addr, power := range c.validators.validators { + item[addr] = power + } + case ItemP: + if item == nil { + return false + } + *item = *(c.params.params) + case *[]*ItemM: + if item == nil { + return false + } + tmp := make([]*ItemM, 0, len(c.msg)) + for _, msgs := range c.msg { + tmp = append(tmp, msgs...) + } + *item = tmp + default: + return false + } + return true +} + +func (c *Cache) CommitCache(ctx sdk.Context, reset bool, k common.KeeperOracle) { + if len(c.msg) > 0 { + c.msg.commit(ctx, k) + c.msg = make(map[uint64][]*ItemM) + } + + if c.validators.update { + c.validators.commit(ctx, k) + c.validators.update = false + } + + if c.params.update { + c.params.commit(ctx, k) + c.params.update = false + } + if reset { + c.ResetCaches() + } +} + +func (c *Cache) ResetCaches() { + *c = *(NewCache()) +} + +func NewCache() *Cache { + return &Cache{ + msg: make(map[uint64][]*ItemM), + validators: &cacheValidator{ + validators: make(map[string]*big.Int), + }, + params: &cacheParams{ + params: &common.Params{}, + }, + } +} diff --git a/x/oracle/keeper/cache/caches_test.go b/x/oracle/keeper/cache/caches_test.go new file mode 100644 index 000000000..25ad6ee48 --- /dev/null +++ b/x/oracle/keeper/cache/caches_test.go @@ -0,0 +1,102 @@ +package cache + +import ( + "math/big" + "testing" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + . "github.com/smartystreets/goconvey/convey" + // "go.uber.org/mock/gomock" +) + +func TestCache(t *testing.T) { + c := NewCache() + p := defaultParams + pWrapped := common.Params(p) + + // ctrl := gomock.NewController(t) + // defer ctrl.Finish() + // ko := common.NewMockKeeperOracle(ctrl) + // c.AddCache(CacheItemP(&pWrapped), ko) + + Convey("test cache", t, func() { + Convey("add pramams item", func() { + c.AddCache(ItemP(&pWrapped)) + pReturn := &common.Params{} + c.GetCache(ItemP(pReturn)) + So(*pReturn, ShouldResemble, pWrapped) + }) + + Convey("add validatorPower item", func() { + validatorPowers := map[string]*big.Int{ + "v1": big.NewInt(100), + "v2": big.NewInt(109), + "v3": big.NewInt(119), + } + c.AddCache(ItemV(validatorPowers)) + vpReturn := make(map[string]*big.Int) + Convey("for empty cache", func() { + c.GetCache(ItemV(vpReturn)) + So(vpReturn, ShouldResemble, validatorPowers) + }) + Convey("then update validatorPower item for this cache", func() { + validaotrPowers := map[string]*big.Int{ + // add v5 + "v5": big.NewInt(123), + // remove v1 + "v1": big.NewInt(0), + // update v2 + "v2": big.NewInt(199), + } + c.AddCache(ItemV(validaotrPowers)) + c.GetCache(ItemV(vpReturn)) + So(vpReturn, ShouldNotContainKey, "v1") + So(vpReturn, ShouldContainKey, "v5") + So(vpReturn["v2"], ShouldResemble, big.NewInt(199)) + }) + }) + + Convey("add msg item", func() { + msgItems := []*ItemM{ + { + FeederID: 1, + PSources: []*types.PriceSource{ + { + SourceID: 1, + Prices: []*types.PriceTimeDetID{ + {Price: "600000", Decimal: 1, Timestamp: "-", DetID: "1"}, {Price: "620000", Decimal: 1, Timestamp: "-", DetID: "2"}, + }, + }, + }, + Validator: "v1", + }, + { + FeederID: 1, + PSources: []*types.PriceSource{ + {SourceID: 1, Prices: []*types.PriceTimeDetID{{Price: "600000", Decimal: 1, Timestamp: "-", DetID: "4"}, {Price: "620000", Decimal: 1, Timestamp: "-", DetID: "3"}}}, + }, + Validator: "v1", + }, + { + FeederID: 2, + PSources: []*types.PriceSource{{SourceID: 1, Prices: []*types.PriceTimeDetID{{Price: "30000", Decimal: 1, Timestamp: "-", DetID: "4"}, {Price: "32000", Decimal: 1, Timestamp: "-", DetID: "3"}}}}, + Validator: "v2", + }, + } + c.AddCache(msgItems[0]) + msgItemsReturn := make([]*ItemM, 0, 3) + Convey("add single item", func() { + c.GetCache(&msgItemsReturn) + So(msgItemsReturn, ShouldContain, msgItems[0]) + }) + Convey("add more items", func() { + c.AddCache(msgItems[1]) + c.AddCache(msgItems[2]) + c.GetCache(&msgItemsReturn) + So(msgItemsReturn, ShouldContain, msgItems[2]) + So(msgItemsReturn, ShouldNotContain, msgItems[0]) + }) + }) + }) +} diff --git a/x/oracle/keeper/cache/info_test.go b/x/oracle/keeper/cache/info_test.go new file mode 100644 index 000000000..8514b8a68 --- /dev/null +++ b/x/oracle/keeper/cache/info_test.go @@ -0,0 +1,11 @@ +package cache + +import "github.com/ExocoreNetwork/exocore/x/oracle/types" + +var defaultParams = types.Params{ + Chains: []*types.Chain{{Name: "-", Desc: "-"}, {Name: "Ethereum", Desc: "-"}}, + Tokens: []*types.Token{{}, {Name: "eth", ChainID: 1, ContractAddress: "0xabc", Decimal: 18, Active: true}}, + Sources: []*types.Source{{}, {Name: "chainLink", Entry: &types.Endpoint{}, Valid: true, Deterministic: true}}, + Rules: []*types.RuleSource{{}, {SourceIDs: []uint64{1}}}, + TokenFeeders: []*types.TokenFeeder{{}, {TokenID: 1, RuleID: 1, StartRoundID: 1, StartBaseBlock: 0, Interval: 10, EndBlock: 0}}, +} diff --git a/x/oracle/keeper/common/common_test.go b/x/oracle/keeper/common/common_test.go new file mode 100644 index 000000000..08944dcaf --- /dev/null +++ b/x/oracle/keeper/common/common_test.go @@ -0,0 +1,29 @@ +package common + +import ( + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + . "github.com/smartystreets/goconvey/convey" + "go.uber.org/mock/gomock" +) + +//go:generate mockgen -destination mock_keeper_test.go -package common github.com/ExocoreNetwork/exocore/x/oracle/keeper/common KeeperOracle + +//go:generate mockgen -destination mock_validator_test.go -package common github.com/cosmos/cosmos-sdk/x/staking/types ValidatorI + +func TestMock(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + ko := NewMockKeeperOracle(ctrl) + + ko.EXPECT().GetLastTotalPower(gomock.Any()).Return(math.NewInt(99)) + + x := ko.GetLastTotalPower(sdk.Context{}) + _ = x + + Convey("mock oracle keeper", t, func() { + Convey("GetLastTotalPower", func() { So(x, ShouldResemble, math.NewInt(99)) }) + }) +} diff --git a/x/oracle/keeper/common/expected_keepers.go b/x/oracle/keeper/common/expected_keepers.go new file mode 100644 index 000000000..23e419ab6 --- /dev/null +++ b/x/oracle/keeper/common/expected_keepers.go @@ -0,0 +1,44 @@ +package common + +import ( + "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type KeeperOracle interface { + KeeperStaking + + GetParams(sdk.Context) types.Params + + GetIndexRecentMsg(sdk.Context) (types.IndexRecentMsg, bool) + GetAllRecentMsgAsMap(sdk.Context) map[int64][]*types.MsgItem + + GetIndexRecentParams(sdk.Context) (types.IndexRecentParams, bool) + GetAllRecentParamsAsMap(sdk.Context) map[int64]*types.Params + + GetValidatorUpdateBlock(sdk.Context) (types.ValidatorUpdateBlock, bool) + + SetIndexRecentMsg(sdk.Context, types.IndexRecentMsg) + SetRecentMsg(sdk.Context, types.RecentMsg) + + SetIndexRecentParams(sdk.Context, types.IndexRecentParams) + SetRecentParams(sdk.Context, types.RecentParams) + + SetValidatorUpdateBlock(sdk.Context, types.ValidatorUpdateBlock) + + RemoveRecentParams(sdk.Context, uint64) + RemoveRecentMsg(sdk.Context, uint64) +} + +var _ KeeperStaking = stakingkeeper.Keeper{} + +type KeeperStaking interface { + GetLastTotalPower(ctx sdk.Context) math.Int + IterateBondedValidatorsByPower(ctx sdk.Context, fn func(index int64, validator stakingTypes.ValidatorI) (stop bool)) + GetValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate + GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingTypes.Validator, found bool) +} diff --git a/x/oracle/keeper/common/mock_keeper_test.go b/x/oracle/keeper/common/mock_keeper_test.go new file mode 100644 index 000000000..0e6f96e3e --- /dev/null +++ b/x/oracle/keeper/common/mock_keeper_test.go @@ -0,0 +1,270 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/ExocoreNetwork/exocore/x/oracle/keeper/common (interfaces: KeeperOracle) +// +// Generated by this command: +// +// mockgen -destination mock_keeper_test.go -package common github.com/ExocoreNetwork/exocore/x/oracle/keeper/common KeeperOracle +// + +// Package common is a generated GoMock package. +package common + +import ( + reflect "reflect" + + math "cosmossdk.io/math" + types "github.com/ExocoreNetwork/exocore/x/oracle/types" + types0 "github.com/cometbft/cometbft/abci/types" + types1 "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + gomock "go.uber.org/mock/gomock" +) + +// MockKeeperOracle is a mock of KeeperOracle interface. +type MockKeeperOracle struct { + ctrl *gomock.Controller + recorder *MockKeeperOracleMockRecorder +} + +// MockKeeperOracleMockRecorder is the mock recorder for MockKeeperOracle. +type MockKeeperOracleMockRecorder struct { + mock *MockKeeperOracle +} + +// NewMockKeeperOracle creates a new mock instance. +func NewMockKeeperOracle(ctrl *gomock.Controller) *MockKeeperOracle { + mock := &MockKeeperOracle{ctrl: ctrl} + mock.recorder = &MockKeeperOracleMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockKeeperOracle) EXPECT() *MockKeeperOracleMockRecorder { + return m.recorder +} + +// GetAllRecentMsgAsMap mocks base method. +func (m *MockKeeperOracle) GetAllRecentMsgAsMap(arg0 types1.Context) map[int64][]*types.MsgItem { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllRecentMsgAsMap", arg0) + ret0, _ := ret[0].(map[int64][]*types.MsgItem) + return ret0 +} + +// GetAllRecentMsgAsMap indicates an expected call of GetAllRecentMsgAsMap. +func (mr *MockKeeperOracleMockRecorder) GetAllRecentMsgAsMap(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllRecentMsgAsMap", reflect.TypeOf((*MockKeeperOracle)(nil).GetAllRecentMsgAsMap), arg0) +} + +// GetAllRecentParamsAsMap mocks base method. +func (m *MockKeeperOracle) GetAllRecentParamsAsMap(arg0 types1.Context) map[uint64]*types.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllRecentParamsAsMap", arg0) + ret0, _ := ret[0].(map[uint64]*types.Params) + return ret0 +} + +// GetAllRecentParamsAsMap indicates an expected call of GetAllRecentParamsAsMap. +func (mr *MockKeeperOracleMockRecorder) GetAllRecentParamsAsMap(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllRecentParamsAsMap", reflect.TypeOf((*MockKeeperOracle)(nil).GetAllRecentParamsAsMap), arg0) +} + +// GetIndexRecentMsg mocks base method. +func (m *MockKeeperOracle) GetIndexRecentMsg(arg0 types1.Context) (types.IndexRecentMsg, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetIndexRecentMsg", arg0) + ret0, _ := ret[0].(types.IndexRecentMsg) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetIndexRecentMsg indicates an expected call of GetIndexRecentMsg. +func (mr *MockKeeperOracleMockRecorder) GetIndexRecentMsg(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIndexRecentMsg", reflect.TypeOf((*MockKeeperOracle)(nil).GetIndexRecentMsg), arg0) +} + +// GetIndexRecentParams mocks base method. +func (m *MockKeeperOracle) GetIndexRecentParams(arg0 types1.Context) (types.IndexRecentParams, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetIndexRecentParams", arg0) + ret0, _ := ret[0].(types.IndexRecentParams) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetIndexRecentParams indicates an expected call of GetIndexRecentParams. +func (mr *MockKeeperOracleMockRecorder) GetIndexRecentParams(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIndexRecentParams", reflect.TypeOf((*MockKeeperOracle)(nil).GetIndexRecentParams), arg0) +} + +// GetLastTotalPower mocks base method. +func (m *MockKeeperOracle) GetLastTotalPower(arg0 types1.Context) math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLastTotalPower", arg0) + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetLastTotalPower indicates an expected call of GetLastTotalPower. +func (mr *MockKeeperOracleMockRecorder) GetLastTotalPower(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastTotalPower", reflect.TypeOf((*MockKeeperOracle)(nil).GetLastTotalPower), arg0) +} + +// GetParams mocks base method. +func (m *MockKeeperOracle) GetParams(arg0 types1.Context) types.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", arg0) + ret0, _ := ret[0].(types.Params) + return ret0 +} + +// GetParams indicates an expected call of GetParams. +func (mr *MockKeeperOracleMockRecorder) GetParams(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockKeeperOracle)(nil).GetParams), arg0) +} + +// GetValidatorByConsAddr mocks base method. +func (m *MockKeeperOracle) GetValidatorByConsAddr(arg0 types1.Context, arg1 types1.ConsAddress) (types2.Validator, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetValidatorByConsAddr", arg0, arg1) + ret0, _ := ret[0].(types2.Validator) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetValidatorByConsAddr indicates an expected call of GetValidatorByConsAddr. +func (mr *MockKeeperOracleMockRecorder) GetValidatorByConsAddr(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorByConsAddr", reflect.TypeOf((*MockKeeperOracle)(nil).GetValidatorByConsAddr), arg0, arg1) +} + +// GetValidatorUpdateBlock mocks base method. +func (m *MockKeeperOracle) GetValidatorUpdateBlock(arg0 types1.Context) (types.ValidatorUpdateBlock, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetValidatorUpdateBlock", arg0) + ret0, _ := ret[0].(types.ValidatorUpdateBlock) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetValidatorUpdateBlock indicates an expected call of GetValidatorUpdateBlock. +func (mr *MockKeeperOracleMockRecorder) GetValidatorUpdateBlock(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorUpdateBlock", reflect.TypeOf((*MockKeeperOracle)(nil).GetValidatorUpdateBlock), arg0) +} + +// GetValidatorUpdates mocks base method. +func (m *MockKeeperOracle) GetValidatorUpdates(arg0 types1.Context) []types0.ValidatorUpdate { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetValidatorUpdates", arg0) + ret0, _ := ret[0].([]types0.ValidatorUpdate) + return ret0 +} + +// GetValidatorUpdates indicates an expected call of GetValidatorUpdates. +func (mr *MockKeeperOracleMockRecorder) GetValidatorUpdates(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorUpdates", reflect.TypeOf((*MockKeeperOracle)(nil).GetValidatorUpdates), arg0) +} + +// IterateBondedValidatorsByPower mocks base method. +func (m *MockKeeperOracle) IterateBondedValidatorsByPower(arg0 types1.Context, arg1 func(int64, types2.ValidatorI) bool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1) +} + +// IterateBondedValidatorsByPower indicates an expected call of IterateBondedValidatorsByPower. +func (mr *MockKeeperOracleMockRecorder) IterateBondedValidatorsByPower(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateBondedValidatorsByPower", reflect.TypeOf((*MockKeeperOracle)(nil).IterateBondedValidatorsByPower), arg0, arg1) +} + +// RemoveRecentMsg mocks base method. +func (m *MockKeeperOracle) RemoveRecentMsg(arg0 types1.Context, arg1 uint64) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RemoveRecentMsg", arg0, arg1) +} + +// RemoveRecentMsg indicates an expected call of RemoveRecentMsg. +func (mr *MockKeeperOracleMockRecorder) RemoveRecentMsg(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveRecentMsg", reflect.TypeOf((*MockKeeperOracle)(nil).RemoveRecentMsg), arg0, arg1) +} + +// RemoveRecentParams mocks base method. +func (m *MockKeeperOracle) RemoveRecentParams(arg0 types1.Context, arg1 uint64) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RemoveRecentParams", arg0, arg1) +} + +// RemoveRecentParams indicates an expected call of RemoveRecentParams. +func (mr *MockKeeperOracleMockRecorder) RemoveRecentParams(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveRecentParams", reflect.TypeOf((*MockKeeperOracle)(nil).RemoveRecentParams), arg0, arg1) +} + +// SetIndexRecentMsg mocks base method. +func (m *MockKeeperOracle) SetIndexRecentMsg(arg0 types1.Context, arg1 types.IndexRecentMsg) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetIndexRecentMsg", arg0, arg1) +} + +// SetIndexRecentMsg indicates an expected call of SetIndexRecentMsg. +func (mr *MockKeeperOracleMockRecorder) SetIndexRecentMsg(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetIndexRecentMsg", reflect.TypeOf((*MockKeeperOracle)(nil).SetIndexRecentMsg), arg0, arg1) +} + +// SetIndexRecentParams mocks base method. +func (m *MockKeeperOracle) SetIndexRecentParams(arg0 types1.Context, arg1 types.IndexRecentParams) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetIndexRecentParams", arg0, arg1) +} + +// SetIndexRecentParams indicates an expected call of SetIndexRecentParams. +func (mr *MockKeeperOracleMockRecorder) SetIndexRecentParams(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetIndexRecentParams", reflect.TypeOf((*MockKeeperOracle)(nil).SetIndexRecentParams), arg0, arg1) +} + +// SetRecentMsg mocks base method. +func (m *MockKeeperOracle) SetRecentMsg(arg0 types1.Context, arg1 types.RecentMsg) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetRecentMsg", arg0, arg1) +} + +// SetRecentMsg indicates an expected call of SetRecentMsg. +func (mr *MockKeeperOracleMockRecorder) SetRecentMsg(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRecentMsg", reflect.TypeOf((*MockKeeperOracle)(nil).SetRecentMsg), arg0, arg1) +} + +// SetRecentParams mocks base method. +func (m *MockKeeperOracle) SetRecentParams(arg0 types1.Context, arg1 types.RecentParams) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetRecentParams", arg0, arg1) +} + +// SetRecentParams indicates an expected call of SetRecentParams. +func (mr *MockKeeperOracleMockRecorder) SetRecentParams(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRecentParams", reflect.TypeOf((*MockKeeperOracle)(nil).SetRecentParams), arg0, arg1) +} + +// SetValidatorUpdateBlock mocks base method. +func (m *MockKeeperOracle) SetValidatorUpdateBlock(arg0 types1.Context, arg1 types.ValidatorUpdateBlock) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetValidatorUpdateBlock", arg0, arg1) +} + +// SetValidatorUpdateBlock indicates an expected call of SetValidatorUpdateBlock. +func (mr *MockKeeperOracleMockRecorder) SetValidatorUpdateBlock(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetValidatorUpdateBlock", reflect.TypeOf((*MockKeeperOracle)(nil).SetValidatorUpdateBlock), arg0, arg1) +} diff --git a/x/oracle/keeper/common/mock_validator_test.go b/x/oracle/keeper/common/mock_validator_test.go new file mode 100644 index 000000000..6e84bfe0a --- /dev/null +++ b/x/oracle/keeper/common/mock_validator_test.go @@ -0,0 +1,343 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/cosmos/cosmos-sdk/x/staking/types (interfaces: ValidatorI) +// +// Generated by this command: +// +// mockgen -destination mock_validator_test.go -package common github.com/cosmos/cosmos-sdk/x/staking/types ValidatorI +// + +// Package common is a generated GoMock package. +package common + +import ( + reflect "reflect" + + math "cosmossdk.io/math" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + types "github.com/cosmos/cosmos-sdk/crypto/types" + types0 "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + gomock "go.uber.org/mock/gomock" +) + +// MockValidatorI is a mock of ValidatorI interface. +type MockValidatorI struct { + ctrl *gomock.Controller + recorder *MockValidatorIMockRecorder +} + +// MockValidatorIMockRecorder is the mock recorder for MockValidatorI. +type MockValidatorIMockRecorder struct { + mock *MockValidatorI +} + +// NewMockValidatorI creates a new mock instance. +func NewMockValidatorI(ctrl *gomock.Controller) *MockValidatorI { + mock := &MockValidatorI{ctrl: ctrl} + mock.recorder = &MockValidatorIMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockValidatorI) EXPECT() *MockValidatorIMockRecorder { + return m.recorder +} + +// ConsPubKey mocks base method. +func (m *MockValidatorI) ConsPubKey() (types.PubKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConsPubKey") + ret0, _ := ret[0].(types.PubKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConsPubKey indicates an expected call of ConsPubKey. +func (mr *MockValidatorIMockRecorder) ConsPubKey() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsPubKey", reflect.TypeOf((*MockValidatorI)(nil).ConsPubKey)) +} + +// GetBondedTokens mocks base method. +func (m *MockValidatorI) GetBondedTokens() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBondedTokens") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetBondedTokens indicates an expected call of GetBondedTokens. +func (mr *MockValidatorIMockRecorder) GetBondedTokens() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBondedTokens", reflect.TypeOf((*MockValidatorI)(nil).GetBondedTokens)) +} + +// GetCommission mocks base method. +func (m *MockValidatorI) GetCommission() math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCommission") + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// GetCommission indicates an expected call of GetCommission. +func (mr *MockValidatorIMockRecorder) GetCommission() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommission", reflect.TypeOf((*MockValidatorI)(nil).GetCommission)) +} + +// GetConsAddr mocks base method. +func (m *MockValidatorI) GetConsAddr() (types0.ConsAddress, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsAddr") + ret0, _ := ret[0].(types0.ConsAddress) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetConsAddr indicates an expected call of GetConsAddr. +func (mr *MockValidatorIMockRecorder) GetConsAddr() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsAddr", reflect.TypeOf((*MockValidatorI)(nil).GetConsAddr)) +} + +// GetConsensusPower mocks base method. +func (m *MockValidatorI) GetConsensusPower(arg0 math.Int) int64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsensusPower", arg0) + ret0, _ := ret[0].(int64) + return ret0 +} + +// GetConsensusPower indicates an expected call of GetConsensusPower. +func (mr *MockValidatorIMockRecorder) GetConsensusPower(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsensusPower", reflect.TypeOf((*MockValidatorI)(nil).GetConsensusPower), arg0) +} + +// GetDelegatorShares mocks base method. +func (m *MockValidatorI) GetDelegatorShares() math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDelegatorShares") + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// GetDelegatorShares indicates an expected call of GetDelegatorShares. +func (mr *MockValidatorIMockRecorder) GetDelegatorShares() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDelegatorShares", reflect.TypeOf((*MockValidatorI)(nil).GetDelegatorShares)) +} + +// GetMinSelfDelegation mocks base method. +func (m *MockValidatorI) GetMinSelfDelegation() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMinSelfDelegation") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetMinSelfDelegation indicates an expected call of GetMinSelfDelegation. +func (mr *MockValidatorIMockRecorder) GetMinSelfDelegation() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMinSelfDelegation", reflect.TypeOf((*MockValidatorI)(nil).GetMinSelfDelegation)) +} + +// GetMoniker mocks base method. +func (m *MockValidatorI) GetMoniker() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMoniker") + ret0, _ := ret[0].(string) + return ret0 +} + +// GetMoniker indicates an expected call of GetMoniker. +func (mr *MockValidatorIMockRecorder) GetMoniker() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMoniker", reflect.TypeOf((*MockValidatorI)(nil).GetMoniker)) +} + +// GetOperator mocks base method. +func (m *MockValidatorI) GetOperator() types0.ValAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOperator") + ret0, _ := ret[0].(types0.ValAddress) + return ret0 +} + +// GetOperator indicates an expected call of GetOperator. +func (mr *MockValidatorIMockRecorder) GetOperator() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOperator", reflect.TypeOf((*MockValidatorI)(nil).GetOperator)) +} + +// GetStatus mocks base method. +func (m *MockValidatorI) GetStatus() types1.BondStatus { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStatus") + ret0, _ := ret[0].(types1.BondStatus) + return ret0 +} + +// GetStatus indicates an expected call of GetStatus. +func (mr *MockValidatorIMockRecorder) GetStatus() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatus", reflect.TypeOf((*MockValidatorI)(nil).GetStatus)) +} + +// GetTokens mocks base method. +func (m *MockValidatorI) GetTokens() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTokens") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetTokens indicates an expected call of GetTokens. +func (mr *MockValidatorIMockRecorder) GetTokens() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokens", reflect.TypeOf((*MockValidatorI)(nil).GetTokens)) +} + +// IsBonded mocks base method. +func (m *MockValidatorI) IsBonded() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsBonded") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsBonded indicates an expected call of IsBonded. +func (mr *MockValidatorIMockRecorder) IsBonded() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsBonded", reflect.TypeOf((*MockValidatorI)(nil).IsBonded)) +} + +// IsJailed mocks base method. +func (m *MockValidatorI) IsJailed() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsJailed") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsJailed indicates an expected call of IsJailed. +func (mr *MockValidatorIMockRecorder) IsJailed() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsJailed", reflect.TypeOf((*MockValidatorI)(nil).IsJailed)) +} + +// IsUnbonded mocks base method. +func (m *MockValidatorI) IsUnbonded() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUnbonded") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsUnbonded indicates an expected call of IsUnbonded. +func (mr *MockValidatorIMockRecorder) IsUnbonded() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnbonded", reflect.TypeOf((*MockValidatorI)(nil).IsUnbonded)) +} + +// IsUnbonding mocks base method. +func (m *MockValidatorI) IsUnbonding() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUnbonding") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsUnbonding indicates an expected call of IsUnbonding. +func (mr *MockValidatorIMockRecorder) IsUnbonding() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnbonding", reflect.TypeOf((*MockValidatorI)(nil).IsUnbonding)) +} + +// SharesFromTokens mocks base method. +func (m *MockValidatorI) SharesFromTokens(arg0 math.Int) (math.LegacyDec, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SharesFromTokens", arg0) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SharesFromTokens indicates an expected call of SharesFromTokens. +func (mr *MockValidatorIMockRecorder) SharesFromTokens(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SharesFromTokens", reflect.TypeOf((*MockValidatorI)(nil).SharesFromTokens), arg0) +} + +// SharesFromTokensTruncated mocks base method. +func (m *MockValidatorI) SharesFromTokensTruncated(arg0 math.Int) (math.LegacyDec, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SharesFromTokensTruncated", arg0) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SharesFromTokensTruncated indicates an expected call of SharesFromTokensTruncated. +func (mr *MockValidatorIMockRecorder) SharesFromTokensTruncated(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SharesFromTokensTruncated", reflect.TypeOf((*MockValidatorI)(nil).SharesFromTokensTruncated), arg0) +} + +// TmConsPublicKey mocks base method. +func (m *MockValidatorI) TmConsPublicKey() (crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TmConsPublicKey") + ret0, _ := ret[0].(crypto.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TmConsPublicKey indicates an expected call of TmConsPublicKey. +func (mr *MockValidatorIMockRecorder) TmConsPublicKey() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TmConsPublicKey", reflect.TypeOf((*MockValidatorI)(nil).TmConsPublicKey)) +} + +// TokensFromShares mocks base method. +func (m *MockValidatorI) TokensFromShares(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromShares", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromShares indicates an expected call of TokensFromShares. +func (mr *MockValidatorIMockRecorder) TokensFromShares(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromShares", reflect.TypeOf((*MockValidatorI)(nil).TokensFromShares), arg0) +} + +// TokensFromSharesRoundUp mocks base method. +func (m *MockValidatorI) TokensFromSharesRoundUp(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromSharesRoundUp", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromSharesRoundUp indicates an expected call of TokensFromSharesRoundUp. +func (mr *MockValidatorIMockRecorder) TokensFromSharesRoundUp(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromSharesRoundUp", reflect.TypeOf((*MockValidatorI)(nil).TokensFromSharesRoundUp), arg0) +} + +// TokensFromSharesTruncated mocks base method. +func (m *MockValidatorI) TokensFromSharesTruncated(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromSharesTruncated", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromSharesTruncated indicates an expected call of TokensFromSharesTruncated. +func (mr *MockValidatorIMockRecorder) TokensFromSharesTruncated(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromSharesTruncated", reflect.TypeOf((*MockValidatorI)(nil).TokensFromSharesTruncated), arg0) +} diff --git a/x/oracle/keeper/common/types.go b/x/oracle/keeper/common/types.go new file mode 100644 index 000000000..4d82e1115 --- /dev/null +++ b/x/oracle/keeper/common/types.go @@ -0,0 +1,174 @@ +package common + +import ( + "errors" + "math/big" + "sort" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +const ( + // maxNonce indicates how many messages a validator can submit in a single round to offer price + // current we use this as a mock distance + MaxNonce = 3 + + // these two threshold value used to set the threshold to tell when the price had come to consensus and was able to get a final price of that round + ThresholdA = 2 + ThresholdB = 3 + + // maxDetId each validator can submit, so the calculator can cache maximum of maxDetId*count(validators) values, this is for resistance of malicious validator submmiting invalid detId + MaxDetID = 5 + + // consensus mode: v1: as soon as possbile + Mode = 1 +) + +type Params types.Params + +func (p Params) GetTokenFeeders() []*types.TokenFeeder { + return p.TokenFeeders +} + +func (p Params) IsDeterministicSource(sourceID uint64) bool { + return p.Sources[sourceID].Deterministic +} + +func (p Params) IsValidSource(sourceID uint64) bool { + if sourceID == 0 { + // custom defined source + return true + } + return p.Sources[sourceID].Valid +} + +func (p Params) GetTokenFeeder(feederID uint64) *types.TokenFeeder { + for k, v := range p.TokenFeeders { + if uint64(k) == feederID { + return v + } + } + return nil +} + +func (p Params) GetTokenInfo(feederID uint64) *types.Token { + for k, v := range p.TokenFeeders { + if uint64(k) == feederID { + return p.Tokens[v.TokenID] + } + } + return nil +} + +func (p Params) CheckRules(feederID uint64, prices []*types.PriceSource) (bool, error) { + feeder := p.TokenFeeders[feederID] + rule := p.Rules[feeder.RuleID] + // specified sources set, v1 use this rule to set `chainlink` as official source + if rule.SourceIDs != nil && len(rule.SourceIDs) > 0 { + if len(rule.SourceIDs) != len(prices) { + return false, errors.New("count prices should match rule") + } + notFound := false + if rule.SourceIDs[0] == 0 { + // match all sources listed + for sID, source := range p.Sources { + if sID == 0 { + continue + } + if source.Valid { + notFound = true + for _, p := range prices { + if p.SourceID == uint64(sID) { + notFound = false + break + } + } + + } + } + } else { + for _, source := range rule.SourceIDs { + notFound = true + for _, p := range prices { + if p.SourceID == source { + notFound = false + break + } + } + // return false, errors.New("price source not match with rule") + } + } + if notFound { + return false, errors.New("price source not match with rule") + } + } + + // TODO: check NOM + // return true if no rule set, we will accept any source + return true, nil +} + +type Set[T comparable] struct { + size int + slice []T +} + +func (s *Set[T]) Add(value T) bool { + if len(s.slice) == s.size { + return false + } + for _, v := range s.slice { + if v == value { + return false + } + } + s.slice = append(s.slice, value) + return true +} + +func (s *Set[T]) Has(value T) bool { + for _, v := range s.slice { + if v == value { + return true + } + } + return false +} + +func (s *Set[T]) Length() int { + return s.size +} + +func NewSet[T comparable](length int) *Set[T] { + return &Set[T]{ + size: length, + slice: make([]T, 0, length), + } +} + +func ExceedsThreshold(power *big.Int, totalPower *big.Int) bool { + return new(big.Int).Mul(power, big.NewInt(ThresholdB)).Cmp(new(big.Int).Mul(totalPower, big.NewInt(ThresholdA))) > 0 +} + +type BigIntList []*big.Int + +func (b BigIntList) Len() int { + return len(b) +} + +func (b BigIntList) Less(i, j int) bool { + return b[i].Cmp(b[j]) < 0 +} + +func (b BigIntList) Swap(i, j int) { + b[i], b[j] = b[j], b[i] +} + +func (b BigIntList) Median() *big.Int { + sort.Sort(b) + l := len(b) + if l%2 == 1 { + return b[l/2] + } + return new(big.Int).Div(new(big.Int).Add(b[l/2], b[l/2-1]), big.NewInt(2)) +} diff --git a/x/oracle/keeper/index_recent_msg.go b/x/oracle/keeper/index_recent_msg.go new file mode 100644 index 000000000..6a63c39fa --- /dev/null +++ b/x/oracle/keeper/index_recent_msg.go @@ -0,0 +1,34 @@ +//nolint:dupl +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetIndexRecentMsg set indexRecentMsg in the store +func (k Keeper) SetIndexRecentMsg(ctx sdk.Context, indexRecentMsg types.IndexRecentMsg) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentMsgKey)) + b := k.cdc.MustMarshal(&indexRecentMsg) + store.Set([]byte{0}, b) +} + +// GetIndexRecentMsg returns indexRecentMsg +func (k Keeper) GetIndexRecentMsg(ctx sdk.Context) (val types.IndexRecentMsg, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentMsgKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveIndexRecentMsg removes indexRecentMsg from the store +func (k Keeper) RemoveIndexRecentMsg(ctx sdk.Context) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentMsgKey)) + store.Delete([]byte{0}) +} diff --git a/x/oracle/keeper/index_recent_msg_test.go b/x/oracle/keeper/index_recent_msg_test.go new file mode 100644 index 000000000..9f7db965c --- /dev/null +++ b/x/oracle/keeper/index_recent_msg_test.go @@ -0,0 +1,38 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func createTestIndexRecentMsg(keeper *keeper.Keeper, ctx sdk.Context) types.IndexRecentMsg { + item := types.IndexRecentMsg{} + keeper.SetIndexRecentMsg(ctx, item) + return item +} + +func TestIndexRecentMsgGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + item := createTestIndexRecentMsg(keeper, ctx) + rst, found := keeper.GetIndexRecentMsg(ctx) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) +} + +func TestIndexRecentMsgRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + createTestIndexRecentMsg(keeper, ctx) + keeper.RemoveIndexRecentMsg(ctx) + _, found := keeper.GetIndexRecentMsg(ctx) + require.False(t, found) +} diff --git a/x/oracle/keeper/index_recent_params.go b/x/oracle/keeper/index_recent_params.go new file mode 100644 index 000000000..769b0471a --- /dev/null +++ b/x/oracle/keeper/index_recent_params.go @@ -0,0 +1,34 @@ +// nolint +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetIndexRecentParams set indexRecentParams in the store +func (k Keeper) SetIndexRecentParams(ctx sdk.Context, indexRecentParams types.IndexRecentParams) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentParamsKey)) + b := k.cdc.MustMarshal(&indexRecentParams) + store.Set([]byte{0}, b) +} + +// GetIndexRecentParams returns indexRecentParams +func (k Keeper) GetIndexRecentParams(ctx sdk.Context) (val types.IndexRecentParams, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentParamsKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveIndexRecentParams removes indexRecentParams from the store +func (k Keeper) RemoveIndexRecentParams(ctx sdk.Context) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.IndexRecentParamsKey)) + store.Delete([]byte{0}) +} diff --git a/x/oracle/keeper/index_recent_params_test.go b/x/oracle/keeper/index_recent_params_test.go new file mode 100644 index 000000000..89f5f2a7c --- /dev/null +++ b/x/oracle/keeper/index_recent_params_test.go @@ -0,0 +1,38 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func createTestIndexRecentParams(keeper *keeper.Keeper, ctx sdk.Context) types.IndexRecentParams { + item := types.IndexRecentParams{} + keeper.SetIndexRecentParams(ctx, item) + return item +} + +func TestIndexRecentParamsGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + item := createTestIndexRecentParams(keeper, ctx) + rst, found := keeper.GetIndexRecentParams(ctx) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) +} + +func TestIndexRecentParamsRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + createTestIndexRecentParams(keeper, ctx) + keeper.RemoveIndexRecentParams(ctx) + _, found := keeper.GetIndexRecentParams(ctx) + require.False(t, found) +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go new file mode 100644 index 000000000..f367e14de --- /dev/null +++ b/x/oracle/keeper/keeper.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + authority string + common.KeeperStaking + } +) + +var _ common.KeeperOracle = Keeper{} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + sKeeper common.KeeperStaking, +) Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + KeeperStaking: sKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/oracle/keeper/keeper_suite_test.go b/x/oracle/keeper/keeper_suite_test.go new file mode 100644 index 000000000..29b0b758d --- /dev/null +++ b/x/oracle/keeper/keeper_suite_test.go @@ -0,0 +1,63 @@ +package keeper_test + +import ( + "context" + "testing" + + "github.com/ExocoreNetwork/exocore/testutil" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + gomock "go.uber.org/mock/gomock" +) + +type KeeperSuite struct { + testutil.BaseTestSuite + + t *testing.T + k keeper.Keeper + ctx sdk.Context + ms types.MsgServer + ctrl *gomock.Controller + valAddr1 sdk.ValAddress + valAddr2 sdk.ValAddress +} + +var ks *KeeperSuite + +func TestKeeper(t *testing.T) { + var ctxW context.Context + ks = &KeeperSuite{} + ks.ms, ctxW, ks.k = setupMsgServer(t) + ks.ctx = sdk.UnwrapSDKContext(ctxW) + ks.t = t + + suite.Run(t, ks) + + resetSingle() + RegisterFailHandler(Fail) + RunSpecs(t, "Keeper Suite") +} + +func (suite *KeeperSuite) Reset() { + var ctxW context.Context + suite.ms, ctxW, suite.k = setupMsgServer(suite.t) + suite.ctx = sdk.UnwrapSDKContext(ctxW) + suite.ctrl = gomock.NewController(suite.t) +} + +func (suite *KeeperSuite) SetupTest() { + suite.DoSetupTest() + suite.valAddr1, _ = sdk.ValAddressFromBech32(suite.Validators[0].OperatorAddress) + suite.valAddr2, _ = sdk.ValAddressFromBech32(suite.Validators[1].OperatorAddress) + resetSingle() +} + +func resetSingle() { + keeper.ResetAggregatorContext() + keeper.ResetCache() +} diff --git a/x/oracle/keeper/mock_validator_test.go b/x/oracle/keeper/mock_validator_test.go new file mode 100644 index 000000000..927beef3d --- /dev/null +++ b/x/oracle/keeper/mock_validator_test.go @@ -0,0 +1,343 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/cosmos/cosmos-sdk/x/staking/types (interfaces: ValidatorI) +// +// Generated by this command: +// +// mockgen -destination mock_validator_test.go -package keeper_test github.com/cosmos/cosmos-sdk/x/staking/types ValidatorI +// + +// Package keeper_test is a generated GoMock package. +package keeper_test + +import ( + reflect "reflect" + + math "cosmossdk.io/math" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + types "github.com/cosmos/cosmos-sdk/crypto/types" + types0 "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" + gomock "go.uber.org/mock/gomock" +) + +// MockValidatorI is a mock of ValidatorI interface. +type MockValidatorI struct { + ctrl *gomock.Controller + recorder *MockValidatorIMockRecorder +} + +// MockValidatorIMockRecorder is the mock recorder for MockValidatorI. +type MockValidatorIMockRecorder struct { + mock *MockValidatorI +} + +// NewMockValidatorI creates a new mock instance. +func NewMockValidatorI(ctrl *gomock.Controller) *MockValidatorI { + mock := &MockValidatorI{ctrl: ctrl} + mock.recorder = &MockValidatorIMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockValidatorI) EXPECT() *MockValidatorIMockRecorder { + return m.recorder +} + +// ConsPubKey mocks base method. +func (m *MockValidatorI) ConsPubKey() (types.PubKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConsPubKey") + ret0, _ := ret[0].(types.PubKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConsPubKey indicates an expected call of ConsPubKey. +func (mr *MockValidatorIMockRecorder) ConsPubKey() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsPubKey", reflect.TypeOf((*MockValidatorI)(nil).ConsPubKey)) +} + +// GetBondedTokens mocks base method. +func (m *MockValidatorI) GetBondedTokens() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBondedTokens") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetBondedTokens indicates an expected call of GetBondedTokens. +func (mr *MockValidatorIMockRecorder) GetBondedTokens() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBondedTokens", reflect.TypeOf((*MockValidatorI)(nil).GetBondedTokens)) +} + +// GetCommission mocks base method. +func (m *MockValidatorI) GetCommission() math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCommission") + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// GetCommission indicates an expected call of GetCommission. +func (mr *MockValidatorIMockRecorder) GetCommission() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommission", reflect.TypeOf((*MockValidatorI)(nil).GetCommission)) +} + +// GetConsAddr mocks base method. +func (m *MockValidatorI) GetConsAddr() (types0.ConsAddress, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsAddr") + ret0, _ := ret[0].(types0.ConsAddress) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetConsAddr indicates an expected call of GetConsAddr. +func (mr *MockValidatorIMockRecorder) GetConsAddr() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsAddr", reflect.TypeOf((*MockValidatorI)(nil).GetConsAddr)) +} + +// GetConsensusPower mocks base method. +func (m *MockValidatorI) GetConsensusPower(arg0 math.Int) int64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsensusPower", arg0) + ret0, _ := ret[0].(int64) + return ret0 +} + +// GetConsensusPower indicates an expected call of GetConsensusPower. +func (mr *MockValidatorIMockRecorder) GetConsensusPower(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsensusPower", reflect.TypeOf((*MockValidatorI)(nil).GetConsensusPower), arg0) +} + +// GetDelegatorShares mocks base method. +func (m *MockValidatorI) GetDelegatorShares() math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDelegatorShares") + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// GetDelegatorShares indicates an expected call of GetDelegatorShares. +func (mr *MockValidatorIMockRecorder) GetDelegatorShares() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDelegatorShares", reflect.TypeOf((*MockValidatorI)(nil).GetDelegatorShares)) +} + +// GetMinSelfDelegation mocks base method. +func (m *MockValidatorI) GetMinSelfDelegation() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMinSelfDelegation") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetMinSelfDelegation indicates an expected call of GetMinSelfDelegation. +func (mr *MockValidatorIMockRecorder) GetMinSelfDelegation() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMinSelfDelegation", reflect.TypeOf((*MockValidatorI)(nil).GetMinSelfDelegation)) +} + +// GetMoniker mocks base method. +func (m *MockValidatorI) GetMoniker() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMoniker") + ret0, _ := ret[0].(string) + return ret0 +} + +// GetMoniker indicates an expected call of GetMoniker. +func (mr *MockValidatorIMockRecorder) GetMoniker() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMoniker", reflect.TypeOf((*MockValidatorI)(nil).GetMoniker)) +} + +// GetOperator mocks base method. +func (m *MockValidatorI) GetOperator() types0.ValAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOperator") + ret0, _ := ret[0].(types0.ValAddress) + return ret0 +} + +// GetOperator indicates an expected call of GetOperator. +func (mr *MockValidatorIMockRecorder) GetOperator() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOperator", reflect.TypeOf((*MockValidatorI)(nil).GetOperator)) +} + +// GetStatus mocks base method. +func (m *MockValidatorI) GetStatus() types1.BondStatus { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetStatus") + ret0, _ := ret[0].(types1.BondStatus) + return ret0 +} + +// GetStatus indicates an expected call of GetStatus. +func (mr *MockValidatorIMockRecorder) GetStatus() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatus", reflect.TypeOf((*MockValidatorI)(nil).GetStatus)) +} + +// GetTokens mocks base method. +func (m *MockValidatorI) GetTokens() math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTokens") + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// GetTokens indicates an expected call of GetTokens. +func (mr *MockValidatorIMockRecorder) GetTokens() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokens", reflect.TypeOf((*MockValidatorI)(nil).GetTokens)) +} + +// IsBonded mocks base method. +func (m *MockValidatorI) IsBonded() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsBonded") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsBonded indicates an expected call of IsBonded. +func (mr *MockValidatorIMockRecorder) IsBonded() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsBonded", reflect.TypeOf((*MockValidatorI)(nil).IsBonded)) +} + +// IsJailed mocks base method. +func (m *MockValidatorI) IsJailed() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsJailed") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsJailed indicates an expected call of IsJailed. +func (mr *MockValidatorIMockRecorder) IsJailed() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsJailed", reflect.TypeOf((*MockValidatorI)(nil).IsJailed)) +} + +// IsUnbonded mocks base method. +func (m *MockValidatorI) IsUnbonded() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUnbonded") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsUnbonded indicates an expected call of IsUnbonded. +func (mr *MockValidatorIMockRecorder) IsUnbonded() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnbonded", reflect.TypeOf((*MockValidatorI)(nil).IsUnbonded)) +} + +// IsUnbonding mocks base method. +func (m *MockValidatorI) IsUnbonding() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUnbonding") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsUnbonding indicates an expected call of IsUnbonding. +func (mr *MockValidatorIMockRecorder) IsUnbonding() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnbonding", reflect.TypeOf((*MockValidatorI)(nil).IsUnbonding)) +} + +// SharesFromTokens mocks base method. +func (m *MockValidatorI) SharesFromTokens(arg0 math.Int) (math.LegacyDec, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SharesFromTokens", arg0) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SharesFromTokens indicates an expected call of SharesFromTokens. +func (mr *MockValidatorIMockRecorder) SharesFromTokens(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SharesFromTokens", reflect.TypeOf((*MockValidatorI)(nil).SharesFromTokens), arg0) +} + +// SharesFromTokensTruncated mocks base method. +func (m *MockValidatorI) SharesFromTokensTruncated(arg0 math.Int) (math.LegacyDec, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SharesFromTokensTruncated", arg0) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SharesFromTokensTruncated indicates an expected call of SharesFromTokensTruncated. +func (mr *MockValidatorIMockRecorder) SharesFromTokensTruncated(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SharesFromTokensTruncated", reflect.TypeOf((*MockValidatorI)(nil).SharesFromTokensTruncated), arg0) +} + +// TmConsPublicKey mocks base method. +func (m *MockValidatorI) TmConsPublicKey() (crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TmConsPublicKey") + ret0, _ := ret[0].(crypto.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TmConsPublicKey indicates an expected call of TmConsPublicKey. +func (mr *MockValidatorIMockRecorder) TmConsPublicKey() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TmConsPublicKey", reflect.TypeOf((*MockValidatorI)(nil).TmConsPublicKey)) +} + +// TokensFromShares mocks base method. +func (m *MockValidatorI) TokensFromShares(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromShares", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromShares indicates an expected call of TokensFromShares. +func (mr *MockValidatorIMockRecorder) TokensFromShares(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromShares", reflect.TypeOf((*MockValidatorI)(nil).TokensFromShares), arg0) +} + +// TokensFromSharesRoundUp mocks base method. +func (m *MockValidatorI) TokensFromSharesRoundUp(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromSharesRoundUp", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromSharesRoundUp indicates an expected call of TokensFromSharesRoundUp. +func (mr *MockValidatorIMockRecorder) TokensFromSharesRoundUp(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromSharesRoundUp", reflect.TypeOf((*MockValidatorI)(nil).TokensFromSharesRoundUp), arg0) +} + +// TokensFromSharesTruncated mocks base method. +func (m *MockValidatorI) TokensFromSharesTruncated(arg0 math.LegacyDec) math.LegacyDec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TokensFromSharesTruncated", arg0) + ret0, _ := ret[0].(math.LegacyDec) + return ret0 +} + +// TokensFromSharesTruncated indicates an expected call of TokensFromSharesTruncated. +func (mr *MockValidatorIMockRecorder) TokensFromSharesTruncated(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TokensFromSharesTruncated", reflect.TypeOf((*MockValidatorI)(nil).TokensFromSharesTruncated), arg0) +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go new file mode 100644 index 000000000..c4a81b3f6 --- /dev/null +++ b/x/oracle/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/oracle/keeper/msg_server_create_price.go b/x/oracle/keeper/msg_server_create_price.go new file mode 100644 index 000000000..e41b429d7 --- /dev/null +++ b/x/oracle/keeper/msg_server_create_price.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "context" + "strconv" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// CreatePrice proposes price for new round of specific tokenFeeder +func (ms msgServer) CreatePrice(goCtx context.Context, msg *types.MsgCreatePrice) (*types.MsgCreatePriceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + newItem, caches, err := GetAggregatorContext(ctx, ms.Keeper).NewCreatePrice(ctx, msg) + if err != nil { + return nil, err + } + + logger := ms.Keeper.Logger(ctx) + logger.Info("add price proposal for aggregation", "feederID", msg.FeederID, "basedBlock", msg.BasedBlock, "proposer", msg.Creator) + + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeCreatePrice, + sdk.NewAttribute(types.AttributeKeyFeederID, strconv.FormatUint(msg.FeederID, 10)), + sdk.NewAttribute(types.AttributeKeyBasedBlock, strconv.FormatUint(msg.BasedBlock, 10)), + sdk.NewAttribute(types.AttributeKeyProposer, msg.Creator), + ), + ) + + if caches != nil { + if newItem != nil { + ms.AppendPriceTR(ctx, newItem.TokenID, newItem.PriceTR) + + logger.Info("final price aggregation done", "feederID", msg.FeederID, "roundID", newItem.PriceTR.RoundID, "price", newItem.PriceTR.Price) + + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeCreatePrice, + sdk.NewAttribute(types.AttributeKeyFeederID, strconv.FormatUint(msg.FeederID, 10)), + sdk.NewAttribute(types.AttributeKeyRoundID, strconv.FormatUint(newItem.PriceTR.RoundID, 10)), + sdk.NewAttribute(types.AttributeKeyFinalPrice, newItem.PriceTR.Price), + sdk.NewAttribute(types.AttributeKeyPriceUpdated, types.AttributeValuePriceUpdatedSuccess), + ), + ) + cs.RemoveCache(caches) + } else { + cs.AddCache(caches) + } + } + + return &types.MsgCreatePriceResponse{}, nil +} diff --git a/x/oracle/keeper/msg_server_create_price_test.go b/x/oracle/keeper/msg_server_create_price_test.go new file mode 100644 index 000000000..27076d2ca --- /dev/null +++ b/x/oracle/keeper/msg_server_create_price_test.go @@ -0,0 +1,136 @@ +package keeper_test + +import ( + reflect "reflect" + + math "cosmossdk.io/math" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/cache" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/testdata" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + . "github.com/agiledragon/gomonkey/v2" + "github.com/cosmos/cosmos-sdk/testutil/mock" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + gomock "go.uber.org/mock/gomock" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +//go:generate mockgen -destination mock_validator_test.go -package keeper_test github.com/cosmos/cosmos-sdk/x/staking/types ValidatorI + +var _ = Describe("MsgCreatePrice", func() { + var operator1, operator2, operator3 sdk.ValAddress + var c *cache.Cache + var p *Patches + BeforeEach(func() { + ks.Reset() + Expect(ks.ms).ToNot(BeNil()) + + validatorC := NewMockValidatorI(ks.ctrl) + validatorC.EXPECT().GetBondedTokens().Return(math.NewInt(1)) + validatorC.EXPECT().GetBondedTokens().Return(math.NewInt(1)) + validatorC.EXPECT().GetBondedTokens().Return(math.NewInt(1)) + + validatorC.EXPECT().GetConsensusPower(gomock.Any()).Return(int64(1)) + validatorC.EXPECT().GetConsensusPower(gomock.Any()).Return(int64(1)) + validatorC.EXPECT().GetConsensusPower(gomock.Any()).Return(int64(1)) + + privVal1 := mock.NewPV() + pubKey1, _ := privVal1.GetPubKey() + operator1 = sdk.ValAddress(pubKey1.Address()) + + privVal2 := mock.NewPV() + pubKey2, _ := privVal2.GetPubKey() + operator2 = sdk.ValAddress(pubKey2.Address()) + + privVal3 := mock.NewPV() + pubKey3, _ := privVal3.GetPubKey() + operator3 = sdk.ValAddress(pubKey3.Address()) + + validatorC.EXPECT().GetOperator().Return(operator1) + validatorC.EXPECT().GetOperator().Return(operator2) + validatorC.EXPECT().GetOperator().Return(operator3) + + //TODO: remove monkey patch for test + p = ApplyMethod(reflect.TypeOf(stakingKeeper.Keeper{}), "IterateBondedValidatorsByPower", func(k stakingKeeper.Keeper, ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) bool) { + f(0, validatorC) + f(0, validatorC) + f(0, validatorC) + }) + p.ApplyMethod(reflect.TypeOf(stakingKeeper.Keeper{}), "GetLastTotalPower", func(k stakingKeeper.Keeper, ctx sdk.Context) math.Int { return math.NewInt(3) }) + + Expect(ks.ctx.BlockHeight()).To(Equal(int64(2))) + }) + + AfterEach(func() { + ks.ctrl.Finish() + if p != nil { + p.Reset() + } + }) + + Context("3 validators with 1 voting power each", func() { + BeforeEach(func() { + ks.ms.CreatePrice(ks.ctx, &types.MsgCreatePrice{ + Creator: operator1.String(), + FeederID: 1, + Prices: testdata.PS1, + BasedBlock: 1, + Nonce: 1, + }) + + c = keeper.GetCaches() + pRes := &common.Params{} + c.GetCache(cache.ItemP(pRes)) + p4Test := types.DefaultParams() + p4Test.TokenFeeders[1].StartBaseBlock = 1 + Expect(*pRes).Should(BeEquivalentTo(p4Test)) + }) + + It("success on 3rd message", func() { + iRes := make([]*cache.ItemM, 0) + c.GetCache(&iRes) + Expect(iRes[0].Validator).Should(Equal(operator1.String())) + + ks.ms.CreatePrice(ks.ctx, &types.MsgCreatePrice{ + Creator: operator2.String(), + FeederID: 1, + Prices: testdata.PS2, + BasedBlock: 1, + Nonce: 1, + }, + ) + ks.ms.CreatePrice(ks.ctx, &types.MsgCreatePrice{}) + c.GetCache(&iRes) + Expect(len(iRes)).Should(Equal(2)) + + ks.ms.CreatePrice(ks.ctx, &types.MsgCreatePrice{ + Creator: operator3.String(), + FeederID: 1, + Prices: testdata.PS4, + BasedBlock: 1, + Nonce: 1, + }, + ) + c.GetCache(&iRes) + Expect(len(iRes)).Should(Equal(0)) + prices := ks.k.GetAllPrices(sdk.UnwrapSDKContext(ks.ctx)) + Expect(prices[0]).Should(BeEquivalentTo(types.Prices{ + TokenID: 1, + NextRoundID: 2, + PriceList: []*types.PriceTimeRound{ + { + Price: testdata.PTD2.Price, + Decimal: testdata.PTD2.Decimal, + Timestamp: prices[0].PriceList[0].Timestamp, + RoundID: 1, + }, + }, + })) + }) + }) +}) diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go new file mode 100644 index 000000000..a3ff1ca70 --- /dev/null +++ b/x/oracle/keeper/msg_server_test.go @@ -0,0 +1,127 @@ +package keeper_test + +import ( + "context" + "testing" + + sdkerrors "cosmossdk.io/errors" + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/testdata" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context, keeper.Keeper) { + k, ctx := keepertest.OracleKeeper(t) + ctx = ctx.WithBlockHeight(2) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx), *k +} + +func TestMsgServer(t *testing.T) { + ms, ctx, _ := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} + +func (suite *KeeperSuite) TestCreatePriceSingleBlock() { + router := suite.App.MsgServiceRouter() + oServer := router.Handler(&types.MsgCreatePrice{}) + require.EqualValues(suite.T(), 2, suite.Ctx.BlockHeight()) + oServer(suite.Ctx, &types.MsgCreatePrice{ + Creator: suite.valAddr1.String(), + Nonce: 1, + FeederID: 1, + Prices: testdata.PS1, + BasedBlock: 1, + }) + oServer(suite.Ctx, &types.MsgCreatePrice{ + Creator: suite.valAddr2.String(), + Nonce: 1, + FeederID: 1, + Prices: testdata.PS2, + BasedBlock: 1, + }) + prices, found := suite.App.OracleKeeper.GetPrices(suite.Ctx, 1) + if suite.Equal(true, found, "final price should be returned") { + suite.EqualValues(prices.TokenID, 1, "final price has tokenID equals to 1") + suite.Equal(2, len(prices.PriceList), "length of price list should be 2 including the 0 index with an empty element as placeholder") + suite.Exactly(types.Prices{ + TokenID: 1, + NextRoundID: 2, + PriceList: []*types.PriceTimeRound{ + {}, + { + Price: testdata.PTD2.Price, + Decimal: 18, + // since timestamp is filled with realtime, so we use the value from result to fill the expected value here + Timestamp: prices.PriceList[1].Timestamp, + RoundID: 1, + }, + }, + }, prices) + } + + // run the endblock to seal and prepare for next block + suite.NextBlock() + require.EqualValues(suite.T(), 3, suite.Ctx.BlockHeight()) + _, err := oServer(suite.Ctx, &types.MsgCreatePrice{ + Creator: suite.valAddr1.String(), + Nonce: 1, + FeederID: 1, + Prices: testdata.PS1, + BasedBlock: 1, + }) + codespace, code, log := sdkerrors.ABCIInfo(err, false) + suite.Equal(codespace, types.ModuleName) + suite.EqualValues(code, 1) + suite.Equal(log, err.Error()) +} + +func (suite *KeeperSuite) TestCreatePriceTwoBlock() { + router := suite.App.MsgServiceRouter() + oServer := router.Handler(&types.MsgCreatePrice{}) + res, _ := oServer(suite.Ctx, &types.MsgCreatePrice{ + Creator: suite.valAddr1.String(), + Nonce: 1, + FeederID: 1, + Prices: testdata.PS1, + BasedBlock: 1, + }) + proposerAttribute, _ := res.GetEvents().GetAttributes(types.AttributeKeyProposer) + proposer := proposerAttribute[0].Value + suite.Equal(suite.valAddr1.String(), proposer) + _, found := suite.App.OracleKeeper.GetPrices(suite.Ctx, 1) + require.Equal(suite.T(), false, found) + if suite.Equal(false, found) { + // run the endblock to seal and prepare for next block + suite.NextBlock() + oServer(suite.Ctx, &types.MsgCreatePrice{ + Creator: suite.valAddr2.String(), + Nonce: 1, + FeederID: 1, + Prices: testdata.PS3, + BasedBlock: 1, + }) + prices, found := suite.App.OracleKeeper.GetPrices(suite.Ctx, 1) + if suite.Equal(true, found) { + suite.Exactly(types.Prices{ + TokenID: 1, + NextRoundID: 2, + PriceList: []*types.PriceTimeRound{ + {}, + { + Price: testdata.PTD1.Price, + Decimal: 18, + // since timestamp is filled with realtime, so we use the value from result to fill the expected value here + Timestamp: prices.PriceList[1].Timestamp, + RoundID: 1, + }, + }, + }, prices) + } + } +} diff --git a/x/oracle/keeper/msg_server_update_params.go b/x/oracle/keeper/msg_server_update_params.go new file mode 100644 index 000000000..3729e996d --- /dev/null +++ b/x/oracle/keeper/msg_server_update_params.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if ms.authority != msg.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", ms.authority, msg.Authority) + } + + // store params + ms.SetParams(ctx, msg.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go new file mode 100644 index 000000000..5dcd5402f --- /dev/null +++ b/x/oracle/keeper/params.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) // return types.NewParams() + if bz != nil { + k.cdc.MustUnmarshal(bz, ¶ms) + } + return +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + // TODO: validation check + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) +} diff --git a/x/oracle/keeper/params_test.go b/x/oracle/keeper/params_test.go new file mode 100644 index 000000000..3fb9269b8 --- /dev/null +++ b/x/oracle/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.OracleKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/oracle/keeper/prices.go b/x/oracle/keeper/prices.go new file mode 100644 index 000000000..804357d8e --- /dev/null +++ b/x/oracle/keeper/prices.go @@ -0,0 +1,170 @@ +package keeper + +import ( + "encoding/binary" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetPrices set a specific prices in the store from its index +func (k Keeper) SetPrices(ctx sdk.Context, prices types.Prices) { + store := k.getPriceTRStore(ctx, prices.TokenID) + for _, v := range prices.PriceList { + b := k.cdc.MustMarshal(v) + store.Set(types.PricesRoundKey(v.RoundID), b) + } + store.Set(types.PricesNextRoundIDKey, types.Uint64Bytes(prices.NextRoundID)) +} + +// GetPrices returns a prices from its index +func (k Keeper) GetPrices( + ctx sdk.Context, + tokenID uint64, +) (val types.Prices, found bool) { + store := k.getPriceTRStore(ctx, tokenID) + nextRoundID := k.GetNextRoundID(ctx, tokenID) + + val.TokenID = tokenID + val.NextRoundID = nextRoundID + val.PriceList = make([]*types.PriceTimeRound, nextRoundID) + // 0 roundId is reserved, expect the roundid corresponds to the slice index + val.PriceList[0] = &types.PriceTimeRound{} + for i := uint64(1); i < nextRoundID; i++ { + b := store.Get(types.PricesRoundKey(i)) + val.PriceList[i] = &types.PriceTimeRound{} + if b != nil { + // should always be true since we don't delete prices from history round + k.cdc.MustUnmarshal(b, val.PriceList[i]) + found = true + } + } + + return +} + +// RemovePrices removes a prices from the store +func (k Keeper) RemovePrices( + ctx sdk.Context, + tokenID uint64, +) { + store := k.getPriceTRStore(ctx, tokenID) + // iterator := sdk.KVStorePrefixIterator(store, []byte{}) + iterator := store.Iterator(nil, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } +} + +// GetAllPrices returns all prices +func (k Keeper) GetAllPrices(ctx sdk.Context) (list []types.Prices) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PricesKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + var price types.Prices + prevTokenID := uint64(0) + for ; iterator.Valid(); iterator.Next() { + tokenID, _, nextRoundID := parseKey(iterator.Key()) + if prevTokenID == 0 { + prevTokenID = tokenID + price.TokenID = tokenID + } else if prevTokenID != tokenID && price.TokenID > 0 { + list = append(list, price) + prevTokenID = tokenID + price = types.Prices{TokenID: tokenID} + } + if nextRoundID { + price.NextRoundID = binary.BigEndian.Uint64(iterator.Value()) + } else { + var val types.PriceTimeRound + k.cdc.MustUnmarshal(iterator.Value(), &val) + price.PriceList = append(price.PriceList, &val) + } + } + if price.TokenID > 0 { + list = append(list, price) + } + return list +} + +func (k Keeper) AppendPriceTR(ctx sdk.Context, tokenID uint64, priceTR types.PriceTimeRound) { + nextRoundID := k.GetNextRoundID(ctx, tokenID) + if nextRoundID != priceTR.RoundID { + return + } + store := k.getPriceTRStore(ctx, tokenID) + b := k.cdc.MustMarshal(&priceTR) + store.Set(types.PricesRoundKey(nextRoundID), b) + k.IncreaseNextRoundID(ctx, tokenID) +} + +// func(k Keeper) SetPriceTR(ctx sdk.Context, tokenID int32, priceTR){} +func (k Keeper) GetPriceTRRoundID(ctx sdk.Context, tokenID uint64, roundID uint64) (price types.PriceTimeRound, found bool) { + store := k.getPriceTRStore(ctx, tokenID) + + b := store.Get(types.PricesRoundKey(roundID)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, &price) + found = true + return +} + +func (k Keeper) GetPriceTRLatest(ctx sdk.Context, tokenID uint64) (price types.PriceTimeRound, found bool) { + // store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PricesKeyPrefix)) + // store = prefix.NewStore(store, types.PricesKey(tokenID)) + store := k.getPriceTRStore(ctx, tokenID) + nextRoundIDB := store.Get(types.PricesNextRoundIDKey) + if nextRoundIDB == nil { + return + } + nextRoundID := binary.BigEndian.Uint64(nextRoundIDB) + b := store.Get(types.PricesRoundKey(nextRoundID - 1)) + if b != nil { + // should always be true + k.cdc.MustUnmarshal(b, &price) + found = true + } + return +} + +func (k Keeper) GetNextRoundID(ctx sdk.Context, tokenID uint64) (nextRoundID uint64) { + nextRoundID = 1 + store := k.getPriceTRStore(ctx, tokenID) + nextRoundIDB := store.Get(types.PricesNextRoundIDKey) + if nextRoundIDB != nil { + if nextRoundID = binary.BigEndian.Uint64(nextRoundIDB); nextRoundID == 0 { + nextRoundID = 1 + } + } + return +} + +func (k Keeper) IncreaseNextRoundID(ctx sdk.Context, tokenID uint64) { + store := k.getPriceTRStore(ctx, tokenID) + nextRoundID := k.GetNextRoundID(ctx, tokenID) + b := make([]byte, 8) + binary.BigEndian.PutUint64(b, nextRoundID+1) + store.Set(types.PricesNextRoundIDKey, b) +} + +func (k Keeper) getPriceTRStore(ctx sdk.Context, tokenID uint64) prefix.Store { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PricesKeyPrefix)) + return prefix.NewStore(store, types.PricesKey(tokenID)) +} + +func parseKey(key []byte) (tokenID uint64, roundID uint64, nextRoundID bool) { + tokenID = binary.BigEndian.Uint64(key[:8]) + if len(key) == 21 { + nextRoundID = true + return + } + roundID = binary.BigEndian.Uint64(key[9:17]) + return +} diff --git a/x/oracle/keeper/prices_test.go b/x/oracle/keeper/prices_test.go new file mode 100644 index 000000000..099dd38ce --- /dev/null +++ b/x/oracle/keeper/prices_test.go @@ -0,0 +1,82 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/testdata" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNPrices(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Prices { + items := make([]types.Prices, n) + for i := range items { + items[i].TokenID = uint64(i + 1) + items[i] = types.Prices{ + TokenID: uint64(i + 1), + NextRoundID: 2, + PriceList: []*types.PriceTimeRound{ + testdata.PTR1, + testdata.PTR2, + testdata.PTR3, + testdata.PTR4, + testdata.PTR5, + }, + } + keeper.SetPrices(ctx, items[i]) + } + return items +} + +func TestPricesGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + keeper.SetPrices(ctx, testdata.P1) + rst, found := keeper.GetPrices(ctx, 1) + require.True(t, found) + pRes := testdata.P1 + pRes.PriceList = append([]*types.PriceTimeRound{{}}, testdata.P1.PriceList...) + require.Equal(t, pRes, rst) + // items := createNPrices(keeper, ctx, 10) + // + // for _, item := range items { + // rst, found := keeper.GetPrices(ctx, + // item.TokenId, + // ) + // require.True(t, found) + // require.Equal(t, + // nullify.Fill(&item), + // nullify.Fill(&rst), + // ) + // } +} + +func TestPricesRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNPrices(keeper, ctx, 10) + for _, item := range items { + keeper.RemovePrices(ctx, + item.TokenID, + ) + _, found := keeper.GetPrices(ctx, + item.TokenID, + ) + require.False(t, found) + } +} + +func TestPricesGetAll(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNPrices(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllPrices(ctx)), + ) +} diff --git a/x/oracle/keeper/query.go b/x/oracle/keeper/query.go new file mode 100644 index 000000000..f15058655 --- /dev/null +++ b/x/oracle/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/oracle/keeper/query_index_recent_msg.go b/x/oracle/keeper/query_index_recent_msg.go new file mode 100644 index 000000000..ab769f077 --- /dev/null +++ b/x/oracle/keeper/query_index_recent_msg.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) IndexRecentMsg(goCtx context.Context, req *types.QueryGetIndexRecentMsgRequest) (*types.QueryGetIndexRecentMsgResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetIndexRecentMsg(ctx) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetIndexRecentMsgResponse{IndexRecentMsg: val}, nil +} diff --git a/x/oracle/keeper/query_index_recent_msg_test.go b/x/oracle/keeper/query_index_recent_msg_test.go new file mode 100644 index 000000000..060c3ef07 --- /dev/null +++ b/x/oracle/keeper/query_index_recent_msg_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func TestIndexRecentMsgQuery(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + item := createTestIndexRecentMsg(keeper, ctx) + tests := []struct { + desc string + request *types.QueryGetIndexRecentMsgRequest + response *types.QueryGetIndexRecentMsgResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetIndexRecentMsgRequest{}, + response: &types.QueryGetIndexRecentMsgResponse{IndexRecentMsg: item}, + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.IndexRecentMsg(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/oracle/keeper/query_index_recent_params.go b/x/oracle/keeper/query_index_recent_params.go new file mode 100644 index 000000000..012e6f0fe --- /dev/null +++ b/x/oracle/keeper/query_index_recent_params.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) IndexRecentParams(goCtx context.Context, req *types.QueryGetIndexRecentParamsRequest) (*types.QueryGetIndexRecentParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetIndexRecentParams(ctx) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetIndexRecentParamsResponse{IndexRecentParams: val}, nil +} diff --git a/x/oracle/keeper/query_index_recent_params_test.go b/x/oracle/keeper/query_index_recent_params_test.go new file mode 100644 index 000000000..f934a4ba2 --- /dev/null +++ b/x/oracle/keeper/query_index_recent_params_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func TestIndexRecentParamsQuery(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + item := createTestIndexRecentParams(keeper, ctx) + tests := []struct { + desc string + request *types.QueryGetIndexRecentParamsRequest + response *types.QueryGetIndexRecentParamsResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetIndexRecentParamsRequest{}, + response: &types.QueryGetIndexRecentParamsResponse{IndexRecentParams: item}, + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.IndexRecentParams(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/oracle/keeper/query_params.go b/x/oracle/keeper/query_params.go new file mode 100644 index 000000000..9aa073c3c --- /dev/null +++ b/x/oracle/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/oracle/keeper/query_params_test.go b/x/oracle/keeper/query_params_test.go new file mode 100644 index 000000000..a587b37d5 --- /dev/null +++ b/x/oracle/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/oracle/keeper/query_prices.go b/x/oracle/keeper/query_prices.go new file mode 100644 index 000000000..504f4d9d5 --- /dev/null +++ b/x/oracle/keeper/query_prices.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// func (k Keeper) PricesAll(goCtx context.Context, req *types.QueryAllPricesRequest) (*types.QueryAllPricesResponse, error) { +// if req == nil { +// return nil, status.Error(codes.InvalidArgument, "invalid request") +// } +// +// var pricess []types.Prices +// ctx := sdk.UnwrapSDKContext(goCtx) +// +// store := ctx.KVStore(k.storeKey) +// pricesStore := prefix.NewStore(store, types.KeyPrefix(types.PricesKeyPrefix)) +// pricesTokenStore := prefix.NewStore(pricesStore, types.PricesKey(tokenID)) +// +// pageRes, err := query.Paginate(pricesTokenStore, req.Pagination, func(key []byte, value []byte) error { +// var prices types.Prices +// if err := k.cdc.Unmarshal(value, &prices); err != nil { +// return err +// } +// +// pricess = append(pricess, prices) +// return nil +// }) +// +// if err != nil { +// return nil, status.Error(codes.Internal, err.Error()) +// } +// +// return &types.QueryAllPricesResponse{Prices: pricess, Pagination: pageRes}, nil +//} + +func (k Keeper) Prices(goCtx context.Context, req *types.QueryGetPricesRequest) (*types.QueryGetPricesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetPrices( + ctx, + req.TokenId, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetPricesResponse{Prices: val}, nil +} diff --git a/x/oracle/keeper/query_prices_test.go b/x/oracle/keeper/query_prices_test.go new file mode 100644 index 000000000..f2fb478e3 --- /dev/null +++ b/x/oracle/keeper/query_prices_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestPricesQuerySingle(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPrices(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryGetPricesRequest + response *types.QueryGetPricesResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetPricesRequest{ + TokenId: msgs[0].TokenID, + }, + response: &types.QueryGetPricesResponse{Prices: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetPricesRequest{ + TokenId: msgs[1].TokenID, + }, + response: &types.QueryGetPricesResponse{Prices: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetPricesRequest{ + TokenId: 100000, + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.Prices(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +//func TestPricesQueryPaginated(t *testing.T) { +// keeper, ctx := keepertest.OracleKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// msgs := createNPrices(keeper, ctx, 5) +// +// request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPricesRequest { +// return &types.QueryAllPricesRequest{ +// Pagination: &query.PageRequest{ +// Key: next, +// Offset: offset, +// Limit: limit, +// CountTotal: total, +// }, +// } +// } +// t.Run("ByOffset", func(t *testing.T) { +// step := 2 +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.PricesAll(wctx, request(nil, uint64(i), uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.Prices), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.Prices), +// ) +// } +// }) +// t.Run("ByKey", func(t *testing.T) { +// step := 2 +// var next []byte +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.PricesAll(wctx, request(next, 0, uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.Prices), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.Prices), +// ) +// next = resp.Pagination.NextKey +// } +// }) +// t.Run("Total", func(t *testing.T) { +// resp, err := keeper.PricesAll(wctx, request(nil, 0, 0, true)) +// require.NoError(t, err) +// require.Equal(t, len(msgs), int(resp.Pagination.Total)) +// require.ElementsMatch(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.Prices), +// ) +// }) +// t.Run("InvalidRequest", func(t *testing.T) { +// _, err := keeper.PricesAll(wctx, nil) +// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) +// }) +//} diff --git a/x/oracle/keeper/query_recent_msg.go b/x/oracle/keeper/query_recent_msg.go new file mode 100644 index 000000000..fe47f4a2a --- /dev/null +++ b/x/oracle/keeper/query_recent_msg.go @@ -0,0 +1,57 @@ +//nolint:dupl +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) RecentMsgAll(goCtx context.Context, req *types.QueryAllRecentMsgRequest) (*types.QueryAllRecentMsgResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var recentMsgs []types.RecentMsg + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + recentMsgStore := prefix.NewStore(store, types.KeyPrefix(types.RecentMsgKeyPrefix)) + + pageRes, err := query.Paginate(recentMsgStore, req.Pagination, func(_ []byte, value []byte) error { + var recentMsg types.RecentMsg + if err := k.cdc.Unmarshal(value, &recentMsg); err != nil { + return err + } + + recentMsgs = append(recentMsgs, recentMsg) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllRecentMsgResponse{RecentMsg: recentMsgs, Pagination: pageRes}, nil +} + +func (k Keeper) RecentMsg(goCtx context.Context, req *types.QueryGetRecentMsgRequest) (*types.QueryGetRecentMsgResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetRecentMsg( + ctx, + req.Block, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetRecentMsgResponse{RecentMsg: val}, nil +} diff --git a/x/oracle/keeper/query_recent_msg_test.go b/x/oracle/keeper/query_recent_msg_test.go new file mode 100644 index 000000000..ba8538963 --- /dev/null +++ b/x/oracle/keeper/query_recent_msg_test.go @@ -0,0 +1,127 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestRecentMsgQuerySingle(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNRecentMsg(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryGetRecentMsgRequest + response *types.QueryGetRecentMsgResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetRecentMsgRequest{ + Block: msgs[0].Block, + }, + response: &types.QueryGetRecentMsgResponse{RecentMsg: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetRecentMsgRequest{ + Block: msgs[1].Block, + }, + response: &types.QueryGetRecentMsgResponse{RecentMsg: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetRecentMsgRequest{ + Block: 100000, + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.RecentMsg(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestRecentMsgQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNRecentMsg(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllRecentMsgRequest { + return &types.QueryAllRecentMsgRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RecentMsgAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RecentMsg), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentMsg), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RecentMsgAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RecentMsg), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentMsg), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.RecentMsgAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentMsg), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.RecentMsgAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/oracle/keeper/query_recent_params.go b/x/oracle/keeper/query_recent_params.go new file mode 100644 index 000000000..b4a89862c --- /dev/null +++ b/x/oracle/keeper/query_recent_params.go @@ -0,0 +1,57 @@ +//nolint:dupl +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) RecentParamsAll(goCtx context.Context, req *types.QueryAllRecentParamsRequest) (*types.QueryAllRecentParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var recentParamss []types.RecentParams + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + recentParamsStore := prefix.NewStore(store, types.KeyPrefix(types.RecentParamsKeyPrefix)) + + pageRes, err := query.Paginate(recentParamsStore, req.Pagination, func(_ []byte, value []byte) error { + var recentParams types.RecentParams + if err := k.cdc.Unmarshal(value, &recentParams); err != nil { + return err + } + + recentParamss = append(recentParamss, recentParams) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllRecentParamsResponse{RecentParams: recentParamss, Pagination: pageRes}, nil +} + +func (k Keeper) RecentParams(goCtx context.Context, req *types.QueryGetRecentParamsRequest) (*types.QueryGetRecentParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetRecentParams( + ctx, + req.Block, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetRecentParamsResponse{RecentParams: val}, nil +} diff --git a/x/oracle/keeper/query_recent_params_test.go b/x/oracle/keeper/query_recent_params_test.go new file mode 100644 index 000000000..f7969f3e5 --- /dev/null +++ b/x/oracle/keeper/query_recent_params_test.go @@ -0,0 +1,127 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestRecentParamsQuerySingle(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNRecentParams(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryGetRecentParamsRequest + response *types.QueryGetRecentParamsResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetRecentParamsRequest{ + Block: msgs[0].Block, + }, + response: &types.QueryGetRecentParamsResponse{RecentParams: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetRecentParamsRequest{ + Block: msgs[1].Block, + }, + response: &types.QueryGetRecentParamsResponse{RecentParams: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetRecentParamsRequest{ + Block: 100000, + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.RecentParams(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestRecentParamsQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNRecentParams(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllRecentParamsRequest { + return &types.QueryAllRecentParamsRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RecentParamsAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RecentParams), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentParams), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RecentParamsAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RecentParams), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentParams), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.RecentParamsAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.RecentParams), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.RecentParamsAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/oracle/keeper/query_validator_update_block.go b/x/oracle/keeper/query_validator_update_block.go new file mode 100644 index 000000000..241b409dc --- /dev/null +++ b/x/oracle/keeper/query_validator_update_block.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) ValidatorUpdateBlock(goCtx context.Context, req *types.QueryGetValidatorUpdateBlockRequest) (*types.QueryGetValidatorUpdateBlockResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetValidatorUpdateBlock(ctx) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetValidatorUpdateBlockResponse{ValidatorUpdateBlock: val}, nil +} diff --git a/x/oracle/keeper/query_validator_update_block_test.go b/x/oracle/keeper/query_validator_update_block_test.go new file mode 100644 index 000000000..27cc458e0 --- /dev/null +++ b/x/oracle/keeper/query_validator_update_block_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func TestValidatorUpdateBlockQuery(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + item := createTestValidatorUpdateBlock(keeper, ctx) + tests := []struct { + desc string + request *types.QueryGetValidatorUpdateBlockRequest + response *types.QueryGetValidatorUpdateBlockResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetValidatorUpdateBlockRequest{}, + response: &types.QueryGetValidatorUpdateBlockResponse{ValidatorUpdateBlock: item}, + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.ValidatorUpdateBlock(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/oracle/keeper/recent_msg.go b/x/oracle/keeper/recent_msg.go new file mode 100644 index 000000000..e559b1457 --- /dev/null +++ b/x/oracle/keeper/recent_msg.go @@ -0,0 +1,77 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetRecentMsg set a specific recentMsg in the store from its index +func (k Keeper) SetRecentMsg(ctx sdk.Context, recentMsg types.RecentMsg) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentMsgKeyPrefix)) + b := k.cdc.MustMarshal(&recentMsg) + store.Set(types.RecentMsgKey( + recentMsg.Block, + ), b) +} + +// GetRecentMsg returns a recentMsg from its index +func (k Keeper) GetRecentMsg( + ctx sdk.Context, + block uint64, +) (val types.RecentMsg, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentMsgKeyPrefix)) + + b := store.Get(types.RecentMsgKey( + block, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveRecentMsg removes a recentMsg from the store +func (k Keeper) RemoveRecentMsg( + ctx sdk.Context, + block uint64, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentMsgKeyPrefix)) + store.Delete(types.RecentMsgKey( + block, + )) +} + +// GetAllRecentMsg returns all recentMsg +func (k Keeper) GetAllRecentMsg(ctx sdk.Context) (list []types.RecentMsg) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentMsgKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RecentMsg + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) GetAllRecentMsgAsMap(ctx sdk.Context) (result map[int64][]*types.MsgItem) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentMsgKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RecentMsg + k.cdc.MustUnmarshal(iterator.Value(), &val) + // list = append(list, val) + result[int64(val.Block)] = val.Msgs + } + + return +} diff --git a/x/oracle/keeper/recent_msg_test.go b/x/oracle/keeper/recent_msg_test.go new file mode 100644 index 000000000..cca76609a --- /dev/null +++ b/x/oracle/keeper/recent_msg_test.go @@ -0,0 +1,64 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNRecentMsg(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.RecentMsg { + items := make([]types.RecentMsg, n) + for i := range items { + items[i].Block = uint64(i) + + keeper.SetRecentMsg(ctx, items[i]) + } + return items +} + +func TestRecentMsgGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentMsg(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetRecentMsg(ctx, + item.Block, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestRecentMsgRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentMsg(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveRecentMsg(ctx, + item.Block, + ) + _, found := keeper.GetRecentMsg(ctx, + item.Block, + ) + require.False(t, found) + } +} + +func TestRecentMsgGetAll(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentMsg(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllRecentMsg(ctx)), + ) +} diff --git a/x/oracle/keeper/recent_params.go b/x/oracle/keeper/recent_params.go new file mode 100644 index 000000000..e2e1a36c9 --- /dev/null +++ b/x/oracle/keeper/recent_params.go @@ -0,0 +1,76 @@ +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetRecentParams set a specific recentParams in the store from its index +func (k Keeper) SetRecentParams(ctx sdk.Context, recentParams types.RecentParams) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentParamsKeyPrefix)) + b := k.cdc.MustMarshal(&recentParams) + store.Set(types.RecentParamsKey( + recentParams.Block, + ), b) +} + +// GetRecentParams returns a recentParams from its index +func (k Keeper) GetRecentParams( + ctx sdk.Context, + block uint64, +) (val types.RecentParams, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentParamsKeyPrefix)) + + b := store.Get(types.RecentParamsKey( + block, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveRecentParams removes a recentParams from the store +func (k Keeper) RemoveRecentParams( + ctx sdk.Context, + block uint64, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentParamsKeyPrefix)) + store.Delete(types.RecentParamsKey( + block, + )) +} + +// GetAllRecentParams returns all recentParams +func (k Keeper) GetAllRecentParams(ctx sdk.Context) (list []types.RecentParams) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentParamsKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RecentParams + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) GetAllRecentParamsAsMap(ctx sdk.Context) (result map[int64]*types.Params) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RecentParamsKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RecentParams + k.cdc.MustUnmarshal(iterator.Value(), &val) + result[int64(val.Block)] = val.Params + } + + return +} diff --git a/x/oracle/keeper/recent_params_test.go b/x/oracle/keeper/recent_params_test.go new file mode 100644 index 000000000..f798a8c92 --- /dev/null +++ b/x/oracle/keeper/recent_params_test.go @@ -0,0 +1,64 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNRecentParams(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.RecentParams { + items := make([]types.RecentParams, n) + for i := range items { + items[i].Block = uint64(i) + + keeper.SetRecentParams(ctx, items[i]) + } + return items +} + +func TestRecentParamsGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentParams(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetRecentParams(ctx, + item.Block, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestRecentParamsRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentParams(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveRecentParams(ctx, + item.Block, + ) + _, found := keeper.GetRecentParams(ctx, + item.Block, + ) + require.False(t, found) + } +} + +func TestRecentParamsGetAll(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + items := createNRecentParams(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllRecentParams(ctx)), + ) +} diff --git a/x/oracle/keeper/single.go b/x/oracle/keeper/single.go new file mode 100644 index 000000000..1019c50c1 --- /dev/null +++ b/x/oracle/keeper/single.go @@ -0,0 +1,143 @@ +package keeper + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/aggregator" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/cache" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/common" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +var cs *cache.Cache + +var agc *aggregator.AggregatorContext + +func GetCaches() *cache.Cache { + if cs != nil { + return cs + } + cs = cache.NewCache() + return cs +} + +// GetAggregatorContext returns singleton aggregatorContext used to calculate final price for each round of each tokenFeeder +func GetAggregatorContext(ctx sdk.Context, k Keeper) *aggregator.AggregatorContext { + if agc != nil { + return agc + } + + c := GetCaches() + c.ResetCaches() + agc = aggregator.NewAggregatorContext() + if ok := recacheAggregatorContext(ctx, agc, k, c); !ok { + // this is the very first time oracle has been started, fill relalted info as initialization + initAggregatorContext(ctx, agc, k, c) + } + return agc +} + +func recacheAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext, k Keeper, c *cache.Cache) bool { + from := ctx.BlockHeight() - common.MaxNonce + to := ctx.BlockHeight() - 1 + + h, ok := k.GetValidatorUpdateBlock(ctx) + recentParamsMap := k.GetAllRecentParamsAsMap(ctx) + if !ok || recentParamsMap == nil { + // no cache, this is the very first running, so go to initial process instead + return false + } + + if int64(h.Block) > from { + from = int64(h.Block) + } + + totalPower := big.NewInt(0) + validatorPowers := make(map[string]*big.Int) + k.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool { + power := big.NewInt(validator.GetConsensusPower(validator.GetBondedTokens())) + addr := string(validator.GetOperator()) + validatorPowers[addr] = power + totalPower = new(big.Int).Add(totalPower, power) + return false + }) + agc.SetValidatorPowers(validatorPowers) + // TODO: test only + if k.GetLastTotalPower(ctx).BigInt().Cmp(totalPower) != 0 { + panic("something wrong when get validatorsPower from staking module") + } + + // reset validators + c.AddCache(cache.ItemV(validatorPowers)) + + recentMsgs := k.GetAllRecentMsgAsMap(ctx) + var pTmp common.Params + for ; from < to; from++ { + // fill params + prev := int64(0) + for b, recentParams := range recentParamsMap { + if b <= from && b > prev { + pTmp = common.Params(*recentParams) + agc.SetParams(&pTmp) + prev = b + } + } + + agc.PrepareRound(ctx, uint64(from)) + + if msgs := recentMsgs[from+1]; msgs != nil { + for _, msg := range msgs { + // these messages are retreived for recache, just skip the validation check and fill the memory cache + //nolint + agc.FillPrice(&types.MsgCreatePrice{ + Creator: msg.Validator, + FeederID: msg.FeederID, + Prices: msg.PSources, + }) + } + } + agc.SealRound(ctx, false) + } + + // fill params cache + c.AddCache(cache.ItemP(&pTmp)) + + agc.PrepareRound(ctx, uint64(to)) + + return true +} + +func initAggregatorContext(ctx sdk.Context, agc *aggregator.AggregatorContext, k common.KeeperOracle, c *cache.Cache) { + // set params + p := k.GetParams(ctx) + pTmp := common.Params(p) + agc.SetParams(&pTmp) + // set params cache + c.AddCache(cache.ItemP(&pTmp)) + + totalPower := big.NewInt(0) + validatorPowers := make(map[string]*big.Int) + k.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool { + power := big.NewInt(validator.GetConsensusPower(validator.GetBondedTokens())) + addr := validator.GetOperator().String() + validatorPowers[addr] = power + totalPower = new(big.Int).Add(totalPower, power) + return false + }) + agc.SetValidatorPowers(validatorPowers) + + // set validatorPower cache + c.AddCache(cache.ItemV(validatorPowers)) + + agc.PrepareRound(ctx, uint64(ctx.BlockHeight()-1)) +} + +func ResetAggregatorContext() { + agc = nil +} + +func ResetCache() { + cs = nil +} diff --git a/x/oracle/keeper/testdata/helper.go b/x/oracle/keeper/testdata/helper.go new file mode 100644 index 000000000..b45ec4553 --- /dev/null +++ b/x/oracle/keeper/testdata/helper.go @@ -0,0 +1,36 @@ +package testdata + +import "github.com/ExocoreNetwork/exocore/x/oracle/types" + +func newPTD(detID, price string) *types.PriceTimeDetID { + return &types.PriceTimeDetID{ + Price: price, + Decimal: 18, + Timestamp: "-", + DetID: detID, + } +} + +func newPS(sourceID uint64, prices ...*types.PriceTimeDetID) *types.PriceSource { + return &types.PriceSource{ + SourceID: sourceID, + Prices: prices, + } +} + +func newPTR(price string, roundID uint64) *types.PriceTimeRound { + return &types.PriceTimeRound{ + Price: price, + Decimal: 18, + Timestamp: "", + RoundID: roundID, + } +} + +func newPrices(tokenID uint64, nextRoundID uint64, pList ...*types.PriceTimeRound) types.Prices { + return types.Prices{ + TokenID: tokenID, + NextRoundID: nextRoundID, + PriceList: pList, + } +} diff --git a/x/oracle/keeper/testdata/info.go b/x/oracle/keeper/testdata/info.go new file mode 100644 index 000000000..e4b72872e --- /dev/null +++ b/x/oracle/keeper/testdata/info.go @@ -0,0 +1,64 @@ +package testdata + +import ( + "math/big" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +var ( + One = big.NewInt(1) + Zero = big.NewInt(0) + Ten = big.NewInt(10) + Eleven = big.NewInt(11) + Fifteen = big.NewInt(15) + Twenty = big.NewInt(20) +) + +var ( + PTD1 = newPTD("1", "10") + PTD2 = newPTD("2", "12") + PTD3 = newPTD("3", "15") + PTD2M = newPTD("2", "11") + PTD3M = newPTD("3", "19") + // 1-10, 2-12 + PS1 = []*types.PriceSource{newPS(1, PTD1, PTD2)} + // 2-12, 3-1 + PS2 = []*types.PriceSource{newPS(1, PTD3, PTD2)} + // 1-10, 2-11(m) + PS3 = []*types.PriceSource{newPS(1, PTD1, PTD2M)} + // 2-12, 3-19(m) + PS4 = []*types.PriceSource{newPS(1, PTD2, PTD3M)} + // 1-10, 3-19(m) + PS5 = []*types.PriceSource{newPS(1, PTD1, PTD3M)} + + PS6 = []*types.PriceSource{newPS(2, PTD1)} + + // 1-10, 2-12 + PS21 = []*types.PriceSource{newPS(1, PTD1, PTD2), newPS(2, PTD1, PTD3)} + // 2-12, 3-15 + PS22 = []*types.PriceSource{newPS(1, PTD3, PTD2), newPS(2, PTD2, PTD3)} + // 1-10, 2-11(m) + PS23 = []*types.PriceSource{newPS(1, PTD1, PTD2M), newPS(2, PTD2M, PTD1)} + // 2-12, 3-19(m) + PS24 = []*types.PriceSource{newPS(1, PTD2, PTD3M), newPS(2, PTD3, PTD2M)} + // 1-10, 3-19(m) + PS25 = []*types.PriceSource{newPS(1, PTD1, PTD3M), newPS(2, PTD2M, PTD3M)} +) + +var ( + PTR1 = newPTR("100", 1) + PTR2 = newPTR("109", 2) + PTR3 = newPTR("117", 3) + PTR4 = newPTR("129", 4) + PTR5 = newPTR("121", 5) + P1 = newPrices(1, 6, PTR1, PTR2, PTR3, PTR4, PTR5) +) + +var DefaultParams = types.Params{ + Chains: []*types.Chain{{Name: "-", Desc: "-"}, {Name: "Ethereum", Desc: "-"}}, + Tokens: []*types.Token{{}, {Name: "eth", ChainID: 1, ContractAddress: "0xabc", Decimal: 18, Active: true}}, + Sources: []*types.Source{{}, {Name: "chainLink", Entry: &types.Endpoint{}, Valid: true, Deterministic: true}}, + Rules: []*types.RuleSource{{}, {SourceIDs: []uint64{1}}}, + TokenFeeders: []*types.TokenFeeder{{}, {TokenID: 1, RuleID: 1, StartRoundID: 1, StartBaseBlock: 0, Interval: 10, EndBlock: 0}}, +} diff --git a/x/oracle/keeper/validator_update_block.go b/x/oracle/keeper/validator_update_block.go new file mode 100644 index 000000000..b4c23e37b --- /dev/null +++ b/x/oracle/keeper/validator_update_block.go @@ -0,0 +1,34 @@ +//nolint:dupl +package keeper + +import ( + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetValidatorUpdateBlock set validatorUpdateBlock in the store +func (k Keeper) SetValidatorUpdateBlock(ctx sdk.Context, validatorUpdateBlock types.ValidatorUpdateBlock) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ValidatorUpdateBlockKey)) + b := k.cdc.MustMarshal(&validatorUpdateBlock) + store.Set([]byte{0}, b) +} + +// GetValidatorUpdateBlock returns validatorUpdateBlock +func (k Keeper) GetValidatorUpdateBlock(ctx sdk.Context) (val types.ValidatorUpdateBlock, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ValidatorUpdateBlockKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveValidatorUpdateBlock removes validatorUpdateBlock from the store +func (k Keeper) RemoveValidatorUpdateBlock(ctx sdk.Context) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ValidatorUpdateBlockKey)) + store.Delete([]byte{0}) +} diff --git a/x/oracle/keeper/validator_update_block_test.go b/x/oracle/keeper/validator_update_block_test.go new file mode 100644 index 000000000..56bd66356 --- /dev/null +++ b/x/oracle/keeper/validator_update_block_test.go @@ -0,0 +1,38 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + keepertest "github.com/ExocoreNetwork/exocore/testutil/keeper" + "github.com/ExocoreNetwork/exocore/testutil/nullify" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/types" +) + +func createTestValidatorUpdateBlock(keeper *keeper.Keeper, ctx sdk.Context) types.ValidatorUpdateBlock { + item := types.ValidatorUpdateBlock{} + keeper.SetValidatorUpdateBlock(ctx, item) + return item +} + +func TestValidatorUpdateBlockGet(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + item := createTestValidatorUpdateBlock(keeper, ctx) + rst, found := keeper.GetValidatorUpdateBlock(ctx) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) +} + +func TestValidatorUpdateBlockRemove(t *testing.T) { + keeper, ctx := keepertest.OracleKeeper(t) + createTestValidatorUpdateBlock(keeper, ctx) + keeper.RemoveValidatorUpdateBlock(ctx) + _, found := keeper.GetValidatorUpdateBlock(ctx) + require.False(t, found) +} diff --git a/x/oracle/module.go b/x/oracle/module.go new file mode 100644 index 000000000..ac5a376e3 --- /dev/null +++ b/x/oracle/module.go @@ -0,0 +1,219 @@ +package oracle + +import ( + "context" + "encoding/json" + "fmt" + "math/big" + "strconv" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/ExocoreNetwork/exocore/x/oracle/client/cli" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper" + "github.com/ExocoreNetwork/exocore/x/oracle/keeper/cache" + "github.com/ExocoreNetwork/exocore/x/oracle/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshaled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + + // used for simulation + accountKeeper types.AccountKeeper + + // used for simulation + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + cs := keeper.GetCaches() + validatorUpdates := am.keeper.GetValidatorUpdates(ctx) + forceSeal := false + agc := keeper.GetAggregatorContext(ctx, am.keeper) + + logger := am.keeper.Logger(ctx) + if len(validatorUpdates) > 0 { + validatorList := make(map[string]*big.Int) + for _, vu := range validatorUpdates { + pubKey, _ := cryptocodec.FromTmProtoPublicKey(vu.PubKey) + validator, _ := am.keeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pubKey)) + validatorList[validator.OperatorAddress] = big.NewInt(vu.Power) + } + validatorPowers := make(map[string]*big.Int) + cs.GetCache(cache.ItemV(validatorPowers)) + // update validatorPowerList in aggregatorContext + agc.SetValidatorPowers(validatorPowers) + // TODO: seal all alive round since validatorSet changed here + forceSeal = true + logger.Info("validator set changed, force seal all active rounds") + } + + // TODO: for v1 use mode==1, just check the failed feeders + _, failed := agc.SealRound(ctx, forceSeal) + // append new round with previous price for fail-seal token + for _, tokenID := range failed { + event := sdk.NewEvent( + types.EventTypeCreatePrice, + sdk.NewAttribute(types.AttributeKeyTokenID, strconv.FormatUint(tokenID, 10)), + sdk.NewAttribute(types.AttributeKeyPriceUpdated, types.AttributeValuePriceUpdatedFail), + ) + logInfo := fmt.Sprintf("add new round with previous price under fail aggregation, tokenID:%d", tokenID) + if pTR, ok := am.keeper.GetPriceTRLatest(ctx, tokenID); ok { + pTR.RoundID++ + am.keeper.AppendPriceTR(ctx, tokenID, pTR) + logger.Info("add new round with previous price under fail aggregation", "tokenID", tokenID, "roundID", pTR.RoundID) + logInfo += fmt.Sprintf(", roundID:%d, price:%s", pTR.RoundID, pTR.Price) + event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeyRoundID, strconv.FormatUint(pTR.RoundID, 10)), + sdk.NewAttribute(types.AttributeKeyFinalPrice, pTR.Price), + ) + } else { + nextRoundID := am.keeper.GetNextRoundID(ctx, tokenID) + am.keeper.AppendPriceTR(ctx, tokenID, types.PriceTimeRound{ + RoundID: nextRoundID, + }) + logInfo += fmt.Sprintf(", roundID:%d, price:-", nextRoundID) + event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeyRoundID, strconv.FormatUint(nextRoundID, 10)), + sdk.NewAttribute(types.AttributeKeyFinalPrice, "-"), + ) + } + logger.Info(logInfo) + ctx.EventManager().EmitEvent(event) + } + // TODO: emit events for success sealed rounds(could ignore for v1) + + logger.Info("prepare for next oracle round of each tokenFeeder") + agc.PrepareRound(ctx, 0) + + cs.CommitCache(ctx, true, am.keeper) + return []abci.ValidatorUpdate{} +} diff --git a/x/oracle/types/codec.go b/x/oracle/types/codec.go new file mode 100644 index 000000000..d8e9b828d --- /dev/null +++ b/x/oracle/types/codec.go @@ -0,0 +1,28 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreatePrice{}, "oracle/CreatePrice", nil) + cdc.RegisterConcrete(Params{}, "exocore/x/oracle/Params", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreatePrice{}, + ) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go new file mode 100644 index 000000000..2183923eb --- /dev/null +++ b/x/oracle/types/errors.go @@ -0,0 +1,14 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/oracle module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrInvalidMsg = sdkerrors.Register(ModuleName, 1, "invalid input create price") + ErrPriceProposalIgnored = sdkerrors.Register(ModuleName, 2, "price proposal ignored") +) diff --git a/x/oracle/types/events.go b/x/oracle/types/events.go new file mode 100644 index 000000000..4a7ae578e --- /dev/null +++ b/x/oracle/types/events.go @@ -0,0 +1,16 @@ +package types + +const ( + EventTypeCreatePrice = "create_price" + + AttributeKeyFeederID = "feeder_id" + AttributeKeyTokenID = "token_id" + AttributeKeyBasedBlock = "based_block" + AttributeKeyRoundID = "round_id" + AttributeKeyProposer = "proposer" + AttributeKeyFinalPrice = "final_price" + AttributeKeyPriceUpdated = "price_update" + + AttributeValuePriceUpdatedSuccess = "success" + AttributeValuePriceUpdatedFail = "fail" +) diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go new file mode 100644 index 000000000..6aa6e9778 --- /dev/null +++ b/x/oracle/types/expected_keepers.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go new file mode 100644 index 000000000..2c301c9b8 --- /dev/null +++ b/x/oracle/types/genesis.go @@ -0,0 +1,72 @@ +package types + +import ( + "fmt" +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + PricesList: []Prices{}, + ValidatorUpdateBlock: nil, + IndexRecentParams: nil, + IndexRecentMsg: nil, + RecentMsgList: []RecentMsg{}, + RecentParamsList: []RecentParams{}, + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +func NewGenesisState(p Params) *GenesisState { + return &GenesisState{ + PricesList: []Prices{}, + ValidatorUpdateBlock: nil, + IndexRecentParams: nil, + IndexRecentMsg: nil, + RecentMsgList: []RecentMsg{}, + RecentParamsList: []RecentParams{}, + Params: p, + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // Check for duplicated index in prices + pricesIndexMap := make(map[string]struct{}) + + for _, elem := range gs.PricesList { + index := string(PricesKey(elem.TokenID)) + if _, ok := pricesIndexMap[index]; ok { + return fmt.Errorf("duplicated index for prices") + } + pricesIndexMap[index] = struct{}{} + } + // Check for duplicated index in recentMsg + recentMsgIndexMap := make(map[string]struct{}) + + for _, elem := range gs.RecentMsgList { + index := string(RecentMsgKey(elem.Block)) + if _, ok := recentMsgIndexMap[index]; ok { + return fmt.Errorf("duplicated index for recentMsg") + } + recentMsgIndexMap[index] = struct{}{} + } + // Check for duplicated index in recentParams + recentParamsIndexMap := make(map[string]struct{}) + + for _, elem := range gs.RecentParamsList { + index := string(RecentParamsKey(elem.Block)) + if _, ok := recentParamsIndexMap[index]; ok { + return fmt.Errorf("duplicated index for recentParams") + } + recentParamsIndexMap[index] = struct{}{} + } + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go new file mode 100644 index 000000000..246abc61f --- /dev/null +++ b/x/oracle/types/genesis.pb.go @@ -0,0 +1,708 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the oracle module's genesis state. +type GenesisState struct { + // module params + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // prices of all tokens + PricesList []Prices `protobuf:"bytes,2,rep,name=prices_list,json=pricesList,proto3" json:"prices_list"` + //TODO: userDefinedTokenFeeder + // latest block on which the validator set be updated + ValidatorUpdateBlock *ValidatorUpdateBlock `protobuf:"bytes,3,opt,name=validator_update_block,json=validatorUpdateBlock,proto3" json:"validator_update_block,omitempty"` + // index for the cached recent params + IndexRecentParams *IndexRecentParams `protobuf:"bytes,4,opt,name=index_recent_params,json=indexRecentParams,proto3" json:"index_recent_params,omitempty"` + // index for the cached recent messages + IndexRecentMsg *IndexRecentMsg `protobuf:"bytes,5,opt,name=index_recent_msg,json=indexRecentMsg,proto3" json:"index_recent_msg,omitempty"` + // cached recent messages + RecentMsgList []RecentMsg `protobuf:"bytes,6,rep,name=recent_msg_list,json=recentMsgList,proto3" json:"recent_msg_list"` + // cached recent params + RecentParamsList []RecentParams `protobuf:"bytes,7,rep,name=recent_params_list,json=recentParamsList,proto3" json:"recent_params_list"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_dbe067676c4dc0de, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetPricesList() []Prices { + if m != nil { + return m.PricesList + } + return nil +} + +func (m *GenesisState) GetValidatorUpdateBlock() *ValidatorUpdateBlock { + if m != nil { + return m.ValidatorUpdateBlock + } + return nil +} + +func (m *GenesisState) GetIndexRecentParams() *IndexRecentParams { + if m != nil { + return m.IndexRecentParams + } + return nil +} + +func (m *GenesisState) GetIndexRecentMsg() *IndexRecentMsg { + if m != nil { + return m.IndexRecentMsg + } + return nil +} + +func (m *GenesisState) GetRecentMsgList() []RecentMsg { + if m != nil { + return m.RecentMsgList + } + return nil +} + +func (m *GenesisState) GetRecentParamsList() []RecentParams { + if m != nil { + return m.RecentParamsList + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "exocore.oracle.GenesisState") +} + +func init() { proto.RegisterFile("exocore/oracle/genesis.proto", fileDescriptor_dbe067676c4dc0de) } + +var fileDescriptor_dbe067676c4dc0de = []byte{ + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x41, 0x4f, 0xe2, 0x40, + 0x14, 0x80, 0xdb, 0x85, 0x65, 0x93, 0x61, 0x97, 0x65, 0x67, 0x09, 0xe9, 0xb2, 0xa4, 0x20, 0xd1, + 0x84, 0xc4, 0xa4, 0x35, 0xea, 0xd5, 0x0b, 0x89, 0x41, 0x8d, 0x1a, 0xac, 0xd1, 0x03, 0x97, 0xa6, + 0x94, 0x49, 0x9d, 0x50, 0x98, 0x66, 0x3a, 0x20, 0xfe, 0x0b, 0x6f, 0xfe, 0x25, 0x8e, 0x1c, 0x3d, + 0x19, 0x03, 0x7f, 0xc4, 0x74, 0xa6, 0x55, 0x3b, 0x36, 0xdc, 0xda, 0xf7, 0xbe, 0xf7, 0xcd, 0xbc, + 0x37, 0x0f, 0xd4, 0xd1, 0x9c, 0xb8, 0x84, 0x22, 0x93, 0x50, 0xc7, 0xf5, 0x91, 0xe9, 0xa1, 0x09, + 0x0a, 0x71, 0x68, 0x04, 0x94, 0x30, 0x02, 0x4b, 0x71, 0xd6, 0x10, 0xd9, 0xda, 0x8e, 0x44, 0xe3, + 0xc9, 0x10, 0xcd, 0x6d, 0x8a, 0x5c, 0x34, 0x61, 0xf6, 0x38, 0xf4, 0x44, 0x59, 0xad, 0xbd, 0x09, + 0x0b, 0x1c, 0xea, 0x8c, 0xe3, 0x03, 0x6a, 0xff, 0x25, 0x72, 0x73, 0x92, 0x62, 0x17, 0x25, 0xc9, + 0x86, 0x94, 0xfc, 0x72, 0x89, 0x56, 0x36, 0x90, 0x3a, 0x61, 0x57, 0x62, 0x66, 0x8e, 0x8f, 0x87, + 0x0e, 0x23, 0xd4, 0x9e, 0x06, 0x43, 0x87, 0x21, 0x7b, 0xe0, 0x13, 0x77, 0x14, 0xc3, 0x15, 0x8f, + 0x78, 0x84, 0x7f, 0x9a, 0xd1, 0x97, 0x88, 0xb6, 0x9e, 0xf2, 0xe0, 0x67, 0x57, 0x0c, 0xed, 0x9a, + 0x39, 0x0c, 0xc1, 0x43, 0x50, 0x10, 0x67, 0x68, 0x6a, 0x53, 0x6d, 0x17, 0xf7, 0xab, 0x46, 0x7a, + 0x88, 0x46, 0x8f, 0x67, 0x3b, 0xf9, 0xc5, 0x4b, 0x43, 0xb1, 0x62, 0x16, 0x1e, 0x81, 0xa2, 0x68, + 0xcf, 0xf6, 0x71, 0xc8, 0xb4, 0x6f, 0xcd, 0x5c, 0x66, 0x29, 0x47, 0xe2, 0x52, 0x20, 0x0a, 0xce, + 0x71, 0xc8, 0x60, 0x1f, 0x54, 0xb3, 0xef, 0xae, 0xe5, 0xf8, 0x25, 0xb6, 0x65, 0xd3, 0x6d, 0x42, + 0xdf, 0x70, 0xb8, 0x13, 0xb1, 0x56, 0x65, 0x96, 0x11, 0x85, 0x57, 0xe0, 0x6f, 0xc6, 0x03, 0x6a, + 0x79, 0x2e, 0xde, 0x92, 0xc5, 0xa7, 0x11, 0x6a, 0x71, 0x52, 0x34, 0x6a, 0xfd, 0xc1, 0x72, 0x08, + 0x9e, 0x80, 0xb2, 0xbc, 0x3a, 0xda, 0x77, 0xee, 0xd3, 0x37, 0xf8, 0x2e, 0x42, 0xcf, 0x2a, 0xe1, + 0xd4, 0x3f, 0xec, 0x82, 0xdf, 0x1f, 0x0e, 0x31, 0xbb, 0x02, 0x9f, 0xdd, 0x3f, 0x59, 0xf4, 0x5e, + 0x13, 0x8f, 0xef, 0x17, 0x4d, 0x02, 0x7c, 0x82, 0x3d, 0x00, 0x53, 0xfd, 0x09, 0xd7, 0x0f, 0xee, + 0xaa, 0x67, 0xbb, 0x52, 0x0f, 0x59, 0xa6, 0x9f, 0x62, 0x91, 0xb1, 0x73, 0xb6, 0x58, 0xe9, 0xea, + 0x72, 0xa5, 0xab, 0xaf, 0x2b, 0x5d, 0x7d, 0x5c, 0xeb, 0xca, 0x72, 0xad, 0x2b, 0xcf, 0x6b, 0x5d, + 0xe9, 0xef, 0x79, 0x98, 0xdd, 0x4d, 0x07, 0x86, 0x4b, 0xc6, 0xe6, 0xb1, 0x30, 0x5f, 0x22, 0x76, + 0x4f, 0xe8, 0xc8, 0x4c, 0x16, 0x72, 0x9e, 0xac, 0x24, 0x7b, 0x08, 0x50, 0x38, 0x28, 0xf0, 0x65, + 0x3b, 0x78, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x81, 0x95, 0xa3, 0xac, 0xaf, 0x03, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecentParamsList) > 0 { + for iNdEx := len(m.RecentParamsList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecentParamsList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.RecentMsgList) > 0 { + for iNdEx := len(m.RecentMsgList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecentMsgList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.IndexRecentMsg != nil { + { + size, err := m.IndexRecentMsg.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.IndexRecentParams != nil { + { + size, err := m.IndexRecentParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.ValidatorUpdateBlock != nil { + { + size, err := m.ValidatorUpdateBlock.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.PricesList) > 0 { + for iNdEx := len(m.PricesList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PricesList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.PricesList) > 0 { + for _, e := range m.PricesList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.ValidatorUpdateBlock != nil { + l = m.ValidatorUpdateBlock.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.IndexRecentParams != nil { + l = m.IndexRecentParams.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.IndexRecentMsg != nil { + l = m.IndexRecentMsg.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.RecentMsgList) > 0 { + for _, e := range m.RecentMsgList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.RecentParamsList) > 0 { + for _, e := range m.RecentParamsList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PricesList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PricesList = append(m.PricesList, Prices{}) + if err := m.PricesList[len(m.PricesList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorUpdateBlock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ValidatorUpdateBlock == nil { + m.ValidatorUpdateBlock = &ValidatorUpdateBlock{} + } + if err := m.ValidatorUpdateBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexRecentParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IndexRecentParams == nil { + m.IndexRecentParams = &IndexRecentParams{} + } + if err := m.IndexRecentParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexRecentMsg", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IndexRecentMsg == nil { + m.IndexRecentMsg = &IndexRecentMsg{} + } + if err := m.IndexRecentMsg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentMsgList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecentMsgList = append(m.RecentMsgList, RecentMsg{}) + if err := m.RecentMsgList[len(m.RecentMsgList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentParamsList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecentParamsList = append(m.RecentParamsList, RecentParams{}) + if err := m.RecentParamsList[len(m.RecentParamsList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go new file mode 100644 index 000000000..5447a4fe6 --- /dev/null +++ b/x/oracle/types/genesis_test.go @@ -0,0 +1,109 @@ +package types_test + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/x/oracle/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + PricesList: []types.Prices{ + { + TokenID: 0, + }, + { + TokenID: 1, + }, + }, + ValidatorUpdateBlock: &types.ValidatorUpdateBlock{}, + IndexRecentParams: &types.IndexRecentParams{}, + IndexRecentMsg: &types.IndexRecentMsg{}, + RecentMsgList: []types.RecentMsg{ + { + Block: 0, + }, + { + Block: 1, + }, + }, + RecentParamsList: []types.RecentParams{ + { + Block: 0, + }, + { + Block: 1, + }, + }, + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + { + desc: "duplicated prices", + genState: &types.GenesisState{ + PricesList: []types.Prices{ + { + TokenID: 0, + }, + { + TokenID: 0, + }, + }, + }, + valid: false, + }, + { + desc: "duplicated recentMsg", + genState: &types.GenesisState{ + RecentMsgList: []types.RecentMsg{ + { + Block: 0, + }, + { + Block: 0, + }, + }, + }, + valid: false, + }, + { + desc: "duplicated recentParams", + genState: &types.GenesisState{ + RecentParamsList: []types.RecentParams{ + { + Block: 0, + }, + { + Block: 0, + }, + }, + }, + valid: false, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/oracle/types/index_recent_msg.pb.go b/x/oracle/types/index_recent_msg.pb.go new file mode 100644 index 000000000..80c0ec424 --- /dev/null +++ b/x/oracle/types/index_recent_msg.pb.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/index_recent_msg.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// index for the cached recent messages +type IndexRecentMsg struct { + // index list + Index []uint64 `protobuf:"varint,1,rep,packed,name=index,proto3" json:"index,omitempty"` +} + +func (m *IndexRecentMsg) Reset() { *m = IndexRecentMsg{} } +func (m *IndexRecentMsg) String() string { return proto.CompactTextString(m) } +func (*IndexRecentMsg) ProtoMessage() {} +func (*IndexRecentMsg) Descriptor() ([]byte, []int) { + return fileDescriptor_5de0367cab17dc5d, []int{0} +} +func (m *IndexRecentMsg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IndexRecentMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IndexRecentMsg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IndexRecentMsg) XXX_Merge(src proto.Message) { + xxx_messageInfo_IndexRecentMsg.Merge(m, src) +} +func (m *IndexRecentMsg) XXX_Size() int { + return m.Size() +} +func (m *IndexRecentMsg) XXX_DiscardUnknown() { + xxx_messageInfo_IndexRecentMsg.DiscardUnknown(m) +} + +var xxx_messageInfo_IndexRecentMsg proto.InternalMessageInfo + +func (m *IndexRecentMsg) GetIndex() []uint64 { + if m != nil { + return m.Index + } + return nil +} + +func init() { + proto.RegisterType((*IndexRecentMsg)(nil), "exocore.oracle.IndexRecentMsg") +} + +func init() { + proto.RegisterFile("exocore/oracle/index_recent_msg.proto", fileDescriptor_5de0367cab17dc5d) +} + +var fileDescriptor_5de0367cab17dc5d = []byte{ + // 165 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0xcf, 0xcc, 0x4b, 0x49, 0xad, + 0x88, 0x2f, 0x4a, 0x4d, 0x4e, 0xcd, 0x2b, 0x89, 0xcf, 0x2d, 0x4e, 0xd7, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0x83, 0x2a, 0xd3, 0x83, 0x28, 0x53, 0x52, 0xe3, 0xe2, 0xf3, 0x04, 0xa9, 0x0c, + 0x02, 0x2b, 0xf4, 0x2d, 0x4e, 0x17, 0x12, 0xe1, 0x62, 0x05, 0xeb, 0x95, 0x60, 0x54, 0x60, 0xd6, + 0x60, 0x09, 0x82, 0x70, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x15, 0x62, 0xb8, + 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xcc, 0x49, 0x15, 0x30, 0x47, 0x95, 0x54, 0x16, + 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xaf, 0xa3, 0x86, + 0x65, 0xb3, 0x00, 0x00, 0x00, +} + +func (m *IndexRecentMsg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IndexRecentMsg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IndexRecentMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Index) > 0 { + dAtA2 := make([]byte, len(m.Index)*10) + var j1 int + for _, num := range m.Index { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintIndexRecentMsg(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintIndexRecentMsg(dAtA []byte, offset int, v uint64) int { + offset -= sovIndexRecentMsg(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IndexRecentMsg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Index) > 0 { + l = 0 + for _, e := range m.Index { + l += sovIndexRecentMsg(uint64(e)) + } + n += 1 + sovIndexRecentMsg(uint64(l)) + l + } + return n +} + +func sovIndexRecentMsg(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIndexRecentMsg(x uint64) (n int) { + return sovIndexRecentMsg(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *IndexRecentMsg) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IndexRecentMsg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IndexRecentMsg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Index = append(m.Index, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthIndexRecentMsg + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthIndexRecentMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Index) == 0 { + m.Index = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Index = append(m.Index, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipIndexRecentMsg(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIndexRecentMsg + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIndexRecentMsg(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthIndexRecentMsg + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIndexRecentMsg + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIndexRecentMsg + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIndexRecentMsg = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIndexRecentMsg = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIndexRecentMsg = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/index_recent_params.pb.go b/x/oracle/types/index_recent_params.pb.go new file mode 100644 index 000000000..c33a996be --- /dev/null +++ b/x/oracle/types/index_recent_params.pb.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/index_recent_params.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// index for the cached recent params +type IndexRecentParams struct { + // index list + Index []uint64 `protobuf:"varint,1,rep,packed,name=index,proto3" json:"index,omitempty"` +} + +func (m *IndexRecentParams) Reset() { *m = IndexRecentParams{} } +func (m *IndexRecentParams) String() string { return proto.CompactTextString(m) } +func (*IndexRecentParams) ProtoMessage() {} +func (*IndexRecentParams) Descriptor() ([]byte, []int) { + return fileDescriptor_1e3da2c92dc64d5c, []int{0} +} +func (m *IndexRecentParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IndexRecentParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IndexRecentParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IndexRecentParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_IndexRecentParams.Merge(m, src) +} +func (m *IndexRecentParams) XXX_Size() int { + return m.Size() +} +func (m *IndexRecentParams) XXX_DiscardUnknown() { + xxx_messageInfo_IndexRecentParams.DiscardUnknown(m) +} + +var xxx_messageInfo_IndexRecentParams proto.InternalMessageInfo + +func (m *IndexRecentParams) GetIndex() []uint64 { + if m != nil { + return m.Index + } + return nil +} + +func init() { + proto.RegisterType((*IndexRecentParams)(nil), "exocore.oracle.IndexRecentParams") +} + +func init() { + proto.RegisterFile("exocore/oracle/index_recent_params.proto", fileDescriptor_1e3da2c92dc64d5c) +} + +var fileDescriptor_1e3da2c92dc64d5c = []byte{ + // 168 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x48, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0xcf, 0xcc, 0x4b, 0x49, 0xad, + 0x88, 0x2f, 0x4a, 0x4d, 0x4e, 0xcd, 0x2b, 0x89, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xaa, 0xd4, 0x83, 0xa8, 0x54, 0xd2, 0xe4, 0x12, 0xf4, + 0x04, 0x29, 0x0e, 0x02, 0xab, 0x0d, 0x00, 0x2b, 0x15, 0x12, 0xe1, 0x62, 0x05, 0x9b, 0x20, 0xc1, + 0xa8, 0xc0, 0xac, 0xc1, 0x12, 0x04, 0xe1, 0x38, 0x79, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, + 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, + 0xb1, 0x1c, 0x43, 0x94, 0x41, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0xbe, + 0x2b, 0xc4, 0x7c, 0xbf, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0x98, 0xc3, 0x2a, 0x60, 0x4e, + 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xbb, 0xc6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, + 0x47, 0xfe, 0xbc, 0x91, 0xb9, 0x00, 0x00, 0x00, +} + +func (m *IndexRecentParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IndexRecentParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IndexRecentParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Index) > 0 { + dAtA2 := make([]byte, len(m.Index)*10) + var j1 int + for _, num := range m.Index { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintIndexRecentParams(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintIndexRecentParams(dAtA []byte, offset int, v uint64) int { + offset -= sovIndexRecentParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IndexRecentParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Index) > 0 { + l = 0 + for _, e := range m.Index { + l += sovIndexRecentParams(uint64(e)) + } + n += 1 + sovIndexRecentParams(uint64(l)) + l + } + return n +} + +func sovIndexRecentParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIndexRecentParams(x uint64) (n int) { + return sovIndexRecentParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *IndexRecentParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IndexRecentParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IndexRecentParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Index = append(m.Index, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthIndexRecentParams + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthIndexRecentParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Index) == 0 { + m.Index = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Index = append(m.Index, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipIndexRecentParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIndexRecentParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIndexRecentParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIndexRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthIndexRecentParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIndexRecentParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIndexRecentParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIndexRecentParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIndexRecentParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIndexRecentParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/info.pb.go b/x/oracle/types/info.pb.go new file mode 100644 index 000000000..6fff3844c --- /dev/null +++ b/x/oracle/types/info.pb.go @@ -0,0 +1,1460 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/info.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Chain represents for the Chain on which token contracts deployed +type Chain struct { + // eg."bitcoin" + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // TODO: metadata + Desc string `protobuf:"bytes,2,opt,name=desc,proto3" json:"desc,omitempty"` +} + +func (m *Chain) Reset() { *m = Chain{} } +func (m *Chain) String() string { return proto.CompactTextString(m) } +func (*Chain) ProtoMessage() {} +func (*Chain) Descriptor() ([]byte, []int) { + return fileDescriptor_a9bbae837d8caf59, []int{0} +} +func (m *Chain) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Chain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Chain.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Chain) XXX_Merge(src proto.Message) { + xxx_messageInfo_Chain.Merge(m, src) +} +func (m *Chain) XXX_Size() int { + return m.Size() +} +func (m *Chain) XXX_DiscardUnknown() { + xxx_messageInfo_Chain.DiscardUnknown(m) +} + +var xxx_messageInfo_Chain proto.InternalMessageInfo + +func (m *Chain) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Chain) GetDesc() string { + if m != nil { + return m.Desc + } + return "" +} + +// Token represents the token info +type Token struct { + // token name + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // id refer to chainList's index + ChainID uint64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // if any, like erc20 tokens + ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + // decimal of token price + Decimal int32 `protobuf:"varint,4,opt,name=decimal,proto3" json:"decimal,omitempty"` + // set false when we stop official price oracle service for a specified token + Active bool `protobuf:"varint,5,opt,name=active,proto3" json:"active,omitempty"` +} + +func (m *Token) Reset() { *m = Token{} } +func (m *Token) String() string { return proto.CompactTextString(m) } +func (*Token) ProtoMessage() {} +func (*Token) Descriptor() ([]byte, []int) { + return fileDescriptor_a9bbae837d8caf59, []int{1} +} +func (m *Token) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Token.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Token) XXX_Merge(src proto.Message) { + xxx_messageInfo_Token.Merge(m, src) +} +func (m *Token) XXX_Size() int { + return m.Size() +} +func (m *Token) XXX_DiscardUnknown() { + xxx_messageInfo_Token.DiscardUnknown(m) +} + +var xxx_messageInfo_Token proto.InternalMessageInfo + +func (m *Token) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Token) GetChainID() uint64 { + if m != nil { + return m.ChainID + } + return 0 +} + +func (m *Token) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *Token) GetDecimal() int32 { + if m != nil { + return m.Decimal + } + return 0 +} + +func (m *Token) GetActive() bool { + if m != nil { + return m.Active + } + return false +} + +// Endpoint tells where to fetch the price info +type Endpoint struct { + // url int refer to TokenList.ID, 0 reprents default for all (as fall back) + // key refer to tokenID, 1->"https://chainlink.../eth" + Offchain map[uint64]string `protobuf:"bytes,1,rep,name=offchain,proto3" json:"offchain,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // url int refer to TokenList.ID, 0 reprents default for all (as fall back) + // key refer to tokenID, 1->"eth://0xabc...def" + Onchain map[uint64]string `protobuf:"bytes,2,rep,name=onchain,proto3" json:"onchain,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Endpoint) Reset() { *m = Endpoint{} } +func (m *Endpoint) String() string { return proto.CompactTextString(m) } +func (*Endpoint) ProtoMessage() {} +func (*Endpoint) Descriptor() ([]byte, []int) { + return fileDescriptor_a9bbae837d8caf59, []int{2} +} +func (m *Endpoint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Endpoint) XXX_Merge(src proto.Message) { + xxx_messageInfo_Endpoint.Merge(m, src) +} +func (m *Endpoint) XXX_Size() int { + return m.Size() +} +func (m *Endpoint) XXX_DiscardUnknown() { + xxx_messageInfo_Endpoint.DiscardUnknown(m) +} + +var xxx_messageInfo_Endpoint proto.InternalMessageInfo + +func (m *Endpoint) GetOffchain() map[uint64]string { + if m != nil { + return m.Offchain + } + return nil +} + +func (m *Endpoint) GetOnchain() map[uint64]string { + if m != nil { + return m.Onchain + } + return nil +} + +// Source represents price data source +type Source struct { + // name of price source, like 'chainlink' + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // endpoint of corresponding source to fetch price data from + Entry *Endpoint `protobuf:"bytes,2,opt,name=entry,proto3" json:"entry,omitempty"` + // set false when the source is out of service or reject to accept this source for official service + Valid bool `protobuf:"varint,3,opt,name=valid,proto3" json:"valid,omitempty"` + // if this source is deteministic or not + Deterministic bool `protobuf:"varint,4,opt,name=deterministic,proto3" json:"deterministic,omitempty"` +} + +func (m *Source) Reset() { *m = Source{} } +func (m *Source) String() string { return proto.CompactTextString(m) } +func (*Source) ProtoMessage() {} +func (*Source) Descriptor() ([]byte, []int) { + return fileDescriptor_a9bbae837d8caf59, []int{3} +} +func (m *Source) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Source) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Source.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Source) XXX_Merge(src proto.Message) { + xxx_messageInfo_Source.Merge(m, src) +} +func (m *Source) XXX_Size() int { + return m.Size() +} +func (m *Source) XXX_DiscardUnknown() { + xxx_messageInfo_Source.DiscardUnknown(m) +} + +var xxx_messageInfo_Source proto.InternalMessageInfo + +func (m *Source) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Source) GetEntry() *Endpoint { + if m != nil { + return m.Entry + } + return nil +} + +func (m *Source) GetValid() bool { + if m != nil { + return m.Valid + } + return false +} + +func (m *Source) GetDeterministic() bool { + if m != nil { + return m.Deterministic + } + return false +} + +func init() { + proto.RegisterType((*Chain)(nil), "exocore.oracle.Chain") + proto.RegisterType((*Token)(nil), "exocore.oracle.Token") + proto.RegisterType((*Endpoint)(nil), "exocore.oracle.Endpoint") + proto.RegisterMapType((map[uint64]string)(nil), "exocore.oracle.Endpoint.OffchainEntry") + proto.RegisterMapType((map[uint64]string)(nil), "exocore.oracle.Endpoint.OnchainEntry") + proto.RegisterType((*Source)(nil), "exocore.oracle.Source") +} + +func init() { proto.RegisterFile("exocore/oracle/info.proto", fileDescriptor_a9bbae837d8caf59) } + +var fileDescriptor_a9bbae837d8caf59 = []byte{ + // 443 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x6e, 0x13, 0x41, + 0x10, 0x86, 0xbd, 0xb6, 0xcf, 0x3e, 0xc6, 0x04, 0xa2, 0x55, 0x84, 0x0e, 0x17, 0x87, 0x65, 0x41, + 0x64, 0x9a, 0x3b, 0x14, 0x1a, 0x14, 0x0a, 0x84, 0xc1, 0x45, 0x28, 0x40, 0x5a, 0xa8, 0x68, 0xa2, + 0xcb, 0xee, 0xd8, 0x59, 0xd9, 0xde, 0xb5, 0xf6, 0xd6, 0x21, 0x7e, 0x83, 0x94, 0x3c, 0x02, 0x8f, + 0x43, 0x99, 0x92, 0x0a, 0xa1, 0xf3, 0x8b, 0xa0, 0xdb, 0xbd, 0x43, 0xb1, 0x94, 0x14, 0x74, 0x33, + 0xff, 0xcc, 0xff, 0xed, 0xdd, 0xcc, 0xc0, 0x63, 0xbc, 0xd4, 0x5c, 0x1b, 0x4c, 0xb5, 0xc9, 0xf8, + 0x02, 0x53, 0xa9, 0xa6, 0x3a, 0x59, 0x19, 0x6d, 0x35, 0x7d, 0x50, 0x95, 0x12, 0x5f, 0xea, 0x1f, + 0xcc, 0xf4, 0x4c, 0xbb, 0x52, 0x5a, 0x46, 0xbe, 0x6b, 0x98, 0x42, 0xf0, 0xee, 0x3c, 0x93, 0x8a, + 0x52, 0x68, 0xab, 0x6c, 0x89, 0x11, 0x19, 0x90, 0xd1, 0x3d, 0xe6, 0xe2, 0x52, 0x13, 0x98, 0xf3, + 0xa8, 0xe9, 0xb5, 0x32, 0x1e, 0xfe, 0x20, 0x10, 0x7c, 0xd1, 0x73, 0xbc, 0xdd, 0x71, 0x08, 0x21, + 0x2f, 0x71, 0xa7, 0x52, 0x38, 0x57, 0x7b, 0xdc, 0x2b, 0x7e, 0x3f, 0xe9, 0xba, 0x27, 0x4e, 0xde, + 0xb3, 0xae, 0x2b, 0x9e, 0x08, 0xfa, 0x1c, 0xf6, 0xb9, 0x56, 0xd6, 0x64, 0xdc, 0x9e, 0x66, 0x42, + 0x18, 0xcc, 0xf3, 0xa8, 0xe5, 0x38, 0x0f, 0x6b, 0xfd, 0xad, 0x97, 0x69, 0x04, 0x5d, 0x81, 0x5c, + 0x2e, 0xb3, 0x45, 0xd4, 0x1e, 0x90, 0x51, 0xc0, 0xea, 0x94, 0x3e, 0x82, 0x4e, 0xc6, 0xad, 0xbc, + 0xc0, 0x28, 0x18, 0x90, 0x51, 0xc8, 0xaa, 0x6c, 0x78, 0xd5, 0x84, 0x70, 0xa2, 0xc4, 0x4a, 0x4b, + 0x65, 0xe9, 0x18, 0x42, 0x3d, 0x9d, 0xba, 0x77, 0x23, 0x32, 0x68, 0x8d, 0x7a, 0x47, 0x87, 0xc9, + 0xee, 0x64, 0x92, 0xba, 0x37, 0xf9, 0x54, 0x35, 0x4e, 0x94, 0x35, 0x1b, 0xf6, 0xcf, 0x47, 0xdf, + 0x40, 0x57, 0x2b, 0x8f, 0x68, 0x3a, 0xc4, 0xb3, 0xbb, 0x11, 0xea, 0x06, 0xa1, 0x76, 0xf5, 0x5f, + 0xc3, 0xde, 0x0e, 0x9b, 0xee, 0x43, 0x6b, 0x8e, 0x1b, 0x37, 0xba, 0x36, 0x2b, 0x43, 0x7a, 0x00, + 0xc1, 0x45, 0xb6, 0x58, 0x63, 0x35, 0x6c, 0x9f, 0x1c, 0x37, 0x5f, 0x91, 0xfe, 0x31, 0xdc, 0xbf, + 0x49, 0xfd, 0x1f, 0xef, 0xf0, 0x8a, 0x40, 0xe7, 0xb3, 0x5e, 0x1b, 0x8e, 0xb7, 0xae, 0x2b, 0x81, + 0x00, 0x4b, 0xa6, 0x33, 0xf6, 0x8e, 0xa2, 0xbb, 0x7e, 0x8b, 0xf9, 0xb6, 0xea, 0x21, 0x29, 0xdc, + 0xae, 0x42, 0xe6, 0x13, 0xfa, 0x14, 0xf6, 0x04, 0x5a, 0x34, 0x4b, 0xa9, 0x64, 0x6e, 0x25, 0x77, + 0x7b, 0x0a, 0xd9, 0xae, 0x38, 0xfe, 0xf0, 0xb3, 0x88, 0xc9, 0x75, 0x11, 0x93, 0x3f, 0x45, 0x4c, + 0xbe, 0x6f, 0xe3, 0xc6, 0xf5, 0x36, 0x6e, 0xfc, 0xda, 0xc6, 0x8d, 0xaf, 0x2f, 0x66, 0xd2, 0x9e, + 0xaf, 0xcf, 0x12, 0xae, 0x97, 0xe9, 0xc4, 0x7f, 0xc0, 0x47, 0xb4, 0xdf, 0xb4, 0x99, 0xa7, 0xf5, + 0x79, 0x5f, 0xd6, 0x07, 0x6e, 0x37, 0x2b, 0xcc, 0xcf, 0x3a, 0xee, 0x78, 0x5f, 0xfe, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x2e, 0xec, 0xd2, 0x51, 0xff, 0x02, 0x00, 0x00, +} + +func (m *Chain) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Chain) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Desc) > 0 { + i -= len(m.Desc) + copy(dAtA[i:], m.Desc) + i = encodeVarintInfo(dAtA, i, uint64(len(m.Desc))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintInfo(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Token) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Token) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Token) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Active { + i-- + if m.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.Decimal != 0 { + i = encodeVarintInfo(dAtA, i, uint64(m.Decimal)) + i-- + dAtA[i] = 0x20 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintInfo(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x1a + } + if m.ChainID != 0 { + i = encodeVarintInfo(dAtA, i, uint64(m.ChainID)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintInfo(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Endpoint) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Onchain) > 0 { + for k := range m.Onchain { + v := m.Onchain[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintInfo(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i = encodeVarintInfo(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintInfo(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Offchain) > 0 { + for k := range m.Offchain { + v := m.Offchain[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintInfo(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i = encodeVarintInfo(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintInfo(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Source) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Source) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Source) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Deterministic { + i-- + if m.Deterministic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Valid { + i-- + if m.Valid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.Entry != nil { + { + size, err := m.Entry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintInfo(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Chain) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + l = len(m.Desc) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + return n +} + +func (m *Token) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + if m.ChainID != 0 { + n += 1 + sovInfo(uint64(m.ChainID)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + if m.Decimal != 0 { + n += 1 + sovInfo(uint64(m.Decimal)) + } + if m.Active { + n += 2 + } + return n +} + +func (m *Endpoint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Offchain) > 0 { + for k, v := range m.Offchain { + _ = k + _ = v + mapEntrySize := 1 + sovInfo(uint64(k)) + 1 + len(v) + sovInfo(uint64(len(v))) + n += mapEntrySize + 1 + sovInfo(uint64(mapEntrySize)) + } + } + if len(m.Onchain) > 0 { + for k, v := range m.Onchain { + _ = k + _ = v + mapEntrySize := 1 + sovInfo(uint64(k)) + 1 + len(v) + sovInfo(uint64(len(v))) + n += mapEntrySize + 1 + sovInfo(uint64(mapEntrySize)) + } + } + return n +} + +func (m *Source) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + if m.Entry != nil { + l = m.Entry.Size() + n += 1 + l + sovInfo(uint64(l)) + } + if m.Valid { + n += 2 + } + if m.Deterministic { + n += 2 + } + return n +} + +func sovInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozInfo(x uint64) (n int) { + return sovInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Chain) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Chain: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Chain: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Desc", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Desc = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Token) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Token: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Token: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) + } + m.ChainID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimal", wireType) + } + m.Decimal = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimal |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Active = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Endpoint) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Offchain", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Offchain == nil { + m.Offchain = make(map[uint64]string) + } + var mapkey uint64 + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthInfo + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthInfo + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Offchain[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Onchain", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Onchain == nil { + m.Onchain = make(map[uint64]string) + } + var mapkey uint64 + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthInfo + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthInfo + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Onchain[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Source) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Source: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Source: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Entry == nil { + m.Entry = &Endpoint{} + } + if err := m.Entry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Valid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Valid = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deterministic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Deterministic = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipInfo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/key_prices.go b/x/oracle/types/key_prices.go new file mode 100644 index 000000000..a140fd619 --- /dev/null +++ b/x/oracle/types/key_prices.go @@ -0,0 +1,34 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // PricesKeyPrefix is the prefix to retrieve all Prices + PricesKeyPrefix = "Prices/value/" +) + +// PricesNextRoundIDKey is the key set for each tokenId storeKV to store the next round id +var PricesNextRoundIDKey = []byte("nextRoundID/") + +// PricesKey returns the store key to retrieve a Prices from the index fields +// this key is actually used as the prefix for kvsotre, TODO: refactor to PriceTokenPrefix +func PricesKey( + tokenID uint64, +) []byte { + var key []byte + + tokenIDBytes := Uint64Bytes(tokenID) + key = append(key, tokenIDBytes...) + key = append(key, []byte("/")...) + + return key +} + +// PricesRoundKey returns the store key to retrieve a PriceTimeRound from the index fields +func PricesRoundKey( + roundID uint64, +) []byte { + return append(Uint64Bytes(roundID), []byte("/")...) +} diff --git a/x/oracle/types/key_recent_msg.go b/x/oracle/types/key_recent_msg.go new file mode 100644 index 000000000..c212aa470 --- /dev/null +++ b/x/oracle/types/key_recent_msg.go @@ -0,0 +1,23 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // RecentMsgKeyPrefix is the prefix to retrieve all RecentMsg + RecentMsgKeyPrefix = "RecentMsg/value/" +) + +// RecentMsgKey returns the store key to retrieve a RecentMsg from the index fields +func RecentMsgKey( + block uint64, +) []byte { + var key []byte + + blockBytes := Uint64Bytes(block) + key = append(key, blockBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/oracle/types/key_recent_params.go b/x/oracle/types/key_recent_params.go new file mode 100644 index 000000000..2c57ef26a --- /dev/null +++ b/x/oracle/types/key_recent_params.go @@ -0,0 +1,23 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // RecentParamsKeyPrefix is the prefix to retrieve all RecentParams + RecentParamsKeyPrefix = "RecentParams/value/" +) + +// RecentParamsKey returns the store key to retrieve a RecentParams from the index fields +func RecentParamsKey( + block uint64, +) []byte { + var key []byte + + blockBytes := Uint64Bytes(block) + key = append(key, blockBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go new file mode 100644 index 000000000..140564af9 --- /dev/null +++ b/x/oracle/types/keys.go @@ -0,0 +1,37 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "oracle" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_oracle" +) + +var ParamsKey = []byte{0x11} + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +const ( + ValidatorsKey = "Validators/value/" +) + +const ( + ValidatorUpdateBlockKey = "ValidatorUpdateBlock/value/" +) + +const ( + IndexRecentParamsKey = "IndexRecentParams/value/" +) + +const ( + IndexRecentMsgKey = "IndexRecentMsg/value/" +) diff --git a/x/oracle/types/message_create_price.go b/x/oracle/types/message_create_price.go new file mode 100644 index 000000000..0ce3452af --- /dev/null +++ b/x/oracle/types/message_create_price.go @@ -0,0 +1,50 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgCreatePrice = "create_price" + +var _ sdk.Msg = &MsgCreatePrice{} + +func NewMsgCreatePrice(creator string, feederID uint64, prices []*PriceSource, basedBlock uint64, nonce int32) *MsgCreatePrice { + return &MsgCreatePrice{ + Creator: creator, + FeederID: feederID, + Prices: prices, + BasedBlock: basedBlock, + Nonce: nonce, + } +} + +func (msg *MsgCreatePrice) Route() string { + return RouterKey +} + +func (msg *MsgCreatePrice) Type() string { + return TypeMsgCreatePrice +} + +func (msg *MsgCreatePrice) GetSigners() []sdk.AccAddress { + creator, err := sdk.ValAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sdk.AccAddress(creator)} +} + +func (msg *MsgCreatePrice) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreatePrice) ValidateBasic() error { + _, err := sdk.ValAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid creator address (%s)", err) + } + return nil +} diff --git a/x/oracle/types/message_create_price_test.go b/x/oracle/types/message_create_price_test.go new file mode 100644 index 000000000..705b710f9 --- /dev/null +++ b/x/oracle/types/message_create_price_test.go @@ -0,0 +1,42 @@ +package types + +import ( + "testing" + + "github.com/ExocoreNetwork/exocore/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + // sdkerrors "cosmossdk.io/errors"" + "github.com/stretchr/testify/require" +) + +func TestMsgCreatePrice_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreatePrice + err error + }{ + { + name: "invalid address", + msg: MsgCreatePrice{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgCreatePrice{ + Creator: sample.ValAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/oracle/types/message_update_params.go b/x/oracle/types/message_update_params.go new file mode 100644 index 000000000..84822971f --- /dev/null +++ b/x/oracle/types/message_update_params.go @@ -0,0 +1,39 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgUpdateParams = "update_params" + +var _ sdk.Msg = &MsgUpdateParams{} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return TypeMsgUpdateParams +} + +// GetSignBytes returns the raw bytes for a MsgUpdateParams message that +// the expected signer needs to sign. +func (msg *MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic executes sanity validation on the provided data +func (msg *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return sdkerrors.Wrap(err, "invalid authority address") + } + return msg.Params.Validate() +} + +// GetSigners returns the expected signers for a MsgUpdateParams message +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go new file mode 100644 index 000000000..b8df75516 --- /dev/null +++ b/x/oracle/types/params.go @@ -0,0 +1,99 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var ( + KeyChains = []byte("Chains") + KeyTokens = []byte("Tokens") + KeySources = []byte("Sources") + KeyRules = []byte("Rules") + KeyTokenFeeders = []byte("TokenFeeders") +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return Params{ + Chains: []*Chain{ + {Name: "-", Desc: "-"}, + {Name: "Ethereum", Desc: "-"}, + }, + Tokens: []*Token{ + {}, + { + Name: "ETH", + ChainID: 1, + ContractAddress: "0x", + Decimal: 18, + Active: true, + }, + }, + Sources: []*Source{ + { + Name: "0 position is reserved", + }, + { + Name: "Chainlink", + Entry: &Endpoint{ + Offchain: map[uint64]string{0: ""}, + }, + Valid: true, + Deterministic: true, + }, + }, + Rules: []*RuleSource{ + // 0 is reserved + {}, + { + // all sources math + SourceIDs: []uint64{0}, + }, + }, + TokenFeeders: []*TokenFeeder{ + {}, + { + TokenID: 1, + RuleID: 1, + StartRoundID: 1, + StartBaseBlock: 100000000, + Interval: 10, + }, + }, + } +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyChains, &p.Chains, func(_ interface{}) error { return nil }), + paramtypes.NewParamSetPair(KeyTokens, &p.Tokens, func(_ interface{}) error { return nil }), + paramtypes.NewParamSetPair(KeySources, &p.Sources, func(_ interface{}) error { return nil }), + paramtypes.NewParamSetPair(KeyRules, &p.Rules, func(_ interface{}) error { return nil }), + paramtypes.NewParamSetPair(KeyTokenFeeders, &p.TokenFeeders, func(_ interface{}) error { return nil }), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/oracle/types/params.pb.go b/x/oracle/types/params.pb.go new file mode 100644 index 000000000..ab6cad371 --- /dev/null +++ b/x/oracle/types/params.pb.go @@ -0,0 +1,588 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // chains represents the blockchains info + Chains []*Chain `protobuf:"bytes,1,rep,name=chains,proto3" json:"chains,omitempty"` + // tokens info + Tokens []*Token `protobuf:"bytes,2,rep,name=tokens,proto3" json:"tokens,omitempty"` + // sources info from where the price data would be fetched + Sources []*Source `protobuf:"bytes,3,rep,name=sources,proto3" json:"sources,omitempty"` + // rules specified on how to decide the provided price source to be accept + Rules []*RuleSource `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` + // each tokenFeeder represents an active token whose price being updated + TokenFeeders []*TokenFeeder `protobuf:"bytes,5,rep,name=token_feeders,json=tokenFeeders,proto3" json:"token_feeders,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ba212ceb89f5e6b2, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetChains() []*Chain { + if m != nil { + return m.Chains + } + return nil +} + +func (m *Params) GetTokens() []*Token { + if m != nil { + return m.Tokens + } + return nil +} + +func (m *Params) GetSources() []*Source { + if m != nil { + return m.Sources + } + return nil +} + +func (m *Params) GetRules() []*RuleSource { + if m != nil { + return m.Rules + } + return nil +} + +func (m *Params) GetTokenFeeders() []*TokenFeeder { + if m != nil { + return m.TokenFeeders + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "exocore.oracle.Params") +} + +func init() { proto.RegisterFile("exocore/oracle/params.proto", fileDescriptor_ba212ceb89f5e6b2) } + +var fileDescriptor_ba212ceb89f5e6b2 = []byte{ + // 296 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, + 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0xa5, 0x24, + 0xd1, 0x14, 0x67, 0xe6, 0xa5, 0xe5, 0x43, 0x94, 0x4a, 0x29, 0xa2, 0x49, 0x95, 0xe4, 0x67, 0xa7, + 0xe6, 0xc5, 0xa7, 0xa5, 0xa6, 0xa6, 0xa4, 0x16, 0x41, 0x95, 0x88, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, + 0x99, 0xfa, 0x20, 0x16, 0x44, 0x54, 0x69, 0x12, 0x13, 0x17, 0x5b, 0x00, 0xd8, 0x52, 0x21, 0x5d, + 0x2e, 0xb6, 0xe4, 0x8c, 0xc4, 0xcc, 0xbc, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x51, + 0x3d, 0x54, 0xfb, 0xf5, 0x9c, 0x41, 0xb2, 0x41, 0x50, 0x45, 0x20, 0xe5, 0x60, 0x5b, 0x8a, 0x25, + 0x98, 0xb0, 0x2b, 0x0f, 0x01, 0xc9, 0x06, 0x41, 0x15, 0x09, 0x19, 0x70, 0xb1, 0x17, 0xe7, 0x97, + 0x16, 0x25, 0xa7, 0x16, 0x4b, 0x30, 0x83, 0xd5, 0x8b, 0xa1, 0xab, 0x0f, 0x06, 0x4b, 0x07, 0xc1, + 0x94, 0x09, 0x19, 0x70, 0xb1, 0x16, 0x95, 0xe6, 0xa4, 0x16, 0x4b, 0xb0, 0x80, 0xd5, 0x4b, 0xa1, + 0xab, 0x0f, 0x2a, 0xcd, 0x49, 0x85, 0xea, 0x81, 0x28, 0x14, 0x72, 0xe0, 0xe2, 0x45, 0xf6, 0x78, + 0xb1, 0x04, 0x2b, 0x58, 0xa7, 0x34, 0x56, 0x97, 0xb9, 0x81, 0xd5, 0x04, 0xf1, 0x94, 0x20, 0x38, + 0xc5, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x38, 0x79, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, + 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, + 0xb1, 0x1c, 0x43, 0x94, 0x41, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0xbe, + 0x2b, 0xc4, 0x50, 0xbf, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0x58, 0x0c, 0x54, 0xc0, 0xe3, + 0xa0, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xce, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x77, 0xaa, 0x84, 0x42, 0xea, 0x01, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenFeeders) > 0 { + for iNdEx := len(m.TokenFeeders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokenFeeders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Rules) > 0 { + for iNdEx := len(m.Rules) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Sources) > 0 { + for iNdEx := len(m.Sources) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Sources[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Chains) > 0 { + for iNdEx := len(m.Chains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Chains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Chains) > 0 { + for _, e := range m.Chains { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.Sources) > 0 { + for _, e := range m.Sources { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.TokenFeeders) > 0 { + for _, e := range m.TokenFeeders { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Chains", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Chains = append(m.Chains, &Chain{}) + if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tokens = append(m.Tokens, &Token{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sources = append(m.Sources, &Source{}) + if err := m.Sources[len(m.Sources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rules = append(m.Rules, &RuleSource{}) + if err := m.Rules[len(m.Rules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenFeeders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenFeeders = append(m.TokenFeeders, &TokenFeeder{}) + if err := m.TokenFeeders[len(m.TokenFeeders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/price.pb.go b/x/oracle/types/price.pb.go new file mode 100644 index 000000000..64cc7b195 --- /dev/null +++ b/x/oracle/types/price.pb.go @@ -0,0 +1,1040 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/price.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// token price with timestamp fetched from source +// {price:"12345",decimal:"2"}->price: 123.45 usdt +type PriceTimeDetID struct { + // price at a specific point(timestamp of non-deterministic source, roundId of deteministic source) + Price string `protobuf:"bytes,1,opt,name=price,proto3" json:"price,omitempty"` + // decimal of the corresponding price + Decimal int32 `protobuf:"varint,2,opt,name=decimal,proto3" json:"decimal,omitempty"` + // timestamp when the price corresponding to + Timestamp string `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // det_id is used for deterministic source to tell of which round from this source the price is corresponded + DetID string `protobuf:"bytes,4,opt,name=det_id,json=detId,proto3" json:"det_id,omitempty"` +} + +func (m *PriceTimeDetID) Reset() { *m = PriceTimeDetID{} } +func (m *PriceTimeDetID) String() string { return proto.CompactTextString(m) } +func (*PriceTimeDetID) ProtoMessage() {} +func (*PriceTimeDetID) Descriptor() ([]byte, []int) { + return fileDescriptor_6755466c800b64fc, []int{0} +} +func (m *PriceTimeDetID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PriceTimeDetID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PriceTimeDetID.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PriceTimeDetID) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceTimeDetID.Merge(m, src) +} +func (m *PriceTimeDetID) XXX_Size() int { + return m.Size() +} +func (m *PriceTimeDetID) XXX_DiscardUnknown() { + xxx_messageInfo_PriceTimeDetID.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceTimeDetID proto.InternalMessageInfo + +func (m *PriceTimeDetID) GetPrice() string { + if m != nil { + return m.Price + } + return "" +} + +func (m *PriceTimeDetID) GetDecimal() int32 { + if m != nil { + return m.Decimal + } + return 0 +} + +func (m *PriceTimeDetID) GetTimestamp() string { + if m != nil { + return m.Timestamp + } + return "" +} + +func (m *PriceTimeDetID) GetDetID() string { + if m != nil { + return m.DetID + } + return "" +} + +// price with its corresponding source +type PriceSource struct { + // source_id refers to id from Params.SourceList, where this price fetched from, 0 is reserved for custom usage + SourceID uint64 `protobuf:"varint,1,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` + // if source is deteministic like chainlink with roundID, set this value with which returned from source + // up to 3 values in case of the async of network, to give more time for oracle nodes(validators) get into consensus + // eg.with deterministic source, this array will contian 3 continuous values up to latest + // for non-deterministic source, it's a choice by v2 rules. + Prices []*PriceTimeDetID `protobuf:"bytes,2,rep,name=prices,proto3" json:"prices,omitempty"` + // used for 0-sourceID-customDefinedSource + Desc string `protobuf:"bytes,3,opt,name=desc,proto3" json:"desc,omitempty"` +} + +func (m *PriceSource) Reset() { *m = PriceSource{} } +func (m *PriceSource) String() string { return proto.CompactTextString(m) } +func (*PriceSource) ProtoMessage() {} +func (*PriceSource) Descriptor() ([]byte, []int) { + return fileDescriptor_6755466c800b64fc, []int{1} +} +func (m *PriceSource) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PriceSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PriceSource.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PriceSource) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceSource.Merge(m, src) +} +func (m *PriceSource) XXX_Size() int { + return m.Size() +} +func (m *PriceSource) XXX_DiscardUnknown() { + xxx_messageInfo_PriceSource.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceSource proto.InternalMessageInfo + +func (m *PriceSource) GetSourceID() uint64 { + if m != nil { + return m.SourceID + } + return 0 +} + +func (m *PriceSource) GetPrices() []*PriceTimeDetID { + if m != nil { + return m.Prices + } + return nil +} + +func (m *PriceSource) GetDesc() string { + if m != nil { + return m.Desc + } + return "" +} + +// price with its specified timestamp and roundid(if from deteministic source) +type PriceTimeRound struct { + // price + Price string `protobuf:"bytes,1,opt,name=price,proto3" json:"price,omitempty"` + // decimal of the corresponding price + Decimal int32 `protobuf:"varint,2,opt,name=decimal,proto3" json:"decimal,omitempty"` + // timestamp when the price is corresponded + Timestamp string `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // roundid of the price if the source is deteministic + RoundID uint64 `protobuf:"varint,4,opt,name=round_id,json=roundId,proto3" json:"round_id,omitempty"` +} + +func (m *PriceTimeRound) Reset() { *m = PriceTimeRound{} } +func (m *PriceTimeRound) String() string { return proto.CompactTextString(m) } +func (*PriceTimeRound) ProtoMessage() {} +func (*PriceTimeRound) Descriptor() ([]byte, []int) { + return fileDescriptor_6755466c800b64fc, []int{2} +} +func (m *PriceTimeRound) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PriceTimeRound) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PriceTimeRound.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PriceTimeRound) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceTimeRound.Merge(m, src) +} +func (m *PriceTimeRound) XXX_Size() int { + return m.Size() +} +func (m *PriceTimeRound) XXX_DiscardUnknown() { + xxx_messageInfo_PriceTimeRound.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceTimeRound proto.InternalMessageInfo + +func (m *PriceTimeRound) GetPrice() string { + if m != nil { + return m.Price + } + return "" +} + +func (m *PriceTimeRound) GetDecimal() int32 { + if m != nil { + return m.Decimal + } + return 0 +} + +func (m *PriceTimeRound) GetTimestamp() string { + if m != nil { + return m.Timestamp + } + return "" +} + +func (m *PriceTimeRound) GetRoundID() uint64 { + if m != nil { + return m.RoundID + } + return 0 +} + +func init() { + proto.RegisterType((*PriceTimeDetID)(nil), "exocore.oracle.PriceTimeDetID") + proto.RegisterType((*PriceSource)(nil), "exocore.oracle.PriceSource") + proto.RegisterType((*PriceTimeRound)(nil), "exocore.oracle.PriceTimeRound") +} + +func init() { proto.RegisterFile("exocore/oracle/price.proto", fileDescriptor_6755466c800b64fc) } + +var fileDescriptor_6755466c800b64fc = []byte{ + // 347 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xbd, 0x4e, 0xc3, 0x30, + 0x10, 0xc7, 0xeb, 0x36, 0x69, 0x1b, 0x17, 0x75, 0xb0, 0x3a, 0x44, 0x15, 0x72, 0xa3, 0x0e, 0xa8, + 0x2c, 0x09, 0x02, 0x89, 0x07, 0x88, 0xc2, 0x10, 0x06, 0x84, 0x0c, 0x13, 0x0b, 0x6a, 0xed, 0x53, + 0x89, 0x68, 0x70, 0xe4, 0xb8, 0xa2, 0x6c, 0x0c, 0x88, 0x99, 0xc7, 0x62, 0xec, 0xc8, 0x54, 0xa1, + 0xf4, 0x45, 0x50, 0x9c, 0x46, 0xd0, 0x9d, 0xed, 0xce, 0xbf, 0xfb, 0xf8, 0xdf, 0xf9, 0xf0, 0x10, + 0x56, 0x92, 0x4b, 0x05, 0x81, 0x54, 0x53, 0xbe, 0x80, 0x20, 0x53, 0x09, 0x07, 0x3f, 0x53, 0x52, + 0x4b, 0xd2, 0xdf, 0x31, 0xbf, 0x62, 0xc3, 0xc1, 0x5c, 0xce, 0xa5, 0x41, 0x41, 0x69, 0x55, 0x51, + 0xe3, 0x57, 0x84, 0xfb, 0xd7, 0x65, 0xd6, 0x6d, 0x92, 0x42, 0x04, 0x3a, 0x8e, 0xc8, 0x00, 0xdb, + 0xa6, 0x8e, 0x8b, 0x3c, 0x34, 0x71, 0x58, 0xe5, 0x10, 0x17, 0x77, 0x04, 0xf0, 0x24, 0x9d, 0x2e, + 0xdc, 0xa6, 0x87, 0x26, 0x36, 0xab, 0x5d, 0x72, 0x88, 0x1d, 0x9d, 0xa4, 0x90, 0xeb, 0x69, 0x9a, + 0xb9, 0x2d, 0x93, 0xf3, 0xfb, 0x40, 0x3c, 0xdc, 0x16, 0xa0, 0xef, 0x13, 0xe1, 0x5a, 0x25, 0x0a, + 0x9d, 0x62, 0x33, 0xb2, 0x4d, 0x23, 0x66, 0x0b, 0xd0, 0xb1, 0x18, 0xbf, 0x21, 0xdc, 0x33, 0x12, + 0x6e, 0xe4, 0x52, 0x71, 0x20, 0xc7, 0xd8, 0xc9, 0x8d, 0x55, 0x26, 0x95, 0x1a, 0xac, 0xf0, 0xa0, + 0xd8, 0x8c, 0xba, 0x15, 0x8e, 0x23, 0xd6, 0xad, 0x70, 0x2c, 0xc8, 0x39, 0x6e, 0x1b, 0x75, 0xb9, + 0xdb, 0xf4, 0x5a, 0x93, 0xde, 0x29, 0xf5, 0xf7, 0x87, 0xf6, 0xf7, 0x47, 0x63, 0xbb, 0x68, 0x42, + 0xb0, 0x25, 0x20, 0xe7, 0x3b, 0xb5, 0xc6, 0x1e, 0xbf, 0xff, 0xdd, 0x04, 0x93, 0xcb, 0x27, 0xf1, + 0xcf, 0x9b, 0x38, 0xc2, 0x5d, 0x55, 0x96, 0xad, 0x77, 0x61, 0x85, 0xbd, 0x62, 0x33, 0xea, 0x98, + 0x56, 0x71, 0xc4, 0x3a, 0x06, 0xc6, 0x22, 0xbc, 0xfc, 0x2c, 0x28, 0x5a, 0x17, 0x14, 0x7d, 0x17, + 0x14, 0x7d, 0x6c, 0x69, 0x63, 0xbd, 0xa5, 0x8d, 0xaf, 0x2d, 0x6d, 0xdc, 0x9d, 0xcc, 0x13, 0xfd, + 0xb0, 0x9c, 0xf9, 0x5c, 0xa6, 0xc1, 0x45, 0x35, 0xe8, 0x15, 0xe8, 0x67, 0xa9, 0x1e, 0x83, 0xfa, + 0x10, 0x56, 0xf5, 0x29, 0xe8, 0x97, 0x0c, 0xf2, 0x59, 0xdb, 0xfc, 0xf2, 0xd9, 0x4f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xc3, 0xe6, 0x21, 0x72, 0x29, 0x02, 0x00, 0x00, +} + +func (m *PriceTimeDetID) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PriceTimeDetID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PriceTimeDetID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DetID) > 0 { + i -= len(m.DetID) + copy(dAtA[i:], m.DetID) + i = encodeVarintPrice(dAtA, i, uint64(len(m.DetID))) + i-- + dAtA[i] = 0x22 + } + if len(m.Timestamp) > 0 { + i -= len(m.Timestamp) + copy(dAtA[i:], m.Timestamp) + i = encodeVarintPrice(dAtA, i, uint64(len(m.Timestamp))) + i-- + dAtA[i] = 0x1a + } + if m.Decimal != 0 { + i = encodeVarintPrice(dAtA, i, uint64(m.Decimal)) + i-- + dAtA[i] = 0x10 + } + if len(m.Price) > 0 { + i -= len(m.Price) + copy(dAtA[i:], m.Price) + i = encodeVarintPrice(dAtA, i, uint64(len(m.Price))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PriceSource) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PriceSource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PriceSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Desc) > 0 { + i -= len(m.Desc) + copy(dAtA[i:], m.Desc) + i = encodeVarintPrice(dAtA, i, uint64(len(m.Desc))) + i-- + dAtA[i] = 0x1a + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPrice(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.SourceID != 0 { + i = encodeVarintPrice(dAtA, i, uint64(m.SourceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PriceTimeRound) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PriceTimeRound) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PriceTimeRound) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RoundID != 0 { + i = encodeVarintPrice(dAtA, i, uint64(m.RoundID)) + i-- + dAtA[i] = 0x20 + } + if len(m.Timestamp) > 0 { + i -= len(m.Timestamp) + copy(dAtA[i:], m.Timestamp) + i = encodeVarintPrice(dAtA, i, uint64(len(m.Timestamp))) + i-- + dAtA[i] = 0x1a + } + if m.Decimal != 0 { + i = encodeVarintPrice(dAtA, i, uint64(m.Decimal)) + i-- + dAtA[i] = 0x10 + } + if len(m.Price) > 0 { + i -= len(m.Price) + copy(dAtA[i:], m.Price) + i = encodeVarintPrice(dAtA, i, uint64(len(m.Price))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPrice(dAtA []byte, offset int, v uint64) int { + offset -= sovPrice(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PriceTimeDetID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Price) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + if m.Decimal != 0 { + n += 1 + sovPrice(uint64(m.Decimal)) + } + l = len(m.Timestamp) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + l = len(m.DetID) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + return n +} + +func (m *PriceSource) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SourceID != 0 { + n += 1 + sovPrice(uint64(m.SourceID)) + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovPrice(uint64(l)) + } + } + l = len(m.Desc) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + return n +} + +func (m *PriceTimeRound) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Price) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + if m.Decimal != 0 { + n += 1 + sovPrice(uint64(m.Decimal)) + } + l = len(m.Timestamp) + if l > 0 { + n += 1 + l + sovPrice(uint64(l)) + } + if m.RoundID != 0 { + n += 1 + sovPrice(uint64(m.RoundID)) + } + return n +} + +func sovPrice(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPrice(x uint64) (n int) { + return sovPrice(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PriceTimeDetID) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PriceTimeDetID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PriceTimeDetID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Price = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimal", wireType) + } + m.Decimal = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimal |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Timestamp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DetID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DetID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPrice(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPrice + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PriceSource) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PriceSource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PriceSource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceID", wireType) + } + m.SourceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SourceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, &PriceTimeDetID{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Desc", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Desc = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPrice(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPrice + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PriceTimeRound) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PriceTimeRound: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PriceTimeRound: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Price = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimal", wireType) + } + m.Decimal = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimal |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPrice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPrice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Timestamp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RoundID", wireType) + } + m.RoundID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RoundID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPrice(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPrice + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPrice(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPrice + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPrice + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPrice + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPrice = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPrice = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPrice = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/prices.pb.go b/x/oracle/types/prices.pb.go new file mode 100644 index 000000000..43a216e16 --- /dev/null +++ b/x/oracle/types/prices.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/prices.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// prices of all rounds of a specific token +type Prices struct { + // for which token these prices are + TokenID uint64 `protobuf:"varint,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + // next round id of the price to be updated + NextRoundID uint64 `protobuf:"varint,2,opt,name=next_round_id,json=nextRoundId,proto3" json:"next_round_id,omitempty"` + // price list of all history round prices for the token + PriceList []*PriceTimeRound `protobuf:"bytes,3,rep,name=price_list,json=priceList,proto3" json:"price_list,omitempty"` +} + +func (m *Prices) Reset() { *m = Prices{} } +func (m *Prices) String() string { return proto.CompactTextString(m) } +func (*Prices) ProtoMessage() {} +func (*Prices) Descriptor() ([]byte, []int) { + return fileDescriptor_50cc9ccc8f92b87a, []int{0} +} +func (m *Prices) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Prices) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Prices.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Prices) XXX_Merge(src proto.Message) { + xxx_messageInfo_Prices.Merge(m, src) +} +func (m *Prices) XXX_Size() int { + return m.Size() +} +func (m *Prices) XXX_DiscardUnknown() { + xxx_messageInfo_Prices.DiscardUnknown(m) +} + +var xxx_messageInfo_Prices proto.InternalMessageInfo + +func (m *Prices) GetTokenID() uint64 { + if m != nil { + return m.TokenID + } + return 0 +} + +func (m *Prices) GetNextRoundID() uint64 { + if m != nil { + return m.NextRoundID + } + return 0 +} + +func (m *Prices) GetPriceList() []*PriceTimeRound { + if m != nil { + return m.PriceList + } + return nil +} + +func init() { + proto.RegisterType((*Prices)(nil), "exocore.oracle.Prices") +} + +func init() { proto.RegisterFile("exocore/oracle/prices.proto", fileDescriptor_50cc9ccc8f92b87a) } + +var fileDescriptor_50cc9ccc8f92b87a = []byte{ + // 268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x4c, 0x4e, + 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x4a, 0xea, 0x41, 0x24, 0xa5, 0xa4, + 0xb0, 0x29, 0x86, 0xa8, 0x95, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x33, 0xf5, 0x41, 0x2c, 0x88, + 0xa8, 0xd2, 0x12, 0x46, 0x2e, 0xb6, 0x00, 0xb0, 0x91, 0x42, 0x6a, 0x5c, 0x1c, 0x25, 0xf9, 0xd9, + 0xa9, 0x79, 0xf1, 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x4e, 0xdc, 0x8f, 0xee, 0xc9, + 0xb3, 0x87, 0x80, 0xc4, 0x3c, 0x5d, 0x82, 0xd8, 0xc1, 0x92, 0x9e, 0x29, 0x42, 0xc6, 0x5c, 0xbc, + 0x79, 0xa9, 0x15, 0x25, 0xf1, 0x45, 0xf9, 0xa5, 0x79, 0x29, 0x20, 0xc5, 0x4c, 0x60, 0xc5, 0xfc, + 0x8f, 0xee, 0xc9, 0x73, 0xfb, 0xa5, 0x56, 0x94, 0x04, 0x81, 0xc4, 0x3d, 0x5d, 0x82, 0xb8, 0xf3, + 0xe0, 0x9c, 0x14, 0x21, 0x5b, 0x2e, 0x2e, 0xb0, 0x63, 0xe2, 0x73, 0x32, 0x8b, 0x4b, 0x24, 0x98, + 0x15, 0x98, 0x35, 0xb8, 0x8d, 0xe4, 0xf4, 0x50, 0x9d, 0xaf, 0x07, 0x76, 0x48, 0x48, 0x66, 0x6e, + 0x2a, 0x58, 0x57, 0x10, 0x27, 0x58, 0x87, 0x4f, 0x66, 0x71, 0x89, 0x93, 0xd7, 0x89, 0x47, 0x72, + 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, + 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, + 0xe7, 0xe7, 0xea, 0xbb, 0x42, 0x8c, 0xf3, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x87, 0x05, + 0x46, 0x05, 0x2c, 0x38, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x3e, 0x37, 0x06, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x30, 0x95, 0x2b, 0x4d, 0x5a, 0x01, 0x00, 0x00, +} + +func (m *Prices) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Prices) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Prices) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PriceList) > 0 { + for iNdEx := len(m.PriceList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PriceList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPrices(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.NextRoundID != 0 { + i = encodeVarintPrices(dAtA, i, uint64(m.NextRoundID)) + i-- + dAtA[i] = 0x10 + } + if m.TokenID != 0 { + i = encodeVarintPrices(dAtA, i, uint64(m.TokenID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPrices(dAtA []byte, offset int, v uint64) int { + offset -= sovPrices(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Prices) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TokenID != 0 { + n += 1 + sovPrices(uint64(m.TokenID)) + } + if m.NextRoundID != 0 { + n += 1 + sovPrices(uint64(m.NextRoundID)) + } + if len(m.PriceList) > 0 { + for _, e := range m.PriceList { + l = e.Size() + n += 1 + l + sovPrices(uint64(l)) + } + } + return n +} + +func sovPrices(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPrices(x uint64) (n int) { + return sovPrices(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Prices) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrices + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Prices: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Prices: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenID", wireType) + } + m.TokenID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrices + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TokenID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextRoundID", wireType) + } + m.NextRoundID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrices + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextRoundID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrices + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPrices + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPrices + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceList = append(m.PriceList, &PriceTimeRound{}) + if err := m.PriceList[len(m.PriceList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPrices(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPrices + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPrices(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrices + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrices + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPrices + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPrices + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPrices + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPrices + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPrices = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPrices = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPrices = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go new file mode 100644 index 000000000..5e8e0b408 --- /dev/null +++ b/x/oracle/types/query.pb.go @@ -0,0 +1,4030 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryGetPricesRequest is request type for all prices of a specific token +type QueryGetPricesRequest struct { + // token_id represents which token's price will be retrieved + TokenId uint64 `protobuf:"varint,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` +} + +func (m *QueryGetPricesRequest) Reset() { *m = QueryGetPricesRequest{} } +func (m *QueryGetPricesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetPricesRequest) ProtoMessage() {} +func (*QueryGetPricesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{2} +} +func (m *QueryGetPricesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPricesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPricesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPricesRequest.Merge(m, src) +} +func (m *QueryGetPricesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPricesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPricesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPricesRequest proto.InternalMessageInfo + +func (m *QueryGetPricesRequest) GetTokenId() uint64 { + if m != nil { + return m.TokenId + } + return 0 +} + +// QueryGetPricesResponse +type QueryGetPricesResponse struct { + // prices returned prices + Prices Prices `protobuf:"bytes,1,opt,name=prices,proto3" json:"prices"` +} + +func (m *QueryGetPricesResponse) Reset() { *m = QueryGetPricesResponse{} } +func (m *QueryGetPricesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetPricesResponse) ProtoMessage() {} +func (*QueryGetPricesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{3} +} +func (m *QueryGetPricesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPricesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPricesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPricesResponse.Merge(m, src) +} +func (m *QueryGetPricesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPricesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPricesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPricesResponse proto.InternalMessageInfo + +func (m *QueryGetPricesResponse) GetPrices() Prices { + if m != nil { + return m.Prices + } + return Prices{} +} + +// QueryAllPricesRequest +type QueryAllPricesRequest struct { + // info of the pagination + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPricesRequest) Reset() { *m = QueryAllPricesRequest{} } +func (m *QueryAllPricesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllPricesRequest) ProtoMessage() {} +func (*QueryAllPricesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{4} +} +func (m *QueryAllPricesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPricesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPricesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPricesRequest.Merge(m, src) +} +func (m *QueryAllPricesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPricesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPricesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPricesRequest proto.InternalMessageInfo + +func (m *QueryAllPricesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllPricesResponse +type QueryAllPricesResponse struct { + // prices retreived + Prices []Prices `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices"` + // info of the pagination + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPricesResponse) Reset() { *m = QueryAllPricesResponse{} } +func (m *QueryAllPricesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllPricesResponse) ProtoMessage() {} +func (*QueryAllPricesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{5} +} +func (m *QueryAllPricesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPricesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPricesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPricesResponse.Merge(m, src) +} +func (m *QueryAllPricesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPricesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPricesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPricesResponse proto.InternalMessageInfo + +func (m *QueryAllPricesResponse) GetPrices() []Prices { + if m != nil { + return m.Prices + } + return nil +} + +func (m *QueryAllPricesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetValidatorUpdateBlockRequest +type QueryGetValidatorUpdateBlockRequest struct { +} + +func (m *QueryGetValidatorUpdateBlockRequest) Reset() { *m = QueryGetValidatorUpdateBlockRequest{} } +func (m *QueryGetValidatorUpdateBlockRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetValidatorUpdateBlockRequest) ProtoMessage() {} +func (*QueryGetValidatorUpdateBlockRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{6} +} +func (m *QueryGetValidatorUpdateBlockRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetValidatorUpdateBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetValidatorUpdateBlockRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetValidatorUpdateBlockRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetValidatorUpdateBlockRequest.Merge(m, src) +} +func (m *QueryGetValidatorUpdateBlockRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetValidatorUpdateBlockRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetValidatorUpdateBlockRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetValidatorUpdateBlockRequest proto.InternalMessageInfo + +// QueryGetValidatorUpdateBlockResponse +type QueryGetValidatorUpdateBlockResponse struct { + // ValidatorUpdateBlock tells the latest block on which the valdiator set was updated + ValidatorUpdateBlock ValidatorUpdateBlock `protobuf:"bytes,1,opt,name=validator_update_block,json=validatorUpdateBlock,proto3" json:"validator_update_block"` +} + +func (m *QueryGetValidatorUpdateBlockResponse) Reset() { *m = QueryGetValidatorUpdateBlockResponse{} } +func (m *QueryGetValidatorUpdateBlockResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetValidatorUpdateBlockResponse) ProtoMessage() {} +func (*QueryGetValidatorUpdateBlockResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{7} +} +func (m *QueryGetValidatorUpdateBlockResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetValidatorUpdateBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetValidatorUpdateBlockResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetValidatorUpdateBlockResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetValidatorUpdateBlockResponse.Merge(m, src) +} +func (m *QueryGetValidatorUpdateBlockResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetValidatorUpdateBlockResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetValidatorUpdateBlockResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetValidatorUpdateBlockResponse proto.InternalMessageInfo + +func (m *QueryGetValidatorUpdateBlockResponse) GetValidatorUpdateBlock() ValidatorUpdateBlock { + if m != nil { + return m.ValidatorUpdateBlock + } + return ValidatorUpdateBlock{} +} + +// QueryGetIndexRecentParamsRequest +type QueryGetIndexRecentParamsRequest struct { +} + +func (m *QueryGetIndexRecentParamsRequest) Reset() { *m = QueryGetIndexRecentParamsRequest{} } +func (m *QueryGetIndexRecentParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetIndexRecentParamsRequest) ProtoMessage() {} +func (*QueryGetIndexRecentParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{8} +} +func (m *QueryGetIndexRecentParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetIndexRecentParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetIndexRecentParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetIndexRecentParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetIndexRecentParamsRequest.Merge(m, src) +} +func (m *QueryGetIndexRecentParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetIndexRecentParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetIndexRecentParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetIndexRecentParamsRequest proto.InternalMessageInfo + +// QueryGetIndexRecentParamsResponse +type QueryGetIndexRecentParamsResponse struct { + // index_recent_params index of cached recent params + IndexRecentParams IndexRecentParams `protobuf:"bytes,1,opt,name=index_recent_params,json=indexRecentParams,proto3" json:"index_recent_params"` +} + +func (m *QueryGetIndexRecentParamsResponse) Reset() { *m = QueryGetIndexRecentParamsResponse{} } +func (m *QueryGetIndexRecentParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetIndexRecentParamsResponse) ProtoMessage() {} +func (*QueryGetIndexRecentParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{9} +} +func (m *QueryGetIndexRecentParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetIndexRecentParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetIndexRecentParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetIndexRecentParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetIndexRecentParamsResponse.Merge(m, src) +} +func (m *QueryGetIndexRecentParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetIndexRecentParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetIndexRecentParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetIndexRecentParamsResponse proto.InternalMessageInfo + +func (m *QueryGetIndexRecentParamsResponse) GetIndexRecentParams() IndexRecentParams { + if m != nil { + return m.IndexRecentParams + } + return IndexRecentParams{} +} + +// QueryGetIndexRecentMsgReque +type QueryGetIndexRecentMsgRequest struct { +} + +func (m *QueryGetIndexRecentMsgRequest) Reset() { *m = QueryGetIndexRecentMsgRequest{} } +func (m *QueryGetIndexRecentMsgRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetIndexRecentMsgRequest) ProtoMessage() {} +func (*QueryGetIndexRecentMsgRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{10} +} +func (m *QueryGetIndexRecentMsgRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetIndexRecentMsgRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetIndexRecentMsgRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetIndexRecentMsgRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetIndexRecentMsgRequest.Merge(m, src) +} +func (m *QueryGetIndexRecentMsgRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetIndexRecentMsgRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetIndexRecentMsgRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetIndexRecentMsgRequest proto.InternalMessageInfo + +// QueryIndexRecentMsgResponse +type QueryGetIndexRecentMsgResponse struct { + // index_recent_msg index of cached recent messages + IndexRecentMsg IndexRecentMsg `protobuf:"bytes,1,opt,name=index_recent_msg,json=indexRecentMsg,proto3" json:"index_recent_msg"` +} + +func (m *QueryGetIndexRecentMsgResponse) Reset() { *m = QueryGetIndexRecentMsgResponse{} } +func (m *QueryGetIndexRecentMsgResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetIndexRecentMsgResponse) ProtoMessage() {} +func (*QueryGetIndexRecentMsgResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{11} +} +func (m *QueryGetIndexRecentMsgResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetIndexRecentMsgResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetIndexRecentMsgResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetIndexRecentMsgResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetIndexRecentMsgResponse.Merge(m, src) +} +func (m *QueryGetIndexRecentMsgResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetIndexRecentMsgResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetIndexRecentMsgResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetIndexRecentMsgResponse proto.InternalMessageInfo + +func (m *QueryGetIndexRecentMsgResponse) GetIndexRecentMsg() IndexRecentMsg { + if m != nil { + return m.IndexRecentMsg + } + return IndexRecentMsg{} +} + +// QueryGetRecentMsgRequest +type QueryGetRecentMsgRequest struct { + // block represents of which block the cached message query for + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *QueryGetRecentMsgRequest) Reset() { *m = QueryGetRecentMsgRequest{} } +func (m *QueryGetRecentMsgRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetRecentMsgRequest) ProtoMessage() {} +func (*QueryGetRecentMsgRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{12} +} +func (m *QueryGetRecentMsgRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRecentMsgRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRecentMsgRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRecentMsgRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRecentMsgRequest.Merge(m, src) +} +func (m *QueryGetRecentMsgRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRecentMsgRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRecentMsgRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRecentMsgRequest proto.InternalMessageInfo + +func (m *QueryGetRecentMsgRequest) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +// QueryGetRecentMsgResponse +type QueryGetRecentMsgResponse struct { + // cached recent message + RecentMsg RecentMsg `protobuf:"bytes,1,opt,name=recent_msg,json=recentMsg,proto3" json:"recent_msg"` +} + +func (m *QueryGetRecentMsgResponse) Reset() { *m = QueryGetRecentMsgResponse{} } +func (m *QueryGetRecentMsgResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetRecentMsgResponse) ProtoMessage() {} +func (*QueryGetRecentMsgResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{13} +} +func (m *QueryGetRecentMsgResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRecentMsgResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRecentMsgResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRecentMsgResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRecentMsgResponse.Merge(m, src) +} +func (m *QueryGetRecentMsgResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRecentMsgResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRecentMsgResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRecentMsgResponse proto.InternalMessageInfo + +func (m *QueryGetRecentMsgResponse) GetRecentMsg() RecentMsg { + if m != nil { + return m.RecentMsg + } + return RecentMsg{} +} + +// QueryAllRecentMsgRequest +type QueryAllRecentMsgRequest struct { + // info of pagination + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRecentMsgRequest) Reset() { *m = QueryAllRecentMsgRequest{} } +func (m *QueryAllRecentMsgRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllRecentMsgRequest) ProtoMessage() {} +func (*QueryAllRecentMsgRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{14} +} +func (m *QueryAllRecentMsgRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRecentMsgRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRecentMsgRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRecentMsgRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRecentMsgRequest.Merge(m, src) +} +func (m *QueryAllRecentMsgRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRecentMsgRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRecentMsgRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRecentMsgRequest proto.InternalMessageInfo + +func (m *QueryAllRecentMsgRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllRecentMsgResponse +type QueryAllRecentMsgResponse struct { + // recent_msg represets the cached recent message + RecentMsg []RecentMsg `protobuf:"bytes,1,rep,name=recent_msg,json=recentMsg,proto3" json:"recent_msg"` + // info of pagination + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRecentMsgResponse) Reset() { *m = QueryAllRecentMsgResponse{} } +func (m *QueryAllRecentMsgResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllRecentMsgResponse) ProtoMessage() {} +func (*QueryAllRecentMsgResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{15} +} +func (m *QueryAllRecentMsgResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRecentMsgResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRecentMsgResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRecentMsgResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRecentMsgResponse.Merge(m, src) +} +func (m *QueryAllRecentMsgResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRecentMsgResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRecentMsgResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRecentMsgResponse proto.InternalMessageInfo + +func (m *QueryAllRecentMsgResponse) GetRecentMsg() []RecentMsg { + if m != nil { + return m.RecentMsg + } + return nil +} + +func (m *QueryAllRecentMsgResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetRecentParamsRequest +type QueryGetRecentParamsRequest struct { + // block represents of which block the cached params from + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *QueryGetRecentParamsRequest) Reset() { *m = QueryGetRecentParamsRequest{} } +func (m *QueryGetRecentParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetRecentParamsRequest) ProtoMessage() {} +func (*QueryGetRecentParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{16} +} +func (m *QueryGetRecentParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRecentParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRecentParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRecentParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRecentParamsRequest.Merge(m, src) +} +func (m *QueryGetRecentParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRecentParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRecentParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRecentParamsRequest proto.InternalMessageInfo + +func (m *QueryGetRecentParamsRequest) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +// QueryGetRecentParamsResponse +type QueryGetRecentParamsResponse struct { + // recent_params cached recent params + RecentParams RecentParams `protobuf:"bytes,1,opt,name=recent_params,json=recentParams,proto3" json:"recent_params"` +} + +func (m *QueryGetRecentParamsResponse) Reset() { *m = QueryGetRecentParamsResponse{} } +func (m *QueryGetRecentParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetRecentParamsResponse) ProtoMessage() {} +func (*QueryGetRecentParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{17} +} +func (m *QueryGetRecentParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRecentParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRecentParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRecentParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRecentParamsResponse.Merge(m, src) +} +func (m *QueryGetRecentParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRecentParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRecentParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRecentParamsResponse proto.InternalMessageInfo + +func (m *QueryGetRecentParamsResponse) GetRecentParams() RecentParams { + if m != nil { + return m.RecentParams + } + return RecentParams{} +} + +// QueryAllRecentParamsRequest +type QueryAllRecentParamsRequest struct { + // info of pagination + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRecentParamsRequest) Reset() { *m = QueryAllRecentParamsRequest{} } +func (m *QueryAllRecentParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllRecentParamsRequest) ProtoMessage() {} +func (*QueryAllRecentParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{18} +} +func (m *QueryAllRecentParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRecentParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRecentParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRecentParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRecentParamsRequest.Merge(m, src) +} +func (m *QueryAllRecentParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRecentParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRecentParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRecentParamsRequest proto.InternalMessageInfo + +func (m *QueryAllRecentParamsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllRecentParamsResponse +type QueryAllRecentParamsResponse struct { + // recent_params cached recent params + RecentParams []RecentParams `protobuf:"bytes,1,rep,name=recent_params,json=recentParams,proto3" json:"recent_params"` + // info of pagination + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRecentParamsResponse) Reset() { *m = QueryAllRecentParamsResponse{} } +func (m *QueryAllRecentParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllRecentParamsResponse) ProtoMessage() {} +func (*QueryAllRecentParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f604621c8da1a6f3, []int{19} +} +func (m *QueryAllRecentParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRecentParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRecentParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRecentParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRecentParamsResponse.Merge(m, src) +} +func (m *QueryAllRecentParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRecentParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRecentParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRecentParamsResponse proto.InternalMessageInfo + +func (m *QueryAllRecentParamsResponse) GetRecentParams() []RecentParams { + if m != nil { + return m.RecentParams + } + return nil +} + +func (m *QueryAllRecentParamsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "exocore.oracle.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "exocore.oracle.QueryParamsResponse") + proto.RegisterType((*QueryGetPricesRequest)(nil), "exocore.oracle.QueryGetPricesRequest") + proto.RegisterType((*QueryGetPricesResponse)(nil), "exocore.oracle.QueryGetPricesResponse") + proto.RegisterType((*QueryAllPricesRequest)(nil), "exocore.oracle.QueryAllPricesRequest") + proto.RegisterType((*QueryAllPricesResponse)(nil), "exocore.oracle.QueryAllPricesResponse") + proto.RegisterType((*QueryGetValidatorUpdateBlockRequest)(nil), "exocore.oracle.QueryGetValidatorUpdateBlockRequest") + proto.RegisterType((*QueryGetValidatorUpdateBlockResponse)(nil), "exocore.oracle.QueryGetValidatorUpdateBlockResponse") + proto.RegisterType((*QueryGetIndexRecentParamsRequest)(nil), "exocore.oracle.QueryGetIndexRecentParamsRequest") + proto.RegisterType((*QueryGetIndexRecentParamsResponse)(nil), "exocore.oracle.QueryGetIndexRecentParamsResponse") + proto.RegisterType((*QueryGetIndexRecentMsgRequest)(nil), "exocore.oracle.QueryGetIndexRecentMsgRequest") + proto.RegisterType((*QueryGetIndexRecentMsgResponse)(nil), "exocore.oracle.QueryGetIndexRecentMsgResponse") + proto.RegisterType((*QueryGetRecentMsgRequest)(nil), "exocore.oracle.QueryGetRecentMsgRequest") + proto.RegisterType((*QueryGetRecentMsgResponse)(nil), "exocore.oracle.QueryGetRecentMsgResponse") + proto.RegisterType((*QueryAllRecentMsgRequest)(nil), "exocore.oracle.QueryAllRecentMsgRequest") + proto.RegisterType((*QueryAllRecentMsgResponse)(nil), "exocore.oracle.QueryAllRecentMsgResponse") + proto.RegisterType((*QueryGetRecentParamsRequest)(nil), "exocore.oracle.QueryGetRecentParamsRequest") + proto.RegisterType((*QueryGetRecentParamsResponse)(nil), "exocore.oracle.QueryGetRecentParamsResponse") + proto.RegisterType((*QueryAllRecentParamsRequest)(nil), "exocore.oracle.QueryAllRecentParamsRequest") + proto.RegisterType((*QueryAllRecentParamsResponse)(nil), "exocore.oracle.QueryAllRecentParamsResponse") +} + +func init() { proto.RegisterFile("exocore/oracle/query.proto", fileDescriptor_f604621c8da1a6f3) } + +var fileDescriptor_f604621c8da1a6f3 = []byte{ + // 972 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0xc7, 0x33, 0x4d, 0x1a, 0xe8, 0x6b, 0x09, 0x74, 0xba, 0x44, 0xcd, 0x36, 0x38, 0xed, 0xb4, + 0x69, 0x53, 0xd2, 0xda, 0xd9, 0xcd, 0x42, 0x01, 0x01, 0x52, 0x22, 0x41, 0x54, 0x50, 0xa3, 0xb0, + 0x12, 0x20, 0xc1, 0x61, 0xf1, 0xee, 0x8e, 0x8c, 0x15, 0xaf, 0xc7, 0xb5, 0x9d, 0x90, 0xaa, 0x54, + 0x42, 0x9c, 0x38, 0x82, 0x90, 0xe0, 0xc0, 0x0d, 0x21, 0xc1, 0x91, 0x03, 0x1f, 0x80, 0x63, 0xb9, + 0x55, 0xe2, 0xc2, 0x09, 0xa1, 0x84, 0x0f, 0x82, 0x76, 0xfc, 0xbc, 0xbb, 0xb6, 0xc7, 0x5e, 0x2f, + 0xda, 0xdb, 0xda, 0xf3, 0x9f, 0xf7, 0x7e, 0xef, 0xcd, 0x7f, 0xfc, 0x12, 0xa8, 0xf2, 0x23, 0xd1, + 0x11, 0x3e, 0x37, 0x84, 0x6f, 0x76, 0x1c, 0x6e, 0xdc, 0x3f, 0xe0, 0xfe, 0x03, 0xdd, 0xf3, 0x45, + 0x28, 0xe8, 0x02, 0xae, 0xe9, 0xd1, 0x5a, 0xf5, 0xc5, 0x8e, 0x08, 0x7a, 0x22, 0x30, 0xda, 0x66, + 0x80, 0x42, 0xe3, 0xb0, 0xd6, 0xe6, 0xa1, 0x59, 0x33, 0x3c, 0xd3, 0xb2, 0x5d, 0x33, 0xb4, 0x85, + 0x1b, 0xed, 0xad, 0xae, 0xa6, 0xe2, 0xda, 0x6e, 0x97, 0x1f, 0xb5, 0x7c, 0xde, 0xe1, 0x6e, 0xd8, + 0xea, 0x05, 0x16, 0xca, 0xd6, 0x8a, 0x64, 0x9e, 0xe9, 0x9b, 0xbd, 0x00, 0x95, 0x97, 0x52, 0xca, + 0xe2, 0x45, 0xdf, 0xee, 0xf0, 0x78, 0x71, 0x25, 0xb5, 0x98, 0x81, 0x60, 0x6a, 0x41, 0x22, 0xc3, + 0x7a, 0x4a, 0x73, 0x68, 0x3a, 0x76, 0xd7, 0x0c, 0x85, 0xdf, 0x3a, 0xf0, 0xba, 0x66, 0xc8, 0x5b, + 0x6d, 0x47, 0x74, 0xf6, 0x51, 0x5c, 0xb1, 0x84, 0x25, 0xe4, 0x4f, 0xa3, 0xff, 0x0b, 0xdf, 0x2e, + 0x5b, 0x42, 0x58, 0x0e, 0x37, 0x4c, 0xcf, 0x36, 0x4c, 0xd7, 0x15, 0xa1, 0xec, 0x17, 0x26, 0x60, + 0x15, 0xa0, 0xef, 0xf5, 0x5b, 0xba, 0x27, 0xb3, 0x36, 0xf9, 0xfd, 0x03, 0x1e, 0x84, 0xec, 0x5d, + 0xb8, 0x90, 0x78, 0x1b, 0x78, 0xc2, 0x0d, 0x38, 0x6d, 0xc0, 0x7c, 0x44, 0x77, 0x91, 0x5c, 0x26, + 0x6b, 0x67, 0xeb, 0x8b, 0x7a, 0xf2, 0xa8, 0xf4, 0x48, 0xbf, 0x3d, 0xf7, 0xf8, 0xef, 0x95, 0x99, + 0x26, 0x6a, 0x59, 0x1d, 0x9e, 0x97, 0xc1, 0x76, 0x78, 0xb8, 0x27, 0x1b, 0x84, 0x59, 0xe8, 0x12, + 0x3c, 0x1d, 0x8a, 0x7d, 0xee, 0xb6, 0xec, 0xae, 0x0c, 0x38, 0xd7, 0x7c, 0x4a, 0x3e, 0xdf, 0xed, + 0xb2, 0x5d, 0x58, 0x4c, 0xef, 0x19, 0x61, 0x90, 0x6f, 0x72, 0x19, 0xe4, 0xea, 0x80, 0x41, 0x3e, + 0xb1, 0x16, 0x32, 0x6c, 0x39, 0x4e, 0x92, 0xe1, 0x6d, 0x80, 0xa1, 0x89, 0x30, 0xe4, 0x75, 0x3d, + 0x72, 0x9c, 0xde, 0x77, 0x9c, 0x1e, 0x59, 0x13, 0x1d, 0xa7, 0xef, 0x99, 0x16, 0xc7, 0xbd, 0xcd, + 0x91, 0x9d, 0xec, 0x7b, 0x82, 0xc4, 0x23, 0x19, 0x14, 0xc4, 0xb3, 0x65, 0x89, 0xe9, 0x4e, 0x02, + 0xec, 0x94, 0x04, 0xbb, 0x31, 0x16, 0x2c, 0x4a, 0x99, 0x20, 0x5b, 0x85, 0xab, 0x71, 0x2b, 0x3f, + 0x88, 0xdd, 0xf3, 0xbe, 0x34, 0xcf, 0x76, 0xdf, 0x3b, 0xf1, 0x91, 0x7f, 0x45, 0xe0, 0x5a, 0xb1, + 0x0e, 0xcb, 0xf9, 0x04, 0x16, 0xd5, 0x2e, 0xc4, 0xee, 0x5d, 0x4b, 0x97, 0xa7, 0x8a, 0x86, 0xc5, + 0x56, 0x0e, 0x15, 0x6b, 0x8c, 0xc1, 0xe5, 0x98, 0xe4, 0x6e, 0xff, 0x62, 0x36, 0xe5, 0xc5, 0x48, + 0x3a, 0xf4, 0x73, 0xb8, 0x52, 0xa0, 0x41, 0xd4, 0x0f, 0xe1, 0x82, 0xe2, 0x66, 0x23, 0xe7, 0x95, + 0x34, 0x67, 0x26, 0x0e, 0x42, 0x9e, 0xb7, 0xd3, 0x0b, 0x6c, 0x05, 0x5e, 0x50, 0x64, 0xbf, 0x17, + 0x58, 0x31, 0x9e, 0x07, 0x5a, 0x9e, 0x00, 0xd9, 0x76, 0xe1, 0xb9, 0xf4, 0xc7, 0x09, 0xc1, 0xb4, + 0x02, 0xb0, 0x7b, 0x81, 0x85, 0x54, 0x0b, 0x76, 0xe2, 0x2d, 0xdb, 0x80, 0x8b, 0x71, 0xc6, 0x34, + 0x0d, 0xad, 0xc0, 0xe9, 0xe1, 0x09, 0xcd, 0x35, 0xa3, 0x07, 0xf6, 0x31, 0x2c, 0x29, 0x76, 0x20, + 0xde, 0x9b, 0x00, 0x19, 0xb0, 0xa5, 0x34, 0x58, 0x9a, 0xe9, 0x8c, 0x3f, 0xc0, 0x69, 0x23, 0xce, + 0x96, 0xe3, 0x64, 0x70, 0xa6, 0x75, 0xe7, 0x7e, 0x22, 0x58, 0x41, 0x32, 0x49, 0x4e, 0x05, 0xb3, + 0x93, 0x55, 0x30, 0xbd, 0x0b, 0xb8, 0x09, 0x97, 0x92, 0x7d, 0x4e, 0x38, 0x39, 0xe7, 0x70, 0x2c, + 0x58, 0x56, 0x6f, 0xc2, 0xea, 0x76, 0xe0, 0x19, 0x95, 0xa9, 0x97, 0xd5, 0x05, 0x26, 0xfc, 0x7c, + 0xce, 0x1f, 0xb5, 0x32, 0x47, 0xba, 0x41, 0x0f, 0x93, 0x74, 0xd3, 0x3a, 0xab, 0x5f, 0x09, 0x16, + 0x94, 0xc9, 0x93, 0x5f, 0xd0, 0xec, 0xff, 0x29, 0x68, 0x6a, 0xe7, 0x56, 0xff, 0xe3, 0x2c, 0x9c, + 0x96, 0xc8, 0xf4, 0x0b, 0x02, 0xf3, 0x18, 0x9d, 0xa5, 0x79, 0xb2, 0xd3, 0xb3, 0x7a, 0xb5, 0x50, + 0x13, 0x65, 0x62, 0xb7, 0xbf, 0xfc, 0xf3, 0xdf, 0x6f, 0x4f, 0xdd, 0xa0, 0xab, 0xc6, 0x5b, 0x91, + 0x78, 0x97, 0x87, 0x9f, 0x09, 0x7f, 0xdf, 0x50, 0xfe, 0xc1, 0x41, 0xbf, 0xe9, 0x23, 0x44, 0x93, + 0x61, 0x55, 0x19, 0x3e, 0x3d, 0x5d, 0xab, 0xd7, 0xc7, 0xc9, 0x10, 0xe4, 0x15, 0x09, 0x52, 0xa7, + 0x1b, 0xe3, 0x40, 0xe4, 0x36, 0xe3, 0x61, 0x3c, 0xb2, 0x1f, 0xd1, 0xdf, 0x09, 0x54, 0x54, 0x1f, + 0x77, 0xba, 0x99, 0x97, 0xba, 0x60, 0x00, 0x55, 0x1b, 0x93, 0x6d, 0x42, 0xfa, 0x37, 0x24, 0xfd, + 0x1d, 0xfa, 0xd2, 0x18, 0x7a, 0xf5, 0xc8, 0xa2, 0xbf, 0x11, 0x38, 0x9f, 0xf9, 0xee, 0xd3, 0x8d, + 0x3c, 0x94, 0xbc, 0x71, 0x54, 0xad, 0x4d, 0xb0, 0x03, 0xc9, 0x5f, 0x93, 0xe4, 0x0d, 0x5a, 0x1f, + 0x43, 0xae, 0x98, 0x60, 0xf4, 0x17, 0x02, 0x0b, 0xc9, 0xa9, 0x40, 0x6f, 0x97, 0x20, 0x18, 0x7e, + 0x83, 0xab, 0x7a, 0x59, 0x39, 0xd2, 0xde, 0x91, 0xb4, 0x35, 0x6a, 0x4c, 0x42, 0xdb, 0x0b, 0x2c, + 0xfa, 0x03, 0x81, 0x33, 0x43, 0xca, 0xb5, 0xbc, 0xb4, 0x19, 0xc0, 0x9b, 0x25, 0x94, 0xc8, 0xf6, + 0xaa, 0x64, 0xdb, 0xa4, 0xb5, 0x31, 0x6c, 0x43, 0x2a, 0xe3, 0xa1, 0x3c, 0xfe, 0x47, 0xf4, 0x3b, + 0x02, 0xe7, 0x06, 0x01, 0xb7, 0x1c, 0x27, 0x07, 0x50, 0x31, 0xc5, 0x72, 0x00, 0x55, 0xa3, 0x88, + 0xd5, 0x24, 0xe0, 0x3a, 0xbd, 0x59, 0x1a, 0x90, 0xfe, 0x3c, 0x00, 0x43, 0x4f, 0xae, 0x17, 0xf7, + 0x23, 0x69, 0xc7, 0x5b, 0xe5, 0xc4, 0x88, 0xf7, 0xba, 0xc4, 0x7b, 0x99, 0x36, 0xca, 0xe1, 0x45, + 0x1e, 0x1c, 0xb4, 0xf0, 0x47, 0x02, 0xcf, 0x8e, 0x86, 0xed, 0x77, 0x71, 0xbd, 0xb8, 0x37, 0x65, + 0x60, 0x73, 0xe6, 0x04, 0x6b, 0x48, 0x58, 0x9d, 0xde, 0x9a, 0x04, 0x76, 0xfb, 0x9d, 0xc7, 0xc7, + 0x1a, 0x79, 0x72, 0xac, 0x91, 0x7f, 0x8e, 0x35, 0xf2, 0xf5, 0x89, 0x36, 0xf3, 0xe4, 0x44, 0x9b, + 0xf9, 0xeb, 0x44, 0x9b, 0xf9, 0x68, 0xc3, 0xb2, 0xc3, 0x4f, 0x0f, 0xda, 0x7a, 0x47, 0xf4, 0xf2, + 0x22, 0x1e, 0xc5, 0x31, 0xc3, 0x07, 0x1e, 0x0f, 0xda, 0xf3, 0xf2, 0x3f, 0xa7, 0xcd, 0xff, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xa7, 0x69, 0x73, 0x84, 0xc4, 0x0e, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of Prices items. + Prices(ctx context.Context, in *QueryGetPricesRequest, opts ...grpc.CallOption) (*QueryGetPricesResponse, error) + // Queries a ValidatorUpdateBlock by index. + ValidatorUpdateBlock(ctx context.Context, in *QueryGetValidatorUpdateBlockRequest, opts ...grpc.CallOption) (*QueryGetValidatorUpdateBlockResponse, error) + // Queries a IndexRecentParams by index. + IndexRecentParams(ctx context.Context, in *QueryGetIndexRecentParamsRequest, opts ...grpc.CallOption) (*QueryGetIndexRecentParamsResponse, error) + // Queries a IndexRecentMsg by index. + IndexRecentMsg(ctx context.Context, in *QueryGetIndexRecentMsgRequest, opts ...grpc.CallOption) (*QueryGetIndexRecentMsgResponse, error) + // Queries a list of RecentMsg items. + RecentMsg(ctx context.Context, in *QueryGetRecentMsgRequest, opts ...grpc.CallOption) (*QueryGetRecentMsgResponse, error) + // RecentMsgAll all RecentMsg items. + RecentMsgAll(ctx context.Context, in *QueryAllRecentMsgRequest, opts ...grpc.CallOption) (*QueryAllRecentMsgResponse, error) + // Queries a list of RecentParams items. + RecentParams(ctx context.Context, in *QueryGetRecentParamsRequest, opts ...grpc.CallOption) (*QueryGetRecentParamsResponse, error) + // RecentParamsAll query all RecentParams. + RecentParamsAll(ctx context.Context, in *QueryAllRecentParamsRequest, opts ...grpc.CallOption) (*QueryAllRecentParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Prices(ctx context.Context, in *QueryGetPricesRequest, opts ...grpc.CallOption) (*QueryGetPricesResponse, error) { + out := new(QueryGetPricesResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/Prices", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ValidatorUpdateBlock(ctx context.Context, in *QueryGetValidatorUpdateBlockRequest, opts ...grpc.CallOption) (*QueryGetValidatorUpdateBlockResponse, error) { + out := new(QueryGetValidatorUpdateBlockResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/ValidatorUpdateBlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) IndexRecentParams(ctx context.Context, in *QueryGetIndexRecentParamsRequest, opts ...grpc.CallOption) (*QueryGetIndexRecentParamsResponse, error) { + out := new(QueryGetIndexRecentParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/IndexRecentParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) IndexRecentMsg(ctx context.Context, in *QueryGetIndexRecentMsgRequest, opts ...grpc.CallOption) (*QueryGetIndexRecentMsgResponse, error) { + out := new(QueryGetIndexRecentMsgResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/IndexRecentMsg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecentMsg(ctx context.Context, in *QueryGetRecentMsgRequest, opts ...grpc.CallOption) (*QueryGetRecentMsgResponse, error) { + out := new(QueryGetRecentMsgResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/RecentMsg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecentMsgAll(ctx context.Context, in *QueryAllRecentMsgRequest, opts ...grpc.CallOption) (*QueryAllRecentMsgResponse, error) { + out := new(QueryAllRecentMsgResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/RecentMsgAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecentParams(ctx context.Context, in *QueryGetRecentParamsRequest, opts ...grpc.CallOption) (*QueryGetRecentParamsResponse, error) { + out := new(QueryGetRecentParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/RecentParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecentParamsAll(ctx context.Context, in *QueryAllRecentParamsRequest, opts ...grpc.CallOption) (*QueryAllRecentParamsResponse, error) { + out := new(QueryAllRecentParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Query/RecentParamsAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of Prices items. + Prices(context.Context, *QueryGetPricesRequest) (*QueryGetPricesResponse, error) + // Queries a ValidatorUpdateBlock by index. + ValidatorUpdateBlock(context.Context, *QueryGetValidatorUpdateBlockRequest) (*QueryGetValidatorUpdateBlockResponse, error) + // Queries a IndexRecentParams by index. + IndexRecentParams(context.Context, *QueryGetIndexRecentParamsRequest) (*QueryGetIndexRecentParamsResponse, error) + // Queries a IndexRecentMsg by index. + IndexRecentMsg(context.Context, *QueryGetIndexRecentMsgRequest) (*QueryGetIndexRecentMsgResponse, error) + // Queries a list of RecentMsg items. + RecentMsg(context.Context, *QueryGetRecentMsgRequest) (*QueryGetRecentMsgResponse, error) + // RecentMsgAll all RecentMsg items. + RecentMsgAll(context.Context, *QueryAllRecentMsgRequest) (*QueryAllRecentMsgResponse, error) + // Queries a list of RecentParams items. + RecentParams(context.Context, *QueryGetRecentParamsRequest) (*QueryGetRecentParamsResponse, error) + // RecentParamsAll query all RecentParams. + RecentParamsAll(context.Context, *QueryAllRecentParamsRequest) (*QueryAllRecentParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Prices(ctx context.Context, req *QueryGetPricesRequest) (*QueryGetPricesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Prices not implemented") +} +func (*UnimplementedQueryServer) ValidatorUpdateBlock(ctx context.Context, req *QueryGetValidatorUpdateBlockRequest) (*QueryGetValidatorUpdateBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidatorUpdateBlock not implemented") +} +func (*UnimplementedQueryServer) IndexRecentParams(ctx context.Context, req *QueryGetIndexRecentParamsRequest) (*QueryGetIndexRecentParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexRecentParams not implemented") +} +func (*UnimplementedQueryServer) IndexRecentMsg(ctx context.Context, req *QueryGetIndexRecentMsgRequest) (*QueryGetIndexRecentMsgResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IndexRecentMsg not implemented") +} +func (*UnimplementedQueryServer) RecentMsg(ctx context.Context, req *QueryGetRecentMsgRequest) (*QueryGetRecentMsgResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecentMsg not implemented") +} +func (*UnimplementedQueryServer) RecentMsgAll(ctx context.Context, req *QueryAllRecentMsgRequest) (*QueryAllRecentMsgResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecentMsgAll not implemented") +} +func (*UnimplementedQueryServer) RecentParams(ctx context.Context, req *QueryGetRecentParamsRequest) (*QueryGetRecentParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecentParams not implemented") +} +func (*UnimplementedQueryServer) RecentParamsAll(ctx context.Context, req *QueryAllRecentParamsRequest) (*QueryAllRecentParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecentParamsAll not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Prices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetPricesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Prices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/Prices", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Prices(ctx, req.(*QueryGetPricesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ValidatorUpdateBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetValidatorUpdateBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ValidatorUpdateBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/ValidatorUpdateBlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ValidatorUpdateBlock(ctx, req.(*QueryGetValidatorUpdateBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_IndexRecentParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetIndexRecentParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IndexRecentParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/IndexRecentParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IndexRecentParams(ctx, req.(*QueryGetIndexRecentParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_IndexRecentMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetIndexRecentMsgRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IndexRecentMsg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/IndexRecentMsg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IndexRecentMsg(ctx, req.(*QueryGetIndexRecentMsgRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecentMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetRecentMsgRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecentMsg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/RecentMsg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecentMsg(ctx, req.(*QueryGetRecentMsgRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecentMsgAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllRecentMsgRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecentMsgAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/RecentMsgAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecentMsgAll(ctx, req.(*QueryAllRecentMsgRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecentParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetRecentParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecentParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/RecentParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecentParams(ctx, req.(*QueryGetRecentParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecentParamsAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllRecentParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecentParamsAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Query/RecentParamsAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecentParamsAll(ctx, req.(*QueryAllRecentParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.oracle.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Prices", + Handler: _Query_Prices_Handler, + }, + { + MethodName: "ValidatorUpdateBlock", + Handler: _Query_ValidatorUpdateBlock_Handler, + }, + { + MethodName: "IndexRecentParams", + Handler: _Query_IndexRecentParams_Handler, + }, + { + MethodName: "IndexRecentMsg", + Handler: _Query_IndexRecentMsg_Handler, + }, + { + MethodName: "RecentMsg", + Handler: _Query_RecentMsg_Handler, + }, + { + MethodName: "RecentMsgAll", + Handler: _Query_RecentMsgAll_Handler, + }, + { + MethodName: "RecentParams", + Handler: _Query_RecentParams_Handler, + }, + { + MethodName: "RecentParamsAll", + Handler: _Query_RecentParamsAll_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/oracle/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetPricesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetPricesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TokenId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TokenId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetPricesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetPricesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Prices.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllPricesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPricesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllPricesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPricesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetValidatorUpdateBlockRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetValidatorUpdateBlockRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetValidatorUpdateBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetValidatorUpdateBlockResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetValidatorUpdateBlockResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetValidatorUpdateBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ValidatorUpdateBlock.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetIndexRecentParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetIndexRecentParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetIndexRecentParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetIndexRecentParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetIndexRecentParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetIndexRecentParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.IndexRecentParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetIndexRecentMsgRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetIndexRecentMsgRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetIndexRecentMsgRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetIndexRecentMsgResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetIndexRecentMsgResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetIndexRecentMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.IndexRecentMsg.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetRecentMsgRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRecentMsgRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRecentMsgRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetRecentMsgResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRecentMsgResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRecentMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RecentMsg.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllRecentMsgRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRecentMsgRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRecentMsgRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllRecentMsgResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRecentMsgResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRecentMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.RecentMsg) > 0 { + for iNdEx := len(m.RecentMsg) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecentMsg[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetRecentParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRecentParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRecentParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetRecentParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRecentParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRecentParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RecentParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllRecentParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRecentParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRecentParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllRecentParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRecentParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRecentParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.RecentParams) > 0 { + for iNdEx := len(m.RecentParams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecentParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetPricesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TokenId != 0 { + n += 1 + sovQuery(uint64(m.TokenId)) + } + return n +} + +func (m *QueryGetPricesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Prices.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllPricesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllPricesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetValidatorUpdateBlockRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetValidatorUpdateBlockResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ValidatorUpdateBlock.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetIndexRecentParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetIndexRecentParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.IndexRecentParams.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetIndexRecentMsgRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetIndexRecentMsgResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.IndexRecentMsg.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetRecentMsgRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovQuery(uint64(m.Block)) + } + return n +} + +func (m *QueryGetRecentMsgResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RecentMsg.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllRecentMsgRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllRecentMsgResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecentMsg) > 0 { + for _, e := range m.RecentMsg { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetRecentParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovQuery(uint64(m.Block)) + } + return n +} + +func (m *QueryGetRecentParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RecentParams.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllRecentParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllRecentParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecentParams) > 0 { + for _, e := range m.RecentParams { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetPricesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetPricesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenId", wireType) + } + m.TokenId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TokenId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetPricesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetPricesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Prices.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllPricesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPricesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllPricesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllPricesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, Prices{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetValidatorUpdateBlockRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetValidatorUpdateBlockRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetValidatorUpdateBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetValidatorUpdateBlockResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetValidatorUpdateBlockResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetValidatorUpdateBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorUpdateBlock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ValidatorUpdateBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetIndexRecentParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetIndexRecentParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetIndexRecentParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetIndexRecentParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetIndexRecentParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetIndexRecentParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexRecentParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.IndexRecentParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetIndexRecentMsgRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetIndexRecentMsgRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetIndexRecentMsgRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetIndexRecentMsgResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetIndexRecentMsgResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetIndexRecentMsgResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexRecentMsg", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.IndexRecentMsg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetRecentMsgRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRecentMsgRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRecentMsgRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetRecentMsgResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRecentMsgResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRecentMsgResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentMsg", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RecentMsg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRecentMsgRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRecentMsgRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRecentMsgRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRecentMsgResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRecentMsgResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRecentMsgResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentMsg", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecentMsg = append(m.RecentMsg, RecentMsg{}) + if err := m.RecentMsg[len(m.RecentMsg)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetRecentParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRecentParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRecentParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetRecentParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRecentParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRecentParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RecentParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRecentParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRecentParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRecentParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRecentParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRecentParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRecentParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecentParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecentParams = append(m.RecentParams, RecentParams{}) + if err := m.RecentParams[len(m.RecentParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go new file mode 100644 index 000000000..f54ad8879 --- /dev/null +++ b/x/oracle/types/query.pb.gw.go @@ -0,0 +1,817 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: exocore/oracle/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Prices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPricesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := client.Prices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Prices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPricesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token_id") + } + + protoReq.TokenId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token_id", err) + } + + msg, err := server.Prices(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ValidatorUpdateBlock_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetValidatorUpdateBlockRequest + var metadata runtime.ServerMetadata + + msg, err := client.ValidatorUpdateBlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ValidatorUpdateBlock_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetValidatorUpdateBlockRequest + var metadata runtime.ServerMetadata + + msg, err := server.ValidatorUpdateBlock(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_IndexRecentParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetIndexRecentParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.IndexRecentParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IndexRecentParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetIndexRecentParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.IndexRecentParams(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_IndexRecentMsg_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetIndexRecentMsgRequest + var metadata runtime.ServerMetadata + + msg, err := client.IndexRecentMsg(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IndexRecentMsg_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetIndexRecentMsgRequest + var metadata runtime.ServerMetadata + + msg, err := server.IndexRecentMsg(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RecentMsg_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRecentMsgRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block") + } + + protoReq.Block, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block", err) + } + + msg, err := client.RecentMsg(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecentMsg_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRecentMsgRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block") + } + + protoReq.Block, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block", err) + } + + msg, err := server.RecentMsg(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RecentMsgAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RecentMsgAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRecentMsgRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecentMsgAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RecentMsgAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecentMsgAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRecentMsgRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecentMsgAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RecentMsgAll(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RecentParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRecentParamsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block") + } + + protoReq.Block, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block", err) + } + + msg, err := client.RecentParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecentParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRecentParamsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block") + } + + protoReq.Block, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block", err) + } + + msg, err := server.RecentParams(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RecentParamsAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RecentParamsAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRecentParamsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecentParamsAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RecentParamsAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecentParamsAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRecentParamsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecentParamsAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RecentParamsAll(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Prices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Prices_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Prices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorUpdateBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ValidatorUpdateBlock_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ValidatorUpdateBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IndexRecentParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IndexRecentParams_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IndexRecentParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IndexRecentMsg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IndexRecentMsg_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IndexRecentMsg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentMsg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecentMsg_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentMsg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentMsgAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecentMsgAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentMsgAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecentParams_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentParamsAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecentParamsAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentParamsAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Prices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Prices_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Prices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorUpdateBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ValidatorUpdateBlock_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ValidatorUpdateBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IndexRecentParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IndexRecentParams_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IndexRecentParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IndexRecentMsg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IndexRecentMsg_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IndexRecentMsg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentMsg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecentMsg_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentMsg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentMsgAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecentMsgAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentMsgAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecentParams_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecentParamsAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RecentParamsAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecentParamsAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Prices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ExocoreNetwork", "exocore", "oracle", "prices", "token_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ValidatorUpdateBlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "validator_update_block"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_IndexRecentParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "index_recent_params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_IndexRecentMsg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "index_recent_msg"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RecentMsg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ExocoreNetwork", "exocore", "oracle", "recent_msg", "block"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RecentMsgAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "recent_msg"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RecentParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ExocoreNetwork", "exocore", "oracle", "recent_params", "block"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RecentParamsAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ExocoreNetwork", "exocore", "oracle", "recent_params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Prices_0 = runtime.ForwardResponseMessage + + forward_Query_ValidatorUpdateBlock_0 = runtime.ForwardResponseMessage + + forward_Query_IndexRecentParams_0 = runtime.ForwardResponseMessage + + forward_Query_IndexRecentMsg_0 = runtime.ForwardResponseMessage + + forward_Query_RecentMsg_0 = runtime.ForwardResponseMessage + + forward_Query_RecentMsgAll_0 = runtime.ForwardResponseMessage + + forward_Query_RecentParams_0 = runtime.ForwardResponseMessage + + forward_Query_RecentParamsAll_0 = runtime.ForwardResponseMessage +) diff --git a/x/oracle/types/recent_msg.pb.go b/x/oracle/types/recent_msg.pb.go new file mode 100644 index 000000000..2faa91d4a --- /dev/null +++ b/x/oracle/types/recent_msg.pb.go @@ -0,0 +1,645 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/recent_msg.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RecentMsg represent the messages to be cached for recent blocks +type RecentMsg struct { + // block height these messages from + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` + // cached messages + Msgs []*MsgItem `protobuf:"bytes,2,rep,name=msgs,proto3" json:"msgs,omitempty"` +} + +func (m *RecentMsg) Reset() { *m = RecentMsg{} } +func (m *RecentMsg) String() string { return proto.CompactTextString(m) } +func (*RecentMsg) ProtoMessage() {} +func (*RecentMsg) Descriptor() ([]byte, []int) { + return fileDescriptor_fa7a51ad934a6cc3, []int{0} +} +func (m *RecentMsg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecentMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecentMsg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecentMsg) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecentMsg.Merge(m, src) +} +func (m *RecentMsg) XXX_Size() int { + return m.Size() +} +func (m *RecentMsg) XXX_DiscardUnknown() { + xxx_messageInfo_RecentMsg.DiscardUnknown(m) +} + +var xxx_messageInfo_RecentMsg proto.InternalMessageInfo + +func (m *RecentMsg) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func (m *RecentMsg) GetMsgs() []*MsgItem { + if m != nil { + return m.Msgs + } + return nil +} + +// MsgItem represents the message info of createPrice +type MsgItem struct { + // feeder_id tells of wich feeder this price if corresponding to + FeederID uint64 `protobuf:"varint,2,opt,name=feeder_id,json=feederId,proto3" json:"feeder_id,omitempty"` + // p_source price with its source info + PSources []*PriceSource `protobuf:"bytes,3,rep,name=p_sources,json=pSources,proto3" json:"p_sources,omitempty"` + // validator tells which validator create this price + Validator string `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"` +} + +func (m *MsgItem) Reset() { *m = MsgItem{} } +func (m *MsgItem) String() string { return proto.CompactTextString(m) } +func (*MsgItem) ProtoMessage() {} +func (*MsgItem) Descriptor() ([]byte, []int) { + return fileDescriptor_fa7a51ad934a6cc3, []int{1} +} +func (m *MsgItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgItem.Merge(m, src) +} +func (m *MsgItem) XXX_Size() int { + return m.Size() +} +func (m *MsgItem) XXX_DiscardUnknown() { + xxx_messageInfo_MsgItem.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgItem proto.InternalMessageInfo + +func (m *MsgItem) GetFeederID() uint64 { + if m != nil { + return m.FeederID + } + return 0 +} + +func (m *MsgItem) GetPSources() []*PriceSource { + if m != nil { + return m.PSources + } + return nil +} + +func (m *MsgItem) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func init() { + proto.RegisterType((*RecentMsg)(nil), "exocore.oracle.RecentMsg") + proto.RegisterType((*MsgItem)(nil), "exocore.oracle.MsgItem") +} + +func init() { proto.RegisterFile("exocore/oracle/recent_msg.proto", fileDescriptor_fa7a51ad934a6cc3) } + +var fileDescriptor_fa7a51ad934a6cc3 = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xc1, 0x4e, 0x32, 0x31, + 0x1c, 0xc4, 0x29, 0xf0, 0x7d, 0xb2, 0xd5, 0x78, 0x68, 0x48, 0xdc, 0xa0, 0x29, 0x84, 0x13, 0xc6, + 0x64, 0xd7, 0xe8, 0xc5, 0x33, 0x51, 0x13, 0x4c, 0x20, 0xa6, 0xde, 0xbc, 0x10, 0xe8, 0xfe, 0xad, + 0x1b, 0x58, 0xff, 0x9b, 0xb6, 0x28, 0xbe, 0x83, 0x07, 0x1f, 0xcb, 0x23, 0x47, 0x4f, 0xc6, 0x2c, + 0x2f, 0x62, 0x68, 0x21, 0x46, 0x6e, 0xd3, 0xe9, 0xaf, 0x33, 0xe9, 0xd0, 0x26, 0xcc, 0x51, 0xa2, + 0x86, 0x18, 0xf5, 0x48, 0x4e, 0x21, 0xd6, 0x20, 0xe1, 0xc9, 0x0e, 0x33, 0xa3, 0xa2, 0x5c, 0xa3, + 0x45, 0xb6, 0xbf, 0x06, 0x22, 0x0f, 0x34, 0x1a, 0x5b, 0x0f, 0x72, 0x9d, 0x4a, 0xf0, 0x6c, 0xa3, + 0xae, 0x50, 0xa1, 0x93, 0xf1, 0x4a, 0x79, 0xb7, 0x3d, 0xa0, 0x81, 0x70, 0xa9, 0x7d, 0xa3, 0x58, + 0x9d, 0xfe, 0x1b, 0x4f, 0x51, 0x4e, 0x42, 0xd2, 0x22, 0x9d, 0xaa, 0xf0, 0x07, 0x76, 0x42, 0xab, + 0x99, 0x51, 0x26, 0x2c, 0xb7, 0x2a, 0x9d, 0xdd, 0xb3, 0x83, 0xe8, 0x6f, 0x67, 0xd4, 0x37, 0xaa, + 0x67, 0x21, 0x13, 0x0e, 0x6a, 0xbf, 0x11, 0xba, 0xb3, 0x76, 0xd8, 0x31, 0x0d, 0x1e, 0x00, 0x12, + 0xd0, 0xc3, 0x34, 0x09, 0xcb, 0xab, 0xc8, 0xee, 0x5e, 0xf1, 0xd5, 0xac, 0x5d, 0x3b, 0xb3, 0x77, + 0x29, 0x6a, 0xfe, 0xba, 0x97, 0xb0, 0x0b, 0x1a, 0xe4, 0x43, 0x83, 0x33, 0x2d, 0xc1, 0x84, 0x15, + 0x57, 0x74, 0xb8, 0x5d, 0x74, 0xbb, 0xfa, 0xcc, 0x9d, 0x63, 0x44, 0x2d, 0xf7, 0xc2, 0xb0, 0x23, + 0x1a, 0x3c, 0x8f, 0xa6, 0x69, 0x32, 0xb2, 0xa8, 0xc3, 0x6a, 0x8b, 0x74, 0x02, 0xf1, 0x6b, 0x74, + 0x6f, 0x3e, 0x0a, 0x4e, 0x16, 0x05, 0x27, 0xdf, 0x05, 0x27, 0xef, 0x4b, 0x5e, 0x5a, 0x2c, 0x79, + 0xe9, 0x73, 0xc9, 0x4b, 0xf7, 0xa7, 0x2a, 0xb5, 0x8f, 0xb3, 0x71, 0x24, 0x31, 0x8b, 0xaf, 0x7c, + 0xd1, 0x00, 0xec, 0x0b, 0xea, 0x49, 0xbc, 0x19, 0x71, 0xbe, 0x99, 0xd1, 0xbe, 0xe6, 0x60, 0xc6, + 0xff, 0xdd, 0x62, 0xe7, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7c, 0xac, 0x7f, 0xac, 0x96, 0x01, + 0x00, 0x00, +} + +func (m *RecentMsg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecentMsg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecentMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRecentMsg(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Block != 0 { + i = encodeVarintRecentMsg(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintRecentMsg(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0x22 + } + if len(m.PSources) > 0 { + for iNdEx := len(m.PSources) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PSources[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRecentMsg(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.FeederID != 0 { + i = encodeVarintRecentMsg(dAtA, i, uint64(m.FeederID)) + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + +func encodeVarintRecentMsg(dAtA []byte, offset int, v uint64) int { + offset -= sovRecentMsg(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RecentMsg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovRecentMsg(uint64(m.Block)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovRecentMsg(uint64(l)) + } + } + return n +} + +func (m *MsgItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FeederID != 0 { + n += 1 + sovRecentMsg(uint64(m.FeederID)) + } + if len(m.PSources) > 0 { + for _, e := range m.PSources { + l = e.Size() + n += 1 + l + sovRecentMsg(uint64(l)) + } + } + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovRecentMsg(uint64(l)) + } + return n +} + +func sovRecentMsg(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRecentMsg(x uint64) (n int) { + return sovRecentMsg(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RecentMsg) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RecentMsg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecentMsg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRecentMsg + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRecentMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, &MsgItem{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecentMsg(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecentMsg + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgItem) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FeederID", wireType) + } + m.FeederID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FeederID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PSources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRecentMsg + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRecentMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PSources = append(m.PSources, &PriceSource{}) + if err := m.PSources[len(m.PSources)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRecentMsg + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecentMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecentMsg(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecentMsg + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRecentMsg(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentMsg + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRecentMsg + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRecentMsg + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRecentMsg + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRecentMsg = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRecentMsg = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRecentMsg = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/recent_params.pb.go b/x/oracle/types/recent_params.pb.go new file mode 100644 index 000000000..44eab2986 --- /dev/null +++ b/x/oracle/types/recent_params.pb.go @@ -0,0 +1,365 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/recent_params.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RecentParams represents the params cached for recent blocks +type RecentParams struct { + // block height of which the params from + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` + // params the module params + Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *RecentParams) Reset() { *m = RecentParams{} } +func (m *RecentParams) String() string { return proto.CompactTextString(m) } +func (*RecentParams) ProtoMessage() {} +func (*RecentParams) Descriptor() ([]byte, []int) { + return fileDescriptor_3ba826a0c619fc62, []int{0} +} +func (m *RecentParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecentParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecentParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RecentParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecentParams.Merge(m, src) +} +func (m *RecentParams) XXX_Size() int { + return m.Size() +} +func (m *RecentParams) XXX_DiscardUnknown() { + xxx_messageInfo_RecentParams.DiscardUnknown(m) +} + +var xxx_messageInfo_RecentParams proto.InternalMessageInfo + +func (m *RecentParams) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func (m *RecentParams) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + +func init() { + proto.RegisterType((*RecentParams)(nil), "exocore.oracle.RecentParams") +} + +func init() { + proto.RegisterFile("exocore/oracle/recent_params.proto", fileDescriptor_3ba826a0c619fc62) +} + +var fileDescriptor_3ba826a0c619fc62 = []byte{ + // 192 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x4a, 0x4d, 0x4e, 0xcd, + 0x2b, 0x89, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, + 0x83, 0xaa, 0xd1, 0x83, 0xa8, 0x91, 0x92, 0x46, 0xd3, 0x83, 0xac, 0x58, 0x29, 0x84, 0x8b, 0x27, + 0x08, 0x6c, 0x46, 0x00, 0x58, 0x54, 0x48, 0x84, 0x8b, 0x35, 0x29, 0x27, 0x3f, 0x39, 0x5b, 0x82, + 0x51, 0x81, 0x51, 0x83, 0x25, 0x08, 0xc2, 0x11, 0xd2, 0xe3, 0x62, 0x83, 0xe8, 0x92, 0x60, 0x52, + 0x60, 0xd4, 0xe0, 0x36, 0x12, 0xd3, 0x43, 0xb5, 0x43, 0x0f, 0xa2, 0x3b, 0x08, 0xaa, 0xca, 0xc9, + 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x5d, 0x21, 0x66, 0xf8, 0xa5, 0x96, 0x94, 0xe7, 0x17, + 0x65, 0xeb, 0xc3, 0x9c, 0x59, 0x01, 0x73, 0x68, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, + 0xa1, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xb1, 0x06, 0x17, 0xfb, 0x00, 0x00, 0x00, +} + +func (m *RecentParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecentParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecentParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRecentParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Block != 0 { + i = encodeVarintRecentParams(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintRecentParams(dAtA []byte, offset int, v uint64) int { + offset -= sovRecentParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RecentParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovRecentParams(uint64(m.Block)) + } + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovRecentParams(uint64(l)) + } + return n +} + +func sovRecentParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRecentParams(x uint64) (n int) { + return sovRecentParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RecentParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RecentParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecentParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecentParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRecentParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRecentParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecentParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecentParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRecentParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRecentParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRecentParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRecentParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRecentParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRecentParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRecentParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRecentParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/token_feeder.pb.go b/x/oracle/types/token_feeder.pb.go new file mode 100644 index 000000000..a0097ca97 --- /dev/null +++ b/x/oracle/types/token_feeder.pb.go @@ -0,0 +1,1060 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/token_feeder.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// n out of m required source +type NOMSource struct { + // required source set, refer to params.sourceList, 1st set to 0 means all valid sources + SourceIDs []uint64 `protobuf:"varint,1,rep,packed,name=source_ids,json=sourceIds,proto3" json:"source_ids,omitempty"` + // minimum number from the required sources to be fullfiled + Minimum uint64 `protobuf:"varint,2,opt,name=minimum,proto3" json:"minimum,omitempty"` +} + +func (m *NOMSource) Reset() { *m = NOMSource{} } +func (m *NOMSource) String() string { return proto.CompactTextString(m) } +func (*NOMSource) ProtoMessage() {} +func (*NOMSource) Descriptor() ([]byte, []int) { + return fileDescriptor_1cc86055064704d5, []int{0} +} +func (m *NOMSource) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NOMSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NOMSource.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NOMSource) XXX_Merge(src proto.Message) { + xxx_messageInfo_NOMSource.Merge(m, src) +} +func (m *NOMSource) XXX_Size() int { + return m.Size() +} +func (m *NOMSource) XXX_DiscardUnknown() { + xxx_messageInfo_NOMSource.DiscardUnknown(m) +} + +var xxx_messageInfo_NOMSource proto.InternalMessageInfo + +func (m *NOMSource) GetSourceIDs() []uint64 { + if m != nil { + return m.SourceIDs + } + return nil +} + +func (m *NOMSource) GetMinimum() uint64 { + if m != nil { + return m.Minimum + } + return 0 +} + +// specify data from which source is needed +// rule_1: specified sources +// rule_2: n out of total sources are required +type RuleSource struct { + // refer to params.sourceList.ID, when length>0, ignore the other field, when 1st set to 0, means all valid sources, + // length==0->check next field:minimum + SourceIDs []uint64 `protobuf:"varint,1,rep,packed,name=source_ids,json=sourceIds,proto3" json:"source_ids,omitempty"` + // n out of total sources are required + Nom *NOMSource `protobuf:"bytes,2,opt,name=nom,proto3" json:"nom,omitempty"` +} + +func (m *RuleSource) Reset() { *m = RuleSource{} } +func (m *RuleSource) String() string { return proto.CompactTextString(m) } +func (*RuleSource) ProtoMessage() {} +func (*RuleSource) Descriptor() ([]byte, []int) { + return fileDescriptor_1cc86055064704d5, []int{1} +} +func (m *RuleSource) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RuleSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RuleSource.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RuleSource) XXX_Merge(src proto.Message) { + xxx_messageInfo_RuleSource.Merge(m, src) +} +func (m *RuleSource) XXX_Size() int { + return m.Size() +} +func (m *RuleSource) XXX_DiscardUnknown() { + xxx_messageInfo_RuleSource.DiscardUnknown(m) +} + +var xxx_messageInfo_RuleSource proto.InternalMessageInfo + +func (m *RuleSource) GetSourceIDs() []uint64 { + if m != nil { + return m.SourceIDs + } + return nil +} + +func (m *RuleSource) GetNom() *NOMSource { + if m != nil { + return m.Nom + } + return nil +} + +// Tokenfeeder represents a price oracle for one token +type TokenFeeder struct { + // refer to params.tokenList, from 1 + TokenID uint64 `protobuf:"varint,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` + // refer to params.ruleList, 0 means no restriction, accept any source including customer defined + RuleID uint64 `protobuf:"varint,2,opt,name=rule_id,json=ruleId,proto3" json:"rule_id,omitempty"` + // include, from 1, when some token's feeder had been stop and then restart, + // the token_id will be continuous from previous one + StartRoundID uint64 `protobuf:"varint,3,opt,name=start_round_id,json=startRoundId,proto3" json:"start_round_id,omitempty"` + // include, first block which start_round_id can be settled is at least start_base_block+1 + StartBaseBlock uint64 `protobuf:"varint,4,opt,name=start_base_block,json=startBaseBlock,proto3" json:"start_base_block,omitempty"` + // set as count of blocks, for how many blocks interval the price will be update once + Interval uint64 `protobuf:"varint,5,opt,name=interval,proto3" json:"interval,omitempty"` + // tokenfeeder is initialized with forever live, update the End parameters by voting, + // and will off service by the end + // this is set by updateParams, and the EndRoundID will be update by related. excluded, + // will not work if current height >=EndBlock + EndBlock uint64 `protobuf:"varint,6,opt,name=end_block,json=endBlock,proto3" json:"end_block,omitempty"` +} + +func (m *TokenFeeder) Reset() { *m = TokenFeeder{} } +func (m *TokenFeeder) String() string { return proto.CompactTextString(m) } +func (*TokenFeeder) ProtoMessage() {} +func (*TokenFeeder) Descriptor() ([]byte, []int) { + return fileDescriptor_1cc86055064704d5, []int{2} +} +func (m *TokenFeeder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenFeeder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TokenFeeder.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TokenFeeder) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenFeeder.Merge(m, src) +} +func (m *TokenFeeder) XXX_Size() int { + return m.Size() +} +func (m *TokenFeeder) XXX_DiscardUnknown() { + xxx_messageInfo_TokenFeeder.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenFeeder proto.InternalMessageInfo + +func (m *TokenFeeder) GetTokenID() uint64 { + if m != nil { + return m.TokenID + } + return 0 +} + +func (m *TokenFeeder) GetRuleID() uint64 { + if m != nil { + return m.RuleID + } + return 0 +} + +func (m *TokenFeeder) GetStartRoundID() uint64 { + if m != nil { + return m.StartRoundID + } + return 0 +} + +func (m *TokenFeeder) GetStartBaseBlock() uint64 { + if m != nil { + return m.StartBaseBlock + } + return 0 +} + +func (m *TokenFeeder) GetInterval() uint64 { + if m != nil { + return m.Interval + } + return 0 +} + +func (m *TokenFeeder) GetEndBlock() uint64 { + if m != nil { + return m.EndBlock + } + return 0 +} + +func init() { + proto.RegisterType((*NOMSource)(nil), "exocore.oracle.NOMSource") + proto.RegisterType((*RuleSource)(nil), "exocore.oracle.RuleSource") + proto.RegisterType((*TokenFeeder)(nil), "exocore.oracle.TokenFeeder") +} + +func init() { proto.RegisterFile("exocore/oracle/token_feeder.proto", fileDescriptor_1cc86055064704d5) } + +var fileDescriptor_1cc86055064704d5 = []byte{ + // 396 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xc1, 0x8a, 0xd4, 0x40, + 0x10, 0x86, 0x27, 0xce, 0x98, 0x6c, 0x6a, 0xd6, 0x65, 0x69, 0x3c, 0xc4, 0x15, 0x92, 0x75, 0x04, + 0x19, 0x50, 0x12, 0x51, 0xf0, 0x01, 0x42, 0x14, 0x22, 0xb8, 0x42, 0x8f, 0x27, 0x2f, 0x21, 0x49, + 0x97, 0x31, 0x4c, 0x92, 0x5e, 0xba, 0x13, 0x5d, 0xdf, 0xc2, 0xc7, 0xf2, 0xb8, 0x47, 0x4f, 0x41, + 0x32, 0xcf, 0xe0, 0x5d, 0xba, 0x7b, 0x66, 0xc4, 0xab, 0xb7, 0xae, 0xfe, 0xbf, 0x2a, 0xfe, 0x2a, + 0x7e, 0x78, 0x84, 0x37, 0xbc, 0xe4, 0x02, 0x23, 0x2e, 0xf2, 0xb2, 0xc1, 0xa8, 0xe7, 0x5b, 0xec, + 0xb2, 0x4f, 0x88, 0x0c, 0x45, 0x78, 0x2d, 0x78, 0xcf, 0xc9, 0xd9, 0x1e, 0x09, 0x0d, 0x72, 0x71, + 0xbf, 0xe2, 0x15, 0xd7, 0x52, 0xa4, 0x5e, 0x86, 0x5a, 0x6d, 0xc0, 0xbd, 0x7a, 0xff, 0x6e, 0xc3, + 0x07, 0x51, 0x22, 0x79, 0x06, 0x20, 0xf5, 0x2b, 0xab, 0x99, 0xf4, 0xac, 0xcb, 0xf9, 0x7a, 0x11, + 0xdf, 0x9b, 0xc6, 0xc0, 0x35, 0x7a, 0x9a, 0x48, 0xea, 0x1a, 0x20, 0x65, 0x92, 0x78, 0xe0, 0xb4, + 0x75, 0x57, 0xb7, 0x43, 0xeb, 0xdd, 0xb9, 0xb4, 0xd6, 0x0b, 0x7a, 0x28, 0x57, 0x15, 0x00, 0x1d, + 0x1a, 0xfc, 0xaf, 0xa9, 0x4f, 0x61, 0xde, 0x71, 0x33, 0x71, 0xf9, 0xe2, 0x41, 0xf8, 0xef, 0x12, + 0xe1, 0xd1, 0x2b, 0x55, 0xd4, 0xea, 0xb7, 0x05, 0xcb, 0x0f, 0x6a, 0xf5, 0x37, 0x7a, 0x73, 0xf2, + 0x04, 0x4e, 0xcc, 0x25, 0x6a, 0xe6, 0x59, 0xca, 0x53, 0xbc, 0x9c, 0xc6, 0xc0, 0xd1, 0x48, 0x9a, + 0x50, 0x47, 0x8b, 0x29, 0x23, 0x8f, 0xc1, 0x11, 0x43, 0xa3, 0x0c, 0x19, 0xeb, 0x31, 0x4c, 0x63, + 0x60, 0x2b, 0xcf, 0x69, 0x42, 0x6d, 0x25, 0xa5, 0x8c, 0xbc, 0x82, 0x33, 0xd9, 0xe7, 0xa2, 0xcf, + 0x04, 0x1f, 0x3a, 0xa6, 0xd8, 0xb9, 0x66, 0xcf, 0xa7, 0x31, 0x38, 0xdd, 0x28, 0x85, 0x2a, 0x21, + 0x4d, 0xe8, 0xa9, 0xfc, 0x5b, 0x31, 0xb2, 0x86, 0x73, 0xd3, 0x57, 0xe4, 0x12, 0xb3, 0xa2, 0xe1, + 0xe5, 0xd6, 0x5b, 0xe8, 0x03, 0x99, 0x79, 0x71, 0x2e, 0x31, 0x56, 0xbf, 0xe4, 0x02, 0x4e, 0xea, + 0xae, 0x47, 0xf1, 0x25, 0x6f, 0xbc, 0xbb, 0x9a, 0x38, 0xd6, 0xe4, 0x21, 0xb8, 0xd8, 0xb1, 0x7d, + 0xbb, 0x6d, 0x44, 0xec, 0x98, 0x6e, 0x8c, 0xdf, 0xfe, 0x98, 0x7c, 0xeb, 0x76, 0xf2, 0xad, 0x5f, + 0x93, 0x6f, 0x7d, 0xdf, 0xf9, 0xb3, 0xdb, 0x9d, 0x3f, 0xfb, 0xb9, 0xf3, 0x67, 0x1f, 0x9f, 0x57, + 0x75, 0xff, 0x79, 0x28, 0xc2, 0x92, 0xb7, 0xd1, 0x6b, 0x73, 0xbb, 0x2b, 0xec, 0xbf, 0x72, 0xb1, + 0x8d, 0x0e, 0x91, 0xb9, 0x39, 0x86, 0xe6, 0xdb, 0x35, 0xca, 0xc2, 0xd6, 0x41, 0x78, 0xf9, 0x27, + 0x00, 0x00, 0xff, 0xff, 0x3d, 0x32, 0x42, 0x06, 0x53, 0x02, 0x00, 0x00, +} + +func (m *NOMSource) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NOMSource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NOMSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Minimum != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.Minimum)) + i-- + dAtA[i] = 0x10 + } + if len(m.SourceIDs) > 0 { + dAtA2 := make([]byte, len(m.SourceIDs)*10) + var j1 int + for _, num := range m.SourceIDs { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintTokenFeeder(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RuleSource) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RuleSource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RuleSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nom != nil { + { + size, err := m.Nom.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTokenFeeder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SourceIDs) > 0 { + dAtA5 := make([]byte, len(m.SourceIDs)*10) + var j4 int + for _, num := range m.SourceIDs { + for num >= 1<<7 { + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j4++ + } + dAtA5[j4] = uint8(num) + j4++ + } + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintTokenFeeder(dAtA, i, uint64(j4)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TokenFeeder) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TokenFeeder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenFeeder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EndBlock != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.EndBlock)) + i-- + dAtA[i] = 0x30 + } + if m.Interval != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.Interval)) + i-- + dAtA[i] = 0x28 + } + if m.StartBaseBlock != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.StartBaseBlock)) + i-- + dAtA[i] = 0x20 + } + if m.StartRoundID != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.StartRoundID)) + i-- + dAtA[i] = 0x18 + } + if m.RuleID != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.RuleID)) + i-- + dAtA[i] = 0x10 + } + if m.TokenID != 0 { + i = encodeVarintTokenFeeder(dAtA, i, uint64(m.TokenID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTokenFeeder(dAtA []byte, offset int, v uint64) int { + offset -= sovTokenFeeder(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *NOMSource) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SourceIDs) > 0 { + l = 0 + for _, e := range m.SourceIDs { + l += sovTokenFeeder(uint64(e)) + } + n += 1 + sovTokenFeeder(uint64(l)) + l + } + if m.Minimum != 0 { + n += 1 + sovTokenFeeder(uint64(m.Minimum)) + } + return n +} + +func (m *RuleSource) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SourceIDs) > 0 { + l = 0 + for _, e := range m.SourceIDs { + l += sovTokenFeeder(uint64(e)) + } + n += 1 + sovTokenFeeder(uint64(l)) + l + } + if m.Nom != nil { + l = m.Nom.Size() + n += 1 + l + sovTokenFeeder(uint64(l)) + } + return n +} + +func (m *TokenFeeder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TokenID != 0 { + n += 1 + sovTokenFeeder(uint64(m.TokenID)) + } + if m.RuleID != 0 { + n += 1 + sovTokenFeeder(uint64(m.RuleID)) + } + if m.StartRoundID != 0 { + n += 1 + sovTokenFeeder(uint64(m.StartRoundID)) + } + if m.StartBaseBlock != 0 { + n += 1 + sovTokenFeeder(uint64(m.StartBaseBlock)) + } + if m.Interval != 0 { + n += 1 + sovTokenFeeder(uint64(m.Interval)) + } + if m.EndBlock != 0 { + n += 1 + sovTokenFeeder(uint64(m.EndBlock)) + } + return n +} + +func sovTokenFeeder(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTokenFeeder(x uint64) (n int) { + return sovTokenFeeder(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *NOMSource) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NOMSource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NOMSource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SourceIDs = append(m.SourceIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTokenFeeder + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTokenFeeder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.SourceIDs) == 0 { + m.SourceIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SourceIDs = append(m.SourceIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field SourceIDs", wireType) + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Minimum", wireType) + } + m.Minimum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Minimum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTokenFeeder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTokenFeeder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RuleSource) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RuleSource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RuleSource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SourceIDs = append(m.SourceIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTokenFeeder + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTokenFeeder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.SourceIDs) == 0 { + m.SourceIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SourceIDs = append(m.SourceIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field SourceIDs", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nom", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTokenFeeder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTokenFeeder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Nom == nil { + m.Nom = &NOMSource{} + } + if err := m.Nom.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTokenFeeder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTokenFeeder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TokenFeeder) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TokenFeeder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenFeeder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenID", wireType) + } + m.TokenID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TokenID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RuleID", wireType) + } + m.RuleID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RuleID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartRoundID", wireType) + } + m.StartRoundID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartRoundID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartBaseBlock", wireType) + } + m.StartBaseBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartBaseBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Interval", wireType) + } + m.Interval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Interval |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EndBlock", wireType) + } + m.EndBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EndBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTokenFeeder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTokenFeeder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTokenFeeder(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTokenFeeder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTokenFeeder + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTokenFeeder + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTokenFeeder + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTokenFeeder = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTokenFeeder = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTokenFeeder = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go new file mode 100644 index 000000000..9c0ad829b --- /dev/null +++ b/x/oracle/types/tx.pb.go @@ -0,0 +1,1107 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgCreatePrice provide the price updating message +type MsgCreatePrice struct { + // creator tells which is the message sender and should sign this message + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + //refer to id from Params.TokenFeeders, 0 is reserved, invalid to use + FeederID uint64 `protobuf:"varint,2,opt,name=feeder_id,json=feederId,proto3" json:"feeder_id,omitempty"` + // prices price with its corresponding source + Prices []*PriceSource `protobuf:"bytes,3,rep,name=prices,proto3" json:"prices,omitempty"` + //on which block commit does this message be built on + BasedBlock uint64 `protobuf:"varint,4,opt,name=based_block,json=basedBlock,proto3" json:"based_block,omitempty"` + // nonce represents the unique number to disginguish duplicated messages + Nonce int32 `protobuf:"varint,5,opt,name=nonce,proto3" json:"nonce,omitempty"` +} + +func (m *MsgCreatePrice) Reset() { *m = MsgCreatePrice{} } +func (m *MsgCreatePrice) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePrice) ProtoMessage() {} +func (*MsgCreatePrice) Descriptor() ([]byte, []int) { + return fileDescriptor_02cf64aff79d2288, []int{0} +} +func (m *MsgCreatePrice) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePrice.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreatePrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePrice.Merge(m, src) +} +func (m *MsgCreatePrice) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePrice) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePrice.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePrice proto.InternalMessageInfo + +func (m *MsgCreatePrice) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreatePrice) GetFeederID() uint64 { + if m != nil { + return m.FeederID + } + return 0 +} + +func (m *MsgCreatePrice) GetPrices() []*PriceSource { + if m != nil { + return m.Prices + } + return nil +} + +func (m *MsgCreatePrice) GetBasedBlock() uint64 { + if m != nil { + return m.BasedBlock + } + return 0 +} + +func (m *MsgCreatePrice) GetNonce() int32 { + if m != nil { + return m.Nonce + } + return 0 +} + +// MsgCreatePriceResponse +type MsgCreatePriceResponse struct { +} + +func (m *MsgCreatePriceResponse) Reset() { *m = MsgCreatePriceResponse{} } +func (m *MsgCreatePriceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePriceResponse) ProtoMessage() {} +func (*MsgCreatePriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_02cf64aff79d2288, []int{1} +} +func (m *MsgCreatePriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePriceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreatePriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePriceResponse.Merge(m, src) +} +func (m *MsgCreatePriceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePriceResponse proto.InternalMessageInfo + +// MsgUpdateParms +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/staking parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_02cf64aff79d2288, []int{2} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_02cf64aff79d2288, []int{3} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreatePrice)(nil), "exocore.oracle.MsgCreatePrice") + proto.RegisterType((*MsgCreatePriceResponse)(nil), "exocore.oracle.MsgCreatePriceResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "exocore.oracle.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "exocore.oracle.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("exocore/oracle/tx.proto", fileDescriptor_02cf64aff79d2288) } + +var fileDescriptor_02cf64aff79d2288 = []byte{ + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xb3, 0xa4, 0x09, 0xcd, 0xa6, 0x2a, 0x62, 0x15, 0x35, 0xae, 0x2b, 0x9c, 0x10, 0x24, + 0x08, 0x91, 0x62, 0x43, 0x2a, 0x55, 0x02, 0x4e, 0x98, 0x3f, 0x52, 0x91, 0x82, 0x90, 0xab, 0x22, + 0xc4, 0x25, 0x72, 0xec, 0xc5, 0xb5, 0x12, 0x7b, 0xad, 0x5d, 0x07, 0xd2, 0x2b, 0x47, 0x4e, 0x3c, + 0x06, 0xc7, 0x1c, 0x2a, 0x4e, 0x3c, 0x40, 0x8f, 0x55, 0x4f, 0x9c, 0x2a, 0x94, 0x20, 0xe5, 0x35, + 0x90, 0x77, 0xd7, 0x34, 0x36, 0x08, 0x2e, 0x89, 0x67, 0x7e, 0xdf, 0xce, 0xce, 0x7c, 0xb3, 0xb0, + 0x8e, 0xa7, 0xc4, 0x21, 0x14, 0x1b, 0x84, 0xda, 0xce, 0x18, 0x1b, 0xf1, 0x54, 0x8f, 0x28, 0x89, + 0x09, 0xda, 0x94, 0x40, 0x17, 0x40, 0xbd, 0x6e, 0x07, 0x7e, 0x48, 0x0c, 0xfe, 0x2b, 0x24, 0x6a, + 0xdd, 0x21, 0x2c, 0x20, 0xcc, 0x08, 0x98, 0x67, 0xbc, 0xbf, 0x9f, 0xfc, 0x49, 0xb0, 0x2d, 0xc0, + 0x80, 0x47, 0x86, 0x08, 0x24, 0xda, 0xc9, 0xdd, 0x17, 0xd9, 0xd4, 0x0e, 0x52, 0xa8, 0xe6, 0x21, + 0xf5, 0x1d, 0x2c, 0x59, 0xcd, 0x23, 0x1e, 0x11, 0x05, 0x93, 0x2f, 0x91, 0x6d, 0xfd, 0x04, 0x70, + 0xb3, 0xcf, 0xbc, 0x27, 0x14, 0xdb, 0x31, 0x7e, 0x95, 0xc8, 0xd1, 0x23, 0x78, 0xd5, 0x49, 0x42, + 0x42, 0x15, 0xd0, 0x04, 0xed, 0x8a, 0x79, 0xf3, 0xfc, 0xa4, 0x7b, 0x43, 0x36, 0xf1, 0xda, 0x1e, + 0xfb, 0x6e, 0xc2, 0x1e, 0xbb, 0x2e, 0xc5, 0x8c, 0x1d, 0xc4, 0xd4, 0x0f, 0x3d, 0x2b, 0x3d, 0x81, + 0xee, 0xc2, 0xca, 0x3b, 0x8c, 0x5d, 0x4c, 0x07, 0xbe, 0xab, 0x5c, 0x69, 0x82, 0xf6, 0x9a, 0xb9, + 0x31, 0xbf, 0x68, 0xac, 0x3f, 0xe7, 0xc9, 0xfd, 0xa7, 0xd6, 0xba, 0xc0, 0xfb, 0x2e, 0xda, 0x85, + 0x65, 0xde, 0x1f, 0x53, 0x8a, 0xcd, 0x62, 0xbb, 0xda, 0xdb, 0xd1, 0xb3, 0x8e, 0xe9, 0xbc, 0x9d, + 0x03, 0x32, 0xa1, 0x0e, 0xb6, 0xa4, 0x14, 0x35, 0x60, 0x75, 0x68, 0x33, 0xec, 0x0e, 0x86, 0x63, + 0xe2, 0x8c, 0x94, 0xb5, 0xe4, 0x06, 0x0b, 0xf2, 0x94, 0x99, 0x64, 0x50, 0x0d, 0x96, 0x42, 0x12, + 0x3a, 0x58, 0x29, 0x35, 0x41, 0xbb, 0x64, 0x89, 0xa0, 0xa5, 0xc0, 0xad, 0xec, 0x94, 0x16, 0x66, + 0x11, 0x09, 0x19, 0x6e, 0x7d, 0x03, 0xf0, 0x5a, 0x9f, 0x79, 0x87, 0x91, 0x9b, 0x20, 0x6e, 0x26, + 0xda, 0x83, 0x15, 0x7b, 0x12, 0x1f, 0x11, 0xea, 0xc7, 0xc7, 0xd2, 0x03, 0xe5, 0xfc, 0xa4, 0x5b, + 0x93, 0x1e, 0x64, 0x47, 0xbf, 0x94, 0xa2, 0x07, 0xb0, 0x2c, 0xd6, 0xc1, 0x27, 0xaf, 0xf6, 0xb6, + 0xfe, 0x98, 0x88, 0x53, 0xb3, 0x72, 0x7a, 0xd1, 0x28, 0x7c, 0x59, 0xce, 0x3a, 0xc0, 0x92, 0x07, + 0x1e, 0xee, 0x7d, 0x5c, 0xce, 0x3a, 0x97, 0xa5, 0x3e, 0x2d, 0x67, 0x9d, 0x5b, 0xe2, 0xba, 0x2e, + 0x73, 0x47, 0xc6, 0x34, 0xdd, 0x68, 0xae, 0xd5, 0xd6, 0x36, 0xac, 0xe7, 0x52, 0xe9, 0x64, 0xbd, + 0xaf, 0x00, 0x16, 0xfb, 0xcc, 0x43, 0x87, 0xb0, 0xba, 0xba, 0x5e, 0x2d, 0xdf, 0x54, 0xd6, 0x18, + 0xf5, 0xf6, 0xbf, 0x79, 0x5a, 0x1e, 0xbd, 0x81, 0x1b, 0x19, 0xd3, 0x1a, 0x7f, 0x39, 0xb7, 0x2a, + 0x50, 0xef, 0xfc, 0x47, 0x90, 0x56, 0x36, 0x5f, 0x9c, 0xce, 0x35, 0x70, 0x36, 0xd7, 0xc0, 0x8f, + 0xb9, 0x06, 0x3e, 0x2f, 0xb4, 0xc2, 0xd9, 0x42, 0x2b, 0x7c, 0x5f, 0x68, 0x85, 0xb7, 0xf7, 0x3c, + 0x3f, 0x3e, 0x9a, 0x0c, 0x75, 0x87, 0x04, 0xc6, 0x33, 0x51, 0xec, 0x25, 0x8e, 0x3f, 0x10, 0x3a, + 0x32, 0xd2, 0x97, 0xff, 0xdb, 0xa9, 0xf8, 0x38, 0xc2, 0x6c, 0x58, 0xe6, 0xcf, 0x7c, 0xf7, 0x57, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0xb9, 0x33, 0x0c, 0xa7, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreatePrice creates price for a new oracle round + CreatePrice(ctx context.Context, in *MsgCreatePrice, opts ...grpc.CallOption) (*MsgCreatePriceResponse, error) + // UpdateParams update params value + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreatePrice(ctx context.Context, in *MsgCreatePrice, opts ...grpc.CallOption) (*MsgCreatePriceResponse, error) { + out := new(MsgCreatePriceResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Msg/CreatePrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/exocore.oracle.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreatePrice creates price for a new oracle round + CreatePrice(context.Context, *MsgCreatePrice) (*MsgCreatePriceResponse, error) + // UpdateParams update params value + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreatePrice(ctx context.Context, req *MsgCreatePrice) (*MsgCreatePriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePrice not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreatePrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePrice) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Msg/CreatePrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePrice(ctx, req.(*MsgCreatePrice)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/exocore.oracle.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "exocore.oracle.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreatePrice", + Handler: _Msg_CreatePrice_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "exocore/oracle/tx.proto", +} + +func (m *MsgCreatePrice) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreatePrice) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nonce != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x28 + } + if m.BasedBlock != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BasedBlock)) + i-- + dAtA[i] = 0x20 + } + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.FeederID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.FeederID)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreatePriceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreatePriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreatePrice) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FeederID != 0 { + n += 1 + sovTx(uint64(m.FeederID)) + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + if m.BasedBlock != 0 { + n += 1 + sovTx(uint64(m.BasedBlock)) + } + if m.Nonce != 0 { + n += 1 + sovTx(uint64(m.Nonce)) + } + return n +} + +func (m *MsgCreatePriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreatePrice) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePrice: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePrice: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FeederID", wireType) + } + m.FeederID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FeederID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, &PriceSource{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BasedBlock", wireType) + } + m.BasedBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BasedBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePriceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/types.go b/x/oracle/types/types.go new file mode 100644 index 000000000..a99349471 --- /dev/null +++ b/x/oracle/types/types.go @@ -0,0 +1,9 @@ +package types + +import "encoding/binary" + +func Uint64Bytes(value uint64) []byte { + valueBytes := make([]byte, 8) + binary.BigEndian.PutUint64(valueBytes, value) + return valueBytes +} diff --git a/x/oracle/types/validator_update_block.pb.go b/x/oracle/types/validator_update_block.pb.go new file mode 100644 index 000000000..9d0fdc57e --- /dev/null +++ b/x/oracle/types/validator_update_block.pb.go @@ -0,0 +1,303 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/validator_update_block.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ValidatorUpdateBlock +type ValidatorUpdateBlock struct { + // block height on which the validator set changed + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *ValidatorUpdateBlock) Reset() { *m = ValidatorUpdateBlock{} } +func (m *ValidatorUpdateBlock) String() string { return proto.CompactTextString(m) } +func (*ValidatorUpdateBlock) ProtoMessage() {} +func (*ValidatorUpdateBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_2ea66d5cc483dd28, []int{0} +} +func (m *ValidatorUpdateBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorUpdateBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorUpdateBlock.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ValidatorUpdateBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorUpdateBlock.Merge(m, src) +} +func (m *ValidatorUpdateBlock) XXX_Size() int { + return m.Size() +} +func (m *ValidatorUpdateBlock) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorUpdateBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorUpdateBlock proto.InternalMessageInfo + +func (m *ValidatorUpdateBlock) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func init() { + proto.RegisterType((*ValidatorUpdateBlock)(nil), "exocore.oracle.ValidatorUpdateBlock") +} + +func init() { + proto.RegisterFile("exocore/oracle/validator_update_block.proto", fileDescriptor_2ea66d5cc483dd28) +} + +var fileDescriptor_2ea66d5cc483dd28 = []byte{ + // 171 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x4b, 0xcc, 0xc9, 0x4c, + 0x49, 0x2c, 0xc9, 0x2f, 0x8a, 0x2f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x8d, 0x4f, 0xca, 0xc9, 0x4f, + 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x2a, 0xd6, 0x83, 0x28, 0x56, 0xd2, + 0xe1, 0x12, 0x09, 0x83, 0xa9, 0x0f, 0x05, 0x2b, 0x77, 0x02, 0xa9, 0x16, 0x12, 0xe1, 0x62, 0x05, + 0x6b, 0x93, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x82, 0x70, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, 0x63, + 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, + 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, + 0x3f, 0x57, 0xdf, 0x15, 0x62, 0x85, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xcc, 0x79, + 0x15, 0x30, 0x07, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x1d, 0x64, 0x0c, 0x08, 0x00, + 0x00, 0xff, 0xff, 0x27, 0x1f, 0x25, 0xe5, 0xbf, 0x00, 0x00, 0x00, +} + +func (m *ValidatorUpdateBlock) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValidatorUpdateBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorUpdateBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != 0 { + i = encodeVarintValidatorUpdateBlock(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintValidatorUpdateBlock(dAtA []byte, offset int, v uint64) int { + offset -= sovValidatorUpdateBlock(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ValidatorUpdateBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovValidatorUpdateBlock(uint64(m.Block)) + } + return n +} + +func sovValidatorUpdateBlock(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozValidatorUpdateBlock(x uint64) (n int) { + return sovValidatorUpdateBlock(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ValidatorUpdateBlock) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidatorUpdateBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValidatorUpdateBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorUpdateBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidatorUpdateBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipValidatorUpdateBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthValidatorUpdateBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipValidatorUpdateBlock(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidatorUpdateBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidatorUpdateBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidatorUpdateBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthValidatorUpdateBlock + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupValidatorUpdateBlock + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthValidatorUpdateBlock + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthValidatorUpdateBlock = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowValidatorUpdateBlock = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupValidatorUpdateBlock = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/validators.pb.go b/x/oracle/types/validators.pb.go new file mode 100644 index 000000000..8e8117825 --- /dev/null +++ b/x/oracle/types/validators.pb.go @@ -0,0 +1,586 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: exocore/oracle/validators.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Validators struct { + Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"` + ValidatorList []*Validator `protobuf:"bytes,2,rep,name=validator_list,json=validatorList,proto3" json:"validator_list,omitempty"` +} + +func (m *Validators) Reset() { *m = Validators{} } +func (m *Validators) String() string { return proto.CompactTextString(m) } +func (*Validators) ProtoMessage() {} +func (*Validators) Descriptor() ([]byte, []int) { + return fileDescriptor_4264e9827808bf71, []int{0} +} +func (m *Validators) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Validators) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Validators.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Validators) XXX_Merge(src proto.Message) { + xxx_messageInfo_Validators.Merge(m, src) +} +func (m *Validators) XXX_Size() int { + return m.Size() +} +func (m *Validators) XXX_DiscardUnknown() { + xxx_messageInfo_Validators.DiscardUnknown(m) +} + +var xxx_messageInfo_Validators proto.InternalMessageInfo + +func (m *Validators) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func (m *Validators) GetValidatorList() []*Validator { + if m != nil { + return m.ValidatorList + } + return nil +} + +type Validator struct { + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` + Power string `protobuf:"bytes,2,opt,name=power,proto3" json:"power,omitempty"` +} + +func (m *Validator) Reset() { *m = Validator{} } +func (m *Validator) String() string { return proto.CompactTextString(m) } +func (*Validator) ProtoMessage() {} +func (*Validator) Descriptor() ([]byte, []int) { + return fileDescriptor_4264e9827808bf71, []int{1} +} +func (m *Validator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Validator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Validator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Validator) XXX_Merge(src proto.Message) { + xxx_messageInfo_Validator.Merge(m, src) +} +func (m *Validator) XXX_Size() int { + return m.Size() +} +func (m *Validator) XXX_DiscardUnknown() { + xxx_messageInfo_Validator.DiscardUnknown(m) +} + +var xxx_messageInfo_Validator proto.InternalMessageInfo + +func (m *Validator) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *Validator) GetPower() string { + if m != nil { + return m.Power + } + return "" +} + +func init() { + proto.RegisterType((*Validators)(nil), "exocore.oracle.Validators") + proto.RegisterType((*Validator)(nil), "exocore.oracle.Validator") +} + +func init() { proto.RegisterFile("exocore/oracle/validators.proto", fileDescriptor_4264e9827808bf71) } + +var fileDescriptor_4264e9827808bf71 = []byte{ + // 225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0xc8, 0x4f, + 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x4b, 0xcc, 0xc9, 0x4c, + 0x49, 0x2c, 0xc9, 0x2f, 0x2a, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0x2a, 0xd0, + 0x83, 0x28, 0x50, 0x4a, 0xe1, 0xe2, 0x0a, 0x83, 0xab, 0x11, 0x12, 0xe1, 0x62, 0x4d, 0xca, 0xc9, + 0x4f, 0xce, 0x96, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x82, 0x70, 0x84, 0x1c, 0xb8, 0xf8, 0xe0, + 0xe6, 0xc4, 0xe7, 0x64, 0x16, 0x97, 0x48, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x49, 0xea, 0xa1, + 0x1a, 0xa6, 0x07, 0x37, 0x29, 0x88, 0x17, 0xae, 0xc1, 0x27, 0xb3, 0xb8, 0x44, 0xc9, 0x96, 0x8b, + 0x13, 0x2e, 0x27, 0x24, 0xc5, 0xc5, 0x91, 0x5f, 0x90, 0x5a, 0x04, 0x62, 0x83, 0xed, 0xe1, 0x0c, + 0x82, 0xf3, 0x41, 0x0e, 0x28, 0xc8, 0x2f, 0x4f, 0x2d, 0x92, 0x60, 0x02, 0x4b, 0x40, 0x38, 0x4e, + 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, + 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x90, 0x9e, 0x59, 0x92, + 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x0a, 0x71, 0x8c, 0x5f, 0x6a, 0x49, 0x79, 0x7e, + 0x51, 0xb6, 0x3e, 0x2c, 0x24, 0x2a, 0x60, 0x61, 0x51, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x0e, 0x07, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x17, 0x61, 0x71, 0xf1, 0x2a, 0x01, 0x00, + 0x00, +} + +func (m *Validators) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Validators) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Validators) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorList) > 0 { + for iNdEx := len(m.ValidatorList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintValidators(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Block != 0 { + i = encodeVarintValidators(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Validator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Validator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Power) > 0 { + i -= len(m.Power) + copy(dAtA[i:], m.Power) + i = encodeVarintValidators(dAtA, i, uint64(len(m.Power))) + i-- + dAtA[i] = 0x12 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintValidators(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintValidators(dAtA []byte, offset int, v uint64) int { + offset -= sovValidators(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Validators) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != 0 { + n += 1 + sovValidators(uint64(m.Block)) + } + if len(m.ValidatorList) > 0 { + for _, e := range m.ValidatorList { + l = e.Size() + n += 1 + l + sovValidators(uint64(l)) + } + } + return n +} + +func (m *Validator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovValidators(uint64(l)) + } + l = len(m.Power) + if l > 0 { + n += 1 + l + sovValidators(uint64(l)) + } + return n +} + +func sovValidators(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozValidators(x uint64) (n int) { + return sovValidators(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Validators) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Validators: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Validators: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthValidators + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthValidators + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorList = append(m.ValidatorList, &Validator{}) + if err := m.ValidatorList[len(m.ValidatorList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipValidators(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthValidators + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Validator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Validator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Validator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthValidators + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthValidators + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Power", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidators + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthValidators + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthValidators + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Power = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipValidators(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthValidators + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipValidators(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidators + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidators + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowValidators + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthValidators + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupValidators + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthValidators + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthValidators = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowValidators = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupValidators = fmt.Errorf("proto: unexpected end of group") +)