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

fix: gov endpoints fail to decode old leverage proposals after upgrade #1628

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions proto/umee/leverage/v1/gov.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package umee.leverage.v1;

import "gogoproto/gogo.proto";
import "umee/leverage/v1/leverage.proto";

option go_package = "github.com/umee-network/umee/v3/x/leverage/types";

option (gogoproto.goproto_getters_all) = false;

// UpdateRegistryProposal is DEPRECATED.
// We will keep the proto so old proposals are readable.
message UpdateRegistryProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;
repeated Token registry = 3 [(gogoproto.nullable) = false];
}
177 changes: 176 additions & 1 deletion swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,77 @@ paths:
format: byte
tags:
- Query
/umee/historacle/v1/denoms/median_deviations:
get:
summary: |-
MedianDeviations returns median deviations of all denoms,
or, if specified, returns a single median deviation
operationId: MedianDeviations
responses:
'200':
description: A successful response.
schema:
type: object
properties:
medianDeviations:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
DecCoin defines a token with a denomination and a decimal
amount.


NOTE: The amount field is an Dec which implements the custom
method

signatures required by gogoproto.
description: >-
medians defines a list of the median deviations for all
stamped denoms.
description: |-
QueryMedianDeviationsResponse is response type for the
Query/MedianDeviations RPC method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: denom
description: denom defines the denomination to query for.
in: query
required: false
type: string
tags:
- Query
/umee/historacle/v1/denoms/medians:
get:
summary: Medians returns medians of all denoms
summary: |-
Medians returns medians of all denoms,
or, if specified, returns a single median
operationId: Medians
responses:
'200':
Expand Down Expand Up @@ -1098,6 +1166,38 @@ paths:
we want

to keep a record of our set of exchange rates.
median_period:
type: string
format: uint64
description: >-
Median Period represents the amount blocks we will wait
between

calculating the median and standard deviation of the
median of

historic prices in the last Prune Period.
historic_accept_list:
type: array
items:
type: object
properties:
base_denom:
type: string
symbol_denom:
type: string
exponent:
type: integer
format: int64
title: Denom - the object to hold configurations of each denom
description: >-
Historic Asset List is a list of assets which will use the
historic

price stamping protection methodology (mainly
manipulatable assets).

Any assets not on this list will not be stamped.
description: >-
QueryParamsResponse is the response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -2515,6 +2615,30 @@ definitions:
description: |-
Prune Period represents the maximum amount of blocks which we want
to keep a record of our set of exchange rates.
median_period:
type: string
format: uint64
description: |-
Median Period represents the amount blocks we will wait between
calculating the median and standard deviation of the median of
historic prices in the last Prune Period.
historic_accept_list:
type: array
items:
type: object
properties:
base_denom:
type: string
symbol_denom:
type: string
exponent:
type: integer
format: int64
title: Denom - the object to hold configurations of each denom
description: |-
Historic Asset List is a list of assets which will use the historic
price stamping protection methodology (mainly manipulatable assets).
Any assets not on this list will not be stamped.
description: Params defines the parameters for the oracle module.
umee.oracle.v1.QueryActiveExchangeRatesResponse:
type: object
Expand Down Expand Up @@ -2688,6 +2812,29 @@ definitions:
description: |-
QueryFeederDelegationResponse is response type for the
Query/FeederDelegation RPC method.
umee.oracle.v1.QueryMedianDeviationsResponse:
type: object
properties:
medianDeviations:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
DecCoin defines a token with a denomination and a decimal amount.

NOTE: The amount field is an Dec which implements the custom method
signatures required by gogoproto.
description: >-
medians defines a list of the median deviations for all stamped
denoms.
description: |-
QueryMedianDeviationsResponse is response type for the
Query/MedianDeviations RPC method.
umee.oracle.v1.QueryMediansResponse:
type: object
properties:
Expand Down Expand Up @@ -2768,6 +2915,34 @@ definitions:
description: |-
Prune Period represents the maximum amount of blocks which we want
to keep a record of our set of exchange rates.
median_period:
type: string
format: uint64
description: |-
Median Period represents the amount blocks we will wait between
calculating the median and standard deviation of the median of
historic prices in the last Prune Period.
historic_accept_list:
type: array
items:
type: object
properties:
base_denom:
type: string
symbol_denom:
type: string
exponent:
type: integer
format: int64
title: Denom - the object to hold configurations of each denom
description: >-
Historic Asset List is a list of assets which will use the
historic

price stamping protection methodology (mainly manipulatable
assets).

Any assets not on this list will not be stamped.
description: QueryParamsResponse is the response type for the Query/Params RPC method.
umee.oracle.v1.QuerySlashWindowResponse:
type: object
Expand Down
7 changes: 7 additions & 0 deletions x/leverage/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
gov1b1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

var (
Expand Down Expand Up @@ -34,6 +35,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgBorrow{}, "umee/leverage/MsgBorrow", nil)
cdc.RegisterConcrete(&MsgRepay{}, "umee/leverage/MsgRepay", nil)
cdc.RegisterConcrete(&MsgLiquidate{}, "umee/leverage/MsgLiquidate", nil)
cdc.RegisterConcrete(&UpdateRegistryProposal{}, "umee/leverage/UpdateRegistryProposal", nil)
cdc.RegisterConcrete(&MsgGovUpdateRegistry{}, "umee/leverage/MsgGovUpdateRegistry", nil)
cdc.RegisterConcrete(&MsgSupplyCollateral{}, "umee/leverage/MsgSupplyCollateral", nil)
}
Expand All @@ -52,5 +54,10 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgSupplyCollateral{},
)

registry.RegisterImplementations(
(*gov1b1.Content)(nil),
&UpdateRegistryProposal{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
61 changes: 61 additions & 0 deletions x/leverage/types/gov.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package types

import (
gov1b1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"gopkg.in/yaml.v3"
)

const (
// ProposalTypeUpdateRegistryProposal defines the type for a UpdateRegistryProposal
// proposal type.
ProposalTypeUpdateRegistryProposal = "UpdateRegistryProposal"
)

func init() {
gov1b1.RegisterProposalType(ProposalTypeUpdateRegistryProposal)
}

// Assert UpdateRegistryProposal implements govtypes.Content at compile-time
var _ gov1b1.Content = &UpdateRegistryProposal{}

func NewUpdateRegistryProposal(title, description string, tokens []Token) *UpdateRegistryProposal {
return &UpdateRegistryProposal{
Title: title,
Description: description,
Registry: tokens,
}
}

// String implements the Stringer interface.
func (p UpdateRegistryProposal) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}

// GetTitle returns the title of the proposal.
func (p *UpdateRegistryProposal) GetTitle() string { return p.Title }

// GetDescription returns the description of the proposal.
func (p *UpdateRegistryProposal) GetDescription() string { return p.Description }

// ProposalRoute returns the x/gov routing key of the proposal.
func (p *UpdateRegistryProposal) ProposalRoute() string { return RouterKey }

// ProposalType returns the x/gov type of the proposal.
func (p *UpdateRegistryProposal) ProposalType() string { return ProposalTypeUpdateRegistryProposal }

// ValidateBasic validates the proposal returning an error if invalid.
func (p *UpdateRegistryProposal) ValidateBasic() error {
err := gov1b1.ValidateAbstract(p)
if err != nil {
return err
}

for _, token := range p.Registry {
if err := token.Validate(); err != nil {
return err
}
}

return nil
}
Loading