Skip to content

Commit

Permalink
Merge branch 'develop' into chore/BCF-2571/nightly-fuzz-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez authored Feb 5, 2024
2 parents c6a8a64 + dc9a073 commit 1889db5
Show file tree
Hide file tree
Showing 53 changed files with 332 additions and 184 deletions.
2 changes: 1 addition & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ solc_version = '0.8.19'
optimizer_runs = 1000000
src = 'src/v0.8/llo-feeds'
test = 'src/v0.8/llo-feeds/test'
solc_version = '0.8.16'
solc_version = '0.8.19'
# We cannot turn on deny_warnings = true as that will hide any CI failure

[profile.shared]
Expand Down
252 changes: 130 additions & 122 deletions contracts/gas-snapshots/llo-feeds.gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_llo-feeds
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo " ┌───────────────────────
echo " │ Compiling Low Latency Oracle contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.16"
SOLC_VERSION="0.8.19"
OPTIMIZE_RUNS=1000000


Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/FeeManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol";
import {IFeeManager} from "./interfaces/IFeeManager.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/RewardManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol";
import {IRewardManager} from "./interfaces/IRewardManager.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/Verifier.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol";
import {IVerifier} from "./interfaces/IVerifier.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/VerifierProxy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol";
import {IVerifierProxy} from "./interfaces/IVerifierProxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/interfaces/IFeeManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol";
import {Common} from "../libraries/Common.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/interfaces/IRewardManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol";
import {Common} from "../libraries/Common.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/interfaces/IVerifier.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol";
import {Common} from "../libraries/Common.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol";
import {Common} from "../libraries/Common.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/interfaces/IVerifierProxy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Common} from "../libraries/Common.sol";
import {AccessControllerInterface} from "../../shared/interfaces/AccessControllerInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/libraries/ByteUtil.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

