diff --git a/app.go b/app.go index d79b50fc..0982793f 100644 --- a/app.go +++ b/app.go @@ -54,6 +54,7 @@ import ( _ "github.com/monerium/module-noble/v2" _ "github.com/noble-assets/authority" _ "github.com/noble-assets/forwarding/v2/x/forwarding" + "github.com/noble-assets/globalfee" _ "github.com/noble-assets/halo/v2" _ "github.com/ondoprotocol/usdy-noble/v2" @@ -90,6 +91,7 @@ import ( // Noble Modules authoritykeeper "github.com/noble-assets/authority/keeper" forwardingkeeper "github.com/noble-assets/forwarding/v2/x/forwarding/keeper" + globalfeekeeper "github.com/noble-assets/globalfee/keeper" ) var DefaultNodeHome string @@ -140,6 +142,7 @@ type App struct { // Noble Modules AuthorityKeeper *authoritykeeper.Keeper ForwardingKeeper *forwardingkeeper.Keeper + GlobalFeeKeeper *globalfeekeeper.Keeper } func init() { @@ -215,6 +218,7 @@ func NewApp( // Noble Modules &app.AuthorityKeeper, &app.ForwardingKeeper, + &app.GlobalFeeKeeper, ); err != nil { return nil, err } @@ -231,6 +235,7 @@ func NewApp( BankKeeper: app.BankKeeper, FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: app.txConfig.SignModeHandler(), + TxFeeChecker: globalfee.TxFeeChecker(app.GlobalFeeKeeper), }, cdc: app.appCodec, FTFKeeper: app.FTFKeeper, @@ -288,6 +293,7 @@ func (app *App) RegisterUpgradeHandler() error { app.ModuleManager, app.Configurator(), app.appCodec, + app.interfaceRegistry, app.Logger(), app.GetKey(capabilitytypes.StoreKey), app.AccountKeeper, @@ -296,6 +302,7 @@ func (app *App) RegisterUpgradeHandler() error { app.CapabilityKeeper, app.IBCKeeper.ClientKeeper, app.ConsensusKeeper, + app.GlobalFeeKeeper, app.ParamsKeeper, app.StakingKeeper, ), diff --git a/app.yaml b/app.yaml index 962f3075..c68041ea 100644 --- a/app.yaml +++ b/app.yaml @@ -6,7 +6,7 @@ modules: pre_blockers: [ upgrade ] begin_blockers: [ capability, authority, slashing, evidence, staking, ibc, authz ] end_blockers: [ crisis, staking, feegrant, forwarding ] - init_genesis: [ capability, transfer, auth, bank, staking, slashing, crisis, fiat-tokenfactory, genutil, ibc, interchainaccounts, packetfowardmiddleware, evidence, authz, feegrant, params, upgrade, vesting, cctp, forwarding, aura, halo, florin, authority ] + init_genesis: [ capability, transfer, auth, bank, staking, slashing, crisis, fiat-tokenfactory, globalfee, genutil, ibc, interchainaccounts, packetfowardmiddleware, evidence, authz, feegrant, params, upgrade, vesting, cctp, forwarding, aura, halo, florin, authority ] override_store_keys: - module_name: auth kv_store_key: acc @@ -118,3 +118,7 @@ modules: config: "@type": noble.forwarding.module.v1.Module authority: authority # Utilize our custom x/authority module. + - name: globalfee + config: + "@type": noble.globalfee.module.v1.Module + authority: authority # Utilize our custom x/authority module. diff --git a/go.mod b/go.mod index 6205de5b..22545695 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/monerium/module-noble/v2 v2.0.0-rc.3.0.20241009233532-f2109c84b6c1 github.com/noble-assets/authority v1.0.0-rc.0 github.com/noble-assets/forwarding/v2 v2.0.0-20241017154500-56685530d602 + github.com/noble-assets/globalfee v1.0.0-rc.0 github.com/noble-assets/halo/v2 v2.0.0-20240928083543-bd3392537219 github.com/ondoprotocol/usdy-noble/v2 v2.0.0-20241008190859-099f72833941 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index e30d87ff..7d3cac0b 100644 --- a/go.sum +++ b/go.sum @@ -1090,6 +1090,8 @@ github.com/noble-assets/authority v1.0.0-rc.0 h1:mrMhEK3+F2lNRMGJalydAt0gTEK+WGt github.com/noble-assets/authority v1.0.0-rc.0/go.mod h1:AyCyM1iP73dHxBsulw0GpZNgPIQvSndWp30pK87nmog= github.com/noble-assets/forwarding/v2 v2.0.0-20241017154500-56685530d602 h1:yNN1TU1qSAWfWUZBBVK2qQgVoKG4z/Q4JuUXgzyQUcE= github.com/noble-assets/forwarding/v2 v2.0.0-20241017154500-56685530d602/go.mod h1:OGbKgjHf/4HHthbilK9RCPsBXUS40LFxRl4cAcNhqwk= +github.com/noble-assets/globalfee v1.0.0-rc.0 h1:O1+XpEBe9eaSaZhgO5+G9NDyThL87xp1nANXcqoxzg8= +github.com/noble-assets/globalfee v1.0.0-rc.0/go.mod h1:DmNoTJ2LqGP4KpJuz+IEKp/5uf/3hRu3GSNBGhNUZkA= github.com/noble-assets/halo/v2 v2.0.0-20240928083543-bd3392537219 h1:kFPNHaKQ6L6FY/qcXVe5guZnBmpbx1YVApyxywMSpAs= github.com/noble-assets/halo/v2 v2.0.0-20240928083543-bd3392537219/go.mod h1:DY4GCfZ/7S3IEjoJBCCh7HRTxirPBOLMVwkT0N6n3bA= github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbnVSxfHJk= diff --git a/go.work.sum b/go.work.sum index 8f714c0b..c757d1fe 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1486,6 +1486,7 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/nishanths/exhaustive v0.9.5/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA= github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= +github.com/noble-assets/globalfee v1.0.0-rc.0/go.mod h1:DmNoTJ2LqGP4KpJuz+IEKp/5uf/3hRu3GSNBGhNUZkA= github.com/noble-assets/halo v1.0.1 h1:Fndy4JaAAvEd5SDGECnkoWJ2uVG1XCF47L67Px9ickE= github.com/nunnatsa/ginkgolinter v0.9.0/go.mod h1:FHaMLURXP7qImeH6bvxWJUpyH+2tuqe5j4rW1gxJRmI= github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= diff --git a/upgrade/store.go b/upgrade/store.go index 97074e32..dcb1b9fd 100644 --- a/upgrade/store.go +++ b/upgrade/store.go @@ -21,6 +21,7 @@ import ( consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" authoritytypes "github.com/noble-assets/authority/types" + globalfeetypes "github.com/noble-assets/globalfee/types" ) func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader { @@ -31,6 +32,7 @@ func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader { crisistypes.StoreKey, // Noble Modules authoritytypes.ModuleName, + globalfeetypes.ModuleName, }, } diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index eeecb4eb..5383332e 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -16,6 +16,8 @@ package upgrade import ( "context" + "sort" + "strings" "cosmossdk.io/errors" "cosmossdk.io/log" @@ -24,6 +26,7 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -43,16 +46,21 @@ import ( v6 "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6" icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" authoritykeeper "github.com/noble-assets/authority/keeper" authoritytypes "github.com/noble-assets/authority/types" + globalfeekeeper "github.com/noble-assets/globalfee/keeper" + globalfeetypes "github.com/noble-assets/globalfee/types" ) func CreateUpgradeHandler( mm *module.Manager, cfg module.Configurator, cdc codec.Codec, + registry codectypes.InterfaceRegistry, logger log.Logger, capabilityStoreKey *storetypes.KVStoreKey, accountKeeper authkeeper.AccountKeeper, @@ -61,6 +69,7 @@ func CreateUpgradeHandler( capabilityKeeper *capabilitykeeper.Keeper, clientKeeper clientkeeper.Keeper, consensusKeeper consensuskeeper.Keeper, + globalFeeKeeper *globalfeekeeper.Keeper, paramsKeeper paramskeeper.Keeper, stakingKeeper *stakingkeeper.Keeper, ) upgradetypes.UpgradeHandler { @@ -84,7 +93,8 @@ func CreateUpgradeHandler( keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck case stakingtypes.ModuleName: keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck - + case globalfeetypes.ModuleName: + keyTable = globalfeetypes.ParamKeyTable() //nolint:staticcheck } if !subspace.HasKeyTable() { @@ -139,12 +149,42 @@ func CreateUpgradeHandler( var authority string subspace = paramsKeeper.Subspace(paramstypes.ModuleName).WithKeyTable(authoritytypes.ParamKeyTable()) //nolint:staticcheck subspace.Get(sdkCtx, authoritytypes.AuthorityKey, &authority) + err = authorityKeeper.Owner.Set(ctx, authority) if err != nil { return vm, errors.Wrap(err, "failed to migrate authority address") } + // Override migrated list of bypass messages, ensuring that IBC relaying + // remains free, and enable all current asset issuers (Circle, Ondo, + // Hashnote, and Monerium) to interact with the protocol for free. + bypassMessages := []string{ + sdk.MsgTypeURL(&clienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&channeltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&channeltypes.MsgTimeout{}), + sdk.MsgTypeURL(&channeltypes.MsgAcknowledgement{}), + } + bypassMessages = append(bypassMessages, GetModuleMessages(registry, "circle")...) + bypassMessages = append(bypassMessages, GetModuleMessages(registry, "aura")...) + bypassMessages = append(bypassMessages, GetModuleMessages(registry, "halo")...) + bypassMessages = append(bypassMessages, GetModuleMessages(registry, "florin")...) + sort.Strings(bypassMessages) + + err = globalFeeKeeper.BypassMessages.Clear(ctx, nil) + if err != nil { + return vm, err + } + for _, bypassMessage := range bypassMessages { + err = globalFeeKeeper.BypassMessages.Set(ctx, bypassMessage) + if err != nil { + return vm, err + } + } + + // Migrate validator accounts to permanently locked vesting. MigrateValidatorAccounts(ctx, accountKeeper, stakingKeeper) + + // Safely burn surplus staking token supply. err = BurnSurplusSupply(ctx, authority, accountKeeper, bankKeeper) if err != nil { return vm, err @@ -214,3 +254,15 @@ func BurnSurplusSupply(ctx context.Context, authority string, accountKeeper auth err = bankKeeper.BurnCoins(ctx, upgradetypes.ModuleName, sdk.NewCoins(surplus)) return err } + +// GetModuleMessages is a utility that returns all messages registered by a module. +func GetModuleMessages(registry codectypes.InterfaceRegistry, name string) (messages []string) { + for _, message := range registry.ListImplementations(sdk.MsgInterfaceProtoName) { + if strings.HasPrefix(message, "/"+name) { + messages = append(messages, message) + } + } + + sort.Strings(messages) + return +}