Skip to content

Commit

Permalink
more readme notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tkernell committed Jan 4, 2024
1 parent 0b6c484 commit 0ef7917
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 73 deletions.
4 changes: 3 additions & 1 deletion evm/contracts/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ On the Layer side, there are two distinct concepts of validator sets: the actual

In addition to validator set changes, validators also provide their attestations to reports. This happens not just for new reports but also for past ones, particularly beneficial for optimistic oracle applications.

It's important to note that once a value is contested, validators cease their attestations for these values. This means that post-dispute, users cannot request or execute attestation proofs for the contested value.
It's important to note that once a value is contested, validators cease their attestations for these values. This means that post-dispute, users cannot request or execute attestation proofs for the contested value.

The official bridge validator set list should be sorted by validator power in descending order. This should limit gas costs of running attestation proofs in the bridge contract, as signatures only have to be checked up until 2/3 of total validator power is reached. This sorting should be enforced on the Layer side.
138 changes: 68 additions & 70 deletions evm/contracts/usingtellor/UsingTellor.sol
Original file line number Diff line number Diff line change
@@ -1,77 +1,75 @@
// // SPDX-License-Identifier: MIT
// pragma solidity >=0.8.0;
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

// import "../bridge/BlobstreamO.sol";
import "../bridge/BlobstreamO.sol";

// contract UsingTellor {
// BlobstreamO public bridge;
// uint256 public constant MAX_ATTESTATION_AGE = 5 minutes;
contract UsingTellor {
BlobstreamO public bridge;
uint256 public constant MAX_ATTESTATION_AGE = 5 minutes;

// constructor(address _blobstreamO) {
// bridge = BlobstreamO(_blobstreamO);
// }
constructor(address _blobstreamO) {
bridge = BlobstreamO(_blobstreamO);
}

// function isCurrentConsensusValue(
// OracleAttestationData calldata _attest,
// Validator[] calldata _currentValidatorSet,
// Signature[] calldata _sigs
// ) public view returns(bool) {
// require(bridge.verifyConsensusOracleData(_attest, _currentValidatorSet, _sigs), "Invalid attestation");
// require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
// require(_attest.report.nextTimestamp == 0, "Report is not latest");
// return true;
// }
function isCurrentConsensusValue(
OracleAttestationData calldata _attest,
Validator[] calldata _currentValidatorSet,
Signature[] calldata _sigs
) public view returns(bool) {
require(bridge.verifyConsensusOracleData(_attest, _currentValidatorSet, _sigs), "Invalid attestation");
require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
require(_attest.report.nextTimestamp == 0, "Report is not latest");
return true;
}

// function isValidDataBefore(
// OracleAttestationData calldata _attest,
// Validator[] calldata _currentValidatorSet,
// Signature[] calldata _sigs,
// uint256 _timestamp,
// uint256 _maxAge,
// uint256 _minimumPower
// ) public view returns(bool){
// require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
// require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
// require(_attest.report.timestamp < _timestamp, "Report timestamp must be before _timestamp");
// require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _timestamp, "Report is latest before timestamp");
// require(_attest.report.aggregatePower >= _minimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
// return true;
// }
function isValidDataBefore(
OracleAttestationData calldata _attest,
Validator[] calldata _currentValidatorSet,
Signature[] calldata _sigs,
uint256 _timestamp,
uint256 _maxAge,
uint256 _minimumPower
) public view returns(bool){
require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
require(_attest.report.timestamp < _timestamp, "Report timestamp must be before _timestamp");
require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _timestamp, "Report is latest before timestamp");
require(_attest.report.aggregatePower >= _minimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
return true;
}

// function isValidDataAfter(
// OracleAttestationData calldata _attest,
// Validator[] calldata _currentValidatorSet,
// Signature[] calldata _sigs,
// uint256 _timestamp,
// uint256 _maxAge, //?
// uint256 _minimumPower
// ) public view returns(bool){
// require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
// require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
// require(_attest.report.timestamp > _timestamp, "Report timestamp must be after _timestamp");
// require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _timestamp, "Report is latest before timestamp");
// require(_attest.report.aggregatePower >= _minimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
// return true;
// }
function isValidDataAfter(
OracleAttestationData calldata _attest,
Validator[] calldata _currentValidatorSet,
Signature[] calldata _sigs,
uint256 _timestamp,
uint256 _maxAge, //?
uint256 _minimumPower
) public view returns(bool){
require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
require(_attest.report.timestamp > _timestamp, "Report timestamp must be after _timestamp");
require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _timestamp, "Report is latest before timestamp");
require(_attest.report.aggregatePower >= _minimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
return true;
}

// function getDataWithFallback(
// OracleAttestationData calldata _attest,
// Validator[] calldata _currentValidatorSet,
// Signature[] calldata _sigs,
// uint256 _fallbackTimestamp,
// uint256 _fallbackMinimumPower
// ) public view returns(bool){
// require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
// require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");

// if(_attest.report.aggregatePower >= bridge.powerThreshold) {
// require(_attest.report.timestamp < _fallbackTimestamp, "Report timestamp must be before _fallbackTimestamp");
// }
// require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _fallbackTimestamp, "Report is latest before timestamp");
// require(_attest.report.aggregatePower >= _fallbackMinimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
// require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp < _fallbackTimestamp, "Report is latest after fallback timestamp");
// require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _fallbackTimestamp, "Report is latest before fallback timestamp");
// require(_attest.report.nextAggregatePower >= _fallbackMinimumPower, "Report aggregate power must be greater than or equal to _fallbackMinimumPower");
// return true;
// }
// }
function getDataWithFallback(
OracleAttestationData calldata _attest,
Validator[] calldata _currentValidatorSet,
Signature[] calldata _sigs,
uint256 _fallbackTimestamp,
uint256 _fallbackMinimumPower
) public view returns(bool){
require(bridge.verifyOracleData(_attest, _currentValidatorSet, _sigs), "Invalid signature");
require(block.timestamp - _attest.attestTimestamp <= MAX_ATTESTATION_AGE, "Attestation is too old");
if(_attest.report.aggregatePower >= bridge.powerThreshold()) {
require(_attest.report.timestamp < _fallbackTimestamp, "Report timestamp must be before _fallbackTimestamp");
}
require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _fallbackTimestamp, "Report is latest before timestamp");
require(_attest.report.aggregatePower >= _fallbackMinimumPower, "Report aggregate power must be greater than or equal to _minimumPower");
require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp < _fallbackTimestamp, "Report is latest after fallback timestamp");
require(_attest.report.nextTimestamp == 0 || _attest.report.nextTimestamp > _fallbackTimestamp, "Report is latest before fallback timestamp");
return true;
}
}
3 changes: 1 addition & 2 deletions evm/test/Bridge-TestsManual.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ describe("BlobstreamO - Manual Function and e2e Tests", function () {
)
})

it("update validator set to 100 validators", async function() {
it("update validator set to 100+ validators", async function() {
nVals = 158
let wallets = []
for (i = 0; i < nVals; i++) {
Expand Down Expand Up @@ -493,7 +493,6 @@ describe("BlobstreamO - Manual Function and e2e Tests", function () {
sigStructArray1
)

console.log("nVals: ", nVals)
})


Expand Down

0 comments on commit 0ef7917

Please sign in to comment.