-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat(services/rfq): use one submitter #2418
Conversation
Warning Rate Limit Exceeded@trajan0x has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 50 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent update introduces enhanced functionality for managing relayer options, particularly focusing on transaction submission. A new mechanism allows for the specification of a submitter through variadic parameters, improving flexibility and customization in the relayer's setup. This change affects the initialization process of the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Deploying sanguine-fe with Cloudflare Pages
|
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: 0
Review Status
Configuration used: .coderabbit.yaml
Files selected for processing (3)
- services/cctp-relayer/relayer/options.go (1 hunks)
- services/cctp-relayer/relayer/relayer.go (2 hunks)
- services/rfq/relayer/service/relayer.go (1 hunks)
Additional Context Used
GitHub Check Runs (1)
Lint (services/cctp-relayer) failure (4)
services/cctp-relayer/relayer/relayer.go: [failure] 77-77:
calculated cyclomatic complexity for function NewCCTPRelayer is 13, max is 10 (cyclop)
Additional comments not posted (3)
services/cctp-relayer/relayer/options.go (1)
5-26
: The implementation of options for the relayer using the functional options pattern is well done. This pattern is a good choice for configuring objects without needing a large constructor or a configuration struct exposed. It's flexible and allows for future expansion of options without breaking changes.services/rfq/relayer/service/relayer.go (1)
277-277
: Addingrelayer.WithSubmitter(r.submitter)
as a parameter toNewCCTPRelayer
effectively implements the PR's goal of using a single submitter instance across the RFQ service. This change should streamline the submitter management and potentially reduce the issues related to race conditions and transaction bumping. Ensure that thesubmitter
instance passed here is properly initialized and thread-safe, as it will be shared across different parts of the service.services/cctp-relayer/relayer/relayer.go (1)
113-122
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [77-119]
The introduction of variadic parameters (
rawOpts ...OptionsArgsOption
) in theNewCCTPRelayer
function is a good approach to enhance flexibility and configurability. This change, along with the conditional initialization oftxSubmitter
based onopts.submitter
, aligns with the PR's objective to consolidate submitter usage. However, the cyclomatic complexity ofNewCCTPRelayer
has increased beyond the recommended threshold. Consider refactoring to simplify the logic, possibly by extracting parts of the initialization process into separate functions.func NewCCTPRelayer(ctx context.Context, cfg config.Config, store db2.CCTPRelayerDB, scribeClient client.ScribeClient, omniRPCClient omniClient.RPCClient, handler metrics.Handler, attestationAPI attestation.CCTPAPI, rawOpts ...OptionsArgsOption) (*CCTPRelayer, error) { + // Refactored code to reduce complexity + conn, grpcClient, err := setupGRPCConnection(ctx, scribeClient, handler) + if err != nil { + return nil, err + } + opts := makeOptions(rawOpts) ... } + // setupGRPCConnection encapsulates the gRPC connection setup + func setupGRPCConnection(ctx context.Context, scribeClient client.ScribeClient, handler metrics.Handler) (*grpc.ClientConn, pbscribe.ScribeServiceClient, error) { + conn, err := grpc.DialContext(ctx, fmt.Sprintf("%s:%d", scribeClient.URL, scribeClient.Port), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(handler.GetTracerProvider()))), + grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(handler.GetTracerProvider()))), + ) + if err != nil { + return nil, nil, fmt.Errorf("could not dial grpc: %w", err) + } + + grpcClient := pbscribe.NewScribeServiceClient(conn) + return conn, grpcClient, nil + }
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2418 +/- ##
===================================================
- Coverage 46.85139% 46.72382% -0.12757%
===================================================
Files 399 396 -3
Lines 30569 30447 -122
Branches 83 83
===================================================
- Hits 14322 14226 -96
+ Misses 14714 14691 -23
+ Partials 1533 1530 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
Currently rfq is using two submitter instances: one for cctp and one for rfq. This is leading to a lot of race conditions, over bumping, and many other issues (and exaggerating #2410). This should fix it
Summary by CodeRabbit