-
Notifications
You must be signed in to change notification settings - Fork 429
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
instantiate_v2
with additional limit parameters
#2123
Conversation
WIP
instantiate_v2
instantiate_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-len
feature - Add some bounds to the traits and impls
- Derive
MaxEncodedLen
forAccountId
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-contracts
includinginstantiate_v2
host function. Introduced in this commitFollowing up on #2077.
There is a new host function
instantiate_v2
which allows passing bothWeight
parts:ref_time_limit
andproof_time_limit
and thestorage_deposit_limit
. The legacyinstantiate
function only provides the singlegas_limit
parameter, which is used as the value forref_time_limit
.The
instantiate
extrinsic 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 originalv1
host function, but it requires calling theinstantiate_v1
method 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_limit
which is replaced byref_time_limit
.