-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace light relay with full relay in utils and swap contracts.
- Loading branch information
Showing
9 changed files
with
89 additions
and
110 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
pragma solidity ^0.8.17; | ||
|
||
// Forked from https://github.com/keep-network/tbtc-v2 | ||
|
||
import {BTCUtils} from "@bob-collective/bitcoin-spv/BTCUtils.sol"; | ||
import {FullRelay} from "./FullRelay.sol"; | ||
|
||
/// @title Test Light Relay | ||
/// @notice TestLightRelay is a stub version of LightRelay intended to be | ||
/// used on for testing network. It allows to set the relay's | ||
/// difficulty based on arbitrary Bitcoin headers thus effectively | ||
/// bypass the validation of difficulties of Bitcoin testnet blocks. | ||
/// Since difficulty in Bitcoin testnet often falls to `1` it would not | ||
/// be possible to validate blocks with the real LightRelay. | ||
/// @dev Notice that TestLightRelay is derived from LightRelay so that the two | ||
/// contracts have the same API and correct bindings can be generated. | ||
contract TestFullRelay is FullRelay { | ||
using BTCUtils for bytes; | ||
using BTCUtils for uint256; | ||
|
||
/// @notice Sets the current and previous difficulty based on the difficulty | ||
/// inferred from the provided Bitcoin headers. | ||
function setDifficultyFromHeaders(bytes memory bitcoinHeaders) external { | ||
uint256 firstHeaderDiff = bitcoinHeaders.extractTarget().calculateDifficulty(); | ||
|
||
currentEpochDiff = firstHeaderDiff; | ||
prevEpochDiff = firstHeaderDiff; | ||
} | ||
|
||
/// @notice Constructor for TestFullRelay | ||
/// @param _genesisHeader The starting header | ||
/// @param _height The starting height | ||
/// @param _periodStart The hash of the first header in the genesis epoch | ||
constructor(bytes memory _genesisHeader, uint256 _height, bytes32 _periodStart) | ||
FullRelay(_genesisHeader, _height, _periodStart) | ||
{} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.