-
Notifications
You must be signed in to change notification settings - Fork 3
⚡️ Add rebroadcast functionality #167
base: fees-v3-post
Are you sure you want to change the base?
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds rebroadcast functionality for failed transactions by implementing storage and retrieval of raw transaction data.
- Adds a new
fee_txtable to store raw transaction data with hash as primary key - Implements database methods to insert and retrieve transaction data
- Updates transaction handling to store raw transactions and enables rebroadcasting when transactions are not found on-chain
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| storage/postgres/schema/schema.sql | Removes entire schema content (appears to be clearing the file) |
| storage/postgres/migrations/plugin/20250630152230_fee_runs.sql | Adds new fee_tx table to store transaction hash and raw transaction data |
| storage/postgres/fees.go | Implements InsertTx and GetTx methods for storing/retrieving raw transactions |
| storage/db.go | Updates interface to include new transaction storage methods and modifies SetFeeBatchSent signature |
| plugin/fees/transaction.go | Updates to store raw transactions during signing process and use new database methods |
| plugin/fees/post_tx.go | Implements rebroadcast logic by retrieving and resending stored transactions |
| plugin/fees/helper.go | Adds parseTransaction function and renames getHash to getTransaction |
Comments suppressed due to low confidence (1)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
storage/postgres/fees.go
Outdated
| h.Write(txBytes) | ||
| hash := h.Sum(nil) | ||
|
|
||
| _, err = tx.Exec(ctx, `insert into fee_tx (hash, raw_tx) values ($1, $2)`, hash, rawTx) |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash is being stored as raw bytes, but the database column is defined as VARCHAR(66) expecting a hex string. This will cause insertion failures. Convert the hash to hex string using hexutil.Encode(hash).
| _, err = tx.Exec(ctx, `insert into fee_tx (hash, raw_tx) values ($1, $2)`, hash, rawTx) | |
| _, err = tx.Exec(ctx, `insert into fee_tx (hash, raw_tx) values ($1, $2)`, hexutil.Encode(hash), rawTx) |
| return "", err | ||
| } | ||
| var rawTx string | ||
| defer rows.Close() |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing rows.Next() call before scanning. This will always fail with 'no rows in result set' error. Add 'if !rows.Next() { return "", pgx.ErrNoRows }' before the Scan call.
| rows, err := p.pool.Query(ctx, query, txHash) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| var rawTx string | ||
| defer rows.Close() | ||
| if err := rows.Scan(&rawTx); err != nil { |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Query() for a single row lookup is inefficient. Use QueryRow() instead which is designed for single-row queries and handles the iteration automatically.
| rows, err := p.pool.Query(ctx, query, txHash) | |
| if err != nil { | |
| return "", err | |
| } | |
| var rawTx string | |
| defer rows.Close() | |
| if err := rows.Scan(&rawTx); err != nil { | |
| row := p.pool.QueryRow(ctx, query, txHash) | |
| var rawTx string | |
| if err := row.Scan(&rawTx); err != nil { |
2a1c212 to
5a7dee8
Compare
73aef17 to
aba76aa
Compare
5a7dee8 to
a670cea
Compare
aba76aa to
5da5bc6
Compare
a670cea to
a444c13
Compare
5da5bc6 to
6c03da4
Compare
No description provided.