Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
89e1683
attempt-basic
aljo242 Sep 30, 2025
47e1ec1
delete-types-address
aljo242 Sep 30, 2025
ddeec48
doc
aljo242 Sep 30, 2025
9e64c51
mempool-api
aljo242 Sep 30, 2025
fe77db3
Revert "delete-types-address"
aljo242 Sep 30, 2025
8120151
add-again
aljo242 Sep 30, 2025
8085454
resolve
aljo242 Sep 30, 2025
5030a6a
ok
aljo242 Sep 30, 2025
b0c28b4
wow
aljo242 Oct 1, 2025
7fa12fa
fix
aljo242 Oct 1, 2025
a03ffd9
trying
aljo242 Oct 1, 2025
96989a5
lint-fikx
aljo242 Oct 1, 2025
0e9a210
more-setup
aljo242 Oct 1, 2025
de34173
geting-there
aljo242 Oct 1, 2025
601e43c
wire
aljo242 Oct 1, 2025
cda9f2d
good-spolt
aljo242 Oct 1, 2025
7d7a641
fixingtown
aljo242 Oct 1, 2025
c08a0eb
disable
aljo242 Oct 1, 2025
f939226
fix
aljo242 Oct 1, 2025
5f05f62
working
aljo242 Oct 1, 2025
6106f3d
maybe
aljo242 Oct 1, 2025
70630d2
wire
aljo242 Oct 1, 2025
959d836
hmmm
aljo242 Oct 1, 2025
57b2c99
eh
aljo242 Oct 1, 2025
eeb0d7c
attempt
aljo242 Oct 2, 2025
25ced56
almost
aljo242 Oct 2, 2025
e297c17
add
aljo242 Oct 2, 2025
4a7ec11
lint-fix
aljo242 Oct 2, 2025
8033839
add-upgrade
aljo242 Oct 2, 2025
06f9001
todo
aljo242 Oct 2, 2025
68b516a
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 3, 2025
21cef57
nice
aljo242 Oct 6, 2025
3bb5844
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 6, 2025
516c296
remove
aljo242 Oct 6, 2025
5d5cb28
fix
aljo242 Oct 6, 2025
b60c423
attempt
aljo242 Oct 6, 2025
5751e06
ok
aljo242 Oct 6, 2025
681f57c
organize
aljo242 Oct 6, 2025
43872f2
attempt-upgrade
aljo242 Oct 6, 2025
14c5593
wip
aljo242 Oct 6, 2025
e45e6c4
fix
aljo242 Oct 6, 2025
e4c2e3e
fixed
aljo242 Oct 6, 2025
396951e
app
aljo242 Oct 6, 2025
52dddb2
move
aljo242 Oct 6, 2025
ad66f9e
extend
aljo242 Oct 6, 2025
63f94fb
extend
aljo242 Oct 6, 2025
94787c7
fix
aljo242 Oct 7, 2025
e56e343
fix
aljo242 Oct 7, 2025
7b16aae
fix
aljo242 Oct 7, 2025
10d5a15
fix
aljo242 Oct 7, 2025
3e948e2
attempt?
aljo242 Oct 7, 2025
4cfbc02
fix
aljo242 Oct 7, 2025
0203e98
attempt
aljo242 Oct 7, 2025
24de218
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 7, 2025
ea73fa5
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 8, 2025
6480b50
fix
aljo242 Oct 8, 2025
b325a74
add
aljo242 Oct 8, 2025
9cb113d
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 15, 2025
4b8b4ac
tidy
aljo242 Oct 15, 2025
e86f0cb
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 15, 2025
15e229f
tidy
aljo242 Oct 15, 2025
d096bf8
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 15, 2025
60daaff
Merge branch 'main' into exp/alex-simplify
aljo242 Oct 16, 2025
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
560 changes: 560 additions & 0 deletions app/app.go

Large diffs are not rendered by default.

223 changes: 223 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
package app

import (
"maps"
"slices"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/authz"
epochstypes "github.com/cosmos/cosmos-sdk/x/epochs/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
protocolpooltypes "github.com/cosmos/cosmos-sdk/x/protocolpool/types"
)

type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Codec *codec.ProtoCodec
LegacyAmino *codec.LegacyAmino
TxConfig client.TxConfig
}

func NewEncodingConfigFromOptions(opts types.InterfaceRegistryOptions) EncodingConfig {
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(opts)
if err != nil {
panic(err)
}

appCodec := codec.NewProtoCodec(interfaceRegistry)
legacyAmino := codec.NewLegacyAmino()
txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes)

if err := interfaceRegistry.SigningContext().Validate(); err != nil {
panic(err)
}

std.RegisterLegacyAminoCodec(legacyAmino)
std.RegisterInterfaces(interfaceRegistry)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: appCodec,
LegacyAmino: legacyAmino,
TxConfig: txConfig,
}
}

type SDKAppConfig struct {
AppName string

AppOpts servertypes.AppOptions
BaseAppOptions []func(*baseapp.BaseApp)

InterfaceRegistryOptions types.InterfaceRegistryOptions

WithProtocolPool bool
WithAuthz bool
WithEpochs bool
WithFeeGrant bool
WithMint bool
// TODO gov optional?
// TODO any other optional modules?

WithUnorderedTx bool

Keys []string
OrderPreBlockers []string
OrderBeginBlockers []string
OrderEndBlockers []string
OrderInitGenesis []string
OrderExportGenesis []string

ModuleAccountPerms map[string][]string

Mempool mempool.Mempool

VerifyVoteExtensionHandler sdk.VerifyVoteExtensionHandler
PrepareProposalHandler sdk.PrepareProposalHandler
ProcessProposalHandler sdk.ProcessProposalHandler
ExtendVoteHandler sdk.ExtendVoteHandler

Upgrades []Upgrade[AppI]

ModuleAuthority string
}

func DefaultSDKAppConfig(
name string,
opts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) SDKAppConfig {
defaultOptions := server.DefaultBaseappOptions(opts)

// TODO - populate if nil to fix any issues

baseAppOptions = append(defaultOptions, baseAppOptions...)

return SDKAppConfig{
AppName: name,

InterfaceRegistryOptions: defaultInterfaceRegistryOptions,

AppOpts: opts,
BaseAppOptions: baseAppOptions,
WithProtocolPool: true,
WithAuthz: true,
WithEpochs: true,
WithFeeGrant: true,
WithMint: true,

WithUnorderedTx: true,

ModuleAccountPerms: defaultMaccPerms,

OrderPreBlockers: defaultOrderPreBlockers,
OrderBeginBlockers: defaultOrderBeginBlockers,
OrderEndBlockers: defaultOrderEndBlockers,
OrderInitGenesis: defaultOrderInitGenesis,
OrderExportGenesis: defaultOrderExportGenesis,

Mempool: mempool.NoOpMempool{},
VerifyVoteExtensionHandler: baseapp.NoOpVerifyVoteExtensionHandler(),
ExtendVoteHandler: baseapp.NoOpExtendVote(),
// leave these as nil for construction later in baseapp by default
PrepareProposalHandler: nil,
ProcessProposalHandler: nil,

Upgrades: nil,

ModuleAuthority: defaultModuleAuthority,
}
}

// TODO test thoroughly
func (appConfig *SDKAppConfig) processOptionalModules() {
checkForModuleInclusion := func(moduleName string) func(string) bool {
return func(s string) bool {
return moduleName == s
}
}

deleteModuleFromOrdering := func(moduleName string) {
defaultOrderPreBlockers = slices.DeleteFunc(defaultOrderPreBlockers, checkForModuleInclusion(moduleName))
defaultOrderBeginBlockers = slices.DeleteFunc(defaultOrderBeginBlockers, checkForModuleInclusion(moduleName))
defaultOrderEndBlockers = slices.DeleteFunc(defaultOrderEndBlockers, checkForModuleInclusion(moduleName))
defaultOrderInitGenesis = slices.DeleteFunc(defaultOrderInitGenesis, checkForModuleInclusion(moduleName))
defaultOrderExportGenesis = slices.DeleteFunc(defaultOrderExportGenesis, checkForModuleInclusion(moduleName))
}

if !appConfig.WithProtocolPool {
// remove from macc permissions
maps.DeleteFunc(appConfig.ModuleAccountPerms, func(s string, _ []string) bool {
switch s {
case protocolpooltypes.ModuleName:
return true
case protocolpooltypes.ProtocolPoolEscrowAccount:
return true
default:
return false
}
})

deleteModuleFromOrdering(protocolpooltypes.ModuleName)
}

if !appConfig.WithAuthz {
maps.DeleteFunc(appConfig.ModuleAccountPerms, func(s string, _ []string) bool {
switch s {
case authz.ModuleName:
return true
default:
return false
}
})

deleteModuleFromOrdering(authz.ModuleName)
}

if !appConfig.WithFeeGrant {
maps.DeleteFunc(appConfig.ModuleAccountPerms, func(s string, _ []string) bool {
switch s {
case feegrant.ModuleName:
return true
default:
return false
}
})

deleteModuleFromOrdering(feegrant.ModuleName)
}

if !appConfig.WithMint {
maps.DeleteFunc(appConfig.ModuleAccountPerms, func(s string, _ []string) bool {
switch s {
case minttypes.ModuleName:
return true
default:
return false
}
})
}

if !appConfig.WithEpochs {
maps.DeleteFunc(appConfig.ModuleAccountPerms, func(s string, _ []string) bool {
switch s {
case epochstypes.ModuleName:
return true
default:
return false
}
})

deleteModuleFromOrdering(epochstypes.ModuleName)
}
}
144 changes: 144 additions & 0 deletions app/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package app

import (
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/x/tx/signing"

"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
epochstypes "github.com/cosmos/cosmos-sdk/x/epochs/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
protocolpooltypes "github.com/cosmos/cosmos-sdk/x/protocolpool/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

var (
defaultModuleAuthority = authtypes.NewModuleAddress(govtypes.ModuleName).String()

defaultMaccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
protocolpooltypes.ModuleName: nil,
protocolpooltypes.ProtocolPoolEscrowAccount: nil,
}

defaultKeys = []string{
authtypes.StoreKey,
banktypes.StoreKey,
stakingtypes.StoreKey,
minttypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
consensusparamtypes.StoreKey,
upgradetypes.StoreKey,
feegrant.StoreKey,
evidencetypes.StoreKey,
authzkeeper.StoreKey,
epochstypes.StoreKey,
protocolpooltypes.StoreKey,
}

// NOTE: upgrade module is required to be prioritized
defaultOrderPreBlockers = []string{
upgradetypes.ModuleName,
authtypes.ModuleName,
}

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
defaultOrderBeginBlockers = []string{
minttypes.ModuleName,
distrtypes.ModuleName,
protocolpooltypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
epochstypes.ModuleName,
}

defaultOrderEndBlockers = []string{
govtypes.ModuleName,
stakingtypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
protocolpooltypes.ModuleName,
}

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
defaultOrderInitGenesis = []string{
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
epochstypes.ModuleName,
protocolpooltypes.ModuleName,
}

defaultOrderExportGenesis = []string{
consensusparamtypes.ModuleName,
authtypes.ModuleName,
protocolpooltypes.ModuleName, // Must be exported before bank
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
epochstypes.ModuleName,
}

defaultInterfaceRegistryOptions = types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
},
},
}
)
Loading
Loading