Skip to content

Commit

Permalink
[R4R] feat(oracle) (#30)
Browse files Browse the repository at this point in the history
* feat(oracle-proto): add proto files for oracle module and some ignite scalffold dependencies

* feat(oracle-proto): add oracle types, mainly proto generated files

* feat(oracle-keeper): implement keeper for state access, msgserver for price update

* test(oracle-keeper): add test

* feat(oracle-keeper): add cache as memory storage for prices collection across blocks

* feat(oracle-keeper): add aggregator used to implement the mainly function to calculate fianl price from sources provided by validators

* feat(oracle): integrate oracle module into app

* fix(oracle-message): udpate CreatePrice signer with validatorAddress and responding GetSigners

* test(oracle): add test cases, events, logs

* fix(oracle): fix workflow check, linters, typo

* refactor(oracle): use internal interface for external keeper reference

* fix(oracle): fix test network params compatible with ignite

* test(oracle): remove client test and simulation temporary

* test(oracle-keeper): reset caches between testsuite

* test(oracle): change monkey to gomonkey for arch compatible, add test flag for monkey

* refactor(oracle): update the file name of aggregator, and fix typo

* feat(oracle): set tokenFeeder in default params to a future block
  • Loading branch information
leonz789 authored Apr 25, 2024
1 parent dd7b872 commit 9f1b6a8
Show file tree
Hide file tree
Showing 124 changed files with 21,166 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 18 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -279,6 +283,7 @@ var (
exoslash.AppModuleBasic{},
avs.AppModuleBasic{},
avstask.AppModuleBasic{},
oracle.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -977,6 +984,8 @@ func NewExocoreApp(
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
exoslashTypes.ModuleName,
// no particular order required
oracleTypes.ModuleName,
// Evmos modules
erc20types.ModuleName,
epochstypes.ModuleName,
Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
35 changes: 35 additions & 0 deletions proto/exocore/oracle/genesis.proto
Original file line number Diff line number Diff line change
@@ -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];
}

10 changes: 10 additions & 0 deletions proto/exocore/oracle/index_recent_msg.proto
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 10 additions & 0 deletions proto/exocore/oracle/index_recent_params.proto
Original file line number Diff line number Diff line change
@@ -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;
}
50 changes: 50 additions & 0 deletions proto/exocore/oracle/info.proto
Original file line number Diff line number Diff line change
@@ -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<uint64,string> 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<uint64,string> 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;
}
23 changes: 23 additions & 0 deletions proto/exocore/oracle/params.proto
Original file line number Diff line number Diff line change
@@ -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;
}
Loading

0 comments on commit 9f1b6a8

Please sign in to comment.