Skip to content
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

feat: relay oracle init #270

Closed
wants to merge 14 commits into from
37 changes: 33 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,16 @@ import (
ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/spf13/cast"

"github.com/ojo-network/ojo/util/genmap"
"github.com/ojo-network/ojo/x/oracle"
oraclekeeper "github.com/ojo-network/ojo/x/oracle/keeper"
oracletypes "github.com/ojo-network/ojo/x/oracle/types"
"github.com/ojo-network/ojo/x/relayoracle"
relayoraclekeeper "github.com/ojo-network/ojo/x/relayoracle/keeper"
relayoracletypes "github.com/ojo-network/ojo/x/relayoracle/types"

"github.com/ojo-network/ojo/x/airdrop"
airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper"
Expand Down Expand Up @@ -156,14 +160,17 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
oracle.AppModuleBasic{},
relayoracle.AppModuleBasic{},
airdrop.AppModuleBasic{},
consensus.AppModuleBasic{},
ibctm.AppModuleBasic{},
)

// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
relayoracletypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -225,13 +232,15 @@ type App struct {
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
OracleKeeper oraclekeeper.Keeper
RelayOracle relayoraclekeeper.Keeper
AirdropKeeper airdropkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedRelayOracleKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper

// mm is the module manager
mm *module.Manager
Expand Down Expand Up @@ -275,6 +284,7 @@ func New(
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
consensusparamtypes.StoreKey, group.StoreKey, oracletypes.StoreKey, airdroptypes.StoreKey,
relayoracletypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -316,6 +326,7 @@ func New(
// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedRelayOracleKeeper := app.CapabilityKeeper.ScopeToModule(relayoracletypes.ModuleName)

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
Expand Down Expand Up @@ -453,6 +464,18 @@ func New(
scopedIBCKeeper,
)

app.RelayOracle = relayoraclekeeper.NewKeeper(
appCodec,
keys[relayoracletypes.ModuleName],
app.GetSubspace(relayoracletypes.ModuleName),
app.OracleKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedRelayOracleKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
relayOracleIBCModule := relayoracle.NewIBCModule(app.RelayOracle)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -507,6 +530,7 @@ func New(
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(relayoracletypes.ModuleName, relayOracleIBCModule)
app.IBCKeeper.SetRouter(ibcRouter)

/**** Module Options ****/
Expand Down Expand Up @@ -544,6 +568,7 @@ func New(
params.NewAppModule(app.ParamsKeeper),
transferModule,
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
relayoracle.NewAppModule(appCodec, app.RelayOracle),
airdrop.NewAppModule(appCodec, app.AirdropKeeper, app.AccountKeeper, app.BankKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
)
Expand Down Expand Up @@ -575,6 +600,7 @@ func New(
vestingtypes.ModuleName,
oracletypes.ModuleName,
airdroptypes.ModuleName,
relayoracletypes.ModuleName,
consensusparamtypes.ModuleName,
)

Expand All @@ -600,6 +626,7 @@ func New(
vestingtypes.ModuleName,
oracletypes.ModuleName,
airdroptypes.ModuleName,
relayoracletypes.ModuleName,
consensusparamtypes.ModuleName,
)

Expand All @@ -614,7 +641,7 @@ func New(
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName,
ibcexported.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName,
group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
oracletypes.ModuleName, airdroptypes.ModuleName, consensusparamtypes.ModuleName,
oracletypes.ModuleName, airdroptypes.ModuleName, relayoracletypes.ModuleName, consensusparamtypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
app.mm.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -685,6 +712,7 @@ func New(

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedRelayOracleKeeper = scopedRelayOracleKeeper

return app
}
Expand Down Expand Up @@ -881,6 +909,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(relayoracletypes.ModuleName)

return paramsKeeper
}
Expand Down
46 changes: 28 additions & 18 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ build:
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
- 39000000000000uojo
mnemonic: entry garbage bike poem grunt negative easily annual miss happy license
blur false fringe program picture inner tape dismiss eagle include quality drill
master
- name: bob
coins:
- 5500000000000uojo
- name: faucet
coins:
- 5500000000000uojo
- name: alice
coins:
- 39000000000000uojo
mnemonic: entry garbage bike poem grunt negative easily annual miss happy license
blur false fringe program picture inner tape dismiss eagle include quality drill
master
- name: bob
coins:
- 5500000000000uojo
- name: relayer
coins:
- 39000000000000uojo
mnemonic: pony glide frown crisp unfold lawn cup loan trial govern usual matrix theory
wash fresh address pioneer between meadow visa buffalo keep gallery swear
- name: faucet
coins:
- 5500000000000uojo
faucet:
name: faucet
coins:
- 5500000000000uojo
- 5500000000000uojo
coins_max:
- 1000000000uojo
- 1000000000uojo
host: 0.0.0.0:4500
port: 4500
genesis:
Expand All @@ -35,5 +40,10 @@ genesis:
bond_denom: uojo
chain_id: ojo-testnet
validators:
- name: alice
bonded: 33500000000000uojo
- name: alice
bonded: 33500000000000uojo
app:
grpc:
address: :9093
grpc-web:
address: :9094
26 changes: 14 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ require (
github.com/golangci/golangci-lint v1.54.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0
github.com/mgechev/revive v1.3.3
github.com/ory/dockertest/v3 v3.10.0
github.com/rs/zerolog v1.30.0
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
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.58.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
mvdan.cc/gofumpt v0.5.0
)

require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
cloud.google.com/go v0.110.4 // indirect
cloud.google.com/go/compute v1.21.0 // indirect
cloud.google.com/go v0.110.6 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
cloud.google.com/go/storage v1.30.1 // indirect
Expand Down Expand Up @@ -119,6 +121,7 @@ require (
github.com/firefart/nonamedreturns v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-critic/go-critic v0.9.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand Down Expand Up @@ -300,25 +303,24 @@ require (
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
honnef.co/go/tools v0.4.5 // indirect
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
Expand Down
Loading