Skip to content
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

RFQ API: add GET /ack endpoint #2643

Merged
merged 24 commits into from
May 20, 2024
Merged

RFQ API: add GET /ack endpoint #2643

merged 24 commits into from
May 20, 2024

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented May 15, 2024

Summary by CodeRabbit

  • New Features

    • Added a new endpoint /ack with a PUT method for caching acknowledgment requests in the API.
    • Added relay acknowledgment functionality to the client interfaces for handling relay synchronization.
  • Enhancements

    • Updated the API documentation to include the new /ack endpoint.
    • Improved request handling by incorporating relay acknowledgment checks to prevent reverts.
  • Testing

    • Added new test functions to verify the PUT acknowledgment requests and relay responses.
  • Internal Improvements

    • Refactored QuoterManager and Relayer to include additional parameters for better relay handling.

Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

The recent updates enhance relay acknowledgment functionality in the RFQ service, introducing features like RelayAckTimeout in the Config struct, new methods for handling acknowledgments in client interfaces, additional API endpoints for acknowledgment caching, and adjustments to structures like QuoterManager and Relayer to support these enhancements, aiming to improve synchronization and prevent reverts during relay operations.

Changes

Files Change Summary
services/rfq/api/config/config.go Added RelayAckTimeout field, default value, and GetRelayAckTimeout method to Config struct.
services/rfq/api/client/client.go Added GetRelayAck and PutRelayAck methods to client interfaces.
services/rfq/api/docs/docs.go Added a new endpoint /ack with a PUT method for caching ack requests.
services/rfq/api/docs/swagger.json Added a new endpoint /ack with a PUT method for caching ack requests.
services/rfq/api/docs/swagger.yaml Added a new endpoint /ack with a PUT method for caching ack requests.
services/rfq/api/model/request.go Added PutAckRequest struct with TxID and DestChainID fields.
services/rfq/api/model/response.go Added PutRelayAckResponse struct with relevant fields.
services/rfq/api/rest/server.go Updated QuoterAPIServer struct with new fields and method.
services/rfq/api/rest/server_test.go Added a new test function and renamed a function.
services/rfq/relayer/quoter/quoter.go Updated function signature and error handling.
services/rfq/relayer/quoter/quoter_test.go Modified function call to include an additional argument.
services/rfq/relayer/quoter/suite_test.go Added an additional argument to a function call.
services/rfq/relayer/relapi/model.go Added a new struct for response schema.
services/rfq/relayer/service/handlers.go Updated logic in a function and added a method call.
services/rfq/relayer/service/relayer.go Updated struct and initialization function.
services/rfq/relayer/service/statushandler.go Added a field to a struct and assigned a value.

🐰✨ In the land of code where packets flow,
A rabbit danced with a relay's glow.
With ack and timeout in his hat,
He ensured the relayers had a chat.
Now synced and swift, no reverts in sight,
The RFQ world shines ever so bright! 🌟


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?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@github-actions github-actions bot added go Pull requests that update Go code size/s labels May 15, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9b30673 and f5155e6.
Files selected for processing (5)
  • services/rfq/api/config/config.go (2 hunks)
  • services/rfq/api/rest/server.go (6 hunks)
  • services/rfq/api/rest/server_test.go (2 hunks)
  • services/rfq/relayer/relapi/handler.go (1 hunks)
  • services/rfq/relayer/relapi/model.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • services/rfq/relayer/relapi/handler.go
  • services/rfq/relayer/relapi/model.go
Additional comments not posted (7)
services/rfq/api/config/config.go (2)

30-30: The default relay acknowledgment timeout is set to 5 seconds, which is a reasonable default value.


33-37: The GetRelayAckTimeout method is correctly implemented to return the RelayAckTimeout value, defaulting to defaultRelayAckTimeout if not set.

services/rfq/api/rest/server.go (4)

44-46: The relayAckCache and ackMux fields are correctly added to manage relay acknowledgment caching and synchronization.


97-106: The relayAckCache is correctly initialized with a TTL and started in a goroutine, with proper handling for context cancellation.


123-123: The AckRoute constant is correctly added for the new /ack endpoint.


213-236: The GetRelayAck method is correctly implemented to handle checking if a relay acknowledgment is pending, using the relayAckCache and ackMux.

services/rfq/api/rest/server_test.go (1)

207-249: The TestGetAck test function is correctly implemented to test the new /ack endpoint for relay acknowledgment.

