Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: check all combinations of internal, external and bounced receivers for "empty" messages #1949

Merged
merged 38 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6300997
feat: first version of tests. Still missing the deploy instructions i…
jeshecdom Feb 18, 2025
e7abd25
tests: incomplete tests on external receivers.
jeshecdom Feb 21, 2025
50d3510
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 21, 2025
a5dd0d9
tests: external receivers tests.
jeshecdom Feb 21, 2025
2b9334a
chore: comment fixes.
jeshecdom Feb 21, 2025
046c3c4
Merge remote-tracking branch 'origin/main' into jeshecdom/empty-strin…
Kaladin13 Feb 24, 2025
293ee86
add fallback text receiver opcode correctness check
Kaladin13 Feb 24, 2025
d5eade6
fix: fix bug with not accounting for empty receiver
Kaladin13 Feb 24, 2025
b7229ef
chore: removed comment about slice external receivers not yet impleme…
jeshecdom Feb 24, 2025
1a7e393
add is_loaded check
Kaladin13 Feb 24, 2025
a061c7e
Merge remote-tracking branch 'origin/main' into jeshecdom/empty-strin…
Kaladin13 Feb 24, 2025
3ba8a48
fix: change results
Kaladin13 Feb 24, 2025
934c16a
lint
Kaladin13 Feb 24, 2025
7ee09e1
Merge remote-tracking branch 'origin/main' into jeshecdom/empty-strin…
Kaladin13 Feb 24, 2025
71e70ba
fix double return
Kaladin13 Feb 24, 2025
8066079
tests: added bounced receivers cases.
jeshecdom Feb 24, 2025
26e3c61
Merge branch 'jeshecdom/empty-string-receiver' of https://github.com/…
jeshecdom Feb 24, 2025
b46fe1d
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 24, 2025
ec1ae3b
tests: sending to emptyReceivers instead of noreceivers in bounced re…
jeshecdom Feb 24, 2025
6ce4dbd
tests: added message struct with empty string inside.
jeshecdom Feb 24, 2025
3d13812
tests: Added tests for empty message struct.
jeshecdom Feb 25, 2025
aa9c4a7
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 25, 2025
ce95d3e
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 26, 2025
e88d088
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 26, 2025
1fe82b9
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 26, 2025
f5d2441
fix: update benchmarks (again)
Kaladin13 Feb 26, 2025
a451057
Merge branch 'main' into jeshecdom/empty-string-receiver
jeshecdom Feb 26, 2025
096693d
fix
novusnota Feb 26, 2025
bf261cb
Merge branch 'main' into jeshecdom/empty-string-receiver
novusnota Feb 26, 2025
4e5d2b4
fix snapshots
novusnota Feb 26, 2025
36e3fd3
Merge branch 'main' into jeshecdom/empty-string-receiver
anton-trunov Feb 26, 2025
017ff5c
Merge branch 'jeshecdom/empty-string-receiver' of github.com:tact-lan…
novusnota Feb 26, 2025
59b3b0b
fix snapshot
anton-trunov Feb 26, 2025
7990593
optimize router a bit
anton-trunov Feb 26, 2025
008de9b
add jetton benchmark to yarn test:fast
anton-trunov Feb 26, 2025
3941363
Merge branch 'main' into jeshecdom/empty-string-receiver
anton-trunov Feb 26, 2025
cccc6ce
Merge branch 'main' into jeshecdom/empty-string-receiver
anton-trunov Feb 26, 2025
f59431a
optimize parsing msg opcodes when there are only binary receivers
anton-trunov Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion jest-fast.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
"/src/test/e2e-emulated/map*",
"/src/cli/e2e.spec.ts",
"/src/ast/fuzz.spec.ts",
"/src/test/benchmarks/jetton/jetton.spec.ts",
],
maxWorkers: "8",
};
9 changes: 9 additions & 0 deletions src/generator/writers/writeContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import type { ItemOrigin } from "../../imports/source";
import { resolveFuncTypeFromAbiUnpack } from "./resolveFuncTypeFromAbiUnpack";
import { getAllocation } from "../../storage/resolveAllocation";
import { contractErrors } from "../../abi/errors";

const SMALL_CONTRACT_MAX_FIELDS = 5;

Expand Down Expand Up @@ -393,6 +394,14 @@ export function writeMainContract(
wCtx.append();
}

wCtx.append(";; message opcode reader utility");
wCtx.append(
`;; Returns 32 bit message opcode, otherwise throws the "Invalid incoming message" exit code`,
);
wCtx.append(
`(slice, int) ~load_opcode(slice s) asm( -> 1 0) "32 LDUQ ${contractErrors.invalidMessage.id} THROWIFNOT";`,
);

wCtx.append(`;;`);
wCtx.append(`;; Routing of a Contract ${contract.name}`);
wCtx.append(`;;`);
Expand Down
24 changes: 14 additions & 10 deletions src/generator/writers/writeRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export function writeNonBouncedRouter(
typeof receivers.fallback !== "undefined" &&
receivers.binary.length === 0 &&
receivers.comment.length === 0 &&
typeof receivers.commentFallback === "undefined"
typeof receivers.commentFallback === "undefined" &&
typeof receivers.empty === "undefined"
) {
writeFallbackReceiver(receivers.fallback, contract, "in_msg", wCtx);
return;
Expand All @@ -91,7 +92,7 @@ export function writeNonBouncedRouter(
typeof receivers.commentFallback === "undefined" &&
typeof receivers.fallback === "undefined"
) {
wCtx.append(`var (op, _) = in_msg~load_uint_quiet(32);`);
wCtx.append("var op = in_msg~load_opcode();");

writeBinaryReceivers(true);

Expand Down Expand Up @@ -216,14 +217,17 @@ function writeCommentReceivers(
) => {
const writeFallbackTextReceiverInternal = () => {
wCtx.append(";; Fallback Text Receiver");
const inMsg = msgOpcodeRemoved ? "in_msg" : "in_msg.skip_bits(32)";
writeFallbackReceiver(
commentFallbackReceiver,
contract,
inMsg,
wCtx,
);
wCtx.append("return ();");
wCtx.inBlock("if (in_msg_length >= 32)", () => {
const inMsg = msgOpcodeRemoved
? "in_msg"
: "in_msg.skip_bits(32)";
writeFallbackReceiver(
commentFallbackReceiver,
contract,
inMsg,
wCtx,
);
});
};

// We optimize fallback
Expand Down
8 changes: 4 additions & 4 deletions src/test/benchmarks/__snapshots__/benchmarks.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ exports[`benchmarks benchmark codeOf vs myCode(): gas used myCode 1`] = `931n`;

exports[`benchmarks benchmark contractAddressExt: gas used contractAddressExt 1`] = `2589n`;

exports[`benchmarks benchmark deployable trait vs raw deploy: gas used deploy trait 1`] = `4576`;
exports[`benchmarks benchmark deployable trait vs raw deploy: gas used deploy trait 1`] = `4548`;

exports[`benchmarks benchmark deployable trait vs raw deploy: gas used raw deploy 1`] = `1585`;

exports[`benchmarks benchmark functions: code size 1`] = `184`;
exports[`benchmarks benchmark functions: code size 1`] = `183`;

exports[`benchmarks benchmark functions: gas used 1`] = `2236`;
exports[`benchmarks benchmark functions: gas used 1`] = `2208`;

exports[`benchmarks benchmark readFwdFee: code size 1`] = `120`;

exports[`benchmarks benchmark readFwdFee: gas used 1`] = `2058`;
exports[`benchmarks benchmark readFwdFee: gas used 1`] = `2048`;

exports[`benchmarks benchmark sha256: gas hash string big 1`] = `2562`;

Expand Down
10 changes: 10 additions & 0 deletions src/test/benchmarks/escrow/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"approveTon": "9418",
"cancelTon": "7144"
}
},
{
"label": "1.5.3 with fixed routing",
"pr": "https://github.com/tact-lang/tact/pull/1949",
"gas": {
"fundingTon": "4988",
"changeCode": "5194",
"approveTon": "9390",
"cancelTon": "7116"
}
}
]
}
9 changes: 9 additions & 0 deletions src/test/benchmarks/jetton/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@
"burn": "12123",
"discovery": "7052"
}
},
{
"label": "1.5.3 with fixed routing",
"pr": "https://github.com/tact-lang/tact/pull/1949",
"gas": {
"transfer": "16036",
"burn": "12067",
"discovery": "7024"
}
}
]
}
Loading
Loading