diff --git a/.github/workflows/dependencies-review.yml b/.github/workflows/dependencies-review.yml deleted file mode 100644 index 52b58c3a486f..000000000000 --- a/.github/workflows/dependencies-review.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Dependency Review" -on: pull_request - -permissions: - contents: read - -jobs: - dependency-review: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: "1.19" - check-latest: true - - name: "Checkout Repository" - uses: actions/checkout@v3 - - name: "Dependency Review" - uses: actions/dependency-review-action@v3 - - name: "Dependency audit" - run: ./scripts/dep-assert.sh - - name: "Go vulnerability check" - run: make vulncheck diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 2d9b4acec711..e06ba1e39c16 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -8,10 +8,10 @@ permissions: jobs: labeler: permissions: - contents: read # for actions/labeler to determine modified files - pull-requests: write # for actions/labeler to add labels to PRs + contents: read # for actions/labeler to determine modified files + pull-requests: write # for actions/labeler to add labels to PRs runs-on: ubuntu-latest steps: - - uses: actions/labeler@main + - uses: actions/labeler@v4 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml deleted file mode 100644 index 5978270a57ae..000000000000 --- a/.github/workflows/project.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Add PR to project - -on: - pull_request: - types: - - opened - - reopened - -jobs: - add-to-project: - name: Add pull request to project - runs-on: ubuntu-latest - steps: - - uses: actions/add-to-project@v0.3.0 - with: - project-url: https://github.com/orgs/cosmos/projects/26 - github-token: ${{ secrets.PERSONAL_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76fa60202e49..7e2f8553c9fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -180,12 +180,6 @@ jobs: with: name: "${{ github.sha }}-e2e-coverage" continue-on-error: true - - name: sonarcloud - if: env.GIT_DIFF - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} liveness-test: runs-on: ubuntu-latest diff --git a/server/start.go b/server/start.go index 374dc5e98572..8a9020f43275 100644 --- a/server/start.go +++ b/server/start.go @@ -3,6 +3,7 @@ package server // DONTCOVER import ( + "encoding/hex" "errors" "fmt" "net" @@ -24,8 +25,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "encoding/hex" - "cosmossdk.io/tools/rosetta" crgserver "cosmossdk.io/tools/rosetta/lib/server" "github.com/cosmos/cosmos-sdk/client" diff --git a/tests/e2e/auth/vesting/suite.go b/tests/e2e/auth/vesting/suite.go index b9d91fa626c8..e291f0905841 100644 --- a/tests/e2e/auth/vesting/suite.go +++ b/tests/e2e/auth/vesting/suite.go @@ -2,6 +2,8 @@ package testutil import ( "fmt" + "log" + "os" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" @@ -221,6 +223,10 @@ func (s *E2ETestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { } func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { + pwd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } val := s.network.Validators[0] for _, tc := range []struct { name string @@ -234,8 +240,8 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { args: []string{ sdk.AccAddress("addr10______________").String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/periods1.json"), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/periods1.json"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"/testdata/periods1.json")), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"/testdata/periods1.json")), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), @@ -249,7 +255,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { args: []string{ sdk.AccAddress("addr11______________").String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/periods1.json"), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"/testdata/periods1.json")), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), @@ -263,7 +269,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { args: []string{ sdk.AccAddress("addr12______________").String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/periods1.json"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"/testdata/periods1.json")), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), @@ -277,8 +283,8 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { args: []string{ sdk.AccAddress("addr10______________").String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/periods1.json"), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/periods1.json"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"/testdata/periods1.json")), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"/testdata/periods1.json")), fmt.Sprintf("--%s=%s", cli.FlagMerge, "true"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), @@ -306,7 +312,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad lockup filename", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/noexist"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"testdata/noexist")), }, expectErr: true, }, @@ -314,7 +320,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad lockup json", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/badjson"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"testdata/badjson")), }, expectErr: true, }, @@ -322,7 +328,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad lockup periods", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/badperiod.json"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"testdata/badperiod.json")), }, expectErr: true, }, @@ -330,7 +336,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad vesting filename", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/noexist"), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"testdata/noexist")), }, expectErr: true, }, @@ -338,7 +344,7 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad vesting json", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/badjson"), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"testdata/badjson")), }, expectErr: true, }, @@ -346,11 +352,17 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { name: "bad vesting periods", args: []string{ sdk.AccAddress("addr13______________").String(), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/badperiod.json"), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"testdata/badperiod.json")), }, expectErr: true, }, } { + // Synchronize height between test runs, to ensure sequence numbers are + // properly updated. + height, err := s.network.LatestHeight() + s.Require().NoError(err, "Getting initial latest height") + s.T().Logf("Initial latest height: %d", height) + s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -365,24 +377,43 @@ func (s *E2ETestSuite) TestNewMsgCreateClawbackVestingAccountCmd() { s.Require().Equal(tc.expectedCode, txResp.Code) } }) + next, err := s.network.WaitForHeight(height + 1) + s.Require().NoError(err, "Waiting for height...") + height = next + s.T().Logf("Height now: %d", height) } } func (s *E2ETestSuite) TestNewMsgClawbackCmd() { + pwd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + val := s.network.Validators[0] addr := sdk.AccAddress("addr30______________") - _, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewMsgCreateClawbackVestingAccountCmd(), []string{ + _, err = clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewMsgCreateClawbackVestingAccountCmd(), []string{ addr.String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=%s", cli.FlagLockup, "testdata/periods1.json"), - fmt.Sprintf("--%s=%s", cli.FlagVesting, "testdata/periods1.json"), + fmt.Sprintf("--%s=%s", cli.FlagLockup, fmt.Sprintf(pwd+"/testdata/periods1.json")), + fmt.Sprintf("--%s=%s", cli.FlagVesting, fmt.Sprintf(pwd+"/testdata/periods1.json")), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }) s.Require().NoError(err) + // Synchronize height between test runs, to ensure sequence numbers are + // properly updated. + height, err := s.network.LatestHeight() + s.Require().NoError(err, "Getting initial latest height") + s.T().Logf("Initial latest height: %d", height) + next, err := s.network.WaitForHeight(height + 1) + s.Require().NoError(err, "Waiting for height...") + height = next + s.T().Logf("Height now: %d", height) + for _, tc := range []struct { name string args []string @@ -433,6 +464,12 @@ func (s *E2ETestSuite) TestNewMsgClawbackCmd() { respType: &sdk.TxResponse{}, }, } { + // Synchronize height between test runs, to ensure sequence numbers are + // properly updated. + height, err := s.network.LatestHeight() + s.Require().NoError(err, "Getting initial latest height") + s.T().Logf("Initial latest height: %d", height) + s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -447,5 +484,9 @@ func (s *E2ETestSuite) TestNewMsgClawbackCmd() { s.Require().Equal(tc.expectedCode, txResp.Code) } }) + next, err := s.network.WaitForHeight(height + 1) + s.Require().NoError(err, "Waiting for height...") + height = next + s.T().Logf("Height now: %d", height) } } diff --git a/x/auth/vesting/client/testutil/testdata/badjson b/tests/e2e/auth/vesting/testdata/badjson similarity index 100% rename from x/auth/vesting/client/testutil/testdata/badjson rename to tests/e2e/auth/vesting/testdata/badjson diff --git a/x/auth/vesting/client/testutil/testdata/badperiod.json b/tests/e2e/auth/vesting/testdata/badperiod.json similarity index 98% rename from x/auth/vesting/client/testutil/testdata/badperiod.json rename to tests/e2e/auth/vesting/testdata/badperiod.json index e580e831438b..ae2735ab690d 100644 --- a/x/auth/vesting/client/testutil/testdata/badperiod.json +++ b/tests/e2e/auth/vesting/testdata/badperiod.json @@ -6,4 +6,4 @@ "length_seconds": -500 } ] -} +} \ No newline at end of file diff --git a/x/auth/vesting/client/testutil/testdata/periods1.json b/tests/e2e/auth/vesting/testdata/periods1.json similarity index 68% rename from x/auth/vesting/client/testutil/testdata/periods1.json rename to tests/e2e/auth/vesting/testdata/periods1.json index 82255f074c99..9c2c0a0d89c4 100644 --- a/x/auth/vesting/client/testutil/testdata/periods1.json +++ b/tests/e2e/auth/vesting/testdata/periods1.json @@ -3,11 +3,11 @@ "periods": [ { "coins": "10stake", - "length": 2592000 + "length_seconds": 2592000 }, { "coins": "10stake", - "length":2592000 + "length_seconds":2592000 } ] } diff --git a/tests/e2e/gov/query.go b/tests/e2e/gov/query.go index b143f910566d..8b8b1a8db518 100644 --- a/tests/e2e/gov/query.go +++ b/tests/e2e/gov/query.go @@ -23,7 +23,7 @@ func (s *E2ETestSuite) TestCmdParams() { { "json output", []string{fmt.Sprintf("--%s=json", flags.FlagOutput)}, - `{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","proposal_cancel_ratio":"0.500000000000000000","proposal_cancel_dest":"","expedited_voting_period":"86400s","expedited_threshold":"0.667000000000000000","expedited_min_deposit":[{"denom":"stake","amount":"50000000"}]}}`, + `{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","expedited_voting_period":"86400s","expedited_threshold":"0.667000000000000000","expedited_min_deposit":[{"denom":"stake","amount":"50000000"}],"burn_vote_quorum":false,"burn_proposal_deposit_prevote":false,"burn_vote_veto":true}}`, }, { "text output", @@ -35,6 +35,9 @@ deposit_params: - amount: "10000000" denom: stake params: + burn_proposal_deposit_prevote: false + burn_vote_quorum: false + burn_vote_veto: true expedited_min_deposit: - amount: "50000000" denom: stake diff --git a/tests/go.mod b/tests/go.mod index 8f18aa90c67e..afd6507b0cad 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -178,6 +178,7 @@ replace ( // We always want to test against the latest version of the simapp. cosmossdk.io/simapp => ../simapp github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + github.com/cometbft/cometbft => github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146 // We always want to test against the latest version of the SDK. github.com/cosmos/cosmos-sdk => ../. // Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities. diff --git a/tests/go.sum b/tests/go.sum index 7c189c147ae2..e1a7ff74eaf8 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -311,8 +311,6 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= -github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -807,6 +805,8 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146 h1:Qkshh58fZCRoHSzbyW8NJf1wBhf9bg1MPFZEuyuI9lE= +github.com/osmosis-labs/cometbft v0.0.0-20240103055822-28da358e3146/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= diff --git a/tests/integration/bank/keeper/deterministic_test.go b/tests/integration/bank/keeper/deterministic_test.go index a07e0d48f9da..112d11489260 100644 --- a/tests/integration/bank/keeper/deterministic_test.go +++ b/tests/integration/bank/keeper/deterministic_test.go @@ -218,7 +218,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupply() { suite.Require().NoError(suite.bankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins)) req := &banktypes.QueryTotalSupplyRequest{} - testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.TotalSupply, 243, false) + testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.TotalSupply, 3285, false) } func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupplyOf() { @@ -238,7 +238,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryTotalSupplyOf() { suite.Require().NoError(suite.bankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, sdk.NewCoins(coin))) req := &banktypes.QuerySupplyOfRequest{Denom: coin.GetDenom()} - testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.SupplyOf, 1021, false) + testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.SupplyOf, 2033, false) } func (suite *DeterministicTestSuite) TestGRPCQueryParams() { @@ -403,50 +403,51 @@ func (suite *DeterministicTestSuite) TestGRPCSendEnabled() { testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.SendEnabled, 4063, false) } -func (suite *DeterministicTestSuite) TestGRPCDenomOwners() { - rapid.Check(suite.T(), func(t *rapid.T) { - denom := rapid.StringMatching(denomRegex).Draw(t, "denom") - numAddr := rapid.IntRange(1, 10).Draw(t, "number-address") - for i := 0; i < numAddr; i++ { - addr := testdata.AddressGenerator(t).Draw(t, "address") - - coin := sdk.NewCoin( - denom, - sdk.NewInt(rapid.Int64Min(1).Draw(t, "amount")), - ) - - err := banktestutil.FundAccount(suite.bankKeeper, suite.ctx, addr, sdk.NewCoins(coin)) - suite.Require().NoError(err) - } - - req := &banktypes.QueryDenomOwnersRequest{ - Denom: denom, - Pagination: testdata.PaginationGenerator(t, uint64(numAddr)).Draw(t, "pagination"), - } - testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.DenomOwners, 0, true) - }) - - denomOwners := []*banktypes.DenomOwner{ - { - Address: "cosmos1qg65a9q6k2sqq7l3ycp428sqqpmqcucgzze299", - Balance: coin1, - }, - { - Address: "cosmos1qglnsqgpq48l7qqzgs8qdshr6fh3gqq9ej3qut", - Balance: coin1, - }, - } - - for i := 0; i < len(denomOwners); i++ { - addr, err := sdk.AccAddressFromBech32(denomOwners[i].Address) - suite.Require().NoError(err) - - err = banktestutil.FundAccount(suite.bankKeeper, suite.ctx, addr, sdk.NewCoins(coin1)) - suite.Require().NoError(err) - } - - req := &banktypes.QueryDenomOwnersRequest{ - Denom: coin1.GetDenom(), - } - testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.DenomOwners, 2525, false) -} +// Not implemented in Osmosis +// func (suite *DeterministicTestSuite) TestGRPCDenomOwners() { +// rapid.Check(suite.T(), func(t *rapid.T) { +// denom := rapid.StringMatching(denomRegex).Draw(t, "denom") +// numAddr := rapid.IntRange(1, 10).Draw(t, "number-address") +// for i := 0; i < numAddr; i++ { +// addr := testdata.AddressGenerator(t).Draw(t, "address") + +// coin := sdk.NewCoin( +// denom, +// sdk.NewInt(rapid.Int64Min(1).Draw(t, "amount")), +// ) + +// err := banktestutil.FundAccount(suite.bankKeeper, suite.ctx, addr, sdk.NewCoins(coin)) +// suite.Require().NoError(err) +// } + +// req := &banktypes.QueryDenomOwnersRequest{ +// Denom: denom, +// Pagination: testdata.PaginationGenerator(t, uint64(numAddr)).Draw(t, "pagination"), +// } +// testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.DenomOwners, 0, true) +// }) + +// denomOwners := []*banktypes.DenomOwner{ +// { +// Address: "cosmos1qg65a9q6k2sqq7l3ycp428sqqpmqcucgzze299", +// Balance: coin1, +// }, +// { +// Address: "cosmos1qglnsqgpq48l7qqzgs8qdshr6fh3gqq9ej3qut", +// Balance: coin1, +// }, +// } + +// for i := 0; i < len(denomOwners); i++ { +// addr, err := sdk.AccAddressFromBech32(denomOwners[i].Address) +// suite.Require().NoError(err) + +// err = banktestutil.FundAccount(suite.bankKeeper, suite.ctx, addr, sdk.NewCoins(coin1)) +// suite.Require().NoError(err) +// } + +// req := &banktypes.QueryDenomOwnersRequest{ +// Denom: coin1.GetDenom(), +// } +// testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.DenomOwners, 2525, false) +// } diff --git a/types/result.go b/types/result.go index 536a37828271..21daec7f1b47 100644 --- a/types/result.go +++ b/types/result.go @@ -14,8 +14,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) -var cdc = codec.NewLegacyAmino() - func (gi GasInfo) String() string { bz, _ := codec.MarshalYAML(codec.NewProtoCodec(nil), &gi) return string(bz) diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index 5c2770840417..63a8d90b8251 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -3,7 +3,6 @@ package cli import ( "encoding/json" "fmt" - "io/ioutil" "os" "strconv" "time" @@ -221,7 +220,7 @@ func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { // readScheduleFile reads the file at path and unmarshals it to get the schedule. // Returns start time, periods, and error. func readScheduleFile(path string) (int64, []types.Period, error) { - contents, err := ioutil.ReadFile(path) + contents, err := os.ReadFile(path) if err != nil { return 0, nil, err } diff --git a/x/auth/vesting/types/period.go b/x/auth/vesting/types/period.go index 85193037b6fb..ca24bdb6b6e9 100644 --- a/x/auth/vesting/types/period.go +++ b/x/auth/vesting/types/period.go @@ -176,11 +176,12 @@ func DisjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (int64, for iP < lenP && iQ < lenQ { nextP := timeP + periodsP[iP].Length // next p event in absolute time nextQ := timeQ + periodsQ[iQ].Length // next q event in absolute time - if nextP < nextQ { + switch { + case nextP < nextQ: consumeP(nextP) - } else if nextP > nextQ { + case nextP > nextQ: consumeQ(nextQ) - } else { + default: consumeBoth(nextP) } } @@ -254,7 +255,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi } // consumeBoth processes simultaneous events in P and Q and emits an - // event if the minumum of P and Q changes + // event if the minimum of P and Q changes consumeBoth := func(nextTime int64) { amountP = amountP.Add(periodsP[iP].Amount...) amountQ = amountQ.Add(periodsQ[iQ].Amount...) @@ -275,11 +276,12 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi for iP < lenP && iQ < lenQ { nextP := timeP + periodsP[iP].Length // next p event in absolute time nextQ := timeQ + periodsQ[iQ].Length // next q event in absolute time - if nextP < nextQ { + switch { + case nextP < nextQ: consumeP(nextP) - } else if nextP > nextQ { + case nextP > nextQ: consumeQ(nextQ) - } else { + default: consumeBoth(nextP) } } @@ -297,7 +299,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi } endTime = time - return + return startTime, endTime, merged } // AlignSchedules rewrites the first period length to align the two arguments to the same start time, diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index ac12810155e0..5d6de4de84c7 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -12,7 +12,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" ) @@ -617,8 +616,10 @@ func marshalYaml(i interface{}) (interface{}, error) { // Clawback Vesting Account -var _ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil) -var _ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil) +var ( + _ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil) + _ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil) +) // NewClawbackVestingAccount returns a new ClawbackVestingAccount func NewClawbackVestingAccount( @@ -702,7 +703,6 @@ func CoinEq(a, b sdk.Coins) bool { func (va ClawbackVestingAccount) Validate() error { if va.GetStartTime() >= va.GetEndTime() { return errors.New("vesting start-time must be before end-time") - } lockupEnd := va.GetStartTime() @@ -754,7 +754,7 @@ func NewClawbackGrantAction( grantStartTime int64, grantLockupPeriods, grantVestingPeriods []Period, grantCoins sdk.Coins, -) exported.AddGrantAction { +) vestexported.AddGrantAction { return clawbackGrantAction{ funderAddress: funderAddress, grantStartTime: grantStartTime, @@ -764,7 +764,7 @@ func NewClawbackGrantAction( } } -func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error { +func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error { cva, ok := rawAccount.(*ClawbackVestingAccount) if !ok { return fmt.Errorf("expected *ClawbackVestingAccount, got %T", rawAccount) @@ -778,10 +778,9 @@ func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported } cva.addGrant(ctx, cga.grantStartTime, cga.grantLockupPeriods, cga.grantVestingPeriods, cga.grantCoins) return nil - } -func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action exported.AddGrantAction) error { +func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action vestexported.AddGrantAction) error { return action.AddToAccount(ctx, va) } @@ -865,7 +864,7 @@ type clawbackAction struct { bk BankKeeper } -func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) exported.ClawbackAction { +func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) vestexported.ClawbackAction { return clawbackAction{ requestor: requestor, dest: dest, @@ -874,7 +873,7 @@ func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk Bank } } -func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error { +func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error { cva, ok := rawAccount.(*ClawbackVestingAccount) if !ok { return fmt.Errorf("clawback expects *ClawbackVestingAccount, got %T", rawAccount) @@ -885,7 +884,7 @@ func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.Ve return cva.clawback(ctx, ca.dest, ca.ak, ca.bk) } -func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action exported.ClawbackAction) error { +func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action vestexported.ClawbackAction) error { return action.TakeFromAccount(ctx, va) } diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 1d65538f3824..60b55cf89c74 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -31,8 +31,8 @@ type Keeper interface { HasSupply(ctx sdk.Context, denom string) bool GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool) - GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int - AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) + GetSupplyOffset(ctx sdk.Context, denom string) math.Int + AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int) GetSupplyWithOffset(ctx sdk.Context, denom string) sdk.Coin GetPaginatedTotalSupplyWithOffsets(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error) IterateTotalSupplyWithOffsets(ctx sdk.Context, cb func(sdk.Coin) bool) diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 666d335df1b4..c85b3036f7a7 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -440,8 +440,8 @@ func (k BaseSendKeeper) initBalances(ctx sdk.Context, addr sdk.AccAddress, balan return nil } -// 2 blocks after osmosis first epoch -var osmosisFirstEpochHeight = int64(12834361) +// // 2 blocks after osmosis first epoch +// var osmosisFirstEpochHeight = int64(12834361) // setBalance sets the coin balance for an account by address. func (k BaseSendKeeper) setBalance(ctx sdk.Context, addr sdk.AccAddress, balance sdk.Coin) error { diff --git a/x/bank/keeper/supply_offset.go b/x/bank/keeper/supply_offset.go index 81d3045f27b3..ddc0f389f2d2 100644 --- a/x/bank/keeper/supply_offset.go +++ b/x/bank/keeper/supply_offset.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -10,7 +11,7 @@ import ( ) // GetSupplyOffset retrieves the SupplyOffset from store for a specific denom -func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int { +func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) math.Int { store := ctx.KVStore(k.storeKey) supplyOffsetStore := prefix.NewStore(store, types.SupplyOffsetKey) @@ -19,7 +20,7 @@ func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int { return sdk.NewInt(0) } - var amount sdk.Int + var amount math.Int err := amount.Unmarshal(bz) if err != nil { panic(fmt.Errorf("unable to unmarshal supply offset value %v", err)) @@ -29,7 +30,7 @@ func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int { } // setSupplyOffset sets the supply offset for the given denom -func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) { +func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int) { intBytes, err := offsetAmount.Marshal() if err != nil { panic(fmt.Errorf("unable to marshal amount value %v", err)) @@ -47,7 +48,7 @@ func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount } // AddSupplyOffset adjusts the current supply offset of a denom by the inputted offsetAmount -func (k BaseKeeper) AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) { +func (k BaseKeeper) AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int) { k.setSupplyOffset(ctx, denom, k.GetSupplyOffset(ctx, denom).Add(offsetAmount)) } @@ -75,7 +76,7 @@ func (k BaseKeeper) GetPaginatedTotalSupplyWithOffsets(ctx sdk.Context, paginati pageRes, err := query.Paginate(supplyStore, pagination, func(key, value []byte) error { denom := string(key) - var amount sdk.Int + var amount math.Int err := amount.Unmarshal(value) if err != nil { return fmt.Errorf("unable to convert amount string to Int %v", err) @@ -87,7 +88,6 @@ func (k BaseKeeper) GetPaginatedTotalSupplyWithOffsets(ctx sdk.Context, paginati supply = supply.Add(sdk.NewCoin(denom, amount)) return nil }) - if err != nil { return nil, nil, err } @@ -106,7 +106,7 @@ func (k BaseViewKeeper) IterateTotalSupplyWithOffsets(ctx sdk.Context, cb func(s defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amount sdk.Int + var amount math.Int err := amount.Unmarshal(iterator.Value()) if err != nil { panic(fmt.Errorf("unable to unmarshal supply value %v", err)) diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 42af9e04f41b..d4e468db9224 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -847,7 +847,6 @@ func (k Keeper) Undelegate( func (k Keeper) InstantUndelegate( ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec, ) (sdk.Coins, error) { - validator, found := k.GetValidator(ctx, valAddr) if !found { return nil, types.ErrNoDelegatorForAddress @@ -872,7 +871,6 @@ func (k Keeper) InstantUndelegate( return nil, err } return res, nil - } // CompleteUnbonding completes the unbonding of all mature entries in the