Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 52 additions & 49 deletions devenv/cldf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package ccip

import (
"context"
// "encoding/hex"
"encoding/hex"
"fmt"

"errors"
"os"
"path/filepath"
Expand All @@ -18,17 +20,19 @@ import (
"github.com/smartcontractkit/chainlink-deployments-framework/deployment"
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
// "github.com/xssnick/tonutils-go/address"
// "github.com/xssnick/tonutils-go/tlb"
// "github.com/xssnick/tonutils-go/ton/wallet"

"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/ton/wallet"

chainsel "github.com/smartcontractkit/chain-selectors"

cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
cldf_evm_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm/provider"
cldf_solana_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana/provider"
// cldf_ton_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/ton/provider"
// testutils "github.com/smartcontractkit/chainlink-ton/deployment/utils"

cldf_ton_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/ton/provider"
testutils "github.com/smartcontractkit/chainlink-ton/deployment/utils"

ccipEVM "github.com/smartcontractkit/chainlink-ccip/devenv/chainimpl/ccip-evm"
ccipSolana "github.com/smartcontractkit/chainlink-ccip/devenv/chainimpl/ccip-solana"
Expand Down Expand Up @@ -164,49 +168,48 @@ func NewCLDFOperationsEnvironment(bc []*blockchain.Input, dataStore datastore.Da
}
providers = append(providers, p)
} 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)
Comment on lines 170 to +178
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.
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))
Comment on lines +183 to +193
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.

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")})
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.
if err != nil {
return nil, nil, fmt.Errorf("failed to fund TON wallet: %w", err)
}
providers = append(providers, p)
}
}

Expand Down
48 changes: 23 additions & 25 deletions devenv/common/home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
capabilities_registry "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0"
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
// tonSeqs "github.com/smartcontractkit/chainlink-ton/deployment/ccip/1_6_0/sequences"
// ccip_ton "github.com/smartcontractkit/chainlink-ton/devenv"

tonSeqs "github.com/smartcontractkit/chainlink-ton/deployment/ccip/1_6_0/sequences"
ccip_ton "github.com/smartcontractkit/chainlink-ton/devenv"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
Expand Down Expand Up @@ -405,12 +406,11 @@ func applyAddDonAndSetCandidateChangesetConfig(e deployment.Environment, cfg Add
return deployment.ChangesetOutput{}, err
}
case chain_selectors.FamilyTon:
// a := &tonSeqs.TonLaneAdapter{}
// offRampAddress, err = a.GetOffRampAddress(e.DataStore, chainSelector)
// if err != nil {
// return deployment.ChangesetOutput{}, err
// }
panic("TON support temporarily disabled")
a := &tonSeqs.TonLaneAdapter{}
offRampAddress, err = a.GetOffRampAddress(e.DataStore, chainSelector)
if err != nil {
return deployment.ChangesetOutput{}, err
}
default:
return deployment.ChangesetOutput{}, fmt.Errorf("unsupported chain family %s for selector %d", family, chainSelector)
}
Expand Down Expand Up @@ -731,17 +731,16 @@ func getOracleIdentities(clClients []*clclient.ChainlinkClient, nodeKeyBundles m
onPrefix = "ocr2on_solana_"
cfgPrefix = "ocr2cfg_solana_"
case chain_selectors.FamilyTon:
panic("TON support temporarily disabled")
// bundle := nodeKeyBundles[family][id.Raw()]
// addr, err = ccip_ton.GetNodeAddressFromBundle(&bundle)
// if err != nil {
// return err
// }
// ocrKey := bundle.OCR2Key
// ocr2Config = ocrKey.Data.Attributes
// offPrefix = "ocr2off_ton_"
// onPrefix = "ocr2on_ton_"
// cfgPrefix = "ocr2cfg_ton_"
bundle := nodeKeyBundles[family][id.Raw()]
addr, err = ccip_ton.GetNodeAddressFromBundle(&bundle)
if err != nil {
return err
}
ocrKey := bundle.OCR2Key
ocr2Config = ocrKey.Data.Attributes
offPrefix = "ocr2off_ton_"
onPrefix = "ocr2on_ton_"
cfgPrefix = "ocr2cfg_ton_"
default:
return fmt.Errorf("unsupported chain family %s for selector %d", family, destSelector)
}
Expand Down Expand Up @@ -902,12 +901,11 @@ func applySetCandidateChangesetConfig(e deployment.Environment, cfg SetCandidate
return deployment.ChangesetOutput{}, err
}
case chain_selectors.FamilyTon:
panic("TON support temporarily disabled")
// a := &tonSeqs.TonLaneAdapter{}
// offRampAddress, err = a.GetOffRampAddress(e.DataStore, chainSelector)
// if err != nil {
// return deployment.ChangesetOutput{}, err
// }
a := &tonSeqs.TonLaneAdapter{}
offRampAddress, err = a.GetOffRampAddress(e.DataStore, chainSelector)
if err != nil {
return deployment.ChangesetOutput{}, err
}
default:
return deployment.ChangesetOutput{}, fmt.Errorf("unsupported chain family %s for selector %d", family, chainSelector)
}
Expand Down
Loading