Conversation
There was a problem hiding this comment.
Pull request overview
This PR re-enables TON support in the CCIP devenv, wiring TON back into home-chain changesets and restoring TON chain provider initialization in the CLDF operations environment.
Changes:
- Re-enable TON sequences/adapters for off-ramp address resolution in home-chain changesets.
- Restore TON node identity/address derivation when building OCR3 oracle identities.
- Add TON chain provider initialization in
NewCLDFOperationsEnvironment, including wallet creation and funding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| devenv/common/home_chain.go | Re-enables TON handling for off-ramp discovery and OCR identity construction. |
| devenv/cldf.go | Restores TON provider setup in the CLDF environment (client, wallet, funding, provider init). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else if b.Type == "ton" { | ||
| panic("TON support temporarily disabled") | ||
| // chainID := b.ChainID | ||
| // rpcHTTPURL := b.Out.Nodes[0].ExternalHTTPUrl | ||
|
|
||
| // d, err := chainsel.GetChainDetailsByChainIDAndFamily(chainID, chainsel.FamilyTon) | ||
| // if err != nil { | ||
| // return nil, nil, err | ||
| // } | ||
| // client, err := testutils.CreateClient(context.Background(), rpcHTTPURL) | ||
| // if err != nil { | ||
| // return nil, nil, fmt.Errorf("failed to create TON client: %w", err) | ||
| // } | ||
|
|
||
| // seed := wallet.NewSeed() | ||
| // w, err := wallet.FromSeed(client, seed, wallet.ConfigV5R1Final{NetworkGlobalID: wallet.MainnetGlobalID, Workchain: 0}) | ||
| // if err != nil { | ||
| // return nil, nil, fmt.Errorf("failed to create TON wallet: %w", err) | ||
| // } | ||
| // privateKey, err := wallet.SeedToPrivateKey(seed /*password=*/, "" /*isBIP39=*/, false) | ||
| // if err != nil { | ||
| // return nil, nil, fmt.Errorf("failed to get private key from seed: %w", err) | ||
| // } | ||
| // walletVersion := "V5R1" | ||
| // deployerSignerGen := cldf_ton_provider.PrivateKeyFromRaw(hex.EncodeToString(privateKey)) | ||
|
|
||
| // selectors = append(selectors, d.ChainSelector) | ||
| // p, err := cldf_ton_provider.NewRPCChainProvider( | ||
| // d.ChainSelector, | ||
| // cldf_ton_provider.RPCChainProviderConfig{ | ||
| // HTTPURL: rpcHTTPURL, | ||
| // WalletVersion: cldf_ton_provider.WalletVersion(walletVersion), | ||
| // DeployerSignerGen: deployerSignerGen, | ||
| // }, | ||
| // ).Initialize(context.Background()) | ||
| // if err != nil { | ||
| // return nil, nil, err | ||
| // } | ||
|
|
||
| // err = testutils.FundWalletsNoT(client, []*address.Address{w.Address()}, []tlb.Coins{tlb.MustFromTON("1000")}) | ||
| // if err != nil { | ||
| // return nil, nil, fmt.Errorf("failed to fund TON wallet: %w", err) | ||
| // } | ||
| // providers = append(providers, p) | ||
| chainID := b.ChainID | ||
| rpcHTTPURL := b.Out.Nodes[0].ExternalHTTPUrl | ||
|
|
||
| d, err := chainsel.GetChainDetailsByChainIDAndFamily(chainID, chainsel.FamilyTon) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| client, err := testutils.CreateClient(context.Background(), rpcHTTPURL) |
There was a problem hiding this comment.
The newly re-enabled TON branch in NewCLDFOperationsEnvironment doesn’t appear to be exercised by existing automated tests (current e2e/smoke flows largely assume EVM/Solana). Adding at least one test that runs the TON initialization path (even if it’s a mocked RPC client) would help catch regressions in wallet creation, funding, and provider initialization.
| seed := wallet.NewSeed() | ||
| w, err := wallet.FromSeed(client, seed, wallet.ConfigV5R1Final{NetworkGlobalID: wallet.MainnetGlobalID, Workchain: 0}) | ||
| if err != nil { | ||
| return nil, nil, fmt.Errorf("failed to create TON wallet: %w", err) | ||
| } | ||
| privateKey, err := wallet.SeedToPrivateKey(seed /*password=*/, "" /*isBIP39=*/, false) | ||
| if err != nil { | ||
| return nil, nil, fmt.Errorf("failed to get private key from seed: %w", err) | ||
| } | ||
| walletVersion := "V5R1" | ||
| deployerSignerGen := cldf_ton_provider.PrivateKeyFromRaw(hex.EncodeToString(privateKey)) |
There was a problem hiding this comment.
The TON provider setup generates a fresh random seed (wallet.NewSeed()) each time NewCLDFOperationsEnvironment is called, which makes the deployer identity non-deterministic across repeated invocations (e.g., commands/tests that load env-out.toml and recreate the environment). This can lead to repeated funding attempts and an inability to operate on previously deployed TON contracts with the same deployer key. Consider sourcing the TON deployer key from config/env (similar to EVM) or persisting/reusing it via the datastore/output file so subsequent runs use the same signer.
| return nil, nil, err | ||
| } | ||
|
|
||
| err = testutils.FundWalletsNoT(client, []*address.Address{w.Address()}, []tlb.Coins{tlb.MustFromTON("1000")}) |
There was a problem hiding this comment.
The TON deployer wallet is funded with a hard-coded amount ("1000" TON). This magic constant can make environment startup slow/flaky on constrained TON devnets and is hard to tune for different setups. Consider making the amount configurable (env/config), or funding the minimum required for deployments instead of a fixed large value.
| err = testutils.FundWalletsNoT(client, []*address.Address{w.Address()}, []tlb.Coins{tlb.MustFromTON("1000")}) | |
| fundAmountTON := os.Getenv("TON_DEPLOYER_FUNDING_TON") | |
| if fundAmountTON == "" { | |
| fundAmountTON = "1000" | |
| } | |
| err = testutils.FundWalletsNoT(client, []*address.Address{w.Address()}, []tlb.Coins{tlb.MustFromTON(fundAmountTON)}) |
|
No description provided.