Skip to content

Commit

Permalink
Optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Fletch153 committed Aug 13, 2024
1 parent c325e07 commit 2cf1664
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
13 changes: 5 additions & 8 deletions contracts/src/v0.8/llo-feeds/v0.4.0/DestinationFeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,14 @@ contract DestinationFeeManager is IDestinationFeeManager, IDestinationVerifierFe
IERC20(i_linkAddress).approve(address(i_rewardManager), type(uint256).max);
}

modifier onlyOwnerOrVerifier() {
if (msg.sender != s_verifierAddressList[msg.sender] && msg.sender != owner()) revert Unauthorized();
_;
}

modifier onlyVerifier() {
if (msg.sender != s_verifierAddressList[msg.sender]) revert Unauthorized();
_;
}

/// @inheritdoc TypeAndVersionInterface
function typeAndVersion() external pure override returns (string memory) {
return "DestinationFeeManager 1.0.0";
return "DestinationFeeManager 0.4.0";
}

/// @inheritdoc IERC165
Expand Down Expand Up @@ -545,8 +540,10 @@ contract DestinationFeeManager is IDestinationFeeManager, IDestinationVerifierFe
revert InvalidAddress();
}

IERC20(i_linkAddress).approve(address(i_rewardManager), 0);
address linkAddress = i_linkAddress;

IERC20(linkAddress).approve(address(i_rewardManager), 0);
i_rewardManager = IDestinationRewardManager(rewardManagerAddress);
IERC20(i_linkAddress).approve(address(i_rewardManager), type(uint256).max);
IERC20(linkAddress).approve(address(rewardManagerAddress), type(uint256).max);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract DestinationRewardManager is IDestinationRewardManager, ConfirmedOwner,

// @inheritdoc TypeAndVersionInterface
function typeAndVersion() external pure override returns (string memory) {
return "RewardManager 1.0.0";
return "DestinationRewardManager 0.4.0";
}

// @inheritdoc IERC165
Expand All @@ -84,12 +84,12 @@ contract DestinationRewardManager is IDestinationRewardManager, ConfirmedOwner,
}

modifier onlyOwnerOrFeeManager() {
if (msg.sender != owner() && msg.sender != s_feeManagerAddressList[msg.sender]) revert Unauthorized();
if (msg.sender != s_feeManagerAddressList[msg.sender] && msg.sender != owner()) revert Unauthorized();
_;
}

modifier onlyOwnerOrRecipientInPool(bytes32 poolId) {
if (msg.sender != owner() && s_rewardRecipientWeights[poolId][msg.sender] == 0) revert Unauthorized();
if (s_rewardRecipientWeights[poolId][msg.sender] == 0 && msg.sender != owner()) revert Unauthorized();
_;
}

Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/llo-feeds/v0.4.0/DestinationVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract DestinationVerifier is IDestinationVerifier, IDestinationVerifierProxyV
bytes calldata signedReport,
bytes calldata parameterPayload,
address sender
) external payable override checkValidProxy checkAccess(sender) returns (bytes memory) {
) external payable override onlyProxy checkAccess(sender) returns (bytes memory) {
(bytes memory verifierResponse, bytes32 donConfigId) = _verify(signedReport, sender);

address fm = s_feeManager;
Expand All @@ -164,7 +164,7 @@ contract DestinationVerifier is IDestinationVerifier, IDestinationVerifierProxyV
bytes[] calldata signedReports,
bytes calldata parameterPayload,
address sender
) external payable override checkValidProxy checkAccess(sender) returns (bytes[] memory) {
) external payable override onlyProxy checkAccess(sender) returns (bytes[] memory) {
bytes[] memory verifierResponses = new bytes[](signedReports.length);
bytes32[] memory donConfigs = new bytes32[](signedReports.length);

Expand Down Expand Up @@ -276,7 +276,7 @@ contract DestinationVerifier is IDestinationVerifier, IDestinationVerifierProxyV
uint8 f,
Common.AddressAndWeight[] memory recipientAddressesAndWeights,
uint32 activationTime
) internal checkConfigValid(signers.length, f) onlyOwner {
) internal {
// Duplicate addresses would break protocol rules
if (Common._hasDuplicateAddresses(signers)) {
revert NonUniqueSignatures();
Expand Down Expand Up @@ -401,7 +401,7 @@ contract DestinationVerifier is IDestinationVerifier, IDestinationVerifierProxyV
_;
}

modifier checkValidProxy() {
modifier onlyProxy() {
if (address(i_verifierProxy) != msg.sender) {
revert AccessForbidden();
}
Expand All @@ -421,6 +421,6 @@ contract DestinationVerifier is IDestinationVerifier, IDestinationVerifierProxyV

/// @inheritdoc TypeAndVersionInterface
function typeAndVersion() external pure override returns (string memory) {
return "DestinationVerifier 1.0.0";
return "DestinationVerifier 0.4.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract DestinationVerifierProxy is IDestinationVerifierProxy, ConfirmedOwner,

/// @inheritdoc TypeAndVersionInterface
function typeAndVersion() external pure override returns (string memory) {
return "DestinationVerifierProxy 1.0.0";
return "DestinationVerifierProxy 0.4.0";
}

/// @inheritdoc IDestinationVerifierProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ contract DestinationVerifierProxyInitializeVerifierTest is BaseTest {

function test_correctlySetsVersion() public view {
string memory version = s_verifierProxy.typeAndVersion();
assertEq(version, "DestinationVerifierProxy 1.0.0");
assertEq(version, "DestinationVerifierProxy 0.4.0");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract DestinationVerifierConstructorTest is BaseTest {
DestinationVerifier v = new DestinationVerifier(address(s_verifierProxy));
assertEq(v.owner(), ADMIN);
string memory typeAndVersion = s_verifier.typeAndVersion();
assertEq(typeAndVersion, "DestinationVerifier 1.0.0");
assertEq(typeAndVersion, "DestinationVerifier 0.4.0");
}

function test_falseIfIsNotCorrectInterface() public view {
Expand Down

0 comments on commit 2cf1664

Please sign in to comment.