Skip to content

feat(relay): dual-write transactions to sos.audius.co#736

Merged
rickyrombo merged 2 commits intomainfrom
relay-sos-dual-write
Mar 25, 2026
Merged

feat(relay): dual-write transactions to sos.audius.co#736
rickyrombo merged 2 commits intomainfrom
relay-sos-dual-write

Conversation

@rickyrombo
Copy link
Contributor

@rickyrombo rickyrombo commented Mar 25, 2026

Fires the mainnet as best effort, always write to sos

Hardcoded as a temporary fix.

🤖 Generated with Claude Code

rickyrombo and others added 2 commits March 24, 2026 18:57
Fires a best-effort background write to https://sos.audius.co on every
relay call, regardless of whether the main mainnet write succeeds.
Hardcoded as a temporary fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- mainnet writes fire in a background goroutine (uses context.Background
  since request context cancels on response)
- sos write is synchronous and returns the tx hash for the receipt
- both writes share a single SendTransactionRequest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rickyrombo rickyrombo merged commit 766444b into main Mar 25, 2026
6 checks passed
@rickyrombo rickyrombo deleted the relay-sos-dual-write branch March 25, 2026 02:13
rickyrombo added a commit that referenced this pull request Mar 25, 2026
Copy link
Contributor

Copilot AI left a 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 PR updates the relay transaction path to attempt a dual-write to a second OpenAudio endpoint (https://sos.audius.co) alongside the existing mainnet submission.

Changes:

  • Adds a hardcoded SOS endpoint and constructs a separate OpenAudio SDK client for it.
  • Refactors handleRelay to send mainnet transactions in a goroutine and send SOS synchronously.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +293 to 297
res, err := sosClient.Core.SendTransaction(ctx, connect.NewRequest(req))
if err != nil {
sosLogger.Warn("sos dual-write failed", zap.Error(err))
return nil, err
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This makes the SOS send the synchronous/authoritative call: failures from sosClient.Core.SendTransaction are returned to the API caller, and the receipt is built from the SOS transaction hash. The PR description says SOS should be best-effort/background in addition to the existing mainnet write; to keep existing semantics, the mainnet send should remain the one that determines the response, and the SOS dual-write should run asynchronously and not fail the request (log errors only).

Copilot uses AI. Check for mistakes.
Comment on lines +275 to +279
go func() {
allClients := app.openAudioPool.GetAll()
for i, clientInfo := range allClients {
endpointLogger := logger.With(zap.String("openaudio_endpoint", clientInfo.Endpoint), zap.Int("attempt", i+1))
res, err := clientInfo.Client.Core.SendTransaction(context.Background(), connect.NewRequest(req))
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The mainnet send is launched as a goroutine using context.Background() with no timeout. Under load, this can create unbounded concurrent goroutines and potentially hang indefinitely if an endpoint stalls (since it won't be canceled when the request ctx is canceled). Consider using a bounded context with timeout (e.g., context.WithTimeout) and/or a background worker/queue to control concurrency.

Copilot uses AI. Check for mistakes.
rickyrombo added a commit that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants