Skip to content

Commit

Permalink
chore: attend pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Nov 25, 2024
1 parent 8a0342e commit ea3cf70
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 176 deletions.
2 changes: 1 addition & 1 deletion contracts/WitPriceFeeds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity >=0.8.0 <0.9.0;
import "./WitFeeds.sol";
import "./interfaces/IWitPriceFeeds.sol";

/// @title WitPriceFeeds: Price Feeds live repository reliant on the Wit/oracle blockchain.
/// @title WitPriceFeeds: Price Feeds live repository reliant on the Wit/Oracle blockchain.
/// @author The Witnet Foundation.
abstract contract WitPriceFeeds
is
Expand Down
13 changes: 10 additions & 3 deletions contracts/apps/WitPriceFeedsUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../interfaces/IWitOracleLegacy.sol";

import "../patterns/Ownable2Step.sol";

/// @title WitPriceFeeds: Price Feeds live repository reliant on the Wit/oracle blockchain.
/// @title WitPriceFeeds: Price Feeds live repository reliant on the Wit/Oracle blockchain.
/// @author Guillermo Díaz <guillermo@otherplane.com>

contract WitPriceFeedsUpgradable
Expand Down Expand Up @@ -131,6 +131,12 @@ contract WitPriceFeedsUpgradable
});
}
}
// for (uint _ix = 0; _ix < __storage().ids.length; _ix ++) {
// bytes4 _feedId = __storage().ids[_ix];
// WitPriceFeedsDataLib.Record storage __record = WitPriceFeedsDataLib.seekRecord(_feedId);
// __record.lastValidQueryId = Witnet.QueryId.wrap(0);
// __record.latestUpdateQueryId = Witnet.QueryId.wrap(0);
// }
}


Expand Down Expand Up @@ -165,8 +171,9 @@ contract WitPriceFeedsUpgradable
public view
returns (uint)
{
return (IWitOracleLegacy(address(witOracle)).estimateBaseFee(_evmGasPrice, 32)
* (100 + __baseFeeOverheadPercentage)
return (
witOracle.estimateBaseFee(_evmGasPrice)
* (100 + __baseFeeOverheadPercentage)
) / 100;
}

Expand Down
18 changes: 9 additions & 9 deletions contracts/apps/WitRandomnessV21.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../interfaces/IWitRandomnessAdmin.sol";
import "../mockups/UsingWitOracle.sol";
import "../patterns/Ownable2Step.sol";

/// @title WitRandomnessV21: Unmalleable and provably-fair randomness generation based on the Wit/oracle v2.*.
/// @title WitRandomnessV21: Unmalleable and provably-fair randomness generation based on the Wit/Oracle v2.*.
/// @author The Witnet Foundation.
contract WitRandomnessV21
is
Expand Down Expand Up @@ -35,8 +35,8 @@ contract WitRandomnessV21
mapping (Witnet.BlockNumber => Randomize) randomize_;
}

/// @notice Unique identifier of the RNG data request used on the Wit/oracle blockchain for solving randomness.
/// @dev Can be used to track all randomness requests solved so far on the Wit/oracle blockchain.
/// @notice Unique identifier of the RNG data request used on the Wit/Oracle blockchain for solving randomness.
/// @dev Can be used to track all randomness requests solved so far on the Wit/Oracle blockchain.
bytes32 immutable public override witOracleQueryRadHash;

constructor(
Expand Down Expand Up @@ -112,7 +112,7 @@ contract WitRandomnessV21
}

/// @notice Retrieves the result of keccak256-hashing the given block number with the randomness value
/// @notice generated by the Wit/oracle blockchain in response to the first non-errored randomize request solved
/// @notice generated by the Wit/Oracle blockchain in response to the first non-errored randomize request solved
/// @notice after such block number.
/// @dev Reverts if:
/// @dev i. no `randomize()` was requested on neither the given block, nor afterwards.
Expand All @@ -133,7 +133,7 @@ contract WitRandomnessV21
}

/// @notice Retrieves the actual unique hash and timestamp of the witnessing commit/reveal act that took
/// @notice place in the Wit/oracle sidechain in response to the first non-errored randomize request
/// @notice place in the Wit/Oracle sidechain in response to the first non-errored randomize request
/// @notice solved after the given block number.
/// @dev Reverts if:
/// @dev i. no `randomize()` was requested on neither the given block, nor afterwards.
Expand Down Expand Up @@ -169,7 +169,7 @@ contract WitRandomnessV21
}

