Skip to content

Commit 7f4daee

Browse files
committed
Merge branch 'main' into roman/backport-wasmd-upgrade
2 parents 7bb0d05 + 4bf3099 commit 7f4daee

29 files changed

+1879
-97
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ EXPOSE 26657
3535
EXPOSE 1317
3636

3737
ENTRYPOINT ["osmosisd"]
38-
CMD [ "start" ]
38+
CMD [ "start" ]

app/ante.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/cosmos/cosmos-sdk/x/auth/signing"
1313

1414
osmoante "github.com/osmosis-labs/osmosis/v7/ante"
15+
16+
v8 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v8"
1517
txfeeskeeper "github.com/osmosis-labs/osmosis/v7/x/txfees/keeper"
1618
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"
1719
)
@@ -40,6 +42,7 @@ func NewAnteHandler(
4042
wasmkeeper.NewLimitSimulationGasDecorator(wasmConfig.SimulationGasLimit),
4143
wasmkeeper.NewCountTXDecorator(txCounterStoreKey),
4244
ante.NewRejectExtensionOptionsDecorator(),
45+
v8.MsgFilterDecorator{},
4346
// Use Mempool Fee Decorator from our txfees module instead of default one from auth
4447
// https://github.com/cosmos/cosmos-sdk/blob/master/x/auth/middleware/fee.go#L34
4548
mempoolFeeDecorator,

app/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
v5 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v5"
4848
v6 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v6"
4949
v7 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v7"
50+
v8 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v8"
5051
v9 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v9"
5152
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"
5253
)
@@ -86,7 +87,7 @@ var (
8687
_ App = (*OsmosisApp)(nil)
8788

8889
Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade}
89-
Forks = []upgrades.Fork{v3.Fork, v6.Fork}
90+
Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork}
9091
)
9192

9293
// GetWasmEnabledProposals parses the WasmProposalsEnabled and

app/keepers/keepers.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,9 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
262262
)
263263

264264
appKeepers.SuperfluidKeeper = superfluidkeeper.NewKeeper(
265-
appCodec,
266-
appKeepers.keys[superfluidtypes.StoreKey],
267-
appKeepers.GetSubspace(superfluidtypes.ModuleName),
268-
*appKeepers.AccountKeeper,
269-
appKeepers.BankKeeper,
270-
appKeepers.StakingKeeper,
271-
appKeepers.DistrKeeper,
272-
appKeepers.EpochsKeeper,
273-
appKeepers.LockupKeeper,
274-
gammKeeper,
275-
appKeepers.IncentivesKeeper,
276-
lockupkeeper.NewMsgServerImpl(appKeepers.LockupKeeper),
277-
)
265+
appCodec, appKeepers.keys[superfluidtypes.StoreKey], appKeepers.GetSubspace(superfluidtypes.ModuleName),
266+
*appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.StakingKeeper, appKeepers.DistrKeeper, appKeepers.EpochsKeeper, appKeepers.LockupKeeper, appKeepers.GAMMKeeper, appKeepers.IncentivesKeeper,
267+
lockupkeeper.NewMsgServerImpl(appKeepers.LockupKeeper))
278268

