docs(sui-indexer): add coin management notes and confirm no race condition#327
Merged
docs(sui-indexer): add coin management notes and confirm no race condition#327
Conversation
…ition Signed-off-by: Rayane Charif <rayane.charif@gonative.cc>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideDocuments how IKA coin selection and merging work in the Sui indexer and clarifies that concurrency characteristics of the Cloudflare worker prevent race conditions when selecting coins. Sequence diagram for IKA coin selection and merging in SuiIndexersequenceDiagram
actor CFWorkerCron
participant SuiIndexer
participant IkaClientImp
participant CoinOps
participant SuiRPC
CFWorkerCron->>SuiIndexer: processSolvedRedeems()
loop each_redeem_request
SuiIndexer->>IkaClientImp: fetchAllIkaCoins(owner)
IkaClientImp->>SuiRPC: query IKA coins for owner
SuiRPC-->>IkaClientImp: CoinStruct[]
IkaClientImp-->>SuiIndexer: CoinStruct[]
SuiIndexer->>CoinOps: selectCoins(coins, targetAmount)
CoinOps-->>SuiIndexer: selectedCoins
alt multiple_coins_needed
SuiIndexer->>CoinOps: prepareCoin(selectedCoins)
CoinOps->>SuiRPC: merge coins on chain
SuiRPC-->>CoinOps: mergedCoin
CoinOps-->>SuiIndexer: mergedCoin
else single_coin_sufficient
SuiIndexer-->>SuiIndexer: use single coin directly
end
SuiIndexer->>SuiRPC: presign/sign transaction using coin
SuiRPC-->>SuiIndexer: transaction result
end
%% Concurrency characteristic: only one CFWorkerCron instance runs
%% and processSolvedRedeems loop is sequential, so no parallel
%% coin selection occurs
Class diagram for IkaClientImp IKA coin management methodclassDiagram
class IkaClientImp {
+fetchAllIkaCoins(owner string) CoinStruct[]
}
class CoinStruct
IkaClientImp ..> CoinStruct : returns
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The concurrency explanation relies on Cloudflare cron behavior; consider clarifying or linking to the specific CF guarantee and explicitly scoping the assumption (e.g., what happens with manual triggers, multiple environments, or future parallel workers) so the "no race condition" claim remains accurate over time.
- Since
fetchAllIkaCoinsis documented as safe becauseprocessSolvedRedeemsis sequential, it may be worth calling out in the comments that introducing any parallel caller or reusing this helper elsewhere would require revisiting the race-condition assumptions to avoid misuse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The concurrency explanation relies on Cloudflare cron behavior; consider clarifying or linking to the specific CF guarantee and explicitly scoping the assumption (e.g., what happens with manual triggers, multiple environments, or future parallel workers) so the "no race condition" claim remains accurate over time.
- Since `fetchAllIkaCoins` is documented as safe because `processSolvedRedeems` is sequential, it may be worth calling out in the comments that introducing any parallel caller or reusing this helper elsewhere would require revisiting the race-condition assumptions to avoid misuse.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
robert-zaremba
approved these changes
Jan 29, 2026
Co-authored-by: Robert Zaremba <robert@zaremba.ch> Signed-off-by: Shish <rayane.charifchefchaouni@epfl.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch> Signed-off-by: Shish <rayane.charifchefchaouni@epfl.ch>
Signed-off-by: Rayane Charif <rayane.charif@gonative.cc>
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.
Closes: #310
Summary by Sourcery
Document IKA coin management and clarify concurrency guarantees in the sui-indexer.
Enhancements:
Documentation: