Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

🎨 Added context to the fee collection methods. Refactored. Added time stamps to the fee worker logged.#119

Merged
garry-sharp merged 4 commits into
mainfrom
fee-collection-refactoring
Jul 7, 2025
Merged

🎨 Added context to the fee collection methods. Refactored. Added time stamps to the fee worker logged.#119
garry-sharp merged 4 commits into
mainfrom
fee-collection-refactoring

Conversation

@garry-sharp

@garry-sharp garry-sharp commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor

    • Improved the fee collection process for greater clarity and modularity, resulting in more consistent and detailed logging during fee operations.
    • Enhanced error handling with early returns and added contextual information for better issue tracing.
  • Style

    • Enhanced log output with standardized timestamps for better readability and traceability.

Copilot AI review requested due to automatic review settings July 4, 2025 16:55
@coderabbitai

coderabbitai Bot commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor the fee collection logic in the FeePlugin by modularizing the process into distinct methods for collecting fees by public key, policy ID, or all policies. A centralized method now handles the core fee collection steps. Additionally, logger configuration is updated to standardize timestamp formatting in log outputs.

Changes

File(s) Change Summary
cmd/fees/worker/main.go Configured the global logger to use a text formatter with RFC3339 full timestamps.
plugin/fees/fees.go Refactored fee collection into separate methods for each collection type; centralized execution logic; improved error handling and logging; updated method signatures.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler
    participant FeePlugin
    participant Database
    participant VerifierAPI
    participant Vault

    Scheduler->>FeePlugin: HandleCollections(ctx, task)
    FeePlugin->>FeePlugin: collectFeesByPublicKey / collectFeesByPolicyId / collectAllFees
    FeePlugin->>Database: Fetch fee policies
    FeePlugin->>VerifierAPI: Fetch fees for policy public key
    FeePlugin->>FeePlugin: executeFeeCollection(ctx, policy)
    FeePlugin->>Database: Create fee run
    FeePlugin->>Vault: Retrieve vault
    FeePlugin->>Vault: Propose transaction(s)
    FeePlugin->>Vault: Initiate signing
    FeePlugin->>FeePlugin: Log results and errors
Loading

Possibly related PRs

  • 🎨 Fee log cleanup #112: Refactors fee collection logic by adding context propagation, restructuring method calls, and enhancing logging with structured fields; related to improving logging practices in the fee plugin.

Suggested reviewers

  • johnnyluo

Poem

In the warren where the code does run,
Fees now gather, one by one.
With logs that shine in RFC time,
And methods split for tasks sublime.
The rabbits cheer as errors flee—
Modular magic, as neat as can be!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package session: could not load export data: no export data for "github.com/vultisig/go-wrappers/go-dkls/sessions""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package session: could not load export data: no export data for "github.com/vultisig/go-wrappers/go-dkls/sessions""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fb5238a and c7e5225.