/*
* @title ByteUtil
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/libraries/Common.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

/*
* @title Common
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/llo-feeds/test/ByteUtilTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Test} from "forge-std/Test.sol";
import {ByteUtil} from "../libraries/ByteUtil.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Test} from "forge-std/Test.sol";
import {FeeManager} from "../../FeeManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import "./BaseFeeManager.t.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Common} from "../../libraries/Common.sol";
import "./BaseFeeManager.t.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Common} from "../../libraries/Common.sol";
import "./BaseFeeManager.t.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import "./BaseFeeManager.t.sol";
import {IRewardManager} from "../../interfaces/IRewardManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseTest, BaseTestWithConfiguredVerifierAndFeeManager} from "../verifier/BaseVerifierTest.t.sol";
import {SimpleWriteAccessController} from "../../../shared/access/SimpleWriteAccessController.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {IVerifier} from "../../interfaces/IVerifier.sol";
import {Common} from "../../libraries/Common.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

// ExposedVerifier exposes certain internal Verifier
// methods/structures so that golang code can access them, and we get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import "../../interfaces/IFeeManager.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Test} from "forge-std/Test.sol";
import {ERC20Mock} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/mocks/ERC20Mock.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseRewardManagerTest} from "./BaseRewardManager.t.sol";
import {Common} from "../../libraries/Common.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseRewardManagerTest} from "./BaseRewardManager.t.sol";
import {RewardManager} from "../../RewardManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseRewardManagerTest} from "./BaseRewardManager.t.sol";
import {IRewardManager} from "../../interfaces/IRewardManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseRewardManagerTest} from "./BaseRewardManager.t.sol";
import {Common} from "../../libraries/Common.sol";
Expand Down Expand Up @@ -31,6 +31,21 @@ contract RewardManagerSetRecipientsTest is BaseRewardManagerTest {
setRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_setRewardRecipientWithZeroWeight() public {
//array of recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](5);

//init each recipient with even weights
recipients[0] = Common.AddressAndWeight(DEFAULT_RECIPIENT_1, ONE_PERCENT * 25);
recipients[1] = Common.AddressAndWeight(DEFAULT_RECIPIENT_2, ONE_PERCENT * 25);
recipients[2] = Common.AddressAndWeight(DEFAULT_RECIPIENT_3, ONE_PERCENT * 25);
recipients[3] = Common.AddressAndWeight(DEFAULT_RECIPIENT_4, ONE_PERCENT * 25);
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, 0);

//set the recipients
setRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_setRewardRecipientWithZeroAddress() public {
//array of recipients
Common.AddressAndWeight[] memory recipients = getPrimaryRecipients();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseRewardManagerTest} from "./BaseRewardManager.t.sol";
import {Common} from "../../libraries/Common.sol";
Expand Down Expand Up @@ -105,6 +105,131 @@ contract RewardManagerUpdateRewardRecipientsTest is BaseRewardManagerTest {
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsToDifferentSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](getPrimaryRecipients().length + 4);
for (uint256 i; i < getPrimaryRecipients().length; i++) {
//copy the recipient and set the weight to 0 which implies the recipient is being replaced
recipients[i] = Common.AddressAndWeight(getPrimaryRecipients()[i].addr, 0);
}

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, ONE_PERCENT * 25);
recipients[5] = Common.AddressAndWeight(DEFAULT_RECIPIENT_6, ONE_PERCENT * 25);
recipients[6] = Common.AddressAndWeight(DEFAULT_RECIPIENT_7, ONE_PERCENT * 25);
recipients[7] = Common.AddressAndWeight(DEFAULT_RECIPIENT_8, ONE_PERCENT * 25);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsToDifferentPartialSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](getPrimaryRecipients().length + 2);
for (uint256 i; i < getPrimaryRecipients().length; i++) {
//copy the recipient and set the weight to 0 which implies the recipient is being replaced
recipients[i] = Common.AddressAndWeight(getPrimaryRecipients()[i].addr, 0);
}

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, FIFTY_PERCENT);
recipients[5] = Common.AddressAndWeight(DEFAULT_RECIPIENT_6, FIFTY_PERCENT);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsToDifferentLargerSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](getPrimaryRecipients().length + 5);
for (uint256 i; i < getPrimaryRecipients().length; i++) {
//copy the recipient and set the weight to 0 which implies the recipient is being replaced
recipients[i] = Common.AddressAndWeight(getPrimaryRecipients()[i].addr, 0);
}

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, TEN_PERCENT * 2);
recipients[5] = Common.AddressAndWeight(DEFAULT_RECIPIENT_6, TEN_PERCENT * 2);
recipients[6] = Common.AddressAndWeight(DEFAULT_RECIPIENT_7, TEN_PERCENT * 2);
recipients[7] = Common.AddressAndWeight(DEFAULT_RECIPIENT_8, TEN_PERCENT * 2);
recipients[8] = Common.AddressAndWeight(DEFAULT_RECIPIENT_9, TEN_PERCENT * 2);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsUpdateAndRemoveExistingForLargerSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](9);

//update the existing recipients
recipients[0] = Common.AddressAndWeight(getPrimaryRecipients()[0].addr, 0);
recipients[1] = Common.AddressAndWeight(getPrimaryRecipients()[1].addr, 0);
recipients[2] = Common.AddressAndWeight(getPrimaryRecipients()[2].addr, TEN_PERCENT * 3);
recipients[3] = Common.AddressAndWeight(getPrimaryRecipients()[3].addr, TEN_PERCENT * 3);

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, TEN_PERCENT);
recipients[5] = Common.AddressAndWeight(DEFAULT_RECIPIENT_6, TEN_PERCENT);
recipients[6] = Common.AddressAndWeight(DEFAULT_RECIPIENT_7, TEN_PERCENT);
recipients[7] = Common.AddressAndWeight(DEFAULT_RECIPIENT_8, TEN_PERCENT);
recipients[8] = Common.AddressAndWeight(DEFAULT_RECIPIENT_9, TEN_PERCENT);

//should revert as the weight does not equal 100%
vm.expectRevert(INVALID_WEIGHT_ERROR_SELECTOR);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsUpdateAndRemoveExistingForSmallerSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](5);

//update the existing recipients
recipients[0] = Common.AddressAndWeight(getPrimaryRecipients()[0].addr, 0);
recipients[1] = Common.AddressAndWeight(getPrimaryRecipients()[1].addr, 0);
recipients[2] = Common.AddressAndWeight(getPrimaryRecipients()[2].addr, TEN_PERCENT * 3);
recipients[3] = Common.AddressAndWeight(getPrimaryRecipients()[3].addr, TEN_PERCENT * 2);

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, TEN_PERCENT * 5);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updateRecipientsToDifferentSetWithInvalidWeights() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](getPrimaryRecipients().length + 2);
for (uint256 i; i < getPrimaryRecipients().length; i++) {
//copy the recipient and set the weight to 0 which implies the recipient is being replaced
recipients[i] = Common.AddressAndWeight(getPrimaryRecipients()[i].addr, 0);
}

//add the new recipients individually
recipients[4] = Common.AddressAndWeight(DEFAULT_RECIPIENT_5, TEN_PERCENT * 5);
recipients[5] = Common.AddressAndWeight(DEFAULT_RECIPIENT_6, TEN_PERCENT);

//should revert as the weight will not equal 100%
vm.expectRevert(INVALID_WEIGHT_ERROR_SELECTOR);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updatePartialRecipientsToSubset() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](4);
recipients[0] = Common.AddressAndWeight(DEFAULT_RECIPIENT_1, 0);
recipients[1] = Common.AddressAndWeight(DEFAULT_RECIPIENT_2, 0);
recipients[2] = Common.AddressAndWeight(DEFAULT_RECIPIENT_3, TEN_PERCENT * 5);
recipients[3] = Common.AddressAndWeight(DEFAULT_RECIPIENT_4, TEN_PERCENT * 5);

//updating a recipient should force the funds to be paid out for the primary recipients
updateRewardRecipients(PRIMARY_POOL_ID, recipients, ADMIN);
}

function test_updatePartialRecipientsWithUnderWeightSet() public {
//create a list of containing recipients from the primary configured set, and new recipients
Common.AddressAndWeight[] memory recipients = new Common.AddressAndWeight[](4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {Test} from "forge-std/Test.sol";
import {VerifierProxy} from "../../VerifierProxy.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseTestWithConfiguredVerifierAndFeeManager, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol";
import {Verifier} from "../../Verifier.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseTestWithConfiguredVerifierAndFeeManager, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol";
import {Verifier} from "../../Verifier.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseTest} from "./BaseVerifierTest.t.sol";
import {VerifierProxy} from "../../VerifierProxy.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
pragma solidity 0.8.19;

import {BaseTest} from "./BaseVerifierTest.t.sol";
import {VerifierProxy} from "../../VerifierProxy.sol";
Expand Down
Loading

0 comments on commit 1889db5

Please sign in to comment.