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

Add upgrade module #4233

Merged
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
f195fbc
Add upgrade module
aaronc Mar 26, 2019
41cc4af
Added pending changelog entry
aaronc Mar 26, 2019
cada0e4
Add cache behavior to upgrade Keeper, bring package test coverage to …
aaronc Mar 28, 2019
b88a9a7
Add the ability to retrieve the height of an applied upgrade and clea…
aaronc Apr 17, 2019
e3faef5
Update upgrade module docs
aaronc Apr 18, 2019
90b9e18
add GetCmdSubmitProposal for upgrade module
aaronc Jun 3, 2019
1f0bf38
Add calls to optional prepare-upgrade and do-upgrade scripts from the…
aaronc Jun 4, 2019
eaaf5a2
Add GetCmdSubmitCancelUpgradeProposal
aaronc Jun 4, 2019
5fc7efb
Disable cache usage for upgrade module and will upgrader because of i…
aaronc Jun 4, 2019
9702017
Explain general workflow of upgrade module from user perspective
ethanfrey Jul 8, 2019
5c494cd
Rename OnUpgrader -> OnShutdowner
ethanfrey Jul 8, 2019
7625f0c
Upgrade client imports to v0.36.0
ethanfrey Jul 8, 2019
1d318fe
Remove upgrade script callbacks - not to be used
ethanfrey Aug 27, 2019
057968e
Abort in BeginBlock if we have too new upgrade handlers
ethanfrey Aug 27, 2019
3e38495
Test early abort
ethanfrey Aug 27, 2019
3fa26ea
Fix compile errors after rebase
ethanfrey Aug 29, 2019
33f8d41
Removed all traces of "informational" software upgrade proposal
ethanfrey Aug 29, 2019
585f242
Fix go lint issues
ethanfrey Sep 20, 2019
8d1788f
Address some PR comments
ethanfrey Sep 30, 2019
a75e5e6
goimports
ethanfrey Sep 30, 2019
b76bdb4
Updated doc.go, address golint errors
ethanfrey Sep 30, 2019
1a018a2
Some more PR cleanup
ethanfrey Sep 30, 2019
5e509a0
Cleanup CHANGELOG
ethanfrey Sep 30, 2019
7b19ead
Change PlanKey/DoneKey to bytes
ethanfrey Sep 30, 2019
07ca03e
Store DoneHeight in BigEndian not amino var-int
ethanfrey Sep 30, 2019
1967997
Add godoc
ethanfrey Sep 30, 2019
af95b8c
Refactor 1: create internal/types
ethanfrey Oct 1, 2019
2133c24
Refactor 2: Add Keeper, clean up internal/types
ethanfrey Oct 1, 2019
1553d75
Refactor 3: Add cli and rest client
ethanfrey Oct 1, 2019
fcbaa4e
Refactor 4: Top level module and helpers
ethanfrey Oct 1, 2019
17ab81c
Move BeginBlock logic from Keeper into abci.go
ethanfrey Oct 1, 2019
ee7cc3c
Resolved linter issues
ethanfrey Oct 1, 2019
4ca8ea1
Merge branch 'master' into regen-network/upgrade-module
fedekunze Oct 1, 2019
cf3acea
Update flow according to PR
ethanfrey Oct 1, 2019
63828cb
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 4, 2019
41ab01f
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 7, 2019
bfe520c
Updated from PR comments
ethanfrey Oct 7, 2019
2b7396a
Ensure ScheduleUpgrade does not overwrite
ethanfrey Oct 7, 2019
a4242a3
Register Querier, use .Query and .QueryWithData
ethanfrey Oct 7, 2019
bd5cecf
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 8, 2019
4842174
Add rest handler for upgrade transactions
ethanfrey Oct 8, 2019
8eeaed0
Allow overwrite scheduled plan, as requested by @aaronc
ethanfrey Oct 8, 2019
ac312d8
Add some tests
ethanfrey Oct 8, 2019
08f48d9
Simply cli tx arguments. Thanks Jack
ethanfrey Oct 9, 2019
4bf257c
Fix lint error
ethanfrey Oct 9, 2019
69a2907
Added proposaltype event attribute to gov/submit-proposal
ethanfrey Oct 9, 2019
1b20be3
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 9, 2019
8c75855
Improved gov event emitting
ethanfrey Oct 9, 2019
ad9d96e
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 10, 2019
4256216
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 16, 2019
f672607
Fix CHANGELOG
ethanfrey Oct 17, 2019
bcb440e
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 17, 2019
eeff838
Merge branch 'master' into regen-network/upgrade-module
alexanderbez Oct 22, 2019
f0ef904
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Oct 24, 2019
e259253
Addressed most PR comments
ethanfrey Oct 24, 2019
8dee72a
Fix scopelint errors
ethanfrey Oct 24, 2019
b3a7de7
More test coverage on abci interface - handler and module
ethanfrey Oct 24, 2019
9652ec5
Becoming convinced scopelinter hates table tests
ethanfrey Oct 24, 2019
f039c59
added proposal handler
Oct 31, 2019
85ad699
renamed beginblock
Oct 31, 2019
86184fa
changed height flag name
Oct 31, 2019
c1233ff
added tstore key
Oct 31, 2019
ca1d0fb
removed pointers
kaustubhkapatral Oct 31, 2019
05adda8
modified keeper
kaustubhkapatral Oct 31, 2019
647306a
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Nov 1, 2019
9a016d3
Update test
ethanfrey Nov 1, 2019
5dbf5d9
Merge remote-tracking branch 'origin/master' into regen-network/upgra…
ethanfrey Nov 5, 2019
7c0bba7
Addressed PR comments
ethanfrey Nov 5, 2019
d8a9c42
Return header for query applied-height
ethanfrey Nov 5, 2019
9c68111
Fix query plan json/binary parsing
ethanfrey Nov 5, 2019
e874d64
Fixed linter issues
ethanfrey Nov 5, 2019
afc0e76
Use prefix store
ethanfrey Nov 5, 2019
7330460
Renamed subroute in rest
Nov 4, 2019
e0fe9be
Better error message
ethanfrey Nov 5, 2019
b11289a
Merge branch 'master' into regen-network/upgrade-module
fedekunze Nov 5, 2019
10af143
Merge branch 'master' into regen-network/upgrade-module
alexanderbez Nov 7, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ upgrade via: `sudo rm -rf /Library/Developer/CommandLineTools; xcode-select --in
correct version via: `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`.
* (keys) [\#5097](https://github.com/cosmos/cosmos-sdk/pull/5097) New `keys migrate` command to assist users migrate their keys
to the new keyring.
* (modules) [\#4233](https://github.com/cosmos/cosmos-sdk/pull/4233) Add upgrade module that coordinates software upgrades of live chains.
* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Introduce new `PeriodicVestingAccount` vesting account type
that allows for arbitrary vesting periods.
* (baseapp) [\#5196](https://github.com/cosmos/cosmos-sdk/pull/5196) Baseapp has a new `runTxModeReCheck` to allow applications to skip expensive and unnecessary re-checking of transactions.
Expand Down
57 changes: 27 additions & 30 deletions x/gov/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const (
StatusRejected = types.StatusRejected
StatusFailed = types.StatusFailed
ProposalTypeText = types.ProposalTypeText
ProposalTypeSoftwareUpgrade = types.ProposalTypeSoftwareUpgrade
QueryParams = types.QueryParams
QueryProposals = types.QueryProposals
QueryProposal = types.QueryProposal
Expand Down Expand Up @@ -111,7 +110,6 @@ var (
ProposalStatusFromString = types.ProposalStatusFromString
ValidProposalStatus = types.ValidProposalStatus
NewTextProposal = types.NewTextProposal
NewSoftwareUpgradeProposal = types.NewSoftwareUpgradeProposal
RegisterProposalType = types.RegisterProposalType
ContentFromProposalType = types.ContentFromProposalType
IsValidProposalType = types.IsValidProposalType
Expand Down Expand Up @@ -142,32 +140,31 @@ var (
)

type (
Keeper = keeper.Keeper
Content = types.Content
Handler = types.Handler
Deposit = types.Deposit
Deposits = types.Deposits
GenesisState = types.GenesisState
MsgSubmitProposal = types.MsgSubmitProposal
MsgDeposit = types.MsgDeposit
MsgVote = types.MsgVote
DepositParams = types.DepositParams
TallyParams = types.TallyParams
VotingParams = types.VotingParams
Params = types.Params
Proposal = types.Proposal
Proposals = types.Proposals
ProposalQueue = types.ProposalQueue
ProposalStatus = types.ProposalStatus
TextProposal = types.TextProposal
SoftwareUpgradeProposal = types.SoftwareUpgradeProposal
QueryProposalParams = types.QueryProposalParams
QueryDepositParams = types.QueryDepositParams
QueryVoteParams = types.QueryVoteParams
QueryProposalsParams = types.QueryProposalsParams
ValidatorGovInfo = types.ValidatorGovInfo
TallyResult = types.TallyResult
Vote = types.Vote
Votes = types.Votes
VoteOption = types.VoteOption
Keeper = keeper.Keeper
Content = types.Content
Handler = types.Handler
Deposit = types.Deposit
Deposits = types.Deposits
GenesisState = types.GenesisState
MsgSubmitProposal = types.MsgSubmitProposal
MsgDeposit = types.MsgDeposit
MsgVote = types.MsgVote
DepositParams = types.DepositParams
TallyParams = types.TallyParams
VotingParams = types.VotingParams
Params = types.Params
Proposal = types.Proposal
Proposals = types.Proposals
ProposalQueue = types.ProposalQueue
ProposalStatus = types.ProposalStatus
TextProposal = types.TextProposal
QueryProposalParams = types.QueryProposalParams
QueryDepositParams = types.QueryDepositParams
QueryVoteParams = types.QueryVoteParams
QueryProposalsParams = types.QueryProposalsParams
ValidatorGovInfo = types.ValidatorGovInfo
TallyResult = types.TallyResult
Vote = types.Vote
Votes = types.Votes
VoteOption = types.VoteOption
)
2 changes: 1 addition & 1 deletion x/gov/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type PostProposalReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title" yaml:"title"` // Title of the proposal
Description string `json:"description" yaml:"description"` // Description of the proposal
ProposalType string `json:"proposal_type" yaml:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal}
ProposalType string `json:"proposal_type" yaml:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal }
aaronc marked this conversation as resolved.
Show resolved Hide resolved
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer
InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Coins to add to the proposal's deposit
}
Expand Down
3 changes: 0 additions & 3 deletions x/gov/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ func NormalizeProposalType(proposalType string) string {
case "Text", "text":
return types.ProposalTypeText

case "SoftwareUpgrade", "software_upgrade":
return types.ProposalTypeSoftwareUpgrade

default:
return ""
}
Expand Down
9 changes: 4 additions & 5 deletions x/gov/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitPropos
),
)

submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, sdk.NewAttribute(types.AttributeKeyProposalType, msg.Content.ProposalType()))
if votingStarted {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeSubmitProposal,
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.ProposalID)),
),
submitEvent.AppendAttributes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
submitEvent.AppendAttributes(
submitEvent = submitEvent.AppendAttributes(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.ProposalID)),
)
}
ctx.EventManager().EmitEvent(submitEvent)

return sdk.Result{
Data: GetProposalIDBytes(proposal.ProposalID),
Expand Down
13 changes: 0 additions & 13 deletions x/gov/legacy/v0_34/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

var (
_ ProposalContent = TextProposal{}
_ ProposalContent = SoftwareUpgradeProposal{}
)

const (
Expand All @@ -35,14 +34,9 @@ const (
ProposalTypeNil ProposalKind = 0x00
ProposalTypeText ProposalKind = 0x01
ProposalTypeParameterChange ProposalKind = 0x02
ProposalTypeSoftwareUpgrade ProposalKind = 0x03
)

type (
SoftwareUpgradeProposal struct {
TextProposal
}

ProposalQueue []uint64

ProposalKind byte
Expand Down Expand Up @@ -142,8 +136,6 @@ func (tp TextProposal) GetTitle() string { return tp.Title }
func (tp TextProposal) GetDescription() string { return tp.Description }
func (tp TextProposal) ProposalType() ProposalKind { return ProposalTypeText }

func (sup SoftwareUpgradeProposal) ProposalType() ProposalKind { return ProposalTypeSoftwareUpgrade }

// ProposalStatusToString turns a string into a ProposalStatus
func ProposalStatusFromString(str string) (ProposalStatus, error) {
switch str {
Expand Down Expand Up @@ -290,8 +282,6 @@ func ProposalTypeFromString(str string) (ProposalKind, error) {
return ProposalTypeText, nil
case "ParameterChange":
return ProposalTypeParameterChange, nil
case "SoftwareUpgrade":
return ProposalTypeSoftwareUpgrade, nil
default:
return ProposalKind(0xff), fmt.Errorf("'%s' is not a valid proposal type", str)
}
Expand Down Expand Up @@ -331,8 +321,6 @@ func (pt ProposalKind) String() string {
return "Text"
case ProposalTypeParameterChange:
return "ParameterChange"
case ProposalTypeSoftwareUpgrade:
return "SoftwareUpgrade"
default:
return ""
}
Expand All @@ -341,5 +329,4 @@ func (pt ProposalKind) String() string {
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterInterface((*ProposalContent)(nil), nil)
cdc.RegisterConcrete(TextProposal{}, "gov/TextProposal", nil)
cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "gov/SoftwareUpgradeProposal", nil)
}
2 changes: 0 additions & 2 deletions x/gov/legacy/v0_36/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func migrateContent(proposalContent v034gov.ProposalContent) (content Content) {
switch proposalContent.ProposalType() {
case v034gov.ProposalTypeText:
return NewTextProposal(proposalContent.GetTitle(), proposalContent.GetDescription())
case v034gov.ProposalTypeSoftwareUpgrade:
return NewSoftwareUpgradeProposal(proposalContent.GetTitle(), proposalContent.GetDescription())
default:
return nil
}
Expand Down
29 changes: 1 addition & 28 deletions x/gov/legacy/v0_36/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const (

DefaultCodespace sdk.CodespaceType = "gov"

ProposalTypeText string = "Text"
ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
ProposalTypeText string = "Text"

MaxDescriptionLength int = 5000
MaxTitleLength int = 140
Expand All @@ -29,7 +28,6 @@ const (

var (
_ Content = TextProposal{}
_ Content = SoftwareUpgradeProposal{}
)

type (
Expand All @@ -41,11 +39,6 @@ type (
Description string `json:"description"`
}

SoftwareUpgradeProposal struct {
Title string `json:"title"`
Description string `json:"description"`
}

Content interface {
GetTitle() string
GetDescription() string
Expand Down Expand Up @@ -114,25 +107,6 @@ func (tp TextProposal) String() string {
`, tp.Title, tp.Description)
}

func NewSoftwareUpgradeProposal(title, description string) Content {
return SoftwareUpgradeProposal{title, description}
}

func (sup SoftwareUpgradeProposal) GetTitle() string { return sup.Title }
func (sup SoftwareUpgradeProposal) GetDescription() string { return sup.Description }
func (sup SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }
func (sup SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade }
func (sup SoftwareUpgradeProposal) ValidateBasic() sdk.Error {
return ValidateAbstract(DefaultCodespace, sup)
}

func (sup SoftwareUpgradeProposal) String() string {
return fmt.Sprintf(`Software Upgrade Proposal:
Title: %s
Description: %s
`, sup.Title, sup.Description)
}

func ErrInvalidProposalContent(cs sdk.CodespaceType, msg string) sdk.Error {
return sdk.NewError(cs, CodeInvalidContent, fmt.Sprintf("invalid proposal content: %s", msg))
}
Expand Down Expand Up @@ -160,5 +134,4 @@ func ValidateAbstract(codespace sdk.CodespaceType, c Content) sdk.Error {
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterInterface((*Content)(nil), nil)
cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil)
cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil)
}
2 changes: 1 addition & 1 deletion x/gov/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const contextKeyBadProposal = "contextKeyBadProposal"
// for the key contextKeyBadProposal or if the value is false.
func badProposalHandler(ctx sdk.Context, c types.Content) sdk.Error {
switch c.ProposalType() {
case types.ProposalTypeText, types.ProposalTypeSoftwareUpgrade:
case types.ProposalTypeText:
v := ctx.Value(contextKeyBadProposal)

if v == nil || !v.(bool) {
Expand Down
1 change: 0 additions & 1 deletion x/gov/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil)

cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil)
cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil)
}

// RegisterProposalTypeCodec registers an external proposal content type defined
Expand Down
1 change: 1 addition & 0 deletions x/gov/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ const (
AttributeValueProposalPassed = "proposal_passed" // met vote quorum
AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum
AttributeValueProposalFailed = "proposal_failed" // error on proposal handler
AttributeKeyProposalType = "proposal_type"
)
6 changes: 0 additions & 6 deletions x/gov/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ func (msg MsgSubmitProposal) ValidateBasic() sdk.Error {
if msg.Content == nil {
return ErrInvalidProposalContent(DefaultCodespace, "missing content")
}
if msg.Content.ProposalType() == ProposalTypeSoftwareUpgrade {
// Disable software upgrade proposals as they are currently equivalent
// to text proposals. Re-enable once a valid software upgrade proposal
// handler is implemented.
return ErrInvalidProposalType(DefaultCodespace, msg.Content.ProposalType())
}
if msg.Proposer.Empty() {
return sdk.ErrInvalidAddress(msg.Proposer.String())
}
Expand Down
1 change: 0 additions & 1 deletion x/gov/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestMsgSubmitProposal(t *testing.T) {
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, true},
{"", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "", ProposalTypeText, addrs[0], coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeSoftwareUpgrade, addrs[0], coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, sdk.AccAddress{}, coinsPos, false},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsZero, true},
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, true},
Expand Down
56 changes: 4 additions & 52 deletions x/gov/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) {

// Proposal types
const (
ProposalTypeText string = "Text"
ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
ProposalTypeText string = "Text"
)

// TextProposal defines a standard text proposal whose changes need to be
Expand Down Expand Up @@ -243,52 +242,8 @@ func (tp TextProposal) String() string {
`, tp.Title, tp.Description)
}

// SoftwareUpgradeProposal defines a proposal for upgrading the network nodes
// without the need of manually halting at a given height
//
// TODO: We have to add fields for SUP specific arguments e.g. commit hash,
// upgrade date, etc.
type SoftwareUpgradeProposal struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
}

// NewSoftwareUpgradeProposal creates a software upgrade proposal Content
func NewSoftwareUpgradeProposal(title, description string) Content {
return SoftwareUpgradeProposal{title, description}
}

// Implements Content Interface
var _ Content = SoftwareUpgradeProposal{}

// GetTitle returns the proposal title
func (sup SoftwareUpgradeProposal) GetTitle() string { return sup.Title }

// GetDescription returns the proposal description
func (sup SoftwareUpgradeProposal) GetDescription() string { return sup.Description }

// ProposalRoute returns the proposal router key
func (sup SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey }

// ProposalType is "SoftwareUpgrade"
func (sup SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade }

// ValidateBasic validates the content's title and description of the proposal
func (sup SoftwareUpgradeProposal) ValidateBasic() sdk.Error {
return ValidateAbstract(DefaultCodespace, sup)
}

// String implements Stringer interface
func (sup SoftwareUpgradeProposal) String() string {
return fmt.Sprintf(`Software Upgrade Proposal:
Title: %s
Description: %s
`, sup.Title, sup.Description)
}

var validProposalTypes = map[string]struct{}{
ProposalTypeText: {},
ProposalTypeSoftwareUpgrade: {},
ProposalTypeText: {},
}

// RegisterProposalType registers a proposal type. It will panic if the type is
Expand All @@ -307,9 +262,6 @@ func ContentFromProposalType(title, desc, ty string) Content {
case ProposalTypeText:
return NewTextProposal(title, desc)

case ProposalTypeSoftwareUpgrade:
return NewSoftwareUpgradeProposal(title, desc)

default:
return nil
}
Expand All @@ -325,12 +277,12 @@ func IsValidProposalType(ty string) bool {
}

// ProposalHandler implements the Handler interface for governance module-based
// proposals (ie. TextProposal and SoftwareUpgradeProposal). Since these are
// proposals (ie. TextProposal ). Since these are
// merely signaling mechanisms at the moment and do not affect state, it
// performs a no-op.
func ProposalHandler(_ sdk.Context, c Content) sdk.Error {
switch c.ProposalType() {
case ProposalTypeText, ProposalTypeSoftwareUpgrade:
case ProposalTypeText:
// both proposal types do not change state so this performs a no-op
return nil

Expand Down
Loading