279269
mintKeeper := mintkeeper.NewKeeper(
280270
appCodec,

app/upgrades/v8/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# V8 Upgrade
2+
3+
The v8 upgrade is an emergency upgrade coordinated according to osmosis governance proposals [225](https://www.mintscan.io/osmosis/proposals/225), [226](https://www.mintscan.io/osmosis/proposals/226). And thus by implication of 225, incentive proposals [222](https://www.mintscan.io/osmosis/proposals/222), [223](https://www.mintscan.io/osmosis/proposals/223), and [224](https://www.mintscan.io/osmosis/proposals/224).
4+
5+
## Adjusting Incentives for 222, 223, 224
6+
Like the weekly Gauge Weight updates, the implementations for these proposals simply modify the weights of gauges between pools in the Upgrade:
7+
8+
* `ApplyProp222Change`
9+
* `ApplyProp223Change`
10+
* `ApplyProp224Change`
11+
12+
The specification of Minimum and Maximum values will be applied to the spreadsheet that is shared in each Weekly update.
13+
14+
## UnPoolWhitelistedPool for 226
15+
The implementation of 226 will introduce a new method for unpooling:
16+
17+
`UnPoolWhitelistedPool`
18+
19+
Let's review the states a position in a pool may be to be able to understand the unpooling process better. Coins are pooled together to form shares of a GAMM. These may be locked for a period of time, to receive addtional incentives. Finally, locked tokens may enter into Superfluid Delegations.
20+
21+
```sh
22+
┌─────────────────────────┐ ┌─────────────────────────┐
23+
│ sdk.Coin │ │ sdk.Coin │
24+
│ Denom: UST │ │ Denom: uOSMO │
25+
│ Amount: 5.647 │ │ Amount: 1 │
26+
└───────────┬─────────────┘ └───────────┬─────────────┘
27+
│ │
28+
┌───────────▼─────────────────────────────▼─────────────┐
29+
JoinPool() │
30+
└───────────────────────────┬───────────────────────────┘
31+
32+
┌────────────▼────────────┐
33+
│ sdk.Coin │
34+
│ Denom: GAMM │
35+
│ Amount: 100000 │
36+
└────────────┬────────────┘
37+
38+
┌───────────────────────────▼───────────────────────────┐
39+
LockTokens() │
40+
└───────────────────────────┬───────────────────────────┘
41+
42+
┌────────────▼────────────┐
43+
│ types.PeriodLock │
44+
└────────────┬────────────┘
45+
46+
┌───────────────────────────▼───────────────────────────┐
47+
SuperfluidDelegate() │
48+
└───────────────────────────┬───────────────────────────┘
49+
50+
┌────────────▼────────────┐
51+
│ types.SuperfluidAsset │
52+
└─────────────────────────┘
53+
54+
```
55+
### Unpooling Steps
56+
To unpool, we'll need to carefully consider each of these concepts above. For instance, a user may have already begun unbonding.
57+
58+
We will start with the most deeply locked assets, and iteratively unroll them until we end up with individual sdk.Coin entities, some of which may be locked.
59+
60+
In the code, the following comment block may be found:
61+
```sh
62+
// 0) Check if its for a whitelisted unpooling poolID
63+
// 1) Consistency check that lockID corresponds to sender, and contains correct LP shares. (Should also be validated by caller)
64+
// 2) Get remaining duration on the lock.
65+
// 3) If superfluid delegated, superfluid undelegate
66+
// 4) Break underlying lock. This will clear any metadata if things are superfluid unbonding
67+
// 5) ExitPool with these unlocked LP shares
68+
// 6) Make 1 new lock for every asset in collateral. Many code paths need this assumption to hold
69+
// 7) Make new lock begin unlocking
70+
```

app/upgrades/v8/constants.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package v8
2+
3+
import (
4+
"github.com/osmosis-labs/osmosis/v7/app/upgrades"
5+
v8constants "github.com/osmosis-labs/osmosis/v7/app/upgrades/v8/constants"
6+
)
7+
8+
const (
9+
// UpgradeName defines the on-chain upgrade name for the Osmosis v8 upgrade.
10+
UpgradeName = v8constants.UpgradeName
11+
12+
// UpgradeHeight defines the block height at which the Osmosis v8 upgrade is
13+
// triggered.
14+
UpgradeHeight = v8constants.UpgradeHeight
15+
)
16+
17+
var Fork = upgrades.Fork{
18+
UpgradeName: UpgradeName,
19+
UpgradeHeight: UpgradeHeight,
20+
BeginForkLogic: RunForkLogic,
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// package v8constants contains constants related to the v8 upgrade.
2+
// It is in its own package to eliminate import cycle issues.
3+
package v8constants
4+
5+
const (
6+
// UpgradeName defines the on-chain upgrade name for the Osmosis v8 upgrade.
7+
UpgradeName = "v8"
8+
9+
// UpgradeHeight defines the block height at which the Osmosis v8 upgrade is
10+
// triggered.
11+
// Block height 4_402_000, approximately 4PM UTC, May 15th
12+
UpgradeHeight = 4402000
13+
)

app/upgrades/v8/forks.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package v8
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
6+
"github.com/osmosis-labs/osmosis/v7/app/keepers"
7+
)
8+
9+
// RunForkLogic executes height-gated on-chain fork logic for the Osmosis v8
10+
// upgrade.
11+
func RunForkLogic(ctx sdk.Context, appKeepers *keepers.AppKeepers) {
12+
for i := 0; i < 100; i++ {
13+
ctx.Logger().Info("I am upgrading to v8")
14+
}
15+
ctx.Logger().Info("Applying Osmosis v8 upgrade. Allowing direct unpooling for whitelisted pools")
16+
ctx.Logger().Info("Applying accelerated incentive updates per proposal 225")
17+
ApplyProp222Change(ctx, appKeepers.PoolIncentivesKeeper)
18+
ApplyProp223Change(ctx, appKeepers.PoolIncentivesKeeper)
19+
ApplyProp224Change(ctx, appKeepers.PoolIncentivesKeeper)
20+
ctx.Logger().Info("Registering state change for whitelisted pools for unpooling ")
21+
RegisterWhitelistedDirectUnbondPools(ctx, appKeepers.SuperfluidKeeper, appKeepers.GAMMKeeper)
22+
}

app/upgrades/v8/incentive_props.go

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package v8
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
"github.com/osmosis-labs/osmosis/v7/osmoutils"
6+
poolincentiveskeeper "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/keeper"
7+
poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"
8+
)
9+
10+
// This file implements logic for accelerated incentive proposals.
11+
12+
// This function is common to all the props,
13+
// executing the equivalent result of the "UpdatePoolIncentives" proposals, inside of this upgrade logic.
14+
func applyPoolIncentivesUpdate(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper, records []poolincentivestypes.DistrRecord) {
15+
// Notice that the pool incentives update proposal code, just calls UpdateDistrRecords:
16+
// https://github.com/osmosis-labs/osmosis/blob/v7.3.0/x/pool-incentives/keeper/gov.go#L13-L15
17+
// And that p.Records is the field output by the gov queries.
18+
19+
// If error, undo state update, log, and proceed. We don't want to stop the entire upgrade due to
20+
// an unexpected error here.
21+
_ = osmoutils.ApplyFuncIfNoError(ctx, func(wrappedCtx sdk.Context) error {
22+
err := poolincentiveskeeper.UpdateDistrRecords(wrappedCtx, records...)
23+
if err != nil {
24+
ctx.Logger().Error("Something has happened, prop update did not apply. Continuing to proceed with other components of the upgrade.")
25+
}
26+
return err
27+
})
28+
}
29+
30+
// Apply prop 222 change
31+
func ApplyProp222Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) {
32+
// Pool records obtained right off proposal
33+
// osmosisd q gov proposal 222
34+
// records:
35+
// - gauge_id: "1718"
36+
// weight: "9138119"
37+
// - gauge_id: "1719"
38+
// weight: "5482871"
39+
// - gauge_id: "1720"
40+
// weight: "3655247"
41+
// - gauge_id: "2965"
42+
// weight: "9138119"
43+
// - gauge_id: "2966"
44+
// weight: "5482872"
45+
// - gauge_id: "2967"
46+
// weight: "3655248"
47+
// _PLEASE_ double check these numbers, and double the check the proposals choice itself
48+
records := []poolincentivestypes.DistrRecord{
49+
{GaugeId: 1718, Weight: sdk.NewInt(9138119)},
50+
{GaugeId: 1719, Weight: sdk.NewInt(5482871)},
51+
{GaugeId: 1720, Weight: sdk.NewInt(3655247)},
52+
{GaugeId: 2965, Weight: sdk.NewInt(9138119)},
53+
{GaugeId: 2966, Weight: sdk.NewInt(5482872)},
54+
{GaugeId: 2967, Weight: sdk.NewInt(3655248)},
55+
}
56+
57+
ctx.Logger().Info("Applying proposal 222 update")
58+
applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records)
59+
}
60+
61+
// Apply prop 223 change
62+
func ApplyProp223Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) {
63+
// Pool records obtained right off proposal
64+
// osmosisd q gov proposal 223
65+
// records:
66+
// - gauge_id: "1721"
67+
// weight: "2831977"
68+
// - gauge_id: "1722"
69+
// weight: "1699186"
70+
// - gauge_id: "1723"
71+
// weight: "1132791"
72+
// - gauge_id: "3383"
73+
// weight: "2831978"
74+
// - gauge_id: "3384"
75+
// weight: "1699187"
76+
// - gauge_id: "3385"
77+
// weight: "1132791"
78+
79+
// _PLEASE_ double check these numbers, and double the check the proposals choice itself
80+
records := []poolincentivestypes.DistrRecord{
81+
{GaugeId: 1721, Weight: sdk.NewInt(2831977)},
82+
{GaugeId: 1722, Weight: sdk.NewInt(1699186)},
83+
{GaugeId: 1723, Weight: sdk.NewInt(1132791)},
84+
{GaugeId: 3383, Weight: sdk.NewInt(2831978)},
85+
{GaugeId: 3384, Weight: sdk.NewInt(1699187)},
86+
{GaugeId: 3385, Weight: sdk.NewInt(1132791)},
87+
}
88+
89+
ctx.Logger().Info("Applying proposal 223 update")
90+
applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records)
91+
}
92+
93+
// Apply prop 224 change
94+
func ApplyProp224Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) {
95+
// Pool records obtained right off proposal
96+
// osmosisd q gov proposal 224
97+
// records:
98+
// - gauge_id: "1724"
99+
// weight: "1881159"
100+
// - gauge_id: "1725"
101+
// weight: "1128695"
102+
// - gauge_id: "1726"
103+
// weight: "752463"
104+
// - gauge_id: "2949"
105+
// weight: "1881160"
106+
// - gauge_id: "2950"
107+
// weight: "1128696"
108+
// - gauge_id: "2951"
109+
// weight: "752464"
110+
// _PLEASE_ double check these numbers, and double the check the proposals choice itself
111+
records := []poolincentivestypes.DistrRecord{
112+
{GaugeId: 1724, Weight: sdk.NewInt(1881159)},
113+
{GaugeId: 1725, Weight: sdk.NewInt(1128695)},
114+
{GaugeId: 1726, Weight: sdk.NewInt(752463)},
115+
{GaugeId: 2949, Weight: sdk.NewInt(1881160)},
116+
{GaugeId: 2950, Weight: sdk.NewInt(1128696)},
117+
{GaugeId: 2951, Weight: sdk.NewInt(752464)},
118+
}
119+
120+
ctx.Logger().Info("Applying proposal 224 update")
121+
applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records)
122+
}

app/upgrades/v8/msg_filter_ante.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package v8
2+
3+
import (
4+
"fmt"
5+
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types"
8+
)
9+
10+
// MsgFilterDecorator defines an AnteHandler decorator for the v8 upgrade that
11+
// provide height-gated message filtering acceptance.
12+
type MsgFilterDecorator struct{}
13+
14+
// AnteHandle performs an AnteHandler check that returns an error if the current
15+
// block height is less than the v8 upgrade height and contains messages that are
16+
// not supported until the upgrade height is reached.
17+
func (mfd MsgFilterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
18+
currHeight := ctx.BlockHeight()
19+
20+
if currHeight < UpgradeHeight && hasInvalidMsgs(tx.GetMsgs()) {
21+
return ctx, fmt.Errorf("tx contains unsupported message types at height %d", currHeight)
22+
}
23+
24+
return next(ctx, tx, simulate)
25+
}
26+
27+
func hasInvalidMsgs(msgs []sdk.Msg) bool {
28+
for _, msg := range msgs {
29+
switch msg.(type) {
30+
case *superfluidtypes.MsgUnPoolWhitelistedPool:
31+
return true
32+
}
33+
}
34+
35+
return false
36+
}

0 commit comments

Comments
 (0)