Skip to content

Conversation

@aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Aug 14, 2025

  • Updated proto definitions based on core v1.16.3 and indexer v1.16.69.
  • Added support for MsgSetDelegationTransferReceivers

Summary by CodeRabbit

  • New Features
    • Added a new transaction/API to set delegation transfer receivers, allowing an admin sender to specify a list of receivers.
    • Introduced a new parameter: human_readable_upgrade_block_height in exchange params.
  • Bug Fixes
    • Updated withdrawal claim hashing to use block height in the final component.
  • Documentation
    • Clarified the definition of cumulative_price for perpetual funding calculations.
  • Chores
    • Bumped cloned dependency versions.
    • Added the new message to the public chain messages registry.

…1.16.69. Added support for MsgSetDelegationTransferReceivers
@aarmoa aarmoa requested a review from Copilot August 14, 2025 13:04
@coderabbitai
Copy link

coderabbitai bot commented Aug 14, 2025

Walkthrough

Introduces a new “SetDelegationTransferReceivers” message and RPC in the exchange module, adds a setter to StakingKeeper, updates public chain message list, and extends Params with a human_readable_upgrade_block_height field. Adjusts a Peggy claim hash component, bumps Makefile clone versions, and refines documentation/comments for funding fields.

Changes

Cohort / File(s) Summary of changes
Exchange: Delegation transfer receivers feature
chain/exchange/types/v2/msgs.go, proto/injective/exchange/v2/tx.proto, chain/exchange/types/expected_keepers.go, injective_data/chain_messages_list.json
Adds MsgSetDelegationTransferReceivers (message, validation, signers), RPC service method and request/response messages, keeper interface method SetDelegationTransferReceiver, and registers the message in public list.
Exchange Params: human-readable upgrade height
proto/injective/exchange/v2/exchange.proto
Adds int64 Params.human_readable_upgrade_block_height = 32 with comments.
Funding docs updates
proto/injective/exchange/v1beta1/exchange.proto, proto/injective/exchange/v2/market.proto
Updates comments describing PerpetualMarketFunding.cumulative_price semantics; no field/signature changes.
Peggy withdraw claim hash adjustment
chain/peggy/types/msgs.go
Changes ClaimHash composition to use BlockHeight in the final segment instead of TokenContract; format string updated accordingly.
Build tooling version bumps
Makefile
Updates clone targets: injective-indexer to v1.16.69 and injective-core to v1.16.3; no logic changes.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant MsgService as Exchange Msg Service
  participant Handler as Exchange Msg Handler
  participant Keeper
  participant StakingKeeper

  Client->>MsgService: MsgSetDelegationTransferReceivers{sender, receivers}
  MsgService->>Handler: route(Type="setDelegationTransferReceivers")
  Handler->>Keeper: validate sender, receivers
  Keeper->>StakingKeeper: SetDelegationTransferReceiver(ctx, receiver) (for each)
  StakingKeeper-->>Keeper: state updated
  Keeper-->>Handler: ok
  Handler-->>MsgService: MsgSetDelegationTransferReceiversResponse{}
  MsgService-->>Client: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paws at blocks so tall,
New msgs hop through gRPC’s hall.
A keeper whispers, “set the way,”
Receivers lined in tidy array.
Peggy’s hash now counts the height—
I twitch my nose: “That’s set just right.”
Carrots commit; all tests alight. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/upgrade_protos_v1_16_3

🪧 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>, please review it.
    • 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.
  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades protocol buffer definitions to align with core v1.16.3 and indexer v1.16.69, adding support for MsgSetDelegationTransferReceivers functionality and improving documentation clarity.

  • Added MsgSetDelegationTransferReceivers message for setting delegation transfer receivers
  • Updated PerpetualMarketFunding cumulative_price field documentation for clarity
  • Added human_readable_upgrade_block_height parameter to exchange module
  • Fixed token contract usage in peggy module claim hash calculation

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
proto/injective/exchange/v2/tx.proto Added new MsgSetDelegationTransferReceivers RPC method and message definitions
proto/injective/exchange/v2/market.proto Updated cumulative_price field documentation to clarify it represents time-integral of perp premium
proto/injective/exchange/v2/exchange.proto Added human_readable_upgrade_block_height parameter for tracking upgrade timing
proto/injective/exchange/v1beta1/exchange.proto Updated cumulative_price documentation for consistency with v2
injective_data/chain_messages_list.json Added MsgSetDelegationTransferReceivers to supported message types
chain/peggy/types/msgs.go Fixed ClaimHash to use BlockHeight instead of duplicate TokenContract
chain/exchange/types/v2/tx.pb.go Generated code for new MsgSetDelegationTransferReceivers functionality
chain/exchange/types/v2/msgs.go Added validation and interface implementations for MsgSetDelegationTransferReceivers
chain/exchange/types/v2/market.pb.go Updated generated code with improved cumulative_price documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@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: 3

🧹 Nitpick comments (10)
Makefile (2)

4-4: Bump to indexer v1.16.69 looks good; consider parameterizing tags for easier maintenance

Hard-coding the tag makes future bumps noisier. Suggest switching to a Make variable so downstream automation can override without editing the rule.

Apply this within the current line:

-git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.16.69 --depth 1 --single-branch
+git clone https://github.com/InjectiveLabs/injective-indexer.git -b $(INDEXER_TAG) --depth 1 --single-branch

Add these definitions near the top of the Makefile to keep defaults aligned with this PR:

# Version pins (override via environment if needed)
INDEXER_TAG ?= v1.16.69
CORE_TAG ?= v1.16.3

7-7: Core bump to v1.16.3 is aligned with PR; mirror the parameterization for consistency

Same rationale as above. It streamlines future upgrades and allows CI overrides.

Apply this within the current line:

-git clone https://github.com/InjectiveLabs/injective-core.git -b v1.16.3 --depth 1 --single-branch
+git clone https://github.com/InjectiveLabs/injective-core.git -b $(CORE_TAG) --depth 1 --single-branch
proto/injective/exchange/v2/exchange.proto (1)

197-199: New Params field human_readable_upgrade_block_height — add a short note about sentinel value

Minor doc tweak to clarify behavior when unset.

-  // human_readable_upgrade_block_height defines the block height at which the
-  // human readable upgrade took place
+  // human_readable_upgrade_block_height defines the block height at which the
+  // human readable upgrade took place. Set to 0 if not applicable.
proto/injective/exchange/v1beta1/exchange.proto (1)

408-411: Comment typography nit: replace curly apostrophe

Avoid curly quotes in source comments to keep diffs and tooling consistent across locales.

-  // used to compute the interval’s average premium for funding
+  // used to compute the interval's average premium for funding
proto/injective/exchange/v2/market.proto (1)

333-335: Comment typography nit: replace curly apostrophe

Same as v1beta1: prefer straight ASCII apostrophes.

-  // used to compute the interval’s average premium for funding
+  // used to compute the interval's average premium for funding
chain/exchange/types/v2/msgs.go (3)

2610-2612: Use a module-level type constant for Type() to stay consistent with other msgs

Most msgs in this file return a named constant (e.g., TypeMsgUpdateParams). Returning a raw string here is inconsistent and brittle.

Apply inside the changed range:

-func (msg *MsgSetDelegationTransferReceivers) Type() string  { return "setDelegationTransferReceivers" }
+func (msg *MsgSetDelegationTransferReceivers) Type() string  { return TypeMsgSetDelegationTransferReceivers }

Add this constant alongside the other message type constants (outside the changed block):

// exchange message types
const (
    // ... existing constants ...
    TypeMsgSetDelegationTransferReceivers = "setDelegationTransferReceivers"
)

2621-2625: Validate and dedupe receivers to prevent duplicates

As written, duplicate receiver addresses are allowed. If duplicates are unintended, reject or de-duplicate to avoid redundant state writes and ambiguous UX.

If duplicates are allowed by design, please confirm and we can skip this.

Suggested change:

- for _, receiver := range msg.Receivers {
+ seen := make(map[string]struct{}, len(msg.Receivers))
+ for _, receiver := range msg.Receivers {
+   if _, ok := seen[receiver]; ok {
+     return errors.Wrapf(sdkerrors.ErrInvalidRequest, "duplicate receiver address: %s", receiver)
+   }
+   seen[receiver] = struct{}{}
    if _, err := sdk.AccAddressFromBech32(receiver); err != nil {
      return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid receiver address: %s", receiver)
    }
  }

2613-2628: Edge-case: Consider bounding the receivers list size

Depending on block gas/tx size policies, an unbounded receivers list could be abused. Consider enforcing a sane upper bound (module param or a conservative constant).

If there’s already a max enforced in the handler/keeper, no change needed. Otherwise, I can propose a minimal check here.

chain/exchange/types/expected_keepers.go (1)

70-71: Consider returning an error and aligning naming/plurality with the Msg

The interface method signature:

  • No error return: callers can’t distinguish failures (e.g., store write errors, permission checks). Most keeper mutators return error.
  • Name is singular (SetDelegationTransferReceiver) while the Msg sets a list of receivers; ensure the handler semantics are intentional.

Recommendations:

  • Prefer SetDelegationTransferReceivers(ctx context.Context, receivers []sdk.AccAddress) error or, if intentionally single, return error and document that the msg applies multiple calls.

Would you like me to draft the interface and a possible adapter in the handler that batches individual calls with proper rollback semantics?

proto/injective/exchange/v2/tx.proto (1)

1524-1534: Optional: Add address annotations and clarify constraints in proto

For stronger typing and client generation consistency, you can annotate address fields with cosmos address scalars, as seen elsewhere (e.g., MsgUpdateParams.authority). Also, if receivers must be unique, consider documenting that here.

Example:

// MsgSetDelegationTransferReceivers defines a message for setting delegation
// transfer receivers
message MsgSetDelegationTransferReceivers {
  option (amino.name) = "exchange/MsgSetDelegationTransferReceivers";
  option (cosmos.msg.v1.signer) = "sender";

  // the sender's Injective address (must be exchange admin)
  string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // list of receiver addresses to set as delegation transfer receivers (must be unique)
  repeated string receivers = 2; // optionally annotate with cosmos.AddressString per element if desired
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97aaaf4 and 9f908d1.

⛔ Files ignored due to path filters (6)
  • chain/exchange/types/exchange.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/exchange.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/market.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/tx.pb.go is excluded by !**/*.pb.go
  • exchange/derivative_exchange_rpc/pb/goadesign_goagen_injective_derivative_exchange_rpc.pb.go is excluded by !**/*.pb.go
  • exchange/spot_exchange_rpc/pb/goadesign_goagen_injective_spot_exchange_rpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (9)
  • Makefile (1 hunks)
  • chain/exchange/types/expected_keepers.go (1 hunks)
  • chain/exchange/types/v2/msgs.go (1 hunks)
  • chain/peggy/types/msgs.go (1 hunks)
  • injective_data/chain_messages_list.json (1 hunks)
  • proto/injective/exchange/v1beta1/exchange.proto (1 hunks)
  • proto/injective/exchange/v2/exchange.proto (1 hunks)
  • proto/injective/exchange/v2/market.proto (1 hunks)
  • proto/injective/exchange/v2/tx.proto (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
chain/exchange/types/v2/msgs.go (3)
chain/exchange/types/v2/tx.pb.go (3)
  • MsgSetDelegationTransferReceivers (4933-4938)
  • MsgSetDelegationTransferReceivers (4942-4942)
  • MsgSetDelegationTransferReceivers (4943-4945)
chain/exchange/types/msgs.go (1)
  • RouterKey (18-18)
chain/exchange/types/errors.go (1)
  • ErrInvalidAddress (91-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint
  • GitHub Check: run-tests
🔇 Additional comments (7)
chain/peggy/types/msgs.go (1)

395-396: Fix ClaimHash composition for MsgWithdrawClaim (include BlockHeight instead of duplicating TokenContract) — LGTM

This aligns the hash path with unique event identity (tokenContract/batchNonce/eventNonce/blockHeight) and removes the prior duplication. Good security-sensitive fix.

chain/exchange/types/v2/msgs.go (1)

2640-2640: LGTM: Interface conformance declaration

Compile-time assertion is present and correct.

injective_data/chain_messages_list.json (1)

96-97: LGTM: Message exposed in the public chain messages list

The new MsgSetDelegationTransferReceivers entry is correctly added alongside other v2 exchange messages.

proto/injective/exchange/v2/tx.proto (3)

222-224: LGTM: New RPC added to Msg service

The SetDelegationTransferReceivers RPC is correctly declared and returns the corresponding response type.


1522-1523: LGTM: Response message remains empty by design

No issues with keeping MsgAtomicMarketOrderFeeMultiplierScheduleResponse empty; unrelated whitespace-only change here is harmless.


1536-1538: LGTM: Empty response type is fine

The response message is appropriately empty for a setter-style RPC.

chain/exchange/types/expected_keepers.go (1)

67-71: Cross-module compatibility check
I ran a search and only found the new SetDelegationTransferReceiver method in chain/exchange/types/expected_keepers.go. Please confirm:

  • Staking module: that x/staking.Keeper (or any other real StakingKeeper implementation) has been updated to define and implement SetDelegationTransferReceiver.
  • App wiring: that your application setup (e.g. in app.go or module constructor) passes a StakingKeeper with the new method into the exchange module so everything still compiles.

Comment on lines +2610 to +2638
func (msg *MsgSetDelegationTransferReceivers) Route() string { return RouterKey }
func (msg *MsgSetDelegationTransferReceivers) Type() string { return "setDelegationTransferReceivers" }
func (msg *MsgSetDelegationTransferReceivers) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil {
return errors.Wrap(sdkerrors.ErrInvalidAddress, msg.Sender)
}

if len(msg.Receivers) == 0 {
return errors.Wrap(sdkerrors.ErrInvalidRequest, "receivers list cannot be empty")
}

for _, receiver := range msg.Receivers {
if _, err := sdk.AccAddressFromBech32(receiver); err != nil {
return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid receiver address: %s", receiver)
}
}

return nil
}

func (msg *MsgSetDelegationTransferReceivers) GetSignBytes() []byte {
bz, _ := json.Marshal(msg)
return sdk.MustSortJSON(bz)
}

func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
sender, _ := sdk.AccAddressFromBech32(msg.Sender)
return []sdk.AccAddress{sender}
}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ensure Msg server and keeper support are implemented

This PR wires the Msg type and proto, but the Msg server handler and keeper logic must exist to effect changes and call StakingKeeper.SetDelegationTransferReceiver for each receiver.

I can help audit and scaffold the Msg server if needed. To locate the handler, run:


🏁 Script executed:

#!/bin/bash
# Verify msg server implementation exists for SetDelegationTransferReceivers
rg -n --context 3 'SetDelegationTransferReceivers\\(.*MsgSetDelegationTransferReceivers'
rg -n --context 3 'MsgSetDelegationTransferReceivers'

Length of output: 23031


Implement Msg server and keeper handler for SetDelegationTransferReceivers

The protobuf, Go message type, and client stub are in place, but there’s currently no gRPC service method or keeper logic to process MsgSetDelegationTransferReceivers. You’ll need to:

  • Add the SetDelegationTransferReceivers RPC handler in your keeper (e.g. in chain/exchange/keeper/msg_server.go) that implements the generated MsgServer interface.
  • In that handler:
    • Convert the incoming sender to an sdk.AccAddress.
    • Loop over msg.Receivers, converting each to sdk.AccAddress and calling
      k.StakingKeeper.SetDelegationTransferReceiver(ctx, sender, receiver).
    • Return a &MsgSetDelegationTransferReceiversResponse{} on success.
  • Ensure this handler is registered in your module’s RegisterMsgServer call (usually in module.go) so gRPC routing picks it up.
  • Add unit tests covering valid, empty, and invalid-address cases.

Let me know if you’d like a scaffold for the keeper method and tests.

Comment on lines +2630 to +2633
func (msg *MsgSetDelegationTransferReceivers) GetSignBytes() []byte {
bz, _ := json.Marshal(msg)
return sdk.MustSortJSON(bz)
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Align GetSignBytes with the standard codec

Other messages use types.ModuleCdc.MustMarshalJSON + sdk.MustSortJSON. Using json.Marshal here is inconsistent and bypasses the module codec.

Apply this diff:

-func (msg *MsgSetDelegationTransferReceivers) GetSignBytes() []byte {
-  bz, _ := json.Marshal(msg)
-  return sdk.MustSortJSON(bz)
-}
+func (msg *MsgSetDelegationTransferReceivers) GetSignBytes() []byte {
+  return sdk.MustSortJSON(types.ModuleCdc.MustMarshalJSON(msg))
+}
🤖 Prompt for AI Agents
In chain/exchange/types/v2/msgs.go around lines 2630 to 2633, GetSignBytes uses
json.Marshal which bypasses the module codec; replace json.Marshal with the
module codec marshal call: use types.ModuleCdc.MustMarshalJSON(msg) and then
pass the result to sdk.MustSortJSON so signing bytes are produced consistently
with other messages.

Comment on lines +2635 to +2638
func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
sender, _ := sdk.AccAddressFromBech32(msg.Sender)
return []sdk.AccAddress{sender}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle address parsing errors in GetSigners to match existing patterns

Other msgs panic on address parsing failures in GetSigners (given ValidateBasic should have run already). Here the error is ignored which could yield an empty address in edge cases.

Apply this diff:

-func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
-  sender, _ := sdk.AccAddressFromBech32(msg.Sender)
-  return []sdk.AccAddress{sender}
-}
+func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
+  sender := sdk.MustAccAddressFromBech32(msg.Sender)
+  return []sdk.AccAddress{sender}
+}
📝 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.

Suggested change
func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
sender, _ := sdk.AccAddressFromBech32(msg.Sender)
return []sdk.AccAddress{sender}
}
func (msg *MsgSetDelegationTransferReceivers) GetSigners() []sdk.AccAddress {
sender := sdk.MustAccAddressFromBech32(msg.Sender)
return []sdk.AccAddress{sender}
}
🤖 Prompt for AI Agents
In chain/exchange/types/v2/msgs.go around lines 2635 to 2638, the GetSigners
method currently ignores the error from AccAddressFromBech32 which can produce
an empty address; change it to handle the parsing error the same way other
messages do by checking the returned error and panicking (or using the project's
established helper) when parsing fails, so the function returns a valid signer
or fails fast if the address is invalid.

@aarmoa aarmoa merged commit 53c94ae into master Aug 14, 2025
6 checks passed
@aarmoa aarmoa deleted the chore/upgrade_protos_v1_16_3 branch August 14, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants