Skip to content

Commit

Permalink
perf: do not revalidate response on request finalization
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Aug 14, 2024
1 parent 600e2b5 commit d2a3a23
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 50 deletions.
2 changes: 0 additions & 2 deletions src/contracts/EBOFinalityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ contract EBOFinalityModule is Module, Arbitrable, IEBOFinalityModule {
if (_request.requester != eboRequestCreator) revert EBOFinalityModule_InvalidRequester();

if (_response.requestId != 0) {
_validateResponse(_request, _response);

// TODO: Redeclare the `Response` struct
// emit NewEpoch(_response.epoch, _response.chainId, _response.block);
}
Expand Down
2 changes: 0 additions & 2 deletions src/contracts/EBORequestModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ contract EBORequestModule is Module, Arbitrable, IEBORequestModule {
// RequestParameters memory _params = decodeRequestData(_request.requestModuleData);

if (_response.requestId != 0) {
_validateResponse(_request, _response);

// TODO: Bond for the rewards
}

Expand Down
23 changes: 0 additions & 23 deletions test/unit/EBOFinalityModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity ^0.8.19;

import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol';
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol';
import {IValidator} from '@defi-wonderland/prophet-core/solidity/interfaces/IValidator.sol';
import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol';

import {IArbitrable} from 'interfaces/IArbitrable.sol';
import {IEBOFinalityModule} from 'interfaces/IEBOFinalityModule.sol';
Expand Down Expand Up @@ -167,27 +165,6 @@ contract EBOFinalityModule_Unit_FinalizeRequest is EBOFinalityModule_Unit_BaseTe
eboFinalityModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_revertInvalidResponseBody(
FinalizeRequestParams memory _params,
bytes32 _requestId
) public happyPath(_params) {
vm.assume(_params.finalizeWithResponse);
vm.assume(_requestId != 0);
vm.assume(_requestId != _getId(_params.request));
_params.response.requestId = _requestId;

vm.expectRevert(ValidatorLib.ValidatorLib_InvalidResponseBody.selector);
eboFinalityModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_revertInvalidResponse(FinalizeRequestParams memory _params) public happyPath(_params) {
vm.assume(_params.finalizeWithResponse);
vm.mockCall(address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(_params.response))), abi.encode(0));

vm.expectRevert(IValidator.Validator_InvalidResponse.selector);
eboFinalityModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_emitNewEpoch(FinalizeRequestParams memory _params) public happyPath(_params) {
vm.assume(_params.finalizeWithResponse);

Expand Down
23 changes: 0 additions & 23 deletions test/unit/EBORequestModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity ^0.8.19;

import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol';
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol';
import {IValidator} from '@defi-wonderland/prophet-core/solidity/interfaces/IValidator.sol';
import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol';
import {IAccountingExtension} from
'@defi-wonderland/prophet-modules/solidity/interfaces/extensions/IAccountingExtension.sol';

Expand Down Expand Up @@ -184,27 +182,6 @@ contract EBORequestModule_Unit_FinalizeRequest is EBORequestModule_Unit_BaseTest
eboRequestModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_revertInvalidResponseBody(
FinalizeRequestParams memory _params,
bytes32 _requestId
) public happyPath(_params) {
vm.assume(_params.finalizeWithResponse);
vm.assume(_requestId != 0);
vm.assume(_requestId != _getId(_params.request));
_params.response.requestId = _requestId;

vm.expectRevert(ValidatorLib.ValidatorLib_InvalidResponseBody.selector);
eboRequestModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_revertInvalidResponse(FinalizeRequestParams memory _params) public happyPath(_params) {
vm.assume(_params.finalizeWithResponse);
vm.mockCall(address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(_params.response))), abi.encode(0));

vm.expectRevert(IValidator.Validator_InvalidResponse.selector);
eboRequestModule.finalizeRequest(_params.request, _params.response, _params.finalizer);
}

function test_emitRequestFinalized(FinalizeRequestParams memory _params) public happyPath(_params) {
vm.expectEmit();
emit RequestFinalized(_params.response.requestId, _params.response, _params.finalizer);
Expand Down

0 comments on commit d2a3a23

Please sign in to comment.