🎨 Added context to the fee collection methods. Refactored. Added time stamps to the fee worker logged.#119
Conversation
… stamps to the fee worker logged.
WalkthroughThe changes refactor the fee collection logic in the Changes
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
Possibly related PRs
Suggested reviewers
Poem
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"" 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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.Contextand delegate to a newexecuteFeeCollectionfunction. - 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.RFC3339but thetimepackage isn't imported in this file. Addimport "time"to avoid a build error.
TimestampFormat: time.RFC3339,
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
executeFeeCollectionmethod 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.
…es by shadow copying the feePolicy value and not by reference
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary by CodeRabbit
Refactor
Style