/// @notice Retrieves metadata related to the randomize request that got posted to the
/// @notice Wit/oracle contract on the given block number.
/// @notice Wit/Oracle contract on the given block number.
/// @dev Returns zero values if no randomize request was actually posted on the given block.
/// @return _queryId Identifier of the underlying Witnet query created on the given block number.
/// @return _prevRandomizeBlock Block number in which a randomize request got posted just before this one. 0 if none.
Expand Down Expand Up @@ -343,7 +343,7 @@ contract WitRandomnessV21
}

/// @notice Requests the Witnet oracle to generate an EVM-agnostic and trustless source of randomness.
/// @dev Only one randomness request per block will be actually posted to the Wit/oracle.
/// @dev Only one randomness request per block will be actually posted to the Wit/Oracle.
/// @return Funds actually paid as randomize fee.
function randomize()
external payable
Expand All @@ -354,7 +354,7 @@ contract WitRandomnessV21
}

/// @notice Requests the Witnet oracle to generate an EVM-agnostic and trustless source of randomness.
/// @dev Only one randomness request per block will be actually posted to the Wit/oracle.
/// @dev Only one randomness request per block will be actually posted to the Wit/Oracle.
/// @dev Reverts if given SLA security parameters are below witOracleDefaultQuerySLA().
/// @return Funds actually paid as randomize fee.
function randomize(Witnet.QuerySLA calldata _querySLA)
Expand All @@ -369,7 +369,7 @@ contract WitRandomnessV21
return __postRandomizeQuery(_querySLA);
}

/// @notice Returns the SLA parameters required for the Wit/oracle blockchain to fulfill
/// @notice Returns the SLA parameters required for the Wit/Oracle blockchain to fulfill
/// @notice when solving randomness requests:
/// @notice - number of witnessing nodes contributing to randomness generation
/// @notice - reward in $nanoWIT received by every contributing node in the Witnet blockchain
Expand Down
8 changes: 4 additions & 4 deletions contracts/core/base/WitOracleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ abstract contract WitOracleBase

/// @notice Estimate the extra reward (i.e. over the base fee) to be paid when posting a new
/// @notice data query in order to avoid getting provable "too low incentives" results from
/// @notice the Wit/oracle blockchain.
/// @notice the Wit/Oracle blockchain.
/// @dev The extra fee gets calculated in proportion to:
/// @param _evmGasPrice Tentative EVM gas price at the moment the query result is ready.
/// @param _evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/oracle blockchain.
/// @param _querySLA The query SLA data security parameters as required for the Wit/oracle blockchain.
/// @param _evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/Oracle blockchain.
/// @param _querySLA The query SLA data security parameters as required for the Wit/Oracle blockchain.
function estimateExtraFee(
uint256 _evmGasPrice,
uint256 _evmWitPrice,
Expand Down Expand Up @@ -400,7 +400,7 @@ abstract contract WitOracleBase
);
}

/// @notice Enables data requesters to settle the actual validators in the Wit/oracle
/// @notice Enables data requesters to settle the actual validators in the Wit/Oracle
/// @notice sidechain that will be entitled whatsover to solve
/// @notice data requests, as presumed to be capable of supporting some given `Wit2.Capability`.
function settleMyOwnCapableCommittee(
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/base/WitOracleBaseTrustless.sol
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ abstract contract WitOracleBaseTrustless
// ================================================================================================================
// --- Overrides IWitOracle (trustlessly) -------------------------------------------------------------------------

/// @notice Verify the data report was actually produced by the Wit/oracle sidechain,
/// @notice Verify the data report was actually produced by the Wit/Oracle sidechain,
/// @notice reverting if the verification fails, or returning the self-contained Witnet.Result value.
function pushData(
Witnet.DataPushReport calldata _report,
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/trustable/WitOracleTrustableOvm2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ contract WitOracleTrustableOvm2

/// @notice Estimate the extra reward (i.e. over the base fee) to be paid when posting a new
/// @notice data query in order to avoid getting provable "too low incentives" results from
/// @notice the Wit/oracle blockchain.
/// @notice the Wit/Oracle blockchain.
/// @dev The extra fee gets calculated in proportion to:
/// @param _evmGasPrice Tentative EVM gas price at the moment the query result is ready.
/// @param _evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/oracle blockchain.
/// @param _querySLA The query SLA data security parameters as required for the Wit/oracle blockchain.
/// @param _evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/Oracle blockchain.
/// @param _querySLA The query SLA data security parameters as required for the Wit/Oracle blockchain.
function estimateExtraFee(
uint256 _evmGasPrice,
uint256 _evmWitPrice,
Expand Down
24 changes: 12 additions & 12 deletions contracts/interfaces/IWitOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ interface IWitOracle {

/// @notice Estimate the extra reward (i.e. over the base fee) to be paid when posting a new
/// @notice data query in order to avoid getting provable "too low incentives" results from
/// @notice the Wit/oracle blockchain.
/// @notice the Wit/Oracle blockchain.
/// @dev The extra fee gets calculated in proportion to:
/// @param evmGasPrice Tentative EVM gas price at the moment the query result is ready.
/// @param evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/oracle blockchain.
/// @param querySLA The query SLA data security parameters as required for the Wit/oracle blockchain.
/// @param evmWitPrice Tentative nanoWit price in Wei at the moment the query is solved on the Wit/Oracle blockchain.
/// @param querySLA The query SLA data security parameters as required for the Wit/Oracle blockchain.
function estimateExtraFee(uint256 evmGasPrice, uint256 evmWitPrice, Witnet.QuerySLA calldata querySLA) external view returns (uint256);

/// @notice Returns next query id to be generated by the Witnet Request Board.
Expand Down Expand Up @@ -60,35 +60,35 @@ interface IWitOracle {
/// @notice Get current status of all given query ids.
function getQueryStatusBatch(Witnet.QueryId[] calldata) external view returns (Witnet.QueryStatus[] memory);

/// @notice Request real world data from the Wit/oracle sidechain.
/// @notice Request real world data from the Wit/Oracle sidechain.
/// @notice The paid fee is escrowed as a reward for the reporter that eventually relays back
/// @notice a valid query result from the Wit/oracle sidechain.
/// @notice a valid query result from the Wit/Oracle sidechain.
/// @notice Query results are CBOR-encoded, and can contain either some data, or an error.
/// @dev Reasons to revert:
/// @dev - the data request's RAD hash was not previously verified into the WitOracleRadonRegistry contract;
/// @dev - invalid query SLA parameters were provided;
/// @dev - insufficient value is paid as reward.
/// @param drRadHash The RAD hash of the data request to be solved by Wit/oracle sidechain.
/// @param drRadHash The RAD hash of the data request to be solved by Wit/Oracle sidechain.
function postQuery(bytes32 drRadHash, Witnet.QuerySLA calldata)
external payable returns (Witnet.QueryId);

/// @notice Request real world data from the Wit/oracle sidechain.
/// @notice Request real world data from the Wit/Oracle sidechain.
/// @notice The paid fee is escrowed as a reward for the reporter that eventually relays back
/// @notice a valid query result from the Wit/oracle sidechain.
/// @notice a valid query result from the Wit/Oracle sidechain.
/// @notice The Witnet-provable result will be reported directly to the requesting contract.
/// @notice Query results are CBOR-encoded, and can contain either some data, or an error.
/// @dev Reasons to revert:
/// @dev - the data request's RAD hash was not previously verified into the Radon Registry;
/// @dev - invalid query SLA parameters were provided;
/// @dev - insufficient value is paid as reward.
/// @dev - passed `consumer` is not a contract implementing the IWitOracleConsumer interface;
/// @param drRadHash The RAD hash of the data request to be solved by Wit/oracle sidechain.
/// @param drRadHash The RAD hash of the data request to be solved by Wit/Oracle sidechain.
function postQuery(bytes32 drRadHash, Witnet.QuerySLA calldata, Witnet.QueryCallback calldata)
external payable returns (Witnet.QueryId);

/// @notice Request real world data from the Wit/oracle sidechain.
/// @notice Request real world data from the Wit/Oracle sidechain.
/// @notice The paid fee is escrowed as a reward for the reporter that eventually relays back
/// @notice a valid query result from the Wit/oracle sidechain.
/// @notice a valid query result from the Wit/Oracle sidechain.
/// @notice The Witnet-provable result will be reported directly to the requesting contract.
/// @notice Query results are CBOR-encoded, and can contain either some data, or an error.
/// @dev Reasons to revert:
Expand All @@ -105,7 +105,7 @@ interface IWitOracle {
/// @notice calling postRequest(bytes32,..) methods.
function registry() external view returns (WitOracleRadonRegistry);

/// @notice Enables data requesters to settle the actual validators in the Wit/oracle
/// @notice Enables data requesters to settle the actual validators in the Wit/Oracle
/// @notice sidechain that will be entitled to solve data requests requiring to
/// @notice support the specified `Wit2.Capability`.
function settleMyOwnCapableCommittee(Witnet.QueryCapability, Witnet.QueryCapabilityMember[] calldata) external;
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IWitOracleRadonRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface IWitOracleRadonRegistry {

/// Verifies and registers the given sequence of dataset filters and reducing function to be
/// potentially used as either Aggregate or Tally reducers within the resolution workflow
/// of Radon Requests in the Wit/oracle blockchain. Returns a unique hash that identifies the
/// of Radon Requests in the Wit/Oracle blockchain. Returns a unique hash that identifies the
/// given Radon Reducer in the registry. Reverts if unsupported reducing or filtering methods
/// are specified.
function verifyRadonReducer(Witnet.RadonReducer calldata reducer) external returns (bytes32 hash);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IWitOracleTrustless.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../libs/Witnet.sol";

interface IWitOracleTrustless {

/// @notice Verify the data report was actually produced by the Wit/oracle sidechain,
/// @notice Verify the data report was actually produced by the Wit/Oracle sidechain,
/// @notice reverting if the verification fails, or returning the self-contained Witnet.Result value.
function pushData(
Witnet.DataPushReport calldata report,
Expand Down
12 changes: 6 additions & 6 deletions contracts/interfaces/IWitRandomness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IWitRandomness {
function estimateRandomizeFee(uint256 evmGasPrice) external view returns (uint256);

/// @notice Retrieves the result of keccak256-hashing the given block number with the randomness value
/// @notice generated by the Wit/oracle blockchain in response to the first non-failing randomize request solved
/// @notice generated by the Wit/Oracle blockchain in response to the first non-failing randomize request solved
/// @notice after such block number.
/// @dev Reverts if:
/// @dev i. no `randomize()` was requested on neither the given block, nor afterwards.
Expand All @@ -23,7 +23,7 @@ interface IWitRandomness {
function fetchRandomnessAfter(Witnet.BlockNumber blockNumber) external view returns (bytes32);

/// @notice Retrieves the actual random value, unique hash and timestamp of the witnessing commit/reveal act that took
/// @notice place in the Wit/oracle blockchain in response to the first non-failing randomize request
/// @notice place in the Wit/Oracle blockchain in response to the first non-failing randomize request
/// @notice solved after the given block number.
/// @dev Reverts if:
/// @dev i. no `randomize()` was requested on neither the given block, nor afterwards.
Expand All @@ -41,7 +41,7 @@ interface IWitRandomness {
function getLastRandomizeBlock() external view returns (Witnet.BlockNumber);

/// @notice Retrieves metadata related to the randomize request that got posted to the
/// @notice Wit/oracle contract on the given block number.
/// @notice Wit/Oracle contract on the given block number.
/// @dev Returns zero values if no randomize request was actually posted on the given block.
/// @return queryId Identifier of the underlying Witnet query created on the given block number.
/// @return prevRandomizeBlock Block number in which a randomize request got posted just before this one. 0 if none.
Expand Down Expand Up @@ -92,20 +92,20 @@ interface IWitRandomness {
function random(uint32 range, uint256 nonce, Witnet.BlockNumber blockNumber) external view returns (uint32);

/// @notice Requests the Witnet oracle to generate an EVM-agnostic and trustless source of randomness.
/// @dev Only one randomness request per block will be actually posted to the Wit/oracle.
/// @dev Only one randomness request per block will be actually posted to the Wit/Oracle.
/// @dev Unused funds will be transferred back to the `msg.sender`.
/// @return Funds actually paid as randomize fee.
function randomize() external payable returns (uint256);

/// @notice Requests the Witnet oracle to generate an EVM-agnostic and trustless source of randomness,
/// @notice while fulfilling the given SLA data security parameters.
/// @dev Only one randomness request per block will be actually posted to the Wit/oracle.
/// @dev Only one randomness request per block will be actually posted to the Wit/Oracle.
/// @dev Unused funds will be transferred back to the `msg.sender`.
/// @dev Passed SLA security parameters must be equal or greater than `witOracleDefaultQuerySLA()`.
/// @return Funds actually paid as randomize fee.
function randomize(Witnet.QuerySLA calldata) external payable returns (uint256);

/// @notice Returns the SLA parameters required for the Wit/oracle blockchain to fulfill
/// @notice Returns the SLA parameters required for the Wit/Oracle blockchain to fulfill
/// @notice when solving randomness requests:
/// @notice - number of witnessing nodes contributing to randomness generation
/// @notice - reward in $nanoWIT received per witnessing node in the Witnet blockchain
Expand Down
Loading

0 comments on commit ea3cf70

Please sign in to comment.