NONEVM-2403: use CLDF for ton localnet access#373
Conversation
For bumping TON localnet version w/o updating frameworks smartcontractkit/chainlink-ton#373 - Added configurations for CTFv2, that can be set by caller - Support ton api client interface
There was a problem hiding this comment.
Pull Request Overview
This PR migrates TON integration tests from direct TON API client creation to using the Chainlink Deployments Framework (CLDF) for localnet access. The changes consolidate TON local network configuration and reduce code duplication.
Key Changes:
- Replaced manual API client creation with CLDF's CTFChainProvider
- Centralized TON localnet configuration in a new
deployment/config/localnetwork.gofile - Updated tests to use the new chain provider pattern with wallet pre-funding
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/.core_version | Updated core version reference to b6d567 |
| pkg/relay/chain.go | Added log poller health report to chain health monitoring |
| integration-tests/txm/txm_test.go | Migrated test to use CLDF chain provider, removed manual wallet setup |
| integration-tests/tracetracking/testutils/test_utils.go | Added new test setup functions using CLDF chain provider |
| integration-tests/smoke/logpoller/log_poller_test.go | Migrated all log poller tests to use CLDF chain provider |
| integration-tests/go.mod | Updated dependencies: chain-selectors, chainlink-deployments-framework, and various AWS/Ethereum packages |
| deployment/utils/chain.go | Replaced custom network setup with CLDF provider, extracted prefunded wallet logic |
| deployment/go.mod | Updated dependencies to match integration-tests module |
| deployment/config/localnetwork.go | New file centralizing TON localnet configuration for CLDF |
| deployment/ccip/helpers/execute.go | Changed client type from *ton.APIClient to ton.APIClientWrapped |
| deployment/ccip/cs_test_helpers.go | Changed client type from *ton.APIClient to ton.APIClientWrapped |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return ton.NewAPIClient(pool, ton.ProofCheckPolicyFast), nil | ||
| } | ||
| chain, err := p.Initialize(t.Context()) | ||
| require.NoError(t, err, "failed to initialize CTF chain provider") |
There was a problem hiding this comment.
Lets try to stop treating this as "test helpers" but as infrastructure code that is used by a test, and return errors vs injecting test context and asserting no errors.
A function can return an error and a specific test can assert no error.
Any test specific funcs should be moved to test packages.
Refactoring function by function would make us get there eventually.
There was a problem hiding this comment.
A function can return an error and a specific test can assert no error
Ah, good point! this made things click for me 👍
fe72a85 to
ffa12b8
Compare
There was a problem hiding this comment.
Seems reasonable to remove testing.T parameter
| if b.Type == CTF || b.Type == LOCAL { | ||
| for _, chain := range env.BlockChains.TonChains() { | ||
| testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) | ||
| ferr := testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) |
There was a problem hiding this comment.
any reason not to call it err? Calling it different makes it look like we are avoding overwriting err for some reason.
There was a problem hiding this comment.
It's to avoid error variable shadowing, I'm sure in some cases it's ok though. I'll clean up once I got CLDF bump merged in core
There was a problem hiding this comment.
You won’t be shadowing it as long as you assign to err using = instead of :=.
If the function returns more than just an error, you can pre-declare the variable to avoid shadowing.
| ferr := testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) | |
| err = testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) |
There was a problem hiding this comment.
Thanks for the clarification. I’ll merge this first to unblock other PRs and handle it in a follow-up
| sender, serr := test_utils.CreateRandomHighloadWallet(tonChain.Client) | ||
| require.NoError(t, serr) | ||
|
|
||
| ferr := test_utils.FundWallets(t, tonChain.Client, []*address.Address{sender.Address()}, | ||
| []tlb.Coins{tlb.MustFromTON("1000")}) | ||
| require.NoError(t, ferr) | ||
|
|
||
| emitter, err := helper.NewTestEventSource(client, sender, "replayEmitter", | ||
| rand.Uint32(), logger.Test(t)) | ||
| emitter, err := helper.NewTestEventSource(tonChain.Client, sender, "replayEmitter", rand.Uint32(), logger.Test(t)) |
There was a problem hiding this comment.
nit: rename errors to err
| sender, serr := test_utils.CreateRandomHighloadWallet(tonChain.Client) | |
| require.NoError(t, serr) | |
| ferr := test_utils.FundWallets(t, tonChain.Client, []*address.Address{sender.Address()}, | |
| []tlb.Coins{tlb.MustFromTON("1000")}) | |
| require.NoError(t, ferr) | |
| emitter, err := helper.NewTestEventSource(client, sender, "replayEmitter", | |
| rand.Uint32(), logger.Test(t)) | |
| emitter, err := helper.NewTestEventSource(tonChain.Client, sender, "replayEmitter", rand.Uint32(), logger.Test(t)) | |
| sender, err := test_utils.CreateRandomHighloadWallet(tonChain.Client) | |
| require.NoError(t, err) | |
| err = test_utils.FundWallets(t, tonChain.Client, []*address.Address{sender.Address()}, | |
| []tlb.Coins{tlb.MustFromTON("1000")}) | |
| require.NoError(t, err) | |
| emitter, err := helper.NewTestEventSource(tonChain.Client, sender, "replayEmitter", rand.Uint32(), logger.Test(t)) |
| if b.Type == CTF || b.Type == LOCAL { | ||
| for _, chain := range env.BlockChains.TonChains() { | ||
| testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) | ||
| ferr := testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) |
There was a problem hiding this comment.
You won’t be shadowing it as long as you assign to err using = instead of :=.
If the function returns more than just an error, you can pre-declare the variable to avoid shadowing.
| ferr := testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) | |
| err = testutils.FundWallets(t, chain.Client, []*address.Address{chain.WalletAddress}, []tlb.Coins{tlb.MustFromTON(DefaultFundAmountTon)}) |
* MCMS suite polish/fixes #3 (#360) * Allow MCMS<T>.submitErrorReport even when root is expired * Timelock.onBouncedMessage - Mark the operation as final * Adopt SnakedCell<T> * Timelock - support blocking msg bodies (data) < 32 bits * Revert - 'Timelock - support blocking msg bodies (data) < 32 bits' * Use SnakedCell<RootDescriptor> for roots * Add scripts/disk-cache-gc.sh run to e2e test (#366) * Add scripts/disk-cache-gc.sh run to e2e test * Relocate Nix store to /mnt * chore: remove unused function (#368) * Dont cache CI test run logs (#377) * dont cache test logs * chore: clean log dir before running test * fix: flag --------- Co-authored-by: Jade Park <jadepark.dev@gmail.com> * Bump core version tag (#381) * refactor: offramp wrappers to use CellCodec (#379) * replace all encode and decode functions with builder type * refactor message encoding as well * Update contracts/wrappers/ccip/OffRamp.ts Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * Update contracts/wrappers/ccip/OffRamp.ts Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * fmt * fix typo --------- Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * refactor ton accessor ocr3base binding (#384) * refactor offramp binding and chain accessor ocr3base * update comments * fix lint * fix contract test * add chainId back * golint * [NONEVM-3047] feat: add feeValueJuels to getValidatedFee and TVM2ANY event (#361) * feat: add feeValueJuels to getValidatedFee * fix: missed overwritten param * fix: update feequoter go bindings * fix: update onramp go bindings * fix: golint * fix: revert unnecesary change * feat: don't fail on missing link token price * cicd: power up integration test vm * test: make feequoter errors work * Fix errorCodes for feeQuoter * LINK token price also needs configuring * Update generated feeQuoter exit codes --------- Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * NONEVM-2403: use CLDF for ton localnet access (#373) * chore: clean up * chore: bump core * chore: bump core/deployment * chore: tidy * chore: clean up * chore: bump core * chore: bump mylocalton * chore: modgraph * Fix compilation on 1.2 * fix import * fix: wait for current masterchain block --------- Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> Co-authored-by: Patricio <contact@patricios.space> Co-authored-by: Oliver Townsend <133903322+ogtownsend@users.noreply.github.com> Co-authored-by: vicentevieytes <73846744+vicentevieytes@users.noreply.github.com> Co-authored-by: Joe Huang <joe.huang@smartcontract.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Tolk 1.2 * Fix pendingOwner serialization * Fix maybeAddr serialization in typescript wrappers * Fix go bindings * nix: Bump sha * Fix more cases * chore: bump mylocalton * tolk-1-2-mylocalton-fix (#387) * MCMS suite polish/fixes #3 (#360) * Allow MCMS<T>.submitErrorReport even when root is expired * Timelock.onBouncedMessage - Mark the operation as final * Adopt SnakedCell<T> * Timelock - support blocking msg bodies (data) < 32 bits * Revert - 'Timelock - support blocking msg bodies (data) < 32 bits' * Use SnakedCell<RootDescriptor> for roots * Add scripts/disk-cache-gc.sh run to e2e test (#366) * Add scripts/disk-cache-gc.sh run to e2e test * Relocate Nix store to /mnt * chore: remove unused function (#368) * Dont cache CI test run logs (#377) * dont cache test logs * chore: clean log dir before running test * fix: flag --------- Co-authored-by: Jade Park <jadepark.dev@gmail.com> * Bump core version tag (#381) * refactor: offramp wrappers to use CellCodec (#379) * replace all encode and decode functions with builder type * refactor message encoding as well * Update contracts/wrappers/ccip/OffRamp.ts Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * Update contracts/wrappers/ccip/OffRamp.ts Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * fmt * fix typo --------- Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> * refactor ton accessor ocr3base binding (#384) * refactor offramp binding and chain accessor ocr3base * update comments * fix lint * fix contract test * add chainId back * golint * [NONEVM-3047] feat: add feeValueJuels to getValidatedFee and TVM2ANY event (#361) * feat: add feeValueJuels to getValidatedFee * fix: missed overwritten param * fix: update feequoter go bindings * fix: update onramp go bindings * fix: golint * fix: revert unnecesary change * feat: don't fail on missing link token price * cicd: power up integration test vm * test: make feequoter errors work * Fix errorCodes for feeQuoter * LINK token price also needs configuring * Update generated feeQuoter exit codes --------- Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * NONEVM-2403: use CLDF for ton localnet access (#373) * chore: clean up * chore: bump core * chore: bump core/deployment * chore: tidy * chore: clean up * chore: bump core * chore: bump mylocalton * chore: modgraph * Fix compilation on 1.2 * fix import * fix: wait for current masterchain block --------- Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> Co-authored-by: Patricio <contact@patricios.space> Co-authored-by: Oliver Townsend <133903322+ogtownsend@users.noreply.github.com> Co-authored-by: vicentevieytes <73846744+vicentevieytes@users.noreply.github.com> Co-authored-by: Joe Huang <joe.huang@smartcontract.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * fix import yet again * Address review * Update sha --------- Co-authored-by: Jade Park <jadepark.dev@gmail.com> Co-authored-by: Kristijan Rebernisak <kristijan.rebernisak@gmail.com> Co-authored-by: Patricio <contact@patricios.space> Co-authored-by: Oliver Townsend <133903322+ogtownsend@users.noreply.github.com> Co-authored-by: vicentevieytes <73846744+vicentevieytes@users.noreply.github.com> Co-authored-by: Joe Huang <joe.huang@smartcontract.com>
Steps
CLDF: expose CTF config to callers(meaning relayer integration tests / product integration tests)chainlink(core): bump CLDF to 0.67.0, fix go-ethereum missing APIchainlink-ton: centralize localnet config in one place, replace CTF direct use with CLDF, bump core to fix e2echainlink(core): bump chainlink-ton, replace custom CLDF configuration with localnet config importedchainlink-ton: bump.core_versionto use the same configuration in ccip e2e test suiteschainlink-ton: bump mylocalton-docker version to test TVM 12(Tolk 1.2) contracts