Skip to content

improvement: use interface for underlying ante#27

Merged
0xstepit merged 4 commits intomainfrom
stepit/update-ante-handler
Apr 9, 2025
Merged

improvement: use interface for underlying ante#27
0xstepit merged 4 commits intomainfrom
stepit/update-ante-handler

Conversation

@0xstepit
Copy link
Copy Markdown
Contributor

@0xstepit 0xstepit commented Apr 9, 2025

This PR introduces the same changes applied to the custom ante handler defined in AutoCCTP: noble-assets/autocctp#12

Summary by CodeRabbit

  • New Features

    • Refined the transaction verification process to enhance security and reliability. This update enables a more flexible and robust handling of transactions, ensuring smoother processing in diverse scenarios.
  • Documentation

    • The release notes have been updated to reflect these improvements in the non-consensus breaking patch release (v2.0.2, April 9, 2025).

@0xstepit 0xstepit requested a review from johnletey April 9, 2025 08:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2025

Walkthrough

This pull request updates the signature verification decorator used in transaction ante handlers. In ante.go, the SigVerificationDecorator structure’s underlying field is changed from a specific type to a more generic one (sdk.AnteDecorator), and its constructor now accepts only a BankKeeper and an underlying decorator, including a panic if the decorator is nil. In simapp/ante.go, a new variable for the forwarding signature verification decorator is created within the ante handler. Additionally, the changelog entries are updated for the v2.0.2 release to document these improvements.

Changes

| Files | Changes Summary |

|------------------------------------------------------|-----------------|
| ante.go | Updated the SigVerificationDecorator struct: changed the underlying field type to sdk.AnteDecorator, revised the constructor to accept only a BankKeeper and an underlying decorator, and added a nil panic check. |
| simapp/ante.go | Introduced a new variable sigVerificationDecorator in NewAnteHandler that constructs a forwarding signature verification decorator using the BankKeeper and a standard signature verification decorator. |
| .changelog/v2.0.2/improvements/27-underlying-ante.md
.changelog/v2.0.2/summary.md
CHANGELOG.md | Added changelog entries for version 2.0.2 reflecting a non-consensus breaking patch release and documenting the new customization capability of the underlying ante handler. |

Sequence Diagram(s)

Decorator Instantiation Flow (in ante.go)

sequenceDiagram
    participant Caller as Constructor Caller
    participant Decorator as NewSigVerificationDecorator
    participant Check as Nil Check

    Caller->>Decorator: Call NewSigVerificationDecorator(bk, underlying)
    Decorator->>Check: Validate underlying parameter
    Check-->>Decorator: Underlying non-nil?
    Decorator-->>Caller: Return initialized SigVerificationDecorator
Loading

Ante Handler Flow (in simapp/ante.go)

sequenceDiagram
    participant Handler as NewAnteHandler
    participant StdDecorator as Standard SigVerificationDecorator
    participant FwdDecorator as Forwarding SigVerificationDecorator

    Handler->>StdDecorator: Create standard decorator instance
    StdDecorator-->>Handler: Return standard decorator
    Handler->>FwdDecorator: Create forwarding decorator (using bk, standard decorator)
    FwdDecorator-->>Handler: Return forwarding decorator instance
    Handler->>Handler: Append forwarding decorator to anteDecorators slice
Loading

Suggested reviewers

  • 0xstepit
  • g-luca

Poem

I’m a rabbit in a codey glen,
Hopping through the lines again and again.
With changes in the ante, swift and light,
I nibble bugs away by night.
In every patch and tweak I see,
A playful dance in code to be!
🐰🌟 Happy hops to all!


🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown

@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

🧹 Nitpick comments (1)
ante.go (1)

48-48: Remove duplicate interface compliance check

This interface compliance check is duplicated at line 55. You should remove one of them to avoid redundancy.

-var _ sdk.AnteDecorator = SigVerificationDecorator{}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8e6c3 and 6da5578.

📒 Files selected for processing (2)
  • ante.go (2 hunks)
  • simapp/ante.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: prepare
  • GitHub Check: unit-test
🔇 Additional comments (5)
simapp/ante.go (2)

36-39: Good refactoring to use interface dependency injection

This change improves the design by injecting the standard signature verification decorator as a dependency instead of hard-coding its creation inside the forwarding decorator. This makes the code more flexible, testable, and follows the dependency inversion principle.


53-54: Clear and descriptive comment

The comment clearly explains the purpose of the decorator, which is helpful for maintainers. Positioned correctly in the decorator chain to perform signature verification before sequence incrementation.

ante.go (3)

52-52: Improved flexibility with interface type

Changing the underlying field type from a concrete implementation to an interface improves flexibility and follows the principle of programming to interfaces rather than implementations. This makes the code more maintainable and extensible.


57-60: Improved constructor with proper validation

The updated constructor properly validates that the underlying decorator is not nil, preventing potential runtime errors. The simplified parameter list makes the code cleaner and follows the dependency injection pattern.


