Skip to content

Commit

Permalink
Fix solhint warnings (#11480)
Browse files Browse the repository at this point in the history
* ignore old automation & fix minor vrf

* add more ignore and fix various non-automation

* fix gas diff
  • Loading branch information
RensR authored and Borja Aranda committed Dec 14, 2023
1 parent 17cc63d commit c22b082
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 1 deletion.
8 changes: 8 additions & 0 deletions contracts/.solhintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# 344 warnings
#./src/v0.8/automation

# Ignore frozen Automation code
./src/v0.8/automation/v1_2
./src/v0.8/automation/v1_3
./src/v0.8/automation/v2_0
./src/v0.8/automation/v2_1
./src/v0.8/automation/mocks
./src/v0.8/automation/testhelpers

# Ignore Functions v1.0.0 code that was frozen after audit
./src/v0.8/functions/v1_0_0

Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder",
"publish-beta": "pnpm publish --tag beta",
"publish-prod": "npm dist-tag add @chainlink/[email protected] latest",
"solhint": "solhint --max-warnings 376 \"./src/v0.8/**/*.sol\""
"solhint": "solhint --max-warnings 83 \"./src/v0.8/**/*.sol\""
},
"files": [
"src/v0.8",
Expand Down
1 change: 1 addition & 0 deletions contracts/src/v0.8/ChainlinkClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ abstract contract ChainlinkClient {
s_pendingRequests[requestId] = oracleAddress;
emit ChainlinkRequested(requestId);
require(s_link.transferAndCall(oracleAddress, payment, encodedRequest), "unable to transferAndCall to oracle");
return requestId;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/v0.8/ValidatorProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ contract ValidatorProxy is AggregatorValidatorInterface, TypeAndVersionInterface
current = s_currentAggregator.target;
hasProposal = s_currentAggregator.hasNewProposal;
proposed = s_proposedAggregator;
return (current, hasProposal, proposed);
}

/** VALIDATOR CONFIGURATION FUNCTIONS **/
Expand Down Expand Up @@ -216,6 +217,7 @@ contract ValidatorProxy is AggregatorValidatorInterface, TypeAndVersionInterface
current = s_currentValidator.target;
hasProposal = s_currentValidator.hasNewProposal;
proposed = s_proposedValidator;
return (current, hasProposal, proposed);
}

/**
Expand Down
1 change: 1 addition & 0 deletions contracts/src/v0.8/automation/libraries/internal/Cron.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct Field {
* abstraction called a Spec. The library also includes a spec function, nextTick(), which
* determines the next time a cron job should fire based on the current block timestamp.
*/
// solhint-disable chainlink-solidity/prefix-internal-functions-with-underscore, no-global-import
library Cron {
using strings for *;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ contract ArbitrumSequencerUptimeFeed is
roundId = _roundId;
updatedAt = startedAt;
answeredInRound = roundId;

return (roundId, answer, startedAt, updatedAt, answeredInRound);
}

/// @inheritdoc AggregatorV3Interface
Expand All @@ -305,5 +307,7 @@ contract ArbitrumSequencerUptimeFeed is
startedAt = feedState.latestTimestamp;
updatedAt = startedAt;
answeredInRound = roundId;

return (roundId, answer, startedAt, updatedAt, answeredInRound);
}
}
2 changes: 2 additions & 0 deletions contracts/src/v0.8/l2ep/dev/arbitrum/ArbitrumValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ contract ArbitrumValidator is TypeAndVersionInterface, AggregatorValidatorInterf
message
);
emit L2WithdrawalRequested(id, amount, refundAddr);

return id;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ contract OptimismSequencerUptimeFeed is
} else {
revert NoDataPresent();
}
return (roundId, answer, startedAt, updatedAt, answeredInRound);
}

/// @inheritdoc AggregatorV3Interface
Expand All @@ -262,5 +263,6 @@ contract OptimismSequencerUptimeFeed is
startedAt = feedState.startedAt;
updatedAt = feedState.updatedAt;
answeredInRound = roundId;
return (roundId, answer, startedAt, updatedAt, answeredInRound);
}
}
4 changes: 4 additions & 0 deletions contracts/src/v0.8/llo-feeds/libraries/ByteUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ library ByteUtil {
* @param offset Position to start reading from.
* @return result The uint256 read from the byte array.
*/
// solhint-disable-next-line chainlink-solidity/explicit-returns
function _readUint256(bytes memory data, uint256 offset) internal pure returns (uint256 result) {
//bounds check
if (offset + 32 > data.length) revert MalformedData();
Expand All @@ -32,6 +33,7 @@ library ByteUtil {
* @param offset Position to start reading from.
* @return result The uint192 read from the byte array.
*/
// solhint-disable-next-line chainlink-solidity/explicit-returns
function _readUint192(bytes memory data, uint256 offset) internal pure returns (uint256 result) {
//bounds check
if (offset + 24 > data.length) revert MalformedData();
Expand All @@ -50,6 +52,7 @@ library ByteUtil {
* @param offset Position to start reading from.
* @return result The uint32 read from the byte array.
*/
// solhint-disable-next-line chainlink-solidity/explicit-returns
function _readUint32(bytes memory data, uint256 offset) internal pure returns (uint256 result) {
//bounds check
if (offset + 4 > data.length) revert MalformedData();
Expand All @@ -68,6 +71,7 @@ library ByteUtil {
* @param offset Position to start reading from.
* @return result The uint32 read from the byte array.
*/
// solhint-disable-next-line chainlink-solidity/explicit-returns
function _readAddress(bytes memory data, uint256 offset) internal pure returns (address result) {
//bounds check
if (offset + 20 > data.length) revert MalformedData();
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/v0.8/transmission/dev/ERC-4337/Paymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ contract Paymaster is IPaymaster, ConfirmedOwner {
extraCost = directFundingData.topupAmount;
}
}
return extraCost;
}

/// @dev Deducts user subscription balance after execution.
Expand All @@ -116,6 +117,7 @@ contract Paymaster is IPaymaster, ConfirmedOwner {

function _getCostJuels(uint256 costWei) internal view returns (uint256 costJuels) {
costJuels = (1e18 * costWei) / uint256(_getFeedData());
return costJuels;
}

function _getFeedData() internal view returns (int256) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ library SCALibrary {
hashOfEncoding
)
);
return fullHash;
}

function _recoverSignature(bytes memory signature, bytes32 fullHash) internal pure returns (address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ contract SmartContractAccountFactory {
}

emit ContractCreated(scaAddress);

return scaAddress;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ library SmartContractAccountHelper {
SCA.executeTransactionFromEntryPoint.selector,
abi.encode(endContract, value, block.timestamp + deadline, data)
);
return encoding;
}

function getFullHashForSigning(bytes32 userOpHash, address scaAddress) public view returns (bytes32) {
Expand All @@ -29,6 +30,7 @@ library SmartContractAccountHelper {
address entryPoint
) public pure returns (bytes memory initCode) {
initCode = bytes.concat(INITIALIZE_CODE, abi.encode(owner, entryPoint));
return initCode;
}

function getInitCode(
Expand All @@ -46,6 +48,7 @@ library SmartContractAccountHelper {
initializeCodeWithConstructor
)
);
return initCode;
}

/// @dev Computes the smart contract address that results from a CREATE2 operation, per EIP-1014.
Expand Down
1 change: 1 addition & 0 deletions contracts/src/v0.8/vrf/KeepersVRFConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 {
* @return upkeepNeeded true if and only if at least UPKEEP_INTERVAL seconds have elapsed since the last upkeep or since construction
* of the contract.
*/
// solhint-disable-next-line chainlink-solidity/explicit-returns
function checkUpkeep(
bytes calldata /* checkData */
) external view override returns (bool upkeepNeeded, bytes memory /* performData */) {
Expand Down
7 changes: 7 additions & 0 deletions contracts/src/v0.8/vrf/VRF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ contract VRF {
while (x_ >= FIELD_SIZE) {
x_ = uint256(keccak256(abi.encodePacked(x_)));
}
return x_;
}

// Hash b to a random point which hopefully lies on secp256k1. The y ordinate
Expand All @@ -223,6 +224,7 @@ contract VRF {
p[1] = FIELD_SIZE - p[1];
}
}
return p;
}

// Domain-separation tag for initial hash in _hashToCurve. Corresponds to
Expand All @@ -248,6 +250,7 @@ contract VRF {
while (!_isOnCurve(rv)) {
rv = _newCandidateSecp256k1Point(abi.encodePacked(rv[0]));
}
return rv;
}

/** *********************************************************************
Expand Down Expand Up @@ -294,6 +297,7 @@ contract VRF {
uint256 num2 = mulmod(FIELD_SIZE - x2, z1, FIELD_SIZE);
(x3, z3) = (addmod(num1, num2, FIELD_SIZE), mulmod(z1, z2, FIELD_SIZE));
}
return (x3, z3);
}

// Returns x1/z1*x2/z2=(x1x2)/(z1z2), in projective coordinates on P¹(𝔽ₙ)
Expand All @@ -304,6 +308,7 @@ contract VRF {
uint256 z2
) internal pure returns (uint256 x3, uint256 z3) {
(x3, z3) = (mulmod(x1, x2, FIELD_SIZE), mulmod(z1, z2, FIELD_SIZE));
return (x3, z3);
}

/** **************************************************************************
Expand Down Expand Up @@ -385,6 +390,7 @@ contract VRF {
sz = dx;
}
}
return (sx, sy, sz);
}

// p1+p2, as affine points on secp256k1.
Expand Down Expand Up @@ -577,5 +583,6 @@ contract VRF {
proof.zInv
);
output = uint256(keccak256(abi.encode(VRF_RANDOM_OUTPUT_HASH_PREFIX, proof.gamma)));
return output;
}
}
1 change: 1 addition & 0 deletions contracts/src/v0.8/vrf/VRFCoordinatorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo
// The seed actually used by the VRF machinery, mixing in the blockhash
uint256 actualSeed = uint256(keccak256(abi.encodePacked(proof.seed, blockHash)));
randomness = VRF._randomValueFromVRFProof(proof, actualSeed); // Reverts on failure
return (keyHash, requestId, randomness);
}

/*
Expand Down

0 comments on commit c22b082

Please sign in to comment.