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: integrate aura #383

Merged
merged 6 commits into from
Jun 26, 2024
Merged
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
1 change: 0 additions & 1 deletion .changelog/unreleased/dependencies/259-bump-cctp.md

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion .changelog/unreleased/improvements/249-module-path-v4.md

This file was deleted.

1 change: 0 additions & 1 deletion .changelog/unreleased/improvements/259-migrate-ftf.md

This file was deleted.

1 change: 1 addition & 0 deletions .changelog/unreleased/improvements/271-module-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Update module path for v5 release line. ([#271](https://github.com/noble-assets/noble/pull/271))
1 change: 0 additions & 1 deletion .changelog/unreleased/improvements/283-module-path.md

This file was deleted.

This file was deleted.

18 changes: 1 addition & 17 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,11 @@ defaults:
- "{{ author }}"

pull_request_rules:
- name: backport patches to v4.0.x branch
conditions:
- base=main
- label=backport/v4.0.x
actions:
backport:
branches:
- release/v4.0.x
- name: backport patches to v4.1.x branch
conditions:
- base=main
- label=backport/v4.1.x
actions:
backport:
branches:
- release/v4.1.x
- name: backport patches to v5.0.x branch
conditions:
- base=main
- label=backport/v5.0.x
actions:
backport:
branches:
- release/v5.0.x
- v5.0.x
36 changes: 18 additions & 18 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ concurrency:
cancel-in-progress: true

jobs:
build-docker:
build:
runs-on: ubuntu-latest
steps:
- name: Build Docker image
- name: Build Docker Image
uses: strangelove-ventures/[email protected]
with:
registry: "" # empty registry, image only shared for e2e testing
Expand All @@ -36,45 +36,45 @@ jobs:
name: noble-docker-image
path: ${{ env.TAR_PATH }}

prepare-e2e-tests:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Go 1.21
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '>=1.21'
go-version: '1.21'

- name: Generate matrix
- name: Generate Matrix
id: set-matrix
run: |
# Run the command and convert its output to a JSON array
TESTS=$(cd interchaintest && go test -list . | grep -v "^ok " | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${TESTS}" >> $GITHUB_OUTPUT
e2e-tests:

test:
needs:
- build-docker
- prepare-e2e-tests
- build
- prepare
runs-on: ubuntu-latest
strategy:
matrix:
# names of `make` commands to run tests
test: ${{fromJson(needs.prepare-e2e-tests.outputs.matrix)}}
test: ${{fromJson(needs.prepare.outputs.matrix)}}
fail-fast: false

steps:
- name: Set up Go 1.21
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '>=1.21'

- name: checkout chain
uses: actions/checkout@v4
go-version: '1.21'

- name: Download Tarball Artifact
uses: actions/download-artifact@v4
Expand All @@ -84,5 +84,5 @@ jobs:
- name: Load Docker Image
run: docker image load -i ${{ env.TAR_PATH }}

- name: run test
- name: Run Tests
run: cd interchaintest && go test -race -v -timeout 30m -run ^${{ matrix.test }}$ .
37 changes: 34 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +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/v5/app/upgrades/krypton"
"github.com/noble-assets/noble/v5/cmd"
"github.com/noble-assets/noble/v5/docs"
"github.com/noble-assets/noble/v5/x/globalfee"
Expand All @@ -104,13 +105,17 @@ import (
tokenfactorymodulekeeper "github.com/noble-assets/noble/v5/x/tokenfactory/keeper"
tokenfactorymoduletypes "github.com/noble-assets/noble/v5/x/tokenfactory/types"

cctp "github.com/circlefin/noble-cctp/x/cctp"
"github.com/circlefin/noble-cctp/x/cctp"
cctpkeeper "github.com/circlefin/noble-cctp/x/cctp/keeper"
cctptypes "github.com/circlefin/noble-cctp/x/cctp/types"

"github.com/noble-assets/forwarding/x/forwarding"
forwardingkeeper "github.com/noble-assets/forwarding/x/forwarding/keeper"
forwardingtypes "github.com/noble-assets/forwarding/x/forwarding/types"

"github.com/noble-assets/aura/x/aura"
aurakeeper "github.com/noble-assets/aura/x/aura/keeper"
auratypes "github.com/noble-assets/aura/x/aura/types"
johnletey marked this conversation as resolved.
Show resolved Hide resolved
)

const (
Expand Down Expand Up @@ -154,6 +159,7 @@ var (
cctp.AppModuleBasic{},
paramauthorityibc.AppModuleBasic{},
forwarding.AppModuleBasic{},
aura.AppModuleBasic{},
)

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

Expand Down Expand Up @@ -231,6 +238,7 @@ type App struct {
TariffKeeper tariffkeeper.Keeper
CCTPKeeper *cctpkeeper.Keeper
ForwardingKeeper *forwardingkeeper.Keeper
AuraKeeper *aurakeeper.Keeper

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

Expand Down Expand Up @@ -269,7 +277,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,
cctptypes.StoreKey, forwardingtypes.StoreKey, auratypes.ModuleName,
)
tkeys := sdk.NewTransientStoreKeys(
paramstypes.TStoreKey,
Expand Down Expand Up @@ -326,13 +334,20 @@ func New(
app.MsgServiceRouter(),
)

app.AuraKeeper = aurakeeper.NewKeeper(
appCodec,
keys[auratypes.ModuleName],
"ausdy",
nil,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.BlockedModuleAccountAddrs(),
)
).WithSendCoinsRestriction(app.AuraKeeper.SendRestrictionFn)
app.AuraKeeper.SetBankKeeper(app.BankKeeper)

app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -548,6 +563,7 @@ func New(
tariff.NewAppModule(appCodec, app.TariffKeeper, app.AccountKeeper, app.BankKeeper),
cctp.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.CCTPKeeper),
forwarding.NewAppModule(app.ForwardingKeeper),
aura.NewAppModule(app.AuraKeeper),
)

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

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -607,6 +624,7 @@ func New(
tarifftypes.ModuleName,
cctptypes.ModuleName,
forwardingtypes.ModuleName,
auratypes.ModuleName,
)

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

// this line is used by starport scaffolding # stargate/app/initGenesis
)
Expand Down Expand Up @@ -876,6 +895,16 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
}

func (app *App) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
krypton.UpgradeName,
krypton.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AuraKeeper,
app.BankKeeper,
),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
Expand All @@ -887,6 +916,8 @@ func (app *App) setupUpgradeHandlers() {
var storeLoader baseapp.StoreLoader

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

if storeLoader != nil {
Expand Down
10 changes: 10 additions & 0 deletions app/upgrades/krypton/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package krypton

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

// MainnetChainID is the Chain ID of the Noble mainnet.
const MainnetChainID = "noble-1"

// TestnetChainID is the Chain ID of the Noble testnet.
const TestnetChainID = "grand-1"
16 changes: 16 additions & 0 deletions app/upgrades/krypton/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package krypton

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/noble-assets/aura/x/aura/types"
)

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

return upgradetypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
}
58 changes: 58 additions & 0 deletions app/upgrades/krypton/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package krypton

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
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/noble-assets/aura/x/aura/keeper"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
auraKeeper *aurakeeper.Keeper,
bankKeeper bankkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
vm, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return vm, err
}

switch ctx.ChainID() {
case TestnetChainID:
auraKeeper.SetOwner(ctx, "noble1mxe0zwwdvjvn8dg2hnep55q4fc7sqmpud9qsqn")
auraKeeper.SetBlocklistOwner(ctx, "noble1mxe0zwwdvjvn8dg2hnep55q4fc7sqmpud9qsqn")
case MainnetChainID:
auraKeeper.SetOwner(ctx, "") // TODO
auraKeeper.SetBlocklistOwner(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",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: "ausdy",
Exponent: 0,
Aliases: []string{"attousdy"},
},
{
Denom: "usdy",
Exponent: 18,
},
},
Base: "ausdy",
Display: "usdy",
Name: "Ondo US Dollar Yield",
johnletey marked this conversation as resolved.
Show resolved Hide resolved
Symbol: "USDY",
})

return vm, nil
}
}
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ require (
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/noble-assets/aura v1.0.0-rc.0
github.com/noble-assets/forwarding v1.1.0
github.com/rs/zerolog v1.27.0
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
github.com/strangelove-ventures/paramauthority v1.1.0
github.com/stretchr/testify v1.8.4
github.com/tendermint/tendermint v0.34.27
Expand Down Expand Up @@ -123,11 +126,9 @@ require (
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.15.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
Expand All @@ -154,6 +155,9 @@ replace (
// use cosmos compatible ChainSafe/go-schnorrkel
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d

// use send restriction compatible cosmos/cosmos-sdk
github.com/cosmos/cosmos-sdk => github.com/noble-assets/cosmos-sdk v0.45.17-0.20240626105200-928be03f1633

// use macos sonoma compatible cosmos/ledger-cosmos-go
github.com/cosmos/ledger-cosmos-go => github.com/cosmos/ledger-cosmos-go v0.12.4

Expand Down
Loading