instantiate_v2 with additional limit parameters#2123
Merged
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
pgherveou
approved these changes
Feb 26, 2024
Comment on lines
+572
to
+576
| 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); |
Contributor
There was a problem hiding this comment.
We can't make use of AccountId::max_encoded_len() here instead of hard coding 1024?
Collaborator
Author
There was a problem hiding this comment.
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.
🦑 📈 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.