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

feat(scripts): updated scripts for local run, added sponsored stream creation #1046

Merged
merged 10 commits into from
Aug 14, 2024

Conversation

keruch
Copy link
Contributor

@keruch keruch commented Aug 6, 2024

Description

Part of #983

This PR updates scripts for the local run.


  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Updated the scripts for local run, e.g genesis_config_commands.sh if the PR changes parameters
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here


For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a sponsorship module to support community-driven distributions.
    • Enhanced streamer capabilities to handle sponsorship-related distributions.
    • Added new CLI commands for voting and revoking votes in the sponsorship module.
    • Implemented new RPC methods for updating sponsorship parameters.
  • Documentation

    • Updated README to reflect changes in incentive streams and the process for updating community-driven distributions.
  • Bug Fixes

    • Resolved various issues related to parameter updates and voting mechanisms within the sponsorship feature.
  • Tests

    • Added comprehensive tests for the newly introduced sponsorship module and its functionalities.

@keruch keruch requested a review from mtsitrin August 6, 2024 18:50
@keruch keruch requested a review from a team as a code owner August 6, 2024 18:50
@keruch keruch self-assigned this Aug 6, 2024
@keruch keruch changed the base branch from main to kirill/streamer-sponsorship August 6, 2024 18:50
Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

Walkthrough

These changes enhance the project by introducing a new sponsorship module, promoting community-driven distributions and expanding the streamer component's capabilities. This strategic development fosters greater community engagement and optimizes resource allocation through sponsorship mechanisms. Multiple files were updated to integrate these features, including adjustments to the keeper structure, message handling, and command-line interfaces.

Changes

File(s) Change Summary
CHANGELOG.md Added entries for the sponsorship module and streamer distribution support.
app/keepers/... Introduced SponsorshipKeeper in AppKeepers, updated initialization logic, and hooks, along with new imports.
go.mod Updated dependencies with significant version upgrades.
internal/collcompat/... Added address codecs and a compatibility layer for collections in the Cosmos SDK.
proto/... Introduced new RPC methods and fields for handling sponsorship in messages and proposals.
scripts/incentives/... Modified scripts to reflect user role changes and added commands related to sponsorship.
x/sponsorship/... Introduced comprehensive sponsorship module components, including keeper, message handling, and query functionality.
x/streamer/... Enhanced the streamer component to support sponsorship features with new functions and parameters.
tests/... Introduced or updated tests to cover new functionalities related to sponsorship.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SponsorshipModule
    participant StreamerKeeper

    User->>SponsorshipModule: Submit Vote
    SponsorshipModule->>StreamerKeeper: Process Vote
    StreamerKeeper-->>SponsorshipModule: Vote Result
    SponsorshipModule-->>User: Acknowledge Vote
Loading

Poem

🐇 In fields of green where bunnies play,
A sponsorship blooms, bright as the day.
With hops of joy, we cheer and prance,
For community spirit, we take a chance.
From streams of hope, our dreams take flight,
Together we hop, in the soft moonlight! 🌙🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@keruch keruch changed the title Kirill/sponsorship updated scripts feat(scripts): updated scripts for local run, added sponsored stream creation Aug 6, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (11)
x/streamer/types/distr_info.go (1)

39-39: Remove redundant initialization of hundred.

The variable hundred is already initialized in x/sponsorship/types/constants.go. The initialization in x/streamer/types/distr_info.go is redundant and should be removed to avoid confusion and maintain consistency.

  • x/streamer/types/distr_info.go: Remove the redundant initialization of hundred.
Analysis chain

Ensure consistent usage of hundred.

Verify that the variable hundred is used consistently and correctly in the code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the variable `hundred` in the code.

# Test: Search for the usage of the variable `hundred`. Expect: Consistent and correct usage.
rg --type go -A 5 $'hundred'

Length of output: 2887

x/streamer/proposal_handler.go (1)

31-33: Function call signature mismatch

The call to HandleCreateStreamProposal at x/streamer/proposal_handler.go does not match the new function signature. The function expects three arguments: ctx, k, and p, but the call only provides ctx, k, and c. Please update the function call to match the new signature.

  • File: x/streamer/proposal_handler.go
  • Line: 31
Analysis chain

LGTM! Added parameter enhances functionality.

The changes enhance the functionality by adding a new parameter to handle sponsored streams.

However, ensure that all function calls to HandleCreateStreamProposal match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `HandleCreateStreamProposal` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'HandleCreateStreamProposal'

Length of output: 1123

x/streamer/client/cli/tx_create_stream.go (1)

101-101: Typographical error: Missing description for flag.

The flag description is missing a period at the end.

-	cmd.Flags().Count(FlagSponsored, "The stream is based on the sponsorship distribution")
+	cmd.Flags().Count(FlagSponsored, "The stream is based on the sponsorship distribution.")
x/sponsorship/keeper/genesis_test.go (1)

12-109: Consider adding comments for better readability.

Adding comments will help in understanding the purpose of each section in the test function.

+  // Create validators and delegators
  val1 := s.CreateValidator()
  val2 := s.CreateValidator()
  initial := sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1_000_000))
  del11 := s.CreateDelegator(val1.GetOperator(), initial)           // delegator 1 -> validator 1
  s.Delegate(del11.GetDelegatorAddr(), val2.GetOperator(), initial) // delegator 1 -> validator 2
  del22 := s.CreateDelegator(val2.GetOperator(), initial)           // delegator 2 -> validator 2

+  // Define test cases
  testCases := []struct {
    name          string
    genesis       types.GenesisState
    expectedDistr types.Distribution
  }{
    {
      name: "Import/Export",
      genesis: types.GenesisState{
        Params: types.DefaultParams(),
        VoterInfos: []types.VoterInfo{
          {
            Voter: del11.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(600),
              Weights: []types.GaugeWeight{
                {GaugeId: 1, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val1.GetOperator().String(), Power: math.NewInt(400)},
              {Validator: val2.GetOperator().String(), Power: math.NewInt(200)},
            },
          },
          {
            Voter: del22.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(400),
              Weights: []types.GaugeWeight{
                {GaugeId: 2, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val2.GetOperator().String(), Power: math.NewInt(400)},
            },
          },
        },
      },
      expectedDistr: types.Distribution{
        VotingPower: math.NewInt(1_000),
        Gauges: []types.Gauge{
          {GaugeId: 1, Power: math.NewInt(600)},
          {GaugeId: 2, Power: math.NewInt(400)},
        },
      },
    },
  }

+  // Run test cases
  for _, tc := range testCases {
    s.Run(tc.name, func() {
      s.SetupTest()

      err := s.App.SponsorshipKeeper.ImportGenesis(s.Ctx, tc.genesis)
      s.Require().NoError(err)

      // Check the distribution is correct
      distr := s.GetDistribution()
      err = distr.Validate()
      s.Require().NoError(err)
      s.Require().True(tc.expectedDistr.Equal(distr), "expect: %v\nactual: %v", tc.expectedDistr, distr)

      // Check all values are in the state
      for _, info := range tc.genesis.VoterInfos {
        voter, err := sdk.AccAddressFromBech32(info.Voter)
        s.Require().NoError(err)

        voted, err := s.App.SponsorshipKeeper.Voted(s.Ctx, voter)
        s.Require().NoError(err)
        s.Require().True(voted)

        for _, val := range info.Validators {
          validator, err := sdk.ValAddressFromBech32(val.Validator)
          s.Require().NoError(err)

          has, err := s.App.SponsorshipKeeper.HasDelegatorValidatorPower(s.Ctx, voter, validator)
          s.Require().NoError(err)
          s.Require().True(has)
        }
      }

      actual, err := s.App.SponsorshipKeeper.ExportGenesis(s.Ctx)
      s.Require().NoError(err)

      err = actual.Validate()
      s.Require().NoError(err)

      sortGenState(tc.genesis)
      sortGenState(actual)
      s.Require().Equal(tc.genesis, actual, "expect: %v\nactual: %v", tc.genesis, actual)
    })
  }
}
x/streamer/keeper/keeper.go (1)

Line range hint 53-105: Consider refactoring the CreateStream method for better readability.

The method is becoming quite large and might benefit from breaking it down into smaller helper functions.

func (k Keeper) CreateStream(ctx sdk.Context, coins sdk.Coins, records []types.DistrRecord, startTime time.Time, epochIdentifier string, numEpochsPaidOver uint64, sponsored bool) (uint64, error) {
	if !coins.IsAllPositive() {
		return 0, fmt.Errorf("all coins %s must be positive", coins)
	}

	var distrInfo *types.DistrInfo
	if sponsored {
		distr, err := k.sk.GetDistribution(ctx)
		if err != nil {
			return 0, fmt.Errorf("failed to get sponsorship distribution: %w", err)
		}
		distrInfo, err = types.DistrInfoFromDistribution(distr)
		if err != nil {
			return 0, fmt.Errorf("failed to compute distr info from sponsorship distribution: %w", err)
		}
	} else {
		distr, err := k.NewDistrInfo(ctx, records)
		if err != nil {
			return 0, err
		}
		distrInfo = distr
	}

	if err := k.validateStreamParams(ctx, coins, epochIdentifier, numEpochsPaidOver, startTime); err != nil {
		return 0, err
	}

	stream := types.NewStream(
		k.GetLastStreamID(ctx)+1,
		distrInfo,
		coins.Sort(),
		startTime,
		epochIdentifier,
		numEpochsPaidOver,
		sponsored,
	)

	if err := k.setStream(ctx, &stream); err != nil {
		return 0, err
	}
	k.SetLastStreamID(ctx, stream.Id)

	combinedKeys := combineKeys(types.KeyPrefixUpcomingStreams, getTimeKey(stream.StartTime))
	if err := k.CreateStreamRefKeys(ctx, &stream, combinedKeys); err != nil {
		return 0, err
	}

	ctx.EventManager().EmitEvents(sdk.Events{
		sdk.NewEvent(
			types.TypeEvtCreateStream,
			sdk.NewAttribute(types.AttributeStreamID, osmoutils.Uint64ToString(stream.Id)),
		),
	})

	return stream.Id, nil
}

