tact-lang / tact

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

Document Tact language limitations due to blockchain/TVM/validator limitations #1097

Open anton-trunov opened 8 months ago

anton-trunov commented 8 months ago

For instance, how large maps can be, etc.

0kenx commented 7 months ago

This limit is contradictory to our tests. We deployed a contract on testnet and added 66k entries to a map.

https://testnet.tonviewer.com/kQDrXvmitxbGvjpXwRtc5NMuN_4tDkJ83f3myVK04VrviF2v

import "@stdlib/deploy";
import "@stdlib/ownable";
import "./utils/transfer_helpers";

message Increment {
    count: Int;
}

contract MapOnlineTest with Deployable, OwnableTransferable {
    const STORAGE_GAS_RESERVE: Int = ton("0.2");

    owner: Address;
    logo: Int;
    total_map: map<Int, Int>;
    total: Int = 0;

    init(owner: Address, logo: Int) {
        self.owner = owner;
        self.logo = logo;
    }

    receive("fund gas") {}

    receive(msg: Increment) {
        self.requireOwner();
        repeat (msg.count) {
            self.total_map.set(self.total, 1);
            self.total = self.total + 1;
        }

    }

    receive("withdraw dust") {
        self.requireOwner();
        send_ton(
            self.owner,
            myBalance() - self.STORAGE_GAS_RESERVE, 
            false,
            "Dust withdrawn".asComment()
        );
    }

    get fun balance(): Int {
        return myBalance();
    }

    get fun total(): Int {
        return self.total;
    }

    get fun total_map(index: Int): Int? {
        return self.total_map.get(index);
    }
}