-
Notifications
You must be signed in to change notification settings - Fork 2
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: access control #52
Conversation
|
||
/// @inheritdoc IOracle | ||
function finalize(IOracle.Request calldata _request, IOracle.Response calldata _response) external { | ||
function finalize( |
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.
Why do we need the msg.senders in finalize? Is there a use for it? If not sure, can you ask in the prophet channel what the intended use is?
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.
commented in the discord channel
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 would be meaningful to revise what each existing implementation of the Prophet modules expects as to the _finalizer
parameter of finalizeRequest()
.
- Apparently, all dispute and resolution modules don't utilize it.
- Moreover, all request and finality modules only do it upon the emission of
RequestFinalized
event (except forEBORequestModule
). - However, the unique response module does so with the aim of identifying whether the argument is an
Oracle::allowedModule
, apart from for the event emission. - Lastly, mind that
CircuitResolverModule
andRootVerificationModule
(both dispute modules) and EBO'sCouncilArbitrator
(not a module) callOracle::finalize
.
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.
Great PR! I think some more testing is missing though. AccessController is also not tested in all of its cases individually. Close to ready!
|
||
/// @inheritdoc IOracle | ||
function finalize(IOracle.Request calldata _request, IOracle.Response calldata _response) external { | ||
function finalize( |
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 would be meaningful to revise what each existing implementation of the Prophet modules expects as to the _finalizer
parameter of finalizeRequest()
.
- Apparently, all dispute and resolution modules don't utilize it.
- Moreover, all request and finality modules only do it upon the emission of
RequestFinalized
event (except forEBORequestModule
). - However, the unique response module does so with the aim of identifying whether the argument is an
Oracle::allowedModule
, apart from for the event emission. - Lastly, mind that
CircuitResolverModule
andRootVerificationModule
(both dispute modules) and EBO'sCouncilArbitrator
(not a module) callOracle::finalize
.
solidity/contracts/Oracle.sol
Outdated
// The caller must be the proposer, unless the response is coming from a dispute module | ||
if (msg.sender != _response.proposer && msg.sender != address(_request.disputeModule)) { | ||
if (_accessControl.user != _response.proposer && _accessControl.user != address(_request.disputeModule)) { |
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.
If I correctly understand the new intended behaviour:
- the user, not the caller, must be the proposer,
- even though the response may come from a dispute module (i.e.,
CircuitResolverModule
orRootVerificationModule
).
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.
Such dispute modules may set themselves as the access control users but not as the proposers; considering that that is the new expected behaviour:
- The user, not the caller, must be the proposer,
- unless the response is coming from a dispute module (i.e.,
CircuitResolverModule
orRootVerificationModule
).
The code comment should be updated accordingly.
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.
👍
solidity/contracts/Oracle.sol
Outdated
external | ||
isApproved(_accessControl.user, _request.accessControlModule) | ||
hasAccess(_request.accessControlModule, PROPOSE_TYPEHASH, abi.encode(_request, _response), _accessControl) | ||
returns (bytes32 _responseId) | ||
{ | ||
_responseId = ValidatorLib._validateResponse(_request, _response); |
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.
Reminder: executing isApproved
and hasAccess
modifiers before any other validation might pose a security vulnerability, given that Oracle
would perform an external call to an arbitrary address with arbitrary data from the user.
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.
Tracked as part of OPT-521
solidity/contracts/Oracle.sol
Outdated
// Needed to avoid stack too deep error | ||
Request memory _usedRequest = _request; | ||
Response memory _usedResponse = _response; | ||
Dispute memory _usedDispute = _dispute; | ||
|
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.
How come defining even more variables fixes the problem?
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.
I'll create a task to track this, but probably we shouldn't merge this PR without fixing it.
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.
Fixed in d34d4ba
@@ -94,10 +101,13 @@ contract BaseTest is Test, Helpers { | |||
event RequestCreated(bytes32 indexed _requestId, IOracle.Request _request, bytes32 _ipfsHash); | |||
event ResponseProposed(bytes32 indexed _requestId, bytes32 indexed _responseId, IOracle.Response _response); | |||
event ResponseDisputed(bytes32 indexed _responseId, bytes32 indexed _disputeId, IOracle.Dispute _dispute); | |||
event OracleRequestFinalized(bytes32 indexed _requestId, bytes32 indexed _responseId, address indexed _caller); | |||
event OracleRequestFinalized(bytes32 indexed _requestId, bytes32 indexed _responseId); |
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 is not blocking the PR, but FYI we can import events from IOracle
instead of defining them in unit tests. For example:
vm.expectEmit(address(_staking));
emit IStaking.Staked(_user, _fuzz.amount);
Note that the emit call includes the full "path" to the event, starting from the interface name. This allows to pull events from anywhere really, reducing the duplication and as well avoiding issues with mismatching declarations of events in interfaces and tests.
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.
Very nice! Tracked in OPT-536
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.
🚀
Closes OPT-493