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

FE Release 2024-08-27 #3071

Closed
wants to merge 91 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
bb647ce
Publish
aureliusbtc Aug 15, 2024
a123a5f
RFQ API Auth Cache (#3007)
aureliusbtc Aug 15, 2024
fca30be
fix ci matrix
trajan0x Aug 15, 2024
6f99fad
Merge branch 'master' of https://github.com/synapsecns/sanguine
trajan0x Aug 15, 2024
914d2e2
feat(listener): add `ListenerName` db field (#3020)
dwasse Aug 15, 2024
445b4fb
feat(rfq-relayer): add mutex on committable balance consumption (#2994)
dwasse Aug 16, 2024
317c07d
feat(promexporter): relayer balances (#3016)
golangisfun123 Aug 16, 2024
8da405f
fix(synapse-interface): hide Blast WETH (#3033)
ChiTimesChi Aug 16, 2024
b8b895f
Publish
ChiTimesChi Aug 16, 2024
e32854b
feat(promexporter): Grafana usdc balances (#3034)
golangisfun123 Aug 16, 2024
1d61605
update pause canto timing
aureliusbtc Aug 16, 2024
9dfde6c
fix(listener): latest block query (#3030)
dwasse Aug 19, 2024
aa898d4
Update blacklist.json (#3037)
Defi-Moses Aug 19, 2024
7976f7a
Publish
aureliusbtc Aug 19, 2024
c26fce3
revert(relayer): potential deadlock (#3036)
dwasse Aug 19, 2024
898b5b9
feat(relapi): get QuoteRequest by txhash (#3032)
golangisfun123 Aug 20, 2024
44f1399
Updating rfq contracts in docs (#3041)
Defi-Moses Aug 20, 2024
914c25a
Publish
trajan0x Aug 20, 2024
b1ddc86
re-pause canto
aureliusbtc Aug 20, 2024
4fd9ef1
feat(rfq-relayer): highly concurrent e2e test (#3042)
dwasse Aug 20, 2024
f789485
feat(rfq-relayer): add balances mutex (#3039)
trajan0x Aug 21, 2024
d73373b
feat(synapse-interface): METIS token (#3044)
bigboydiamonds Aug 21, 2024
d952e4c
Publish
bigboydiamonds Aug 21, 2024
1d06a74
first pass at updating RFQ relayer documentation (#3000)
Defi-Moses Aug 22, 2024
961356a
Publish
Defi-Moses Aug 22, 2024
c0b30cc
fix(promexporter) add new external relayer (#3040)
golangisfun123 Aug 22, 2024
08b9e9e
Add METIS token support (#3046)
bigboydiamonds Aug 22, 2024
ead107f
Publish
bigboydiamonds Aug 22, 2024
3499bd2
fix relayer dashboard
trajan0x Aug 22, 2024
469f0cd
Merge branch 'master' of https://github.com/synapsecns/sanguine
trajan0x Aug 22, 2024
c1e56ba
fix relayer dashboard
trajan0x Aug 22, 2024
b65003c
Feat: add listener_name as attribute (#3050)
dwasse Aug 23, 2024
e50d90e
fix relayer dashboard
trajan0x Aug 23, 2024
214614b
Exports metis (#3052)
abtestingalpha Aug 23, 2024
1aee96b
Publish
abtestingalpha Aug 23, 2024
6304351
hotfix for blockExplorerUrls (#3054)
bigboydiamonds Aug 23, 2024
eae2795
Publish
bigboydiamonds Aug 23, 2024
8b44c1c
chore(widget): update block explorers (#3055)
bigboydiamonds Aug 24, 2024
ee4a700
Publish
trajan0x Aug 24, 2024
d0c386c
slack token update
trajan0x Aug 25, 2024
8851629
add manifest to readme
trajan0x Aug 25, 2024
9fe0f03
quick doc update
trajan0x Aug 25, 2024
96ec352
update new-from-rev
trajan0x Aug 25, 2024
99bf33b
Extend canto pause (#3058)
Defi-Moses Aug 25, 2024
813317e
Publish
aureliusbtc Aug 25, 2024
013d4b9
basic listener docs (#3060)
trajan0x Aug 26, 2024
649b3f5
feat(synapse-interface): bridge quote state validations (#3019)
abtestingalpha Aug 26, 2024
85b5f53
feat(sdk): uuid `BridgeQuote.id` (#2896)
bigboydiamonds Aug 26, 2024
ef021dc
Script to check token exports match bridgeable.ts (#3053)
abtestingalpha Aug 26, 2024
7793703
Publish
abtestingalpha Aug 26, 2024
224606f
chore(deps): update graphqlcodegenerator monorepo (#2747)
renovate[bot] Aug 26, 2024
c366782
Publish
abtestingalpha Aug 26, 2024
0e64a98
standardize middleware (#3066)
trajan0x Aug 27, 2024
88a6b1c
fix(deps): update github.com/charmbracelet/huh/spinner digest to 5fd7…
renovate[bot] Aug 27, 2024
e61e1bf
[explorer ui] units for time elapsed (#3064)
nautsimon Aug 27, 2024
fca6b36
Extend canto pause (#3069)
bigboydiamonds Aug 27, 2024
aa5796a
Publish
abtestingalpha Aug 27, 2024
6d971c2
Display days remaining when more than 24h left (#3070)
bigboydiamonds Aug 27, 2024
af233c2
Publish
bigboydiamonds Aug 27, 2024
8226c60
feat(widget): visual update (#2992)
bigboydiamonds Aug 27, 2024
cf2f3e9
Publish
abtestingalpha Aug 27, 2024
bb13b4b
fix(rfq-relayer): check request status before forwarding (#3073)
dwasse Aug 27, 2024
eccbfd1
refactor(relapi): deprecate `GetQuoteRequestStatusResponse` model (#3…
golangisfun123 Aug 28, 2024
b568cbe
feat(synapse-interface): bridge quote uuid (#2900)
bigboydiamonds Aug 29, 2024
7d50e75
Publish
abtestingalpha Aug 29, 2024
e38d1e4
REST API Migration (#3049)
Defi-Moses Aug 29, 2024
89871e9
Publish
aureliusbtc Aug 29, 2024
a6e1781
feat(opbot): add screener to opbot (#3076)
golangisfun123 Aug 30, 2024
debe263
add all modules output [goreleaser] (#3083)
trajan0x Aug 30, 2024
252fb54
feat(rfq-relayer): wait for finality before proving (#3062)
dwasse Aug 30, 2024
c6953ed
fix(opbot): fix refund forever (#3082)
golangisfun123 Aug 30, 2024
7e0b8f1
small bug fix [goreleaser] (#3086)
golangisfun123 Sep 1, 2024
4a17c15
feat(opbot): print explorer refund tx link (#3087)
golangisfun123 Sep 2, 2024
db72b4b
update bl
aureliusbtc Sep 3, 2024
48d8082
chore(synapse-interface): tailwind intellisense setting (#3085)
bigboydiamonds Sep 3, 2024
784fb3e
Publish
abtestingalpha Sep 3, 2024
9ceacfe
fix(rfq-relayer): e2e test flakes (#3075)
dwasse Sep 3, 2024
2a74772
recovery id validate & normalize
parodime Sep 4, 2024
07c16b0
Reduces FastBridge deadline to two hours (#3090)
abtestingalpha Sep 4, 2024
62ca720
Publish
abtestingalpha Sep 4, 2024
a364bbd
update first time ontributor docs
trajan0x Sep 4, 2024
dfb97a8
refactor(rfq-relayer): rebalancing with multiple tokens (#3003)
dwasse Sep 4, 2024
3216321
+TestEIP191_SuccessfulSignature_vCodeNormalize
parodime Sep 4, 2024
29d75bb
Fixes logo (#3100)
abtestingalpha Sep 4, 2024
17e7eba
Publish
abtestingalpha Sep 4, 2024
131fe33
tweak comments, logging
parodime Sep 4, 2024
06c7ba1
Merge pull request #3098 from synapsecns/feat/eip191recovId
parodime Sep 4, 2024
ae734cc
add squash and merge guide
trajan0x Sep 5, 2024
715269a
ignore roookout on go 1.23 (#3093)
trajan0x Sep 5, 2024
ebc1577
Update rebalancing docs (#3103)
dwasse Sep 5, 2024
69ec859
Publish
dwasse Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(rfq-relayer): add mutex on committable balance consumption (#2994)
* Feat: add balanceMtx

* [goreleaser]

* Feat: check lock in handleNotEnoughInventory

* [goreleaser]

* Feat: add commitPendingBalance

* [goreleaser]
dwasse authored Aug 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 445b4fb12af705746ec4ab61ea2613082a8e291b
53 changes: 43 additions & 10 deletions services/rfq/relayer/service/handlers.go
Original file line number Diff line number Diff line change
@@ -162,6 +162,36 @@ func (q *QuoteRequestHandler) handleSeen(ctx context.Context, span trace.Span, r
return nil
}

// check balance and mark it as CommitPending
err = q.commitPendingBalance(ctx, span, request)
if err != nil {
return fmt.Errorf("could not commit pending balance: %w", err)
}

// immediately forward the request to handleCommitPending
span.AddEvent("forwarding to handleCommitPending")
fwdErr := q.Forward(ctx, request)
if fwdErr != nil {
logger.Errorf("could not forward to handle commit pending: %w", fwdErr)
span.AddEvent("could not forward to handle commit pending")
}

return nil
}

// commitPendingBalance locks the balance and marks the request as CommitPending.
func (q *QuoteRequestHandler) commitPendingBalance(ctx context.Context, span trace.Span, request reldb.QuoteRequest) (err error) {
// lock the consumed balance
key := getBalanceMtxKey(q.Dest.ChainID, request.Transaction.DestToken)
span.SetAttributes(attribute.String("balance_lock_key", key))
unlocker, ok := q.balanceMtx.TryLock(key)
if !ok {
// balance is locked due to concurrent request, try again later
span.SetAttributes(attribute.Bool("locked", true))
return nil
}
defer unlocker.Unlock()

// get destination committable balance
committableBalance, err := q.Inventory.GetCommittableBalance(ctx, int(q.Dest.ChainID), request.Transaction.DestToken)
if errors.Is(err, inventory.ErrUnsupportedChain) {
@@ -211,14 +241,6 @@ func (q *QuoteRequestHandler) handleSeen(ctx context.Context, span trace.Span, r
return fmt.Errorf("could not update request status: %w", err)
}

// immediately forward the request to handleCommitPending
span.AddEvent("forwarding to handleCommitPending")
fwdErr := q.Forward(ctx, request)
if fwdErr != nil {
logger.Errorf("could not forward to handle commit pending: %w", fwdErr)
span.AddEvent("could not forward to handle commit pending")
}

return nil
}

@@ -487,12 +509,23 @@ func (q *QuoteRequestHandler) handleProofPosted(ctx context.Context, span trace.
// Error Handlers Only from this point below.
//
// handleNotEnoughInventory handles the not enough inventory status.
func (q *QuoteRequestHandler) handleNotEnoughInventory(ctx context.Context, _ trace.Span, request reldb.QuoteRequest) (err error) {
func (q *QuoteRequestHandler) handleNotEnoughInventory(ctx context.Context, span trace.Span, request reldb.QuoteRequest) (err error) {
// acquire balance lock
key := getBalanceMtxKey(q.Dest.ChainID, request.Transaction.DestToken)
span.SetAttributes(attribute.String("balance_lock_key", key))
unlocker, ok := q.balanceMtx.TryLock(key)
if !ok {
// balance is locked due to concurrent request, try again later
span.SetAttributes(attribute.Bool("locked", true))
return nil
}
defer unlocker.Unlock()

// commit destination balance
committableBalance, err := q.Inventory.GetCommittableBalance(ctx, int(q.Dest.ChainID), request.Transaction.DestToken)
if err != nil {
return fmt.Errorf("could not get committable balance: %w", err)
}
// if committableBalance > destAmount
if committableBalance.Cmp(request.Transaction.DestAmount) > 0 {
err = q.db.UpdateQuoteRequestStatus(ctx, request.TransactionID, reldb.CommittedPending, &request.Status)
if err != nil {
7 changes: 5 additions & 2 deletions services/rfq/relayer/service/relayer.go
Original file line number Diff line number Diff line change
@@ -61,8 +61,10 @@ type Relayer struct {
decimalsCache *xsync.MapOf[string, *uint8]
// semaphore is used to limit the number of concurrent requests
semaphore *semaphore.Weighted
// handlerMtx is used to synchronize handling of relay requests
handlerMtx mapmutex.StringMapMutex
// handlerMtx is used to synchronize handling of relay requests, keyed on transaction ID
handlerMtx mapmutex.StringMapMutex
// balanceMtx is used to synchronize balance requests, keyed on a chainID and tokenAddress pair
balanceMtx mapmutex.StringMapMutex
otelRecorder iOtelRecorder
}

@@ -165,6 +167,7 @@ func NewRelayer(ctx context.Context, metricHandler metrics.Handler, cfg relconfi
apiClient: apiClient,
semaphore: semaphore.NewWeighted(maxConcurrentRequests),
handlerMtx: mapmutex.NewStringMapMutex(),
balanceMtx: mapmutex.NewStringMapMutex(),
otelRecorder: otelRecorder,
}
return &rel, nil
7 changes: 7 additions & 0 deletions services/rfq/relayer/service/statushandler.go
Original file line number Diff line number Diff line change
@@ -52,6 +52,12 @@ type QuoteRequestHandler struct {
mutexMiddlewareFunc func(func(ctx context.Context, span trace.Span, req reldb.QuoteRequest) error) func(ctx context.Context, span trace.Span, req reldb.QuoteRequest) error
// handlerMtx is the mutex for relaying.
handlerMtx mapmutex.StringMapMutex
// balanceMtx is the mutex for balances.
balanceMtx mapmutex.StringMapMutex
}

func getBalanceMtxKey(chainID uint32, token common.Address) string {
return fmt.Sprintf("%d-%s", chainID, token.Hex())
Comment on lines +62 to +63
Copy link
Contributor

Choose a reason for hiding this comment

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

New function getBalanceMtxKey implementation

The implementation of getBalanceMtxKey appears correct and is a straightforward string formatting based on chainID and token. Consider adding unit tests to cover various edge cases and ensure the function handles all expected inputs correctly.

Would you like me to help by writing some unit tests for this function?

}

// Handler is the handler for a quote request.
@@ -81,6 +87,7 @@ func (r *Relayer) requestToHandler(ctx context.Context, req reldb.QuoteRequest)
apiClient: r.apiClient,
mutexMiddlewareFunc: r.mutexMiddleware,
handlerMtx: r.handlerMtx,
balanceMtx: r.balanceMtx,
}

// wrap in deadline middleware since the relay has not yet happened