Port string `yaml:"port"`
Bridges map[uint32]string `yaml:"bridges"`
Port string `yaml:"port"`
RelayAckTimeout time.Duration `yaml:"relay_ack_timeout"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a YAML tag for RelayAckTimeout.

- RelayAckTimeout time.Duration     `yaml:"relay_ack_timeout"`
+ RelayAckTimeout time.Duration     `yaml:"relay_ack_timeout" yaml:"relay_ack_timeout"`

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
RelayAckTimeout time.Duration `yaml:"relay_ack_timeout"`
RelayAckTimeout time.Duration `yaml:"relay_ack_timeout" yaml:"relay_ack_timeout"`

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 53.28947% with 71 lines in your changes are missing coverage. Please review.

Project coverage is 39.68329%. Comparing base (9b30673) to head (85b3dc0).
Report is 2 commits behind head on master.

Files Patch % Lines
services/rfq/api/rest/server.go 71.81818% 22 Missing and 9 partials ⚠️
services/rfq/relayer/service/handlers.go 0.00000% 17 Missing ⚠️
services/rfq/api/client/client.go 0.00000% 15 Missing ⚠️
services/rfq/relayer/service/relayer.go 0.00000% 6 Missing ⚠️
services/rfq/relayer/relapi/handler.go 0.00000% 1 Missing ⚠️
services/rfq/relayer/service/statushandler.go 0.00000% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2643         +/-   ##
===================================================
- Coverage   40.93290%   39.68329%   -1.24961%     
===================================================
  Files            231         180         -51     
  Lines          15843       14714       -1129     
  Branches         312          80        -232     
===================================================
- Hits            6485        5839        -646     
+ Misses          8571        8106        -465     
+ Partials         787         769         -18     
Flag Coverage Δ
rfq 31.63408% <53.28947%> (+0.61855%) ⬆️
solidity ?
stiprelayer 3.33333% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

cloudflare-workers-and-pages bot commented May 15, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 85b3dc0
Status: ✅  Deploy successful!
Preview URL: https://5bea1ad2.sanguine-fe.pages.dev
Branch Preview URL: https://feat-relay-semaphore.sanguine-fe.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between f5155e6 and b201299.
Files selected for processing (5)
  • services/rfq/api/client/client.go (2 hunks)
  • services/rfq/api/model/response.go (1 hunks)
  • services/rfq/relayer/service/handlers.go (1 hunks)
  • services/rfq/relayer/service/relayer.go (4 hunks)
  • services/rfq/relayer/service/statushandler.go (3 hunks)
Additional comments not posted (4)
services/rfq/api/model/response.go (1)

29-35: The GetRelayAckResponse struct is well-defined and correctly uses JSON tags.

services/rfq/api/client/client.go (1)

37-37: The GetRelayAck method has been correctly added to the UnauthenticatedClient interface.

services/rfq/relayer/service/statushandler.go (1)

46-47: The apiClient field has been correctly added to the QuoteRequestHandler struct.

services/rfq/relayer/service/relayer.go (1)

44-44: The apiClient field has been correctly added to the Relayer struct.

Comment on lines 150 to 159
// get ack from API to synchronize calls with other relayers and avoid reverts
resp, err := q.apiClient.GetRelayAck(ctx, hexutil.Encode(request.TransactionID[:]))
if err != nil {
return fmt.Errorf("could not get relay ack: %w", err)
}
if !resp.ShouldRelay {
span.SetAttributes(attribute.Bool("should_relay", false))
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling and logging for API call to GetRelayAck.

The added code correctly calls the GetRelayAck API and handles the response. However, it would be beneficial to add logging for better traceability and debugging.

// get ack from API to synchronize calls with other relayers and avoid reverts
resp, err := q.apiClient.GetRelayAck(ctx, hexutil.Encode(request.TransactionID[:]))
if err != nil {
    logger.Errorf("Failed to get relay ack for transaction ID: %s, error: %v", hexutil.Encode(request.TransactionID[:]), err)
    return fmt.Errorf("could not get relay ack: %w", err)
}
if !resp.ShouldRelay {
    span.SetAttributes(attribute.Bool("should_relay", false))
    logger.Infof("Relay not required for transaction ID: %s", hexutil.Encode(request.TransactionID[:]))
    return nil
}

Comment on lines 193 to 212
func (c *unauthenticatedClient) GetRelayAck(ctx context.Context, txID string) (*model.GetRelayAckResponse, error) {
var ack *model.GetRelayAckResponse
resp, err := c.rClient.R().
SetContext(ctx).
SetQueryParams(map[string]string{
"id": txID,
}).
SetResult(&ack).
Get(rest.AckRoute)

if err != nil {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}

if resp.IsError() {
return nil, fmt.Errorf("error from server: %s", resp.Status())
}

return ack, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve error handling for clarity in the GetRelayAck method.

-	if err != nil {
-		return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
-	}
-
-	if resp.IsError() {
-		return nil, fmt.Errorf("error from server: %s", resp.Status())
-	}
+	if err != nil || resp.IsError() {
+		return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
+	}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (c *unauthenticatedClient) GetRelayAck(ctx context.Context, txID string) (*model.GetRelayAckResponse, error) {
var ack *model.GetRelayAckResponse
resp, err := c.rClient.R().
SetContext(ctx).
SetQueryParams(map[string]string{
"id": txID,
}).
SetResult(&ack).
Get(rest.AckRoute)
if err != nil {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}
if resp.IsError() {
return nil, fmt.Errorf("error from server: %s", resp.Status())
}
return ack, nil
}
func (c *unauthenticatedClient) GetRelayAck(ctx context.Context, txID string) (*model.GetRelayAckResponse, error) {
var ack *model.GetRelayAckResponse
resp, err := c.rClient.R().
SetContext(ctx).
SetQueryParams(map[string]string{
"id": txID,
}).
SetResult(&ack).
Get(rest.AckRoute)
if err != nil || resp.IsError() {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}
return ack, nil
}

Comment on lines 125 to 128
apiClient, err := rfqAPIClient.NewUnauthenticatedClient(metricHandler, cfg.GetRfqAPIURL())
if err != nil {
return nil, fmt.Errorf("error creating RFQ API client: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the error message for consistency in the NewRelayer function.

-	return nil, fmt.Errorf("error creating RFQ API client: %w", err)
+	return nil, fmt.Errorf("could not create RFQ API client: %w", err)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
apiClient, err := rfqAPIClient.NewUnauthenticatedClient(metricHandler, cfg.GetRfqAPIURL())
if err != nil {
return nil, fmt.Errorf("error creating RFQ API client: %w", err)
}
apiClient, err := rfqAPIClient.NewUnauthenticatedClient(metricHandler, cfg.GetRfqAPIURL())
if err != nil {
return nil, fmt.Errorf("could not create RFQ API client: %w", err)
}

services/rfq/api/rest/server.go Outdated Show resolved Hide resolved
services/rfq/api/config/config.go Outdated Show resolved Hide resolved
@@ -188,3 +209,28 @@ func (r *QuoterAPIServer) AuthMiddleware() gin.HandlerFunc {
c.Next()
}
}

// GetRelayAck checks if a relay is pending or not.
func (r *QuoterAPIServer) GetRelayAck(c *gin.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this w/ swagger docs? You should see this in handler.go and be able to regenerate. Just consists of copying the comments over from anything in handler.go and rerunning go generate followed by a yarn docusaurus gen-api-docs all from docs/bridge

Would also be good to add the endpoint here

and document the step here

services/rfq/relayer/service/relayer.go Outdated Show resolved Hide resolved
services/rfq/api/model/response.go Outdated Show resolved Hide resolved
services/rfq/api/rest/server.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/m and removed size/s labels May 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between b201299 and e50f170.
Files selected for processing (16)
  • services/rfq/api/client/client.go (2 hunks)
  • services/rfq/api/config/config.go (2 hunks)
  • services/rfq/api/docs/docs.go (1 hunks)
  • services/rfq/api/docs/swagger.json (1 hunks)
  • services/rfq/api/docs/swagger.yaml (1 hunks)
  • services/rfq/api/model/request.go (1 hunks)
  • services/rfq/api/model/response.go (1 hunks)
  • services/rfq/api/rest/server.go (6 hunks)
  • services/rfq/api/rest/server_test.go (9 hunks)
  • services/rfq/relayer/quoter/quoter.go (1 hunks)
  • services/rfq/relayer/quoter/quoter_test.go (1 hunks)
  • services/rfq/relayer/quoter/suite_test.go (1 hunks)
  • services/rfq/relayer/relapi/model.go (1 hunks)
  • services/rfq/relayer/service/handlers.go (2 hunks)
  • services/rfq/relayer/service/relayer.go (4 hunks)
  • services/rfq/relayer/service/statushandler.go (3 hunks)
Files not reviewed due to errors (2)
  • services/rfq/relayer/service/relayer.go (no review received)
  • services/rfq/relayer/quoter/quoter.go (no review received)
Files skipped from review as they are similar to previous changes (2)
  • services/rfq/api/config/config.go
  • services/rfq/relayer/relapi/model.go
Additional Context Used
GitHub Check Runs (2)
codecov/patch success (7)

services/rfq/api/rest/server.go: [warning] 278-279: services/rfq/api/rest/server.go#L278-L279
Added lines #L278 - L279 were not covered by tests


services/rfq/relayer/service/handlers.go: [warning] 157-163: services/rfq/relayer/service/handlers.go#L157-L163
Added lines #L157 - L163 were not covered by tests


services/rfq/relayer/service/relayer.go: [warning] 116-116: services/rfq/relayer/service/relayer.go#L116
Added line #L116 was not covered by tests


services/rfq/relayer/service/relayer.go: [warning] 118-118: services/rfq/relayer/service/relayer.go#L118
Added line #L118 was not covered by tests


services/rfq/relayer/service/relayer.go: [warning] 144-144: services/rfq/relayer/service/relayer.go#L144
Added line #L144 was not covered by tests


services/rfq/relayer/service/statushandler.go: [warning] 74-74: services/rfq/relayer/service/statushandler.go#L74
Added line #L74 was not covered by tests

Lint (services/rfq) failure (8)

services/rfq/api/rest/server.go: [failure] 210-210:
unnecessary conversion (unconvert)


services/rfq/api/rest/server.go: [failure] 227-227:
unnecessary conversion (unconvert)


services/rfq/api/rest/server.go: [failure] 232-232:
unnecessary conversion (unconvert)


services/rfq/api/rest/server.go: [failure] 223-223:
non-wrapping format verb for fmt.Errorf. Use %w to format errors (errorlint)


services/rfq/api/rest/server.go: [failure] 274-274:
type assertion must be checked (forcetypeassert)

Additional comments not posted (16)
services/rfq/api/model/request.go (1)

16-20: LGTM! The new PutAckRequest struct follows the existing pattern.

services/rfq/api/model/response.go (1)

29-37: LGTM! The new PutRelayAckResponse struct follows the existing pattern.

services/rfq/api/docs/swagger.yaml (1)

70-89: LGTM! The new /ack path follows the existing pattern.

services/rfq/relayer/quoter/suite_test.go (1)

119-119: LGTM! The new call to quoter.NewQuoterManager follows the existing pattern.

services/rfq/api/client/client.go (1)

29-29: LGTM! The addition of PutRelayAck method to AuthenticatedClient interface is appropriate.

services/rfq/api/docs/swagger.json (1)

7-36: LGTM! The Swagger documentation for the new /ack endpoint is clear and well-structured.

services/rfq/api/docs/docs.go (1)

18-47: LGTM! The generated Swagger documentation for the new /ack endpoint is clear and well-structured.

services/rfq/api/rest/server.go (5)

97-106: Ensure the relay acknowledgment cache is properly initialized and stopped.

Please verify that the relay acknowledgment cache is correctly integrated and stopped when the context is done.


177-183: Ensure the request type is correctly handled for AckRoute.

Please verify that the request type for AckRoute is correctly handled and that the appropriate fields are being parsed.


264-268: Ensure the request is properly retrieved from the context.

Please verify that the request is properly retrieved from the context and that appropriate error handling is in place.


271-273: Ensure the relayer address is properly retrieved from the context.

Please verify that the relayer address is properly retrieved from the context and that appropriate error handling is in place.


277-279: Ensure the request type is correctly asserted.

Please verify that the request type is correctly asserted and that appropriate error handling is in place.

services/rfq/api/rest/server_test.go (3)

16-16: The import of relapi is necessary for the new test case TestPutAck.


207-250: The test case TestPutAck is well-structured and covers both scenarios of acknowledgment: first-time acknowledgment and repeated acknowledgment.


314-340: The helper method sendPutAckRequest is correctly implemented and follows the pattern of other helper methods in the file.

services/rfq/relayer/quoter/quoter_test.go (1)

234-234: The test case TestGetDestAmount is well-structured and covers various scenarios for calculating the destination amount.

Comment on lines +142 to +150
// check if we have enough inventory to handle the request
if committableBalance.Cmp(request.Transaction.DestAmount) < 0 {
err = q.db.UpdateQuoteRequestStatus(ctx, request.TransactionID, reldb.NotEnoughInventory)
if err != nil {
return fmt.Errorf("could not update request status: %w", err)
}
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add logging for better traceability and debugging.

// check if we have enough inventory to handle the request
if committableBalance.Cmp(request.Transaction.DestAmount) < 0 {
    logger.Infof("Not enough inventory for transaction ID: %s", hexutil.Encode(request.TransactionID[:]))
    err = q.db.UpdateQuoteRequestStatus(ctx, request.TransactionID, reldb.NotEnoughInventory)
    if err != nil {
        return fmt.Errorf("could not update request status: %w", err)
    }
    return nil
}

Comment on lines 151 to 164
// get ack from API to synchronize calls with other relayers and avoid reverts
req := model.PutAckRequest{
TxID: hexutil.Encode(request.TransactionID[:]),
DestChainID: int(request.Transaction.DestChainId),
}
resp, err := q.apiClient.PutRelayAck(ctx, &req)
if err != nil {
return fmt.Errorf("could not get relay ack: %w", err)
}
if !resp.ShouldRelay {
span.SetAttributes(attribute.Bool("should_relay", false))
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling and logging for API call to PutRelayAck.

// get ack from API to synchronize calls with other relayers and avoid reverts
req := model.PutAckRequest{
    TxID:        hexutil.Encode(request.TransactionID[:]),
    DestChainID: int(request.Transaction.DestChainId),
}
resp, err := q.apiClient.PutRelayAck(ctx, &req)
if err != nil {
    logger.Errorf("Failed to get relay ack for transaction ID: %s, error: %v", hexutil.Encode(request.TransactionID[:]), err)
    return fmt.Errorf("could not get relay ack: %w", err)
}
if !resp.ShouldRelay {
    span.SetAttributes(attribute.Bool("should_relay", false))
    logger.Infof("Relay not required for transaction ID: %s", hexutil.Encode(request.TransactionID[:]))
    return nil
}

Comment on lines 151 to 163
// get ack from API to synchronize calls with other relayers and avoid reverts
req := model.PutAckRequest{
TxID: hexutil.Encode(request.TransactionID[:]),
DestChainID: int(request.Transaction.DestChainId),
}
resp, err := q.apiClient.PutRelayAck(ctx, &req)
if err != nil {
return fmt.Errorf("could not get relay ack: %w", err)
}
if !resp.ShouldRelay {
span.SetAttributes(attribute.Bool("should_relay", false))
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for the new code handling relay acknowledgment.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Comment on lines +141 to +143
ackPut := engine.Group(AckRoute)
ackPut.Use(r.AuthMiddleware())
ackPut.PUT("", r.PutRelayAck)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing the HTTP method to PUT for consistency.

-  ackPut.PUT("", r.PutRelayAck)
+  ackPut.PUT("", r.PutRelayAck)

A GET request is counterintuitive here since it writes data to a cache. Consider using PUT to reflect that data is being written.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
ackPut := engine.Group(AckRoute)
ackPut.Use(r.AuthMiddleware())
ackPut.PUT("", r.PutRelayAck)
ackPut := engine.Group(AckRoute)
ackPut.Use(r.AuthMiddleware())
ackPut.PUT("", r.PutRelayAck)

Comment on lines 210 to 214
bridge, ok := r.fastBridgeContracts[uint32(destChainID)]
if !ok {
err = fmt.Errorf("dest chain id not supported: %d", destChainID)
return addressRecovered, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary type conversion.

-  bridge, ok := r.fastBridgeContracts[uint32(destChainID)]
+  bridge, ok := r.fastBridgeContracts[destChainID]

The type conversion is unnecessary here.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
bridge, ok := r.fastBridgeContracts[uint32(destChainID)]
if !ok {
err = fmt.Errorf("dest chain id not supported: %d", destChainID)
return addressRecovered, err
}
bridge, ok := r.fastBridgeContracts[destChainID]
if !ok {
err = fmt.Errorf("dest chain id not supported: %d", destChainID)
return addressRecovered, err
}

Comment on lines +136 to +142
if err != nil {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}

if resp.IsError() {
return nil, fmt.Errorf("error from server: %s", resp.Status())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine error checks for clarity.

-	if err != nil {
-		return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
-	}
-
-	if resp.IsError() {
-		return nil, fmt.Errorf("error from server: %s", resp.Status())
-	}
+	if err != nil || resp.IsError() {
+		return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
+	}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err != nil {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}
if resp.IsError() {
return nil, fmt.Errorf("error from server: %s", resp.Status())
}
if err != nil || resp.IsError() {
return nil, fmt.Errorf("error from server: %s %w", resp.Status(), err)
}

c.Abort()
return
}
hasRole := r.roleCache[uint32(destChainID)].Get(addressRecovered.Hex())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary type conversion.

-  hasRole := r.roleCache[uint32(destChainID)].Get(addressRecovered.Hex())
+  hasRole := r.roleCache[destChainID].Get(addressRecovered.Hex())

The type conversion is unnecessary here.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
hasRole := r.roleCache[uint32(destChainID)].Get(addressRecovered.Hex())
hasRole := r.roleCache[destChainID].Get(addressRecovered.Hex())

Comment on lines +46 to +47
// apiClient is used to get acks before submitting a relay transaction.
apiClient client.AuthenticatedClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test coverage for apiClient field in QuoteRequestHandler.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

if hasRole == nil || hasRole.IsExpired() {
has, roleErr := bridge.HasRole(ops, relayerRole, addressRecovered)
if roleErr == nil {
r.roleCache[uint32(destChainID)].Set(addressRecovered.Hex(), has, cacheInterval)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary type conversion.

-  r.roleCache[uint32(destChainID)].Set(addressRecovered.Hex(), has, cacheInterval)
+  r.roleCache[destChainID].Set(addressRecovered.Hex(), has, cacheInterval)

The type conversion is unnecessary here.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
r.roleCache[uint32(destChainID)].Set(addressRecovered.Hex(), has, cacheInterval)
r.roleCache[destChainID].Set(addressRecovered.Hex(), has, cacheInterval)

c.JSON(http.StatusBadRequest, gin.H{"error": "No relayer address recovered from signature"})
return
}
relayerAddr := rawRelayerAddr.(string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check type assertion for relayer address.

-  relayerAddr := rawRelayerAddr.(string)
+  relayerAddr, ok := rawRelayerAddr.(string)
+  if !ok {
+    c.JSON(http.StatusInternalServerError, gin.H{"error": "Invalid relayer address type"})
+    return
+  }

Type assertion must be checked to avoid potential runtime panics.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
relayerAddr := rawRelayerAddr.(string)
relayerAddr, ok := rawRelayerAddr.(string)
if !ok {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Invalid relayer address type"})
return
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between e50f170 and 86ff8ee.
Files selected for processing (1)
  • services/rfq/api/rest/server.go (6 hunks)
Additional comments not posted (6)
services/rfq/api/rest/server.go (6)

42-46: LGTM! The addition of relayAckCache and ackMux fields enhances the functionality for caching relay acknowledgments and ensuring thread safety.


97-107: LGTM! The initialization and lifecycle management of relayAckCache are correctly handled.


141-143: LGTM! The addition of the /ack endpoint with a PUT method is consistent with the new functionality.


177-186: LGTM! The changes ensure that the AckRoute is authenticated correctly.


246-302: LGTM! The PutRelayAck method includes proper request validation, caching logic, and response generation.


246-263: LGTM! The documentation comments provide a clear description of the method's functionality and limitations.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 86ff8ee and 2327ba5.
Files selected for processing (1)
  • services/rfq/relayer/service/handlers.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/relayer/service/handlers.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2327ba5 and 85b3dc0.
Files selected for processing (1)
  • services/rfq/api/config/config.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/rfq/api/config/config.go

@dwasse dwasse merged commit f9b6d45 into master May 20, 2024
32 checks passed
@dwasse dwasse deleted the feat/relay-semaphore branch May 20, 2024 18:01
Defi-Moses added a commit that referenced this pull request May 31, 2024
* Update bl

* chore: lint bl

* RFQ: support multiple rebalance methods (#2556)

* WIP: refactor GetRebalanceMethod()

* Feat: implement more robust rebalance method handling

* Feat: move method validation to getRebalance() func

* Feat: manual impl for String() on RebalanceMethod

* Fix: tests

* Feat: add rebalance method clauses to TestGetRebalance

* Feat: use rebalance.Method to choose executor

* Cleanup: lint

* [goreleaser]

* [goreleaser]

* RFQ: drop requests for unsupported chains (#2563)

* Feat: check for unsupported chain in inventory manager

* Cleanup: lint

* [goreleaser]

* Fix: check for nil base fee

* [goreleaser]

* Feat: fee pricer gets gas price from SuggestGasPrice()

* [goreleaser]

* Fix: tests

* lint, add err around clientSuggestGasPrice

* Fix: tests

---------

Co-authored-by: aureliusbtc <82057759+aureliusbtc@users.noreply.github.com>

* RFQ: add decimals cache (#2502)

* Feat: add decimalsCache, refactor decimal fetching

* Cleanup: comments

* Fix: build

* Fix: use concurrent map

* CCTP: use chain listener instead of scribe (#2592)

* WIP: replace scribe with chain listener

* Fix: build

* Fix: tests

* Fix: rfq build

* Cleanup: remove unused enum

* Cleanup: revert test change

* Cleanup: comments

* Cleanup: lint

* Fix: build

* Fix: test

* docs(contracts-communication): move natspec from interfaces (#2595)

* docs: SynapseExecutionServiceV1

* docs: SynapseGasOracleV1

* docs: Interchain app templates

* docs: InterchainClientV1

* docs: InterchainDB

* docs: interchain modules

* docs: MessageBus

* style: make interfaces easier to read

* chore: fix linter warnings

* Publish

 - contracts-communication@1.5.4

* fix(sdk-rouder): remove cache hydration (#2597)

* fix: disable hydration

* chore: don't log quotes in the integration test

* Publish

 - @synapsecns/rest-api@1.0.63
 - @synapsecns/sdk-router@0.5.1
 - @synapsecns/synapse-interface@0.22.4
 - @synapsecns/widget@0.1.17

* update bl

* Revert "update bl"

This reverts commit ab56c7a.

* update bl

* feat(webhook): add webhook  (#2538)

* add models and endpoint, lacking logic

* just stuff

* just stuff

* made general db interface

* cleanup

* trying to test

* trying to test

* trying ot fix test

* remove interface{} from gorm models, start tests, rework db interface

* add signature

* secret

* look away for now

* finish db test

* finish tests

* add auth

* remove debugging log

* comments and nits

* lint

* appsecret and appid

* resolve comments

* swagger, lint

* feat(synapse-interface): maintenance aggregator using PAUSED_CHAINS (#2345)

* Aggregate maintenance events for banners and warning message

* Dynamically render countdown progress bars based on PAUSED_CHAIN

* Dynamically rendering banners

* Slightly organize

* ChainPause type applied to enforce maintenance event structure, pass in component messages as a prop

* Working with multiple events

* Add dev comments to MaintenanceBanner; refactor

* Add dev comments for MaintenanceWarningMessage; refactor

* Dev comments

* Organize components

* isChainIncluded util

* Clean

* Add ability to specify paused chains by from/to side (#2346)

* Allow indefinite maintenance components by setting end date to null

* Banners to show indefinitely as well

* Add props to disable banner / warning / countdown

* Implement disable warning

* Implement disable countdown, bridge pause still working

* Example

* Clean

* Update naming on Bridge page

* Update comment for isChainIncluded

* Create maintenance events reading from pausedChains.json

* Remove custom margins to allow Bridge parent gap styling to handle spacing

* Require all props to be defined

* Add Swap to maintenance warning messages

* Update useMaintenanceCountdownProgresses to allow distinction between Swap and Bridge pauses

* Move MaintenanceBanners into LandingPageWrapper so banner appears on all pages

* Add ability to specify whether to pause bridge / swap with maintenance event in json

* Clean

* Unused code

* Update dev comments

* Update pause start/end time name for legibility

* Create type guard to check for paused bridge module

* usePausedBridgeModules

* usePausedBridgeModules to filter out SDK quotes

* Initialize paused routes to handle specific route pauses instead of grouping with chain pauses

* Update paused route structure

* Filter for valid quotes based on paused routes

* Create a Set with paused bridge module names to improve time complexity

* Allow for all bridge modules to be paused with ALL

* Add ability to pause bridge modules for all chains, if chainId is left undefined

* Move json files to /v1/ version control folder

* Compare quotes against paused bridge modules more cleanly

* Paused bridge modules json control working

* Fix pausedChains json

* Create examples folder for pause jsons

* Retrigger build

* Fix banner flashing after clearing

* Add padding to banner Close button

* Update text sizing on progress bar

* Update prop naming to prevent confusion on start/end

* Clear chain pauses to ready PR

* Change json file naming to be more readable

* Use inputWarningMessage prop name to indicate warning placement

* Pause Doge activity using Maintenance, to replace prior Chain pause mechanism

* Doge chain paused chain prop values

* Remove paused from/to chainId constants

* Publish

 - @synapsecns/synapse-interface@0.21.0

* Exempt gh pages (#2541)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Deploy: `FastBridge` to Scroll (#2525)

* chore: add Base to `.env.example`

* chore: add Scroll config

* chore: bump devops dependency

* chore: yarn

* feat: deploy `FastBridge` on scroll

* Publish

 - FastBridge@0.2.1

* fix: update `forge-std` to 1.8.1, remove `ds-test`, use `solhint` for linting (#2545)

* chore: forge-std  v1.8.1, remove ds-test dep

* chore: remove ds-test from remappings

* refactor: state mutability

* chore: add solhint

* chore: yarn

* fix: unused imports

* fix: max line length

* Publish

 - contracts-communication@1.3.1
 - FastBridge@0.2.2
 - @synapsecns/solidity-devops@0.3.3

* chore: remove submodules from `contracts-rfq` (#2547)

* build: install OZ as npm module

* chore: update remappings

* refactor: fix compiler warnings in test contract

* chore: remove forge-std submodule

* chore: remove `openzeppelin-contracts` submodule

* fix: restore padding in `.gitmodules`

* Publish

 - FastBridge@0.2.3

* gogenerate

* Revert "gogenerate"

This reverts commit b40e602.

* im dumb

* generate

* tidy

* update swagger doc

* [goreleaser]

* [goreleaser]

---------

Co-authored-by: shampoobera <shampoo@berachain.com>
Co-authored-by: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com>
Co-authored-by: bigboydiamonds <bigboydiamonds@users.noreply.github.com>
Co-authored-by: trajan0x <83933037+trajan0x@users.noreply.github.com>
Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
Co-authored-by: χ² <88190723+ChiTimesChi@users.noreply.github.com>
Co-authored-by: ChiTimesChi <ChiTimesChi@users.noreply.github.com>

* rfq api cache (#2562)

* cache api result [goreleaser]

* clean up

* clean up 2

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* add trace to sync (#2601)

* trace more

* cleanup

* allow use of mustache templates

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* remove iconfig file (#2602)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* feat(contracts-communication): remove batching (#2599)

* feat: scaffold InterchainDB interface changes

* feat: scaffold Module interface changes

* feat: update InterchainEntry

* test: update DB tests

* test: update Client tests

* refactor: ModuleBatch -> ModuleEntry

* feat: remove `entryIndex` from InterchainTx

* feat: scaffold Client interface changes

* feat: start updating the Module

* test: update integration tests

* cleanup: remove BatchingV1

* feat: update InterchainDB

* cleanup: remove entryIndex from apps

* cleanup: remove entryIndex from Client events

* feat: update ClientV1

* cleanup: remove entryIndex from DB

* test: update SynapseModule tests

* cleanup: ClientV1

* cleanup: DB

* cleanup: Module

* cleanup: remove batch lib

* docs: smol fixes

* Publish

 - contracts-communication@1.6.0

* optional screener for cctp relayer (#2600)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Sin/testnet 9 (#2567)

* fix: remove `ExecutionFees` references

* New set of deployments

* Adjust config files to the latest changes

* adding spectral coingecko ids for pricing (#2596)

* feat(widget): suppress console errors (#2594)

* Allow widget to suppress Synapse console errors

* feat(sdk-router): router cache error log (#2591)

* Improve RouterCache error logging

* Add common error string to target at Consumer level

* Add common string to all console errors

* feat(widget): error logs (#2593)

* Add common base string to allow hiding Widget related errors outputted in Consumer app

* Convert logs into errors if firing in catch statement

* Update README

* Optional prop

* Switch catch log to error

* Re-trigger action

* Remove line

* Publish

 - @synapsecns/rest-api@1.0.64
 - @synapsecns/sdk-router@0.6.0
 - @synapsecns/synapse-interface@0.22.5
 - @synapsecns/widget@0.2.0

* fix(contracts-communication): interchain module ignore nonces (#2604)

* feat: remove dbNonce from Module interface

* cleanup: update Module interface references

* refactor: lint

* Publish

 - contracts-communication@1.6.1

* feat(synapse-interface): bridge gas handler (#2437)

* Initial gas data slice state

* Async thunk fetchGasData

* Add gas data reducers

* useFetchGasDataOnInterval added to Bridge Listener

* Explicitly declare fetching gas data in gwei

* Calculate max bridgeable amount

* On max balance factoring in gas cost

* Add comment

* Differentiate max balance vs max bridgeable balance

* Add error toaster for when max balance less than bridge fee

* refactor; calculateGasFeeInGwei()

* Move to util

* Fix lint error

* Fetch gas when fromChainId on bridge card changes

* Use exact token balance when calculate max bridgeable amount

* Conditions for showing max button

* showMaxOption to determine display

* Disable max button if gas fees more than gas balance

* Clean jsx

* AvailableBalance component to track subscript detail in bridge origin input

* Return raw and formatted gas cost in calculateGasCost

* Update comments

* Fix imports based on name cange

* Use parsed

* calculateMaxBridgeableGas

* Clean

* refactor: clean InputContainer

* Replace onMaxBalance() with onMaxBridgeableBalance()`

* Allow undefined object when destructuring

* Display when token balance is trace balance

* Typing

* showGasReserved

* Update avail balance text and color when gas cost greater than balance

* Detect when input value is less than required estimated gas

* onAvailableBalance applied

* Make opacity greater when Max button disabled

* Fix calculations for when gas input is enough to cover gas

* Clean

* Add hover tooltip for warning gas states

* Use tooltip to describe gas status

* Update tooltip text

* Add buffer to calculate gas cost, use 1.5x

* AvailableBalance component to replace label in AmountInput

* Display trace balances in AvailableBalance

* Fix naming

* Add HoverTooltip to Available Balance

* Add conditions for displaying gas error based on input

* Use full parsed balance when making comparisons for gas checks

* Show gas reserved in Available Balance

* hasOnlyZeroes to return true if string contains only zeroes and periods

* Display estimated gas cost in tool tip

* Remove Available Balance elements from AmountInput, migrated to AvailableBalance

* Display trace amount for input when displaying how much is reserved for gas

* Fetch estimated gas limit based on real bridge quote using max gas balance

* Fetching accurate gasLimit

* Fix Trace balance

* Set gasLimit to 0 if not valid bridge data avail

* ...

* Fix when gas covered msg appears

* Available Balance

* Clean available balance flow

* useGasEstimator hook to encapsulate logic to clean InputContainer

