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

Mark v1.17.0-rc3. Backport: #1729, #1738, #1712, #1742, #1741, #1740 #1743

Merged
merged 8 commits into from
Nov 10, 2023
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ Ref: https://keepachangelog.com/en/1.0.0/

---

## [v1.17.0-rc3](https://github.com/provenance-io/provenance/releases/tag/v1.17.0-rc3) - 2023-11-10

### Improvements

* Add upgrade handler to set net asset values to markers [PR 1712](https://github.com/provenance-io/provenance/pull/1712).
* Add additional logging to trigger module [#1718](https://github.com/provenance-io/provenance/issues/1718).
* When the exchange module settles orders, update the marker net-asset-values ([#1736](https://github.com/provenance-io/provenance/pull/1736).
* Add the EventTriggerDetected and EventTriggerExecuted events [#1717](https://github.com/provenance-io/provenance/issues/1717).
* Add spec docs for the exchange module [#1700](https://github.com/provenance-io/provenance/issues/1700).

### Bug Fixes

* Fixed denom metadata source chain-id retrieval for new ibc markers [#1726](https://github.com/provenance-io/provenance/issues/1726).

### Full Commit History

* https://github.com/provenance-io/provenance/compare/v1.17.0-rc2...v1.17.0-rc3
* https://github.com/provenance-io/provenance/compare/v1.16.0...v1.17.0-rc3

---

## [v1.17.0-rc2](https://github.com/provenance-io/provenance/releases/tag/v1.17.0-rc2) - 2023-11-03

### Features
Expand Down
21 changes: 21 additions & 0 deletions RELEASE_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [v1.17.0-rc3](https://github.com/provenance-io/provenance/releases/tag/v1.17.0-rc3) - 2023-11-10

### Improvements

* Add upgrade handler to set net asset values to markers [PR 1712](https://github.com/provenance-io/provenance/pull/1712).
* Add additional logging to trigger module [#1718](https://github.com/provenance-io/provenance/issues/1718).
* When the exchange module settles orders, update the marker net-asset-values ([#1736](https://github.com/provenance-io/provenance/pull/1736).
* Add the EventTriggerDetected and EventTriggerExecuted events [#1717](https://github.com/provenance-io/provenance/issues/1717).
* Add spec docs for the exchange module [#1700](https://github.com/provenance-io/provenance/issues/1700).

### Bug Fixes

* Fixed denom metadata source chain-id retrieval for new ibc markers [#1726](https://github.com/provenance-io/provenance/issues/1726).

### Full Commit History

* https://github.com/provenance-io/provenance/compare/v1.17.0-rc2...v1.17.0-rc3
* https://github.com/provenance-io/provenance/compare/v1.16.0...v1.17.0-rc3

---

## [v1.17.0-rc2](https://github.com/provenance-io/provenance/releases/tag/v1.17.0-rc2) - 2023-11-03

### Features
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func New(

app.ExchangeKeeper = exchangekeeper.NewKeeper(
appCodec, keys[exchange.StoreKey], authtypes.FeeCollectorName,
app.AccountKeeper, app.AttributeKeeper, app.BankKeeper, app.HoldKeeper,
app.AccountKeeper, app.AttributeKeeper, app.BankKeeper, app.HoldKeeper, app.MarkerKeeper,
)

pioMessageRouter := MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler {
Expand Down
5,589 changes: 5,589 additions & 0 deletions app/navs_mainnet.go

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/provenance-io/provenance/x/exchange"
"github.com/provenance-io/provenance/x/hold"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
"github.com/provenance-io/provenance/x/marker/types"
markertypes "github.com/provenance-io/provenance/x/marker/types"
msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types"
oracletypes "github.com/provenance-io/provenance/x/oracle/types"
triggertypes "github.com/provenance-io/provenance/x/trigger/types"
Expand Down Expand Up @@ -137,6 +137,19 @@ var upgrades = map[string]appUpgrade{
return vm, nil
},
},
"saffron-rc3": { // upgrade for v1.17.0-rc3
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
vm, err = runModuleMigrations(ctx, app, vm)
if err != nil {
return nil, err
}

updateIbcMarkerDenomMetadata(ctx, app)

return vm, nil
},
},
"saffron": { // upgrade for v1.17.0,
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
Expand All @@ -151,6 +164,9 @@ var upgrades = map[string]appUpgrade{
removeInactiveValidatorDelegations(ctx, app)
setupICQ(ctx, app)
updateMaxSupply(ctx, app)

addMarkerNavs(ctx, app, GetPioMainnet1DenomToNav())

setExchangeParams(ctx, app)
updateIbcMarkerDenomMetadata(ctx, app)

Expand Down Expand Up @@ -364,6 +380,22 @@ func updateMaxSupply(ctx sdk.Context, app *App) {
ctx.Logger().Info("Done updating MaxSupply marker param")
}

// addMarkerNavs adds navs to existing markers
func addMarkerNavs(ctx sdk.Context, app *App, denomToNav map[string]markertypes.NetAssetValue) {
ctx.Logger().Info("Adding marker net asset values")
for denom, nav := range denomToNav {
marker, err := app.MarkerKeeper.GetMarkerByDenom(ctx, denom)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to get marker %v: %v", denom, err))
continue
}
if err := app.MarkerKeeper.AddSetNetAssetValues(ctx, marker, []markertypes.NetAssetValue{nav}, "upgrade_handler"); err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to set net asset value %v: %v", nav, err))
}
}
ctx.Logger().Info("Done adding marker net asset values")
}

// setExchangeParams sets exchange module's params to the defaults.
// TODO: Remove with the saffron handlers.
func setExchangeParams(ctx sdk.Context, app *App) {
Expand All @@ -383,7 +415,7 @@ func setExchangeParams(ctx sdk.Context, app *App) {
// TODO: Remove with the saffron handlers.
func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {
ctx.Logger().Info("Updating ibc marker denom metadata")
app.MarkerKeeper.IterateMarkers(ctx, func(record types.MarkerAccountI) bool {
app.MarkerKeeper.IterateMarkers(ctx, func(record markertypes.MarkerAccountI) bool {
if !strings.HasPrefix(record.GetDenom(), "ibc/") {
return false
}
Expand Down
84 changes: 83 additions & 1 deletion app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

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

Expand Down Expand Up @@ -445,6 +446,15 @@ func (s *UpgradeTestSuite) TestSaffronRC2() {
s.AssertUpgradeHandlerLogs("saffron-rc2", expInLog, nil)
}

func (s *UpgradeTestSuite) TestSaffronRC3() {
expInLog := []string{
"INF Updating ibc marker denom metadata",
"INF Done updating ibc marker denom metadata",
}

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

func (s *UpgradeTestSuite) TestSaffron() {
// Each part is (hopefully) tested thoroughly on its own.
// So for this test, just make sure there's log entries for each part being done.
Expand All @@ -456,6 +466,8 @@ func (s *UpgradeTestSuite) TestSaffron() {
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
"INF Adding marker net asset values",
"INF Done adding marker net asset values",
"INF Ensuring exchange module params are set.",
"INF Updating ibc marker denom metadata",
"INF Done updating ibc marker denom metadata",
Expand Down Expand Up @@ -859,6 +871,77 @@ func (s *UpgradeTestSuite) TestSetAccountDataNameRecord() {
s.AssertLogContents(logOutput, expInLog, nil, true, "setAccountDataNameRecord")
}

func (s *UpgradeTestSuite) TestAddMarkerNavs() {
address1 := sdk.AccAddress("address1")
testcoin := markertypes.NewEmptyMarkerAccount("testcoin",
address1.String(),
[]markertypes.AccessGrant{})
testcoin.Supply = sdk.OneInt()
s.Require().NoError(s.app.MarkerKeeper.AddMarkerAccount(s.ctx, testcoin), "AddMarkerAccount() error")

testcoinInList := markertypes.NewEmptyMarkerAccount("testcoininlist",
address1.String(),
[]markertypes.AccessGrant{})
testcoinInList.Supply = sdk.OneInt()
s.Require().NoError(s.app.MarkerKeeper.AddMarkerAccount(s.ctx, testcoinInList), "AddMarkerAccount() error")

nosupplycoin := markertypes.NewEmptyMarkerAccount("nosupplycoin",
address1.String(),
[]markertypes.AccessGrant{})
s.Require().NoError(s.app.MarkerKeeper.AddMarkerAccount(s.ctx, nosupplycoin), "AddMarkerAccount() error")

hasnavcoin := markertypes.NewEmptyMarkerAccount("hasnavcoin",
address1.String(),
[]markertypes.AccessGrant{})
hasnavcoin.Supply = sdk.NewInt(100)
s.Require().NoError(s.app.MarkerKeeper.AddMarkerAccount(s.ctx, hasnavcoin), "AddMarkerAccount() error")
presentnav := markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, int64(55)), uint64(100))
s.Require().NoError(s.app.MarkerKeeper.AddSetNetAssetValues(s.ctx, hasnavcoin, []markertypes.NetAssetValue{presentnav}, "test"))

addMarkerNavs(s.ctx, s.app, map[string]markertypes.NetAssetValue{
"testcoininlist": {Price: sdk.NewInt64Coin(markertypes.UsdDenom, int64(12345)), Volume: uint64(1)},
})

tests := []struct {
name string
markerAddr sdk.AccAddress
expNav *markertypes.NetAssetValue
}{
{
name: "already has nav",
markerAddr: hasnavcoin.GetAddress(),
expNav: &markertypes.NetAssetValue{Price: sdk.NewInt64Coin(markertypes.UsdDenom, int64(55)), Volume: uint64(100)},
},
{
name: "nav add fails for coin",
markerAddr: nosupplycoin.GetAddress(),
expNav: nil,
},
{
name: "nav set from custom config",
markerAddr: testcoinInList.GetAddress(),
expNav: &markertypes.NetAssetValue{Price: sdk.NewInt64Coin(markertypes.UsdDenom, int64(12345)), Volume: uint64(1)},
},
}
for _, tc := range tests {
s.Run(tc.name, func() {
netAssetValues := []markertypes.NetAssetValue{}
err := s.app.MarkerKeeper.IterateNetAssetValues(s.ctx, tc.markerAddr, func(state markertypes.NetAssetValue) (stop bool) {
netAssetValues = append(netAssetValues, state)
return false
})
s.Require().NoError(err, "IterateNetAssetValues err")
if tc.expNav != nil {
s.Assert().Len(netAssetValues, 1, "Should be 1 nav set for testcoin")
s.Assert().Equal(tc.expNav.Price, netAssetValues[0].Price, "Net asset value price should equal default upgraded price")
s.Assert().Equal(tc.expNav.Volume, netAssetValues[0].Volume, "Net asset value volume should equal 1")
} else {
s.Assert().Len(netAssetValues, 0, "Marker not expected to have nav")
}
})
}
}

func (s *UpgradeTestSuite) TestSetExchangeParams() {
startMsg := "INF Ensuring exchange module params are set."
noopMsg := "INF Exchange module params are already defined."
Expand Down Expand Up @@ -908,7 +991,6 @@ func (s *UpgradeTestSuite) TestSetExchangeParams() {
expInLog: []string{startMsg, noopMsg, doneMsg},
},
}

for _, tc := range tests {
s.Run(tc.name, func() {
s.app.ExchangeKeeper.SetParams(s.ctx, tc.existingParams)
Expand Down
38 changes: 36 additions & 2 deletions docs/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@
- [provenance/trigger/v1/event.proto](#provenance/trigger/v1/event.proto)
- [EventTriggerCreated](#provenance.trigger.v1.EventTriggerCreated)
- [EventTriggerDestroyed](#provenance.trigger.v1.EventTriggerDestroyed)
- [EventTriggerDetected](#provenance.trigger.v1.EventTriggerDetected)
- [EventTriggerExecuted](#provenance.trigger.v1.EventTriggerExecuted)

- [provenance/trigger/v1/trigger.proto](#provenance/trigger/v1/trigger.proto)
- [Attribute](#provenance.trigger.v1.Attribute)
Expand Down Expand Up @@ -9990,7 +9992,7 @@ EventTriggerCreated is an event for when a trigger is created

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger. |



Expand All @@ -10005,7 +10007,39 @@ EventTriggerDestroyed is an event for when a trigger is destroyed

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger. |






<a name="provenance.trigger.v1.EventTriggerDetected"></a>

### EventTriggerDetected
EventTriggerDetected is an event for when a trigger's event is detected


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger. |






<a name="provenance.trigger.v1.EventTriggerExecuted"></a>

### EventTriggerExecuted
EventTriggerExecuted is an event for when a trigger is executed.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `trigger_id` | [string](#string) | | trigger_id is a unique identifier of the trigger. |
| `owner` | [string](#string) | | owner is the creator of the trigger. |
| `success` | [bool](#bool) | | success indicates if all executed actions were successful. |



Expand Down
20 changes: 18 additions & 2 deletions proto/provenance/trigger/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ option java_multiple_files = true;

// EventTriggerCreated is an event for when a trigger is created
message EventTriggerCreated {
// trigger_id is a unique identifier of the trigger
// trigger_id is a unique identifier of the trigger.
string trigger_id = 1;
}

// EventTriggerDestroyed is an event for when a trigger is destroyed
message EventTriggerDestroyed {
// trigger_id is a unique identifier of the trigger
// trigger_id is a unique identifier of the trigger.
string trigger_id = 1;
}

// EventTriggerDetected is an event for when a trigger's event is detected
message EventTriggerDetected {
// trigger_id is a unique identifier of the trigger.
string trigger_id = 1;
}

// EventTriggerExecuted is an event for when a trigger is executed.
message EventTriggerExecuted {
// trigger_id is a unique identifier of the trigger.
string trigger_id = 1;
// owner is the creator of the trigger.
string owner = 2;
// success indicates if all executed actions were successful.
bool success = 3;
}
6 changes: 6 additions & 0 deletions x/exchange/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

attrtypes "github.com/provenance-io/provenance/x/attribute/types"
markertypes "github.com/provenance-io/provenance/x/marker/types"
)

type AccountKeeper interface {
Expand All @@ -30,3 +31,8 @@ type HoldKeeper interface {
ReleaseHold(ctx sdk.Context, addr sdk.AccAddress, funds sdk.Coins) error
GetHoldCoin(ctx sdk.Context, addr sdk.AccAddress, denom string) (sdk.Coin, error)
}

type MarkerKeeper interface {
GetMarker(ctx sdk.Context, address sdk.AccAddress) (markertypes.MarkerAccountI, error)
AddSetNetAssetValues(ctx sdk.Context, marker markertypes.MarkerAccountI, netAssetValues []markertypes.NetAssetValue, source string) error
}
Loading
Loading