Skip to content
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

[Framework] Add on-the-fly fungible store concurrency upgrade to general case #12348

Conversation

alnoki
Copy link
Contributor

@alnoki alnoki commented Mar 2, 2024

@igor-aptos @georgemitenkov @lightmark

#11183 enables voluntary upgrading of a fungible asset store to use a concurrent balance, via fungible_asset::upgrade_store_to_concurrent. However, fungible_asset::upgrade_store_to_concurrent requires an ExtendRef and thus cannot be used in the general case, because fungible_asset::create_store does not by default store an ExtendRef anywhere (#11183 (comment)).

Importantly, the primary_fungible_store module has no way of provisioning an ExtendRef, which means that the current iteration of #11183 blocks all of a user's existing primary fungible asset stores (essentially all assets held in their wallet) from upgrading to concurrent balances when the features roll out on mainnet: in practice this means that most primary fungible stores would be locked out from concurrency forever.

This PR adds a simple inline function call inside fungible_asset::withdraw_internal and fungible_asset::deposit_internal that automatically upgrades a fungible store to concurrent balance on the fly (e.g. whenever an amount is transferred in or out of it).

Hence with this PR, simple transfers to or from the same wallet can all be parallelized, including for fungible stores that were initialized before the on-chain framework upgrade

Copy link

trunk-io bot commented Mar 2, 2024

⏱️ 1h 23m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-unit-tests 30m 🟥
rust-move-tests 19m 🟥
windows-build 18m 🟩
rust-lints 8m 🟩
check 4m 🟥
general-lints 2m 🟩
check-dynamic-deps 2m 🟩
semgrep/ci 20s 🟩
permission-check 10s 🟥🟥
file_change_determinator 9s 🟩
permission-check 7s 🟥🟥
permission-check 6s 🟥🟥
permission-check 5s 🟥🟥

settingsfeedbackdocs ⋅ learn more about trunk.io

@igor-aptos
Copy link
Contributor

thanks for working on this, this should allow for the optimization to be more generally applicable!

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (igor/concurrent_fungible_balance@21cdef5). Click here to learn what that means.

Additional details and impacted files
@@                         Coverage Diff                         @@
##             igor/concurrent_fungible_balance   #12348   +/-   ##
===================================================================
  Coverage                                    ?    70.3%           
===================================================================
  Files                                       ?      850           
  Lines                                       ?   189123           
  Branches                                    ?        0           
===================================================================
  Hits                                        ?   132957           
  Misses                                      ?    56166           
  Partials                                    ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@igor-aptos igor-aptos merged commit 195429b into aptos-labs:igor/concurrent_fungible_balance Mar 5, 2024
41 of 46 checks passed
igor-aptos pushed a commit that referenced this pull request Mar 5, 2024
…ral case (#12348)

* Add on-the-fly concurrency upgrade to general case

* Clarify helper func doc comment
igor-aptos pushed a commit that referenced this pull request Mar 8, 2024
…ral case (#12348)

* Add on-the-fly concurrency upgrade to general case

* Clarify helper func doc comment
igor-aptos pushed a commit that referenced this pull request Mar 27, 2024
…ral case (#12348)

* Add on-the-fly concurrency upgrade to general case

* Clarify helper func doc comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants