From c04d8ef39fa3995e756825e8e1cc4be7b9b0f4c0 Mon Sep 17 00:00:00 2001 From: Jade Park Date: Tue, 15 Jul 2025 10:37:17 +0100 Subject: [PATCH 1/3] feat: TVM version update, add custom env --- .../framework/components/blockchains/ton.md | 16 +++++++++++++ framework/components/blockchain/blockchain.go | 2 ++ framework/components/blockchain/ton.go | 24 ++++++++++++++----- framework/examples/myproject/smoke_ton.toml | 2 +- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/book/src/framework/components/blockchains/ton.md b/book/src/framework/components/blockchains/ton.md index b8f1205b7..4f8046612 100644 --- a/book/src/framework/components/blockchains/ton.md +++ b/book/src/framework/components/blockchains/ton.md @@ -11,6 +11,21 @@ TON (The Open Network) support in the framework utilizes MyLocalTon Docker envir port = "8000" ``` +## Genesis Container Parameters + +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: + +```toml +[blockchain_a] + type = "ton" + image = "ghcr.io/neodix42/mylocalton-docker:latest" + port = "8000" + custom_env = { VERSION_CAPABILITIES = "11" } +``` + +The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed. +More info on parameters can be found here . + ## Default Ports The TON implementation exposes essential services: @@ -20,6 +35,7 @@ The TON implementation exposes essential services: > 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. + ## Usage ```go diff --git a/framework/components/blockchain/blockchain.go b/framework/components/blockchain/blockchain.go index acfd8694b..0b18cde09 100644 --- a/framework/components/blockchain/blockchain.go +++ b/framework/components/blockchain/blockchain.go @@ -61,6 +61,8 @@ type Input struct { // Optional params ImagePlatform *string `toml:"image_platform"` + // Custom environment variables for the container + CustomEnv map[string]string `toml:"custom_env"` } // Output is a blockchain network output, ChainID and one or more nodes that forms the network diff --git a/framework/components/blockchain/ton.go b/framework/components/blockchain/ton.go index e1db1b5db..59c30d632 100644 --- a/framework/components/blockchain/ton.go +++ b/framework/components/blockchain/ton.go @@ -63,6 +63,23 @@ func newTon(in *Input) (*Output, error) { return nil, err } networkName := network.Name + + baseEnv := map[string]string{ + "GENESIS": "true", + "NAME": "genesis", + "LITE_PORT": ports.LiteServer, + "CUSTOM_PARAMETERS": "--state-ttl 315360000 --archive-ttl 315360000", + "VERSION_CAPABILITIES": "11", + } + + // merge with additional environment variables from input + finalEnv := baseEnv + if in.CustomEnv != nil { + for key, value := range in.CustomEnv { + finalEnv[key] = value + } + } + req := testcontainers.ContainerRequest{ Image: in.Image, AlwaysPullImage: in.PullImage, @@ -77,12 +94,7 @@ func newTon(in *Input) (*Output, error) { Networks: []string{networkName}, NetworkAliases: map[string][]string{networkName: {"genesis"}}, Labels: framework.DefaultTCLabels(), - Env: map[string]string{ - "GENESIS": "true", - "NAME": "genesis", - "LITE_PORT": ports.LiteServer, // Note: exposed config file follows this env - "CUSTOM_PARAMETERS": "--state-ttl 315360000 --archive-ttl 315360000", - }, + Env: finalEnv, WaitingFor: wait.ForExec([]string{ "/usr/local/bin/lite-client", "-a", fmt.Sprintf("127.0.0.1:%s", ports.LiteServer), diff --git a/framework/examples/myproject/smoke_ton.toml b/framework/examples/myproject/smoke_ton.toml index 5e6e990a5..9584bdc7a 100644 --- a/framework/examples/myproject/smoke_ton.toml +++ b/framework/examples/myproject/smoke_ton.toml @@ -2,4 +2,4 @@ type = "ton" image = "ghcr.io/neodix42/mylocalton-docker:latest" port = "8000" - \ No newline at end of file + custom_env = { VERSION_CAPABILITIES = "11" } From 39cf623a128e450a969f4669ef9f710855253aab Mon Sep 17 00:00:00 2001 From: Jade Park Date: Tue, 15 Jul 2025 11:51:34 +0100 Subject: [PATCH 2/3] chore: add changeset --- framework/.changeset/v0.10.4.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 framework/.changeset/v0.10.4.md diff --git a/framework/.changeset/v0.10.4.md b/framework/.changeset/v0.10.4.md new file mode 100644 index 000000000..807106b4a --- /dev/null +++ b/framework/.changeset/v0.10.4.md @@ -0,0 +1 @@ +- TON blockchain support to enable TVM version configuration and adds custom environment variable support \ No newline at end of file From f5383936b753095e00f2923cd672336a54ee640d Mon Sep 17 00:00:00 2001 From: Jade Park Date: Tue, 15 Jul 2025 12:08:19 +0100 Subject: [PATCH 3/3] fix: refine TON toml --- book/src/framework/components/blockchains/ton.md | 4 +++- framework/examples/myproject/smoke_ton.toml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/book/src/framework/components/blockchains/ton.md b/book/src/framework/components/blockchains/ton.md index 4f8046612..a861b1146 100644 --- a/book/src/framework/components/blockchains/ton.md +++ b/book/src/framework/components/blockchains/ton.md @@ -20,7 +20,9 @@ The genesis container supports additional environment variables that can be conf type = "ton" image = "ghcr.io/neodix42/mylocalton-docker:latest" port = "8000" - custom_env = { VERSION_CAPABILITIES = "11" } + + [blockchain_a.custom_env] + VERSION_CAPABILITIES = "11" ``` The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed. diff --git a/framework/examples/myproject/smoke_ton.toml b/framework/examples/myproject/smoke_ton.toml index 9584bdc7a..88a108d8d 100644 --- a/framework/examples/myproject/smoke_ton.toml +++ b/framework/examples/myproject/smoke_ton.toml @@ -2,4 +2,6 @@ type = "ton" image = "ghcr.io/neodix42/mylocalton-docker:latest" port = "8000" - custom_env = { VERSION_CAPABILITIES = "11" } + + [blockchain_a.custom_env] + VERSION_CAPABILITIES = "11"