diff --git a/docs/governance/proposal-types/params-change/Auth.md b/docs/governance/proposal-types/params-change/Auth.md index 7268c642c17..112b586c971 100644 --- a/docs/governance/proposal-types/params-change/Auth.md +++ b/docs/governance/proposal-types/params-change/Auth.md @@ -30,7 +30,9 @@ There is an option to include a "memo," or additional information (data) to Cosm Decreasing the value of `MaxMemoCharacters` will decrease the character limit for each transaction memo. This may break the functionality of applications that rely upon the data in the memo field. For example, an exchange may use a common deposit address for all of its users, and then individualize account deposits using the memo field. If the memo field suddenly decreased, the exchange may no longer automatically sort its users' transactions. #### Increasing the value of `MaxMemoCharacters` + Increasing the value of `MaxMemoCharacters` will increase the character limit for each transaction memo. This may enable new functionality for applications that use transaction memos. It may also enable an increase in the amount of data in each block, leading to an increased storage need for the blockchain and [state bloat](https://thecontrol.co/state-growth-a-look-at-the-problem-and-its-solutions-6de9d7634b0b). + ### `TxSigLimit` **The max number of signatures per transaction** diff --git a/go.mod b/go.mod index ee126763e5b..74741a41eec 100644 --- a/go.mod +++ b/go.mod @@ -288,11 +288,11 @@ replace ( // force all dependecies to use the same versions of ibc, tendermint and cosmos-sdk github.com/cosmos/ibc-go/v3 => github.com/cosmos/ibc-go/v3 v3.4.0 - github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24 github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.11 // use cosmos style protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24 // latest grpc doesn't work with with our modified proto compiler, so we need to enforce // the following version across all dependencies. diff --git a/tests/e2e/e2e_distribution_test.go b/tests/e2e/e2e_distribution_test.go index 6ba76c9eb1f..99d98e27cf1 100644 --- a/tests/e2e/e2e_distribution_test.go +++ b/tests/e2e/e2e_distribution_test.go @@ -53,3 +53,37 @@ func (s *IntegrationTestSuite) testDistribution() { 5*time.Second, ) } + +/* +fundCommunityPool tests the funding of the community pool on behalf of the distribution module. +Test Benchmarks: +1. Validation that balance of the distribution module account before funding +2. Execution funding the community pool +3. Verification that correct funds have been deposited to distribution module account +*/ +func (s *IntegrationTestSuite) fundCommunityPool() { + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + sender := s.chainA.validators[0].keyInfo.GetAddress() + + beforeDistUatomBalance, _ := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom) + if beforeDistUatomBalance.IsNil() { + // Set balance to 0 if previous balance does not exist + beforeDistUatomBalance = sdk.NewInt64Coin(uatomDenom, 0) + } + + s.execDistributionFundCommunityPool(s.chainA, 0, sender.String(), tokenAmount.String(), standardFees.String()) + + // there are still tokens being added to the community pool through block production rewards but they should be less than 500 tokens + marginOfErrorForBlockReward := sdk.NewInt64Coin(uatomDenom, 500) + + s.Require().Eventually( + func() bool { + afterDistPhotonBalance, err := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom) + s.Require().NoErrorf(err, "Error getting balance: %s", afterDistPhotonBalance) + + return afterDistPhotonBalance.Sub(beforeDistUatomBalance.Add(tokenAmount.Add(standardFees))).IsLT(marginOfErrorForBlockReward) + }, + 15*time.Second, + 5*time.Second, + ) +} diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 661f921e5a9..dbe93d0345e 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -364,69 +364,18 @@ func (s *IntegrationTestSuite) execDistributionFundCommunityPool(c *chain, valId s.T().Logf("Successfully funded community pool") } -func (s *IntegrationTestSuite) execGovSubmitLegacyGovProposal(c *chain, valIdx int, submitterAddr, govProposalPath, fees, govProposalSubType string) { +func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, govCommand string, proposalFlags []string, fees string) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - s.T().Logf("Executing gaiad tx gov submit-proposal on chain %s", c.id) - - gaiaCommand := []string{ - gaiadBinary, - txCommand, - govtypes.ModuleName, - "submit-proposal", - govProposalSubType, - govProposalPath, - fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), - fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), - fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), - "--keyring-backend=test", - "--output=json", - "-y", - } - - s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) - s.T().Logf("Successfully submitted legacy proposal") -} - -func (s *IntegrationTestSuite) execGovDepositProposal(c *chain, valIdx int, submitterAddr string, proposalId int, amount, fees string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - s.T().Logf("Executing gaiad tx gov deposit on chain %s", c.id) - gaiaCommand := []string{ gaiadBinary, txCommand, govtypes.ModuleName, - "deposit", - fmt.Sprintf("%d", proposalId), - amount, - fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), - fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), - fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), - "--keyring-backend=test", - "--output=json", - "-y", + govCommand, } - s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) - s.T().Logf("Successfully deposited proposal %d", proposalId) -} - -func (s *IntegrationTestSuite) execGovVoteProposal(c *chain, valIdx int, submitterAddr string, proposalId int, vote, fees string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - s.T().Logf("Executing gaiad tx gov vote on chain %s", c.id) - - gaiaCommand := []string{ - gaiadBinary, - txCommand, - govtypes.ModuleName, - "vote", - fmt.Sprintf("%d", proposalId), - vote, + generalFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), @@ -435,57 +384,11 @@ func (s *IntegrationTestSuite) execGovVoteProposal(c *chain, valIdx int, submitt "-y", } - s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) - s.T().Logf("Successfully voted on proposal %d", proposalId) -} - -func (s *IntegrationTestSuite) execGovWeightedVoteProposal(c *chain, valIdx int, submitterAddr string, proposalId int, vote, fees string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - s.T().Logf("Executing gaiad tx gov vote on chain %s", c.id) - - gaiaCommand := []string{ - gaiadBinary, - txCommand, - govtypes.ModuleName, - "weighted-vote", - fmt.Sprintf("%d", proposalId), - vote, - fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), - fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), - fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), - "--keyring-backend=test", - "--output=json", - "-y", - } - - s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) - s.T().Logf("Successfully voted on proposal %d", proposalId) -} - -func (s *IntegrationTestSuite) execGovSubmitProposal(c *chain, valIdx int, submitterAddr, govProposalPath, fees string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - s.T().Logf("Executing gaiad tx gov submit-proposal on chain %s", c.id) - - gaiaCommand := []string{ - gaiadBinary, - txCommand, - govtypes.ModuleName, - "submit-proposal", - govProposalPath, - fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), - fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), - fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), - "--keyring-backend=test", - "--output=json", - "-y", - } + gaiaCommand = concatFlags(gaiaCommand, proposalFlags, generalFlags) + s.T().Logf("Executing gaiad tx gov %s on chain %s", govCommand, c.id) s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) - s.T().Logf("Successfully submitted proposal %s", govProposalPath) + s.T().Logf("Successfully executed %s", govCommand) } func (s *IntegrationTestSuite) executeGKeysAddCommand(c *chain, valIdx int, name string, home string) string { diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index ac8682a737d..b4d9e49cd65 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -2,21 +2,25 @@ package e2e import ( "fmt" + "strconv" "time" sdk "github.com/cosmos/cosmos-sdk/types" gov "github.com/cosmos/cosmos-sdk/x/gov/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" ) func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, proposalCounter int, submitter string, fees string) { s.writeGovParamChangeProposalGlobalFees(s.chainA, newGlobalfee) chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + submitGovFlags := []string{"param-change", configFile(proposalGlobalFeeFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + // gov proposing new fees s.T().Logf("Proposal number: %d", proposalCounter) s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fee to %s", newGlobalfee.String()) - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, fees, "param-change", proposalCounter, configFile(proposalGlobalFee)) - s.depositGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter, "yes", false) + s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote") // query the proposal status and new fee s.Require().Eventually( diff --git a/tests/e2e/e2e_gov_test.go b/tests/e2e/e2e_gov_test.go index 7f355eceab4..1daa573887a 100644 --- a/tests/e2e/e2e_gov_test.go +++ b/tests/e2e/e2e_gov_test.go @@ -2,64 +2,15 @@ package e2e import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "strconv" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - gov "github.com/cosmos/cosmos-sdk/x/gov/types" - // govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -/* -SendTokensFromNewGovAccount tests passing a gov proposal that sends tokens on behalf of the gov module to a recipient. -Test Benchmarks: -1. Subtest to fund the community pool via the distribution module -2. Submission, deposit and vote of legacy proposal to fund the gov account from the community pool -3. Validation that funds have been deposited to gov account -4. Submission, deposit and vote of message based proposal to send funds from the gov account to a recipient account -5. Validation that funds have been deposited to recipient account -*/ -func (s *IntegrationTestSuite) SendTokensFromNewGovAccount() { - s.writeGovProposals(s.chainA) - chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) - senderAddress := s.chainA.validators[0].keyInfo.GetAddress() - sender := senderAddress.String() - // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query - proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - - s.fundCommunityPool(chainAAPIEndpoint, sender) - - s.T().Logf("Submitting Legacy Gov Proposal: Community Spend Funding Gov Module") - s.submitLegacyGovProposal(chainAAPIEndpoint, sender, standardFees.String(), "community-pool-spend", proposalCounter, configFile("proposal.json")) - s.T().Logf("Depositing Legacy Gov Proposal: Community Spend Funding Gov Module") - s.depositGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter) - s.T().Logf("Voting Legacy Gov Proposal: Community Spend Funding Gov Module") - s.voteGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter, "yes", false) - - initialGovBalance, err := getSpecificBalance(chainAAPIEndpoint, govModuleAddress, uatomDenom) - s.Require().NoError(err) - proposalCounter++ - - s.T().Logf("Submitting Gov Proposal: Sending Tokens from Gov Module to Recipient") - s.submitNewGovProposal(chainAAPIEndpoint, sender, proposalCounter, configFile("proposal_2.json")) - s.T().Logf("Depositing Gov Proposal: Sending Tokens from Gov Module to Recipient") - s.depositGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter) - s.T().Logf("Voting Gov Proposal: Sending Tokens from Gov Module to Recipient") - s.voteGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter, "yes", false) - s.Require().Eventually( - func() bool { - newGovBalance, err := getSpecificBalance(chainAAPIEndpoint, govModuleAddress, uatomDenom) - s.Require().NoError(err) - - recipientBalance, err := getSpecificBalance(chainAAPIEndpoint, govSendMsgRecipientAddress, uatomDenom) - s.Require().NoError(err) - return newGovBalance.IsEqual(initialGovBalance.Sub(sendGovAmount)) && recipientBalance.Equal(initialGovBalance.Sub(newGovBalance)) - }, - 15*time.Second, - 5*time.Second, - ) -} - /* GovSoftwareUpgrade tests passing a gov proposal to upgrade the chain at a given height. Test Benchmarks: @@ -77,16 +28,10 @@ func (s *IntegrationTestSuite) GovSoftwareUpgrade() { proposalHeight := height + govProposalBlockBuffer // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query proposalCounter++ - - s.T().Logf("Writing proposal %d on chain %s", proposalCounter, s.chainA.id) - s.writeGovUpgradeSoftwareProposal(s.chainA, proposalHeight) - - s.T().Logf("Submitting Gov Proposal: Software Upgrade") - s.submitNewGovProposal(chainAAPIEndpoint, sender, proposalCounter, configFile("proposal_3.json")) - s.T().Logf("Depositing Gov Proposal: Software Upgrade") - s.depositGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter) - s.T().Logf("Weighted Voting Gov Proposal: Software Upgrade") - s.voteGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter, "yes=0.8,no=0.1,abstain=0.05,no_with_veto=0.05", true) + submitGovFlags := []string{"software-upgrade", "Upgrade-0", "--title='Upgrade V1'", "--description='Software Upgrade'", fmt.Sprintf("--upgrade-height=%d", proposalHeight)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes=0.8,no=0.1,abstain=0.05,no_with_veto=0.05"} + s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, upgradetypes.ProposalTypeSoftwareUpgrade, submitGovFlags, depositGovFlags, voteGovFlags, "weighted-vote") s.verifyChainHaltedAtUpgradeHeight(s.chainA, 0, proposalHeight) s.T().Logf("Successfully halted chain at height %d", proposalHeight) @@ -116,7 +61,6 @@ Test Benchmarks: 3. Validation that the chain produced blocks past the intended upgrade height */ func (s *IntegrationTestSuite) GovCancelSoftwareUpgrade() { - chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) senderAddress := s.chainA.validators[0].keyInfo.GetAddress() @@ -125,60 +69,67 @@ func (s *IntegrationTestSuite) GovCancelSoftwareUpgrade() { proposalHeight := height + 50 // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query proposalCounter++ - - s.T().Logf("Writing proposal %d on chain %s", proposalCounter, s.chainA.id) - s.writeGovUpgradeSoftwareProposal(s.chainA, proposalHeight) - - s.T().Logf("Submitting Gov Proposal: Software Upgrade") - s.submitNewGovProposal(chainAAPIEndpoint, sender, proposalCounter, configFile("proposal_3.json")) - s.depositGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter, "yes", false) + submitGovFlags := []string{"software-upgrade", "Upgrade-1", "--title='Upgrade V1'", "--description='Software Upgrade'", fmt.Sprintf("--upgrade-height=%d", proposalHeight)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, upgradetypes.ProposalTypeSoftwareUpgrade, submitGovFlags, depositGovFlags, voteGovFlags, "vote") proposalCounter++ - - s.T().Logf("Writing proposal %d on chain %s", proposalCounter, s.chainA.id) - s.writeGovCancelUpgradeSoftwareProposal(s.chainA) - - s.T().Logf("Submitting Gov Proposal: Cancel Software Upgrade") - s.submitNewGovProposal(chainAAPIEndpoint, sender, proposalCounter, configFile("proposal_4.json")) - s.depositGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, sender, standardFees.String(), proposalCounter, "yes", false) + submitGovFlags = []string{"cancel-software-upgrade", "--title='Upgrade V1'", "--description='Software Upgrade'"} + depositGovFlags = []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags = []string{strconv.Itoa(proposalCounter), "yes"} + s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, upgradetypes.ProposalTypeCancelSoftwareUpgrade, submitGovFlags, depositGovFlags, voteGovFlags, "vote") s.verifyChainPassesUpgradeHeight(s.chainA, 0, proposalHeight) s.T().Logf("Successfully canceled upgrade at height %d", proposalHeight) } /* -fundCommunityPool tests the funding of the community pool on behalf of the distribution module. +GovCommunityPoolSpend tests passing a community spend proposal. Test Benchmarks: -1. Validation that balance of the distribution module account before funding -2. Execution funding the community pool -3. Verification that correct funds have been deposited to distribution module account +1. Fund Community Pool +2. Submission, deposit and vote of proposal to spend from the community pool to send atoms to a recipient +3. Validation that the recipient balance has increased by proposal amount */ -func (s *IntegrationTestSuite) fundCommunityPool(chainAAPIEndpoint, sender string) { - s.Run("fund_community_pool", func() { - beforeDistUatomBalance, _ := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom) - if beforeDistUatomBalance.IsNil() { - // Set balance to 0 if previous balance does not exist - beforeDistUatomBalance = sdk.NewInt64Coin(uatomDenom, 0) - } +func (s *IntegrationTestSuite) GovCommunityPoolSpend() { + s.fundCommunityPool() + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + senderAddress := s.chainA.validators[0].keyInfo.GetAddress() + sender := senderAddress.String() + recipientAddress := s.chainA.validators[1].keyInfo.GetAddress() + recipient := recipientAddress.String() + sendAmount := sdk.NewCoin(uatomDenom, sdk.NewInt(10000000)) // 10uatom + s.writeGovCommunitySpendProposal(s.chainA, sendAmount.String(), recipient) - s.execDistributionFundCommunityPool(s.chainA, 0, sender, tokenAmount.String(), standardFees.String()) + beforeRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) + s.Require().NoError(err) - // there are still tokens being added to the community pool through block production rewards but they should be less than 500 tokens - marginOfErrorForBlockReward := sdk.NewInt64Coin(uatomDenom, 500) + // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query + proposalCounter++ + submitGovFlags := []string{"community-pool-spend", configFile(proposalCommunitySpendFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + s.runGovProcess(chainAAPIEndpoint, sender, proposalCounter, distrtypes.ProposalTypeCommunityPoolSpend, submitGovFlags, depositGovFlags, voteGovFlags, "vote") - s.Require().Eventually( - func() bool { - afterDistPhotonBalance, err := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom) - s.Require().NoErrorf(err, "Error getting balance: %s", afterDistPhotonBalance) + s.Require().Eventually( + func() bool { + afterRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) + s.Require().NoError(err) - return afterDistPhotonBalance.Sub(beforeDistUatomBalance.Add(tokenAmount.Add(standardFees))).IsLT(marginOfErrorForBlockReward) - }, - 15*time.Second, - 5*time.Second, - ) - }) + return afterRecipientBalance.Sub(sendAmount).IsEqual(beforeRecipientBalance) + }, + 10*time.Second, + 5*time.Second, + ) +} + +func (s *IntegrationTestSuite) runGovProcess(chainAAPIEndpoint, sender string, proposalId int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string) { + s.T().Logf("Submitting Gov Proposal: %s", proposalType) + s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, "submit-proposal", submitFlags, govtypes.StatusDepositPeriod) + s.T().Logf("Depositing Gov Proposal: %s", proposalType) + s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, "deposit", depositFlags, govtypes.StatusVotingPeriod) + s.T().Logf("Voting Gov Proposal: %s", proposalType) + s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, voteCommand, voteFlags, govtypes.StatusPassed) } func (s *IntegrationTestSuite) verifyChainHaltedAtUpgradeHeight(c *chain, valIdx, upgradeHeight int) { @@ -222,71 +173,16 @@ func (s *IntegrationTestSuite) verifyChainPassesUpgradeHeight(c *chain, valIdx, ) } -func (s *IntegrationTestSuite) submitLegacyGovProposal(chainAAPIEndpoint string, sender string, fees string, proposalTypeSubCmd string, proposalId int, proposalPath string) { - s.Run("submit_legacy_gov_proposal", func() { - s.execGovSubmitLegacyGovProposal(s.chainA, 0, sender, proposalPath, fees, proposalTypeSubCmd) - - s.Require().Eventually( - func() bool { - proposal, err := queryGovProposal(chainAAPIEndpoint, proposalId) - s.Require().NoError(err) - return proposal.GetProposal().Status == gov.StatusDepositPeriod - }, - 15*time.Second, - 5*time.Second, - ) - }) -} - -func (s *IntegrationTestSuite) submitNewGovProposal(chainAAPIEndpoint, sender string, proposalId int, proposalPath string) { - s.Run("submit_new_gov_proposal", func() { - s.execGovSubmitProposal(s.chainA, 0, sender, proposalPath, standardFees.String()) - - s.Require().Eventually( - func() bool { - proposal, err := queryGovProposal(chainAAPIEndpoint, proposalId) - s.T().Logf("Proposal: %s", proposal.String()) - s.Require().NoError(err) - - return proposal.GetProposal().Status == gov.StatusDepositPeriod - }, - 15*time.Second, - 5*time.Second, - ) - }) -} - -func (s *IntegrationTestSuite) depositGovProposal(chainAAPIEndpoint, sender string, fees string, proposalId int) { - s.Run("deposit_gov_proposal", func() { - s.execGovDepositProposal(s.chainA, 0, sender, proposalId, depositAmount.String(), fees) - - s.Require().Eventually( - func() bool { - proposal, err := queryGovProposal(chainAAPIEndpoint, proposalId) - s.Require().NoError(err) - - return proposal.GetProposal().Status == gov.StatusVotingPeriod - }, - 15*time.Second, - 5*time.Second, - ) - }) -} - -func (s *IntegrationTestSuite) voteGovProposal(chainAAPIEndpoint, sender string, fees string, proposalId int, vote string, weighted bool) { - s.Run("vote_gov_proposal", func() { - if weighted { - s.execGovWeightedVoteProposal(s.chainA, 0, sender, proposalId, vote, fees) - } else { - s.execGovVoteProposal(s.chainA, 0, sender, proposalId, vote, fees) - } +func (s *IntegrationTestSuite) submitGovCommand(chainAAPIEndpoint, sender string, proposalId int, govCommand string, proposalFlags []string, expectedSuccessStatus govtypes.ProposalStatus) { + s.Run(fmt.Sprintf("Running tx gov %s", govCommand), func() { + s.runGovExec(s.chainA, 0, sender, govCommand, proposalFlags, standardFees.String()) s.Require().Eventually( func() bool { proposal, err := queryGovProposal(chainAAPIEndpoint, proposalId) s.Require().NoError(err) - return proposal.GetProposal().Status == gov.StatusPassed + return proposal.GetProposal().Status == expectedSuccessStatus }, 15*time.Second, 5*time.Second, diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index d529040a067..bd409451864 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/client/flags" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -26,7 +25,6 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - gov "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" ibcchanneltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" @@ -64,25 +62,19 @@ const ( numberOfEvidences = 10 slashingShares int64 = 10000 - proposalGlobalFee = "proposal_globalfee.json" + proposalGlobalFeeFilename = "proposal_globalfee.json" + proposalCommunitySpendFilename = "proposal_community_spend.json" ) var ( - gaiaConfigPath = filepath.Join(gaiaHomePath, "config") - stakingAmount = sdk.NewInt(100000000000) - stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) - tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom - standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom - depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(10000000)) // 10uatom - distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() - govModuleAddress = authtypes.NewModuleAddress(gov.ModuleName).String() - proposalCounter = 0 - govSendMsgRecipientAddress = Address() - sendGovAmount = sdk.NewInt64Coin(uatomDenom, 10) - proposalSendMsg = &gov.MsgSubmitProposal{ - InitialDeposit: sdk.Coins{depositAmount}, - // Metadata: b64.StdEncoding.EncodeToString([]byte("Testing 1, 2, 3!")), - } + gaiaConfigPath = filepath.Join(gaiaHomePath, "config") + stakingAmount = sdk.NewInt(100000000000) + stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) + tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom + standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom + depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(10000000)) // 10uatom + distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() + proposalCounter = 0 ) type IntegrationTestSuite struct { @@ -608,85 +600,6 @@ func noRestart(config *docker.HostConfig) { } } -func (s *IntegrationTestSuite) writeGovProposals(c *chain) { - // bankSendMsg := &banktypes.MsgSend{ - // FromAddress: govModuleAddress, - // ToAddress: govSendMsgRecipientAddress, - // Amount: []sdk.Coin{sendGovAmount}, - // } - - // msgs := []sdk.Msg{bankSendMsg} - // protoMsgs, err := txtypes.SetMsgs(msgs) - // s.Require().NoError(err) - // proposalSendMsg.Messages = protoMsgs - // sendMsgBody, err := cdc.MarshalJSON(proposalSendMsg) - // s.Require().NoError(err) - - // proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ - // Title: "Community Pool Spend", - // Description: "Fund Gov !", - // Recipient: govModuleAddress, - // Amount: "1000uatom", - // Deposit: "5000uatom", - // } - // commSpendBody, err := json.MarshalIndent(proposalCommSpend, "", " ") - // s.Require().NoError(err) - - // for _, val := range c.validators { - // err = writeFile(filepath.Join(val.configDir(), "config", "proposal.json"), commSpendBody) - // s.Require().NoError(err) - - // err = writeFile(filepath.Join(val.configDir(), "config", "proposal_2.json"), sendMsgBody) - // s.Require().NoError(err) - // } -} - -func (s *IntegrationTestSuite) writeGovUpgradeSoftwareProposal(c *chain, height int) { - // upgradePlan := &upgradetypes.Plan{ - // Name: "upgrade-1", - // Height: int64(height), - // Info: "binary-1", - // } - - // upgradeProp := &upgradetypes.MsgSoftwareUpgrade{ - // Authority: govModuleAddress, - // Plan: *upgradePlan, - // } - - // msgs := []sdk.Msg{upgradeProp} - // protoMsgs, err := txtypes.SetMsgs(msgs) - // s.Require().NoError(err) - // proposalSendMsg.Messages = protoMsgs - // upgradeProposalBody, err := cdc.MarshalJSON(proposalSendMsg) - // s.Require().NoError(err) - - // path := filepath.Join(c.validators[0].configDir(), "config", "proposal_3.json") - // err = writeFile(path, upgradeProposalBody) - // s.Require().NoError(err) - // fmt.Println("saved proposal_3.json to ", path) -} - -func (s *IntegrationTestSuite) writeGovCancelUpgradeSoftwareProposal(c *chain) { - // cancelUpgradeProp := &upgradetypes.MsgCancelUpgrade{ - // Authority: govModuleAddress, - // } - // protoMsgs, err := txtypes.SetMsgs([]sdk.Msg{cancelUpgradeProp}) - // s.Require().NoError(err) - // proposalSendMsg.Messages = protoMsgs - // cancelUpgradeProposalBody, err := cdc.MarshalJSON(proposalSendMsg) - // s.Require().NoError(err) - - // err = writeFile(filepath.Join(c.validators[0].configDir(), "config", "proposal_4.json"), cancelUpgradeProposalBody) - // s.Require().NoError(err) -} - -func (s *IntegrationTestSuite) writeFile(c *chain, filename string, body []byte) { - for _, val := range c.validators { - err := writeFile(filepath.Join(val.configDir(), "config", filename), body) - s.Require().NoError(err) - } -} - func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, coins sdk.DecCoins) { type ParamInfo struct { Subspace string `json:"subspace"` @@ -715,39 +628,26 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, c }, "", " ") s.Require().NoError(err) - err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalGlobalFee), paramChangeProposalBody) + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalGlobalFeeFilename), paramChangeProposalBody) s.Require().NoError(err) } -func (s *IntegrationTestSuite) writeICAtx(cmd []string, path string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - cmd = append(cmd, fmt.Sprintf("--%s=%s", flags.FlagGenerateOnly, "true")) - s.T().Logf("dry run: ica tx %s", strings.Join(cmd, " ")) - - type txResponse struct { - Body struct { - Messages []map[string]interface{} - } +func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount string, recipient string) { + proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ + Title: "Community Pool Spend", + Description: "Fund Team!", + Recipient: recipient, + Amount: amount, + Deposit: "100uatom", } + commSpendBody, err := json.MarshalIndent(proposalCommSpend, "", " ") + s.Require().NoError(err) - s.executeGaiaTxCommand(ctx, s.chainA, cmd, 0, func(stdOut []byte, stdErr []byte) bool { - var txResp txResponse - s.Require().NoError(json.Unmarshal(stdOut, &txResp)) - b, err := json.MarshalIndent(txResp.Body.Messages[0], "", " ") - s.Require().NoError(err) - - err = writeFile(path, b) - s.Require().NoError(err) - return true - }) - - s.T().Logf("write ica transaction json to %s", path) + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalCommunitySpendFilename), commSpendBody) + s.Require().NoError(err) } func configFile(filename string) string { filepath := filepath.Join(gaiaConfigPath, filename) - fmt.Println("retrieving filepath ", filepath) return filepath } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 0436d02f8bb..53a901550a2 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -11,7 +11,7 @@ var ( runEvidenceTest = true runFeeGrantTest = true runGlobalFeesTest = true - runGovTest = false // legacy gov system needs to be added back + runGovTest = true runIBCTest = true runSlashingTest = true runStakingAndDistributionTest = true @@ -68,9 +68,9 @@ func (s *IntegrationTestSuite) TestGov() { if !runGovTest { s.T().Skip() } - s.SendTokensFromNewGovAccount() s.GovSoftwareUpgrade() s.GovCancelSoftwareUpgrade() + s.GovCommunityPoolSpend() } func (s *IntegrationTestSuite) TestIBC() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index b4234d26d28..e392ca4a5eb 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -116,96 +116,6 @@ func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (dis return res, nil } -// func queryGroupMembers(endpoint string, groupId int) (group.QueryGroupMembersResponse, error) { -// var res group.QueryGroupMembersResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/group_members/%d", endpoint, groupId) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - -// func queryGroupInfo(endpoint string, groupId int) (group.QueryGroupInfoResponse, error) { -// var res group.QueryGroupInfoResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/group_info/%d", endpoint, groupId) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - -// func queryGroupsByAdmin(endpoint string, adminAddress string) (group.QueryGroupsByAdminResponse, error) { -// var res group.QueryGroupsByAdminResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/groups_by_admin/%s", endpoint, adminAddress) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - -// func queryGroupPolicies(endpoint string, groupId int) (group.QueryGroupPoliciesByGroupResponse, error) { -// var res group.QueryGroupPoliciesByGroupResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/group_policies_by_group/%d", endpoint, groupId) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - -// func queryGroupProposal(endpoint string, groupId int) (group.QueryProposalResponse, error) { -// var res group.QueryProposalResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/proposal/%d", endpoint, groupId) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - -// func queryGroupProposalByGroupPolicy(endpoint string, policyAddress string) (group.QueryProposalsByGroupPolicyResponse, error) { -// var res group.QueryProposalsByGroupPolicyResponse -// path := fmt.Sprintf("%s/cosmos/group/v1/proposals_by_group_policy/%s", endpoint, policyAddress) - -// body, err := httpGet(path) -// if err != nil { -// return res, fmt.Errorf("failed to execute HTTP request: %w", err) -// } -// if err := cdc.UnmarshalJSON(body, &res); err != nil { -// return res, err -// } - -// return res, nil -// } - func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalResponse, error) { //nolint:unused // this is called during e2e tests var govProposalResp govtypes.QueryProposalResponse diff --git a/tests/e2e/util.go b/tests/e2e/util.go index 01a1dda02ae..d690e67a2c6 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -44,3 +44,11 @@ func decodeTx(txBytes []byte) (*sdktx.Tx, error) { Signatures: raw.Signatures, }, nil } + +//nolint:unused // this is called during e2e tests +func concatFlags(originalCollection []string, commandFlags []string, generalFlags []string) []string { + originalCollection = append(originalCollection, commandFlags...) + originalCollection = append(originalCollection, generalFlags...) + + return originalCollection +}