Skip to content

Commit

Permalink
Merge branch 'main' into nv/block-sdk-v25-upgrade-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddyMc committed Apr 15, 2024
2 parents 329bf60 + fe4f0c6 commit be8d828
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### State Breaking

<<<<<<< HEAD
* [#7935](https://github.com/osmosis-labs/osmosis/pull/7935) Add block sdk and top of block auction from skip-mev :handshake:
=======
* [#8030](https://github.com/osmosis-labs/osmosis/pull/8030) Delete legacy behavior where lockups could not unbond at very small block heights on a testnet.
>>>>>>> main
### State Compatible

Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v24/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func CreateUpgradeHandler(
// Now that the TWAP keys are refactored, we can delete all time indexed TWAPs
// since we only need the pool indexed TWAPs. We set the is pruning store value to true
// and spread the pruning time across multiple blocks to avoid a single block taking too long.
keepers.TwapKeeper.SetDeprecatedHistoricalTWAPsIsPruning(ctx)
// keepers.TwapKeeper.SetDeprecatedHistoricalTWAPsIsPruning(ctx)

// Set the new min value for distribution for the incentives module.
// https://www.mintscan.io/osmosis/proposals/733
Expand Down
8 changes: 4 additions & 4 deletions app/upgrades/v24/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ func (s *UpgradeTestSuite) TestUpgrade() {
s.App.EndBlocker(s.Ctx, abci.RequestEndBlock{})

// Since the prune limit was 1, 1 TWAP record indexed by time should be completely removed, leaving one more.
twapRecords, err = osmoutils.GatherValuesFromStorePrefix(store, []byte(HistoricalTWAPTimeIndexPrefix), types.ParseTwapFromBz)
s.Require().NoError(err)
s.Require().Len(twapRecords, 1)
s.Require().Equal(twapRecord2, twapRecords[0])
// twapRecords, err = osmoutils.GatherValuesFromStorePrefix(store, []byte(HistoricalTWAPTimeIndexPrefix), types.ParseTwapFromBz)
// s.Require().NoError(err)
// s.Require().Len(twapRecords, 1)
// s.Require().Equal(twapRecord2, twapRecords[0])

// TWAP records indexed by pool ID should be untouched.
twapRecords, err = s.App.TwapKeeper.GetAllHistoricalPoolIndexedTWAPsForPoolId(s.Ctx, twapRecord1.PoolId)
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/v25/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func CreateUpgradeHandler(
return nil, err
}

keepers.TwapKeeper.DeleteDeprecatedHistoricalTWAPsIsPruning(ctx)

return migrations, nil
}
}
7 changes: 4 additions & 3 deletions cmd/osmosisd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
// If this is not a mainnet node, or the genesis file download failed, generate a new genesis file
if genesisFileDownloadFailed || !isMainnet {
// If the chainID is not blank or genesis file download failed, generate a new genesis file
var genDoc *types.GenesisDoc
var genDoc types.GenesisDoc

appState, err := json.MarshalIndent(mbm.DefaultGenesis(cdc), "", " ")
if err != nil {
Expand All @@ -194,16 +194,17 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
return err
}
} else {
genDoc, err = types.GenesisDocFromFile(genFilePath)
genDocFromFile, err := types.GenesisDocFromFile(genFilePath)
if err != nil {
return errors.Wrap(err, "Failed to read genesis doc from file")
}
genDoc = *genDocFromFile
}

genDoc.ChainID = chainID
genDoc.Validators = nil
genDoc.AppState = appState
if err = genutil.ExportGenesisFile(genDoc, genFilePath); err != nil {
if err = genutil.ExportGenesisFile(&genDoc, genFilePath); err != nil {
return errors.Wrap(err, "Failed to export genesis file")
}

Expand Down
34 changes: 28 additions & 6 deletions cosmwasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/release/create_binaries_json/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
certifi==2023.7.22
charset-normalizer==3.2.0
idna==3.4
idna==3.7
requests==2.31.0
urllib3==2.0.7
2 changes: 1 addition & 1 deletion scripts/release/update_chain_registry/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
certifi==2023.7.22
charset-normalizer==3.2.0
idna==3.4
idna==3.7
requests==2.31.0
urllib3==2.0.7
9 changes: 2 additions & 7 deletions x/lockup/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)

// Called every block to automatically unlock matured locks.
func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate {
// disable automatic withdraw before specific block height
// it is actually for testing with legacy
MinBlockHeightToBeginAutoWithdrawing := int64(6)
if ctx.BlockHeight() < MinBlockHeightToBeginAutoWithdrawing {
return []abci.ValidatorUpdate{}
}

// TODO: Change this logic to "know" when the next unbonding time is, and only unlock at that time.
// At each unbond, do an iterate to find the next unbonding time and wait until then.
// delete synthetic locks matured before lockup deletion
k.DeleteAllMaturedSyntheticLocks(ctx)

Expand Down
6 changes: 0 additions & 6 deletions x/twap/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ func (k Keeper) EndBlock(ctx sdk.Context) {
ctx.Logger().Error("Error pruning old twaps at the end block", err)
}
}

// If we still have more deprecated historical twaps to prune, then we prune up to the per block limit.
// TODO: Can remove this in the v25 upgrade or after.
if k.IsDeprecatedHistoricalTWAPsPruning(ctx) {
k.DeleteHistoricalTimeIndexedTWAPs(ctx)
}
}

// updateRecords updates all records for a given pool id.
Expand Down
14 changes: 4 additions & 10 deletions x/twap/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,10 @@ func (k Keeper) DeleteHistoricalTimeIndexedTWAPs(ctx sdk.Context) {
}
}

// IsDeprecatedHistoricalTWAPsPruning returns whether the deprecated historical twaps are being pruned.
func (k Keeper) IsDeprecatedHistoricalTWAPsPruning(ctx sdk.Context) bool {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.DeprecatedHistoricalTWAPsIsPruningKey)
return bz != nil
}

// SetDeprecatedHistoricalTWAPsIsPruning sets the state entry that determines if we are still
// DeleteDeprecatedHistoricalTWAPsIsPruning the state entry that determines if we are still
// executing pruning logic in the end blocker.
func (k Keeper) SetDeprecatedHistoricalTWAPsIsPruning(ctx sdk.Context) {
// TODO: Remove this in v26
func (k Keeper) DeleteDeprecatedHistoricalTWAPsIsPruning(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
store.Set(types.DeprecatedHistoricalTWAPsIsPruningKey, sentinelExistsValue)
store.Delete(types.DeprecatedHistoricalTWAPsIsPruningKey)
}
3 changes: 2 additions & 1 deletion x/twap/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const (
)

var (
PruningStateKey = []byte{0x01}
PruningStateKey = []byte{0x01}
// TODO: Delete in v26
DeprecatedHistoricalTWAPsIsPruningKey = []byte{0x02}
mostRecentTWAPsNoSeparator = "recent_twap"
historicalTWAPPoolIndexNoSeparator = "historical_pool_index"
Expand Down

0 comments on commit be8d828

Please sign in to comment.