-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: Add a coin reservation abstraction to prevent equivocation within the same relayer #304
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
Conversation
|
👋 faisal-chainlink, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
stackman27
left a comment
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.
LGTM
…in the same relayer (#304) * add a GasCoinManager abstraction * add locked coin error parsing to reserve coins * allow setting an expiry when reserving coins * update GasCoinManager * fix txm tests * release coins on confirmer marking transaction as failed or succeeded * error checking * add separate txm error strategy for simple coin refreshing (used for locked coins) * nit --------- Co-authored-by: stackman27 <[email protected]>
The PR includes the following:
GasCoinManagerabstraction to keep a cache of "reserved" coins (being used in other transacitons)Additional description of the change
For a tx we build/send, you reserve its payment coins by calling
TryReserveCoins(txID, []SuiObjectRef, expiry=nil)(or similar). That creates:coinID -> truewith TTL = 30s (default)txID -> []SuiObjectRefwith TTL = 30sIf we then detect the “locked coin / equivocation” issue and run the quarantine path, you call
TryReserveCoins(..., &expiry)with 24h, which creates:coinID -> truewith TTL = 24htxID -> []SuiObjectRefwith TTL = 30s (still)So after ~30s or failure/success:
That’s why later ReleaseCoins(txID) often can’t undo the 24h quarantine: it loses the txID→coins index, but the coin lock key is still present.