64-64: Correctly using the injected decorator

The constructor now properly uses the injected decorator instead of creating a new one, completing the dependency injection pattern.

Copy link
Copy Markdown
Member

@johnletey johnletey left a comment

Choose a reason for hiding this comment

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

Looks great, let's just make sure to add a CHANGELOG for a new patch release 🫡

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
.changelog/unreleased/improvements/27-use-interface-for-underlying-ante.md (1)

1-2: Changelog Entry Clarity & Detail

The entry clearly states that an interface is now used for the underlying ante in NewSigVerificationDecorator as part of PR #27. Consider expanding the description with a brief note on the benefits this change brings (e.g., improved decoupling, ease of testing, or extension) so that readers have more context on the impact of this design decision.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6da5578 and 178e38d.

📒 Files selected for processing (1)
  • .changelog/unreleased/improvements/27-use-interface-for-underlying-ante.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test (TestAllowedDenoms)
  • GitHub Check: test (TestFallbackAccount)
  • GitHub Check: test (TestClearAccount)
  • GitHub Check: test (TestFrontRunAccount)
  • GitHub Check: test (TestRegisterViaPacket)
  • GitHub Check: test (TestRegisterViaTransfer)
  • GitHub Check: test (TestRegisterOnNobleSignerlessly)
  • GitHub Check: test (TestRegisterOnNoble)

Copy link
Copy Markdown

@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

🧹 Nitpick comments (3)
.changelog/unreleased/summary.md (3)

3-4: Grammar Correction: Verb Agreement in Line 4
The phrase "The release improve the constructor..." should use the third-person singular verb form. Consider changing "improve" to "improves" for correct grammar.

🧰 Tools
🪛 LanguageTool

[grammar] ~3-~3: The verb form ‘improve’ does not appear to fit in this context.
Context: ...aking patch release to the v2 line. The release improve the constructor of the `SigVerification...

(SINGULAR_NOUN_VERB_AGREEMENT)


5-7: Consistency & Clarity: Pluralize Decorator in Line 6
The text "to chain multiple signature verification decorator for" appears to have a grammatical issue. It is clearer and more consistent to use the plural form "decorators" if multiple decorators are intended.


8-8: Remove Extraneous Content on Line 8
Line 8 contains only the character "8". If this is an unintended stray entry, please remove it to maintain the file’s clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 178e38d and 8d35474.

📒 Files selected for processing (2)
  • .changelog/unreleased/improvements/27-use-interface-for-underlying-ante.md (1 hunks)
  • .changelog/unreleased/summary.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changelog/unreleased/improvements/27-use-interface-for-underlying-ante.md
🧰 Additional context used
🪛 LanguageTool
.changelog/unreleased/summary.md

[grammar] ~3-~3: The verb form ‘improve’ does not appear to fit in this context.
Context: ...aking patch release to the v2 line. The release improve the constructor of the `SigVerification...

(SINGULAR_NOUN_VERB_AGREEMENT)

🪛 markdownlint-cli2 (0.17.2)
.changelog/unreleased/summary.md

1-1: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
.changelog/v2.0.2/summary.md (1)

1-3: Changelog Summary Entry Formatting

The release entry clearly states the release date and notes that it's a non-consensus breaking patch release. A static analysis hint flagged MD036 due to the use of emphasis for the date. If this format is intentional and consistent with your team’s style (as seen in previous entries), you can safely ignore this warning. Otherwise, consider using a heading (e.g., ### Apr 9, 2025) for improved clarity.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

1-1: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

CHANGELOG.md (1)

3-11: CHANGELOG Entry for v2.0.2

The new version entry is well integrated into the CHANGELOG. It includes:

  • The version header (## v2.0.2)
  • The release date (*Apr 9, 2025*)
  • A clear description noting the release as a non-consensus breaking patch to the v2 line
  • An "IMPROVEMENTS" section with a bullet detailing the customization of the underlying ante handler

This format is consistent with previous entries. Note that the static analysis tool again flags the use of emphasis for the release date; if this is an intentional style choice, no changes are needed.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d35474 and 0c32a30.

📒 Files selected for processing (3)
  • .changelog/v2.0.2/improvements/27-underlying-ante.md (1 hunks)
  • .changelog/v2.0.2/summary.md (1 hunks)
  • CHANGELOG.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

5-5: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

.changelog/v2.0.2/summary.md

1-1: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: prepare
  • GitHub Check: build
🔇 Additional comments (1)
.changelog/v2.0.2/improvements/27-underlying-ante.md (1)

1-2: Improvement Description Clarity

This entry succinctly captures the new functionality allowing customization of the underlying ante handler in SigVerificationDecorator and accurately references PR #27. The description is clear and appropriate for the intended audience.

@0xstepit 0xstepit merged commit 52de25b into main Apr 9, 2025
12 checks passed
@0xstepit 0xstepit deleted the stepit/update-ante-handler branch April 9, 2025 10:53
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