Skip to content

Commit 1189180

Browse files
tt-cllagusaldasorohuangzhen1997skudasovCopilot
authored
ton devenv (#470)
* Add set ocr to adapter * fix lint * fix imports * Fix lint * fix lint * fix lint * bump chainlink ccip deployment dependency * fix make * nop * tidy * add noop * revert adaptor * update * add mcms deployment * fix * fix make * fix test * devenv-impl template for TON * readme * add setOCR3 test * update mock * fix some lint * add test coverage for deploycontracts as well. Only MCMS left * fix test * fix mcms test * fix mod * fix make * fix fmt * revert breaking change * update comments * rename back * fix * fix mockery * fix nix * fix modgraph version mismatch * fix go.md * fix lint * new interface * fix test and fix lint * fix mod * bump dep * bump dep * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * refactor with new chainlink-ccip * goimport * minor * interface * interface * devenv * minor * devenv * fix golint * mod tidy * devenv-impl template for TON (#457) * devenv-impl template for TON * readme * new interface * bump dep * bump dep * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> * Update devenv-impl/impl.go Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Terry Tata <[email protected]> Co-authored-by: tt-cll <[email protected]> Co-authored-by: Copilot <[email protected]> * Revert "devenv-impl template for TON (#457)" This reverts commit 9374364. * funding * create client * wip * address comments part 1 * refactor [][]byte for ops output * fix serialization * refactor mock * fix import * fix nix hash * mod tidy * clean go.md * fix nix again * fix test * use zero address * wip * working e2e * comments * add missing utils * bump ctf * change ton blockchain * try e2e * comment * substitute * fix ref * iterate * pass contract version * pending gati * try new gati * try new gati * try polling * try polling * try polling * run in separate script * get rid of script * use workflow call * Revert "use workflow call" This reverts commit 5d7cb4f. * try polling again * fix nix * try local * fix merge * fix * debug * fix nix hash * use develop * cr comments * detect * checkout to read ref * bump ref to main * cr comments * reference client * imports * fix e2e * refactor * gomod * go.md * chainlink common * Update README.md * format * lint * revert fund wallets * lint * Update test-smoke.yml --------- Co-authored-by: Agustina Aldasoro <[email protected]> Co-authored-by: Agustina Aldasoro <[email protected]> Co-authored-by: Joe Huang <[email protected]> Co-authored-by: skudasov <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 77cfa84 commit 1189180

File tree

11 files changed

+2069
-27
lines changed

11 files changed

+2069
-27
lines changed

.github/workflows/test-smoke.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Run TON Smoke Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: '0 3 * * *' # runs each night at 03:00 UTC
10+
11+
jobs:
12+
run-ton-smoke-tests:
13+
name: Run TON Smoke Tests in Chainlink CCIP
14+
runs-on: ubuntu-24.04
15+
permissions:
16+
id-token: write
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v5
20+
- name: Set Chainlink version
21+
id: set-version
22+
run: |
23+
# Default to the pinned version for PRs
24+
CHAINLINK_VERSION=$(cat ./scripts/.core_version | tr -d '[:space:]')
25+
26+
# If this is a scheduled (nightly) run, switch to develop
27+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
28+
CHAINLINK_VERSION="develop"
29+
fi
30+
31+
echo "chainlink_version=$CHAINLINK_VERSION" >> "$GITHUB_OUTPUT"
32+
- name: Setup GitHub Token
33+
id: setup-github-token
34+
uses: smartcontractkit/.github/actions/setup-github-token@setup-github-token/1.0.0
35+
with:
36+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN_WORKFLOWS_CHAINLINKCCIP }}
37+
aws-lambda-url: ${{ secrets.AWS_LAMBDA_URL_GATI_CHAINLINKCCIP }}
38+
aws-region: ${{ vars.AWS_REGION }}
39+
aws-role-duration-seconds: "1800"
40+
- name: Trigger Chainlink CCIP TON Smoke Tests
41+
env:
42+
GH_TOKEN: ${{ steps.setup-github-token.outputs.access-token }}
43+
# Deployment configuration
44+
WORKFLOW_FILE: .github/workflows/test_smoke.yml
45+
TARGET_REPO: smartcontractkit/chainlink-ccip
46+
TARGET_BRANCH: main
47+
TON_REF: ${{ github.head_ref || github.sha }}
48+
CHAINLINK_VERSION: ${{steps.set-version.outputs.chainlink_version}}
49+
# relative to chainlink-ccip/devenv. Assumes chainlink-ton is checked out to top level
50+
CUSTOM_CONFIG: env.toml,env-cl-rebuild-ci.toml,../chainlink-ton/devenv/ton.toml
51+
CONTRACT_VERSION: local
52+
run: |
53+
fetch_id() {
54+
gh run list \
55+
--repo "${TARGET_REPO}" \
56+
--workflow test_smoke.yml \
57+
--branch "${TARGET_BRANCH}" \
58+
--status in_progress \
59+
--json databaseId \
60+
--limit 1 \
61+
--jq '.[0].databaseId'
62+
}
63+
current_run_id=$(fetch_id)
64+
gh workflow run "${WORKFLOW_FILE}" \
65+
--repo "${TARGET_REPO}" \
66+
--ref "${TARGET_BRANCH}" \
67+
--field "ton_ref=${TON_REF}" \
68+
--field "chainlink_version=${CHAINLINK_VERSION}" \
69+
--field "contract_version=${CONTRACT_VERSION}" \
70+
--field "custom_config=${CUSTOM_CONFIG}"
71+
72+
new_run_id=""
73+
while [ -z "$new_run_id" ] || [ "$new_run_id" == "$current_run_id" ]; do
74+
echo "Waiting for new workflow run to start..."
75+
sleep 10
76+
new_run_id=$(fetch_id)
77+
done
78+
RUN_ID=$new_run_id
79+
80+
# Watch the run until complete
81+
gh run watch --repo "${TARGET_REPO}" $RUN_ID --exit-status

deployment/utils/chain.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strings"
78
"sync"
89
"testing"
910
"time"
1011

1112
"github.com/xssnick/tonutils-go/address"
13+
"github.com/xssnick/tonutils-go/liteclient"
1214
"github.com/xssnick/tonutils-go/tlb"
1315
"github.com/xssnick/tonutils-go/ton"
1416
"github.com/xssnick/tonutils-go/ton/wallet"
@@ -17,6 +19,7 @@ import (
1719
cldf_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/ton/provider"
1820

1921
"github.com/smartcontractkit/chainlink-ton/deployment/config"
22+
tonchainpkg "github.com/smartcontractkit/chainlink-ton/pkg/ton/chain"
2023
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
2124
)
2225

@@ -36,6 +39,14 @@ func GetLocalnetFunderWallet(client ton.APIClientWrapped) (*wallet.Wallet, error
3639
}
3740

3841
func FundWallets(t *testing.T, client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error {
42+
return FundWalletsWithCtx(t.Context(), client, recipients, amounts)
43+
}
44+
45+
func FundWalletsNoT(client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error {
46+
return FundWalletsWithCtx(context.Background(), client, recipients, amounts)
47+
}
48+
49+
func FundWalletsWithCtx(ctx context.Context, client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error {
3950
funder, err := GetLocalnetFunderWallet(client)
4051
if err != nil {
4152
return fmt.Errorf("failed to get prefunded wallet: %w", err)
@@ -53,16 +64,16 @@ func FundWallets(t *testing.T, client ton.APIClientWrapped, recipients []*addres
5364
}
5465
messages[i] = transfer
5566
}
56-
_, _, txerr := funder.SendManyWaitTransaction(t.Context(), messages)
67+
_, _, txerr := funder.SendManyWaitTransaction(ctx, messages)
5768
if txerr != nil {
5869
return fmt.Errorf("airdrop transaction failed: %w", txerr)
5970
}
6071

61-
err = waitForAirdropCompletion(t.Context(), client, recipients, amounts, 120*time.Second)
72+
err = waitForAirdropCompletion(ctx, client, recipients, amounts, 120*time.Second)
6273
if err != nil {
6374
return fmt.Errorf("airdrop completion verification failed: %w", err)
6475
}
65-
t.Logf("✓ %d funded successfully", len(recipients))
76+
fmt.Printf("✓ %d funded successfully\n", len(recipients))
6677
return nil
6778
}
6879

@@ -163,3 +174,27 @@ func StartChain(t *testing.T, chainID uint64, once *sync.Once) (cldf_ton.Chain,
163174

164175
return tonChain, nil
165176
}
177+
178+
func CreateClient(ctx context.Context, url string) (*ton.APIClient, error) {
179+
var client *ton.APIClient
180+
if strings.HasPrefix(url, "liteserver://") {
181+
pool, err := tonchainpkg.CreateLiteserverConnectionPool(ctx, url)
182+
if err != nil {
183+
return nil, fmt.Errorf("failed to create liteserver connection pool: %w", err)
184+
}
185+
client = ton.NewAPIClient(pool, ton.ProofCheckPolicyFast)
186+
} else {
187+
// connect via config URL
188+
cfg, err := liteclient.GetConfigFromUrl(ctx, url)
189+
if err != nil {
190+
return nil, fmt.Errorf("failed to get TON config: %w", err)
191+
}
192+
pool := liteclient.NewConnectionPool()
193+
err = pool.AddConnectionsFromConfig(ctx, cfg)
194+
if err != nil {
195+
return nil, fmt.Errorf("failed to connect to TON: %w", err)
196+
}
197+
client = ton.NewAPIClient(pool, ton.ProofCheckPolicyFast)
198+
}
199+
return client, nil
200+
}

devenv/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## CCIP16Devenv Implementation for TON network
2+
3+
Download [chainlink-ccip](https://github.com/smartcontractkit/chainlink-ccip) repository, build the CLI and run
4+
5+
```bash
6+
cd devenv
7+
just cli
8+
ccip up env.toml,../../chainlink-ton/devenv/ton.toml # static CL node version
9+
ccip up env.toml,env-cl-rebuild.toml,../../chainlink-ton/devenv/ton.toml # rebuild CL node
10+
ccip test smoke
11+
```

0 commit comments

Comments
 (0)