@@ -6,7 +6,6 @@ import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet
6
6
7
7
contract Oracle is IOracle {
8
8
using EnumerableSet for EnumerableSet.Bytes32Set;
9
- using EnumerableSet for EnumerableSet.AddressSet;
10
9
11
10
/// @inheritdoc IOracle
12
11
mapping (bytes32 _responseId = > bytes32 _disputeId ) public disputeOf;
@@ -33,7 +32,7 @@ contract Oracle is IOracle {
33
32
/**
34
33
* @notice The list of the participants for each request
35
34
*/
36
- mapping (bytes32 _requestId = > EnumerableSet.AddressSet _participants ) internal _participants;
35
+ mapping (bytes32 _requestId = > bytes _participants ) internal _participants;
37
36
38
37
/**
39
38
* @notice The finalized response for each request
@@ -194,7 +193,7 @@ contract Oracle is IOracle {
194
193
}
195
194
196
195
_responseId = keccak256 (abi.encodePacked (_proposer, address (this ), _requestId, _responseNonce++ ));
197
- _participants[_requestId]. add ( _proposer);
196
+ _participants[_requestId] = abi.encodePacked (_participants[_requestId], _proposer);
198
197
_responses[_responseId] = _request.responseModule.propose (_requestId, _proposer, _responseData, msg .sender );
199
198
_responseIds[_requestId].add (_responseId);
200
199
@@ -241,7 +240,7 @@ contract Oracle is IOracle {
241
240
}
242
241
243
242
_disputeId = keccak256 (abi.encodePacked (msg .sender , _requestId, _responseId));
244
- _participants[_requestId]. add ( msg .sender );
243
+ _participants[_requestId] = abi.encodePacked (_participants[_requestId], msg .sender );
245
244
246
245
Dispute memory _dispute =
247
246
_request.disputeModule.disputeResponse (_requestId, _responseId, msg .sender , _response.proposer);
@@ -326,8 +325,27 @@ contract Oracle is IOracle {
326
325
|| address (_request.finalityModule) == _module;
327
326
}
328
327
328
+ // @inheritdoc IOracle
329
329
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
+ }
331
349
}
332
350
333
351
/// @inheritdoc IOracle
@@ -436,7 +454,7 @@ contract Oracle is IOracle {
436
454
});
437
455
438
456
_requests[_requestId] = _storedRequest;
439
- _participants[_requestId]. add ( msg .sender );
457
+ _participants[_requestId] = abi.encodePacked (_participants[_requestId], msg .sender );
440
458
441
459
_request.requestModule.setupRequest (_requestId, _request.requestModuleData);
442
460
_request.responseModule.setupRequest (_requestId, _request.responseModuleData);
0 commit comments