* Fix prop issue

* Remove duplicate HoverTooltip

* Move HoverTooltip to shared component folder

* Update gas fetch for wagmi v2, up limit to 1.7

* Estimated gas bridge quote fetched on load

* Update var naming

* Improve Available Balance flow

* Display estimated bridgeable balance on hover

* Show gas estimate when estimated gas cost available

* Do not show negative bridgable balance

* Separate out bridge gas limit calculations into smaller functions

* Wrap async functions with try catch

* Implement updated gas estimation flow

* Move gas estimate logic to useGasEstimator

* Move async sdk fetch functions to useGasEstimator file

* Remove unused vars

* Shorten est gas cost

* Improve code legibility in AvailableBalance

* Assign conditions to vars to reduce clutter

* Reset gas price data when fromChainId changes

* Reset fetched gas limit when fromChainId changes

* Clean

* Fix old import

* Fix max button placement

* Add loading state for useGasEstimator

* Remove available balance states for gas est

* Remove unused props

* Clean gas token detection in PortfolioTokenAsset

* Simplify onMaxBalance()

* Clean constants in InputContainer

* Clean token detail destructuring

* Include gas estimate when updating input from Portfolio token selection

* Fire error toaster if gas fees exceed balance

* Render error toaster when firing onMaxBalance callback instead of a side effect

