Skip to content

Commit 3f4540c

Browse files
authored
Merge branch 'dev' into chore/remove-docs-from-core
2 parents debd1b1 + d6ded22 commit 3f4540c

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

solidity/contracts/Oracle.sol

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet
66

77
contract Oracle is IOracle {
88
using EnumerableSet for EnumerableSet.Bytes32Set;
9-
using EnumerableSet for EnumerableSet.AddressSet;
109

1110
/// @inheritdoc IOracle
1211
mapping(bytes32 _responseId => bytes32 _disputeId) public disputeOf;
@@ -33,7 +32,7 @@ contract Oracle is IOracle {
3332
/**
3433
* @notice The list of the participants for each request
3534
*/
36-
mapping(bytes32 _requestId => EnumerableSet.AddressSet _participants) internal _participants;
35+
mapping(bytes32 _requestId => bytes _participants) internal _participants;
3736

3837
/**
3938
* @notice The finalized response for each request
@@ -194,7 +193,7 @@ contract Oracle is IOracle {
194193
}
195194

196195
_responseId = keccak256(abi.encodePacked(_proposer, address(this), _requestId, _responseNonce++));
197-
_participants[_requestId].add(_proposer);
196+
_participants[_requestId] = abi.encodePacked(_participants[_requestId], _proposer);
198197
_responses[_responseId] = _request.responseModule.propose(_requestId, _proposer, _responseData, msg.sender);
199198
_responseIds[_requestId].add(_responseId);
200199

@@ -241,7 +240,7 @@ contract Oracle is IOracle {
241240
}
242241

243242
_disputeId = keccak256(abi.encodePacked(msg.sender, _requestId, _responseId));
244-
_participants[_requestId].add(msg.sender);
243+
_participants[_requestId] = abi.encodePacked(_participants[_requestId], msg.sender);
245244

246245
Dispute memory _dispute =
247246
_request.disputeModule.disputeResponse(_requestId, _responseId, msg.sender, _response.proposer);
@@ -326,8 +325,27 @@ contract Oracle is IOracle {
326325
|| address(_request.finalityModule) == _module;
327326
}
328327

328+
// @inheritdoc IOracle
329329
function isParticipant(bytes32 _requestId, address _user) external view returns (bool _isParticipant) {
330-
_isParticipant = _participants[_requestId].contains(_user);
330+
bytes memory _requestParticipants = _participants[_requestId];
331+
332+
assembly {
333+
let length := mload(_requestParticipants)
334+
let i := 0
335+
336+
// Iterate 20-bytes chunks of the participants data
337+
for {} lt(i, length) { i := add(i, 20) } {
338+
// Load the participant at index i
339+
let _participant := mload(add(add(_requestParticipants, 0x20), i))
340+
341+
// Shift the participant to the right by 96 bits and compare with _user
342+
if eq(shr(96, _participant), _user) {
343+
// Set _isParticipant to true and return
344+
mstore(0x00, 1)
345+
return(0x00, 32)
346+
}
347+
}
348+
}
331349
}
332350

333351
/// @inheritdoc IOracle
@@ -436,7 +454,7 @@ contract Oracle is IOracle {
436454
});
437455

438456
_requests[_requestId] = _storedRequest;
439-
_participants[_requestId].add(msg.sender);
457+
_participants[_requestId] = abi.encodePacked(_participants[_requestId], msg.sender);
440458

441459
_request.requestModule.setupRequest(_requestId, _request.requestModuleData);
442460
_request.responseModule.setupRequest(_requestId, _request.responseModuleData);

solidity/test/integration/IntegrationBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {TestConstants} from '../utils/TestConstants.sol';
2929
// solhint-enable no-unused-import
3030

3131
contract IntegrationBase is DSTestPlus, TestConstants, Helpers {
32-
uint256 public constant FORK_BLOCK = 756_611;
32+
uint256 public constant FORK_BLOCK = 111_361_902;
3333

3434
uint256 internal _initialBalance = 100_000 ether;
3535

solidity/test/unit/Oracle.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ contract ForTest_Oracle is Oracle {
4949
}
5050

5151
function forTest_addParticipant(bytes32 _requestId, address _participant) external {
52-
_participants[_requestId].add(_participant);
52+
_participants[_requestId] = abi.encodePacked(_participants[_requestId], _participant);
5353
}
5454

5555
function forTest_setFinalizedResponseId(bytes32 _requestId, bytes32 _finalizedResponseId) external {

0 commit comments

Comments
 (0)