Skip to content

Commit

Permalink
fix: large contracts compilation (tact-lang#297)
Browse files Browse the repository at this point in the history
I have used ton-blockchain/ton@4cfe1d1
to patch and compile the new WASM version of FunC.
In the patched version, the first argument to `PSTRING()` [here](https://github.com/ton-blockchain/ton/blob/4cfe1d1a96acf956e28e2bbc696a143489e23631/crypto/fift/utils.cpp#L215-L216) is built as an `std::string` first. Otherwise the wrapped `asm_code` gets truncated in WASM version.

* remove auto-generated file from git

* update src/imports/stdlib.ts -- looks like it wasn't updated in one the previous PRs

* current version fo FunC is 0.4.4, update generated pragmas

* fix a test: the new version of FunC has different gas consumption
occasionally
  • Loading branch information
anton-trunov authored Apr 25, 2024
1 parent 8e61206 commit f777da3
Show file tree
Hide file tree
Showing 10 changed files with 849 additions and 380 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist
output/
src/grammar/grammar.ohm-bundle.js
src/grammar/grammar.ohm-bundle.d.ts
src/func/funcfiftlib.wasm.js

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- FunC compilation errors when trying to `dump()` values of the `Cell`, `Slice`, `Builder` and `StringBuilder` types: PR [#271](https://github.com/tact-lang/tact/pull/271)
- Tact's CLI returns a non-zero exit code if compilation fails: PR [#278](https://github.com/tact-lang/tact/pull/278)
- Use the most recent version of the FunC standard library [`stdlib.fc`](https://github.com/ton-blockchain/ton/blob/4cfe1d1a96acf956e28e2bbc696a143489e23631/crypto/smartcont/stdlib.fc): PR [#283](https://github.com/tact-lang/tact/pull/283)
- The WASM version of the FunC compiler has been updated to 0.4.4 and patched to work on larger contracts: PR [#297](https://github.com/tact-lang/tact/pull/297)

## [1.2.0] - 2024-02-29

Expand Down
2 changes: 1 addition & 1 deletion src/func/funcfiftlib.js

Large diffs are not rendered by default.

Binary file modified src/func/funcfiftlib.wasm
Binary file not shown.
1 change: 0 additions & 1 deletion src/func/funcfiftlib.wasm.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/generator/writeProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export async function writeProgram(

const remainingFunctions = tryExtractModule(functions, null, imported);
const header: string[] = [];
header.push("#pragma version =0.4.3;");
header.push("#pragma version =0.4.4;");
header.push("#pragma allow-post-modification;");
header.push("#pragma compute-asm-ltr;");
header.push("");
Expand Down
745 changes: 376 additions & 369 deletions src/imports/stdlib.ts

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/test/__snapshots__/feature-try-catch.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`feature-ternary should implement try-catch statements correctly 1`] = `
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn",
"to": "kQBxrfQA9sLnV68zdLLcV-EkDzEs9jgV46pIuCfD3pobhwzw",
"type": "internal",
"value": "10",
},
Expand All @@ -45,14 +45,14 @@ exports[`feature-ternary should implement try-catch statements correctly 1`] = `
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn",
"to": "kQBxrfQA9sLnV68zdLLcV-EkDzEs9jgV46pIuCfD3pobhwzw",
"type": "internal",
"value": "10",
},
},
{
"$type": "processed",
"gasUsed": 4507n,
"gasUsed": 4564n,
},
],
},
Expand All @@ -72,14 +72,14 @@ exports[`feature-ternary should implement try-catch statements correctly 1`] = `
},
"bounce": true,
"from": "@treasure(treasure)",
"to": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn",
"to": "kQBxrfQA9sLnV68zdLLcV-EkDzEs9jgV46pIuCfD3pobhwzw",
"type": "internal",
"value": "10",
},
},
{
"$type": "processed",
"gasUsed": 12023n,
"gasUsed": 12080n,
},
{
"$type": "sent",
Expand All @@ -90,10 +90,10 @@ exports[`feature-ternary should implement try-catch statements correctly 1`] = `
"type": "text",
},
"bounce": true,
"from": "kQAZccETl-kyR0WEGf-7CT-k7zXmJGLmD8_jF9zsGay7wpHn",
"from": "kQBxrfQA9sLnV68zdLLcV-EkDzEs9jgV46pIuCfD3pobhwzw",
"to": "@treasure(treasure)",
"type": "internal",
"value": "9.986741",
"value": "9.986684",
},
],
},
Expand Down
3 changes: 2 additions & 1 deletion src/test/bugs/bugs.tact
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./issue42.tact";
import "./issue43.tact";
import "./issue53.tact";
import "./issue117.tact";
import "./issue117.tact";
import "./large-contract.tact";
Loading

0 comments on commit f777da3

Please sign in to comment.