-
Notifications
You must be signed in to change notification settings - Fork 480
instantiate_v2 with additional limit parameters
#2123
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
Conversation
WIP instantiate_v2instantiate_v2 cross contract instantiation with additional limit parameters
instantiate_v2 cross contract instantiation with additional limit parametersinstantiate_v2 with additional limit parameters
| let enc_input = scoped.take_encoded(params.exec_input()); | ||
| // We support `AccountId` types with an encoding that requires up to | ||
| // 1024 bytes. Beyond that limit ink! contracts will trap for now. | ||
| // In the default configuration encoded `AccountId` require 32 bytes. | ||
| let out_address = &mut scoped.take(1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't make use of AccountId::max_encoded_len() here instead of hard coding 1024?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea. We will need to:
- Enable
max-encoded-lenfeature - Add some bounds to the traits and impls
- Derive
MaxEncodedLenforAccountId
It's not that much to do, but I'm inclined to make that a separate PR to this, so we can properly test it and see e.g. contract size differences if any.
This block of code I simply copied from the existing instantiate_contract, so we are confident it works well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑These are the results when building the
Link to the run | Last update: Tue Feb 27 12:30:26 CET 2024 |
Requires version of
pallet-contractsincludinginstantiate_v2host function. Introduced in this commitFollowing up on #2077.
There is a new host function
instantiate_v2which allows passing bothWeightparts:ref_time_limitandproof_time_limitand thestorage_deposit_limit. The legacyinstantiatefunction only provides the singlegas_limitparameter, which is used as the value forref_time_limit.The
instantiateextrinsic already requires these, so this just brings the cross-contract instantiation API into line with the extrinsic.Migration
If your target node does not yet support
instantiate_v2, then you can continue to use the originalv1host function, but it requires calling theinstantiate_v1method on the builder e.g.Otherwise if you do not change your code, it will attempt to call the new instantiate_v2 function, with no compiler warnings unless you are using
gas_limitwhich is replaced byref_time_limit.