Skip to content

Commit

Permalink
Prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
austinborn committed Sep 14, 2023
1 parent 7c93caa commit 8f57dcd
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 36 deletions.
10 changes: 8 additions & 2 deletions contracts/src/v0.8/llo-feeds/VerifierProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ contract VerifierProxy is IVerifierProxy, ConfirmedOwner, TypeAndVersionInterfac
}

/// @inheritdoc IVerifierProxy
function verify(bytes calldata payload, bytes calldata feePayload) external payable checkAccess returns (bytes memory) {
function verify(
bytes calldata payload,
bytes calldata feePayload
) external payable checkAccess returns (bytes memory) {
IVerifierFeeManager feeManager = s_feeManager;

// Bill the verifier
Expand All @@ -133,7 +136,10 @@ contract VerifierProxy is IVerifierProxy, ConfirmedOwner, TypeAndVersionInterfac
}

/// @inheritdoc IVerifierProxy
function verifyBulk(bytes[] calldata payloads, bytes calldata feePayload) external payable checkAccess returns (bytes[] memory verifiedReports) {
function verifyBulk(
bytes[] calldata payloads,
bytes calldata feePayload
) external payable checkAccess returns (bytes[] memory verifiedReports) {
IVerifierFeeManager feeManager = s_feeManager;

// Bill the verifier
Expand Down
18 changes: 15 additions & 3 deletions contracts/src/v0.8/llo-feeds/dev/FeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,16 @@ contract FeeManager is IFeeManager, ConfirmedOwner, TypeAndVersionInterface {
}

/// @inheritdoc IVerifierFeeManager
function processFee(bytes calldata payload, bytes calldata feePayload, address subscriber) external payable override onlyProxy {
(Common.Asset memory fee, Common.Asset memory reward, uint256 appliedDiscount) = _processFee(payload, feePayload, subscriber);
function processFee(
bytes calldata payload,
bytes calldata feePayload,
address subscriber
) external payable override onlyProxy {
(Common.Asset memory fee, Common.Asset memory reward, uint256 appliedDiscount) = _processFee(
payload,
feePayload,
subscriber
);

if (fee.amount == 0) {
_tryReturnChange(subscriber, msg.value);
Expand All @@ -188,7 +196,11 @@ contract FeeManager is IFeeManager, ConfirmedOwner, TypeAndVersionInterface {
}

/// @inheritdoc IVerifierFeeManager
function processFeeBulk(bytes[] calldata payloads, bytes calldata feePayload, address subscriber) external payable override onlyProxy {
function processFeeBulk(
bytes[] calldata payloads,
bytes calldata feePayload,
address subscriber
) external payable override onlyProxy {
FeeAndReward[] memory feesAndRewards = new IFeeManager.FeeAndReward[](payloads.length);

//keep track of the number of fees to prevent over initialising the FeePayment array within _convertToLinkAndNativeFees
Expand Down
10 changes: 8 additions & 2 deletions contracts/src/v0.8/llo-feeds/interfaces/IVerifierProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ interface IVerifierProxy {
* @param feePayload fee metadata for billing
* @return verifierResponse The encoded report from the verifier.
*/
function verify(bytes calldata payload, bytes calldata feePayload) external payable returns (bytes memory verifierResponse);
function verify(
bytes calldata payload,
bytes calldata feePayload
) external payable returns (bytes memory verifierResponse);

/**
* @notice Bulk verifies that the data encoded has been signed
Expand All @@ -24,7 +27,10 @@ interface IVerifierProxy {
* @param feePayload fee metadata for billing
* @return verifiedReports The encoded reports from the verifier.
*/
function verifyBulk(bytes[] calldata payloads, bytes calldata feePayload) external payable returns (bytes[] memory verifiedReports);
function verifyBulk(
bytes[] calldata payloads,
bytes calldata feePayload
) external payable returns (bytes[] memory verifiedReports);

/**
* @notice Sets the verifier address initially, allowing `setVerifier` to be set by this Verifier in the future
Expand Down
34 changes: 10 additions & 24 deletions contracts/src/v0.8/llo-feeds/test/fee-manager/BaseFeeManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,21 @@ contract BaseFeeManagerTest is Test {
}

// solium-disable-next-line no-unused-vars
function getFee(
bytes memory report,
address quote,
address subscriber
) public view returns (Common.Asset memory) {
function getFee(bytes memory report, address quote, address subscriber) public view returns (Common.Asset memory) {
//get the fee
(Common.Asset memory fee, , ) = feeManager.getFeeAndReward(subscriber, report, quote);

return fee;
}

function getReward(
bytes memory report,
address quote,
address subscriber
) public view returns (Common.Asset memory) {
function getReward(bytes memory report, address quote, address subscriber) public view returns (Common.Asset memory) {
//get the reward
(, Common.Asset memory reward, ) = feeManager.getFeeAndReward(subscriber, report, quote);

return reward;
}

function getAppliedDiscount(
bytes memory report,
address quote,
address subscriber
) public view returns (uint256) {
function getAppliedDiscount(bytes memory report, address quote, address subscriber) public view returns (uint256) {
//get the reward
(, , uint256 appliedDiscount) = feeManager.getFeeAndReward(subscriber, report, quote);

Expand Down Expand Up @@ -329,7 +317,12 @@ contract BaseFeeManagerTest is Test {
changePrank(originalAddr);
}

function processFee(bytes[] memory payloads, address subscriber, address feeAddress, uint256 wrappedNativeValue) public {
function processFee(
bytes[] memory payloads,
address subscriber,
address feeAddress,
uint256 wrappedNativeValue
) public {
//record the current address and switch to the recipient
address originalAddr = msg.sender;
changePrank(subscriber);
Expand All @@ -342,14 +335,7 @@ contract BaseFeeManagerTest is Test {
}

function getPayload(bytes memory reportPayload) public pure returns (bytes memory) {
return
abi.encode(
[DEFAULT_CONFIG_DIGEST, 0, 0],
reportPayload,
new bytes32[](1),
new bytes32[](1),
bytes32("")
);
return abi.encode([DEFAULT_CONFIG_DIGEST, 0, 0], reportPayload, new bytes32[](1), new bytes32[](1), bytes32(""));
}

function approveLink(address spender, uint256 quantity, address sender) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest {
bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1));

//processing the fee will transfer the link from the user to the rewardManager
processFee(payload, USER, address(0), 0);
processFee(payload, USER, address(0), 0);
}

function test_processFeeWithDefaultReportPayloadAndQuoteStillVerifies() public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest {
changePrank(originalAddr);
}

function _verifyBulk(bytes[] memory payload, address feeAddress, uint256 wrappedNativeValue, address sender) internal {
function _verifyBulk(
bytes[] memory payload,
address feeAddress,
uint256 wrappedNativeValue,
address sender
) internal {
address originalAddr = msg.sender;
changePrank(sender);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn
signedReports[1] = signedReportV3;
signedReports[2] = signedReportV3;

_approveLink(address(rewardManager), 2* DEFAULT_REPORT_LINK_FEE, USER);
_approveLink(address(rewardManager), 2 * DEFAULT_REPORT_LINK_FEE, USER);

_verifyBulk(signedReports, address(link), 0, USER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest {
function test_revertsIfConfigDigestNotSet() public {
bytes32[3] memory reportContext = s_reportContext;
reportContext[0] = bytes32("wrong-context-digest");
bytes memory signedReport = _generateV1EncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1));
bytes memory signedReport = _generateV1EncodedBlob(
s_testReportOne,
reportContext,
_getSigners(FAULT_TOLERANCE + 1)
);
vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID, reportContext[0]));
changePrank(address(s_verifierProxy));
s_verifier.verify(signedReport, msg.sender);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/contracts/ethereum_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ func (e *EthereumMercuryVerifier) Address() string {
return e.address.Hex()
}

func (e *EthereumMercuryVerifier) Verify(signedReport []byte, feePayload []byte, sender common.Address) error {
func (e *EthereumMercuryVerifier) Verify(signedReport []byte, sender common.Address) error {
opts, err := e.client.TransactionOpts(e.client.GetDefaultWallet())
if err != nil {
return err
Expand Down

0 comments on commit 8f57dcd

Please sign in to comment.