Skip to content

Commit

Permalink
Lint warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kidambisrinivas committed Mar 5, 2024
1 parent c70f811 commit ae2823f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
10 changes: 10 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ src = 'src/v0.8/vrf'
test = 'test/v0.8/foundry/vrf' # skips tests for no VRF foundry tests
solc_version = '0.8.6'

[profile.vrfv2plus_coordinator]
optimizer_runs = 50
src = 'src/v0.8/vrf'
solc_version = '0.8.6'

[profile.vrfv2plus]
optimizer_runs = 1_000_000
src = 'src/v0.8/vrf'
solc_version = '0.8.6'

[profile.automation]
optimizer_runs = 10000
src = 'src/v0.8/automation'
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
uint256 weiPerUnitGas,
bool nativePayment,
bool onlyPremium
) internal returns (uint96) {
) internal view returns (uint96) {
if (nativePayment) {
return _calculatePaymentAmountNative(startGas, weiPerUnitGas, onlyPremium);
}
Expand All @@ -514,7 +514,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
uint256 startGas,
uint256 weiPerUnitGas,
bool onlyPremium
) internal returns (uint96) {
) internal view returns (uint96) {
// Will return non-zero on chains that have this enabled
uint256 l1CostWei = ChainSpecificUtil._getCurrentTxL1GasFees(msg.data);
// calculate the payment without the premium
Expand All @@ -533,7 +533,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
uint256 startGas,
uint256 weiPerUnitGas,
bool onlyPremium
) internal returns (uint96) {
) internal view returns (uint96) {
int256 weiPerUnitLink;
weiPerUnitLink = _getFeedData();
if (weiPerUnitLink <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract ExposedVRFCoordinatorV2_5 is VRFCoordinatorV2_5 {
uint256 weiPerUnitGas,
bool nativePayment,
bool onlyPremium
) external returns (uint96) {
) external view returns (uint96) {
return _calculatePaymentAmount(startGas, weiPerUnitGas, nativePayment, onlyPremium);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ contract VRFV2PlusLoadTestWithMetrics is VRFConsumerBaseV2Plus {
uint256 _slowestResponseTime,
uint256 _averageInMillions,
uint256 _responseCount
) internal returns (uint256 slowest, uint256 fastest, uint256 average) {
) internal pure returns (uint256 slowest, uint256 fastest, uint256 average) {
uint256 _requestDelayInMillions = _responseTime * 1_000_000;
if (_responseTime > _slowestResponseTime) {
_slowestResponseTime = _responseTime;
}
_fastestResponseTime = _responseTime < _fastestResponseTime ? _responseTime : _fastestResponseTime;
uint256 _averageInMillions = _responseCount > 0
uint256 averageInMillions = _responseCount > 0
? (_averageInMillions * _responseCount + _requestDelayInMillions) / (_responseCount + 1)
: _requestDelayInMillions;

return (_slowestResponseTime, _fastestResponseTime, _averageInMillions);
return (_slowestResponseTime, _fastestResponseTime, averageInMillions);
}
}
10 changes: 5 additions & 5 deletions contracts/src/v0.8/vrf/testhelpers/VRFMockETHLINKAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ contract VRFMockETHLINKAggregator is AggregatorV3Interface {
int256 public answer;
uint256 private blockTimestampDeduction = 0;

constructor(int256 _answer) public {
constructor(int256 _answer) {
answer = _answer;
}

function decimals() external view override returns (uint8) {
function decimals() external pure override returns (uint8) {
return 18;
}

function description() external view override returns (string memory) {
function description() external pure override returns (string memory) {
return "VRFMockETHLINKAggregator";
}

function version() external view override returns (uint256) {
function version() external pure override returns (uint256) {
return 1;
}

function getRoundData(
uint80 _roundId
uint80 /*_roundId*/
)
external
view
Expand Down
18 changes: 10 additions & 8 deletions contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,16 @@ contract VRFV2Plus is BaseTest {
vm.roll(requestBlock);
s_linkToken.transfer(address(s_testConsumer), 10 ether);
s_testConsumer.createSubscriptionAndFund(10 ether);
uint256 subId = s_testConsumer.s_subId();
subId = s_testConsumer.s_subId();

// Apply basic configs to contract.
setConfig();
registerProvingKey();

// Request random words.
vm.expectEmit(true, true, false, true);
(uint256 requestId, uint256 preSeed) = s_testCoordinator.computeRequestIdExternal(
uint256 preSeed;
(requestId, preSeed) = s_testCoordinator.computeRequestIdExternal(
vrfKeyHash,
address(s_testConsumer),
subId,
Expand Down Expand Up @@ -460,7 +461,7 @@ contract VRFV2Plus is BaseTest {
-block-num 20 \
-sender 0x90A8820424CC8a819d14cBdE54D12fD3fbFa9bb2
*/
VRF.Proof memory proof = VRF.Proof({
proof = VRF.Proof({
pk: [
72488970228380509287422715226575535698893157273063074627791787432852706183111,
62070622898698443831883535403436258712770888294397026493185421712108624767191
Expand All @@ -483,7 +484,7 @@ contract VRFV2Plus is BaseTest {
],
zInv: 100579074451139970455673776933943662313989441807178260211316504761358492254052
});
VRFCoordinatorV2_5.RequestCommitment memory rc = VRFCoordinatorV2_5.RequestCommitment({
rc = VRFCoordinatorV2_5.RequestCommitment({
blockNum: requestBlock,
subId: subId,
callbackGasLimit: 1000000,
Expand All @@ -501,7 +502,7 @@ contract VRFV2Plus is BaseTest {
uint32 requestBlock = 10;
vm.roll(requestBlock);
s_testConsumer.createSubscriptionAndFund(0);
uint256 subId = s_testConsumer.s_subId();
subId = s_testConsumer.s_subId();
s_testCoordinator.fundSubscriptionWithNative{value: 10 ether}(subId);

// Apply basic configs to contract.
Expand All @@ -510,7 +511,8 @@ contract VRFV2Plus is BaseTest {

// Request random words.
vm.expectEmit(true, true, true, true);
(uint256 requestId, uint256 preSeed) = s_testCoordinator.computeRequestIdExternal(
uint256 preSeed;
(requestId, preSeed) = s_testCoordinator.computeRequestIdExternal(
vrfKeyHash,
address(s_testConsumer),
subId,
Expand Down Expand Up @@ -553,7 +555,7 @@ contract VRFV2Plus is BaseTest {
-sender 0x90A8820424CC8a819d14cBdE54D12fD3fbFa9bb2 \
-native-payment true
*/
VRF.Proof memory proof = VRF.Proof({
proof = VRF.Proof({
pk: [
72488970228380509287422715226575535698893157273063074627791787432852706183111,
62070622898698443831883535403436258712770888294397026493185421712108624767191
Expand All @@ -576,7 +578,7 @@ contract VRFV2Plus is BaseTest {
],
zInv: 97568175302326019383632009699686265453584842953005404815285123863099260038246
});
VRFCoordinatorV2_5.RequestCommitment memory rc = VRFCoordinatorV2_5.RequestCommitment({
rc = VRFCoordinatorV2_5.RequestCommitment({
blockNum: requestBlock,
subId: subId,
callbackGasLimit: 1_000_000,
Expand Down

0 comments on commit ae2823f

Please sign in to comment.