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: Symbiotic network module #542

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ import (
gasestimatekeeper "github.com/ojo-network/ojo/x/gasestimate/keeper"
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"

"github.com/ojo-network/ojo/x/symbiotic"
symbiotickeeper "github.com/ojo-network/ojo/x/symbiotic/keeper"
symbiotictypes "github.com/ojo-network/ojo/x/symbiotic/types"

"github.com/ojo-network/ojo/x/airdrop"
airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper"
airdroptypes "github.com/ojo-network/ojo/x/airdrop/types"
Expand Down Expand Up @@ -150,6 +154,7 @@ var (
oracletypes.ModuleName: {authtypes.Minter},
gmptypes.ModuleName: {authtypes.Minter},
gasestimatetypes.ModuleName: {authtypes.Burner},
symbiotictypes.ModuleName: {authtypes.Minter},
airdroptypes.ModuleName: {authtypes.Minter},
}
)
Expand Down Expand Up @@ -208,6 +213,7 @@ type App struct {
GmpKeeper gmpkeeper.Keeper
GasEstimateKeeper gasestimatekeeper.Keeper
AirdropKeeper airdropkeeper.Keeper
SymbioticKeeper symbiotickeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

// make scoped keepers public for test purposes
Expand Down Expand Up @@ -270,7 +276,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, gmptypes.StoreKey,
gasestimatetypes.ModuleName, airdroptypes.StoreKey,
gasestimatetypes.ModuleName, airdroptypes.StoreKey, symbiotictypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -421,6 +427,13 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.SymbioticKeeper = symbiotickeeper.NewKeeper(
appCodec,
keys[symbiotictypes.ModuleName],
app.StakingKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec,
keys[oracletypes.ModuleName],
Expand All @@ -430,6 +443,7 @@ func New(
app.DistrKeeper,
app.StakingKeeper,
app.GasEstimateKeeper,
app.SymbioticKeeper,
distrtypes.ModuleName,
cast.ToBool(appOpts.Get("telemetry.enabled")),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand Down Expand Up @@ -596,6 +610,7 @@ func New(
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
gmp.NewAppModule(appCodec, app.GmpKeeper, app.OracleKeeper),
gasestimate.NewAppModule(appCodec, app.GasEstimateKeeper),
symbiotic.NewAppModule(appCodec, app.SymbioticKeeper),
airdrop.NewAppModule(appCodec, app.AirdropKeeper, app.AccountKeeper, app.BankKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
)
Expand Down Expand Up @@ -632,6 +647,7 @@ func New(
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
symbiotictypes.ModuleName,
stakingtypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand All @@ -655,6 +671,7 @@ func New(
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
symbiotictypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
Expand Down Expand Up @@ -685,12 +702,12 @@ func New(
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
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, gmptypes.ModuleName, gasestimatetypes.ModuleName,
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
symbiotictypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName,
govtypes.ModuleName, 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, gmptypes.ModuleName, gasestimatetypes.ModuleName,
airdroptypes.ModuleName, consensusparamtypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1011,6 +1028,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(gasestimatetypes.ModuleName)
paramsKeeper.Subspace(symbiotictypes.ModuleName)

// register the key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
Expand Down
8 changes: 8 additions & 0 deletions app/preblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ojo-network/ojo/x/oracle/types"

gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
symbiotictypes "github.com/ojo-network/ojo/x/symbiotic/types"
)

// PreBlocker is run before finalize block to update the aggregrate exchange rate votes on the oracle module
Expand Down Expand Up @@ -67,6 +68,13 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock)
})
}
app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians)

currentBlockHash := app.OracleKeeper.SymbioticKeeper.TallyBlockHashVotes(ctx, injectedVoteExtTx.BlockHashVotes)
cachedBlockHash := symbiotictypes.CachedBlockHash{
BlockHash: currentBlockHash,
Height: req.Height,
}
app.OracleKeeper.SymbioticKeeper.SetCachedBlockHash(ctx, cachedBlockHash)
}

app.Logger().Info(
Expand Down
Loading
Loading