Skip to content

Commit 1f7d3b7

Browse files
committed
Merge branch 'main' into issue716v2
2 parents ded0d2f + cbef14d commit 1f7d3b7

File tree

309 files changed

+19708
-10440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+19708
-10440
lines changed

.eslintrc.cjs

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ module.exports = {
1515
es2021: true,
1616
},
1717
rules: {
18+
"@typescript-eslint/consistent-type-imports": [
19+
"error",
20+
{
21+
prefer: "type-imports",
22+
fixStyle: "separate-type-imports",
23+
disallowTypeAnnotations: true,
24+
},
25+
],
1826
"@typescript-eslint/no-unused-vars": [
1927
"error",
2028
{

.github/actions/test/action.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "Setup Node.js"
2+
description: "Set up Node.js and install dependencies"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Checkout repository
7+
uses: actions/checkout@v4
8+
9+
- name: Setup Node.js ${{ matrix.node-version }}
10+
uses: actions/setup-node@v4
11+
with:
12+
node-version: ${{ matrix.node-version }}
13+
cache: "yarn"
14+
15+
- name: Install dependencies
16+
shell: bash
17+
run: |
18+
corepack enable
19+
yarn install
20+
21+
- name: List installed packages
22+
shell: bash
23+
run: |
24+
yarn list
25+
26+
- name: Print some environment info
27+
shell: bash
28+
run: |
29+
yarn cross-env echo $NODE_ENV
30+
31+
- name: Build Tact compiler
32+
shell: bash
33+
run: |
34+
yarn clean
35+
yarn gen
36+
yarn build
37+
38+
- name: Test Tact compiler
39+
shell: bash
40+
run: |
41+
yarn coverage
42+
43+
- name: Show an example .pkg file on Windows
44+
shell: pwsh
45+
if: runner.os == 'Windows'
46+
run: |
47+
type examples\output\echo_Echo.pkg
48+
49+
- name: Link Tact yarn package
50+
shell: bash
51+
run: |
52+
yarn link

.github/workflows/external-links.yml

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Link check
1+
name: External link check
22

33
on:
44
workflow_dispatch: # on demand launches, if needed
@@ -22,9 +22,15 @@ jobs:
2222
--exclude '\.(?:jpg|png)$'
2323
docs/README.md './docs/**/*.mdx'
2424
output: "/dev/stdout"
25-
fail: false
25+
fail: true
2626
failIfEmpty: false
2727

28+
linkcheck-dev:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
2834
- name: (dev-docs) Check broken HTTP(S) links
2935
uses: lycheeverse/lychee-action@v2
3036
id: lychee_dev
@@ -34,5 +40,22 @@ jobs:
3440
--exclude-path node_modules --exclude-path docs
3541
'./**/*.md'
3642
output: "/dev/stdout"
37-
fail: false
43+
fail: true
44+
failIfEmpty: false
45+
46+
linkcheck-stdlib:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: (stdlib) Check broken HTTP(S) links in doc comments
53+
uses: lycheeverse/lychee-action@v2
54+
id: lychee_dev
55+
with:
56+
args: >
57+
-n -s https -s http
58+
'./src/stdlib/stdlib/**/*.tact'
59+
output: "/dev/stdout"
60+
fail: true
3861
failIfEmpty: false

.github/workflows/tact.yml

+27-38
Original file line numberDiff line numberDiff line change
@@ -76,54 +76,43 @@ jobs:
7676
fail-fast: false
7777
matrix:
7878
node-version: [22]
79-
os: [ubuntu-latest, windows-latest, macos-latest]
79+
os: [ubuntu-latest, macos-latest]
8080
runs-on: ${{ matrix.os }}
8181
steps:
82-
- name: Checkout repository
83-
uses: actions/checkout@v4
84-
85-
- name: Setup Node.js ${{ matrix.node-version }}
86-
uses: actions/setup-node@v4
87-
with:
88-
node-version: ${{ matrix.node-version }}
89-
cache: "yarn"
90-
91-
- name: Install dependencies
82+
- uses: actions/checkout@v4
83+
- uses: ./.github/actions/test
84+
- name: Test compatibility with tact-template
9285
run: |
93-
corepack enable
86+
# !!!!!!! Don't forget to update test-windows below !!!!!!!
87+
git clone https://github.com/tact-lang/tact-template.git
88+
cd tact-template
89+
# Hijack the dependency on Tact to avoid redundant npm downloads
90+
jq 'del(.dependencies."@tact-lang/compiler")' package.json -M > temp.json
91+
mv temp.json package.json
9492
yarn install
95-
96-
- name: List installed packages
97-
run: |
98-
yarn list
99-
100-
- name: Print some environment info
101-
run: |
102-
yarn cross-env echo $NODE_ENV
103-
104-
- name: Build Tact compiler
105-
run: |
106-
yarn clean
107-
yarn gen
93+
yarn link @tact-lang/compiler
10894
yarn build
95+
yarn test
10996
110-
- name: Test Tact compiler
111-
run: |
112-
yarn coverage
113-
114-
- name: Show an example .pkg file on Windows
115-
if: runner.os == 'Windows'
116-
run: |
117-
type examples\output\echo_Echo.pkg
118-
119-
- name: Link Tact yarn package
120-
run: |
121-
yarn link
122-
97+
test-windows:
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
node-version: [22]
102+
os: [windows-latest]
103+
runs-on: ${{ matrix.os }}
104+
steps:
105+
- uses: actions/checkout@v4
106+
- uses: ./.github/actions/test
123107
- name: Test compatibility with tact-template
124108
run: |
109+
# !!!!!!! Don't forget to update test above !!!!!!!
110+
$ErrorActionPreference = 'Stop'
125111
git clone https://github.com/tact-lang/tact-template.git
126112
cd tact-template
113+
# Hijack the dependency on Tact to avoid redundant npm downloads
114+
jq 'del(.dependencies."@tact-lang/compiler")' package.json -M | Set-Content temp.json
115+
Move-Item temp.json package.json -Force
127116
yarn install
128117
yarn link @tact-lang/compiler
129118
yarn build

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ A next-gen smart contract language for TON focused on efficiency and simplicity.
1414
- [Tact Documentation](https://docs.tact-lang.org)
1515
- [Awesome Tact](https://github.com/tact-lang/awesome-tact)
1616

17+
## Security
18+
19+
- [Security audit of Tact by the Trail of Bits (2025, PDF)](https://tact-lang.org/assets/pdfs/2025-01-ton-studio-tact-compiler-securityreview.pdf)
20+
- Backup link: [PDF Report](https://github.com/tact-lang/website/blob/416073ed4056034639de257cb1e2815227f497cb/pdfs/2025-01-ton-studio-tact-compiler-securityreview.pdf)
21+
1722
## Community
1823

1924
- [Tact Discussion Group](https://t.me/tactlang)

dev-docs/CHANGELOG.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- `nullChecks` config option to disable run-time null checks for the `!!` operator in order to save gas: PR [#1660](https://github.com/tact-lang/tact/pull/1660)
2525
- `loadVarInt16`, `loadVarUint16`, `loadVarInt32`, `loadVarUint32` methods for the `Slice` type: PR [#1667](https://github.com/tact-lang/tact/pull/1667)
2626
- New functions in stdlib from `stdlib.fc` and `math.fc`: `Builder.depth`, `Slice.skipLastBits`, `Slice.firstBits`, `Slice.lastBits`, `Slice.depth`, `Cell.computeDataSize`, `Slice.computeDataSize`, `Cell.depth`, `curLt`, `blockLt`, `setGasLimit`, `getSeed`, `setSeed`, `myCode`, `sign`, `divc`, `muldivc`, `mulShiftRight`, `mulShiftRightRound`, `mulShiftRightCeil`, `sqrt`: PR [#986](https://github.com/tact-lang/tact/pull/986)
27+
- The `--output` CLI flag for specifying custom output directory in single-contract compilation: PR [#1793](https://github.com/tact-lang/tact/pull/1793)
28+
- New functions `Slice.asAddressUnsafe` and `contractHash` in stdlib: PR [#1766](https://github.com/tact-lang/tact/pull/1766)
2729

2830
### Changed
2931

@@ -45,6 +47,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4547
- Better error message for `unresolved name` error: PR [#1595](https://github.com/tact-lang/tact/pull/1595)
4648
- Better error message for `unresolved global function` error: PR [#1610](https://github.com/tact-lang/tact/pull/1610)
4749
- Better error message for `extend function without parameters` error: PR [#1624](https://github.com/tact-lang/tact/pull/1624)
50+
- Don't generate `lazy_deployment_completed` by default: PR [#1717](https://github.com/tact-lang/tact/pull/1717)
51+
- Optimized `emptyCell()` and `emptySlice()` functions: PR [#1696](https://github.com/tact-lang/tact/pull/1696)
52+
- Internal `crc16` function is now verifiable and covered with tests: PR [#1739](https://github.com/tact-lang/tact/pull/1739)
53+
- Rearrange parameters of some asm methods in order described in `AsmShuffle`: PR [#1702](https://github.com/tact-lang/tact/pull/1702)
54+
- Error message for invalid type for function argument now shows expected type: PR [#1738](https://github.com/tact-lang/tact/pull/1738)
4855

4956
### Fixed
5057

@@ -80,13 +87,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8087
- Runtime `sha256` now work for arbitrary strings with length >= 128: PR [#1626](https://github.com/tact-lang/tact/pull/1626)
8188
- Generated code in TypeScript wrappers for contract with `init(init: Init)`: PR [#1709](https://github.com/tact-lang/tact/pull/1709)
8289
- Error message for comment (text) receivers with 124 bytes or more: PR [#1711](https://github.com/tact-lang/tact/pull/1711)
90+
- Support overriding constants and methods of BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
91+
- Forbid traits inherit implicitly from BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
92+
- Forbid the `override` modifier for constants without the corresponding super-constant: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
93+
- Check map types for `deepEquals` method: PR [#1718](https://github.com/tact-lang/tact/pull/1718)
94+
- Remove "remainder" from error messages: PR [#1699](https://github.com/tact-lang/tact/pull/1699)
95+
- Check map types for `deepEquals` method: PR [#1718](https://github.com/tact-lang/tact/pull/1718)
8396

8497
### Docs
8598

8699
- Added the `description` property to the frontmatter of the each page for better SEO: PR [#916](https://github.com/tact-lang/tact/pull/916)
87100
- Added Google Analytics tags per every page: PR [#921](https://github.com/tact-lang/tact/pull/921)
88101
- Added Ston.fi cookbook: PR [#956](https://github.com/tact-lang/tact/pull/956)
89-
- Added NFTs cookbook: PR [#958](https://github.com/tact-lang/tact/pull/958)
102+
- Added NFTs cookbook: PR [#958](https://github.com/tact-lang/tact/pull/958), PR [#1747](https://github.com/tact-lang/tact/pull/1747)
90103
- Added security best practices: PR [#1070](https://github.com/tact-lang/tact/pull/1070)
91104
- Added automatic links to Web IDE from all code blocks: PR [#994](https://github.com/tact-lang/tact/pull/994)
92105
- Added initial semi-automated Chinese translation of the documentation: PR [#942](https://github.com/tact-lang/tact/pull/942)
@@ -116,9 +129,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
116129
- Removed the notion of the non-standard TL-B syntax `remainder<X>`: PR [#1599](https://github.com/tact-lang/tact/pull/1599)
117130
- Added description of `.boc`, `.ts`, `.abi`, `.pkg` files and completed Compilation page: PR [#1676](https://github.com/tact-lang/tact/pull/1676)
118131
- Marked gas-expensive functions and expressions: PR [#1703](https://github.com/tact-lang/tact/pull/1703)
132+
- Added a Security audits page, with the first assessment from the Trail of Bits: PR [#1791](https://github.com/tact-lang/tact/pull/1791)
133+
- Listed functions with implicit mode and further clarified the interactions of message sending functions and their modes: PR [#1634](https://github.com/tact-lang/tact/pull/1634)
119134

120135
### Release contributors
121136

137+
## [1.5.4] - 2025-02-04
138+
139+
### Fixed
140+
141+
- Allowed importing FunC files with `.func` extension. Resolves the `TOB-TACT-1` issue
142+
- Issue understandable error on circular trait dependencies. Resolves the `TOB-TACT-2` issue
143+
- Forbade accessing files via symlinks. Resolves the `TOB-TACT-3` issue
144+
- Bit shift FunC compilation errors for incorrect bit widths. Partially resolves the `TOB-TACT-5` issue
145+
- Streamlined `renameModuleItems` function. Resolves the `TOB-TACT-6` issue
146+
- Documented the parser limitations for nested expressions. Alleviates the `TOB-TACT-7` issue
147+
- Bit shift FunC compilation errors for incorrect bit widths
148+
- Throwing from functions with non-trivial branching in the `try` statement
149+
150+
### Notes
151+
152+
Handling the Unicode in the Tact grammar as per the `TOB-TACT-4` issue has been left unchanged and will be addressed in the future Tact releases.
153+
154+
### Release contributors
155+
156+
- [Anton Trunov](https://github.com/anton-trunov): security audit fixes
157+
- [@verytactical](https://github.com/verytactical): internal review of the security audit fixes
158+
- [Trail of Bits](https://www.trailofbits.com): the security audit of the Tact compiler v1.5.0 (commit 0106ea14857bcf3c40dd10135243d0de96012871) and the audit of the fixes
159+
122160
## [1.5.3] - 2024-11-28
123161

124162
### Changed

dev-docs/CONTRIBUTING.md

-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ Some other codegen tests are as follows:
210210

211211
The entry point to the Tact AST pretty-printer is [src/ast/ast-printer.ts](../src/ast/ast-printer.ts). It is going to be used for the Tact source code formatter once the parser keeps comments and other relevant information.
212212

213-
The AST comparator is defined in [src/ast/compare.ts](../src/ast/compare.ts). This is useful, for instance, for static analysis tools which can re-use the Tact TypeScript API.
214-
215213
The corresponding test spec files can be found in [src/test](../src/test) folder with the test contracts in [src/test/contracts](../src/test/contracts) folder.
216214

217215
## Build scripts and test helpers

docs/astro.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export default defineConfig({
285285
},
286286
items: [
287287
{ slug: 'ecosystem' },
288+
{ slug: 'ecosystem/security-audits' },
288289
{
289290
label: 'Tools',
290291
translations: { 'zh-CN': '工具' },

docs/package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,11 @@
3131
"unist-util-visit": "^5.0.0"
3232
},
3333
"packageManager": "[email protected]",
34-
"version": ""
34+
"version": "",
35+
"resolutions": {
36+
"esbuild": "^0.25.0"
37+
},
38+
"overrides": {
39+
"esbuild": "^0.25.0"
40+
}
3541
}

docs/src/content/docs/book/assembly-functions.mdx

+9-3
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ When there are literals involved, they'll be shown as is. Additionally, when val
478478

479479
```tact
480480
// Computes and returns the Keccak-256 hash as an 256-bit unsigned `Int`
481-
// from a passed `Slice` `s`. Uses the Ethereum-compatible implementation.
481+
// from a passed `Slice` `s`. Uses the Ethereum-compatible* implementation.
482482
asm fun keccak256(s: Slice): Int {
483483
// s:Slice → s:Slice, 1
484484
// —————————————————————
@@ -498,8 +498,8 @@ The [`HASHEXT_KECCAK512`](https://docs.ton.org/v3/documentation/tvm/instructions
498498

499499
```tact
500500
// Computes and returns the Keccak-512 hash in two 256-bit unsigned `Int`
501-
// values from a passed `Slice` `s`. Uses the Ethereum-compatible implementation.
502-
asm fun keccak256(s: Slice): Hash512 {
501+
// values from a passed `Slice` `s`. Uses the Ethereum-compatible* implementation.
502+
asm fun keccak512(s: Slice): Hash512 {
503503
// s:Slice → s:Slice, 1
504504
// —————————————————————
505505
// s0 → s1 s0
@@ -520,6 +520,12 @@ asm fun keccak256(s: Slice): Hash512 {
520520
struct Hash512 { h1: Int; h2: Int }
521521
```
522522

523+
While it is said that these sample `keccak256(){:tact}` and `keccak512(){:tact}` functions use the Ethereum-compatible implementation, note that the underlying `HASHEXT` family of [TVM][tvm] instructions has its own drawbacks.
524+
525+
These drawbacks stem from the limitations of the [`Slice{:tact}`][slice] type itself — `HASHEXT_KECCAK256` and other hashing instructions of the `HASHEXT` family ignore any references present in the passed slice(s), i.e. only up to $1023$ bits of its data are used.
526+
527+
To work around this, you can recursively load all the refs from the given [`Slice{:tact}`][slice], and then hash them all at once by specifying their exact number instead of the `ONE` [TVM][tvm] instruction used earlier. See an example below: [`onchainSha256`](#onchainsha256).
528+
523529
:::note[Useful links:]
524530

525531
[`HASHEXT_KECCAK256`](https://docs.ton.org/v3/documentation/tvm/instructions#F90403)\

docs/src/content/docs/book/compile.mdx

+9-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ If you want to pin down a specific version of the compiler, run the following co
9595

9696
A number of build artifacts can be produced per compilation of each contract. Some of the artifacts can be omitted using [configuration settings](/book/config).
9797

98-
The location of the artifacts depends on the [`output`](/book/config#projects-output) field of the [`tact.config.json`](/book/config). In [Blueprint][bp]-based projects, `output` is not used and all generated files are always placed in `build/ProjectName/`.
98+
The location of the artifacts depends on the compilation method:
99+
- For projects using `tact.config.json`, use the [`output`](/book/config#projects-output) field in the config file
100+
- For single contract compilation, you can specify the output directory using the `-o` or `--output` flag:
101+
```shell
102+
tact contract.tact --output ./custom-output
103+
```
104+
If not specified, the files will be generated in the same directory as the input file.
105+
106+
In [Blueprint][bp]-based projects, `output` is not used and all generated files are always placed in `build/ProjectName/`.
99107

100108
### Compilation report, `.md` {#report}
101109

0 commit comments

Comments
 (0)