-
Notifications
You must be signed in to change notification settings - Fork 190
feat: add whitelisted proposer OO #4841
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | ||
import "@openzeppelin/contracts/utils/Address.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
import "../../data-verification-mechanism/interfaces/StoreInterface.sol"; | ||
import "../../data-verification-mechanism/interfaces/OracleAncillaryInterface.sol"; | ||
import "../../data-verification-mechanism/interfaces/FinderInterface.sol"; | ||
import "../../data-verification-mechanism/interfaces/IdentifierWhitelistInterface.sol"; | ||
import "../../data-verification-mechanism/implementation/Constants.sol"; | ||
|
||
import "../interfaces/OptimisticOracleV2Interface.sol"; | ||
|
||
import "../../common/implementation/Testable.sol"; | ||
import "../../common/implementation/Lockable.sol"; | ||
import "../../common/implementation/FixedPoint.sol"; | ||
import "../../common/implementation/AncillaryData.sol"; | ||
import "../../common/implementation/AddressWhitelist.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports are not strictly required as we have them in the inherited OptimisticOracleV2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed and replaced with named imports
using SafeERC20 for IERC20; | ||
using Address for address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not directly used in the derived contract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
bytes memory ancillaryData, | ||
address whitelist | ||
) external nonReentrant() onlyOwner() { | ||
customProposerWhitelists[_getId(requester, identifier, timestamp, ancillaryData)] = AddressWhitelistInterface( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to also check if the given request state is State.Requested
. This could help the caller be better assured that the applied whitelist would in fact be effective. Otherwise they could be under impression that the whitelist was set, but in fact the proposal has been already made against the default whitelist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this no longer applies as we want the manager being able to set these before the request has be made
* @notice Sets the requester whitelist. | ||
* @param whitelist address of the whitelist to set. | ||
*/ | ||
function ownerSetRequesterWhitelist(address whitelist) external nonReentrant() onlyOwner() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the sake of completeness, shall we also have similar function for setting the default proposer whitelist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this was my mistake. Good call!
packages/core/contracts/optimistic-oracle-v2/implementation/WhitelistOptimisticOracleV2.sol
Show resolved
Hide resolved
) public override returns (uint256 totalBond) { | ||
AddressWhitelistInterface whitelist = | ||
customProposerWhitelists[_getId(requester, identifier, timestamp, ancillaryData)]; | ||
if (address(whitelist) == address(0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should allow for a request to have no whitelist so it can be proposed by anyone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added AllowAllList
contract that always returns true when checking the address. so admin or manager can set whitelist to this AllowAllList
contract if disabling the whitelist restrictions is desired.
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
require(_getState(requester, identifier, timestamp, ancillaryData) == State.Requested, "setBond: Requested"); | ||
_validateBond(bond); | ||
Request storage request = _getRequest(requester, identifier, timestamp, ancillaryData); | ||
request.requestSettings.bond = bond; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming - it looks like the request sender can still call setBond
directly on the OOv2
and bypass the onlyRequestManager
restriction. That might be acceptable but is this behavior intentded? Same for liveness.
* @param whitelist address of the whitelist to set. | ||
*/ | ||
function _setDefaultProposerWhitelist(address whitelist) internal { | ||
defaultProposerWhitelist = AddressWhitelistInterface(whitelist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we require whitelist != zeroAddress?
* @param ancillaryData ancillary data of the price being requested. | ||
* @return AddressWhitelistInterface the custom proposer whitelist for the request or zero address if not set. | ||
*/ | ||
function getCustomProposerWhitelist( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also extend this to have a function recursing the effective whitelist array and boolean on whether the whitelist is enabled.
No description provided.