PolymeshAssociation / Polymesh

Node for Polymesh Blockchain
https://polymesh.network/
GNU General Public License v3.0
165 stars 47 forks source link

Upgrade contracts to ink! 4.0 #1402

Closed HCastano closed 10 months ago

HCastano commented 1 year ago

Hi there!

I was looking through some of your contracts and noticed that you're still using ink! 3.x.

We released ink! 4.0 recently and it would probably be worth your time to update. We wrote a migration guide to help out.

Neopallium commented 1 year ago

Thanks for the great work on Ink! and the new release. I look forward to using 4.0.

We can't upgrade the contracts to 4.0 yet. Our current Substrate version (pallet-contracts) doesn't have the some of the new stabilized storage APIs that Ink! 4.0 needs.

We do have a PR ready to upgrade Substrate, but there are some other things we plan on releasing before merging and updating the chain with the newer Substrate release.

Neopallium commented 1 year ago

Also you might be interested in the contracts in this PR: https://github.com/PolymeshAssociation/Polymesh/pull/1393

I see that Ink! has a PR to add support for call_runtime. We use our ChainExtension instead of call_runtime (because we have to swap from the caller's identity to the contract's identity). Any contract that calls into the chain runtime, either needs to be upgradable or wrap the code that calls the runtime in an upgradable contract.

Since we wanted to provide a way for contract's to keep working even after major chain updates (i.e. breaking type/call API changes), we looked at different ideas for supporting a smaller "Stable" runtime API with lower maintenance costs.

In that PR we use a macro to create upgradable APIs that use delegate calls, this allows updating the API implementation to support new major runtime upgrades.

Neopallium commented 11 months ago

Updated our example contracts to Ink! 4.3: #1569