📒 Files selected for processing (1)
  • plugin/fees/fees.go (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/fees/fees.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the fee collection workflow to use a unified executor with context propagation and enhances logging in the fee worker.

  • Handler methods now accept context.Context and delegate to a new executeFeeCollection function.
  • Worker binary’s logger is configured to include full RFC3339 timestamps.
  • Removed errgroup-based concurrency and made signing calls sequential.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
plugin/fees/fees.go Refactored collection entry points to accept ctx, consolidated logic into executeFeeCollection, added structured logging and timestamp fields.
cmd/fees/worker/main.go Configured logrus.TextFormatter to use full timestamps in RFC3339 format.
Comments suppressed due to low confidence (1)

cmd/fees/worker/main.go:45

  • The code references time.RFC3339 but the time package isn't imported in this file. Add import "time" to avoid a build error.
		TimestampFormat: time.RFC3339,

Comment thread plugin/fees/fees.go Outdated
Comment thread plugin/fees/fees.go
Comment thread plugin/fees/fees.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d582872 and 18c2314.

📒 Files selected for processing (2)
  • cmd/fees/worker/main.go (1 hunks)
  • plugin/fees/fees.go (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/constraints.go:3-3
Timestamp: 2025-07-04T10:50:42.819Z
Learning: For the vultisig/plugin project, use "fee" (singular) throughout the codebase wherever possible, not "fees" (plural). This applies to all naming conventions including plugin types, variable names, function names, comments, and documentation.
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/policy.go:46-47
Timestamp: 2025-07-04T10:47:47.908Z
Learning: For the fee plugin in plugin/fees/policy.go, the resource validation and recipe specification are intentionally configured to accept only USDC transfers ("ethereum.usdc.transfer"), not general ERC20 transfers ("ethereum.erc20.transfer"), as fees are only collected in USDC.
plugin/fees/fees.go (6)
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/policy.go:46-47
Timestamp: 2025-07-04T10:47:47.908Z
Learning: For the fee plugin in plugin/fees/policy.go, the resource validation and recipe specification are intentionally configured to accept only USDC transfers ("ethereum.usdc.transfer"), not general ERC20 transfers ("ethereum.erc20.transfer"), as fees are only collected in USDC.
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/constraints.go:3-3
Timestamp: 2025-07-04T10:50:42.819Z
Learning: For the vultisig/plugin project, use "fee" (singular) throughout the codebase wherever possible, not "fees" (plural). This applies to all naming conventions including plugin types, variable names, function names, comments, and documentation.
Learnt from: RaghavSood
PR: vultisig/plugin#36
File: api/server.go:21-33
Timestamp: 2025-05-07T08:23:45.882Z
Learning: The import path `github.com/vultisig/verifier/plugin` refers to an external dependency that provides the plugin interface, and should not be changed to `github.com/vultisig/plugin/plugin` as these are distinct packages with different purposes.
Learnt from: johnnyluo
PR: vultisig/plugin#108
File: Dockerfile.Payroll.server:14-19
Timestamp: 2025-07-02T04:55:36.331Z
Learning: In the vultisig/plugin repository, the team maintains both the main repository and the go-wrappers dependency repository, so they are comfortable downloading from the master branch rather than pinning to specific commits.
Learnt from: johnnyluo
PR: vultisig/plugin#108
File: cmd/payroll/worker/main.go:84-84
Timestamp: 2025-07-02T04:58:30.139Z
Learning: VaultServiceConfig is defined as a field of type vault_config.Config from the external package "github.com/vultisig/verifier/vault_config" in worker configuration structs across the vultisig/plugin codebase (cmd/payroll/worker/config.go, cmd/fees/worker/config.go, cmd/dca/worker/config.go). The vault_config.Config struct contains an EncryptionSecret field that can be accessed via cfg.VaultServiceConfig.EncryptionSecret.
Learnt from: RaghavSood
PR: vultisig/plugin#75
File: storage/postgres/db_plugin.go:25-40
Timestamp: 2025-05-30T02:44:31.711Z
Learning: The embed.FS directive `//go:embed migrations/plugin/*.sql` in storage/postgres/db_plugin.go correctly embeds plugin migration files that exist in the storage/postgres/migrations/plugin/ directory. The path "migrations/plugin" passed to goose.Up() references the embedded filesystem structure, not the physical file system path.
🧬 Code Graph Analysis (1)
plugin/fees/fees.go (2)
plugin/fees/config.go (2)
  • FeeCollectionTypeByPolicy (152-152)
  • FeeCollectionTypeAll (154-154)
internal/types/fees.go (1)
  • FeeRunStateDraft (14-14)
🪛 GitHub Check: build
cmd/fees/worker/main.go

[failure] 45-45:
undefined: time

🪛 golangci-lint (1.64.8)
cmd/fees/worker/main.go

45-45: undefined: time

(typecheck)

🪛 GitHub Actions: Go
cmd/fees/worker/main.go

[error] 45-45: Build failed: undefined identifier 'time' used at line 45.

🔇 Additional comments (2)
plugin/fees/fees.go (2)

106-137: Well-structured refactoring of fee collection logic.

The refactoring successfully modularizes the fee collection process into distinct methods for different collection types. The use of context parameters and improved error handling enhances the robustness of the code.


189-258: Excellent consolidation of fee collection logic.

The executeFeeCollection method effectively centralizes the core fee collection steps with comprehensive logging and proper error handling. The sequential approach with immediate error returns is more reliable than the previous concurrent approach.

Comment thread cmd/fees/worker/main.go
Comment thread plugin/fees/fees.go
Comment thread plugin/fees/fees.go
Comment thread plugin/fees/fees.go
Garry Sharp and others added 3 commits July 4, 2025 21:08
@garry-sharp
garry-sharp enabled auto-merge July 7, 2025 07:21

@webpiratt webpiratt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@garry-sharp
garry-sharp merged commit 33a4336 into main Jul 7, 2025
3 checks passed
@garry-sharp
garry-sharp deleted the fee-collection-refactoring branch July 7, 2025 19:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants