-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): Import Fork of Osmosis (#252)
Co-authored-by: Inon Man <121477599+inon-man@users.noreply.github.com> (cherry picked from commit 9d73c0d)
- Loading branch information
1 parent
cb67db4
commit 38f351e
Showing
24 changed files
with
322 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package app | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// BeginBlockForks is intended to be ran in a chain upgrade. | ||
func BeginBlockForks(ctx sdk.Context, app *TerraApp) { | ||
for _, fork := range Forks { | ||
if ctx.BlockHeight() == fork.UpgradeHeight { | ||
fork.BeginForkLogic(ctx, &app.AppKeepers, app.mm) | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Classic Terra Upgrades | ||
|
||
This folder contains sub-folders for every classic terra upgrade. (Both state | ||
migrations, and hard forks) It also defines upgrade & hard fork structs, | ||
that each upgrade implements. These then get included in the application | ||
app.go to run the upgrade. | ||
|
||
## Upgrade History | ||
### v1 (core v1.0.x) | ||
__NOTE__: initial version without upgrade handler | ||
* (soft-fork) v0.5.20 - Disable swap and IBC [#760](https://github.com/terra-money/classic-core/pull/760) | ||
* (soft-fork) v0.5.21 - Burn Tax and allow Luna to be taxed | ||
* (soft-fork) v0.5.22 - Limit validator power to 20% [cosmos-sdk/pull/104](https://github.com/terra-money/cosmos-sdk/pull/104) | ||
* (soft-fork) v0.5.23 - Enable IBC | ||
* (soft-fork) v1.0.5 - Set module version map for enabling software upgrades | ||
### v2 (core v1.1.x) | ||
* (treasury) Tax exemption list, burn tax split | ||
### v3 (core v2.0.x) | ||
* (treasury) Minimum initial deposit for governance proposals | ||
### v4 (core v2.1.x) | ||
* (staking) Minimum commision rate | ||
|
||
## Upgrade types | ||
|
||
There are two upgrade types exposed, `Upgrade` and `Fork`. An `Upgrade` | ||
defines an upgrade that is to be acted upon by state migrations from the | ||
SDK `x/upgrade` module. A `Fork` defines a hard fork that changes some | ||
logic at a block height. If the goal is to have a new binary be | ||
compatible with the old binary prior to the upgrade height, as is the | ||
case for all classic terra `Fork`s, then all logic changes must be | ||
height-gated or in the `BeginForkLogic` code. | ||
|
||
```go | ||
type Upgrade struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v7` | ||
UpgradeName string | ||
// Function that creates an upgrade handler | ||
CreateUpgradeHandler func(mm *module.Manager, configurator module.Configurator, keepers *keepers.AppKeepers) upgradetypes.UpgradeHandler | ||
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. | ||
StoreUpgrades store.StoreUpgrades | ||
} | ||
|
||
type Fork struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v7` | ||
UpgradeName string | ||
// height the upgrade occurs at | ||
UpgradeHeight int64 | ||
|
||
// Function that runs some custom state transition code at the beginning of a fork. | ||
BeginForkLogic func(ctx sdk.Context, keppers *keepers.AppKeepers, mm *module.Manager) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/classic-terra/core/v2/app/upgrades" | ||
"github.com/classic-terra/core/v2/types/fork" | ||
) | ||
|
||
var DisableSwapFork = upgrades.Fork{ | ||
UpgradeName: "v0.5.20", | ||
UpgradeHeight: fork.SwapDisableHeight, | ||
BeginForkLogic: runForkLogicSwapDisable, | ||
} | ||
|
||
var IbcEnableFork = upgrades.Fork{ | ||
UpgradeName: "v0.5.23", | ||
UpgradeHeight: fork.IbcEnableHeight, | ||
BeginForkLogic: runForkLogicIbcEnable, | ||
} | ||
|
||
var VersionMapEnableFork = upgrades.Fork{ | ||
UpgradeName: "v1.0.5", | ||
UpgradeHeight: fork.VersionMapEnableHeight, | ||
BeginForkLogic: runForkLogicVersionMapEnable, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/classic-terra/core/v2/app/keepers" | ||
core "github.com/classic-terra/core/v2/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" | ||
ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" | ||
) | ||
|
||
func runForkLogicSwapDisable(ctx sdk.Context, keppers *keepers.AppKeepers, _ *module.Manager) { | ||
if ctx.ChainID() == core.ColumbusChainID { | ||
// Make min spread to 100% to disable swap | ||
params := keppers.MarketKeeper.GetParams(ctx) | ||
params.MinStabilitySpread = sdk.OneDec() | ||
keppers.MarketKeeper.SetParams(ctx, params) | ||
|
||
// Disable IBC Channels | ||
channelIDs := []string{ | ||
"channel-1", // Osmosis | ||
"channel-49", // Crescent | ||
"channel-20", // Juno | ||
} | ||
for _, channelID := range channelIDs { | ||
channel, found := keppers.IBCKeeper.ChannelKeeper.GetChannel(ctx, ibctransfertypes.PortID, channelID) | ||
if !found { | ||
panic(fmt.Sprintf("%s not found", channelID)) | ||
} | ||
|
||
channel.State = ibcchanneltypes.CLOSED | ||
keppers.IBCKeeper.ChannelKeeper.SetChannel(ctx, ibctransfertypes.PortID, channelID, channel) | ||
} | ||
} | ||
} | ||
|
||
func runForkLogicIbcEnable(ctx sdk.Context, keppers *keepers.AppKeepers, _ *module.Manager) { | ||
if ctx.ChainID() == core.ColumbusChainID { | ||
// Enable IBC Channels | ||
channelIDs := []string{ | ||
"channel-1", // Osmosis | ||
"channel-49", // Crescent | ||
"channel-20", // Juno | ||
} | ||
for _, channelID := range channelIDs { | ||
channel, found := keppers.IBCKeeper.ChannelKeeper.GetChannel(ctx, ibctransfertypes.PortID, channelID) | ||
if !found { | ||
panic(fmt.Sprintf("%s not found", channelID)) | ||
} | ||
|
||
channel.State = ibcchanneltypes.OPEN | ||
keppers.IBCKeeper.ChannelKeeper.SetChannel(ctx, ibctransfertypes.PortID, channelID, channel) | ||
} | ||
} | ||
} | ||
|
||
func runForkLogicVersionMapEnable(ctx sdk.Context, keppers *keepers.AppKeepers, mm *module.Manager) { | ||
// trigger SetModuleVersionMap in upgrade keeper at the VersionMapEnableHeight | ||
if ctx.ChainID() == core.ColumbusChainID { | ||
keppers.UpgradeKeeper.SetModuleVersionMap(ctx, mm.GetVersionMap()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.