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

🎨 Fee log cleanup#112

Merged
garry-sharp merged 1 commit into
mainfrom
fee-log-cleanup
Jul 3, 2025
Merged

🎨 Fee log cleanup#112
garry-sharp merged 1 commit into
mainfrom
fee-log-cleanup

Conversation

@garry-sharp

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

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Reduced debug and error logging throughout the fee-related features for a cleaner user experience.
    • Improved consistency in error messages for transaction and fee processing.
    • Streamlined internal error handling and logging mechanisms without affecting visible functionality.

Copilot AI review requested due to automatic review settings July 3, 2025 09:39
@coderabbitai

coderabbitai Bot commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes focus on reducing debug and error logging verbosity across several internal and plugin-related files. Logging statements are removed or replaced with more consistent direct logger usage. Error handling is updated to favor error wrapping over logging, and error message prefixes are standardized for clarity. No control flow or logic is altered.

Changes

File(s) Change Summary
internal/verifierapi/fees.go Removed debug and error logging statements from fee-related functions; error handling remains unchanged.
internal/verifierapi/verifierapi.go Removed debug log in VerifierApi constructor.
plugin/fees/fees.go Removed custom Log method; replaced with direct logger usage; reduced debug logs; improved error wrapping.
plugin/fees/transaction.go Standardized error message prefixes; removed some error logs; simplified error handling without logging.

Poem

In burrows deep, the logs grew wild,
But now they're trimmed, the code is styled.
Errors wrapped with care, not shouted loud,
The rabbit hops—debug unbowed.
With cleaner trails and messages neat,
This patch is light upon its feet!
🐇✨

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""

✨ 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 standardizes logging and error handling in the fee plugin by removing a custom Log wrapper, consolidating direct fp.logger calls, and unifying error prefixes; it also cleans up debug logs in verifier API code.

  • Replaced the custom Log method with direct fp.logger calls in plugin/fees/fees.go
  • Updated error‐message prefixes in plugin/fees/transaction.go to consistently reference the correct functions/fields
  • Removed extraneous debug logs from internal/verifierapi

Reviewed Changes

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

File Description
plugin/fees/transaction.go Standardize error prefixes and remove old p. shorthand in fmt.Errorf
plugin/fees/fees.go Removed Log wrapper, replaced calls with fp.logger, and cleaned up error messages
internal/verifierapi/verifierapi.go Removed a debug log in the constructor
internal/verifierapi/fees.go Stripped out debug logs on error paths
Comments suppressed due to low confidence (1)

plugin/fees/transaction.go:139

  • The error prefix uses lowercase plugincommon.genUnsignedTx but the actual function is plugincommon.GenUnsignedTx. Update the case to match the function name.
			return []vtypes.PluginKeysignRequest{}, fmt.Errorf("plugincommon.genUnsignedTx: %w", e)

