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

rework and fix eth tx calldata/fee build#96

Merged
webpiratt merged 3 commits into
mainfrom
eth-fixes
Jun 18, 2025
Merged

rework and fix eth tx calldata/fee build#96
webpiratt merged 3 commits into
mainfrom
eth-fixes

Conversation

@webpiratt

@webpiratt webpiratt commented Jun 18, 2025

Copy link
Copy Markdown
Contributor
  • correctly pack/unpack unsigned tx;
  • correctly append signature after it signed;
  • correctly work with gas and using latest EIP-1559 tx (instead of LegacyTx) for faster landing on-chain with less fees;
  • refactoring to make code extendable;

Unit tests to be done in next PRs

Ref: #61

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Payroll transactions now use EIP-1559 dynamic fee ERC20 transfers, providing improved fee estimation and transaction reliability.
  • Refactor
    • Transaction generation and signing flows have been streamlined for better performance and maintainability.
  • Bug Fixes
    • Enhanced concurrency when estimating gas and nonces, reducing potential delays and errors during transaction creation.

@coderabbitai

coderabbitai Bot commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The payroll plugin's Ethereum transaction logic is refactored to use EIP-1559 dynamic fee transactions. Legacy transaction construction and signing are replaced with new methods that generate, encode, and sign unsigned transactions using updated concurrency and helper functions. The transaction proposal and signing completion flows are updated accordingly.

Changes

File(s) Change Summary
plugin/payroll/transaction.go Removed legacy Ethereum transaction generation; added EIP-1559 dynamic fee unsigned tx creation; replaced signing logic with signature appending; updated proposal and signing flows; introduced helpers for encoding, signing, and concurrent estimation of gas, fees, and nonce.

Sequence Diagram(s)

sequenceDiagram
    participant Plugin as PayrollPlugin
    participant RPC as Ethereum RPC
    participant TSS as Threshold Signer

    Plugin->>RPC: Concurrently estimate gas, fees, nonce
    Plugin->>Plugin: Build unsigned EIP-1559 ERC20 transfer tx
    Plugin->>TSS: Propose unsigned tx (hex-encoded) for signing
    TSS-->>Plugin: Return TSS signature (R, S, RecoveryID)
    Plugin->>Plugin: Append signature to unsigned tx
    Plugin->>RPC: Broadcast signed transaction
Loading

Poem

In the warren where code does hop,
EIP-1559 takes the top!
Old ways gone, new bytes spun,
Transactions built, gas estimates run.
Sign and send, with speed anew—
The payroll rabbits thank this crew!
🐇✨

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 d75acfb and 7efb4d8.

📒 Files selected for processing (1)
  • plugin/payroll/transaction.go (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
plugin/payroll/transaction.go (3)
Learnt from: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:510-514
Timestamp: 2025-06-18T18:20:59.469Z
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.333Z
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: webpiratt
PR: vultisig/plugin#96
File: plugin/payroll/transaction.go:0-0
Timestamp: 2025-06-18T18:23:20.046Z
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.
🔇 Additional comments (8)
plugin/payroll/transaction.go (8)

17-17: LGTM! Import addition is correct.

The reth alias for the ethereum recipes package is properly imported and used throughout the new EIP-1559 transaction handling code.


158-191: Transaction generation refactoring looks good.

The refactoring from generatePayrollTransaction to genUnsignedTx simplifies the code and makes it more maintainable. The new approach with concurrent transaction generation is well-implemented.


238-259: SigningComplete method simplification is excellent.

The refactoring to use evmAppendSignature significantly simplifies the signing completion logic and makes it more maintainable. The error handling and logging are also improved.


322-344: Excellent design for chain-agnostic transaction generation.

The genUnsignedTx method provides a clean abstraction that will make it easy to add support for additional chains in the future. The error handling and switch statement structure are well-implemented.


346-373: EIP-1559 transaction encoding is correctly implemented.

The function properly encodes dynamic fee transactions according to the EIP-1559 specification, including the correct transaction type prefix and RLP encoding structure.


375-395: Signature appending logic is correctly implemented.

The function properly handles TSS signature components and uses the Prague signer, which is appropriate for the latest Ethereum transaction types.


397-494: Excellent concurrent estimation approach.

The use of errgroup for concurrent gas estimation, fee suggestion, and nonce retrieval is an excellent optimization that will improve performance significantly.


496-551: ERC20 transfer transaction creation is well-implemented.

The function correctly handles ERC20 transfer transaction creation with proper ABI encoding and parameter validation. The integration with the estimation and encoding functions is seamless.

✨ 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.

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

🧹 Nitpick comments (2)
plugin/payroll/transaction.go (2)

321-344: Unhandled default branch hides error cause

The default: case in genUnsignedTx is empty, then the function falls through to the generic error. Logically unreachable code paths should return a descriptive error inside the switch to avoid accidental success with nil.


404-420: Data-race risk on shared vars

gasLimit, gasTipCap, baseFee, nonce are written inside goroutines without synchronisation. While writes finish before the eg.Wait() return, the Go race-detector still flags unsynchronised writes. Wrap each variable in a struct and assign the pointer inside the goroutine, or compute sequentially—these RPC calls are cheap.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 30548d1 and d75acfb.

📒 Files selected for processing (1)
  • plugin/payroll/transaction.go (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
plugin/payroll/transaction.go (1)

158-171: Missing 0x prefix and potential odd-length hex

hex.EncodeToString(tx) yields a bare hex string. Later you feed this value into gcommon.FromHex which expects an optional "0x" prefix and even length; if the first byte is < 0x10 the length becomes odd and decoding will panic.
Add the prefix and normalise length before storing / transmitting.

- txHex := hex.EncodeToString(tx)
+txHex := "0x" + hex.EncodeToString(tx)

Likely an incorrect or invalid review comment.

Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@webpiratt
webpiratt enabled auto-merge June 18, 2025 18:28

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

2 participants