Skip to content

Commit

Permalink
feat: initial changes based on teleswap contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
easonchan17 committed Jan 22, 2024
1 parent 41f9fa4 commit 86a3b4f
Show file tree
Hide file tree
Showing 54 changed files with 1,711 additions and 5,363 deletions.
363 changes: 210 additions & 153 deletions contracts/common/libraries/BitcoinHelper.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/common/libraries/TypedMemView.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.8.4;
pragma solidity 0.8.4;

/** @author Summa (https://summa.one) */

Expand Down
615 changes: 56 additions & 559 deletions contracts/common/relay/BitcoinRelayLogic.sol

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions contracts/common/relay/BitcoinRelayProxy.sol
@@ -1,14 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.8.4;
pragma solidity 0.8.4;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

contract BitcoinRelayProxy is TransparentUpgradeableProxy {
contract BitcoinRelayProxy is ERC1967Proxy {

constructor(
address _logic,
address admin_,
bytes memory _data
) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}
) payable ERC1967Proxy(_logic, _data) {}

}
150 changes: 4 additions & 146 deletions contracts/common/relay/interfaces/IBitcoinRelay.sol
@@ -1,178 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.8.4;
pragma solidity 0.8.4;

interface IBitcoinRelay {
// Structures

/// @notice Structure for recording block header
/// @param selfHash Hash of block header
/// @param parentHash Hash of parent header
/// @param merkleRoot Merkle root of transactions in the header
/// @param relayer Address of Relayer who submitted the block header
/// @param gasPrice Gas price of block header submission transaction
struct blockHeader {
bytes32 selfHash;
bytes32 parentHash;
bytes32 merkleRoot;
address relayer;
uint gasPrice;
}

// Events

/// @notice Emits when a block header is added
/// @param height of submitted header
/// @param selfHash Hash of submitted header
/// @param parentHash of submitted header
/// @param relayer Address of Relayer who submitted the block header
event BlockAdded(
uint indexed height,
bytes32 selfHash,
bytes32 indexed parentHash,
address indexed relayer
);

/// @notice Emits when a block header gets finalized
/// @param height of the header
/// @param selfHash Hash of the header
/// @param parentHash of the header
/// @param relayer Address of Relayer who submitted the block header
/// @param rewardAmountTNT Amount of reward that the Relayer receives in target blockchain native token
/// @param rewardAmountTDT Amount of reward that the Relayer receives in TeleportDAO token
event BlockFinalized(
uint indexed height,
bytes32 selfHash,
bytes32 parentHash,
address indexed relayer,
uint rewardAmountTNT,
uint rewardAmountTDT
);

/// @notice Emits when inclusion of a tx is queried
/// @param txId of queried transaction
/// @param blockHeight of the block that includes the tx
/// @param paidFee Amount of fee that user paid to Relay
event NewQuery(
bytes32 txId,
uint blockHeight,
uint paidFee
);

event NewRewardAmountInTDT (
uint oldRewardAmountInTDT,
uint newRewardAmountInTDT
);

event NewFinalizationParameter (
uint oldFinalizationParameter,
uint oldFinalizationParameter,
uint newFinalizationParameter
);

event NewRelayerPercentageFee (
uint oldRelayerPercentageFee,
uint newRelayerPercentageFee
);

event NewTeleportDAOToken(
address oldTeleportDAOToken,
address newTeleportDAOToken
);

event NewEpochLength(
uint oldEpochLength,
uint newEpochLength
);

event NewBaseQueries(
uint oldBaseQueries,
uint newBaseQueries
);

event NewSubmissionGasUsed(
uint oldSubmissionGasUsed,
uint newSubmissionGasUsed
);

// Read-only functions

function relayGenesisHash() external view returns (bytes32);

function initialHeight() external view returns(uint);

function lastSubmittedHeight() external view returns(uint);

function finalizationParameter() external view returns(uint);

function TeleportDAOToken() external view returns(address);

function relayerPercentageFee() external view returns(uint);

function epochLength() external view returns(uint);

function lastEpochQueries() external view returns(uint);

function currentEpochQueries() external view returns(uint);

function baseQueries() external view returns(uint);

function submissionGasUsed() external view returns(uint);

function getBlockHeaderHash(uint height, uint index) external view returns(bytes32);

function getBlockHeaderFee(uint _height, uint _index) external view returns(uint);

function getNumberOfSubmittedHeaders(uint height) external view returns (uint);

function availableTDT() external view returns(uint);

function availableTNT() external view returns(uint);

function findHeight(bytes32 _hash) external view returns (uint256);

function rewardAmountInTDT() external view returns (uint);
function btcLightClient() external view returns(address);

// State-changing functions

function pauseRelay() external;

function unpauseRelay() external;

function setRewardAmountInTDT(uint _rewardAmountInTDT) external;

function setFinalizationParameter(uint _finalizationParameter) external;

function setRelayerPercentageFee(uint _relayerPercentageFee) external;

function setTeleportDAOToken(address _TeleportDAOToken) external;

function setEpochLength(uint _epochLength) external;

function setBaseQueries(uint _baseQueries) external;

function setSubmissionGasUsed(uint _submissionGasUsed) external;

function checkTxProof(
bytes32 txid,
uint blockHeight,
bytes calldata intermediateNodes,
uint index
) external payable returns (bool);

function getBlockHeaderHashContract(uint _height, uint _index) external payable returns (bytes32);

function addHeaders(bytes calldata _anchor, bytes calldata _headers) external returns (bool);

function addHeadersWithRetarget(
bytes calldata _oldPeriodStartHeader,
bytes calldata _oldPeriodEndHeader,
bytes calldata _headers
) external returns (bool);

function ownerAddHeaders(bytes calldata _anchor, bytes calldata _headers) external returns (bool);

function ownerAddHeadersWithRetarget(
bytes calldata _oldPeriodStartHeader,
bytes calldata _oldPeriodEndHeader,
bytes calldata _headers
) external returns (bool);
) external view returns (bool);
}
2 changes: 1 addition & 1 deletion contracts/common/types/ScriptTypesEnum.sol
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.8.4;
pragma solidity 0.8.4;

enum ScriptTypes {
P2PK, // 32 bytes
Expand Down

0 comments on commit 86a3b4f

Please sign in to comment.