fix payroll data structures & policy validation#125
Conversation
WalkthroughThis set of changes updates the payroll plugin to support a "token" parameter in policy rules, simplifies token ID extraction from rule parameter constraints, and switches policy deserialization from JSON to base64-decoded protobuf. It also adds related validation logic, updates scheduling limits, and includes a minor comment addition for local debugging. Changes
Sequence Diagram(s)sequenceDiagram
participant Scheduler
participant Policy
participant Protobuf
Scheduler->>Policy: GetTriggerFromPolicy(policy)
Policy->>Scheduler: policy.Recipe (base64 string)
Scheduler->>Protobuf: base64 decode + proto.Unmarshal
Protobuf-->>Scheduler: Policy object
Scheduler->>Scheduler: Proceed with trigger extraction
sequenceDiagram
participant Plugin
participant Rule
participant getTokenID
Plugin->>Rule: Access parameter constraints
Plugin->>getTokenID: getTokenID(rule)
getTokenID->>Rule: Find "token" constraint
getTokenID-->>Plugin: Return token ID or zero address
Plugin->>Plugin: Use token ID in transaction proposal
Possibly related PRs
Suggested reviewers
Poem
✨ 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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
plugin/payroll/transaction.go (1)
404-404: Unlimited scheduled executions may impact performance.The change from
MaxScheduledExecutions: 100toMaxScheduledExecutions: -1(infinite) removes the execution limit, which could lead to performance issues or resource exhaustion.Consider whether unlimited executions are truly needed or if a higher but finite limit would be more appropriate for production environments. You might also want to implement monitoring and alerting for policies with high execution counts.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
api/plugin.go(1 hunks)internal/scheduler/scheduler.go(3 hunks)plugin/payroll/policy.go(2 hunks)plugin/payroll/transaction.go(5 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
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.
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.
api/plugin.go (1)
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.
internal/scheduler/scheduler.go (1)
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.
plugin/payroll/policy.go (3)
Learnt from: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:510-514
Timestamp: 2025-06-18T18:20:59.510Z
Learning: The erc20ABI constant is defined in plugin/payroll/constants.go within the payroll package, making it accessible to other files in the same package like transaction.go.
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/policy.go:46-47
Timestamp: 2025-07-04T10:47:47.927Z
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: 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.
plugin/payroll/transaction.go (5)
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: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:510-514
Timestamp: 2025-06-18T18:20:59.510Z
Learning: The erc20ABI constant is defined in plugin/payroll/constants.go within the payroll package, making it accessible to other files in the same package like transaction.go.
Learnt from: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:43-44
Timestamp: 2025-06-18T18:22:06.358Z
Learning: In the vultisig/plugin codebase, the hardcoded ethereumEvmChainID = big.NewInt(1) in plugin/payroll/transaction.go is intentional for the current implementation phase. The team is implementing ETH first, with plans to add other EVM chains later. The functions/methods are already designed to work with all EVM chains.
Learnt from: garry-sharp
PR: vultisig/plugin#117
File: plugin/fees/policy.go:46-47
Timestamp: 2025-07-04T10:47:47.927Z
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: 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.
🧬 Code Graph Analysis (1)
plugin/payroll/policy.go (1)
plugin/payroll/payroll.go (1)
PayrollPlugin(19-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
api/plugin.go (1)
191-191: Development note acknowledged.The TODO comment serves as a helpful reminder for local debugging scenarios involving recipe mocks and signature validation.
internal/scheduler/scheduler.go (1)
188-195: Policy serialization format changes verifiedAll occurrences of
policy.Recipenow consistently use protobuf-encoded, base64 strings:
- common/util.go – RecipeToBase64: proto.Marshal + base64 encode
- internal/scheduler/scheduler.go – GetTriggerFromPolicy: base64 decode + proto.Unmarshal
- plugin/payroll/policy.go & plugin/fees/policy.go – base64 decode + proto.Unmarshal
- No remaining JSON Unmarshal of
policy.Recipein production codeNo further action required.
plugin/payroll/transaction.go (1)
449-449: Parameter constraints limit increase is logical.The increase from 2 to 3 parameter constraints aligns with the addition of the "token" parameter alongside existing "recipient" and "amount" parameters.
Ref: #124
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation