Skip to content

Commit ae7bced

Browse files
authored
feat(solana): remove txs field in relayer, encode txs, parallel relayer packets submission (#771)
1 parent 0366f0d commit ae7bced

File tree

14 files changed

+535
-190
lines changed

14 files changed

+535
-190
lines changed

e2e/interchaintestv8/solana/solana.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (s *Solana) NewTransactionFromInstructions(payerPubKey solana.PublicKey, in
5858
)
5959
}
6060

61-
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it.
61+
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it is finalized.
6262
func (s *Solana) SignAndBroadcastTx(ctx context.Context, tx *solana.Transaction, signers ...*solana.Wallet) (solana.Signature, error) {
6363
_, err := s.SignTx(ctx, tx, signers...)
6464
if err != nil {
@@ -113,6 +113,7 @@ func confirmationStatusLevel(status rpc.ConfirmationStatusType) int {
113113
}
114114
}
115115

116+
// Waits for transaction reaching status
116117
func (s *Solana) WaitForTxStatus(txSig solana.Signature, status rpc.ConfirmationStatusType) error {
117118
return testutil.WaitForCondition(time.Second*30, time.Second, func() (bool, error) {
118119
out, err := s.RPCClient.GetSignatureStatuses(context.TODO(), false, txSig)
@@ -189,13 +190,12 @@ func (s *Solana) WaitForProgramAvailabilityWithTimeout(ctx context.Context, prog
189190
return false
190191
}
191192

192-
// SignAndBroadcastTxWithRetry retries transaction broadcasting with default timeout
193+
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it is finalized, retries with default timeout
193194
func (s *Solana) SignAndBroadcastTxWithRetry(ctx context.Context, tx *solana.Transaction, signers ...*solana.Wallet) (solana.Signature, error) {
194195
return s.SignAndBroadcastTxWithRetryTimeout(ctx, tx, 30, signers...)
195196
}
196197

197-
// SignAndBroadcastTxWithRetryTimeout retries transaction broadcasting with specified timeout
198-
// It refreshes the blockhash on each attempt to handle expired blockhashes
198+
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it is finalized, retries with timeout
199199
func (s *Solana) SignAndBroadcastTxWithRetryTimeout(ctx context.Context, tx *solana.Transaction, timeoutSeconds int, signers ...*solana.Wallet) (solana.Signature, error) {
200200
var lastErr error
201201
for range timeoutSeconds {
@@ -218,10 +218,12 @@ func (s *Solana) SignAndBroadcastTxWithRetryTimeout(ctx context.Context, tx *sol
218218
return solana.Signature{}, fmt.Errorf("transaction broadcast timed out after %d seconds: %w", timeoutSeconds, lastErr)
219219
}
220220

221+
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it is in confirmed status
221222
func (s *Solana) SignAndBroadcastTxWithConfirmedStatus(ctx context.Context, tx *solana.Transaction, wallet *solana.Wallet) (solana.Signature, error) {
222223
return s.SignAndBroadcastTxWithOpts(ctx, tx, wallet, rpc.ConfirmationStatusConfirmed)
223224
}
224225

226+
// SignTx signs a transaction with the provided signers, broadcasts it, and confirms it is in requested status
225227
func (s *Solana) SignAndBroadcastTxWithOpts(ctx context.Context, tx *solana.Transaction, wallet *solana.Wallet, status rpc.ConfirmationStatusType) (solana.Signature, error) {
226228
_, err := s.SignTx(ctx, tx, wallet)
227229
if err != nil {

e2e/interchaintestv8/solana_gmp_test.go

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,9 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPCounterFromCosmos() {
419419
DstClientId: SolanaClientID,
420420
})
421421
s.Require().NoError(err, "Relayer Update Client failed")
422-
s.Require().NotEmpty(updateResp.Txs, "Relayer Update client should return chunked transactions")
422+
s.Require().NotEmpty(updateResp.Tx, "Relayer Update client should return chunked transactions")
423423

424424
s.submitChunkedUpdateClient(ctx, updateResp, s.SolanaUser)
425-
s.T().Logf("%s: Updated Tendermint client on Solana using %d chunked transactions", userLabel, len(updateResp.Txs))
426425

427426
// Now retrieve and relay the GMP packet
428427
resp, err := s.RelayerClient.RelayByTx(context.Background(), &relayertypes.RelayByTxRequest{
@@ -433,8 +432,7 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPCounterFromCosmos() {
433432
DstClientId: SolanaClientID,
434433
})
435434
s.Require().NoError(err)
436-
s.Require().NotEmpty(resp.Txs, "Relay should return chunked transactions")
437-
s.T().Logf("%s: Retrieved %d relay transactions (chunks + final instructions)", userLabel, len(resp.Txs))
435+
s.Require().NotEmpty(resp.Tx, "Relay should return chunked transactions")
438436

439437
// Execute on Solana using chunked submission
440438
solanaRelayTxSig = s.submitChunkedRelayPackets(ctx, resp, s.SolanaUser)
@@ -716,10 +714,9 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPSPLTokenTransferFromCosmos() {
716714
DstClientId: SolanaClientID,
717715
})
718716
s.Require().NoError(err, "Relayer Update Client failed")
719-
s.Require().NotEmpty(updateResp.Txs, "Relayer Update client should return chunked transactions")
717+
s.Require().NotEmpty(updateResp.Tx, "Relayer Update client should return chunked transactions")
720718

721719
s.submitChunkedUpdateClient(ctx, updateResp, s.SolanaUser)
722-
s.T().Logf("Updated Tendermint client on Solana using %d chunked transactions", len(updateResp.Txs))
723720
}))
724721

725722
s.Require().True(s.Run("Retrieve relay tx from relayer", func() {
@@ -731,8 +728,7 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPSPLTokenTransferFromCosmos() {
731728
DstClientId: SolanaClientID,
732729
})
733730
s.Require().NoError(err)
734-
s.Require().NotEmpty(resp.Txs, "Relay should return chunked transactions")
735-
s.T().Logf("Retrieved %d relay transactions (chunks + final instructions)", len(resp.Txs))
731+
s.Require().NotEmpty(resp.Tx, "Relay should return chunked transactions")
736732

737733
solanaRelayTxSig = s.submitChunkedRelayPackets(ctx, resp, s.SolanaUser)
738734
s.T().Logf("SPL transfer executed on Solana: %s", solanaRelayTxSig)
@@ -831,8 +827,8 @@ func (s *IbcEurekaSolanaTestSuite) createSPLTokenMint(ctx context.Context, decim
831827
return solanago.PublicKey{}, err
832828
}
833829

834-
// Sign and broadcast with both payer and mint account (with retry)
835-
_, err = s.SolanaChain.SignAndBroadcastTxWithRetry(ctx, tx, s.SolanaUser, mintAccount)
830+
// Sign and broadcast with both payer and mint account
831+
_, err = s.SolanaChain.SignAndBroadcastTx(ctx, tx, s.SolanaUser, mintAccount)
836832
if err != nil {
837833
return solanago.PublicKey{}, err
838834
}
@@ -881,8 +877,8 @@ func (s *IbcEurekaSolanaTestSuite) createTokenAccount(ctx context.Context, mint,
881877
return solanago.PublicKey{}, err
882878
}
883879

884-
// Sign and broadcast with both payer and token account (with retry)
885-
_, err = s.SolanaChain.SignAndBroadcastTxWithRetry(ctx, tx, s.SolanaUser, tokenAccount)
880+
// Sign and broadcast with both payer and token account
881+
_, err = s.SolanaChain.SignAndBroadcastTx(ctx, tx, s.SolanaUser, tokenAccount)
886882
if err != nil {
887883
return solanago.PublicKey{}, err
888884
}
@@ -1199,10 +1195,9 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPSendCallFromSolana() {
11991195
DstClientId: SolanaClientID,
12001196
})
12011197
s.Require().NoError(err, "Relayer Update Client failed")
1202-
s.Require().NotEmpty(resp.Txs, "Relayer Update client should return transactions")
1198+
s.Require().NotEmpty(resp.Tx, "Relayer Update client should return transactions")
12031199

12041200
s.submitChunkedUpdateClient(ctx, resp, s.SolanaUser)
1205-
s.T().Logf("Successfully updated Tendermint client on Solana using %d transaction(s)", len(resp.Txs))
12061201
}))
12071202

12081203
s.Require().True(s.Run("Relay acknowledgement", func() {
@@ -1214,8 +1209,7 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPSendCallFromSolana() {
12141209
DstClientId: SolanaClientID,
12151210
})
12161211
s.Require().NoError(err)
1217-
s.Require().NotEmpty(resp.Txs, "Relay should return chunked transactions")
1218-
s.T().Logf("Retrieved %d relay transactions (chunks + final instructions)", len(resp.Txs))
1212+
s.Require().NotEmpty(resp.Tx, "Relay should return chunked transactions")
12191213

12201214
sig := s.submitChunkedRelayPackets(ctx, resp, s.SolanaUser)
12211215
s.T().Logf("Acknowledgement transaction broadcasted: %s", sig)
@@ -1418,10 +1412,9 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPTimeoutFromSolana() {
14181412
DstClientId: SolanaClientID,
14191413
})
14201414
s.Require().NoError(err, "Relayer Update Client failed")
1421-
s.Require().NotEmpty(resp.Txs, "Relayer Update client should return transactions")
1415+
s.Require().NotEmpty(resp.Tx, "Relayer Update client should return transactions")
14221416

14231417
s.submitChunkedUpdateClient(ctx, resp, s.SolanaUser)
1424-
s.T().Logf("Successfully updated Tendermint client on Solana using %d transaction(s)", len(resp.Txs))
14251418
}))
14261419

14271420
s.Require().True(s.Run("Relay timeout transaction", func() {
@@ -1433,8 +1426,7 @@ func (s *IbcEurekaSolanaTestSuite) Test_GMPTimeoutFromSolana() {
14331426
DstClientId: SolanaClientID,
14341427
})
14351428
s.Require().NoError(err)
1436-
s.Require().NotEmpty(resp.Txs, "Relay should return chunked transactions")
1437-
s.T().Logf("Retrieved %d relay transactions (chunks + final instructions)", len(resp.Txs))
1429+
s.Require().NotEmpty(resp.Tx, "Relay should return chunked transactions")
14381430

14391431
sig := s.submitChunkedRelayPackets(ctx, resp, s.SolanaUser)
14401432
s.T().Logf("Timeout transaction broadcasted: %s", sig)

0 commit comments

Comments
 (0)