Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/bufbuild/buf-setup…
Browse files Browse the repository at this point in the history
…-action-1.30.0
  • Loading branch information
iramiller authored Mar 10, 2024
2 parents 97fcb1f + 754919c commit 79df4c7
Show file tree
Hide file tree
Showing 69 changed files with 30,172 additions and 7,621 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* Add [Payments](x/exchange/spec/01_concepts.md#payments) to the exchange module [#1703](https://github.com/provenance-io/provenance/issues/1703).
Payments allow two parties to trade assets securely and asynchronously.

### Improvements

* Allow force transfers from marker and market accounts [#1855](https://github.com/provenance-io/provenance/pull/1855).
* Add a `tourmaline-rc3` upgrade handler to set some new exchange module params related to payments [#1703](https://github.com/provenance-io/provenance/issues/1703).

### Bug Fixes

* Fix `MarkerTransferAuthorization` validation to ensure the coins and addresses are all valid [1856](https://github.com/provenance-io/provenance/pull/1856).
* Fix `MarkerTransferAuthorization` validation to ensure the coins and addresses are all valid [#1703](https://github.com/provenance-io/provenance/issues/1703).
* In `MarketCommitmentSettle`, only consume the settlement fee if the settlement succeeds [#1703](https://github.com/provenance-io/provenance/issues/1703).

### Dependencies

Expand Down
28 changes: 24 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,23 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress {
return addresses
}

// createIncrementalAccountsLong is a strategy used by addTestAddrs() in order to generate 32-byte addresses in ascending order.
func createIncrementalAccountsLong(accNum int) []sdk.AccAddress {
var addresses []sdk.AccAddress

// There's nothing special about this base other than it's 30 bytes long (60 hex chars => 30 bytes).
// That leaves 2 bytes for the incrementing number = 65536 addrs max.
// It's the result of two calls to uuidgen with the last 4 chars removed.
base := "9B4006D1F9794F07BEC52279C3C31480CCC9A1EB3FD64F628CC405E4E2E2"
for i := 0; i < accNum; i++ {
addrHex := fmt.Sprintf("%s%04X", base, i)
addr, _ := sdk.AccAddressFromHexUnsafe(addrHex)
addresses = append(addresses, addr)
}

return addresses
}

// AddTestAddrsFromPubKeys adds the addresses into the App providing only the public keys.
func AddTestAddrsFromPubKeys(app *App, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdkmath.Int) {
initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
Expand All @@ -403,18 +420,21 @@ func AddTestAddrsFromPubKeys(app *App, ctx sdk.Context, pubKeys []cryptotypes.Pu
}
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
// AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt in random order.
func AddTestAddrs(app *App, ctx sdk.Context, accNum int, accAmt sdkmath.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts)
}

// AddTestAddrsIncremental constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
// AddTestAddrsIncremental creates accNum accounts with 20-byte incrementing addresses and initialBondAmount of bond denom.
func AddTestAddrsIncremental(app *App, ctx sdk.Context, accNum int, accAmt sdkmath.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts)
}

// AddTestAddrsIncrementalLong creates accNum accounts with 32-byte incrementing addresses and initialBondAmount of bond denom.
func AddTestAddrsIncrementalLong(app *App, ctx sdk.Context, accNum int, initialBondAmount sdkmath.Int) []sdk.AccAddress {
return addTestAddrs(app, ctx, accNum, initialBondAmount, createIncrementalAccountsLong)
}

func addTestAddrs(app *App, ctx sdk.Context, accNum int, accAmt sdkmath.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
testAddrs := strategy(accNum)

Expand Down
26 changes: 26 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ var upgrades = map[string]appUpgrade{
},
},
"tourmaline-rc2": {}, // upgrade for v1.18.0-rc2
"tourmaline-rc3": { // upgrade for v1.18.0-rc3
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
setExchangePaymentParamsToDefaults(ctx, app)
return vm, nil
},
},
"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 @@ -148,6 +154,8 @@ var upgrades = map[string]appUpgrade{
// This isn't in an rc because it was handled via gov prop for testnet.
updateMsgFeesNhashPerMil(ctx, app)

setExchangePaymentParamsToDefaults(ctx, app)

return vm, nil
},
},
Expand Down Expand Up @@ -357,6 +365,7 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {
}

// convertNavUnits iterates all the net asset values and updates their units if they are using usd.
// TODO: Remove with the tourmaline handlers.
func convertNavUnits(ctx sdk.Context, app *App) {
ctx.Logger().Info("Converting NAV units.")
err := app.MarkerKeeper.IterateAllNetAssetValues(ctx, func(markerAddr sdk.AccAddress, nav markertypes.NetAssetValue) (stop bool) {
Expand All @@ -382,6 +391,7 @@ func convertNavUnits(ctx sdk.Context, app *App) {
}

// updateMsgFeesNhashPerMil updates the MsgFees Params to set the NhashPerUsdMil to 40,000,000.
// TODO: Remove with the tourmaline handlers.
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))
Expand All @@ -390,3 +400,19 @@ func updateMsgFeesNhashPerMil(ctx sdk.Context, app *App) {
app.MsgFeesKeeper.SetParams(ctx, params)
ctx.Logger().Info("Done setting MsgFees Params NhashPerUsdMil.")
}

// setExchangePaymentParamsToDefaults updates the exchange module params to have the default create payment and accept payment values.
// TODO: Remove with the tourmaline handlers.
func setExchangePaymentParamsToDefaults(ctx sdk.Context, app *App) {
ctx.Logger().Info("Setting exchange module payment params to defaults.")
defaultParams := exchange.DefaultParams()
curParams := app.ExchangeKeeper.GetParams(ctx)
if curParams == nil {
curParams = defaultParams
} else {
curParams.FeeCreatePaymentFlat = defaultParams.FeeCreatePaymentFlat
curParams.FeeAcceptPaymentFlat = defaultParams.FeeAcceptPaymentFlat
}
app.ExchangeKeeper.SetParams(ctx, curParams)
ctx.Logger().Info("Done setting exchange module payment params to defaults.")
}
69 changes: 69 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,22 @@ func (s *UpgradeTestSuite) TestTourmalineRC2() {
s.Require().Empty(upgrades[key], "upgrades[%q]", key)
}

func (s *UpgradeTestSuite) TestTourmalineRC3() {
expInLog := []string{
"INF Setting exchange module payment params to defaults.",
"INF Done setting exchange module payment params to defaults.",
}

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

func (s *UpgradeTestSuite) TestTourmaline() {
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 Converting NAV units.",
"INF Setting MsgFees Params NhashPerUsdMil to 40000000.",
"INF Setting exchange module payment params to defaults.",
}

s.AssertUpgradeHandlerLogs("tourmaline", expInLog, nil)
Expand Down Expand Up @@ -974,3 +984,62 @@ func (s *UpgradeTestSuite) TestUpdateMsgFeesNhashPerMil() {
})
}
}

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

defaultParams := exchange.DefaultParams()

tests := []struct {
name string
existingParams *exchange.Params
expectedParams *exchange.Params
}{
{
name: "no params set yet",
existingParams: nil,
expectedParams: defaultParams,
},
{
name: "params set previously",
existingParams: &exchange.Params{
DefaultSplit: 333,
DenomSplits: []exchange.DenomSplit{{Denom: "date", Split: 99}},
FeeCreatePaymentFlat: nil,
FeeAcceptPaymentFlat: nil,
},
expectedParams: &exchange.Params{
DefaultSplit: 333,
DenomSplits: []exchange.DenomSplit{{Denom: "date", Split: 99}},
FeeCreatePaymentFlat: defaultParams.FeeCreatePaymentFlat,
FeeAcceptPaymentFlat: defaultParams.FeeAcceptPaymentFlat,
},
},
}

for _, tc := range tests {
s.Run(tc.name, func() {
s.app.ExchangeKeeper.SetParams(s.ctx, tc.existingParams)
expInLog := []string{
"INF Setting exchange module payment params to defaults.",
"INF Done setting exchange module payment params to defaults.",
}

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

actParams := s.app.ExchangeKeeper.GetParams(s.ctx)
s.Assert().Equal(tc.expectedParams, actParams, "Exchange Params after setExchangePaymentParamsToDefaults")
})
}
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit 79df4c7

Please sign in to comment.