fixed: mutexguard over alive problem #1089
Merged
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.
Problem
The SDK uses
std::sync::Mutexfor global configuration:When methods
fetch_whirlpools_by_token_pairandfetch_concentrated_liquidity_poolare called insidetokio::spawn, it fails becauseMutexGuarddoesn't implementSend, preventing the async task from being sent between threads.Error
Reproduction - u can check at https://github.com/nam2ee/custom-whirlpool
Testing the Broken Version (Official SDK)
Edit
src/main.rs:Run:
You'll see the
Sendtrait error.Testing the Working Version (Reference overalive Fixed)
Edit
src/main.rs:Run:
It compiles and runs successfully. Also tests are all passed at modified ver.
The Fix
In

rust-sdk/whirlpool/src/, change:What was the issue?
Mutexguard for
WHIRLPOOLS_CONFIG_ADDRESSis alive over after the .await contexts. It doesn't implementsSendso that violates thread safety.Related Issue
See the discussion in the Orca Discord for more context.
NEXT STEP
Basically, I notice operations for
WHIRLPOOLS_CONFIG_ADDRESSare read-intensive overall.So, I think changing
Mutextype toRwLockwill be helpful for tackling performance issue. Let me measure the performance metric!