Skip to content

Commit

Permalink
Revert "perf: use sstore2 in createRequest"
Browse files Browse the repository at this point in the history
This reverts commit 33e02ce.
  • Loading branch information
gas1cent committed Oct 29, 2023
1 parent 480806d commit 4806dc9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 67 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"package.json": "sort-package-json"
},
"dependencies": {
"@0xsequence/sstore2": "https://github.com/0xsequence/sstore2",
"@defi-wonderland/solidity-utils": "0.0.0-3e9c8e8b",
"@openzeppelin/contracts": "^4.9.3",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
Expand Down
70 changes: 23 additions & 47 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {SSTORE2} from '@0xsequence/sstore2/contracts/SSTORE2.sol';
import {IOracle} from '../interfaces/IOracle.sol';
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

contract Oracle is IOracle {
using EnumerableSet for EnumerableSet.Bytes32Set;

// mapping(bytes32 _requestId => bytes32 _requestHash) internal _requestHashes;
mapping(bytes32 _requestId => address _pointer) internal _sstore2Pointers;
mapping(bytes32 _requestId => address _pointer) internal _sstoreDataPointers;
mapping(bytes32 _requestId => bytes32 _requestHash) internal _requestHashes;
mapping(bytes32 _requestId => HashedRequest _hashedRequest) internal _hashedRequests;

/// @inheritdoc IOracle
mapping(bytes32 _responseId => bytes32 _disputeId) public disputeOf;
Expand Down Expand Up @@ -451,59 +449,37 @@ contract Oracle is IOracle {
*/
function _createRequest(NewRequest calldata _request) internal returns (bytes32 _requestId) {
uint256 _requestNonce = totalRequestCount++;
// bytes32 _requestHash = keccak256(
// abi.encodePacked(
// _requestNonce,
// _request.requestModule,
// _request.responseModule,
// _request.disputeModule,
// _request.resolutionModule,
// _request.finalityModule
// )
// );

_requestId = keccak256(abi.encodePacked(msg.sender, address(this), _requestNonce));
_requestIds[_requestNonce] = _requestId;
// _requestHashes[_requestId] = _requestHash;
_sstoreDataPointers[_requestId] = SSTORE2.write(
abi.encodePacked(
keccak256(_request.requestModuleData),
keccak256(_request.responseModuleData),
keccak256(_request.disputeModuleData),
keccak256(_request.resolutionModuleData),
keccak256(_request.finalityModuleData)
)
);
_sstore2Pointers[_requestId] = SSTORE2.write(
bytes32 _requestHash = keccak256(
abi.encodePacked(

Check failure on line 453 in solidity/contracts/Oracle.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Missing named parameters. Max unnamed parameters value is 4
_requestNonce,
_request.requestModule,
_request.responseModule,
_request.disputeModule,
_request.resolutionModule,
_request.finalityModule,
msg.sender,
_requestNonce,
block.timestamp
_request.finalityModule
)
);
_requestId = keccak256(abi.encodePacked(msg.sender, address(this), _requestNonce));
_requestIds[_requestNonce] = _requestId;
_requestHashes[_requestId] = _requestHash;

Request memory _storedRequest = Request({
ipfsHash: _request.ipfsHash,
requestModule: _request.requestModule,
responseModule: _request.responseModule,
disputeModule: _request.disputeModule,
resolutionModule: _request.resolutionModule,
finalityModule: _request.finalityModule,
requester: msg.sender,
nonce: uint96(_requestNonce),
createdAt: uint128(block.timestamp),
finalizedAt: 0
});

// Request memory _storedRequest = Request({
// ipfsHash: _request.ipfsHash,
// requestModule: _request.requestModule,
// responseModule: _request.responseModule,
// disputeModule: _request.disputeModule,
// resolutionModule: _request.resolutionModule,
// finalityModule: _request.finalityModule,
// requester: msg.sender,
// nonce: uint96(_requestNonce),
// createdAt: uint128(block.timestamp),
// finalizedAt: 0
// });

// _requests[_requestId] = _storedRequest;
_requests[_requestId] = _storedRequest;
_participants[_requestId] = abi.encodePacked(_participants[_requestId], msg.sender);

emit RequestCreated(_requestId, _sstore2Pointers[_requestId], msg.sender, block.timestamp);
emit RequestCreated(_requestId, _requestHash, msg.sender, block.timestamp);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion solidity/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface IOracle {
* @param _requester The address of the user who created the request
*/
event RequestCreated(
bytes32 indexed _requestId, address _pointer, address indexed _requester, uint256 indexed _blockNumber
bytes32 indexed _requestId, bytes32 _requestHash, address indexed _requester, uint256 indexed _blockNumber
);

/**
Expand Down
18 changes: 0 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@
# yarn lockfile v1


"@0xsequence/create3@https://github.com/0xsequence/create3.git":
version "3.0.0"
resolved "https://github.com/0xsequence/create3.git#acc4703a21ec1d71dc2a99db088c4b1f467530fd"
dependencies:
csv-writer "^1.6.0"

"@0xsequence/sstore2@https://github.com/0xsequence/sstore2":
version "1.1.0"
resolved "https://github.com/0xsequence/sstore2#0a28fe61b6e81de9a05b462a24b9f4ba8c70d5b7"
dependencies:
"@0xsequence/create3" "https://github.com/0xsequence/create3.git"
csv-writer "^1.6.0"

"@babel/code-frame@^7.0.0":
version "7.21.4"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39"
Expand Down Expand Up @@ -1007,11 +994,6 @@ cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

csv-writer@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/csv-writer/-/csv-writer-1.6.0.tgz#d0cea44b6b4d7d3baa2ecc6f3f7209233514bcf9"
integrity sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==

dargs@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"
Expand Down

0 comments on commit 4806dc9

Please sign in to comment.