fix(spv): align deposit sweep proof length with Bridge accumulated difficulty#3918
Open
lionakhnazarov wants to merge 10 commits intothreshold-network:mainfrom
Open
fix(spv): align deposit sweep proof length with Bridge accumulated difficulty#3918lionakhnazarov wants to merge 10 commits intothreshold-network:mainfrom
lionakhnazarov wants to merge 10 commits intothreshold-network:mainfrom
Conversation
- Added function to create block headers with specified difficulty. - Introduced method in to add headers for a range of heights based on dynamic difficulty. - Updated tests in to utilize the new difficulty handling, ensuring accurate proof range calculations across epochs. - Enhanced function to compute required confirmations based on actual header difficulties instead of fixed assumptions.
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.
Updates the SPV maintainer’s getProofInfo logic so the number of Bitcoin headers in the SPV proof matches what Bridge.evaluateProofDifficulty requires: sum of per-header difficulty ≥ requestedDifficulty × txProofDifficultyFactor, with the first header matching relay current or previous epoch difficulty. Adds relay-window checks so the proof range stays in the previous epoch, current epoch, or spans previous→current only.
This fixes failures like Insufficient accumulated difficulty in header chain on chains where per-block work varies (e.g. testnet4 min-difficulty streaks), where a fixed block count × epoch-average math was wrong.
Changes
pkg/maintainer/spv/spv.go: implement proofRangeWithinRelayWindow; rewrite getProofInfo to walk headers from proof start, sum header.Difficulty(), resolve requestedDiff from first header vs relay difficulties.
pkg/maintainer/spv/spv_test.go + bitcoin_chain_test.go: populate mock headers with realistic Bits/difficulty; fix setCurrentAndPrevEpochDifficulty argument order; update expectations.
(if included) .github/workflows/contracts-ecdsa.yml: resolve accidental merge conflict markers in on: triggers.