tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
388 stars 106 forks source link

Tact generated FunC code is not future proof #369

Open 0kenx opened 5 months ago

0kenx commented 5 months ago

Why does Tact generate the following FunC code:

slice __tact_verify_address(slice address) inline {
    throw_unless(136, address.slice_bits() == 267);
    var h = address.preload_uint(11);
    throw_if(137, h == 1279);
    throw_unless(136, h == 1024);
    return address;
}

Wouldn't that always fail when chain ID != 0 when in the future some addresses are from a different chain ID?

It should just generate

-    throw_unless(136, h == 1024);
+    throw_unless(136, h >> 8 == 2);
anton-trunov commented 4 months ago

@0kenx Would you like to open a PR and contribute this change?

0kenx commented 4 months ago

I can fix this single instance, but I believe a more systematic review of the codegen is necessary.

anton-trunov commented 4 months ago

Yep, codegen review is planned actually