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

bridge/pkg/solana: retry VAA submission on transient errors #48

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions bridge/pkg/solana/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

eth_common "github.com/ethereum/go-ethereum/common"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

agentv1 "github.com/certusone/wormhole/bridge/pkg/proto/agent/v1"

Expand Down Expand Up @@ -110,6 +112,31 @@ func (e *SolanaBridgeWatcher) Run(ctx context.Context) error {
cancel()
if err != nil {
logger.Error("failed to submit VAA", zap.Error(err), zap.String("digest", h))

st, ok := status.FromError(err)
if !ok {
panic("err not a status")
}

// For transient errors, we can put the VAA back into the queue such that it can
// be retried after the runnable has been rescheduled.
switch st.Code() {
case
// Our context was cancelled, likely because the watcher stream died.
codes.Canceled,
// The agent encountered a transient error, likely node unavailability.
codes.Unavailable,
codes.Aborted:

logger.Error("requeuing VAA", zap.Error(err), zap.String("digest", h))

// Tombstone goroutine
go func(v *vaa.VAA) {
time.Sleep(10 * time.Second)
e.vaaChan <- v
}(v)
}

break
}

Expand Down