diff --git a/app/ante/ante.go b/app/ante/ante.go index 42460940..814bbc4e 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -59,6 +59,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { anteDecorators := []sdk.AnteDecorator{ auctionDecorator, ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + NewCommunityPoolDecorator(), wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), diff --git a/app/ante/custom_ante.go b/app/ante/custom_ante.go new file mode 100644 index 00000000..9d72ce2c --- /dev/null +++ b/app/ante/custom_ante.go @@ -0,0 +1,40 @@ +package ante + +import ( + "fmt" + "time" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/distribution/types" +) + +type CommunityPoolDecorator struct { + futureBlockTime time.Time + msgCommunityPoolSpend string +} + +func NewCommunityPoolDecorator() CommunityPoolDecorator { + return CommunityPoolDecorator{ + futureBlockTime: time.Date(2025, 1, 1, 0, 0, 0, 0, time.Local), + msgCommunityPoolSpend: sdk.MsgTypeURL(&types.MsgCommunityPoolSpend{}), + } +} + +func (d CommunityPoolDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + // Compare block time to be before 2025 + if ctx.BlockTime().Before(d.futureBlockTime) { + // Iterate the tx messages + for _, msg := range tx.GetMsgs() { + // check if the msg is a MsgFundCommunityPool + msgType := sdk.MsgTypeURL(msg) + + if msgType == d.msgCommunityPoolSpend { + message := fmt.Sprintf("%s is blocked until the future blocktime %s", d.msgCommunityPoolSpend, d.futureBlockTime) + return ctx, sdkerrors.Register(types.ModuleName, 999, message) + } + } + } + + return next(newCtx, tx, simulate) +} diff --git a/app/app.go b/app/app.go index 3b6cc5c8..50677ecc 100644 --- a/app/app.go +++ b/app/app.go @@ -165,6 +165,7 @@ import ( v2_3_0 "github.com/terra-money/core/v2/app/upgrades/v2.3.0" v2_4 "github.com/terra-money/core/v2/app/upgrades/v2.4" v2_5 "github.com/terra-money/core/v2/app/upgrades/v2.5" + v2_6 "github.com/terra-money/core/v2/app/upgrades/v2.6" // unnamed import of statik for swagger UI support _ "github.com/terra-money/core/v2/client/docs/statik" @@ -1165,6 +1166,14 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) { app.AccountKeeper, ), ) + app.UpgradeKeeper.SetUpgradeHandler( + terraappconfig.Upgrade2_6, + v2_6.CreateUpgradeHandler(app.mm, + app.configurator, + app.appCodec, + app.IBCKeeper.ClientKeeper, + ), + ) } // RegisterSwaggerAPI registers swagger route with API Server diff --git a/app/config/const.go b/app/config/const.go index cbd314fd..849e5554 100644 --- a/app/config/const.go +++ b/app/config/const.go @@ -52,4 +52,5 @@ const ( Upgrade2_4_rc = "2.4.0-rc4" // This is pisco only since an incorrect plan name was used for the upgrade Upgrade2_4 = "v2.4" Upgrade2_5 = "v2.5" + Upgrade2_6 = "v2.6" ) diff --git a/app/upgrades/v2.6/upgrade.go b/app/upgrades/v2.6/upgrade.go new file mode 100644 index 00000000..ff3807fa --- /dev/null +++ b/app/upgrades/v2.6/upgrade.go @@ -0,0 +1,67 @@ +package v2_6 + +import ( + "time" + + sdkerrors "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" +) + +func CreateUpgradeHandler( + mm *module.Manager, + cfg module.Configurator, + cdc codec.Codec, + clientKeeper clientkeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + err := increaseUnbondingPeriod(ctx, cdc, clientKeeper) + if err != nil { + return nil, err + } + return mm.RunMigrations(ctx, cfg, fromVM) + } +} + +// Iterate all IBC clients and increase unbonding period for all atlantic-2 clients +func increaseUnbondingPeriod(ctx sdk.Context, cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) error { + var clientIDs []string + clientKeeper.IterateClientStates(ctx, []byte(ibcexported.Tendermint), func(clientID string, _ ibcexported.ClientState) bool { + clientIDs = append(clientIDs, clientID) + return false + }) + + var totalUpdated int + + for _, clientID := range clientIDs { + clientState, ok := clientKeeper.GetClientState(ctx, clientID) + if !ok { + return sdkerrors.Wrapf(ibcclienttypes.ErrClientNotFound, "clientID %s", clientID) + } + + tmClientState, ok := clientState.(*ibctm.ClientState) + if !ok { + return sdkerrors.Wrap(ibcclienttypes.ErrInvalidClient, "client state is not tendermint even though client id contains 07-tendermint") + } + + // ATLANTIC 2 blockchain changed the unbonding period on their side, + // we take advantage of having to upgrade the chain to also increase + // the unbonding priod on our side. + if tmClientState.GetChainID() == "atlantic-2" { + tmClientState.UnbondingPeriod = time.Hour * 24 * 21 + + clientKeeper.SetClientState(ctx, clientID, tmClientState) + } + } + + clientLogger := clientKeeper.Logger(ctx) + clientLogger.Info("total ibc clients updated: ", totalUpdated) + + return nil +} diff --git a/client/docs/config.json b/client/docs/config.json index 5ddec10e..8998d459 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "Source code for Terra Core v2.5
UI to interact with the blockchain Station
Create a DAO on Terra using Enterprise
Run on-chain automted jobs Wrap
Explore the network using TerraScope
Anything you need to know about shared security on Alliance Docs
More info about the protocol on Terra Docs", + "description": "Source code for Terra Core v2.6
UI to interact with the blockchain Station
Create a DAO on Terra using Enterprise
Run on-chain automted jobs Wrap
Explore the network using TerraScope
Anything you need to know about shared security on Alliance Docs
More info about the protocol on Terra Docs", "version": "2.5" }, "apis": [ diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 8f68f181..334727ab 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -2,7 +2,7 @@ swagger: '2.0' info: description: >- Source code for Terra Core v2.5
UI to + href='https://github.com/terra-money/core'>Terra Core v2.6
UI to interact with the blockchain Station
Create a DAO on Terra using