-
Notifications
You must be signed in to change notification settings - Fork 283
refactor: make tx forwarding to sequencer non-blocking if tx pool is enabled #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant EthAPIBackend
participant SequencerRPC
Client->>EthAPIBackend: SendTx(signedTx)
alt TxPool Disabled
EthAPIBackend->>EthAPIBackend: sendToSequencer(ctx, signedTx)
EthAPIBackend->>SequencerRPC: eth_sendRawTransaction
SequencerRPC-->>EthAPIBackend: Response/Error
EthAPIBackend-->>Client: Error or nil
else TxPool Enabled
EthAPIBackend->>EthAPIBackend: goroutine sendToSequencer(ctx, signedTx)
EthAPIBackend-->>Client: nil
EthAPIBackend->>SequencerRPC: eth_sendRawTransaction (async)
SequencerRPC-->>EthAPIBackend: Response/Error (logged)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (1)
✨ 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. 🪧 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
eth/api_backend.go
(2 hunks)params/version.go
(1 hunks)
🔇 Additional comments (3)
params/version.go (1)
27-27
: Version increment looks appropriate.The patch version bump from 74 to 75 correctly reflects the refactoring changes in this PR.
eth/api_backend.go (2)
22-22
: Import addition is correct.The
fmt
import is properly added to support error formatting in the newsendToSequencer
method.
297-307
: Well-implemented helper method.The
sendToSequencer
method properly extracts the sequencer RPC logic with appropriate error handling and clear separation of concerns. The error messages are descriptive and the method follows the single responsibility principle.
eth/api_backend.go
Outdated
return err | ||
// If the transaction pool is disabled, then we need to make sure that we send the transaction to the sequencer RPC synchronously. | ||
if b.disableTxPool { | ||
return b.sendToSequencer(ctx, signedTx) |
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.
return b.sendToSequencer(ctx, signedTx) | |
err := b.sendToSequencer(ctx, signedTx) | |
if err != nil { | |
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err) | |
} | |
return err |
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.
done in f0362d4
eth/api_backend.go
Outdated
// If the transaction pool is enabled, we send the transaction to the sequencer RPC asynchronously as this is | ||
// additional to the public mempool. | ||
go func() { | ||
err := b.sendToSequencer(ctx, signedTx) | ||
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err) |
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.
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err) | |
if err != nil { | |
log.Warn("failed to forward tx to sequencer", "tx", signedTx.Hash(), "err", err) | |
} |
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.
done in f0362d4
* fix: beacon node client request with context * chore: auto version bump [bot]
…ward-non-blocking
This PR makes tx forwarding non-blocking if the tx pool is enabled. If the tx pool is disabled (private mempool mode) then the forwarding is done synchronously to notify the user. In the additional case this is not necessary as it is optional and in the failure case the transaction will simply be broadcast like usual via gossip (public mempool).
Summary by CodeRabbit