Skip to content

Commit

Permalink
Solana Watcher: filter transactions to those including a log from the…
Browse files Browse the repository at this point in the history
… wormhole core contractact prior to resolving account table references
  • Loading branch information
barnjamin authored and evan-gray committed Sep 18, 2023
1 parent 7a75b46 commit a3df706
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions node/pkg/watchers/solana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"sync"
"time"

Expand All @@ -20,7 +21,6 @@ import (
lookup "github.com/gagliardetto/solana-go/programs/address-lookup-table"
"github.com/gagliardetto/solana-go/rpc"
"github.com/gagliardetto/solana-go/rpc/jsonrpc"

"github.com/google/uuid"
"github.com/mr-tron/base58"
"github.com/near/borsh-go"
Expand Down Expand Up @@ -493,6 +493,20 @@ OUTER:
)
continue
}

// If the logs don't contain the contract address, skip the transaction.
// ex: "Program 3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5 invoke [2]",
var (
possiblyWormhole bool
whLogPrefix = fmt.Sprintf("Program %s", s.rawContract)
)
for i := 0; i < len(txRpc.Meta.LogMessages) && !possiblyWormhole; i++ {
possiblyWormhole = strings.HasPrefix(txRpc.Meta.LogMessages[i], whLogPrefix)
}
if !possiblyWormhole {
continue
}

tx, err := txRpc.GetTransaction()
if err != nil {
logger.Error("failed to unmarshal transaction",
Expand Down Expand Up @@ -524,14 +538,6 @@ OUTER:
continue
}

if txRpc.Meta.Err != nil {
logger.Debug("skipping failed Wormhole transaction",
zap.Stringer("signature", signature),
zap.Uint64("slot", slot),
zap.String("commitment", string(s.commitment)))
continue
}

logger.Debug("found Wormhole transaction",
zap.Stringer("signature", signature),
zap.Uint64("slot", slot),
Expand Down

0 comments on commit a3df706

Please sign in to comment.