Skip to content

Commit 3f9ccf1

Browse files
authored
Update TON chain client type, use retry strategy (#761)
1 parent b35d411 commit 3f9ccf1

5 files changed

Lines changed: 17 additions & 11 deletions

File tree

.changeset/mighty-chicken-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": minor
3+
---
4+
5+
Changed TON chain client type, use retry strategy

chain/mcms/adapters/chain_access.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (a *ChainAccessAdapter) SuiClient(selector uint64) (sui.ISuiAPI, mcmssui.Su
8585
}
8686

8787
// TonClient returns the Ton API client for the given selector.
88-
func (a *ChainAccessAdapter) TonClient(selector uint64) (*ton.APIClient, bool) {
88+
func (a *ChainAccessAdapter) TonClient(selector uint64) (ton.APIClientWrapped, bool) {
8989
ch, ok := a.inner.TonChains()[selector]
9090
if !ok {
9191
return nil, false

chain/ton/provider/ctf_provider.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232

3333
// supportedTONImageRepository is the only supported Docker image repository for TON localnet.
3434
supportedTONImageRepository = "ghcr.io/neodix42/mylocalton-docker"
35+
defaultClientRetryCount = 5
3536
)
3637

3738
// CTFChainProviderConfig holds the configuration to initialize the CTFChainProvider.
@@ -136,7 +137,7 @@ func (p *CTFChainProvider) Initialize(ctx context.Context) (chain.BlockChain, er
136137
return *p.chain, nil
137138
}
138139

139-
func (p *CTFChainProvider) startContainer(ctx context.Context, chainID string) (string, *ton.APIClient, error) {
140+
func (p *CTFChainProvider) startContainer(ctx context.Context, chainID string) (string, ton.APIClientWrapped, error) {
140141
var (
141142
attempts = uint(10)
142143
url string
@@ -190,7 +191,7 @@ func (p *CTFChainProvider) startContainer(ctx context.Context, chainID string) (
190191
return "", nil, fmt.Errorf("failed to create liteclient connection pool: %w", err)
191192
}
192193

193-
client := ton.NewAPIClient(connectionPool, ton.ProofCheckPolicyFast)
194+
client := ton.NewAPIClient(connectionPool, ton.ProofCheckPolicyFast).WithRetry(defaultClientRetryCount)
194195

195196
// check connection, CTFv2 handles the readiness
196197
mb, err := getMasterchainBlockID(ctx, client)

chain/ton/provider/rpc_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ func NewRPCChainProvider(selector uint64, config RPCChainProviderConfig) *RPCCha
110110
}
111111

112112
// setupConnection creates and tests a connection to the TON liteserver
113-
func setupConnection(ctx context.Context, liteserverURL string) (*tonlib.APIClient, error) {
113+
func setupConnection(ctx context.Context, liteserverURL string) (tonlib.APIClientWrapped, error) {
114114
connectionPool, err := createLiteclientConnectionPool(ctx, liteserverURL)
115115
if err != nil {
116116
return nil, fmt.Errorf("failed to connect to liteserver: %w", err)
117117
}
118118

119-
api := tonlib.NewAPIClient(connectionPool, tonlib.ProofCheckPolicyFast)
119+
api := tonlib.NewAPIClient(connectionPool, tonlib.ProofCheckPolicyFast).WithRetry(defaultClientRetryCount)
120120

121121
// Test connection and get current block
122122
mb, err := api.GetMasterchainInfo(ctx)

chain/ton/ton_chain.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ type ChainMetadata = common.ChainMetadata
2121

2222
// Chain represents a TON chain.
2323
type Chain struct {
24-
ChainMetadata // Contains canonical chain identifier
25-
Client *ton.APIClient // APIClient for Lite Server connection
26-
Wallet *wallet.Wallet // Wallet abstraction (signing, sending)
27-
WalletAddress *address.Address // Address of deployer wallet
28-
URL string // Liteserver URL
29-
Confirm ConfirmFunc // Function to confirm transactions
24+
ChainMetadata // Contains canonical chain identifier
25+
Client ton.APIClientWrapped // APIClient for Lite Server connection
26+
Wallet *wallet.Wallet // Wallet abstraction (signing, sending)
27+
WalletAddress *address.Address // Address of deployer wallet
28+
URL string // Liteserver URL
29+
Confirm ConfirmFunc // Function to confirm transactions
3030
}
3131

3232
// MakeDefaultConfirmFunc creates a default ConfirmFunc that waits for transaction trace.

0 commit comments

Comments
 (0)