* Clean useGasEstimator

* Ensure available balance does not show if wallet not connected, set default value if balances not loaded

* Replicate onMax behavior in Portfolio

* Use fetched gas

* Improve error handling in gas estimator

* ...

* Remove tooltip on AvailableBalance

* Remove balance prefill from Portfolio Token selection

* Update available balance in input based on max bridgeable gas toke

* Destructure estimateGasLimit callback from useGasEstimator to retrigger fetching gas estimate

* Refetch gas ata in estimateGasLimit callback

* Display total vs bridgeable balance on hover in Portfolio gas token when gas data available

* Update balance shown on hover

* Clean

* Simplify useFetchGasDataOnInterval

* Prevent unnecessary fetches, fix chain update old gas issue

* Fetch estimated bridgeable max gas amount onClick token max input, fill input once amount fetched

* Clean

* onMaxBalance will use default balanceif fetched bridgeable balance estimate returns null

* Show dust gas amounts on hover in Portfolio

* Clean

* Available balance including gas estimates moved to within Input to synchronize data

* Move gasLimit to global store to share data between Bridge components

* Display max bridgeable balance on hover in Portfolio, add onMaxBalance onClick Portfolio asset

* Portfolio and Input available balance onClick behave the same

* Fetch gas prices to provide most accurate gas cost