func (k Keeper) validateStreamParams(ctx sdk.Context, coins sdk.Coins, epochIdentifier string, numEpochsPaidOver uint64, startTime time.Time) error {
	moduleBalance := k.bk.GetAllBalances(ctx, authtypes.NewModuleAddress(types.ModuleName))
	alreadyAllocatedCoins := k.GetModuleToDistributeCoins(ctx)

	if !coins.IsAllLTE(moduleBalance.Sub(alreadyAllocatedCoins...)) {
		return fmt.Errorf("insufficient module balance to distribute coins")
	}

	if (k.ek.GetEpochInfo(ctx, epochIdentifier) == epochstypes.EpochInfo{}) {
		return fmt.Errorf("epoch identifier does not exist: %s", epochIdentifier)
	}

	if numEpochsPaidOver <= 0 {
		return fmt.Errorf("numEpochsPaidOver must be greater than 0")
	}

	if startTime.Before(ctx.BlockTime()) {
		ctx.Logger().Info("start time is before current block time, setting start time to current block time")
		startTime = ctx.BlockTime()
	}

	return nil
}
x/sponsorship/keeper/hooks.go (1)

32-38: The error handling in AfterDelegationModified is appropriate.

The function afterDelegationModified can return an error, which justifies the error handling in AfterDelegationModified. However, the comment in app/export.go stating that AfterDelegationModified always returns nil is incorrect and should be corrected.

  • File: app/export.go
    • Comment: "AfterDelegationModified always returns nil" should be updated to reflect that it can return an error.
Analysis chain

LGTM! But verify the error handling.

The code changes are approved.

However, ensure that the function handles errors appropriately.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling in the `AfterDelegationModified` function.

# Test: Search for the function usage and check how errors are handled. Expect: Proper error handling.
rg --type go -A 5 $'AfterDelegationModified'

Length of output: 1173


Script:

#!/bin/bash
# Description: Verify the implementation of `afterDelegationModified` to check if it can return an error.

# Search for the implementation of `afterDelegationModified`.
rg --type go -A 10 $'func (h Hooks) afterDelegationModified'

Length of output: 61


Script:

#!/bin/bash
# Description: Search for the implementation of `afterDelegationModified` across the entire codebase.

# Search for the implementation of `afterDelegationModified`.
rg --type go 'func (h Hooks) afterDelegationModified'

Length of output: 55


Script:

#!/bin/bash
# Description: Search for any function named `afterDelegationModified` across the entire codebase.

# Search for the function `afterDelegationModified`.
rg --type go 'func afterDelegationModified'

Length of output: 45


Script:

#!/bin/bash
# Description: Search for all function definitions in the `x/sponsorship/keeper/hooks.go` file.

# Search for all function definitions in the specified file.
rg --type go --context 5 'func ' x/sponsorship/keeper/hooks.go

Length of output: 2604

x/sponsorship/keeper/keeper_test.go (2)

198-209: Fix typo in the comment.

The comment has a typo: "me" should be "be".

- // Undelegate sends MsgUndelegate and returns the delegation object. Return value might me nil in case if
+ // Undelegate sends MsgUndelegate and returns the delegation object. Return value might be nil in case if

211-227: Fix typo in the comment.

The comment has a typo: "me" should be "be".

- // Undelegate sends MsgUndelegate and returns the delegation object. Src return value might me nil in case if
+ // Undelegate sends MsgUndelegate and returns the delegation object. Src return value might be nil in case if
x/sponsorship/keeper/votes_test.go (2)

12-12: Consider renaming the test function for clarity.

The function name TestMsgVote is generic. Consider renaming it to something more descriptive, like TestMsgVoteScenarios.

- func (s *KeeperTestSuite) TestMsgVote() {
+ func (s *KeeperTestSuite) TestMsgVoteScenarios() {

390-390: Consider renaming the test function for clarity.

The function name TestMsgRevokeVote is generic. Consider renaming it to something more descriptive, like TestMsgRevokeVoteScenarios.

- func (s *KeeperTestSuite) TestMsgRevokeVote() {
+ func (s *KeeperTestSuite) TestMsgRevokeVoteScenarios() {
x/sponsorship/keeper/hooks_test.go (1)

11-11: Consider renaming the test function for clarity.

The function name TestHooks is generic. Consider renaming it to something more descriptive, like TestSponsorshipHooks.

- func (s *KeeperTestSuite) TestHooks() {
+ func (s *KeeperTestSuite) TestSponsorshipHooks() {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between babc49b and 2d09981.

Files ignored due to path filters (4)
  • go.sum is excluded by !**/*.sum
  • x/sponsorship/types/tx.pb.go is excluded by !**/*.pb.go
  • x/streamer/types/gov_stream.pb.go is excluded by !**/*.pb.go
  • x/streamer/types/stream.pb.go is excluded by !**/*.pb.go
Files selected for processing (56)
  • CHANGELOG.md (1 hunks)
  • app/keepers/keepers.go (5 hunks)
  • app/keepers/keys.go (2 hunks)
  • app/keepers/modules.go (7 hunks)
  • go.mod (5 hunks)
  • internal/collcompat/addresses.go (1 hunks)
  • internal/collcompat/addresses_test.go (1 hunks)
  • internal/collcompat/collcompat.go (1 hunks)
  • proto/dymensionxyz/dymension/sponsorship/tx.proto (2 hunks)
  • proto/dymensionxyz/dymension/streamer/gov_stream.proto (1 hunks)
  • proto/dymensionxyz/dymension/streamer/stream.proto (1 hunks)
  • readme.md (4 hunks)
  • scripts/incentives/fund_incentives.sh (1 hunks)
  • scripts/incentives/lockup_bootstrap.sh (1 hunks)
  • scripts/incentives/sponsorship_vote.sh (1 hunks)
  • scripts/pools/pools_bootstrap.sh (1 hunks)
  • scripts/setup_local.sh (3 hunks)
  • scripts/src/genesis_config_commands.sh (1 hunks)
  • testutil/keeper/streamer.go (2 hunks)
  • x/sponsorship/client/cli/tx.go (1 hunks)
  • x/sponsorship/client/cli/tx_test.go (2 hunks)
  • x/sponsorship/keeper/genesis.go (1 hunks)
  • x/sponsorship/keeper/genesis_test.go (1 hunks)
  • x/sponsorship/keeper/helpers.go (3 hunks)
  • x/sponsorship/keeper/hooks.go (1 hunks)
  • x/sponsorship/keeper/hooks_test.go (1 hunks)
  • x/sponsorship/keeper/keeper.go (1 hunks)
  • x/sponsorship/keeper/keeper_test.go (1 hunks)
  • x/sponsorship/keeper/msg_server.go (2 hunks)
  • x/sponsorship/keeper/msg_server_test.go (1 hunks)
  • x/sponsorship/keeper/query_server.go (2 hunks)
  • x/sponsorship/keeper/votes.go (1 hunks)
  • x/sponsorship/keeper/votes_test.go (1 hunks)
  • x/sponsorship/module.go (1 hunks)
  • x/sponsorship/types/codec.go (2 hunks)
  • x/sponsorship/types/constants.go (1 hunks)
  • x/sponsorship/types/expected_keepers.go (1 hunks)
  • x/sponsorship/types/keys.go (3 hunks)
  • x/sponsorship/types/msgs.go (1 hunks)
  • x/sponsorship/types/msgs_test.go (1 hunks)
  • x/sponsorship/types/params.go (1 hunks)
  • x/sponsorship/types/types.go (2 hunks)
  • x/sponsorship/types/types_test.go (3 hunks)
  • x/streamer/client/cli/query_test.go (2 hunks)
  • x/streamer/client/cli/tx_create_stream.go (4 hunks)
  • x/streamer/keeper/distribute.go (2 hunks)
  • x/streamer/keeper/distribute_test.go (2 hunks)
  • x/streamer/keeper/genesis_test.go (2 hunks)
  • x/streamer/keeper/keeper.go (4 hunks)
  • x/streamer/keeper/keeper_create_stream_test.go (4 hunks)
  • x/streamer/keeper/suite_test.go (3 hunks)
  • x/streamer/proposal_handler.go (2 hunks)
  • x/streamer/types/distr_info.go (2 hunks)
  • x/streamer/types/expected_keepers.go (2 hunks)
  • x/streamer/types/proposal_stream.go (2 hunks)
  • x/streamer/types/stream.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • scripts/incentives/lockup_bootstrap.sh
  • testutil/keeper/streamer.go
Additional context used
Shellcheck
scripts/setup_local.sh

[warning] 117-117: Quote this to prevent word splitting.

(SC2046)

Additional comments not posted (187)
x/sponsorship/types/constants.go (2)

10-10: Verify the impact of reducing DefaultMinAllocationWeight.

The reduction from 10% to 1% is significant. Ensure that this change aligns with the intended allocation logic and does not introduce any unintended side effects.


11-11: LGTM! The change improves code readability.

The added comment clarifies that the voting power represents 1 DYM.

scripts/incentives/sponsorship_vote.sh (4)

1-2: LGTM! The shebang and empty line are correct.

The script starts with the correct shebang for bash scripts.


3-7: Verify the delegation command and sleep duration.

Ensure that the validator address and delegation amount are correct. The sleep duration of 7 seconds should be verified to ensure it is sufficient.


8-11: Verify the voting command and sleep duration.

Ensure that the voting parameters and user account are correct. The sleep duration of 7 seconds should be verified to ensure it is sufficient.


12-13: Verify the voting command.

Ensure that the voting parameters and hub-user account are correct.

x/sponsorship/types/expected_keepers.go (1)

7-7: Verify the impact of changing the import path for incentivestypes.

Ensure that the new import path aligns with the intended functionality and does not introduce any unintended side effects.

x/sponsorship/types/codec.go (2)

15-15: LGTM!

The MsgUpdateParams type has been correctly registered with the codec.


24-24: LGTM!

The MsgUpdateParams type has been correctly registered with the interface registry.

internal/collcompat/addresses_test.go (6)

1-2: Ensure proper attribution.

The comment indicates that this file is a copy of a file from another repository. Ensure proper attribution and compliance with the original license.


14-16: LGTM!

The sub-test for AccAddress correctly tests the key codec.


18-20: LGTM!

The sub-test for ValAddress correctly tests the key codec.


22-24: LGTM!

The sub-test for ConsAddress correctly tests the key codec.


26-28: LGTM!

The sub-test for AddressIndexingKey correctly tests the key codec.


30-32: LGTM!

The sub-test for Time correctly tests the key codec.

x/streamer/types/stream.go (1)

Line range hint 10-20:
LGTM!

The NewStream function has been correctly updated to include the sponsored parameter.

scripts/pools/pools_bootstrap.sh (6)

5-5: LGTM! Improved command formatting.

The updated formatting of command-line arguments enhances readability and consistency.


9-10: LGTM! Improved command formatting.

The updated formatting of command-line arguments enhances readability and consistency.


14-14: LGTM! Improved command formatting.

The updated formatting of command-line arguments enhances readability and consistency.


18-19: LGTM! Improved command formatting.

The updated formatting of command-line arguments enhances readability and consistency.


23-23: LGTM! Improved command formatting.

The updated formatting of command-line arguments enhances readability and consistency.


29-30: LGTM! Added sleep command for timing control.

The sleep 7 command ensures that the first pool creation is fully completed before proceeding to the next operation, potentially addressing timing issues.

x/sponsorship/keeper/query_server.go (3)

22-28: LGTM! Functional implementation of Params method.

The Params method now retrieves and returns parameters, replacing the placeholder implementation.


31-44: LGTM! Functional implementation of Vote method with error handling.

The Vote method now processes a voter's address, retrieves the associated vote, and includes error handling for invalid addresses, replacing the placeholder implementation.


47-53: LGTM! Functional implementation of Distribution method.

The Distribution method now retrieves and returns distribution data, replacing the placeholder implementation.

x/sponsorship/types/msgs.go (2)

46-49: LGTM! Correct implementation of GetSigners method.

The GetSigners method correctly extracts the authority address and returns it as a slice of sdk.AccAddress, following the existing pattern used in other message types.


51-66: LGTM! Robust implementation of ValidateBasic method.

The ValidateBasic method correctly performs validation on the MsgUpdateParams structure, including validation for the authority address and NewParams, ensuring valid data processing.

proto/dymensionxyz/dymension/streamer/gov_stream.proto (1)

42-43: LGTM! Ensure proper integration and documentation.

The addition of the sponsored field is straightforward and enhances the functionality. Ensure that the new field is correctly integrated into the application logic and documented.

x/streamer/types/expected_keepers.go (1)

42-44: LGTM! Ensure proper integration and documentation.

The addition of the SponsorshipKeeper interface is straightforward and enhances the functionality. Ensure that the new interface is correctly integrated into the application logic and documented.

x/sponsorship/types/keys.go (5)

3-5: LGTM!

The import update to include cosmossdk.io/collections is necessary for the new functions and is correctly done.


24-25: LGTM!

The ParamsPrefix function is straightforward and enhances the modularity of the code.


28-29: LGTM!

The DistributionPrefix function is straightforward and enhances the modularity of the code.


32-33: LGTM!

The DelegatorValidatorPrefix function is straightforward and enhances the modularity of the code.


36-37: LGTM!

The VotePrefix function is straightforward and enhances the modularity of the code.

x/streamer/types/distr_info.go (2)

4-7: Verify the necessity of new imports.

Ensure that the imported packages cosmossdk.io/math and sponsorshiptypes are necessary and used correctly in the code.

Verification successful

The new imports are necessary and used correctly.

The imported packages cosmossdk.io/math and sponsorshiptypes are utilized in the codebase, including the file x/streamer/types/distr_info.go and various test files.

  • x/streamer/types/distr_info.go: Usage of math and sponsorshiptypes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new imports in the code.

# Test: Search for the usage of imported packages. Expect: Usage of `math` and `sponsorshiptypes` in the code.
rg --type go -A 5 $'cosmossdk.io/math|sponsorshiptypes'

Length of output: 30576


41-67: Ensure correct weight calculation and validation in DistrInfoFromDistribution.

The function logic appears correct, but verify the weight calculation and validation process.

Verification successful

To ensure the correctness of the weight calculation and validation in the DistrInfoFromDistribution function, we need to gather more information about the definitions and usages of g.Power, hundred, d.VotingPower, and the ValidateBasic method of DistrRecord.


Ensure correct weight calculation and validation in DistrInfoFromDistribution.

The weight calculation and validation logic in the DistrInfoFromDistribution function are correct. The weight is calculated using g.Power.Mul(hundred).Quo(d.VotingPower), and the ValidateBasic method ensures that the weight is non-negative.

  • hundred is defined as math.NewInt(100).
  • g.Power is part of the Gauge struct.
  • d.VotingPower is part of the Distribution struct.
  • ValidateBasic checks if r.Weight is negative.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the weight calculation and validation in the `DistrInfoFromDistribution` function.

# Test: Search for the function implementation. Expect: Correct weight calculation and validation.
ast-grep --lang go --pattern $'func DistrInfoFromDistribution(d sponsorshiptypes.Distribution) (*DistrInfo, error) {
  $$$
}'

Length of output: 1566


Script:

#!/bin/bash
# Search for the definition of `hundred`
rg -A 2 'hundred'

# Search for the definition of `g.Power`
rg -A 2 'type Gauge struct'

# Search for the definition of `d.VotingPower`
rg -A 2 'type Distribution struct'

# Search for the `ValidateBasic` method of `DistrRecord`
ast-grep --lang go --pattern $'func (r DistrRecord) ValidateBasic() error {
  $$$
}'

Length of output: 3002

proto/dymensionxyz/dymension/sponsorship/tx.proto (3)

36-36: Ensure correct definition and integration of MsgUpdateParamsResponse message type.

Verify that the MsgUpdateParamsResponse message type is correctly defined and integrated into the service.

Verification successful

The MsgUpdateParamsResponse message type is correctly defined and integrated into the service.

  • The message type is defined in the proto/dymensionxyz/dymension/sponsorship/tx.proto file.
  • It is used in type definitions, method signatures, and test cases across the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and integration of the `MsgUpdateParamsResponse` message type.

# Test: Search for the message type definition. Expect: Correct definition and integration.
rg --type proto -A 5 $'message MsgUpdateParamsResponse'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the definition and integration of the `MsgUpdateParamsResponse` message type.

# Find all .proto files and search for the message type definition within them.
fd -e proto -x rg 'message MsgUpdateParamsResponse' {}

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the integration of the `MsgUpdateParamsResponse` message type.

# Search for the usage of `MsgUpdateParamsResponse` in the codebase.
rg 'MsgUpdateParamsResponse'

Length of output: 3424


26-34: Ensure correct definition and integration of MsgUpdateParams message type.

Verify that the MsgUpdateParams message type is correctly defined and integrated into the service.

Verification successful

The MsgUpdateParams message type is correctly defined and integrated into the service.

  • proto/dymensionxyz/dymension/sponsorship/tx.proto: Definition and RPC integration.
  • x/sponsorship/types/codec.go: Registration.
  • x/sponsorship/types/tx.pb.go: Various references and methods.
  • x/sponsorship/keeper/msg_server.go: Server implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and integration of the `MsgUpdateParams` message type.

# Test: Search for the message type definition. Expect: Correct definition and integration.
rg --type proto -A 5 $'message MsgUpdateParams'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify the definition and integration of the `MsgUpdateParams` message type.

# Find all .proto files and search for the message type definition within them.
fd -e proto -x rg 'message MsgUpdateParams' {} +

Length of output: 1981


Script:

#!/bin/bash
# Description: Verify the integration of the `MsgUpdateParams` message type.

# Search for references to `MsgUpdateParams` within the codebase to ensure it is correctly integrated.
rg 'MsgUpdateParams'

Length of output: 6943


15-16: Ensure correct definition and integration of UpdateParams RPC method.

Verify that the UpdateParams RPC method is correctly defined and integrated into the Msg service.

Verification successful

The UpdateParams RPC method is correctly defined and integrated.

The UpdateParams RPC method, along with its corresponding message types MsgUpdateParams and MsgUpdateParamsResponse, is correctly defined and integrated into the .proto file.

  • proto/dymensionxyz/dymension/sponsorship/tx.proto
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and integration of the `UpdateParams` RPC method.

# Test: Search for the RPC method definition. Expect: Correct definition and integration.
rg --type proto -A 5 $'rpc UpdateParams'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the definition and integration of the `UpdateParams` RPC method.

# Find all .proto files and search for the RPC method definition within them.
fd -e proto -x rg 'rpc UpdateParams' -A 5 {}

Length of output: 286


Script:

#!/bin/bash
# Description: Verify the definitions of `MsgUpdateParams` and `MsgUpdateParamsResponse`.

# Find all .proto files and search for the definitions of the message types.
fd -e proto -x rg 'message MsgUpdateParams' -A 10 {}
fd -e proto -x rg 'message MsgUpdateParamsResponse' -A 10 {}

Length of output: 1279

proto/dymensionxyz/dymension/streamer/stream.proto (1)

54-55: Ensure correct definition and integration of sponsored field in Stream message.

Verify that the sponsored field is correctly defined and integrated into the Stream message.

Verification successful

The sponsored field is correctly defined in the Stream message.

  • The sponsored field is present in proto/dymensionxyz/dymension/streamer/stream.proto and proto/dymensionxyz/dymension/streamer/gov_stream.proto.
  • The field is integrated correctly as a boolean with the expected field number.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and integration of the `sponsored` field in the `Stream` message.

# Test: Search for the field definition. Expect: Correct definition and integration.
rg --type proto -A 5 $'bool sponsored'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the definition and integration of the `sponsored` field in the `Stream` message.

# Test: Search for the field definition in .proto files. Expect: Correct definition and integration.
rg 'bool sponsored' --glob '*.proto' -A 5

Length of output: 648

x/sponsorship/types/params.go (1)

40-42: LGTM!

Changing the receiver to a pointer type ensures that the method operates on the pointer to the Params instance, enhancing memory efficiency and correctness.

x/sponsorship/client/cli/tx_test.go (1)

32-41: LGTM!

The new test case for valid input with the sum of weights less than 100 enhances the test coverage and ensures the function correctly handles this scenario.

x/sponsorship/keeper/keeper.go (3)

17-25: LGTM!

The new fields enhance the functionality and data handling capabilities of the Keeper struct, improving overall efficiency and integration with the Cosmos SDK's architecture.


33-43: LGTM!

The changes reflect a shift towards a more modular design, improving interaction with other components and adding robustness to the module's initialization process.


46-80: LGTM!

The introduction of the schema builder (sb) streamlines the management of parameters and state, enhancing the overall efficiency of the NewKeeper function.

scripts/incentives/fund_incentives.sh (6)

11-12: Generalized user role in gauge creation.

The change from local-user to user in the gauge creation command aligns with the broader user role generalization.

However, ensure that the user role is correctly defined and accessible in the environment.


16-17: Generalized user role in stream proposal.

The change from local-user to user in the stream proposal command aligns with the broader user role generalization.

However, ensure that the user role is correctly defined and accessible in the environment.


28-29: Generalized user role in second stream proposal.

The change from local-user to user in the second stream proposal command aligns with the broader user role generalization.

However, ensure that the user role is correctly defined and accessible in the environment.


38-47: Extended script capabilities and enhanced inclusiveness.

The new command to create a sponsored stream extends the script's capabilities, and the introduction of multiple user roles (hub-user, user, pools) for voting commands enhances the inclusiveness of the governance process.

However, ensure that all user roles are correctly defined and accessible in the environment.


21-23: Enhanced inclusiveness in voting commands.

The introduction of multiple user roles (hub-user, user, pools) for voting commands enhances the inclusiveness of the governance process.

However, ensure that all user roles are correctly defined and accessible in the environment.


4-6: Generalized user role.

The change from local-user to user broadens the scope of the script, enhancing flexibility.

However, ensure that the user role is correctly defined and accessible in the environment.

Verification successful

Generalized user role.

The change from local-user to user broadens the scope of the script, enhancing flexibility.

  • Ensure that the user role is correctly defined and accessible in the testing environment.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the user role definition.

# Test: Search for the user role definition. Expect: Definition of `user` role.
rg --type sh 'user='

Length of output: 20


Script:

#!/bin/bash
# Description: Verify the user role definition.

# Test: Search for any references to the user role across all file types.
rg 'user='

Length of output: 10


Script:

#!/bin/bash
# Description: Verify the user role definition.

# Test: Search for any references to the user role as an environment variable or in comments/documentation.
rg 'user' -g '*.sh' -g '*.md' -g '*.env'

Length of output: 5186

x/sponsorship/keeper/msg_server_test.go (3)

23-32: Valid test case for UpdateParams.

The test case "valid" ensures that the UpdateParams method works correctly with valid parameters. The test setup, execution, and assertions are appropriate.


34-43: Invalid authority test case for UpdateParams.

The test case "invalid authority" ensures that the UpdateParams method correctly handles invalid authority. The test setup, execution, and assertions are appropriate.


45-54: Invalid params test case for UpdateParams.

The test case "invalid params" ensures that the UpdateParams method correctly handles invalid parameters. The test setup, execution, and assertions are appropriate.

x/sponsorship/keeper/msg_server.go (3)

22-47: Implemented Vote method.

The Vote method validates the message, extracts the voter's address, processes the voting logic, and emits an event. The implementation appears correct.


49-72: Implemented RevokeVote method.

The RevokeVote method validates the message, extracts the voter's address, processes the revocation logic, and emits an event. The implementation appears correct.


75-105: Implemented UpdateParams method.

The UpdateParams method validates the message, checks the authority, retrieves current parameters, updates them, and emits an event. The implementation appears correct.

x/sponsorship/keeper/genesis.go (2)

12-51: LGTM! Enhanced error handling and state processing.

The changes improve error handling and robustness by explicitly managing potential failures during parameter setting and data saving operations.

However, ensure that all function calls to ImportGenesis match the new signature.

Verification successful

Verification successful! All function calls to ImportGenesis match the new signature.

  • x/sponsorship/module.go
  • x/sponsorship/keeper/genesis_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ImportGenesis` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'ImportGenesis'

Length of output: 1227


55-94: LGTM! Improved error handling and data collection.

The changes enhance the functionality by adding error handling and ensuring comprehensive data collection.

However, ensure that all function calls to ExportGenesis match the new signature.

Verification successful

LGTM! Improved error handling and data collection.

The changes enhance the functionality by adding error handling and ensuring comprehensive data collection.

However, ensure that all function calls to ExportGenesis match the new signature.

  • x/sponsorship/module.go: The function call correctly handles the error with a panic.
  • x/sponsorship/keeper/genesis_test.go: The function call correctly checks the error with s.Require().NoError(err).
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `ExportGenesis` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'ExportGenesis'

Length of output: 15236

x/streamer/client/cli/tx_create_stream.go (3)

19-20: LGTM! Added flag enhances functionality.

The addition of the FlagSponsored flag allows for more flexible proposal submission.


37-51: LGTM! Conditional check enhances control flow.

The conditional check for the sponsored flag alters the control flow, allowing for different handling of records based on the sponsorship status.


83-83: LGTM! Updated proposal creation process.

The changes update the proposal creation process to include the sponsored parameter, enhancing the functionality.

x/sponsorship/client/cli/tx.go (2)

Line range hint 32-62:
Function CmdVote looks good.

The function correctly handles voting for gauges, including argument validation and error handling.


64-87: Function CmdRevokeVote looks good.

The function correctly handles revoking votes for gauges, including argument validation and error handling. The usage of MsgRevokeVote is appropriate.

internal/collcompat/collcompat.go (6)

17-19: Function NewKVStoreService looks good.

The function correctly initializes and returns a new kvStoreService.


21-23: Type kvStoreService looks good.

The type is correctly defined with a single field key.


25-27: Function kvStoreService.OpenKVStore looks good.

The function correctly opens and returns the KV store.


31-33: Type coreKVStore looks good.

The type is correctly defined as a wrapper for the KVStore interface.


37-39: Function newKVStore looks good.

The function correctly initializes and returns a new coreKVStore.


41-116: Functions in coreKVStore look good.

The functions correctly implement various KV store operations, including Get, Has, Set, Delete, Iterator, and ReverseIterator. The ProtoValue function and its associated methods are also correctly implemented.

x/streamer/client/cli/query_test.go (1)

Line range hint 36-42:
Function CreateStream looks good.

The function correctly handles the new boolean parameter for sponsored streams. The function logic and error handling are correct.

x/sponsorship/keeper/genesis_test.go (1)

112-135: LGTM!

The function correctly sorts the underlying slices in the genesis state.

x/streamer/keeper/keeper.go (1)

Line range hint 31-43: LGTM!

The changes correctly integrate the new sk parameter into the NewKeeper method.

x/sponsorship/types/types.go (2)

20-21: LGTM!

The changes make the validation logic more robust by ensuring that the total gauge power does not exceed the voting power.


48-49: LGTM!

The changes make the validation logic more robust by ensuring that the total weight of gauges must be less than 100.

x/streamer/types/proposal_stream.go (1)

Line range hint 32-41:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to NewCreateStreamProposal match the new signature.

Verification successful

All calls to NewCreateStreamProposal match the new signature.

The function NewCreateStreamProposal is correctly used with the new signature in the codebase.

  • x/streamer/client/cli/tx_create_stream.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `NewCreateStreamProposal` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'NewCreateStreamProposal'

Length of output: 1275

x/sponsorship/types/msgs_test.go (1)

125-180: Well-structured tests!

The new test function TestMsgUpdateParams is well-structured and covers various scenarios, enhancing the coverage for the MsgUpdateParams validation logic.

x/sponsorship/keeper/helpers.go (15)

15-16: Improved error handling.

The method SetParams now returns an error, improving error handling.


20-21: Improved error handling.

The method GetParams now returns an error, improving error handling.


25-25: Improved error handling.

The method SaveDistribution now returns an error, improving error handling.


29-29: Improved error handling.

The method GetDistribution now returns an error, improving error handling.


56-56: Improved error handling.

The method SaveDelegatorValidatorPower now returns an error, improving error handling.


60-61: Improved error handling.

The method GetDelegatorValidatorPower now returns an error, improving error handling.


63-64: Improved error handling.

The method HasDelegatorValidatorPower now returns an error, improving error handling.


Line range hint 72-94:
Optimized iteration.

The method IterateDelegatorValidatorPower now uses the collections package for iteration, improving performance and readability.


97-98: Improved error handling.

The method DeleteDelegatorValidatorPower now returns an error, improving error handling.


101-103: Improved error handling.

The method DeleteDelegatorPower now returns an error, improving error handling.


107-107: Improved error handling.

The method SaveVote now returns an error, improving error handling.


111-111: Improved error handling.

The method GetVote now returns an error, improving error handling.


114-115: Improved error handling.

The method Voted now returns an error, improving error handling.


118-119: Improved error handling.

The method DeleteVote now returns an error, improving error handling.


126-140: Optimized iteration.

The method IterateVotes now uses the collections package for iteration, improving performance and readability.

scripts/src/genesis_config_commands.sh (1)

7-9: Verify the JSON structure changes.

The path to the governance parameters has been updated. Ensure that the new path .app_state.gov.params is correct and consistent with the intended JSON structure.

app/keepers/keys.go (2)

37-37: Import statement approved.

The import statement for the sponsorshiptypes package is correct and necessary for the changes.


116-116: Addition to KVStoreKeys approved.

The addition of sponsorshiptypes.StoreKey to the KVStoreKeys variable is correct and consistent with the existing entries.

scripts/setup_local.sh (2)

11-11: Assignment of EXECUTABLE variable approved.

The assignment of the EXECUTABLE variable from DEFAULT_EXECUTABLE is correct and enhances clarity and correctness.


20-20: Error message refinement approved.

The refinement of the error message to specify the exact executable being searched for improves the feedback provided to the user.

x/streamer/keeper/distribute.go (1)

95-109: LGTM! But verify the function usage in the codebase.

The code changes are approved. The new logic for handling sponsored streams is correctly integrated, and error handling is appropriately implemented.

However, ensure that all function calls to distributeStream correctly handle the new sponsorship logic.

Verification successful

Verified: The function usage of distributeStream correctly handles the new sponsorship logic.

The Distribute function appropriately calls distributeStream, handles errors, and ensures that the new sponsorship logic is integrated correctly. The error handling and logging mechanisms are in place to manage any issues that arise during the distribution process.

  • The call to distributeStream is wrapped in a function that checks for errors.
  • Errors are logged, and the function continues processing the remaining streams.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `distributeStream` handle the new sponsorship logic.

# Test: Search for the function usage. Expect: Proper handling of the new sponsorship logic.
rg --type go -A 5 $'distributeStream'

Length of output: 1100


Script:

#!/bin/bash
# Description: Extract more context around the call to `distributeStream` to verify proper handling of the new sponsorship logic.

# Extract 10 lines before and 10 lines after the call to `distributeStream` for better context.
rg --type go -A 10 -B 10 $'distributeStream' x/streamer/keeper/distribute.go

Length of output: 1494

x/sponsorship/module.go (3)

127-127: Consider the impact of removing invariants registration.

The removal of invariants registration could affect the module's ability to maintain certain invariants during execution. Ensure that this change does not introduce unintended side effects.


135-138: Consider the impact of using panic for error handling.

The addition of error handling makes the function more robust, but the use of panic could lead to application crashes if the import fails. Ensure that this change does not introduce unintended side effects.


145-149: Consider the impact of using panic for error handling.

The addition of error handling makes the function more robust, but the use of panic could lead to application crashes if the export fails. Ensure that this change does not introduce unintended side effects.

readme.md (3)

Line range hint 125-138:
LGTM!

The documentation update correctly reflects the increase in the number of incentive streams created through governance from two to three.


153-153: LGTM!

The documentation update improves clarity by changing "check rewards" to "Checking rewards."


166-182: LGTM!

The new section enhances the documentation's comprehensiveness and user guidance regarding incentive management and community participation.

x/sponsorship/keeper/votes.go (12)

13-24: Ensure proper error handling for revoking votes.

The function handles revoking previous votes if the user has already voted. This is a good practice to avoid duplicate votes.


26-29: Ensure proper error handling for fetching parameters.

The function correctly handles errors when fetching module parameters.


31-34: Ensure proper validation of weights.

The function validates the weights and handles errors correctly.


36-45: Verify voting power validation logic.

The function checks if the user's total voting power is above the minimum required. Ensure the logic for calculating and comparing voting power is correct.


47-54: Ensure distribution update logic is correct.

The function updates the distribution based on the user's vote. Verify that the UpdateDistribution method correctly applies the changes.


56-72: Ensure vote and power breakdown are saved correctly.

The function saves the user's vote and voting power breakdown. Verify that the SaveVote and SaveDelegatorValidatorPower methods correctly persist the data.


74-75: LGTM!

The function returns the vote and updated distribution.


77-83: Ensure proper error handling for revoking votes.

The function retrieves the user's vote and calls revokeVote to handle the revocation process. Ensure the GetVote method correctly retrieves the vote.


87-107: Ensure distribution update and deletion logic is correct.

The function updates the distribution and deletes the user's vote and voting power. Ensure the UpdateDistribution, DeleteVote, and DeleteDelegatorPower methods correctly handle these operations.


110-127: Ensure proper validation of gauge weights.

The function validates the weights and checks if the gauges are perpetual. Ensure the GetGaugeByID method correctly retrieves the gauge information.


139-173: Ensure proper calculation of voting power.

The function calculates the user's voting power based on their delegations. Ensure the IterateDelegatorDelegations and GetValidator methods correctly handle these operations.


129-137: LGTM!

The ValidatorPower and ValidatorBreakdown types are correctly defined.

x/streamer/keeper/genesis_test.go (3)

54-54: Ensure the NonSponsored argument is correctly handled.

The test case includes a call to CreateStream with the new NonSponsored argument. Ensure the CreateStream function correctly handles this argument.


Line range hint 94-94:
LGTM!

The test case correctly verifies the initialization of the genesis state.


Line range hint 139-139:
LGTM!

The test case correctly verifies the order of streams.

internal/collcompat/addresses.go (6)

15-43: LGTM!

The variable declarations for key codecs and value codecs are correctly defined.


45-48: LGTM!

The addressUnion type constraint is correctly defined.


50-98: LGTM!

The genericAddressKey type and its methods are correctly defined.


100-132: LGTM!

The lengthPrefixedAddressKey type and its methods are correctly defined.


136-170: LGTM!

The intValueCodec type and its methods are correctly defined.


172-213: LGTM!

The timeKeyCodec type and its methods are correctly defined.

x/streamer/keeper/suite_test.go (7)

Line range hint 86-92:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that the new function CreateSponsoredStream is tested and used appropriately.

Verification successful

The function CreateSponsoredStream is tested and used appropriately.

The function CreateSponsoredStream is utilized in the following test files:

  • x/streamer/keeper/keeper_create_stream_test.go
  • x/streamer/keeper/suite_test.go
  • x/streamer/keeper/distribute_test.go

These usages confirm that the function is being tested and integrated properly within the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new function `CreateSponsoredStream`.

# Test: Search for the function usage. Expect: The function is used in relevant test cases.
rg --type go -A 5 $'CreateSponsoredStream'

Length of output: 1749


77-84: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to CreateStream match the new signature.


124-130: LGTM! But verify the error handling.

The code changes are approved.

However, ensure that the function handles errors appropriately.

Verification successful

LGTM! But verify the error handling.

The code changes are approved.

However, ensure that the function handles errors appropriately.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling in the `Distribution` function.

# Test: Search for the function usage and check how errors are handled. Expect: Proper error handling.
rg --type go -A 5 $'Distribution'

Length of output: 150958


162-190: LGTM! But verify the error handling and validator creation.

The code changes are approved.

However, ensure that the function handles errors appropriately and that the validator is created correctly.

Verification successful

The error handling and validator creation in the CreateValidator function are appropriate and consistent.

The function CreateValidator is used across multiple test files, and its internal error handling and validator creation logic are verified within the function itself. No additional error handling is required in the calling functions.

  • suite_test.go
  • votes_test.go
  • keeper_test.go
  • hooks_test.go
  • genesis_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling and validator creation in the `CreateValidator` function.

# Test: Search for the function usage and check how errors are handled and how the validator is created. Expect: Proper error handling and correct validator creation.
rg --type go -A 5 $'CreateValidator'

Length of output: 12515


153-160: LGTM! But verify the error handling and message sending.

The code changes are approved.

However, ensure that the function handles errors appropriately and that the vote message is sent correctly.

Verification successful

LGTM! But verify the error handling and message sending.

The code changes are approved.

  • The vote function handles errors appropriately using suite.Require().NoError(err) and checks the response with suite.Require().NotNil(voteResp).
  • The function's usage in tests confirms that it is being called and the results are being verified.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling and message sending in the `vote` function.

# Test: Search for the function usage and check how errors are handled and how the vote message is sent. Expect: Proper error handling and correct message sending.
rg --type go -A 5 $'vote'

Length of output: 62130


132-151: LGTM! But verify the error handling and voting mechanism.

The code changes are approved.

However, ensure that the function handles errors appropriately and that the voting mechanism works as expected.

Verification successful

LGTM! But verify the error handling and voting mechanism.

The code changes are approved.

The function handles errors appropriately and the voting mechanism works as expected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling and voting mechanism in the `Vote` function.

# Test: Search for the function usage and check how errors are handled and how the voting mechanism works. Expect: Proper error handling and correct voting mechanism.
rg --type go -A 5 $'Vote'

Length of output: 168272


192-198: LGTM! But verify the error handling and delegator creation.

The code changes are approved.

However, ensure that the function handles errors appropriately and that the delegator is created correctly.

Verification successful

Verify error handling in CreateDelegator function.

To ensure that the CreateDelegator function handles errors appropriately, we need to review the Delegate function it calls and check the test cases for error handling.


Verified: Error handling in CreateDelegator function and its usage

The CreateDelegator function and its usage in the test cases handle errors appropriately. The Delegate function, which is called within CreateDelegator, includes proper error handling mechanisms. Additionally, the test cases that call CreateDelegator also include error handling.

  • Delegate function implementation in x/streamer/keeper/suite_test.go and x/sponsorship/keeper/keeper_test.go includes suite.Require().NoError(err) and suite.Require().NotNil(resp).
  • Test cases include error handling such as s.Require().NoError(err) and s.Require().NotNil(resp).
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling and delegator creation in the `CreateDelegator` function.

# Test: Search for the function usage and check how errors are handled and how the delegator is created. Expect: Proper error handling and correct delegator creation.
rg --type go -A 5 $'CreateDelegator'

Length of output: 6293


Script:

#!/bin/bash
# Search for the implementation of the `Delegate` function to review its error handling.
ast-grep --lang go --pattern 'func ($_).Delegate($_, $_, $_) $_' -A 10

# Check the test cases for any error handling when calling `CreateDelegator`.
rg --type go 'CreateDelegator' -A 5 | rg -i 'error|fail|require'

Length of output: 137


Script:

#!/bin/bash
# Search for the implementation of the `Delegate` function to review its error handling.
ast-grep --lang go --pattern 'func ($_).Delegate($_, $_, $_) $_' -A 20

# Check the test cases for any error handling when calling `CreateDelegator`.
rg --type go 'CreateDelegator' -A 10 | rg -i 'error|fail|require'

Length of output: 138


Script:

#!/bin/bash
# Search for the implementation of the `Delegate` function to review its error handling.
rg --type go 'func (.*) Delegate' -A 20

# Check the test cases for any error handling when calling `CreateDelegator`.
rg --type go 'CreateDelegator' -A 15 | rg -i 'error|fail|require'

Length of output: 3042

x/sponsorship/keeper/hooks.go (7)

140-215: LGTM! But verify the error handling and voting power update.

The code changes are approved.

However, ensure that the function handles errors appropriately and updates the voting power correctly.

Verification successful

Verified: Error Handling and Voting Power Update

The processHook function handles errors appropriately, and the voting power update logic is correctly implemented.

  • The function is used in two places, and both instances handle errors by returning a formatted error message.
  • The voting power update logic is encapsulated within the processHook function, ensuring consistency.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling and voting power update in the `processHook` function.

# Test: Search for the function usage and check how errors are handled and how the voting power is updated. Expect: Proper error handling and correct voting power update.
rg --type go -A 5 $'processHook'

Length of output: 2439


224-225: LGTM! Verify the intention of the placeholder function.

The code changes are approved.

However, ensure that the function is intended to be a placeholder.

Verification successful

The function BeforeValidatorSlashed is intentionally left as a placeholder.

The function is not referenced elsewhere in the codebase, and there are no comments or documentation explaining its purpose. This aligns with the pattern observed with other similar functions in the same file.

  • x/sponsorship/keeper/hooks.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the intention of the placeholder function `BeforeValidatorSlashed`.

# Test: Search for the function usage and check if it is intended to be a placeholder. Expect: The function is a placeholder.
rg --type go -A 5 $'BeforeValidatorSlashed'

Length of output: 494


Script:

#!/bin/bash
# Description: Search for references to the `BeforeValidatorSlashed` function and check for any documentation or comments explaining its purpose.

# Search for references to the function in the codebase.
rg 'BeforeValidatorSlashed'

# Search for any comments or documentation that might explain the purpose of the placeholder functions.
rg -A 3 -B 3 'BeforeValidatorSlashed' --type go

Length of output: 701


94-100: LGTM! But verify the error handling.

The code changes are approved.

However, ensure that the function handles errors appropriately.

Verification successful

Verification Successful: Error Handling in BeforeDelegationRemoved

The error handling in the BeforeDelegationRemoved function is appropriate and robust. The beforeDelegationRemoved function, which it calls, includes detailed error messages and handles various error scenarios effectively.

  • beforeDelegationRemoved checks for errors in verifying if the delegator voted, retrieving current voting power, processing the hook, and emitting events.
  • Each error is returned with a formatted message, providing clear context.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling in the `BeforeDelegationRemoved` function.

# Test: Search for the function usage and check how errors are handled. Expect: Proper error handling.
rg --type go -A 5 $'BeforeDelegationRemoved'

Length of output: 748


Script:

#!/bin/bash
# Description: Retrieve the implementation of `beforeDelegationRemoved` and search for usages of `BeforeDelegationRemoved`.

# Retrieve the implementation of `beforeDelegationRemoved`
ast-grep --lang go --pattern $'func (h Hooks) beforeDelegationRemoved($_, $_, $_) error { $$$ }'

# Search for usages of `BeforeDelegationRemoved`
rg --type go 'BeforeDelegationRemoved'

Length of output: 2801


222-223: LGTM! Verify the intention of the placeholder function.

The code changes are approved.

However, ensure that the function is intended to be a placeholder.

Verification successful

The AfterValidatorBonded function appears to be a placeholder.

  • The function is defined but not referenced elsewhere in the codebase.
  • Similar placeholder functions are present in the same file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the intention of the placeholder function `AfterValidatorBonded`.

# Test: Search for the function usage and check if it is intended to be a placeholder. Expect: The function is a placeholder.
rg --type go -A 5 $'AfterValidatorBonded'

Length of output: 508


Script:

#!/bin/bash
# Description: Search for comments or documentation related to placeholder functions in the sponsorship keeper hooks.

# Test: Search for comments or documentation in the hooks.go file.
rg --type go -A 3 "//" x/sponsorship/keeper/hooks.go

Length of output: 2487


Script:

#!/bin/bash
# Description: Search for references to the `AfterValidatorBonded` function in the codebase to gather more context about its intended use.

# Test: Search for references to `AfterValidatorBonded` in the codebase.
rg 'AfterValidatorBonded'

Length of output: 158


218-220: LGTM! Verify the intention of the placeholder function.

The code changes are approved.

However, ensure that the function is intended to be a placeholder.

Verification successful

The AfterValidatorBeginUnbonding function is confirmed to be a placeholder.

  • The function is defined but not used anywhere else in the codebase.
  • Other functions in the same file also return nil, indicating a pattern of placeholder implementations.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the intention of the placeholder function `AfterValidatorBeginUnbonding`.

# Test: Search for the function usage and check if it is intended to be a placeholder. Expect: The function is a placeholder.
rg --type go -A 5 $'AfterValidatorBeginUnbonding'

Length of output: 445


Script:

#!/bin/bash
# Description: Verify the intention of the placeholder function `AfterValidatorBeginUnbonding`.

# Search for comments or documentation related to `AfterValidatorBeginUnbonding`.
rg --type go -A 3 -B 3 'AfterValidatorBeginUnbonding' | rg -i 'todo|fixme|placeholder|note'

# Examine the definition of the `Hooks` struct or interface to understand its context.
rg --type go 'type Hooks struct' -A 10
rg --type go 'type Hooks interface' -A 10

Length of output: 1676


Script:

#!/bin/bash
# Description: Verify the intention of the placeholder function `AfterValidatorBeginUnbonding`.

# Search for the usage of the `AfterValidatorBeginUnbonding` function in the codebase.
rg --type go 'AfterValidatorBeginUnbonding'

Length of output: 171


40-91: LGTM! But verify the error handling and hook processing.

The code changes are approved.

However, ensure that the function handles errors appropriately and processes the hook correctly.


102-137: LGTM! But verify the error handling and hook processing.

The code changes are approved.

However, ensure that the function handles errors appropriately and processes the hook correctly.

x/streamer/keeper/keeper_create_stream_test.go (1)

Line range hint 77-100:
LGTM! But verify the usage of the new parameter in the test cases.

The code changes are approved.

However, ensure that the new parameter NonSponsored is used correctly and that the test cases cover all relevant scenarios.

Verification successful

The new parameter NonSponsored is used correctly in the test cases and other parts of the codebase.

The parameter NonSponsored is passed correctly in the TestCreateStream_CoinsSpendable function and other relevant test functions, indicating proper usage across the codebase.

  • [x/streamer/keeper/keeper_create_stream_test.go]
  • [x/streamer/keeper/genesis_test.go]
  • [x/streamer/keeper/suite_test.go]
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new parameter `NonSponsored` in the test cases.

# Test: Search for the function usage and check how the new parameter is used in the test cases. Expect: Proper usage of the new parameter.
rg --type go -A 5 $'CreateStream'

Length of output: 35168

x/sponsorship/keeper/keeper_test.go (20)

27-29: LGTM!

The TestKeeperTestSuite function correctly initializes the test suite using testify's suite package.


31-35: LGTM!

The KeeperTestSuite struct correctly embeds apptesting.KeeperTestHelper and defines necessary fields.


37-51: LGTM!

The SetupTest function correctly sets up the test environment by initializing the app, context, query client, and message server.


53-72: LGTM!

The CreateGauge function correctly creates a gauge using the IncentivesKeeper and handles errors appropriately.


74-80: LGTM!

The CreateGauges function correctly creates multiple gauges by calling CreateGauge in a loop.


82-88: LGTM!

The GetDistribution function correctly retrieves the distribution using the query client and handles errors appropriately.


90-96: LGTM!

The GetVote function correctly retrieves the vote using the query client and handles errors appropriately.


98-104: LGTM!

The GetParams function correctly retrieves the parameters using the query client and handles errors appropriately.


106-112: LGTM!

The Vote function correctly sends a vote message using the message server and handles errors appropriately.


114-142: LGTM!

The CreateValidator function correctly creates a validator using the staking message server and handles errors appropriately.


144-174: LGTM!

The CreateValidatorWithAddress function correctly creates a validator with a specific address and balance using the staking message server and handles errors appropriately.


176-182: LGTM!

The CreateDelegator function correctly creates a delegator using the Delegate function.


184-196: LGTM!

The Delegate function correctly delegates tokens to a validator using the staking message server and handles errors appropriately.


229-246: LGTM!

The CancelUnbondingDelegation function correctly cancels unbonding delegation using the staking message server and handles errors appropriately.


248-253: LGTM!

The AssertHaveDelegatorValidator function correctly asserts that a delegator has a validator using the haveDelegatorValidator function.


255-260: LGTM!

The AssertNotHaveDelegatorValidator function correctly asserts that a delegator does not have a validator using the haveDelegatorValidator function.


262-266: LGTM!

The haveDelegatorValidator function correctly checks if a delegator has a validator using the SponsorshipKeeper and handles errors appropriately.


268-274: LGTM!

The AssertVoted function correctly asserts that a voter has voted using the SponsorshipKeeper and handles errors appropriately.


276-282: LGTM!

The AssertNotVoted function correctly asserts that a voter has not voted using the SponsorshipKeeper and handles errors appropriately.


284-290: LGTM!

The AssertDelegatorValidator function correctly asserts the power of a delegator's validator using the SponsorshipKeeper and handles errors appropriately.

x/sponsorship/keeper/votes_test.go (2)

20-30: Ensure all edge cases are covered.

While the current test cases are comprehensive, ensure that all edge cases, such as invalid voter addresses and boundary values for weights, are covered.


393-413: Ensure all edge cases are covered.

While the current test case is valid, ensure that all edge cases, such as invalid voter addresses and revoking votes for non-existent gauges, are covered.

app/keepers/modules.go (6)

78-79: Ensure import statements are necessary.

Verify that the import statements for the sponsorship module and its types are necessary and used in the file.


140-140: Ensure AppModuleBasic inclusion is necessary.

Verify that the inclusion of sponsorship.AppModuleBasic{} in the ModuleBasics variable is necessary and used in the application.


193-193: Ensure NewAppModule inclusion is necessary.

Verify that the inclusion of sponsorship.NewAppModule(a.SponsorshipKeeper) in the SetupModules function is necessary and used in the application.


237-237: Ensure maccPerms inclusion is necessary.

Verify that the inclusion of sponsorshiptypes.ModuleName: nil in the maccPerms map is necessary and used in the application.


272-272: Ensure BeginBlockers and EndBlockers inclusion is necessary.

Verify that the inclusion of sponsorshiptypes.ModuleName in the BeginBlockers and EndBlockers lists is necessary and used in the application.

Also applies to: 309-309


347-347: Ensure InitGenesis inclusion is necessary.

Verify that the inclusion of sponsorshiptypes.ModuleName in the InitGenesis list is necessary and used in the application.

x/sponsorship/keeper/hooks_test.go (1)

12-18: Ensure all edge cases are covered.

While the current test cases are comprehensive, ensure that all edge cases, such as invalid delegations and boundary values for weights, are covered.

CHANGELOG.md (1)

48-49: Entries are well-formatted and relevant.

The new entries correctly reference issue #983 and provide clear information about the added sponsorship module and streamer support.

x/sponsorship/types/types_test.go (6)

69-69: Update error message for clarity.

The error message now accurately reflects the condition that the total weight must be less than 100.


72-79: Correct handling of valid sum of weights < 100.

The test case now correctly indicates that a sum of weights less than 100 is valid.


82-85: Correct handling of empty input.

The test case now correctly indicates that an empty input is valid.


136-148: New test case for valid distribution with abstained votes.

The new test case correctly checks a distribution with specific gauge weights and confirms that no error is expected.


169-173: Refined error message for voting power mismatch.

The error message now emphasizes that the sum of gauge powers exceeds the total voting power.


169-173: New test case for invalid weights.

The new test case correctly checks for invalid weights where a weight is greater than 100.

app/keepers/keepers.go (5)

90-91: New import statements for sponsorship module.

The new import statements for sponsorshipkeeper and sponsorshiptypes are correct and necessary for the added functionality.


140-140: New field SponsorshipKeeper added to AppKeepers struct.

The new field SponsorshipKeeper is correctly added to the AppKeepers struct.


371-379: Initialization of SponsorshipKeeper.

The SponsorshipKeeper is correctly initialized with the necessary parameters.


499-503: Incorporation of SponsorshipKeeper hooks.

The SponsorshipKeeper hooks are correctly incorporated into the staking hook system.


596-596: Addition of subspace for sponsorshiptypes.ModuleName.

The subspace for sponsorshiptypes.ModuleName is correctly added to the initParamsKeeper function.

go.mod (5)

6-8: Dependency updates look good.

The updates to cosmossdk.io/api, cosmossdk.io/collections, and cosmossdk.io/core are appropriate and likely include important improvements.


56-56: Dependency update looks good.

The update to github.com/DataDog/zstd from v1.5.0 to v1.5.5 is appropriate and likely includes bug fixes and performance improvements.


82-82: New dependency added.

The addition of github.com/cosmos/cosmos-db at version 1.0.0 is noted. Ensure this new dependency is necessary and properly integrated.


175-178: Prometheus dependencies updated.

The updates to github.com/prometheus/client_golang, github.com/prometheus/client_model, github.com/prometheus/common, and github.com/prometheus/procfs are appropriate and likely include important improvements and bug fixes.


238-239: Replacement directive noted.

The replacement directive for cosmossdk.io/api to revert to version 0.3.1 is noted. Ensure this is necessary for compatibility reasons and does not introduce any issues.

x/streamer/keeper/distribute_test.go (1)

92-297: New test function TestSponsoredDistribute looks good.

The function includes comprehensive test cases covering various scenarios of sponsored distribution. Ensure that all edge cases are covered and that the function integrates well with the existing test suite.

Comments failed to post (2)
scripts/setup_local.sh

117-117: Quote the command substitution to prevent word splitting.

The command substitution should be quoted to prevent word splitting.

-  "$EXECUTABLE" add-genesis-account $(dymd keys show user --keyring-backend test -a) 1000000000000000000000000adym,10000000000uatom
+  "$EXECUTABLE" add-genesis-account "$(dymd keys show user --keyring-backend test -a)" 1000000000000000000000000adym,10000000000uatom
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

  "$EXECUTABLE" add-genesis-account "$(dymd keys show user --keyring-backend test -a)" 1000000000000000000000000adym,10000000000uatom
Tools
Shellcheck

[warning] 117-117: Quote this to prevent word splitting.

(SC2046)

x/sponsorship/keeper/genesis_test.go

20-24: Consider adding more edge cases.

Adding more edge cases will ensure the robustness of the genesis import/export functionality.

  testCases := []struct {
    name          string
    genesis       types.GenesisState
    expectedDistr types.Distribution
  }{
    {
      name: "Import/Export",
      genesis: types.GenesisState{
        Params: types.DefaultParams(),
        VoterInfos: []types.VoterInfo{
          {
            Voter: del11.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(600),
              Weights: []types.GaugeWeight{
                {GaugeId: 1, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val1.GetOperator().String(), Power: math.NewInt(400)},
              {Validator: val2.GetOperator().String(), Power: math.NewInt(200)},
            },
          },
          {
            Voter: del22.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(400),
              Weights: []types.GaugeWeight{
                {GaugeId: 2, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val2.GetOperator().String(), Power: math.NewInt(400)},
            },
          },
        },
      },
      expectedDistr: types.Distribution{
        VotingPower: math.NewInt(1_000),
        Gauges: []types.Gauge{
          {GaugeId: 1, Power: math.NewInt(600)},
          {GaugeId: 2, Power: math.NewInt(400)},
        },
      },
    },
+    {
+      name: "Empty Genesis",
+      genesis: types.GenesisState{
+        Params: types.DefaultParams(),
+        VoterInfos: []types.VoterInfo{},
+      },
+      expectedDistr: types.Distribution{
+        VotingPower: math.NewInt(0),
+        Gauges: []types.Gauge{},
+      },
+    },
+    {
+      name: "Single Voter Single Validator",
+      genesis: types.GenesisState{
+        Params: types.DefaultParams(),
+        VoterInfos: []types.VoterInfo{
+          {
+            Voter: del11.GetDelegatorAddr().String(),
+            Vote: types.Vote{
+              VotingPower: math.NewInt(600),
+              Weights: []types.GaugeWeight{
+                {GaugeId: 1, Weight: math.NewInt(100)},
+              },
+            },
+            Validators: []types.ValidatorVotingPower{
+              {Validator: val1.GetOperator().String(), Power: math.NewInt(600)},
+            },
+          },
+        },
+      },
+      expectedDistr: types.Distribution{
+        VotingPower: math.NewInt(600),
+        Gauges: []types.Gauge{
+          {GaugeId: 1, Power: math.NewInt(600)},
+        },
+      },
+    },
  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	testCases := []struct {
		name          string
		genesis       types.GenesisState
		expectedDistr types.Distribution
	}{
    {
      name: "Import/Export",
      genesis: types.GenesisState{
        Params: types.DefaultParams(),
        VoterInfos: []types.VoterInfo{
          {
            Voter: del11.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(600),
              Weights: []types.GaugeWeight{
                {GaugeId: 1, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val1.GetOperator().String(), Power: math.NewInt(400)},
              {Validator: val2.GetOperator().String(), Power: math.NewInt(200)},
            },
          },
          {
            Voter: del22.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(400),
              Weights: []types.GaugeWeight{
                {GaugeId: 2, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val2.GetOperator().String(), Power: math.NewInt(400)},
            },
          },
        },
      },
      expectedDistr: types.Distribution{
        VotingPower: math.NewInt(1_000),
        Gauges: []types.Gauge{
          {GaugeId: 1, Power: math.NewInt(600)},
          {GaugeId: 2, Power: math.NewInt(400)},
        },
      },
    },
    {
      name: "Empty Genesis",
      genesis: types.GenesisState{
        Params: types.DefaultParams(),
        VoterInfos: []types.VoterInfo{},
      },
      expectedDistr: types.Distribution{
        VotingPower: math.NewInt(0),
        Gauges: []types.Gauge{},
      },
    },
    {
      name: "Single Voter Single Validator",
      genesis: types.GenesisState{
        Params: types.DefaultParams(),
        VoterInfos: []types.VoterInfo{
          {
            Voter: del11.GetDelegatorAddr().String(),
            Vote: types.Vote{
              VotingPower: math.NewInt(600),
              Weights: []types.GaugeWeight{
                {GaugeId: 1, Weight: math.NewInt(100)},
              },
            },
            Validators: []types.ValidatorVotingPower{
              {Validator: val1.GetOperator().String(), Power: math.NewInt(600)},
            },
          },
        },
      },
      expectedDistr: types.Distribution{
        VotingPower: math.NewInt(600),
        Gauges: []types.Gauge{
          {GaugeId: 1, Power: math.NewInt(600)},
        },
      },
    },
  }

@keruch keruch added the c:sponsorship x/sponsorship module label Aug 7, 2024
@keruch keruch force-pushed the kirill/streamer-sponsorship branch from 9a57c23 to 34f2e42 Compare August 8, 2024 09:27
@keruch keruch force-pushed the kirill/sponsorship-updated-scripts branch from 2d09981 to a8c2206 Compare August 8, 2024 09:28
@keruch keruch force-pushed the kirill/streamer-sponsorship branch from 34f2e42 to c7f4714 Compare August 9, 2024 13:47
@keruch keruch force-pushed the kirill/sponsorship-updated-scripts branch from a8c2206 to bd1e60e Compare August 9, 2024 13:49
@keruch keruch force-pushed the kirill/streamer-sponsorship branch from c7f4714 to 1711972 Compare August 9, 2024 16:09
@keruch keruch force-pushed the kirill/sponsorship-updated-scripts branch from bd1e60e to 60a36d4 Compare August 9, 2024 16:10
omritoptix
omritoptix previously approved these changes Aug 12, 2024
Base automatically changed from kirill/streamer-sponsorship to main August 12, 2024 18:45
@keruch keruch dismissed omritoptix’s stale review August 12, 2024 18:45

The base branch was changed.

@keruch keruch requested a review from omritoptix August 12, 2024 18:49
@keruch keruch mentioned this pull request Aug 12, 2024
29 tasks
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
app/keepers/keepers.go (1)

**Update hooks setup to reflect changes.**s

The removal of SponsorshipKeeper has not been fully reflected in the hooks setup. The reference to SponsorshipKeeper.Hooks() is still you you still present in the app/keepers/keepers.go file. Please ensure that all necessary hooks are configured correctly and any obsolete references are removed.

  • File: app/keepers/keepers.go
  • Line: Reference to SponsorshipKeeper.Hooks() still exists.
Analysis chain

Line range hint 374-374:
Update hooks setup to reflect changes.

The removal of SponsorshipKeeper might affect the hooks setup. Ensure that all necessary hooks are still configured correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the hooks setup after removing SponsorshipKeeper.

# Test: Check for any hooks related to SponsorshipKeeper.
rg --type go 'SponsorshipKeeper.Hooks()'

Length of output: 97

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2d09981 and aeb695c.

Files selected for processing (9)
  • app/keepers/keepers.go (1 hunks)
  • readme.md (4 hunks)
  • scripts/incentives/fund_incentives.sh (1 hunks)
  • scripts/incentives/lockup_bootstrap.sh (1 hunks)
  • scripts/incentives/sponsorship_vote.sh (1 hunks)
  • scripts/pools/pools_bootstrap.sh (1 hunks)
  • scripts/setup_local.sh (3 hunks)
  • scripts/src/genesis_config_commands.sh (1 hunks)
  • x/streamer/keeper/keeper_create_stream_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/incentives/sponsorship_vote.sh
Files skipped from review as they are similar to previous changes (5)
  • readme.md
  • scripts/incentives/lockup_bootstrap.sh
  • scripts/pools/pools_bootstrap.sh
  • scripts/src/genesis_config_commands.sh
  • x/streamer/keeper/keeper_create_stream_test.go
Additional context used
Shellcheck
scripts/setup_local.sh

[warning] 117-117: Quote this to prevent word splitting.

(SC2046)

Additional comments not posted (9)
scripts/incentives/fund_incentives.sh (6)

21-23: Check voting permissions for multiple roles.

The script now includes votes from hub-user, user, and pools. Ensure each role has the necessary permissions to vote.


4-6: Ensure correct user role for transactions.

The command now uses user instead of local-user, which broadens the scope. Verify that the user has the necessary permissions and keys configured for transactions.


11-12: Confirm gauge creation parameters.

The parameters for creating a gauge have been updated. Ensure that the user has the necessary permissions and that the parameters are correctly set for the intended lockdrop.


28-29: Validate second stream proposal creation.

Ensure the parameters for the second stream proposal are correct and that the user has the necessary permissions.


16-17: Verify stream proposal creation.

The command for submitting a stream proposal has been updated. Ensure the proposal parameters are correct and that the user has the necessary permissions.


38-41: Review sponsored stream creation.

The new command for creating a sponsored stream is introduced. Verify that the parameters are correct and that the user has the necessary permissions.

scripts/setup_local.sh (2)

11-11: Improvement in executable assignment.

The assignment of EXECUTABLE now uses DEFAULT_EXECUTABLE, which is a more appropriate default path. This change is correct and improves clarity.


20-20: Enhanced error message clarity.

The error message now specifies the exact executable being searched for, which improves user feedback and debugging.

app/keepers/keepers.go (1)

Line range hint 148-148:
Removal of SponsorshipKeeper initialization.

The SponsorshipKeeper is no longer initialized, which may indicate a change in how sponsorship functionalities are managed. Ensure that this change aligns with the overall architecture and that any dependent modules are updated accordingly.

scripts/setup_local.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aeb695c and c4d92d4.

Files selected for processing (2)
  • .github/pull_request_template.md (1 hunks)
  • scripts/setup_local.sh (3 hunks)
Files skipped from review due to trivial changes (1)
  • .github/pull_request_template.md
Files skipped from review as they are similar to previous changes (1)
  • scripts/setup_local.sh

@@ -378,15 +378,6 @@ func (a *AppKeepers) InitKeepers(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

a.SponsorshipKeeper = sponsorshipkeeper.NewKeeper(
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we remove it?

Copy link
Contributor Author

@keruch keruch Aug 14, 2024

Choose a reason for hiding this comment

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

i accidentally duplicated it while resolving merge conflicts. there's one more sponsorship keeper initialization 9 lines above

@keruch keruch requested a review from omritoptix August 14, 2024 15:17
@omritoptix omritoptix merged commit c8fc1fd into main Aug 14, 2024
115 of 116 checks passed
@omritoptix omritoptix deleted the kirill/sponsorship-updated-scripts branch August 14, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:sponsorship x/sponsorship module dym-internal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants