Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/cargo/testutil/contracts/echo/ser…
Browse files Browse the repository at this point in the history
…de-json-wasm-0.5.2
  • Loading branch information
nullpointer0x00 committed Feb 15, 2024
2 parents 3661dad + 21b0ebf commit 8716fa2
Show file tree
Hide file tree
Showing 38 changed files with 5,142 additions and 483 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
if: env.GIT_DIFF
with:
go-version: '1.21'
- uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@v4
if: env.GIT_DIFF
with:
# If you change this version, be sure to also change it in contrib/devtools/Makefile.
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Improvements

* 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).

### 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 Down
34 changes: 24 additions & 10 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,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 +237,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 +357,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.")
}
147 changes: 112 additions & 35 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/provenance-io/provenance/x/exchange"
markertypes "github.com/provenance-io/provenance/x/marker/types"
msgfeestypes "github.com/provenance-io/provenance/x/msgfees/types"
)

type UpgradeTestSuite struct {
Expand Down Expand Up @@ -371,7 +372,7 @@ func (s *UpgradeTestSuite) TestSaffronRC1() {

expInLog := []string{
"INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.",
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
"INF Updating ICQ params",
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
Expand Down Expand Up @@ -409,7 +410,7 @@ func (s *UpgradeTestSuite) TestSaffron() {

expInLog := []string{
"INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.",
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
"INF Updating ICQ params",
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
Expand All @@ -426,15 +427,21 @@ func (s *UpgradeTestSuite) TestSaffron() {

func (s *UpgradeTestSuite) TestTourmalineRC1() {
expInLog := []string{
"INF Converting NAV units",
"INF Converting NAV units.",
}
expNotInLog := []string{
"INF Setting MsgFees Params NhashPerUsdMil to 40000000.",
}

s.AssertUpgradeHandlerLogs("tourmaline-rc1", expInLog, nil)
s.AssertUpgradeHandlerLogs("tourmaline-rc1", expInLog, expNotInLog)
}

func (s *UpgradeTestSuite) TestTourmaline() {
expInLog := []string{
"INF Converting NAV units",
"INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
"INF Converting NAV units.",
"INF Setting MsgFees Params NhashPerUsdMil to 40000000.",
}

s.AssertUpgradeHandlerLogs("tourmaline", expInLog, nil)
Expand All @@ -457,8 +464,8 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 1, "GetAllValidators after setup")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
"INF a total of 0 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
"INF A total of 0 inactive (unbonded) validators have had all their delegators removed.",
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, nil, true, runnerName)

Expand All @@ -476,10 +483,10 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 2, "Setup: GetAllValidators should have: 1 bonded, 1 unbonded")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF a total of 1 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF A total of 1 inactive (unbonded) validators have had all their delegators removed.",
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, nil, true, runnerName)

Expand Down Expand Up @@ -509,11 +516,11 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 2, "Setup: GetAllValidators should have: 1 bonded, 1 unbonded")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF a total of 1 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF A total of 1 inactive (unbonded) validators have had all their delegators removed.",
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, nil, false, runnerName)

Expand Down Expand Up @@ -551,14 +558,14 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 3, "Setup: GetAllValidators should have: 1 bonded, 2 unbonded")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal2.OperatorAddress, 29),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr1.String(), unbondedVal2.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr2.String(), unbondedVal2.OperatorAddress, delegationCoinAmt),
"INF a total of 2 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal2.OperatorAddress, 29),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr1.String(), unbondedVal2.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr2.String(), unbondedVal2.OperatorAddress, delegationCoinAmt),
"INF A total of 2 inactive (unbonded) validators have had all their delegators removed.",
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, nil, false, runnerName)

