Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: 1830 (commitments CLI), 1831 (force transfer), 1833 (nhash-per-usd-mil), 1835 (transfer agents), 1843 (bid prices), 1846 (restricted coins/fee collector), 1848 (sdk to v0.46.13-pio-3). #1849

Merged
merged 7 commits into from
Feb 22, 2024
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,31 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* In the marker module's `SendRestrictionFn`, allow a transfer agent to be identified through the context [#1834](https://github.com/provenance-io/provenance/issues/1834).
* In the exchange module, provide the admin as the transfer agent when attepting to move funds [#1834](https://github.com/provenance-io/provenance/issues/1834).

### Improvements

* Add an empty `tourmaline-rc2` upgrade handler [#1834](https://github.com/provenance-io/provenance/issues/1834).
* Add new force_transfer access that is required for an account to do a forced transfer ([#1829](https://github.com/provenance-io/provenance/issues/1829)).
* Add exchange commitment stuff to CLI [PR 1830](https://github.com/provenance-io/provenance/pull/1830).
* Update the MsgFees Params to set the nhash per usd-mil to 40,000,000 ($0.025/hash) [#1833](https://github.com/provenance-io/provenance/pull/1833).
* Bid order prices are no longer restricted to amounts that can be evenly applied to a buyer settlement fee ratio [1834](https://github.com/provenance-io/provenance/pull/1843).
* In the marker and exchange modules, help ensure funds don't get sent to blocked addresses [#1834](https://github.com/provenance-io/provenance/issues/1834).
* Update marker and exchange spec docs to include info about transfer agents [#1834](https://github.com/provenance-io/provenance/issues/1834).
* Prevent restricted markers from being sent to the fee collector account [#1845](https://github.com/provenance-io/provenance/issues/1845).

### Bug Fixes

* Prevent funds from going to or from a marker without the transfer agent having deposit or withdraw access (respectively) [#1834](https://github.com/provenance-io/provenance/issues/1834).

### API Breaking

* Accounts that have transfer access in a marker are no longer allowed to do forced transfers ([#1829](https://github.com/provenance-io/provenance/issues/1829)).
Accounts must now have the force_transfer access for that.

### Dependencies

- Bump `codecov/codecov-action` from 3 to 4 ([#1828](https://github.com/provenance-io/provenance/pull/1828))
Expand All @@ -48,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- Bump `serde-json-wasm` from 0.5.1 to 0.5.2 in /testutil/contracts/echo ([#1838](https://github.com/provenance-io/provenance/pull/1838))
- Bump `golangci/golangci-lint-action` from 3 to 4 ([#1840](https://github.com/provenance-io/provenance/pull/1840))
- Bump `google.golang.org/grpc` from 1.61.0 to 1.61.1 ([#1842](https://github.com/provenance-io/provenance/pull/1842))
- Bump `cosmos-sdk` from v0.46.13-pio-2 to v0.46.13-pio-3 ([#1848](https://github.com/provenance-io/provenance/pull/1848))

---

Expand Down
35 changes: 25 additions & 10 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ var upgrades = map[string]appUpgrade{
return vm, nil
},
},
"tourmaline-rc2": {}, // upgrade for v1.18.0-rc2
"tourmaline": { // upgrade for v1.18.0
Added: []string{ibcratelimit.ModuleName},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -144,6 +145,9 @@ var upgrades = map[string]appUpgrade{
removeInactiveValidatorDelegations(ctx, app)
convertNavUnits(ctx, app)

// This isn't in an rc because it was handled via gov prop for testnet.
updateMsgFeesNhashPerMil(ctx, app)

return vm, nil
},
},
Expand Down Expand Up @@ -234,33 +238,33 @@ var _ = runModuleMigrations
// This should be applied in most upgrades.
func removeInactiveValidatorDelegations(ctx sdk.Context, app *App) {
unbondingTimeParam := app.StakingKeeper.GetParams(ctx).UnbondingTime
ctx.Logger().Info(fmt.Sprintf("removing all delegations from validators that have been inactive (unbonded) for %d days", int64(unbondingTimeParam.Hours()/24)))
ctx.Logger().Info(fmt.Sprintf("Removing all delegations from validators that have been inactive (unbonded) for %d days.", int64(unbondingTimeParam.Hours()/24)))
removalCount := 0
validators := app.StakingKeeper.GetAllValidators(ctx)
for _, validator := range validators {
if validator.IsUnbonded() {
inactiveDuration := ctx.BlockTime().Sub(validator.UnbondingTime)
if inactiveDuration >= unbondingTimeParam {
ctx.Logger().Info(fmt.Sprintf("validator %v has been inactive (unbonded) for %d days and will be removed", validator.OperatorAddress, int64(inactiveDuration.Hours()/24)))
ctx.Logger().Info(fmt.Sprintf("Validator %v has been inactive (unbonded) for %d days and will be removed.", validator.OperatorAddress, int64(inactiveDuration.Hours()/24)))
valAddress, err := sdk.ValAddressFromBech32(validator.OperatorAddress)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("invalid operator address: %s: %v", validator.OperatorAddress, err))
ctx.Logger().Error(fmt.Sprintf("Invalid operator address: %s: %v.", validator.OperatorAddress, err))
continue
}
delegations := app.StakingKeeper.GetValidatorDelegations(ctx, valAddress)
for _, delegation := range delegations {
ctx.Logger().Info(fmt.Sprintf("undelegate delegator %v from validator %v of all shares (%v)", delegation.DelegatorAddress, validator.OperatorAddress, delegation.GetShares()))
ctx.Logger().Info(fmt.Sprintf("Undelegate delegator %v from validator %v of all shares (%v).", delegation.DelegatorAddress, validator.OperatorAddress, delegation.GetShares()))
_, err = app.StakingKeeper.Undelegate(ctx, delegation.GetDelegatorAddr(), valAddress, delegation.GetShares())
if err != nil {
ctx.Logger().Error(fmt.Sprintf("failed to undelegate delegator %s from validator %s: %v", delegation.GetDelegatorAddr().String(), valAddress.String(), err))
ctx.Logger().Error(fmt.Sprintf("Failed to undelegate delegator %s from validator %s: %v.", delegation.GetDelegatorAddr().String(), valAddress.String(), err))
continue
}
}
removalCount++
}
}
}
ctx.Logger().Info(fmt.Sprintf("a total of %d inactive (unbonded) validators have had all their delegators removed", removalCount))
ctx.Logger().Info(fmt.Sprintf("A total of %d inactive (unbonded) validators have had all their delegators removed.", removalCount))
}

// setupICQ sets the correct default values for ICQKeeper.
Expand Down Expand Up @@ -354,24 +358,35 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {

// convertNavUnits iterates all the net asset values and updates their units if they are using usd.
func convertNavUnits(ctx sdk.Context, app *App) {
ctx.Logger().Info("Converting NAV units")
ctx.Logger().Info("Converting NAV units.")
err := app.MarkerKeeper.IterateAllNetAssetValues(ctx, func(markerAddr sdk.AccAddress, nav markertypes.NetAssetValue) (stop bool) {
if nav.Price.Denom == markertypes.UsdDenom {
nav.Price.Amount = nav.Price.Amount.Mul(math.NewInt(10))
marker, err := app.MarkerKeeper.GetMarker(ctx, markerAddr)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("Unable to get marker for address: %s, error: %s", markerAddr, err))
ctx.Logger().Error(fmt.Sprintf("Unable to get marker for address: %s, error: %s.", markerAddr, err))
return false
}
err = app.MarkerKeeper.SetNetAssetValue(ctx, marker, nav, "upgrade")
if err != nil {
ctx.Logger().Error(fmt.Sprintf("Unable to set net asset value for marker: %s, error: %s", markerAddr, err))
ctx.Logger().Error(fmt.Sprintf("Unable to set net asset value for marker: %s, error: %s.", markerAddr, err))
return false
}
}
return false
})
if err != nil {
ctx.Logger().Error(fmt.Sprintf("Unable to iterate all net asset values error: %s", err))
ctx.Logger().Error(fmt.Sprintf("Unable to iterate all net asset values error: %s.", err))
}
ctx.Logger().Info("Done converting NAV units.")
}

// updateMsgFeesNhashPerMil updates the MsgFees Params to set the NhashPerUsdMil to 40,000,000.
func updateMsgFeesNhashPerMil(ctx sdk.Context, app *App) {
var newVal uint64 = 40_000_000
ctx.Logger().Info(fmt.Sprintf("Setting MsgFees Params NhashPerUsdMil to %d.", newVal))
params := app.MsgFeesKeeper.GetParams(ctx)
params.NhashPerUsdMil = newVal
app.MsgFeesKeeper.SetParams(ctx, params)
ctx.Logger().Info("Done setting MsgFees Params NhashPerUsdMil.")
}
Loading
Loading