nonce, err := fp.nonceManager.GetNextNonce(ethAddress)
if err != nil {
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("p.nonceManager.GetNextNonce: %w", err)
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("plugincommon.nonceManager.GetNextNonce: %w", err)

Copilot AI Jul 3, 2025

Copy link

Choose a reason for hiding this comment

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

The error prefix "plugincommon.nonceManager.GetNextNonce" does not match the actual target. It should refer to fp.nonceManager.GetNextNonce or the correct package-level function name to avoid misleading error traces.

Suggested change
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("plugincommon.nonceManager.GetNextNonce: %w", err)
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("fp.nonceManager.GetNextNonce: %w", err)

Copilot uses AI. Check for mistakes.
})
if e != nil {
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("p.txIndexerService.CreateTx: %w", e)
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("fp.tx_indexer.CreateTx: %w", e)

Copilot AI Jul 3, 2025

Copy link

Choose a reason for hiding this comment

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

Reference to fp.tx_indexer appears incorrect; the field is named fp.txIndexerService. Update the error prefix and field usage to the correct identifier to ensure accurate context and compilation.

Suggested change
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("fp.tx_indexer.CreateTx: %w", e)
return []vtypes.PluginKeysignRequest{}, fmt.Errorf("fp.txIndexerService.CreateTx: %w", e)

Copilot uses AI. Check for mistakes.
Comment thread plugin/fees/fees.go
if err := json.Unmarshal(task.Payload(), &feeCollectionFormat); err != nil {
fp.Log(logrus.ErrorLevel, "Failed to unmarshal fee collection config")
return err
return fmt.Errorf("fp.HandleCollections, failed to unmarshall asynq task payload, %w", err)

Copilot AI Jul 3, 2025

Copy link

Choose a reason for hiding this comment

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

Typo in error message: 'unmarshall' should be 'unmarshal'. Also consider rephrasing for consistency (e.g., 'failed to unmarshal asynq task payload: %w').

Suggested change
return fmt.Errorf("fp.HandleCollections, failed to unmarshall asynq task payload, %w", err)
return fmt.Errorf("failed to unmarshal asynq task payload: %w", err)

Copilot uses AI. Check for mistakes.
Comment thread plugin/fees/fees.go
return fp.collectFeesByPolicy(feeCollectionFormat.Value)
case FeeCollectionTypeByPluginID:
fp.Log(logrus.InfoLevel, "Collecting fees by plugin id")
fp.logger.Info("Collecting fees by plugin id")

Copilot AI Jul 3, 2025

Copy link

Choose a reason for hiding this comment

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

This branch logs an info message but doesn’t return or invoke a handler, causing a silent fallthrough that returns nil. Add a return or handling logic for FeeCollectionTypeByPluginID.

Suggested change
fp.logger.Info("Collecting fees by plugin id")
fp.logger.Info("Collecting fees by plugin id")
return fp.collectFeesByPluginID(feeCollectionFormat.Value)

Copilot uses AI. Check for mistakes.

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

🧹 Nitpick comments (1)
plugin/fees/fees.go (1)

314-314: Consider using structured logging for the fee run object.

The current log concatenates the feeRun object, which may not provide optimal formatting.

Consider using structured logging:

-fp.logger.Info("Fee run created: ", feeRun)
+fp.logger.WithField("fee_run_id", feeRun.ID).Info("Fee run created")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3381e and bba03f8.

📒 Files selected for processing (4)
  • internal/verifierapi/fees.go (0 hunks)
  • internal/verifierapi/verifierapi.go (0 hunks)
  • plugin/fees/fees.go (5 hunks)
  • plugin/fees/transaction.go (7 hunks)
💤 Files with no reviewable changes (2)
  • internal/verifierapi/verifierapi.go
  • internal/verifierapi/fees.go
🧰 Additional context used
🧠 Learnings (1)
plugin/fees/transaction.go (3)
Learnt from: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:0-0
Timestamp: 2025-06-18T18:23:20.077Z
Learning: In the payroll plugin (plugin/payroll/transaction.go), signRequest.Transaction is stored with the "0x" prefix, making it compatible with gcommon.FromHex which requires 0x-prefixed hex strings.
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: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:178-183
Timestamp: 2025-06-18T18:28:19.759Z
Learning: In the payroll plugin, the Hash field in PluginKeysignRequest is intentionally set to the unsigned transaction hex (same as Message field) because computing a hash with empty V,R,S signature fields doesn't make sense, and it's documented as "not on-chain hash without signature". This is a deliberate placeholder approach.
🧬 Code Graph Analysis (2)
plugin/fees/transaction.go (1)
internal/types/keysign.go (1)
  • PluginKeysignRequest (7-12)
plugin/fees/fees.go (1)
plugin/fees/config.go (6)
  • FeeCollectionFormat (154-157)
  • FeeCollectionType (145-145)
  • FeeCollectionTypeAll (151-151)
  • FeeCollectionTypeByPublicKey (148-148)
  • FeeCollectionTypeByPolicy (149-149)
  • FeeCollectionTypeByPluginID (150-150)
🔇 Additional comments (12)
plugin/fees/fees.go (5)

162-162: Good addition of structured logging for fee collection job tracking.

This info-level log appropriately marks the start of the fee collection process, which is useful for monitoring and debugging.


170-170: Improved error message with consistent prefix and proper error wrapping.

The error message now includes a clear function context prefix and uses proper error wrapping with %w verb for better error traceability.


176-184: Helpful info logs for different fee collection types.

These logs provide clear visibility into which type of fee collection is being executed, which is valuable for operational monitoring.


203-203: Consistent info-level logging for fee collection status.

The logging provides good visibility into the fee collection process, including pending amounts and collection status for different scenarios.

Also applies to: 217-217, 220-220, 239-239, 254-254, 273-273, 288-288


329-329: Proper error wrapping for transaction proposal failures.

The error wrapping follows Go best practices and provides clear context for debugging.

plugin/fees/transaction.go (7)

124-124: Improved error message prefix for nonce manager.

The updated prefix "plugincommon.nonceManager.GetNextNonce" provides better context and consistency compared to the previous shorter form.


139-139: Standardized error message prefix for transaction generation.

The prefix "plugincommon.genUnsignedTx" clearly identifies the function context and maintains consistency with other error messages.


154-154: Consistent error message prefix for transaction indexer.

The prefix "fp.tx_indexer.CreateTx" follows the established pattern and provides clear context for debugging.


223-223: Standardized error message prefix for transaction range query.

The prefix "fp.txIndexerService.GetTxInTimeRange" is consistent with other error messages and provides clear function context.


244-244: Improved error message prefix for async task enqueueing.

The prefix "fp.client.Enqueue" follows the established pattern and provides clear context for task queue operations.


254-254: Consistent error message prefix for task inspection.

The prefix "fp.inspector.GetTaskInfo" maintains consistency with other error messages and clearly identifies the operation context.


277-277: Standardized error message prefix for signing completion.

The prefix "fp.SigningComplete" follows the established pattern and provides clear context for the signing operation.

@johnnyluo johnnyluo 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

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