Skip to content

Commit

Permalink
feat: integrate halo (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: John Letey <[email protected]>
  • Loading branch information
boojamya and johnletey authored Jul 22, 2024
1 parent 54de99d commit 7e5f3fb
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Build Docker Image
uses: strangelove-ventures/[email protected].2
uses: strangelove-ventures/[email protected].3
with:
registry: "" # empty registry, image only shared for e2e testing
tag: local # emulate local environment for consistency in interchaintest cases
Expand Down
40 changes: 32 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/noble-assets/noble/v6/app/upgrades/krypton"
"github.com/noble-assets/noble/v6/app/upgrades/xenon"
"github.com/noble-assets/noble/v6/cmd"
"github.com/noble-assets/noble/v6/docs"
"github.com/noble-assets/noble/v6/x/globalfee"
Expand All @@ -116,6 +116,10 @@ import (
"github.com/ondoprotocol/usdy-noble/x/aura"
aurakeeper "github.com/ondoprotocol/usdy-noble/x/aura/keeper"
auratypes "github.com/ondoprotocol/usdy-noble/x/aura/types"

"github.com/noble-assets/halo/x/halo"
halokeeper "github.com/noble-assets/halo/x/halo/keeper"
halotypes "github.com/noble-assets/halo/x/halo/types"
)

const (
Expand Down Expand Up @@ -160,6 +164,7 @@ var (
paramauthorityibc.AppModuleBasic{},
forwarding.AppModuleBasic{},
aura.AppModuleBasic{},
halo.AppModuleBasic{},
)

// module account permissions
Expand All @@ -174,6 +179,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
cctptypes.ModuleName: nil,
auratypes.ModuleName: {authtypes.Burner, authtypes.Minter},
halotypes.ModuleName: {authtypes.Burner, authtypes.Minter},
}
)

Expand Down Expand Up @@ -239,6 +245,7 @@ type App struct {
CCTPKeeper *cctpkeeper.Keeper
ForwardingKeeper *forwardingkeeper.Keeper
AuraKeeper *aurakeeper.Keeper
HaloKeeper *halokeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -277,7 +284,7 @@ func New(
paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey,
ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey,
tokenfactorymoduletypes.StoreKey, fiattokenfactorymoduletypes.StoreKey, packetforwardtypes.StoreKey, stakingtypes.StoreKey,
cctptypes.StoreKey, forwardingtypes.StoreKey, auratypes.ModuleName,
cctptypes.StoreKey, forwardingtypes.StoreKey, auratypes.ModuleName, halotypes.ModuleName,
)
tkeys := sdk.NewTransientStoreKeys(
paramstypes.TStoreKey,
Expand Down Expand Up @@ -340,14 +347,27 @@ func New(
"ausdy",
nil,
)

app.HaloKeeper = halokeeper.NewKeeper(
appCodec,
keys[halotypes.ModuleName],
"uusyc",
"uusdc",
app.AccountKeeper,
nil,
)

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.BlockedModuleAccountAddrs(),
).WithSendCoinsRestriction(app.AuraKeeper.SendRestrictionFn)
).
WithSendCoinsRestriction(app.AuraKeeper.SendRestrictionFn).
WithSendCoinsRestriction(app.HaloKeeper.SendRestrictionFn)
app.AuraKeeper.SetBankKeeper(app.BankKeeper)
app.HaloKeeper.SetBankKeeper(app.BankKeeper)

