Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
bump solc to 0.6.12, using btc spv fork
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <[email protected]>
  • Loading branch information
gregdhill committed Jul 27, 2020
1 parent 1cab347 commit d3f7e2f
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion buidler.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;
const config = {
defaultNetwork: "buidlerevm",
solc: {
version: "0.5.15",
version: "0.6.12",
optimizer: { enabled: true, runs: 500 }
},
paths: {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@interlay/btc-relay-sol",
"version": "0.3.1",
"version": "0.3.2",
"description": "BTC Relay in Solidity",
"dependencies": {
"@summa-tx/bitcoin-spv-sol": "3.1.0",
"@interlay/bitcoin-spv-sol": "3.2.1",
"@openzeppelin/contracts": "3.1.0",
"bitcoinjs-lib": "^5.1.7"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion src/IRelay.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

interface IRelay {
/**
Expand Down
10 changes: 6 additions & 4 deletions src/Parser.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
pragma solidity ^0.6.12;

import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@interlay/bitcoin-spv-sol/contracts/BTCUtils.sol";

library Parser {
using SafeMath for uint256;
Expand Down
6 changes: 4 additions & 2 deletions src/ParserDelegate.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
pragma solidity ^0.6.12;

import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";

import {Parser} from "./Parser.sol";

Expand Down
26 changes: 14 additions & 12 deletions src/Relay.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {ValidateSPV} from "@summa-tx/bitcoin-spv-sol/contracts/ValidateSPV.sol";
pragma solidity ^0.6.12;

import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@interlay/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {ValidateSPV} from "@interlay/bitcoin-spv-sol/contracts/ValidateSPV.sol";
import {IRelay} from "./IRelay.sol";

/// @title BTC Relay
Expand Down Expand Up @@ -107,7 +109,7 @@ contract Relay is IRelay {
/**
* @dev Core logic for block header validation
*/
function _submitBlockHeader(bytes memory header) internal {
function _submitBlockHeader(bytes memory header) internal virtual {
require(header.length == 80, ERR_INVALID_HEADER_SIZE);

// Fail if block already exists
Expand Down Expand Up @@ -189,14 +191,14 @@ contract Relay is IRelay {
/**
* @dev See {IRelay-submitBlockHeader}.
*/
function submitBlockHeader(bytes calldata header) external {
function submitBlockHeader(bytes calldata header) external override {
_submitBlockHeader(header);
}

/**
* @dev See {IRelay-submitBlockHeaderBatch}.
*/
function submitBlockHeaderBatch(bytes calldata headers) external {
function submitBlockHeaderBatch(bytes calldata headers) external override {
require(headers.length % 80 == 0, ERR_INVALID_HEADER_BATCH);

for (uint256 i = 0; i < headers.length / 80; i = i.add(1)) {
Expand Down Expand Up @@ -314,14 +316,14 @@ contract Relay is IRelay {
/**
* @dev See {IRelay-getBlockHeight}.
*/
function getBlockHeight(bytes32 digest) external view returns (uint32) {
function getBlockHeight(bytes32 digest) external view override returns (uint32) {
return _headers[digest].height;
}

/**
* @dev See {IRelay-getBlockHash}.
*/
function getBlockHash(uint32 height) external view returns (bytes32) {
function getBlockHash(uint32 height) external view override returns (bytes32) {
bytes32 digest = _chain[height];
require(digest > 0, ERR_BLOCK_NOT_FOUND);
return digest;
Expand All @@ -330,7 +332,7 @@ contract Relay is IRelay {
/**
* @dev See {IRelay-getBestBlock}.
*/
function getBestBlock() external view returns (bytes32 digest, uint32 height) {
function getBestBlock() external view override returns (bytes32 digest, uint32 height) {
return (_bestBlock, _bestHeight);
}

Expand All @@ -345,7 +347,7 @@ contract Relay is IRelay {
bytes calldata proof,
uint256 confirmations,
bool insecure
) external view returns (bool) {
) external view override returns (bool) {
// txid must be little endian
require(txid != 0, ERR_INVALID_TXID);

Expand Down
8 changes: 5 additions & 3 deletions src/Script.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
pragma solidity ^0.6.12;

import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@interlay/bitcoin-spv-sol/contracts/BTCUtils.sol";

library Script {
using BytesLib for bytes;
Expand Down
4 changes: 3 additions & 1 deletion src/ScriptDelegate.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import {Script} from "./Script.sol";

Expand Down
14 changes: 8 additions & 6 deletions src/TestRelay.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pragma solidity ^0.5.15;
// SPDX-License-Identifier: MIT

import {SafeMath} from "@summa-tx/bitcoin-spv-sol/contracts/SafeMath.sol";
import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@summa-tx/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {ValidateSPV} from "@summa-tx/bitcoin-spv-sol/contracts/ValidateSPV.sol";
pragma solidity ^0.6.12;

import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {BytesLib} from "@interlay/bitcoin-spv-sol/contracts/BytesLib.sol";
import {BTCUtils} from "@interlay/bitcoin-spv-sol/contracts/BTCUtils.sol";
import {ValidateSPV} from "@interlay/bitcoin-spv-sol/contracts/ValidateSPV.sol";
import {Relay} from "./Relay.sol";

/// @title Testnet BTC Relay
Expand All @@ -25,7 +27,7 @@ contract TestRelay is Relay {
/**
* @dev Override to remove the difficulty check
*/
function _submitBlockHeader(bytes memory header) internal {
function _submitBlockHeader(bytes memory header) internal override {
require(header.length == 80, ERR_INVALID_HEADER_SIZE);

bytes32 hashPrevBlock = header.extractPrevBlockLE().toBytes32();
Expand Down

0 comments on commit d3f7e2f

Please sign in to comment.