-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R4R] feat(oracle) #30
Changes from 43 commits
24fefab
d78044c
afb4965
d6d244f
9809ec5
c098faa
39da9c9
2773654
0ae869a
c630033
b7966ce
f49d1c5
bf65e5e
4d2d032
1b3401f
9b3383a
6b06afe
b807cd8
6ac82f4
dbd4d60
ef07cc5
7ea268f
511b012
c1b307a
c1dac1e
60a81f6
f7cf7df
d7f19db
6d53266
e91d320
473175b
5d7b769
397d051
21e2c5a
c288a0a
cb6e88c
ecfda24
dfb42a4
2ef42cd
a723d1a
dc84085
5567367
e6c3c85
06f5fd4
7c3dff1
7588a48
8cc8f75
ecf9145
d892e60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,10 @@ import ( | |
|
||
operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/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/reward" | ||
rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" | ||
rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" | ||
|
@@ -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,12 @@ 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 +670,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be added to |
||
// We call this after setting the hooks to ensure that the hooks are set on the keeper | ||
evmKeeper.WithPrecompiles( | ||
evmkeeper.AvailablePrecompiles( | ||
|
@@ -855,6 +860,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 +906,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 +947,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 +985,7 @@ func NewExocoreApp( | |
withdrawTypes.ModuleName, | ||
rewardTypes.ModuleName, | ||
exoslashTypes.ModuleName, | ||
oracleTypes.ModuleName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please explain the rationale for these orders, if there is any. Or add a comment anyway if there is no particular rationale. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
// 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()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also have the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. udpated |
||
return paramsKeeper | ||
} | ||
|
||
|
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 = 4; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this start from 3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrected |
||
// index for the cached recent params | ||
IndexRecentParams index_recent_params = 5; | ||
// index for the cached recent messages | ||
IndexRecentMsg index_recent_msg = 6; | ||
// cached recent messages | ||
repeated RecentMsg recent_msg_list = 7 [(gogoproto.nullable) = false]; | ||
// cached recent params | ||
repeated RecentParams recent_params_list = 8 [(gogoproto.nullable) = false]; | ||
} | ||
|
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; | ||
} |
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; | ||
} |
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{ | ||
TimmyExogenous marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//eg."bitcoin" | ||
string name = 1; | ||
//TODO: metadata | ||
string desc = 2; | ||
} | ||
|
||
// Token represents the token info | ||
message Token{ | ||
TimmyExogenous marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// 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; | ||
} |
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update or remove this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated