Open bymoses opened 3 months ago
@bymoses brilliant! Let me take a look at it 😎
There's also comment in tact repo by @wedvjin himself https://github.com/tact-lang/tact/issues/27#issuecomment-2124694217 It seems that devs has planned implementation of native upgrade mechanism to v1.4.0, but there's no assignee, so maybe we shouldn't rely on it
@bymoses This idea looks fantastic! Would you be willing to try writing this upgradeable contract pattern example and become one of the open-source contributors to tondynasty-contracts?
@alan890104 Sure, I've made basic commit at my fork https://github.com/Ton-Dynasty/tondynasty-contracts/commit/9e4ac701399542e01502c664b3f9c840420c3ee6 . Issue with 11 exit code is there, could you take a look at compiled funC code? I need some assistance here because I don't have experience with this language.
I've got some matters to handle these days, so I might not be able to check this for you until after Wednesday. In the meantime, could you please take a look at this webpage?
@bymoses There's a strange issue: when I call the get counter method (a GET method) after upgrading to v3, I encounter an exit code 9. This is quite unusual and seems to suggest there might be something hidden within the mechanism of the Tact language.
Ok, as far as I can tell we now have two options:
a. Off-chain computation of new storage cells. e.g. When you send UpgradeContract
, data field should be computed on your server and your storage will be overwriten with it.
b. On-chain migrations using lock mechanism:
_get_migrated_data
method (asm SETCODE instruction shedule code upgrade when the contract execution finished, so we need two contract calls here)_get_migrated_data
method and update storage@bymoses Thank you for the time you have invested. After discussing with other teams, instead of incorporating the trait for upgrading contracts into the tondynasty contract, I would suggest that the Tact compiler team include this trait as a built-in feature. This way, everyone can use it upon installation.
Disclaimer: Hi guys, I'm relative new to TON ecosystem but AFAIK there's no standardized approach for upgradable contracts in Tact.
Motivation
Motivation for this issue is to discuss some approaches for making contract upgrades here because tondynasty is relatively popular and it will be easier to find this information for newcomers.
Solution
A couple weeks ago @wedvjin created proof of concept repo. Using his example and tondynasty's traits approach I've created a basic Upgradable trait:
Limitations
https://github.com/wedvjin/ton-tact-contract-upgrade?tab=readme-ov-file#issue
@alan890104 @howardpen9 please take a look, maybe you have some different approaches for this