Expand Down Expand Up @@ -595,16 +602,16 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 3, "Setup: GetAllValidators should have: 1 bonded, 1 recently unbonded, 1 old unbonded")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF undelegate delegator %v from validator %v of all shares (%v)", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF a total of 1 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal1.OperatorAddress, 30),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr1.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
fmt.Sprintf("INF Undelegate delegator %v from validator %v of all shares (%v).", addr2.String(), unbondedVal1.OperatorAddress, delegationCoinAmt),
"INF A total of 1 inactive (unbonded) validators have had all their delegators removed.",
}
notExpectedLogLines := []string{
fmt.Sprintf("validator %v has been inactive (unbonded)", unbondedVal2.OperatorAddress),
fmt.Sprintf("undelegate delegator %v from validator %v", addr1.String(), unbondedVal2.OperatorAddress),
fmt.Sprintf("undelegate delegator %v from validator %v", addr2.String(), unbondedVal2.OperatorAddress),
fmt.Sprintf("Validator %v has been inactive (unbonded).", unbondedVal2.OperatorAddress),
fmt.Sprintf("Undelegate delegator %v from validator %v", addr1.String(), unbondedVal2.OperatorAddress),
fmt.Sprintf("Undelegate delegator %v from validator %v", addr2.String(), unbondedVal2.OperatorAddress),
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, notExpectedLogLines, false, runnerName)

Expand All @@ -629,9 +636,9 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() {
s.Require().Len(validators, 3, "Setup: GetAllValidators should have: 1 bonded, 1 recently unbonded, 1 empty unbonded")

expectedLogLines := []string{
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
fmt.Sprintf("INF validator %v has been inactive (unbonded) for %d days and will be removed", unbondedVal1.OperatorAddress, 30),
"INF a total of 1 inactive (unbonded) validators have had all their delegators removed",
"INF Removing all delegations from validators that have been inactive (unbonded) for 21 days.",
fmt.Sprintf("INF Validator %v has been inactive (unbonded) for %d days and will be removed.", unbondedVal1.OperatorAddress, 30),
"INF A total of 1 inactive (unbonded) validators have had all their delegators removed.",
}
s.ExecuteAndAssertLogs(runner, expectedLogLines, nil, true, runnerName)

Expand Down Expand Up @@ -891,3 +898,73 @@ func (s *UpgradeTestSuite) TestConvertNAVUnits() {
})
}
}

func (s *UpgradeTestSuite) TestUpdateMsgFeesNhashPerMil() {
origParams := s.app.MsgFeesKeeper.GetParams(s.ctx)
defer s.app.MsgFeesKeeper.SetParams(s.ctx, origParams)

tests := []struct {
name string
existingParams msgfeestypes.Params
}{
{
name: "from 0",
existingParams: msgfeestypes.Params{
FloorGasPrice: sdk.NewInt64Coin("cat", 50),
NhashPerUsdMil: 0,
ConversionFeeDenom: "horse",
},
},
{
name: "from 25,000,000",
existingParams: msgfeestypes.Params{
FloorGasPrice: sdk.NewInt64Coin("dog", 12),
NhashPerUsdMil: 25_000_000,
ConversionFeeDenom: "pig",
},
},
{
name: "from 40,000,000",
existingParams: msgfeestypes.Params{
FloorGasPrice: sdk.NewInt64Coin("fish", 83),
NhashPerUsdMil: 40_000_000,
ConversionFeeDenom: "cow",
},
},
{
name: "from 123,456,789",
existingParams: msgfeestypes.Params{
FloorGasPrice: sdk.NewInt64Coin("hamster", 83),
NhashPerUsdMil: 123_456_789,
ConversionFeeDenom: "llama",
},
},
}

for _, tc := range tests {
s.Run(tc.name, func() {
s.app.MsgFeesKeeper.SetParams(s.ctx, tc.existingParams)
expParams := tc.existingParams
expParams.NhashPerUsdMil = 40_000_000
expInLog := []string{
"INF Setting MsgFees Params NhashPerUsdMil to 40000000.",
"INF Done setting MsgFees Params NhashPerUsdMil.",
}

// Reset the log buffer and call the func. Relog the output if it panics.
s.logBuffer.Reset()
testFunc := func() {
updateMsgFeesNhashPerMil(s.ctx, s.app)
}
didNotPanic := s.Assert().NotPanics(testFunc, "updateMsgFeesNhashPerMil")
logOutput := s.GetLogOutput("updateMsgFeesNhashPerMil")
if !didNotPanic {
return
}
s.AssertLogContents(logOutput, expInLog, nil, true, "updateMsgFeesNhashPerMil")

actParams := s.app.MsgFeesKeeper.GetParams(s.ctx)
s.Assert().Equal(expParams, actParams, "MsgFeesKeeper Params after updateMsgFeesNhashPerMil")
})
}
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit 8716fa2

Please sign in to comment.