Open
Conversation
|
Contract comparison - from b9138e3 to 7345145
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces handle-level deallocation support for ManagedVec items (primarily for StaticApi / scenario usage) by plumbing a requires_drop() signal through ManagedVecItem, updating ManagedVec operations to avoid handle aliasing/double-frees, and expanding scenario/bench coverage.
Changes:
- Add
requires_drop()propagation forManagedVecItem(derive + many manual impls) and a backend capability flag (requires_managed_type_drop) exposed via scenario APIs. - Update
ManagedVecto drop items when needed (on drop/clear/overwrite/remove/dedup), and make slicing deep-copy items when handle-level drop is required. - Add benchmarks and scenario tests validating new
ManagedVecAPIs/behavior and derive outputs.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/managed-mem-bench/src/main.rs | Expands benchmarks to cover enums/structs and many ManagedVec<T> item shapes under StaticApi. |
| framework/scenario/tests/managed_vec_test.rs | Adds tests for byte_len, is_empty, try_get, set, slice, remove, clear, find, contains (incl. BigUint cases). |
| framework/scenario/tests/derive_managed_vec_item_struct_3.rs | Extends derive test assertions to validate requires_drop() for derived struct/enum. |
| framework/scenario/tests/derive_managed_vec_item_struct_2_test.rs | Adds requires_drop() assertion for a derived struct. |
| framework/scenario/tests/derive_managed_vec_item_struct_1_test.rs | Adds requires_drop() assertion for a derived struct. |
| framework/scenario/tests/derive_managed_vec_item_esdt_token_payment_test.rs | Adds requires_drop() assertion for a derived managed-token struct. |
| framework/scenario/tests/derive_managed_vec_item_enum_simple.rs | Adds requires_drop() assertion for a derived simple enum. |
| framework/scenario/tests/derive_managed_vec_item_enum_2_managed.rs | Adds requires_drop() assertion for a derived enum containing managed fields. |
| framework/scenario/tests/derive_managed_vec_item_enum_1.rs | Adds requires_drop() assertion for a derived enum. |
| framework/scenario/tests/derive_managed_vec_item_decimal_test.rs | Adds requires_drop() assertion for a derived decimal wrapper. |
| framework/scenario/tests/derive_managed_vec_item_biguint_test.rs | Adds requires_drop() assertion for a derived BigUint wrapper. |
| framework/scenario/src/api/managed_type_api_vh.rs | Exposes requires_managed_type_drop() through ManagedTypeApiImpl for VMHooks-backed APIs. |
| framework/scenario/src/api/impl_vh/vm_hooks_backend.rs | Adds a backend capability hook backend_requires_managed_type_drop(). |
| framework/scenario/src/api/impl_vh/static_api.rs | Enables managed-type dropping for StaticApi backend. |
| framework/scenario/src/api/impl_vh/single_tx_api.rs | Disables managed-type dropping for SingleTxApi backend. |
| framework/scenario/src/api/impl_vh/debug_api.rs | Disables managed-type dropping for DebugApi backend. |
| framework/derive/src/managed_vec_item_derive.rs | Extends ManagedVecItem derive to compute requires_drop() from fields/variants. |
| framework/base/src/types/managed/wrapped/token/payment.rs | Implements requires_drop() based on backend capability for Payment. |
| framework/base/src/types/managed/wrapped/token/fungible_payment.rs | Implements requires_drop() based on backend capability for FungiblePayment. |
| framework/base/src/types/managed/wrapped/token/esdt_token_payment.rs | Implements requires_drop() based on backend capability for EsdtTokenPayment. |
| framework/base/src/types/managed/wrapped/token/egld_or_esdt_token_payment.rs | Implements requires_drop() based on backend capability for EgldOrEsdtTokenPayment. |
| framework/base/src/types/managed/wrapped/managed_vec_ref_mut.rs | Adjusts write-back to avoid drop semantics during ManagedVecRefMut guard drop. |
| framework/base/src/types/managed/wrapped/managed_vec_item.rs | Makes requires_drop() mandatory and implements it for primitives/managed types/options/tuples. |
| framework/base/src/types/managed/wrapped/managed_vec.rs | Implements item-dropping behavior and updates slice, set, remove/take, append_vec, clear, dedup, and drop logic. |
| framework/base/src/types/managed/wrapped/managed_option.rs | Adds backend-driven requires_drop() for ManagedOption as a ManagedVecItem. |
| framework/base/src/types/managed/wrapped/managed_decimal/managed_decimal_signed.rs | Adds backend-driven requires_drop() for signed decimal variants. |
| framework/base/src/types/managed/wrapped/managed_decimal.rs | Adds backend-driven requires_drop() for decimal variants. |
| framework/base/src/types/managed/multi_value/payment_multi_value.rs | Adds backend-driven requires_drop() for multi-value payment wrapper. |
| framework/base/src/types/managed/multi_value/multi_value_managed_vec_counted.rs | Adds backend-driven requires_drop() for counted vec multi-value wrapper. |
| framework/base/src/types/managed/multi_value/multi_value_managed_vec.rs | Updates slice signature to match underlying ManagedVec requirements. |
| framework/base/src/types/managed/multi_value/esdt_token_payment_multi_value.rs | Adds backend-driven requires_drop() for ESDT payment multi-value wrapper. |
| framework/base/src/types/managed/multi_value/egld_or_esdt_token_payment_multi_value.rs | Adds backend-driven requires_drop() for EGLD/ESDT payment multi-value wrapper. |
| framework/base/src/types/interaction/managed_arg_buffer.rs | Adds backend-driven requires_drop() for ManagedArgBuffer as a ManagedVecItem. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
This PR introduces handle-level deallocation support for
ManagedVecitems (primarily forStaticApi/ scenario usage) by plumbing arequires_drop()signal throughManagedVecItem, updatingManagedVecoperations to avoid handle aliasing/double-frees, and expanding scenario/bench coverage.Changes:
requires_drop()propagation forManagedVecItem(derive + many manual impls) and a backend capability flag (requires_managed_type_drop) exposed via scenario APIs.ManagedVecto drop items when needed (on drop/clear/overwrite/remove/dedup), and make slicing deep-copy items when handle-level drop is required.ManagedVecAPIs/behavior and derive outputs.