Skip to content

Commit

Permalink
Merge pull request #148 from bob-collective/nakul/fix_updates_docs_an…
Browse files Browse the repository at this point in the history
…d_docker

fix: Update btc core version, add docs to relay contract
  • Loading branch information
nud3l authored Jan 24, 2024
2 parents 0784938 + 4da58fc commit 99a4f33
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.8"
services:
bitcoind:
image: "ruimarinho/bitcoin-core:24"
image: "lightninglabs/bitcoin-core:25"
command:
- -regtest
- -server
Expand All @@ -15,7 +15,7 @@ services:
- "18443:18443"

bitcoin-cli:
image: "ruimarinho/bitcoin-core:24"
image: "lightninglabs/bitcoin-core:25"
command:
- /bin/sh
- -c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,87 @@
**Inherits:**
Ownable, [ILightRelay](../../relay/LightRelay.sol/interface.ILightRelay.md)

*THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.*
*The LightRelay contract manages a relay for Bitcoin header information,
allowing retargeting and validation of header chains.
THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.*


## State Variables
### ready
Flag indicating whether the relay is ready for use.


```solidity
bool public ready;
```


### authorizationRequired
Flag indicating whether authorization is required for retarget submitters.


```solidity
bool public authorizationRequired;
```


### proofLength
Number of blocks required for each side of a retarget proof.


```solidity
uint64 public proofLength;
```


### genesisEpoch
The number of the first epoch recorded by the relay.


```solidity
uint64 public genesisEpoch;
```


### currentEpoch
The number of the latest epoch whose difficulty is proven to the relay.


```solidity
uint64 public currentEpoch;
```


### currentEpochDifficulty
Difficulty of the current epoch.


```solidity
uint256 internal currentEpochDifficulty;
```


### prevEpochDifficulty
Difficulty of the previous epoch.


```solidity
uint256 internal prevEpochDifficulty;
```


### epochs
Mapping of each epoch from genesis to the current one, keyed by their numbers.


```solidity
mapping(uint256 => Epoch) internal epochs;
```


### isAuthorized
Mapping of authorized submitters.


```solidity
mapping(address => bool) public isAuthorized;
Expand All @@ -74,6 +94,8 @@ mapping(address => bool) public isAuthorized;
## Functions
### relayActive

Modifier to check if the relay is active.


```solidity
modifier relayActive();
Expand Down
21 changes: 15 additions & 6 deletions src/relay/LightRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,51 @@ library RelayUtils {
}
}

/// @dev THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.
/// @title LightRelay Contract
/// @dev The LightRelay contract manages a relay for Bitcoin header information,
/// allowing retargeting and validation of header chains.
/// THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.
contract LightRelay is Ownable, ILightRelay {
using BytesLib for bytes;
using BTCUtils for bytes;
using ValidateSPV for bytes;
using RelayUtils for bytes;

/// @notice Flag indicating whether the relay is ready for use.
bool public ready;
// Whether the relay requires the address submitting a retarget to be
// authorised in advance by governance.
/// @notice Flag indicating whether authorization is required for retarget submitters.
bool public authorizationRequired;
// Number of blocks required for each side of a retarget proof:
// a retarget must provide `proofLength` blocks before the retarget
/// @notice Number of blocks required for each side of a retarget proof.
// A retarget must provide `proofLength` blocks before the retarget
// and `proofLength` blocks after it.
// Governable
// Should be set to a fairly high number (e.g. 20-50) in production.
uint64 public proofLength;
// The number of the first epoch recorded by the relay.
/// @notice The number of the first epoch recorded by the relay.
// This should equal the height of the block starting the genesis epoch,
// divided by 2016, but this is not enforced as the relay has no
// information about block numbers.
uint64 public genesisEpoch;
// The number of the latest epoch whose difficulty is proven to the relay.
/// @notice The number of the latest epoch whose difficulty is proven to the relay.
// If the genesis epoch's number is set correctly, and retargets along the
// way have been legitimate, this equals the height of the block starting
// the most recent epoch, divided by 2016.
uint64 public currentEpoch;

/// @notice Difficulty of the current epoch.
uint256 internal currentEpochDifficulty;
/// @notice Difficulty of the previous epoch.
uint256 internal prevEpochDifficulty;

// Each epoch from genesis to the current one, keyed by their numbers.
/// @notice Mapping of each epoch from genesis to the current one, keyed by their numbers.
mapping(uint256 => Epoch) internal epochs;

/// @notice Mapping of authorized submitters.
mapping(address => bool) public isAuthorized;

/// @notice Modifier to check if the relay is active.
modifier relayActive() {
require(ready, "Relay is not ready for use");
_;
Expand Down

0 comments on commit 99a4f33

Please sign in to comment.