fix(relayer): remove RPC dependency on CCIPProvider creation#658
fix(relayer): remove RPC dependency on CCIPProvider creation#658jadepark-dev merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates TON CCIP provider construction so it no longer requires an RPC client to be created/fetched at provider creation time, and instead defers client acquisition via a callback.
Changes:
- Change CCIP provider/TON accessor construction to accept a
clientProvider(ctx)function rather than a concreteton.APIClientWrapped. - Update TON accessor read paths to call
clientProvider(ctx)at time of use. - Update integration tests to pass the new
clientProviderintoNewTONAccessor.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/relay/relay.go | Switch relayer’s CCIP provider creation to pass a clientProvider callback. |
| pkg/ccip/provider/provider.go | Update NewCCIPProvider signature to accept clientProvider and forward it to the chain accessor. |
| pkg/ccip/chainaccessor/ton_accessor.go | Replace stored client with clientProvider and fetch client on-demand in several accessor methods. |
| pkg/ccip/chainaccessor/config.go | Update config getter paths to fetch client via clientProvider. |
| integration-tests/deployment/ccip/cs_test.go | Update accessor construction to use clientProvider. |
| integration-tests/deployment/ccip/cs_deployer_test.go | Update accessor construction to use clientProvider. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| func (a *TONAccessor) getCurrentMasterchainBlock(ctx context.Context) (*ton.BlockIDExt, error) { | ||
| block, err := a.client.CurrentMasterchainInfo(ctx) | ||
| client, err := a.clientProvider(ctx) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to get TON client: %w", err) | ||
| } | ||
| block, err := client.CurrentMasterchainInfo(ctx) |
There was a problem hiding this comment.
Currently only one connection at a time, and should be low priority for now.
There was a problem hiding this comment.
currently func (c *chain) GetClient(ctx context.Context) (ton.APIClientWrapped, error) { doesn't create multiple connection in liteclient.ConnectionPool, but once we introduce multi node management using connection pool, we should be using tonutils-go.client.StickyContext
| func NewTONAccessor( | ||
| lggr logger.Logger, | ||
| chainSelector ccipocr3.ChainSelector, | ||
| client ton.APIClientWrapped, | ||
| clientProvider func(context.Context) (ton.APIClientWrapped, error), | ||
| logPoller logpoller.Service, | ||
| addrCodec ccipocr3.ChainSpecificAddressCodec, | ||
| ) (ccipocr3.ChainAccessor, error) { | ||
| sLggr := logger.Sugared(lggr).Named("TONAccessor").Named(chainSelector.String()) | ||
| return &TONAccessor{ | ||
| lggr: sLggr, | ||
| chainSelector: chainSelector, | ||
| client: client, | ||
| logPoller: logPoller, | ||
| bindings: make(map[string]*address.Address), | ||
| bindingsMu: sync.RWMutex{}, | ||
| addrCodec: addrCodec, | ||
| lggr: sLggr, | ||
| chainSelector: chainSelector, | ||
| clientProvider: clientProvider, | ||
| logPoller: logPoller, | ||
| bindings: make(map[string]*address.Address), | ||
| bindingsMu: sync.RWMutex{}, | ||
| addrCodec: addrCodec, | ||
| }, nil |
| addr, err := a.getBinding(consts.ContractNameOffRamp) | ||
| if err != nil { | ||
| return ccipocr3.OfframpConfig{}, err | ||
| } | ||
| config, err := tvm.CallGetter(ctx, a.client, block, addr, offramp.GetConfig) | ||
| client, err := a.clientProvider(ctx) | ||
| if err != nil { | ||
| return ccipocr3.OfframpConfig{}, fmt.Errorf("failed to get TON client: %w", err) | ||
| } | ||
| config, err := tvm.CallGetter(ctx, client, block, addr, offramp.GetConfig) |
There was a problem hiding this comment.
Currently only one connection at a time, and should be low priority for now.
* chore: test * fix: clientProvider for CCIPProvider * chore: test * fix: remove failure * fix: NewTONAccessor param
fix(relayer): remove RPC dependency on CCIPProvider creation (#658)
No description provided.