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

chore: fix event emission for smart account module #8858

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

PaddyMc
Copy link
Collaborator

@PaddyMc PaddyMc commented Dec 2, 2024

What is the purpose of the change

Events are being formatted incorrectly when being emitted, this PR fixes that

Testing and Verifying

Review code

Query the osmosis rpc endpoints

  • osmosisd q tx C603B5E501D2812F888232A24403E86CCCED23AFAB8B1ADCCD21E25759B16E00 --output json --node https://rpc.osmosis.zone:443 | jq

Check these events:

 "events": [
    {
      "type": "tx",
      "attributes": [
        {
          "key": "acc_seq",
          "value": "�a\"�p���\u007f}��Z��\"gCٺ/5829",
          "index": true
        },
        {
          "key": "authenticator_acc_seq",
          "value": "�a\"�p���\u007f}��Z��\"gCٺ/5829",
          "index": true
        }
      ]
    },

run this branch:

  • osmosisd q tx C603B5E501D2812F888232A24403E86CCCED23AFAB8B1ADCCD21E25759B16E00 --output json | jq

Check these events:

  "events": [
    {
      "type": "tx",
      "attributes": [
        {
          "key": "acc_seq",
          "value": "osmo1efsj9hrsuhcu6lmamm544n7syfn58kd68d30k4/5829",
          "index": true
        },
        {
          "key": "authenticator_acc_seq",
          "value": "osmo1efsj9hrsuhcu6lmamm544n7syfn58kd68d30k4/5829",
          "index": true
        }
      ]
    },

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@PaddyMc PaddyMc added A:backport/v27.x backport patches to v27.x branch V:state/compatible/backport State machine compatible PR, should be backported labels Dec 2, 2024
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The changes in this pull request focus on the AnteHandle method within the EmitPubKeyDecoratorEvents struct in the x/smart-account/ante/pubkey.go file. The modifications include converting byte representations of signers' addresses to string format before appending them to event attributes. Additionally, the error handling for address conversion has been improved by introducing a new error return, enhancing the robustness of the method. The CHANGELOG.md file has also been updated to reflect these changes.

Changes

File Path Change Summary
x/smart-account/ante/pubkey.go Updated AnteHandle method to convert signers' byte addresses to string format for event attributes and enhanced error handling for address conversion.
CHANGELOG.md Added new entry for fixing event emission in the smart account module and organized version sections.

Possibly related PRs

  • fix: smart account signing checktx error #8665: This PR addresses a specific issue related to smart account signing, which is closely related to the changes made in the main PR regarding the handling of signers' addresses in the AnteHandle method.
  • [x/concentratedliquidity]: Fix Incorrect Event Emission  #8755: This PR focuses on fixing incorrect event emissions in the concentratedliquidity module, which is relevant as it also deals with event handling similar to the changes made in the main PR regarding event attributes for signers' addresses.
  • chore: bump cometbft/cosmos-sdk versions #8779: This PR involves a bump of the cometbft/cosmos-sdk versions, which may indirectly relate to the overall functionality and stability improvements that the main PR aims to achieve through enhanced error handling and address representation.
  • chore: update tagged submodules for v27 #8801: This PR updates tagged submodules, which could include dependencies relevant to the changes made in the main PR, ensuring that the overall project remains compatible and functional.
  • chore: tagged v27 changelog #8822: This PR updates the changelog for the v27.0.0 release, which includes documentation of changes that may encompass the improvements made in the main PR regarding event handling and error management.

Suggested labels

A:no-changelog

Suggested reviewers

  • czarcas7ic
  • ValarDragon
  • nicolaslara

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bab956a and bda70ac.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🔇 Additional comments (1)
CHANGELOG.md (1)

45-46: LGTM!

The changelog entry is properly formatted and provides clear information about the fix for event emission in the smart account module.


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>, please review it.
    • 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 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 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 using 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.

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.

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.

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

🧹 Outside diff range and nitpick comments (1)
x/smart-account/ante/pubkey.go (1)

53-56: Improve error handling for address conversion

The error handling could be enhanced by:

  1. Using the existing context instead of returning an empty one
  2. Wrapping the error with additional context for better debugging
-			return sdk.Context{}, err
+			return ctx, errorsmod.Wrapf(err, "failed to convert address bytes to string for signer %d", i)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4eba83 and bab956a.

📒 Files selected for processing (1)
  • x/smart-account/ante/pubkey.go (1 hunks)
🔇 Additional comments (2)
x/smart-account/ante/pubkey.go (2)

51-59: LGTM - Event emission changes look correct

The changes properly address the event formatting issue by:

  1. Converting addresses to strings before event emission
  2. Maintaining consistent event attribute structure
  3. Following Cosmos SDK event patterns

The implementation is solid with only minor suggestions for improvement noted above.


58-59: Verify the necessity of duplicate event attributes

The code emits two nearly identical attributes with different keys:

  • account_sequence
  • account_sequence_authenticator

While this might be intentional for backwards compatibility, please confirm if both are necessary.

✅ Verification successful

Duplicate event attributes appear to serve different purposes

Based on the code context, the two attributes serve distinct purposes:

  • account_sequence is a standard Cosmos SDK attribute key for general sequence tracking
  • authenticator_acc_seq is a smart-account specific attribute that appears to be part of a broader authenticator-related event system (alongside other authenticator attributes like authenticator_type, authenticator_id, etc.)

The duplication is justified as they serve different consumers:

  • Standard SDK consumers rely on the common account_sequence attribute
  • Smart account specific features track authentication state via authenticator_acc_seq
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for consumers of these event attributes
rg -l "account_sequence_authenticator" 
rg -l "account_sequence.*EventType.*Tx"

Length of output: 80


Script:

#!/bin/bash
# Let's try a broader search for these attribute keys and their usage
rg -A 2 "AttributeKeyAccountSequence"
rg -A 2 "AttributeKeyAccountSequenceAuthenticator"

# Also search for any event handling or processing related to these attributes
rg -A 2 "HandleMessage|ProcessEvent.*account_sequence"

Length of output: 1197


Script:

#!/bin/bash
# Let's look for the context around where these attributes are used
rg -B 5 -A 5 "authenticator_acc_seq"

# Also search for any tests or documentation that might explain the purpose
fd -e md -e go | xargs rg -l "account sequence.*authenticator"

Length of output: 770

@PaddyMc PaddyMc added the A:backport/v28.x backport patches to v28.x branch label Dec 2, 2024
@PaddyMc PaddyMc closed this Dec 11, 2024
@PaddyMc PaddyMc reopened this Dec 11, 2024
@PaddyMc PaddyMc removed the A:backport/v27.x backport patches to v27.x branch label Dec 18, 2024
@PaddyMc PaddyMc closed this Dec 18, 2024
@PaddyMc PaddyMc reopened this Dec 18, 2024
@PaddyMc PaddyMc merged commit e12cabf into main Dec 18, 2024
1 check passed
@PaddyMc PaddyMc deleted the chore/fix-events-for-smart-accounts branch December 18, 2024 15:48
mergify bot pushed a commit that referenced this pull request Dec 18, 2024
* chore: fix event emission for smart account module

* chore: add changelog.md

(cherry picked from commit e12cabf)
PaddyMc added a commit that referenced this pull request Dec 18, 2024
* chore: fix event emission for smart account module

* chore: add changelog.md

(cherry picked from commit e12cabf)

Co-authored-by: PaddyMc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v28.x backport patches to v28.x branch V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants