Skip to content

Commit

Permalink
merges main
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hanna committed Sep 12, 2024
2 parents bc2f105 + bf92e1e commit 2db779d
Show file tree
Hide file tree
Showing 97 changed files with 3,767 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.34.7"
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
TEST_DOCKER_REPO=cosmos/contrib-atomeonetest
TEST_DOCKER_REPO=cosmos/contrib-atomonetest

GO_SYSTEM_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1-2)
REQUIRE_GO_VERSION = 1.21
Expand Down
16 changes: 8 additions & 8 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ Once the automated releases process is completed, please add any missing informa
With every release, the `goreleaser` tool will create a file with all the build artifact checksums and upload it alongside the artifacts.
The file is called `SHA256SUMS-{{.version}}.txt` and contains the following:
```
098b00ed78ca01456c388d7f1f22d09a93927d7a234429681071b45d94730a05 atomeoned_0.0.4_windows_arm64.exe
15b2b9146d99426a64c19d219234cd0fa725589c7dc84e9d4dc4d531ccc58bec atomeoned_0.0.4_darwin_amd64
604912ee7800055b0a1ac36ed31021d2161d7404cea8db8776287eb512cd67a9 atomeoned_0.0.4_darwin_arm64
76e5ff7751d66807ee85bc5301484d0f0bcc5c90582d4ba1692acefc189392be atomeoned_0.0.4_linux_arm64
bcbca82da2cb2387ad6d24c1f6401b229a9b4752156573327250d37e5cc9bb1c atomeoned_0.0.4_windows_amd64.exe
f39552cbfcfb2b06f1bd66fd324af54ac9ee06625cfa652b71eba1869efe8670 atomeoned_0.0.4_linux_amd64
098b00ed78ca01456c388d7f1f22d09a93927d7a234429681071b45d94730a05 atomoned_0.0.4_windows_arm64.exe
15b2b9146d99426a64c19d219234cd0fa725589c7dc84e9d4dc4d531ccc58bec atomoned_0.0.4_darwin_amd64
604912ee7800055b0a1ac36ed31021d2161d7404cea8db8776287eb512cd67a9 atomoned_0.0.4_darwin_arm64
76e5ff7751d66807ee85bc5301484d0f0bcc5c90582d4ba1692acefc189392be atomoned_0.0.4_linux_arm64
bcbca82da2cb2387ad6d24c1f6401b229a9b4752156573327250d37e5cc9bb1c atomoned_0.0.4_windows_amd64.exe
f39552cbfcfb2b06f1bd66fd324af54ac9ee06625cfa652b71eba1869efe8670 atomoned_0.0.4_linux_amd64
```

### Tagging Procedure

**Important**: _**Always create tags from your local machine**_ since all release tags should be signed and annotated.
Using Github UI will create a `lightweight` tag, so it's possible that `atomeoned version` returns a commit hash, instead of a tag.
This is important because most operators build from source, and having incorrect information when you run `make install && atomeoned version` raises confusion.
Using Github UI will create a `lightweight` tag, so it's possible that `atomoned version` returns a commit hash, instead of a tag.
This is important because most operators build from source, and having incorrect information when you run `make install && atomoned version` raises confusion.

The following steps are the default for tagging a specific branch commit using git on your local machine. Usually, release branches are labeled `release/v*`:

Expand Down
1 change: 1 addition & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

atomone "github.com/atomone-hub/atomone/app"
atomonehelpers "github.com/atomone-hub/atomone/app/helpers"
govtypes "github.com/atomone-hub/atomone/x/gov/types"
)

type EmptyAppOptions struct{}
Expand Down
294 changes: 294 additions & 0 deletions app/gov_handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
package atomone

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/upgrade/plan"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

govclient "github.com/atomone-hub/atomone/x/gov/client"
"github.com/atomone-hub/atomone/x/gov/client/cli"
govv1beta1 "github.com/atomone-hub/atomone/x/gov/types/v1beta1"
)

var (
paramsChangeProposalHandler = govclient.NewProposalHandler(newSubmitParamChangeProposalTxCmd)
upgradeProposalHandler = govclient.NewProposalHandler(newCmdSubmitLegacyUpgradeProposal)
cancelUpgradeProposalHandler = govclient.NewProposalHandler(newCmdSubmitLegacyCancelUpgradeProposal)
)

func init() {
// Proposal types are registered within their specific module in the SDK, but
// using the legacy gov module. To register them in the atomone gov module,
// we need to do it here.
govv1beta1.RegisterProposalType(paramproposal.ProposalTypeChange)
govv1beta1.RegisterProposalType(upgradetypes.ProposalTypeSoftwareUpgrade)
govv1beta1.RegisterProposalType(upgradetypes.ProposalTypeCancelSoftwareUpgrade)
}

// NewSubmitParamChangeProposalTxCmd returns a CLI command handler for creating
// a parameter change proposal governance transaction.
//
// NOTE: copy of x/params/client.newSubmitParamChangeProposalTxCmd() except
// that it creates a atomone.gov.MsgSubmitProposal instead of a
// cosmos.gov.MsgSubmitProposal.
func newSubmitParamChangeProposalTxCmd() *cobra.Command {
return &cobra.Command{
Use: "param-change [proposal-file]",
Args: cobra.ExactArgs(1),
Short: "Submit a parameter change proposal",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit a parameter proposal along with an initial deposit.
The proposal details must be supplied via a JSON file. For values that contains
objects, only non-empty fields will be updated.
IMPORTANT: Currently parameter changes are evaluated but not validated, so it is
very important that any "value" change is valid (ie. correct type and within bounds)
for its respective parameter, eg. "MaxValidators" should be an integer and not a decimal.
Proper vetting of a parameter change proposal should prevent this from happening
(no deposits should occur during the governance process), but it should be noted
regardless.
Example:
$ %s tx gov submit-proposal param-change <path/to/proposal.json> --from=<key_or_address>
Where proposal.json contains:
{
"title": "Staking Param Change",
"description": "Update max validators",
"changes": [
{
"subspace": "staking",
"key": "MaxValidators",
"value": 105
}
],
"deposit": "1000stake"
}
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
proposal, err := paramscutils.ParseParamChangeProposalJSON(clientCtx.LegacyAmino, args[0])
if err != nil {
return err
}

from := clientCtx.GetFromAddress()
content := paramproposal.NewParameterChangeProposal(
proposal.Title, proposal.Description, proposal.Changes.ToParamChanges(),
)

deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit)
if err != nil {
return err
}

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
}

const (
// Deprecated: only used for v1beta1 legacy proposals.
FlagUpgradeHeight = "upgrade-height"
// Deprecated: only used for v1beta1 legacy proposals.
FlagUpgradeInfo = "upgrade-info"
FlagNoValidate = "no-validate"
FlagDaemonName = "daemon-name"
)

// newCmdSubmitLegacyUpgradeProposal implements a command handler for submitting a software upgrade proposal transaction.
// Deprecated: please use NewCmdSubmitUpgradeProposal instead.ck
//
// NOTE: copy of x/upgrade/client.NewCmdSubmitUpgradeProposal() except
// that it creates a atomone.gov.MsgSubmitProposal instead of a
// cosmos.gov.MsgSubmitProposal.
func newCmdSubmitLegacyUpgradeProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]",
Args: cobra.ExactArgs(1),
Short: "Submit a software upgrade proposal",
Long: "Submit a software upgrade along with an initial deposit.\n" +
"Please specify a unique name and height for the upgrade to take effect.\n" +
"You may include info to reference a binary download link, in a format compatible with: https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
name := args[0]
content, err := parseArgsToContent(cmd.Flags(), name)
if err != nil {
return err
}
noValidate, err := cmd.Flags().GetBool(FlagNoValidate)
if err != nil {
return err
}
if !noValidate {
prop := content.(*upgradetypes.SoftwareUpgradeProposal) //nolint:staticcheck // we are intentionally using a deprecated proposal type.
var daemonName string
if daemonName, err = cmd.Flags().GetString(FlagDaemonName); err != nil {
return err
}
var planInfo *plan.Info
if planInfo, err = plan.ParseInfo(prop.Plan.Info); err != nil {
return err
}
if err = planInfo.ValidateFull(daemonName); err != nil {
return err
}
}

from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here.
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
cmd.Flags().Int64(FlagUpgradeHeight, 0, "The height at which the upgrade must happen")
cmd.Flags().String(FlagUpgradeInfo, "", "Info for the upgrade plan such as new version download urls, etc.")
cmd.Flags().Bool(FlagNoValidate, false, "Skip validation of the upgrade info")
cmd.Flags().String(FlagDaemonName, getDefaultDaemonName(), "The name of the executable being upgraded (for upgrade-info validation). Default is the DAEMON_NAME env var if set, or else this executable")

return cmd
}