app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -564,6 +584,7 @@ func New(
cctp.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.CCTPKeeper),
forwarding.NewAppModule(app.ForwardingKeeper),
aura.NewAppModule(app.AuraKeeper),
halo.NewAppModule(app.HaloKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -597,6 +618,7 @@ func New(
cctptypes.ModuleName,
forwardingtypes.ModuleName,
auratypes.ModuleName,
halotypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -625,6 +647,7 @@ func New(
cctptypes.ModuleName,
forwardingtypes.ModuleName,
auratypes.ModuleName,
halotypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -658,6 +681,7 @@ func New(
cctptypes.ModuleName,
forwardingtypes.ModuleName,
auratypes.ModuleName,
halotypes.ModuleName,

// this line is used by starport scaffolding # stargate/app/initGenesis
)
Expand Down Expand Up @@ -896,11 +920,11 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

func (app *App) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
krypton.UpgradeName,
krypton.CreateUpgradeHandler(
xenon.UpgradeName,
xenon.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AuraKeeper,
app.HaloKeeper,
app.BankKeeper,
),
)
Expand All @@ -916,8 +940,8 @@ func (app *App) setupUpgradeHandlers() {
var storeLoader baseapp.StoreLoader

switch upgradeInfo.Name {
case krypton.UpgradeName:
storeLoader = krypton.CreateStoreLoader(upgradeInfo.Height)
case xenon.UpgradeName:
storeLoader = xenon.CreateStoreLoader(upgradeInfo.Height)
}

if storeLoader != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package krypton
package xenon

// UpgradeName is the name of this specific software upgrade used on-chain.
const UpgradeName = "krypton"
const UpgradeName = "xenon"

// MainnetChainID is the Chain ID of the Noble mainnet.
const MainnetChainID = "noble-1"
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades/krypton/store.go → app/upgrades/xenon/store.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package krypton
package xenon

import (
"github.com/cosmos/cosmos-sdk/baseapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
auratypes "github.com/ondoprotocol/usdy-noble/x/aura/types"
halotypes "github.com/noble-assets/halo/x/halo/types"
)

func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{auratypes.ModuleName},
Added: []string{halotypes.ModuleName},
}

return upgradetypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
Expand Down
34 changes: 18 additions & 16 deletions app/upgrades/krypton/upgrade.go → app/upgrades/xenon/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package krypton
package xenon

import (
"fmt"
Expand All @@ -8,13 +8,13 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
aurakeeper "github.com/ondoprotocol/usdy-noble/x/aura/keeper"
halokeeper "github.com/noble-assets/halo/x/halo/keeper"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
auraKeeper *aurakeeper.Keeper,
haloKeeper *halokeeper.Keeper,
bankKeeper bankkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -25,32 +25,34 @@ func CreateUpgradeHandler(

switch ctx.ChainID() {
case TestnetChainID:
auraKeeper.SetOwner(ctx, "noble1mxe0zwwdvjvn8dg2hnep55q4fc7sqmpud9qsqn")
auraKeeper.SetBlocklistOwner(ctx, "noble1mxe0zwwdvjvn8dg2hnep55q4fc7sqmpud9qsqn")
haloKeeper.SetOwner(ctx, "noble1u0nahk4wltsp89tpce4cyayd63a69dhpkfq9wq")
haloKeeper.SetAggregatorOwner(ctx, "noble1u0nahk4wltsp89tpce4cyayd63a69dhpkfq9wq")
haloKeeper.SetEntitlementsOwner(ctx, "noble1u0nahk4wltsp89tpce4cyayd63a69dhpkfq9wq")
case MainnetChainID:
auraKeeper.SetOwner(ctx, "noble1t6ypyedl6ggvvlgx3cn6jvy9xpr3p2395m2dg5")
auraKeeper.SetBlocklistOwner(ctx, "noble1t6ypyedl6ggvvlgx3cn6jvy9xpr3p2395m2dg5")
haloKeeper.SetOwner(ctx, "") // TODO
haloKeeper.SetAggregatorOwner(ctx, "") // TODO
haloKeeper.SetEntitlementsOwner(ctx, "") // TODO
default:
return vm, fmt.Errorf("%s upgrade not allowed to execute on %s chain", UpgradeName, ctx.ChainID())
}

bankKeeper.SetDenomMetaData(ctx, banktypes.Metadata{
Description: "Ondo US Dollar Yield",
Description: "Hashnote US Yield Coin",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: "ausdy",
Denom: "uusyc",
Exponent: 0,
Aliases: []string{"attousdy"},
Aliases: []string{"microusyc"},
},
{
Denom: "usdy",
Exponent: 18,
Denom: "usyc",
Exponent: 6,
},
},
Base: "ausdy",
Display: "usdy",
Name: "Ondo US Dollar Yield",
Symbol: "USDY",
Base: "uusyc",
Display: "usyc",
Name: "Hashnote US Yield Coin",
Symbol: "USYC",
})

return vm, nil
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/noble-assets/forwarding v1.1.0
github.com/noble-assets/halo v1.0.0-alpha.0
github.com/ondoprotocol/usdy-noble v1.0.0
github.com/rs/zerolog v1.27.0
github.com/spf13/cast v1.5.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ github.com/noble-assets/cosmos-sdk v0.45.16-send-restrictions h1:oQwbCoejkXp2/oz
github.com/noble-assets/cosmos-sdk v0.45.16-send-restrictions/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/noble-assets/forwarding v1.1.0 h1:2TXBs2Y9vWqgHyDKtdcHht6i7OT+pLaVHE3bPvfpmJY=
github.com/noble-assets/forwarding v1.1.0/go.mod h1:o64ZfzCHteRDhOlkpi7GeKAcjlcbWUihC7Y34Er2/3U=
github.com/noble-assets/halo v1.0.0-alpha.0 h1:i5HBbMVi+GQul/aMxRtfFMfn6B4LKbYj10BFIZ0C3u8=
github.com/noble-assets/halo v1.0.0-alpha.0/go.mod h1:zWcppKjRH5v0ZTRXPtxEhoO1XRFE7wi5GhxtnGeFy6I=
github.com/nunnatsa/ginkgolinter v0.14.0 h1:XQPNmw+kZz5cC/HbFK3mQutpjzAQv1dHregRA+4CGGg=
github.com/nunnatsa/ginkgolinter v0.14.0/go.mod h1:cm2xaqCUCRd7qcP4DqbVvpcyEMkuLM9CF0wY6VASohk=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
Expand Down
5 changes: 5 additions & 0 deletions interchaintest/upgrade_grand-1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func TestGrand1ChainUpgrade(t *testing.T) {
{
// krypton is a major release that introduced the aura module.
upgradeName: "krypton",
image: ghcrImage("v5.0.0-rc.0"),
},
{
// xenon is a major release that introduced the halo module.
upgradeName: "xenon",
image: nobleImageInfo[0],
},
}
Expand Down
5 changes: 5 additions & 0 deletions interchaintest/upgrade_noble-1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func TestNoble1ChainUpgrade(t *testing.T) {
{
// krypton is a major release that introduced the aura module.
upgradeName: "krypton",
image: ghcrImage("v5.0.0"),
},
{
// xenon is a major release that introduced the halo module.
upgradeName: "xenon",
image: nobleImageInfo[0],
},
}
Expand Down

0 comments on commit 7e5f3fb

Please sign in to comment.