From c6699c262d2f4657a8e343f610f9cee7fc65dc77 Mon Sep 17 00:00:00 2001 From: moebius <0xmoebius@tutanota.com> Date: Thu, 26 Oct 2023 11:53:14 -0300 Subject: [PATCH] perf: request struct packing --- solidity/contracts/Oracle.sol | 6 +++--- solidity/interfaces/IOracle.sol | 8 ++++---- solidity/test/unit/Oracle.t.sol | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/solidity/contracts/Oracle.sol b/solidity/contracts/Oracle.sol index 03bfef2..a7b5f66 100644 --- a/solidity/contracts/Oracle.sol +++ b/solidity/contracts/Oracle.sol @@ -378,7 +378,7 @@ contract Oracle is IOracle { } _finalizedResponses[_requestId] = _finalizedResponseId; - _request.finalizedAt = block.timestamp; + _request.finalizedAt = uint128(block.timestamp); _finalize(_requestId, _request); } @@ -406,7 +406,7 @@ contract Oracle is IOracle { } } } - _request.finalizedAt = block.timestamp; + _request.finalizedAt = uint128(block.timestamp); _finalize(_requestId, _request); } @@ -448,7 +448,7 @@ contract Oracle is IOracle { finalityModule: _request.finalityModule, requester: msg.sender, nonce: _requestNonce, - createdAt: block.timestamp, + createdAt: uint128(block.timestamp), finalizedAt: 0 }); diff --git a/solidity/interfaces/IOracle.sol b/solidity/interfaces/IOracle.sol index 51b2145..f0d38c5 100644 --- a/solidity/interfaces/IOracle.sol +++ b/solidity/interfaces/IOracle.sol @@ -198,15 +198,15 @@ interface IOracle { */ struct Request { bytes32 ipfsHash; + uint128 createdAt; + uint128 finalizedAt; + uint256 nonce; + address requester; IRequestModule requestModule; IResponseModule responseModule; IDisputeModule disputeModule; IResolutionModule resolutionModule; IFinalityModule finalityModule; - address requester; - uint256 nonce; - uint256 createdAt; - uint256 finalizedAt; } /** diff --git a/solidity/test/unit/Oracle.t.sol b/solidity/test/unit/Oracle.t.sol index e03d9fa..56c15a0 100644 --- a/solidity/test/unit/Oracle.t.sol +++ b/solidity/test/unit/Oracle.t.sol @@ -689,7 +689,7 @@ contract Unit_ProposeResponse is BaseTest { assertEq(_responseIds[1], _secondResponseId); } - function test_proposeResponseRevertsIfAlreadyFinalized(bytes calldata _responseData, uint256 _finalizedAt) public { + function test_proposeResponseRevertsIfAlreadyFinalized(bytes calldata _responseData, uint128 _finalizedAt) public { vm.assume(_finalizedAt > 0); // Create mock request