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

fix: cherry pick athens3 hotfixes #3253

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* [3206](https://github.com/zeta-chain/node/pull/3206) - skip Solana unsupported transaction version to not block inbound observation
* [3184](https://github.com/zeta-chain/node/pull/3184) - zetaclient should not retry if inbound vote message validation fails
* [3225](https://github.com/zeta-chain/node/pull/3225) - use separate database file names for btc signet and testnet4
* [3253](https://github.com/zeta-chain/node/pull/3253) - fix solana inbound version 0 queries and move tss keysign prior to relayer key checking

## v23.0.0

Expand Down
12 changes: 7 additions & 5 deletions zetaclient/chains/solana/observer/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"fmt"

"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/pkg/errors"

solanarpc "github.com/zeta-chain/node/zetaclient/chains/solana/rpc"
zctx "github.com/zeta-chain/node/zetaclient/context"
clienttypes "github.com/zeta-chain/node/zetaclient/types"
)
Expand Down Expand Up @@ -61,10 +61,12 @@
// process inbound trackers
for _, tracker := range trackers {
signature := solana.MustSignatureFromBase58(tracker.TxHash)
txResult, err := ob.solClient.GetTransaction(ctx, signature, &rpc.GetTransactionOpts{
Commitment: rpc.CommitmentFinalized,
})
if err != nil {
txResult, err := solanarpc.GetTransaction(ctx, ob.solClient, signature)
switch {
case errors.Is(err, solanarpc.ErrUnsupportedTxVersion):
ob.Logger().Inbound.Warn().Stringer("tx.signature", signature).Msg("skip inbound tracker hash")
continue
case err != nil:

Check warning on line 69 in zetaclient/chains/solana/observer/inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/solana/observer/inbound_tracker.go#L64-L69

Added lines #L64 - L69 were not covered by tests
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved
return errors.Wrapf(err, "error GetTransaction for chain %d sig %s", chainID, signature)
}

Expand Down
9 changes: 3 additions & 6 deletions zetaclient/chains/solana/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@
var allSignatures []*rpc.TransactionSignature

// make sure that the 'untilSig' exists to prevent undefined behavior on GetSignaturesForAddressWithOpts
_, err := client.GetTransaction(
ctx,
untilSig,
&rpc.GetTransactionOpts{Commitment: rpc.CommitmentFinalized},
)
if err != nil {
_, err := GetTransaction(ctx, client, untilSig)
if err != nil && !errors.Is(err, ErrUnsupportedTxVersion) {

Check warning on line 89 in zetaclient/chains/solana/rpc/rpc.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/solana/rpc/rpc.go#L88-L89

Added lines #L88 - L89 were not covered by tests
return nil, errors.Wrapf(err, "error GetTransaction for untilSig %s", untilSig)
}

Expand Down Expand Up @@ -137,6 +133,7 @@
sig solana.Signature,
) (*rpc.GetTransactionResult, error) {
txResult, err := client.GetTransaction(ctx, sig, &rpc.GetTransactionOpts{
Commitment: rpc.CommitmentFinalized,

Check warning on line 136 in zetaclient/chains/solana/rpc/rpc.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/solana/rpc/rpc.go#L136

Added line #L136 was not covered by tests
MaxSupportedTransactionVersion: &rpc.MaxSupportedTransactionVersion0,
})

Expand Down
19 changes: 19 additions & 0 deletions zetaclient/chains/solana/rpc/rpc_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/gagliardetto/solana-go"
solanarpc "github.com/gagliardetto/solana-go/rpc"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/zetaclient/chains/solana/rpc"
"github.com/zeta-chain/node/zetaclient/common"
"github.com/zeta-chain/node/zetaclient/testutils"
)

// Test_SolanaRPCLive is a phony test to run all live tests
Expand All @@ -20,6 +22,7 @@ func Test_SolanaRPCLive(t *testing.T) {
LiveTest_GetTransactionWithVersion(t)
LiveTest_GetFirstSignatureForAddress(t)
LiveTest_GetSignaturesForAddressUntil(t)
LiveTest_GetSignaturesForAddressUntil_Version0(t)
LiveTest_CheckRPCStatus(t)
}

Expand Down Expand Up @@ -80,6 +83,22 @@ func LiveTest_GetSignaturesForAddressUntil(t *testing.T) {
}
}

func LiveTest_GetSignaturesForAddressUntil_Version0(t *testing.T) {
// create a Solana devnet RPC client
client := solanarpc.New(solanarpc.DevNet_RPC)

// program address and signature of version "0"
chain := chains.SolanaDevnet
address := solana.MustPublicKeyFromBase58(testutils.GatewayAddresses[chain.ChainId])
untilSig := solana.MustSignatureFromBase58(
"39fSgD2nteJCQRQP3ynqEcDMZAFSETCbfb61AUqLU6y7qbzSJL5rn2DHU2oM35zsf94Feb5C5QWd5L5UnncBsAay",
)

// should get all signatures for the address until a signature of version "0" successfully
_, err := rpc.GetSignaturesForAddressUntil(context.Background(), client, address, untilSig, 100)
require.NoError(t, err)
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved
}

func LiveTest_CheckRPCStatus(t *testing.T) {
// create a Solana devnet RPC client
client := solanarpc.New(solanarpc.DevNet_RPC)
Expand Down
12 changes: 6 additions & 6 deletions zetaclient/chains/solana/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@
nonce := params.TssNonce
coinType := cctx.InboundParams.CoinType

// skip relaying the transaction if this signer hasn't set the relayer key
if !signer.HasRelayerKey() {
logger.Warn().Msgf("TryProcessOutbound: no relayer key configured")
return
}

var tx *solana.Transaction

switch coinType {
Expand Down Expand Up @@ -168,6 +162,12 @@
return
}

// skip relaying the transaction if this signer hasn't set the relayer key
if !signer.HasRelayerKey() {
logger.Warn().Msgf("TryProcessOutbound: no relayer key configured")
return
}

Check warning on line 169 in zetaclient/chains/solana/signer/signer.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/solana/signer/signer.go#L166-L169

Added lines #L166 - L169 were not covered by tests
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved

// set relayer balance metrics
signer.SetRelayerBalanceMetrics(ctx)

Expand Down
3 changes: 3 additions & 0 deletions zetaclient/keys/relayer_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gagliardetto/solana-go"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"

"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/pkg/crypto"
Expand Down Expand Up @@ -68,6 +69,8 @@ func LoadRelayerKey(relayerKeyPath string, network chains.Network, password stri
return relayerKey, nil
}

log.Logger.Warn().Msgf("relayer key file not found: %s", fileName)

// relayer key is optional, so it's okay if the relayer key is not provided
return nil, nil
}
Expand Down
Loading