* Remove hover on AvailableBalance

* Fix Token Selector width

* Remove onClick Portfolio Token Balance, allow Token selection from Portfolio only without Balance input update

* Cursor default on Portfolio Token Balance

* Show available/max buttons when bridge valid selections

* Swap input to have available balance

* Clean

* Basic MaxButton onClick and hidden when loading gas data

* Show MaxButton when input is not full balance or bridgeable balance

* Implement Max button and placement in Bridge/Swap

* Hide MaxButton until connected

* Hide MaxButton conditions

* Show Max when all input selections are made

* Remove click states for AvailableBalance on Bridge/Swap

* Style Input / Max

* Max mobile size

* Fe/format amount (#2598)

* formatAmount util function, use rounded shortened values in Bridge/Swap Input

* Update Bridge/Swap page with parsed / formatted balances

* Clean imports

* Clean imports

* Swap Max spacing

* Improve html element composition

* Prevent layout shift in Swap UI

* Publish

 - @synapsecns/synapse-interface@0.23.0

* add "and" (#2608)

* fix(contracts-communication): default settings for Guard service (#2605)

* test: should ignore optimistic period w/o guard

* test: app should have empty config be default

* test: should allow setting zero optimistic period

* fix: ignore optimistic period without a guard

* fix: use GUARD_DISABLED flag by default

* fix: don't revert on zero optimistic period

* test: different optimistic periods for integration tests

* fix: use default guard for PingPongApp

* refactor: fix linter warnings

* Publish

 - contracts-communication@1.6.2
 - @synapsecns/synapse-interface@0.23.1

* Fix: put blocking call to Start() in new goroutine (#2614)

* feat(contracts-communication): default values for modules/required respones (#2612)

* feat: scaffold defaultModule in Client

* test: expected behavior for setting default module

* feat: setting default Module in Client

* refactor: Client views test

* test: appConfig with zero modules/responses

* feat: module config defaults

* cleanup: remove `ZeroRequiredResponses` error

* refactor: prep for 0 and 1 module tests

* test: ClientV1 + app with 1 module

* test: ClientV1 + app with 0 modules

* Publish

 - contracts-communication@1.7.0

* RFQ: rebalance edge cases & refactoring (#2613)

* Fix: filter rebalance origin / dest on rebalance method

* Cleanup: move getRebalance() into rebalance.go

* Cleanup: add helpers to getRebalance()

* Cleanup: comments

* Feat: remove Rebalance() call upon deposit claimed

* Feat: getRebalance() takes in dest chain id

* Cleanup: comments

* Feat: extra check that we don't exceed origin maintenance

* Feat: add new test case for mismatched methods but existing rebalance

* Feat: break down TestGetRebalance into sub tests

* Cleanup: lint

* [goreleaser]

* [goreleaser]

* refactor: move opinionated stuff into SynapseModule (#2617)

* Publish

 - contracts-communication@1.7.1

* Document Modules (#2611)



Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* cleanup (#2618)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* fix tests (#2620)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* RFQ API: replace `otelresty` with `otelhhtp` package (#2606)

* Feat: replace otelresty usage with otelhttp pkg

* [goreleaser]

* make coverage aggregator public (#2621)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Publish

 - @synapsecns/coverage-aggregator@1.0.5

* publish aggregator fix (#2622)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Publish

 - @synapsecns/coverage-aggregator@1.0.6

* fix(solidity-devops): update forge-std to 1.8.2 (#2619)

* build: update `forge-std` to 1.8.2

* chore: yarn

* Publish

 - contracts-communication@1.7.2
 - FastBridge@0.2.5
 - @synapsecns/solidity-devops@0.3.5

* feat(docs): auto deploy vercel to prod (only vercel) (#2627)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* fix(ci): fixes bug in #2627, deploys go to prod (#2628)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* docs(contributing) add a guide on adding js packages (#2629)

* docs(contributing) add a guide on adding js packages

* Update CONTRIBUTING.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* revert coderabbit fix (#2630)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* prod release fix (#2631)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Publish

 - @synapsecns/bridge-docs@0.1.0

* add grafana dashboard and fix broken link (#2634)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* add scroll (#2635)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Submitter: bump MaxResultsPerChain (#2633)

* Feat: bump MaxResultsPerChain

* [goreleaser]

* fast bridge regen (#2636)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* omnirpc doc fixes (#2637)

* swagger

* embed swagger ui

* generic lint fixer

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* fix typo (#2638)

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>

* Update bl

* Add SPECTRAL token support (#2640)

* Publish

 - @synapsecns/synapse-interface@0.23.2
 - @synapsecns/widget@0.2.1

* feat(synapse-interface): Adds Scroll via RFQ (#2526)

* Adds Scroll via RFQ

* Adds NewTag

* Adds RFQ logic into the generateMaps script

* Adds announcement banner

* Linting

* Adjusts order

* API call for quotes

* Updates bridgeMap for live Scroll quotes

* For reusing NewTag

* Adjust dates

* Publish

 - @synapsecns/synapse-interface@0.24.0

* feat(widget): maintenance (#2616)

* Fetch pause data and store JSON object in client browser

* Refetch only if last fetch was more than 24 hours ago

* Read chain + module pause from local storage

* Maintenance components rendering based off of fetched pause data

* Pause Bridge button based on Maintenance status

* Filter quotes based on paused modules

* Use user defined styling or defaults

* Style Progress Bar

* Refactor getSynapsePauseData

* Clean

* Fix bridge quote filter

* Adjust text size for maintenance

* Add comments + clean

* Update comment

* Refresh data every hour

* Clean

* Add key to warning messages

* Fix render issues, start move event countdown component directly to Widget to resolve hooks issue

* Resolve hooks render issue with localized component

* Progress bar renders when not isabled

* Clean and simplify Maintenance components

* getMaintenanceData

* Organize back into useMaintenance hook

* Clean / organize

* Use prod urls

* Organizational updates

* Fetch pause data every render, set fetching status flag

* Rm timestamp key

---------

Co-authored-by: abtestingalpha <abtestingalpha@gmail.com>

* Publish

 - @synapsecns/widget@0.3.0

* RFQ API: add GET /ack endpoint (#2643)

* WIP: add relay ack cache and GetRelayAck endpoint

* Feat: register AckRoute

* Feat: add ackMux

* Feat: add GetRelayAck test

* Feat: add GetRelayAck to UnauthenticatedClient

* Feat: relayer fetches ack before updating to CommittedPending

* [goreleaser]

* Feat: move GET /ack to PUT /ack

* WIP: generalize AuthMiddleware()

* Fix: working refactor for auth

* Feat: add PutAckRequest and parse in auth middleware

* Feat: impl PUT /ack request with json req body

* Feat: bump default timeout from 5 to 10

* Feat: add swagger comments

* Cleanup: pass API client into quoter

* Feat: return RelayerAddress in PutRelayAckResponse

* Cleanup: add clarifying comment

* [goreleaser]

* Cleanup: lint

* [goreleaser]

* Cleanup: add tracing

* [goreleaser]

* Config: bump relay ack timeout to 30 seconds

* [goreleaser]

* Feat: lower submitter retry interval (#2645)

* update bl

* Adjusts banner date (#2647)

* Publish

 - @synapsecns/synapse-interface@0.24.1

* Add SPEC token pricing to the manual cache (#2646)

* adding spectral coingecko ids for pricing

* adding spec token to cache

* Update bl

* fix(screener): fix screener http 502 (#2650)


Co-authored-by: trajan0x <83933037+trajan0x@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* update bl

* update bl

---------

Co-authored-by: aureliusbtc <82057759+aureliusbtc@users.noreply.github.com>
Co-authored-by: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com>
Co-authored-by: dwasse <wassermandaniel8@gmail.com>
Co-authored-by: ChiTimesChi <ChiTimesChi@users.noreply.github.com>
Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
Co-authored-by: vro <168573323+golangisfun123@users.noreply.github.com>
Co-authored-by: shampoobera <shampoo@berachain.com>
Co-authored-by: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com>
Co-authored-by: bigboydiamonds <bigboydiamonds@users.noreply.github.com>
Co-authored-by: trajan0x <83933037+trajan0x@users.noreply.github.com>
Co-authored-by: Moses <103143573+Defi-Moses@users.noreply.github.com>
Co-authored-by: Simon <ak.simonm@gmail.com>
Co-authored-by: aureliusbtc <aureliusbtc@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: abtestingalpha <abtestingalpha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants