Skip to content

reenable ton in devenv#1899

Open
tt-cll wants to merge 1 commit intomainfrom
tt/ton2
Open

reenable ton in devenv#1899
tt-cll wants to merge 1 commit intomainfrom
tt/ton2

Conversation

@tt-cll
Copy link
Collaborator

@tt-cll tt-cll commented Mar 24, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 170 to +178
} 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)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +183 to +193
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))
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
return nil, nil, err
}

err = testutils.FundWalletsNoT(client, []*address.Address{w.Address()}, []tlb.Coins{tlb.MustFromTON("1000")})
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)})

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Metric tt/ton2 main
Coverage 70.1% 69.8%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants