feat: Prevent miner slashing on API outages by distinguishing tx-not-found from provider-unreachable#10
Open
bittoby wants to merge 1 commit intoentrius:testfrom
Conversation
…found from provider-unreachable
Author
|
@anderdc @LandynDev Ready for review. Please give me any feedbacks. |
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.
Summary
Right now
verify_transaction()returnsNonefor both "transaction does not exist" and "API is down." The validator treats both the same way - it assumes the miner never sent funds, and eventually slashes them.This means a miner who fulfilled a swap correctly can still lose collateral just because Blockstream was temporarily unreachable.
This PR adds a three-state return (
VerifyResult) so the validator can tell the difference and hold off on slashing when verification is inconclusive.What changed
VerifyResulttype inbase.pywith three states:FOUND,NOT_FOUND,ERRORNone. Retries up to 3 times on transient failures (5xx, 429, connection errors) before returningERRORVERIFIED/FAILED/UNCERTAINoutcome up to the forward loop_timeout_expired): skips timeout vote onFULFILLEDswaps when verification returnedUNCERTAIN. ACTIVE swaps and swaps that definitively failed verification still timeout normallyHow it protects miners
Before:
After:
Miner only gets slashed when the API is reachable and the transaction genuinely does not exist.
Test plan
VerifyResult/VerifyStatusconstruction and properties