Skip to content

Commit

Permalink
fix: cherry pick athens3 hotfixes (#3253)
Browse files Browse the repository at this point in the history
* cherry pick athens3 hotfixes

* add changelog entry
  • Loading branch information
ws4charlie authored Dec 6, 2024
1 parent bc1d8ae commit 2cd0b73
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
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 @@ import (
"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 @@ func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error {
// 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:
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 @@ func GetSignaturesForAddressUntil(
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) {
return nil, errors.Wrapf(err, "error GetTransaction for untilSig %s", untilSig)
}

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

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 @@ func (signer *Signer) TryProcessOutbound(
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 @@ func (signer *Signer) TryProcessOutbound(
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
}

// 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

0 comments on commit 2cd0b73

Please sign in to comment.