Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: full btc relay added #273

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
608 changes: 608 additions & 0 deletions docs/docs/contracts/src/src/relay/FullRelay.sol/contract.FullRelay.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# IFullRelay
[Git Source](https://github.com/bob-collective/bob/blob/master/src/relay/FullRelayInterfaces.sol)


## Functions
### getCurrentEpochDifficulty


```solidity
function getCurrentEpochDifficulty() external view returns (uint256);
```

### getPrevEpochDifficulty


```solidity
function getPrevEpochDifficulty() external view returns (uint256);
```

### getRelayGenesis


```solidity
function getRelayGenesis() external view returns (bytes32);
```

### getBestKnownDigest


```solidity
function getBestKnownDigest() external view returns (bytes32);
```

### getLastReorgCommonAncestor


```solidity
function getLastReorgCommonAncestor() external view returns (bytes32);
```

### findHeight


```solidity
function findHeight(bytes32 _digest) external view returns (uint256);
```

### findAncestor


```solidity
function findAncestor(bytes32 _digest, uint256 _offset) external view returns (bytes32);
```

### isAncestor


```solidity
function isAncestor(bytes32 _ancestor, bytes32 _descendant, uint256 _limit) external view returns (bool);
```

### addHeaders


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

### addHeadersWithRetarget


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

### markNewHeaviest


```solidity
function markNewHeaviest(bytes32 _ancestor, bytes calldata _currentBest, bytes calldata _newBest, uint256 _limit)
external
returns (bool);
```

## Events
### Extension

```solidity
event Extension(bytes32 indexed _first, bytes32 indexed _last);
```

### NewTip

```solidity
event NewTip(bytes32 indexed _from, bytes32 indexed _to, bytes32 indexed _gcd);
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# FullRelayWithVerify
[Git Source](https://github.com/bob-collective/bob/blob/master/src/relay/FullRelayWithVerify.sol)

**Inherits:**
[FullRelay](../../relay/FullRelay.sol/contract.FullRelay.md)


## Functions
### constructor

Gives a starting point for the relay

*We don't check this AT ALL really. Don't use relays with bad genesis*


```solidity
constructor(bytes memory _genesisHeader, uint256 _height, bytes32 _periodStart)
FullRelay(_genesisHeader, _height, _periodStart);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_genesisHeader`|`bytes`| The starting header|
|`_height`|`uint256`| The starting height|
|`_periodStart`|`bytes32`| The hash of the first header in the genesis epoch|


### verifyProof

Provide a proof of a tx that satisfies some request

*The caller must specify which inputs, which outputs, and which request*


```solidity
function verifyProof(bytes calldata _header, bytes calldata _proof, bytes32 _txId, uint256 _index, uint8 _numConfs)
external
view;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_header`|`bytes`| The header containing the merkleroot committing to the tx|
|`_proof`|`bytes`| The merkle proof intermediate nodes|
|`_txId`|`bytes32`| The transaction id to verify|
|`_index`|`uint256`| The index of the tx in the merkle tree's leaves|
|`_numConfs`|`uint8`| Number of confirmations required|


### _getConfs

Finds the number of headers on top of the argument

*Bounded to 6400 gas (8 looksups) max*


```solidity
function _getConfs(bytes32 _headerHash) internal view virtual returns (uint8);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_headerHash`|`bytes32`| The LE double-sha2 header hash|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`uint8`|The number of headers on top|


Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# TestRelay
[Git Source](https://github.com/bob-collective/bob/blob/master/src/relay/FullRelayWithVerify.sol)

**Inherits:**
[FullRelayWithVerify](../../relay/FullRelayWithVerify.sol/contract.FullRelayWithVerify.md)


## State Variables
### isAncestorOverride

```solidity
bool isAncestorOverride;
```


### isAncestorOverrideRes

```solidity
bool isAncestorOverrideRes;
```


## Functions
### constructor

Gives a starting point for the relay

*We don't check this AT ALL really. Don't use relays with bad genesis*


```solidity
constructor(bytes memory _genesisHeader, uint256 _height, bytes32 _periodStart)
FullRelayWithVerify(_genesisHeader, _height, _periodStart);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_genesisHeader`|`bytes`| The starting header|
|`_height`|`uint256`| The starting height|
|`_periodStart`|`bytes32`| The hash of the first header in the genesis epoch|


### heaviestFromAncestor


```solidity
function heaviestFromAncestor(bytes32 _ancestor, bytes calldata _left, bytes calldata _right)
external
view
returns (bytes32);
```

### isMostRecentAncestor


```solidity
function isMostRecentAncestor(bytes32 _ancestor, bytes32 _left, bytes32 _right, uint256 _limit)
external
view
returns (bool);
```

### setAncestorOverride


```solidity
function setAncestorOverride(bool _isAncestorOverride, bool _isAncestorOverrideRes) public;
```

### _isAncestor


```solidity
function _isAncestor(bytes32 _ancestor, bytes32 _descendant, uint256 _limit)
internal
view
virtual
override
returns (bool);
```

### _getConfs


```solidity
function _getConfs(bytes32) internal view virtual override returns (uint8);
```

3 changes: 1 addition & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[profile.default]
fs_permissions = [{ access = "read", path = "./optimized-out" }]
fs_permissions = [{ access = "read", path = "./optimized-out" }, { access = "read", path = "./test/fullRelay/testData/" }]
src = "src"
out = "out"
libs = ["lib"]
Expand Down Expand Up @@ -27,4 +27,3 @@ remappings = [
"@openzeppelin/=lib/openzeppelin-contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
]

Loading