Skip to content

Commit

Permalink
e2e: manifest module (#10)
Browse files Browse the repository at this point in the history
* e2e: allow PoA admin override with ENV variable

* setup params

* tweaks

* simplify + working manual e2e

* full e2e of manifest module + ci

* lint iter1

* lint2 + remove unused bankKeeper

* last minute cleanup

* wait 2 blocks
  • Loading branch information
Reecepbcups authored Feb 27, 2024
1 parent f67be75 commit 0ebdae9
Show file tree
Hide file tree
Showing 28 changed files with 443 additions and 403 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
test:
- "ictest-ibc"
- "ictest-tokenfactory"
- "ictest-manifest"
fail-fast: false

steps:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ ictest-ibc:
ictest-tokenfactory:
cd interchaintest && go test -race -v -run TestTokenFactory . -count=1

ictest-manifest:
cd interchaintest && go test -race -v -run TestManifestModule . -count=1


.PHONY: ictest-ibc ictest-tokenfactory

Expand Down
7 changes: 0 additions & 7 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package app

import (
"context"
"errors"

"github.com/liftedinit/manifest-ledger/app/decorators"
manifestkeeper "github.com/liftedinit/manifest-ledger/x/manifest/keeper"
poaante "github.com/strangelove-ventures/poa/ante"

ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
Expand All @@ -26,9 +23,6 @@ type HandlerOptions struct {

IBCKeeper *keeper.Keeper
CircuitKeeper *circuitkeeper.Keeper

ManifestKeeper *manifestkeeper.Keeper
IsSudoAdminFunc func(ctx context.Context, fromAddr string) bool
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
Expand Down Expand Up @@ -65,7 +59,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
poaante.NewPOADisableStakingDecorator(),
poaante.NewCommissionLimitDecorator(doGenTxRateValidation, rateFloor, rateCeil),
decorators.NewMsgManualMintFilterDecorator(options.ManifestKeeper, options.IsSudoAdminFunc),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
}

Expand Down
55 changes: 30 additions & 25 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

// !IMPORTANT: testnet only (reece's addr)
const POAAdmin = "manifest10r39fueph9fq7a6lgswu4zdsg8t3gxlqdwwncm"
func GetPoAAdmin() string {
// used only in e2e testing with interchaintest
if address := os.Getenv("POA_ADMIN_ADDRESS"); address != "" {
return address
}

// !IMPORTANT: testnet only (reece's addr). Change this to a mainnet address
return "manifest10r39fueph9fq7a6lgswu4zdsg8t3gxlqdwwncm"
}

// We pull these out so we can set them with LDFLAGS in the Makefile
var (
Expand Down Expand Up @@ -344,7 +351,7 @@ func NewApp(
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
POAAdmin,
GetPoAAdmin(),
runtime.EventService{},
)
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
Expand All @@ -371,14 +378,14 @@ func NewApp(
maccPerms,
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()),
sdk.GetConfig().GetBech32AccountAddrPrefix(),
POAAdmin,
GetPoAAdmin(),
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
app.AccountKeeper,
BlockedAddresses(),
POAAdmin,
GetPoAAdmin(),
logger,
)

Expand All @@ -387,7 +394,7 @@ func NewApp(
runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
POAAdmin,
GetPoAAdmin(),
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
)
Expand All @@ -398,7 +405,7 @@ func NewApp(
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
POAAdmin,
GetPoAAdmin(),
)

app.DistrKeeper = distrkeeper.NewKeeper(
Expand All @@ -408,15 +415,15 @@ func NewApp(
app.BankKeeper,
app.StakingKeeper,
authtypes.FeeCollectorName,
POAAdmin,
GetPoAAdmin(),
)

app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
legacyAmino,
runtime.NewKVStoreService(keys[slashingtypes.StoreKey]),
app.StakingKeeper,
POAAdmin,
GetPoAAdmin(),
)

app.POAKeeper = poakeeper.NewKeeper(
Expand All @@ -436,7 +443,7 @@ func NewApp(
invCheckPeriod,
app.BankKeeper,
authtypes.FeeCollectorName,
POAAdmin,
GetPoAAdmin(),
app.AccountKeeper.AddressCodec(),
)

Expand All @@ -451,7 +458,7 @@ func NewApp(
app.CircuitKeeper = circuitkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[circuittypes.StoreKey]),
POAAdmin,
GetPoAAdmin(),
app.AccountKeeper.AddressCodec(),
)
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
Expand Down Expand Up @@ -487,7 +494,7 @@ func NewApp(
appCodec,
homePath,
app.BaseApp,
POAAdmin,
GetPoAAdmin(),
)

app.IBCKeeper = ibckeeper.NewKeeper(
Expand All @@ -497,7 +504,7 @@ func NewApp(
app.StakingKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
POAAdmin,
GetPoAAdmin(),
)

// Register the proposal types
Expand All @@ -523,7 +530,7 @@ func NewApp(
app.DistrKeeper,
app.MsgServiceRouter(),
govConfig,
POAAdmin,
GetPoAAdmin(),
)

app.GovKeeper = *govKeeper.SetHooks(
Expand Down Expand Up @@ -558,7 +565,7 @@ func NewApp(
app.MintKeeper,
app.BankKeeper,
logger,
POAAdmin,
GetPoAAdmin(),
)

// Create the TokenFactory Keeper
Expand All @@ -570,7 +577,7 @@ func NewApp(
app.DistrKeeper,
tokenFactoryCapabilities,
app.POAKeeper.IsAdmin,
POAAdmin,
GetPoAAdmin(),
)

// IBC Fee Module keeper
Expand All @@ -592,7 +599,7 @@ func NewApp(
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
POAAdmin,
GetPoAAdmin(),
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
Expand All @@ -605,7 +612,7 @@ func NewApp(
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
POAAdmin,
GetPoAAdmin(),
)
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
Expand All @@ -616,7 +623,7 @@ func NewApp(
app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper,
app.MsgServiceRouter(),
POAAdmin,
GetPoAAdmin(),
)

// Set legacy router for backwards compatibility with gov v1beta1
Expand Down Expand Up @@ -693,7 +700,7 @@ func NewApp(
poamodule.NewAppModule(appCodec, app.POAKeeper),
// sdk
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
manifest.NewAppModule(appCodec, app.ManifestKeeper, app.MintKeeper, app.BankKeeper),
manifest.NewAppModule(appCodec, app.ManifestKeeper, app.MintKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -841,6 +848,8 @@ func NewApp(
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper

app.setAnteHandler(txConfig)

// In v0.46, the SDK introduces _postHandlers_. PostHandlers are like
// antehandlers, but are run _after_ the `runMsgs` execution. They are also
// defined as a chain, and have the same signature as antehandlers.
Expand Down Expand Up @@ -895,10 +904,6 @@ func (app *ManifestApp) setAnteHandler(txConfig client.TxConfig) {
},
IBCKeeper: app.IBCKeeper,
CircuitKeeper: &app.CircuitKeeper,

// Manifest specific logic for inflation disabled manual minting / disabled if inflation is on.
ManifestKeeper: &app.ManifestKeeper,
IsSudoAdminFunc: app.POAKeeper.IsAdmin,
},
)
if err != nil {
Expand Down Expand Up @@ -1123,7 +1128,7 @@ func BlockedAddresses() map[string]bool {
}

// allow the following addresses to receive funds
delete(modAccAddrs, POAAdmin)
delete(modAccAddrs, govtypes.ModuleName)

return modAccAddrs
}
Expand Down
60 changes: 0 additions & 60 deletions app/decorators/inflation_disable_minting.go

This file was deleted.

Loading

0 comments on commit 0ebdae9

Please sign in to comment.