Node: Upgrade to solana-go v1.7.1 (#1799)

Change-Id: Ia83b193d524e4c8571bfb8f3dd3075da8b5581cf
This commit is contained in:
bruce-riley 2022-10-27 11:14:42 -05:00 committed by GitHub
parent 40644ee267
commit ea50bee9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 45 deletions

View File

@ -11,7 +11,7 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.1
github.com/diamondburned/arikawa/v3 v3.0.0-rc.2
github.com/ethereum/go-ethereum v1.10.21
github.com/gagliardetto/solana-go v1.6.0
github.com/gagliardetto/solana-go v1.7.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
@ -36,7 +36,7 @@ require (
github.com/tendermint/tendermint v0.34.14
github.com/tidwall/gjson v1.14.3
go.uber.org/zap v1.23.0
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a
golang.org/x/crypto v0.1.0
golang.org/x/sys v0.1.0
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
google.golang.org/api v0.99.0
@ -91,7 +91,7 @@ require (
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gagliardetto/binary v0.7.2 // indirect
github.com/gagliardetto/binary v0.7.3 // indirect
github.com/gagliardetto/treeout v0.1.4 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.0 // indirect
@ -217,10 +217,10 @@ require (
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/term v0.0.0-20221017184919-83659145692c // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.1.12 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect

View File

@ -396,11 +396,18 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/gagliardetto/binary v0.7.1/go.mod h1:aOfYkc20U0deHaHn/LVZXiqlkDbFAX0FpTlDhsXa0S0=
github.com/gagliardetto/binary v0.7.2-0.20220918220700-6a22eaf7d87e/go.mod h1:aOfYkc20U0deHaHn/LVZXiqlkDbFAX0FpTlDhsXa0S0=
github.com/gagliardetto/binary v0.7.2 h1:LJmEon+jY8e6uT3/ezCZHfA6p7hRgvQNjbdPFamNHoU=
github.com/gagliardetto/binary v0.7.2/go.mod h1:mUuay5LL8wFVnIlecHakSZMvcdqfs+CsotR5n77kyjM=
github.com/gagliardetto/binary v0.7.3 h1:QlBNaHwqjHuH23DBLR9DLrsKoCAA5kC63LgqZxyl3fg=
github.com/gagliardetto/binary v0.7.3/go.mod h1:mUuay5LL8wFVnIlecHakSZMvcdqfs+CsotR5n77kyjM=
github.com/gagliardetto/gofuzz v1.2.2/go.mod h1:bkH/3hYLZrMLbfYWA0pWzXmi5TTRZnu4pMGZBkqMKvY=
github.com/gagliardetto/solana-go v1.6.0 h1:NDpsNr46IgPaL0BTSwWR1bftCiWrBEnycWNBBlJkWkA=
github.com/gagliardetto/solana-go v1.6.0/go.mod h1:053e9WcQ/SN1po8VYDC1890jU3bDBEsH4skoZq7U5Is=
github.com/gagliardetto/solana-go v1.6.1-0.20221022165958-3da9ae47f108 h1:iFlIN49QrXNbmbRBxIV2amzYSg9HISGobGwCGsCLV5w=
github.com/gagliardetto/solana-go v1.6.1-0.20221022165958-3da9ae47f108/go.mod h1:a8cIq86a+lf5Q3iyU7GyUL+orUN7xKG8j71aIYy96cs=
github.com/gagliardetto/solana-go v1.7.1 h1:1zptQe8jroTVpWKgvTcRTPMJ8kdiE2P6MmhnOO+r6jA=
github.com/gagliardetto/solana-go v1.7.1/go.mod h1:AXNlsBGSxT6OhwfH2ofFkDUwA2yGry0e15OH+h2t8Jk=
github.com/gagliardetto/treeout v0.1.4 h1:ozeYerrLCmCubo1TcIjFiOWTTGteOOHND1twdFpgwaw=
github.com/gagliardetto/treeout v0.1.4/go.mod h1:loUefvXTrlRG5rYmJmExNryyBRh8f89VZhmMOyCyqok=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
@ -1427,6 +1434,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a h1:NmSIgad6KjE6VvHciPZuNRTKxGhlPfD6OA87W/PLkqg=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -1544,6 +1553,8 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193 h1:3Moaxt4TfzNcQH6DWvlYKraN1ozhBXQHcgvXjRGeim0=
golang.org/x/net v0.0.0-20221017152216-f25eb7ecb193/go.mod h1:RpDiru2p0u2F0lLpEoqnP2+7xs0ifAuOcJ442g6GU2s=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@ -1722,6 +1733,8 @@ golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20221017184919-83659145692c h1:dveknrit5futqEmXAvd2I1BbZIDhxRijsyWHM86NlcA=
golang.org/x/term v0.0.0-20221017184919-83659145692c/go.mod h1:VTIZ7TEbF0BS9Sv9lPTvGbtW8i4z6GGbJBCM37uMCzY=
golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@ -14,7 +14,6 @@ import (
"github.com/certusone/wormhole/node/pkg/db"
gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
nodev1 "github.com/certusone/wormhole/node/pkg/proto/node/v1"
solwatcher "github.com/certusone/wormhole/node/pkg/watchers/solana"
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/wormhole-foundation/wormhole/sdk"
@ -290,13 +289,7 @@ func process(txRpc *rpc.TransactionWithMeta) (*solana.PublicKey, error) {
txs := make([]solana.CompiledInstruction, 0, len(tx.Message.Instructions))
txs = append(txs, tx.Message.Instructions...)
for _, inner := range txRpc.Meta.InnerInstructions {
for _, instRpc := range inner.Instructions {
inst, err := solwatcher.ConvertRpcInstruction(instRpc)
if err != nil {
log.Fatalf("Failed to unmarshal inner instruction: %v", err)
}
txs = append(txs, inst)
}
txs = append(txs, inner.Instructions...)
}
for _, inst := range txs {

View File

@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"math"
"time"
"github.com/certusone/wormhole/node/pkg/common"
@ -252,7 +251,7 @@ func (s *SolanaWatcher) fetchBlock(ctx context.Context, logger *zap.Logger, slot
maxSupportedTransactionVersion := uint64(0)
out, err := s.rpcClient.GetBlockWithOpts(rCtx, slot, &rpc.GetBlockOpts{
Encoding: "base64", // solana-go doesn't support json encoding.
Encoding: solana.EncodingBase64, // solana-go doesn't support json encoding.
TransactionDetails: "full",
Rewards: &rewards,
Commitment: s.commitment,
@ -306,10 +305,19 @@ func (s *SolanaWatcher) fetchBlock(ctx context.Context, logger *zap.Logger, slot
zap.String("commitment", string(s.commitment)))
OUTER:
for _, txRpc := range out.Transactions {
for txNum, txRpc := range out.Transactions {
if txRpc.Meta.Err != nil {
logger.Info("Transaction failed, skipping it", zap.Int("txNum", txNum))
continue
}
tx, err := txRpc.GetTransaction()
if err != nil {
logger.Error("failed to unmarshal transaction", zap.Error(err))
logger.Error("failed to unmarshal transaction",
zap.Uint64("slot", slot),
zap.Int("txNum", txNum),
zap.Int("dataLen", len(txRpc.Transaction.GetBinary())),
zap.Error(err),
)
continue
}
signature := tx.Signatures[0]
@ -357,9 +365,11 @@ OUTER:
// Call GetConfirmedTransaction to get at innerTransactions
rCtx, cancel := context.WithTimeout(ctx, rpcTimeout)
start := time.Now()
maxSupportedTransactionVersion := uint64(0)
tr, err := s.rpcClient.GetTransaction(rCtx, signature, &rpc.GetTransactionOpts{
Encoding: "base64", // solana-go doesn't support json encoding.
Commitment: s.commitment,
Encoding: solana.EncodingBase64, // solana-go doesn't support json encoding.
Commitment: s.commitment,
MaxSupportedTransactionVersion: &maxSupportedTransactionVersion,
})
cancel()
queryLatency.WithLabelValues(s.networkName, "get_confirmed_transaction", string(s.commitment)).Observe(time.Since(start).Seconds())
@ -381,19 +391,7 @@ OUTER:
zap.Duration("took", time.Since(start)))
for _, inner := range tr.Meta.InnerInstructions {
for i, instRpc := range inner.Instructions {
inst, err := ConvertRpcInstruction(instRpc)
if err != nil {
logger.Error("failed to unmarshal inner instruction",
zap.Error(err),
zap.Int("idx", i),
zap.Stringer("signature", signature),
zap.Uint64("slot", slot),
)
continue
}
for i, inst := range inner.Instructions {
_, err = s.processInstruction(ctx, logger, slot, inst, programIndex, tx, signature, i)
if err != nil {
logger.Error("malformed Wormhole instruction",
@ -620,16 +618,3 @@ func ParseMessagePublicationAccount(data []byte) (*MessagePublicationAccount, er
return prop, nil
}
// ConvertRpcInstruction converts an rpc.CompiledInstruction into a solana.CompiledInstruction.
func ConvertRpcInstruction(instRpc rpc.CompiledInstruction) (solana.CompiledInstruction, error) {
var accounts []uint16
for _, a := range instRpc.Accounts {
if a > math.MaxUint16 || a < 0 {
return solana.CompiledInstruction{}, fmt.Errorf("account %d will not fit in a uint16", a)
}
accounts = append(accounts, uint16(a))
}
return solana.CompiledInstruction{ProgramIDIndex: instRpc.ProgramIDIndex, Accounts: accounts, Data: instRpc.Data}, nil
}