Skip to content

Commit ace64fd

Browse files
authored
TON: TVM version update, add custom env field (#1981)
* feat: TVM version update, add custom env * chore: add changeset * fix: refine TON toml
1 parent 8ff0c57 commit ace64fd

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

book/src/framework/components/blockchains/ton.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ TON (The Open Network) support in the framework utilizes MyLocalTon Docker envir
1111
port = "8000"
1212
```
1313

14+
## Genesis Container Parameters
15+
16+
The genesis container supports additional environment variables that can be configured through the `custom_env` field. These parameters allow you to customize the blockchain behavior:
17+
18+
```toml
19+
[blockchain_a]
20+
type = "ton"
21+
image = "ghcr.io/neodix42/mylocalton-docker:latest"
22+
port = "8000"
23+
24+
[blockchain_a.custom_env]
25+
VERSION_CAPABILITIES = "11"
26+
```
27+
28+
The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed.
29+
More info on parameters can be found here <https://github.com/neodix42/mylocalton-docker/wiki/Genesis-setup-parameters>.
30+
1431
## Default Ports
1532

1633
The TON implementation exposes essential services:
@@ -20,6 +37,7 @@ The TON implementation exposes essential services:
2037

2138
> Note: `tonutils-go` library is used for TON blockchain interactions, which requires a TON Lite Server connection. `tonutils-go` queries config file to determine the Lite Server connection details, which are provided by the MyLocalTon Docker environment.
2239
40+
2341
## Usage
2442

2543
```go

framework/.changeset/v0.10.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- TON blockchain support to enable TVM version configuration and adds custom environment variable support

framework/components/blockchain/blockchain.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type Input struct {
6161

6262
// Optional params
6363
ImagePlatform *string `toml:"image_platform"`
64+
// Custom environment variables for the container
65+
CustomEnv map[string]string `toml:"custom_env"`
6466
}
6567

6668
// Output is a blockchain network output, ChainID and one or more nodes that forms the network

framework/components/blockchain/ton.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ func newTon(in *Input) (*Output, error) {
6363
return nil, err
6464
}
6565
networkName := network.Name
66+
67+
baseEnv := map[string]string{
68+
"GENESIS": "true",
69+
"NAME": "genesis",
70+
"LITE_PORT": ports.LiteServer,
71+
"CUSTOM_PARAMETERS": "--state-ttl 315360000 --archive-ttl 315360000",
72+
"VERSION_CAPABILITIES": "11",
73+
}
74+
75+
// merge with additional environment variables from input
76+
finalEnv := baseEnv
77+
if in.CustomEnv != nil {
78+
for key, value := range in.CustomEnv {
79+
finalEnv[key] = value
80+
}
81+
}
82+
6683
req := testcontainers.ContainerRequest{
6784
Image: in.Image,
6885
AlwaysPullImage: in.PullImage,
@@ -77,12 +94,7 @@ func newTon(in *Input) (*Output, error) {
7794
Networks: []string{networkName},
7895
NetworkAliases: map[string][]string{networkName: {"genesis"}},
7996
Labels: framework.DefaultTCLabels(),
80-
Env: map[string]string{
81-
"GENESIS": "true",
82-
"NAME": "genesis",
83-
"LITE_PORT": ports.LiteServer, // Note: exposed config file follows this env
84-
"CUSTOM_PARAMETERS": "--state-ttl 315360000 --archive-ttl 315360000",
85-
},
97+
Env: finalEnv,
8698
WaitingFor: wait.ForExec([]string{
8799
"/usr/local/bin/lite-client",
88100
"-a", fmt.Sprintf("127.0.0.1:%s", ports.LiteServer),

framework/examples/myproject/smoke_ton.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
type = "ton"
33
image = "ghcr.io/neodix42/mylocalton-docker:latest"
44
port = "8000"
5-
5+
6+
[blockchain_a.custom_env]
7+
VERSION_CAPABILITIES = "11"

0 commit comments

Comments
 (0)