// newCmdSubmitLegacyCancelUpgradeProposal implements a command handler for submitting a software upgrade cancel proposal transaction.
// Deprecated: please use NewCmdSubmitCancelUpgradeProposal instead.
//
// NOTE: copy of x/upgrade/client.newcmdsubmitcancelupgradeproposal() except
// that it creates a atomone.gov.msgsubmitproposal instead of a
// cosmos.gov.msgsubmitproposal.
func newCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-software-upgrade [flags]",
Args: cobra.ExactArgs(0),
Short: "Cancel the current software upgrade proposal",
Long: "Cancel a software upgrade along with an initial deposit.",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
if err != nil {
return err
}

deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

title, err := cmd.Flags().GetString(cli.FlagTitle)
if err != nil {
return err
}

description, err := cmd.Flags().GetString(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here.
if err != nil {
return err
}

content := upgradetypes.NewCancelSoftwareUpgradeProposal(title, description)

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here.
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
cmd.MarkFlagRequired(cli.FlagTitle) //nolint:errcheck
cmd.MarkFlagRequired(cli.FlagDescription) //nolint:staticcheck,errcheck // we are intentionally using a deprecated flag here.

return cmd
}

// getDefaultDaemonName gets the default name to use for the daemon.
// If a DAEMON_NAME env var is set, that is used.
// Otherwise, the last part of the currently running executable is used.
func getDefaultDaemonName() string {
// DAEMON_NAME is specifically used here to correspond with the Cosmovisor setup env vars.
name := os.Getenv("DAEMON_NAME")
if len(name) == 0 {
_, name = filepath.Split(os.Args[0])
}
return name
}

func parseArgsToContent(fs *pflag.FlagSet, name string) (govv1beta1.Content, error) {
title, err := fs.GetString(cli.FlagTitle)
if err != nil {
return nil, err
}

description, err := fs.GetString(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here.
if err != nil {
return nil, err
}

height, err := fs.GetInt64(FlagUpgradeHeight)
if err != nil {
return nil, err
}

info, err := fs.GetString(FlagUpgradeInfo)
if err != nil {
return nil, err
}

plan := upgradetypes.Plan{Name: name, Height: height, Info: info}
content := upgradetypes.NewSoftwareUpgradeProposal(title, description, plan)
return content, nil
}
4 changes: 2 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ func NewAppKeeper(
govRouter := govv1beta1.NewRouter()
govRouter.
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper))
AddRoute(paramproposal.RouterKey, govv1beta1.WrapSDKHandler(params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper))).
AddRoute(upgradetypes.RouterKey, govv1beta1.WrapSDKHandler(upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)))

// Set legacy router for backwards compatibility with gov v1beta1
appKeepers.GovKeeper.SetLegacyRouter(govRouter)
Expand Down
8 changes: 3 additions & 5 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ import (
"github.com/atomone-hub/atomone/x/mint"
minttypes "github.com/atomone-hub/atomone/x/mint/types"
sdkparams "github.com/atomone-hub/atomone/x/params"
paramsclient "github.com/atomone-hub/atomone/x/params/client"
paramstypes "github.com/atomone-hub/atomone/x/params/types"
"github.com/atomone-hub/atomone/x/slashing"
slashingtypes "github.com/atomone-hub/atomone/x/slashing/types"
"github.com/atomone-hub/atomone/x/staking"
stakingtypes "github.com/atomone-hub/atomone/x/staking/types"
"github.com/atomone-hub/atomone/x/upgrade"
upgradeclient "github.com/atomone-hub/atomone/x/upgrade/client"
upgradetypes "github.com/atomone-hub/atomone/x/upgrade/types"
)

Expand Down Expand Up @@ -67,9 +65,9 @@ var ModuleBasics = module.NewBasicManager(
gov.NewAppModuleBasic(
// TODO remove since no compat needed with old gov handler system?
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
paramsChangeProposalHandler,
upgradeProposalHandler,
cancelUpgradeProposalHandler,
},
),
sdkparams.AppModuleBasic{},
Expand Down
2 changes: 1 addition & 1 deletion contrib/githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [[ $STAGED_GO_FILES != "" ]]; then

gofmt -w -s $file
misspell -w $file
goimports -w -local github.com/atomeone-hub/atomone $file
goimports -w -local github.com/atomone-hub/atomone $file
git add $file

done
Expand Down
2 changes: 1 addition & 1 deletion contrib/githooks/precommit
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [[ $STAGED_GO_FILES != "" ]]; then

gofmt -w -s $file
misspell -w $file
goimports -w -local github.com/atomeone-hub/atomeone $file
goimports -w -local github.com/atomone-hub/atomone $file
git add $file

done
Expand Down
Loading

0 comments on commit 2db779d

Please sign in to comment.