diff --git a/contracts/src/v0.8/vrf/BatchBlockhashStore.sol b/contracts/src/v0.8/vrf/BatchBlockhashStore.sol index 54054344fe7..e55616924cd 100644 --- a/contracts/src/v0.8/vrf/BatchBlockhashStore.sol +++ b/contracts/src/v0.8/vrf/BatchBlockhashStore.sol @@ -29,7 +29,7 @@ contract BatchBlockhashStore { for (uint256 i = 0; i < blockNumbers.length; i++) { // skip the block if it's not storeable, the caller will have to check // after the transaction is mined to see if the blockhash was truly stored. - if (!storeableBlock(blockNumbers[i])) { + if (!_storeableBlock(blockNumbers[i])) { continue; } BHS.store(blockNumbers[i]); @@ -73,8 +73,7 @@ contract BatchBlockhashStore { * using the blockhash() instruction. * @param blockNumber the block number to check if it's storeable with blockhash() */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function storeableBlock(uint256 blockNumber) private view returns (bool) { + function _storeableBlock(uint256 blockNumber) private view returns (bool) { // handle edge case on simulated chains which possibly have < 256 blocks total. return ChainSpecificUtil._getBlockNumber() <= 256 ? true : blockNumber >= (ChainSpecificUtil._getBlockNumber() - 256); diff --git a/contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol b/contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol index 1072289e88e..b35df41d1e3 100644 --- a/contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol +++ b/contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol @@ -32,10 +32,10 @@ contract BatchVRFCoordinatorV2 { try COORDINATOR.fulfillRandomWords(proofs[i], rcs[i]) returns (uint96 /* payment */) { continue; } catch Error(string memory reason) { - uint256 requestId = getRequestIdFromProof(proofs[i]); + uint256 requestId = _getRequestIdFromProof(proofs[i]); emit ErrorReturned(requestId, reason); } catch (bytes memory lowLevelData) { - uint256 requestId = getRequestIdFromProof(proofs[i]); + uint256 requestId = _getRequestIdFromProof(proofs[i]); emit RawErrorReturned(requestId, lowLevelData); } } @@ -45,8 +45,7 @@ contract BatchVRFCoordinatorV2 { * @notice Returns the proving key hash associated with this public key. * @param publicKey the key to return the hash of. */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) { + function _hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) { return keccak256(abi.encode(publicKey)); } @@ -54,9 +53,8 @@ contract BatchVRFCoordinatorV2 { * @notice Returns the request ID of the request associated with the given proof. * @param proof the VRF proof provided by the VRF oracle. */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) { - bytes32 keyHash = hashOfKey(proof.pk); + function _getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) { + bytes32 keyHash = _hashOfKey(proof.pk); return uint256(keccak256(abi.encode(keyHash, proof.seed))); } } diff --git a/contracts/src/v0.8/vrf/KeepersVRFConsumer.sol b/contracts/src/v0.8/vrf/KeepersVRFConsumer.sol index 438696c7f4d..a18c6e03798 100644 --- a/contracts/src/v0.8/vrf/KeepersVRFConsumer.sol +++ b/contracts/src/v0.8/vrf/KeepersVRFConsumer.sol @@ -6,7 +6,6 @@ import {VRFConsumerBaseV2} from "./VRFConsumerBaseV2.sol"; import {VRFCoordinatorV2Interface} from "./interfaces/VRFCoordinatorV2Interface.sol"; // solhint-disable chainlink-solidity/prefix-immutable-variables-with-i -// solhint-disable chainlink-solidity/prefix-internal-functions-with-underscore /** * @title KeepersVRFConsumer @@ -76,7 +75,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 { if ((block.timestamp - s_lastTimeStamp) > UPKEEP_INTERVAL) { s_lastTimeStamp = block.timestamp; - requestRandomWords(); + _requestRandomWords(); } } @@ -85,6 +84,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 { * @param requestId the VRF V2 request ID, provided at request time. * @param randomWords the randomness provided by Chainlink VRF. */ + // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override { // Check that the request exists. If not, revert. RequestRecord memory record = s_requests[requestId]; @@ -99,7 +99,7 @@ contract KeepersVRFConsumer is KeeperCompatibleInterface, VRFConsumerBaseV2 { /** * @notice Requests random words from Chainlink VRF. */ - function requestRandomWords() internal { + function _requestRandomWords() internal { uint256 requestId = COORDINATOR.requestRandomWords( KEY_HASH, SUBSCRIPTION_ID, diff --git a/contracts/src/v0.8/vrf/VRF.sol b/contracts/src/v0.8/vrf/VRF.sol index 7ec5f2d5a60..a19fc39ec3e 100644 --- a/contracts/src/v0.8/vrf/VRF.sol +++ b/contracts/src/v0.8/vrf/VRF.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.0; * **************************************************************************** * @dev USAGE - * @dev The main entry point is randomValueFromVRFProof. See its docstring. + * @dev The main entry point is _randomValueFromVRFProof. See its docstring. * **************************************************************************** * @dev PURPOSE @@ -57,18 +57,18 @@ pragma solidity ^0.8.0; * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.5 * @dev For curve-point multiplication, it's much cheaper to abuse ECRECOVER - * @dev - hashToCurve recursively hashes until it finds a curve x-ordinate. On + * @dev - _hashToCurve recursively hashes until it finds a curve x-ordinate. On * @dev the EVM, this is slightly more efficient than the recommendation in * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.1.1 * @dev step 5, to concatenate with a nonce then hash, and rehash with the * @dev nonce updated until a valid x-ordinate is found. - * @dev - hashToCurve does not include a cipher version string or the byte 0x1 + * @dev - _hashToCurve does not include a cipher version string or the byte 0x1 * @dev in the hash message, as recommended in step 5.B of the draft * @dev standard. They are unnecessary here because no variation in the * @dev cipher suite is allowed. - * @dev - Similarly, the hash input in scalarFromCurvePoints does not include a + * @dev - Similarly, the hash input in _scalarFromCurvePoints does not include a * @dev commitment to the cipher suite, either, which differs from step 2 of * @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.3 * @dev . Also, the hash input is the concatenation of the uncompressed @@ -88,7 +88,7 @@ pragma solidity ^0.8.0; * @dev Full uniqueness: For any seed and valid VRF public key, there is * @dev exactly one VRF output which can be proved to come from that seed, in - * @dev the sense that the proof will pass verifyVRFProof. + * @dev the sense that the proof will pass _verifyVRFProof. * @dev Full collision resistance: It's cryptographically infeasible to find * @dev two seeds with same VRF output from a fixed, valid VRF key @@ -110,13 +110,13 @@ pragma solidity ^0.8.0; * @dev OTHER SECURITY CONSIDERATIONS * * @dev The seed input to the VRF could in principle force an arbitrary amount - * @dev of work in hashToCurve, by requiring extra rounds of hashing and + * @dev of work in _hashToCurve, by requiring extra rounds of hashing and * @dev checking whether that's yielded the x ordinate of a secp256k1 point. * @dev However, under the Random Oracle Model the probability of choosing a - * @dev point which forces n extra rounds in hashToCurve is 2⁻ⁿ. The base cost - * @dev for calling hashToCurve is about 25,000 gas, and each round of checking + * @dev point which forces n extra rounds in _hashToCurve is 2⁻ⁿ. The base cost + * @dev for calling _hashToCurve is about 25,000 gas, and each round of checking * @dev for a valid x ordinate costs about 15,555 gas, so to find a seed for - * @dev which hashToCurve would cost more than 2,017,000 gas, one would have to + * @dev which _hashToCurve would cost more than 2,017,000 gas, one would have to * @dev try, in expectation, about 2¹²⁸ seeds, which is infeasible for any * @dev foreseeable computational resources. (25,000 + 128 * 15,555 < 2,017,000.) @@ -125,10 +125,10 @@ pragma solidity ^0.8.0; * @dev operation of this contract by choosing an adverse seed. * @dev (See TestMeasureHashToCurveGasCost for verification of the gas cost for - * @dev hashToCurve.) + * @dev _hashToCurve.) - * @dev It may be possible to make a secure constant-time hashToCurve function. - * @dev See notes in hashToCurve docstring. + * @dev It may be possible to make a secure constant-time _hashToCurve function. + * @dev See notes in _hashToCurve docstring. */ contract VRF { // See https://www.secg.org/sec2-v2.pdf, section 2.4.1, for these constants. @@ -142,8 +142,7 @@ contract VRF { // (base^exponent) % FIELD_SIZE // Cribbed from https://medium.com/@rbkhmrcr/precompiles-solidity-e5d29bd428c4 - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function bigModExp(uint256 base, uint256 exponent) internal view returns (uint256 exponentiation) { + function _bigModExp(uint256 base, uint256 exponent) internal view returns (uint256 exponentiation) { uint256 callResult; uint256[6] memory bigModExpContractInputs; bigModExpContractInputs[0] = WORD_LENGTH_BYTES; // Length of base @@ -175,34 +174,30 @@ contract VRF { uint256 private constant SQRT_POWER = (FIELD_SIZE + 1) >> 2; // Computes a s.t. a^2 = x in the field. Assumes a exists - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function squareRoot(uint256 x) internal view returns (uint256) { - return bigModExp(x, SQRT_POWER); + function _squareRoot(uint256 x) internal view returns (uint256) { + return _bigModExp(x, SQRT_POWER); } // The value of y^2 given that (x,y) is on secp256k1. - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function ySquared(uint256 x) internal pure returns (uint256) { + function _ySquared(uint256 x) internal pure returns (uint256) { // Curve is y^2=x^3+7. See section 2.4.1 of https://www.secg.org/sec2-v2.pdf uint256 xCubed = mulmod(x, mulmod(x, x, FIELD_SIZE), FIELD_SIZE); return addmod(xCubed, 7, FIELD_SIZE); } // True iff p is on secp256k1 - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function isOnCurve(uint256[2] memory p) internal pure returns (bool) { + function _isOnCurve(uint256[2] memory p) internal pure returns (bool) { // Section 2.3.6. in https://www.secg.org/sec1-v2.pdf // requires each ordinate to be in [0, ..., FIELD_SIZE-1] // solhint-disable-next-line custom-errors require(p[0] < FIELD_SIZE, "invalid x-ordinate"); // solhint-disable-next-line custom-errors require(p[1] < FIELD_SIZE, "invalid y-ordinate"); - return ySquared(p[0]) == mulmod(p[1], p[1], FIELD_SIZE); + return _ySquared(p[0]) == mulmod(p[1], p[1], FIELD_SIZE); } // Hash x uniformly into {0, ..., FIELD_SIZE-1}. - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function fieldHash(bytes memory b) internal pure returns (uint256 x_) { + function _fieldHash(bytes memory b) internal pure returns (uint256 x_) { x_ = uint256(keccak256(b)); // Rejecting if x >= FIELD_SIZE corresponds to step 2.1 in section 2.3.4 of // http://www.secg.org/sec1-v2.pdf , which is part of the definition of @@ -218,11 +213,10 @@ contract VRF { // step 5.C, which references arbitrary_string_to_point, defined in // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.5 as // returning the point with given x ordinate, and even y ordinate. - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function newCandidateSecp256k1Point(bytes memory b) internal view returns (uint256[2] memory p) { + function _newCandidateSecp256k1Point(bytes memory b) internal view returns (uint256[2] memory p) { unchecked { - p[0] = fieldHash(b); - p[1] = squareRoot(ySquared(p[0])); + p[0] = _fieldHash(b); + p[1] = _squareRoot(_ySquared(p[0])); if (p[1] % 2 == 1) { // Note that 0 <= p[1] < FIELD_SIZE // so this cannot wrap, we use unchecked to save gas. @@ -231,7 +225,7 @@ contract VRF { } } - // Domain-separation tag for initial hash in hashToCurve. Corresponds to + // Domain-separation tag for initial hash in _hashToCurve. Corresponds to // vrf.go/hashToCurveHashPrefix uint256 internal constant HASH_TO_CURVE_HASH_PREFIX = 1; @@ -249,11 +243,10 @@ contract VRF { // // This would greatly simplify the analysis in "OTHER SECURITY CONSIDERATIONS" // https://www.pivotaltracker.com/story/show/171120900 - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function hashToCurve(uint256[2] memory pk, uint256 input) internal view returns (uint256[2] memory rv) { - rv = newCandidateSecp256k1Point(abi.encodePacked(HASH_TO_CURVE_HASH_PREFIX, pk, input)); - while (!isOnCurve(rv)) { - rv = newCandidateSecp256k1Point(abi.encodePacked(rv[0])); + function _hashToCurve(uint256[2] memory pk, uint256 input) internal view returns (uint256[2] memory rv) { + rv = _newCandidateSecp256k1Point(abi.encodePacked(HASH_TO_CURVE_HASH_PREFIX, pk, input)); + while (!_isOnCurve(rv)) { + rv = _newCandidateSecp256k1Point(abi.encodePacked(rv[0])); } } @@ -267,8 +260,7 @@ contract VRF { * @param product: secp256k1 expected to be multiplier * multiplicand * @return verifies true iff product==scalar*multiplicand, with cryptographically high probability */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function ecmulVerify( + function _ecmulVerify( uint256[2] memory multiplicand, uint256 scalar, uint256[2] memory product @@ -289,8 +281,7 @@ contract VRF { } // Returns x1/z1-x2/z2=(x1z2-x2z1)/(z1z2) in projective coordinates on P¹(𝔽ₙ) - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function projectiveSub( + function _projectiveSub( uint256 x1, uint256 z1, uint256 x2, @@ -306,8 +297,7 @@ contract VRF { } // Returns x1/z1*x2/z2=(x1x2)/(z1z2), in projective coordinates on P¹(𝔽ₙ) - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function projectiveMul( + function _projectiveMul( uint256 x1, uint256 z1, uint256 x2, @@ -322,7 +312,7 @@ contract VRF { @dev Using projective coordinates avoids costly divisions @dev To use this with p and q in affine coordinates, call - @dev projectiveECAdd(px, py, qx, qy). This will return + @dev _projectiveECAdd(px, py, qx, qy). This will return @dev the addition of (px, py, 1) and (qx, qy, 1), in the @dev secp256k1 group. @@ -332,7 +322,7 @@ contract VRF { @dev This function assumes [px,py,1],[qx,qy,1] are valid projective coordinates of secp256k1 points. That is safe in this contract, - because this method is only used by linearCombination, which checks + because this method is only used by _linearCombination, which checks points are on the curve via ecrecover. ************************************************************************** @param px The first affine coordinate of the first summand @@ -348,8 +338,7 @@ contract VRF { @return sy @return sz */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function projectiveECAdd( + function _projectiveECAdd( uint256 px, uint256 py, uint256 qx, @@ -360,11 +349,11 @@ contract VRF { // "Guide to Elliptic Curve Cryptography" by Hankerson, Menezes and Vanstone // We take the equations there for (sx,sy), and homogenize them to // projective coordinates. That way, no inverses are required, here, and we - // only need the one inverse in affineECAdd. + // only need the one inverse in _affineECAdd. // We only need the "point addition" equations from Hankerson et al. Can // skip the "point doubling" equations because p1 == p2 is cryptographically - // impossible, and required not to be the case in linearCombination. + // impossible, and required not to be the case in _linearCombination. // Add extra "projective coordinate" to the two points (uint256 z1, uint256 z2) = (1, 1); @@ -376,15 +365,15 @@ contract VRF { uint256 dx; // Accumulates denominator from sx calculation // sx=((qy-py)/(qx-px))^2-px-qx - (sx, dx) = projectiveMul(lx, lz, lx, lz); // ((qy-py)/(qx-px))^2 - (sx, dx) = projectiveSub(sx, dx, px, z1); // ((qy-py)/(qx-px))^2-px - (sx, dx) = projectiveSub(sx, dx, qx, z2); // ((qy-py)/(qx-px))^2-px-qx + (sx, dx) = _projectiveMul(lx, lz, lx, lz); // ((qy-py)/(qx-px))^2 + (sx, dx) = _projectiveSub(sx, dx, px, z1); // ((qy-py)/(qx-px))^2-px + (sx, dx) = _projectiveSub(sx, dx, qx, z2); // ((qy-py)/(qx-px))^2-px-qx uint256 dy; // Accumulates denominator from sy calculation // sy=((qy-py)/(qx-px))(px-sx)-py - (sy, dy) = projectiveSub(px, z1, sx, dx); // px-sx - (sy, dy) = projectiveMul(sy, dy, lx, lz); // ((qy-py)/(qx-px))(px-sx) - (sy, dy) = projectiveSub(sy, dy, py, z1); // ((qy-py)/(qx-px))(px-sx)-py + (sy, dy) = _projectiveSub(px, z1, sx, dx); // px-sx + (sy, dy) = _projectiveMul(sy, dy, lx, lz); // ((qy-py)/(qx-px))(px-sx) + (sy, dy) = _projectiveSub(sy, dy, py, z1); // ((qy-py)/(qx-px))(px-sx)-py if (dx != dy) { // Cross-multiply to put everything over a common denominator @@ -400,13 +389,12 @@ contract VRF { // p1+p2, as affine points on secp256k1. // - // invZ must be the inverse of the z returned by projectiveECAdd(p1, p2). + // invZ must be the inverse of the z returned by _projectiveECAdd(p1, p2). // It is computed off-chain to save gas. // - // p1 and p2 must be distinct, because projectiveECAdd doesn't handle + // p1 and p2 must be distinct, because _projectiveECAdd doesn't handle // point doubling. - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function affineECAdd( + function _affineECAdd( uint256[2] memory p1, uint256[2] memory p2, uint256 invZ @@ -414,7 +402,7 @@ contract VRF { uint256 x; uint256 y; uint256 z; - (x, y, z) = projectiveECAdd(p1[0], p1[1], p2[0], p2[1]); + (x, y, z) = _projectiveECAdd(p1[0], p1[1], p2[0], p2[1]); // solhint-disable-next-line custom-errors require(mulmod(z, invZ, FIELD_SIZE) == 1, "invZ must be inverse of z"); // Clear the z ordinate of the projective representation by dividing through @@ -424,8 +412,7 @@ contract VRF { // True iff address(c*p+s*g) == lcWitness, where g is generator. (With // cryptographically high probability.) - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function verifyLinearCombinationWithGenerator( + function _verifyLinearCombinationWithGenerator( uint256 c, uint256[2] memory p, uint256 s, @@ -457,9 +444,8 @@ contract VRF { // (cryptographically impossible) case that a prover accidentally derives // a proof with equal c*p1 and s*p2, they should retry with a different // proof nonce.) Assumes that all points are on secp256k1 - // (which is checked in verifyVRFProof below.) - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function linearCombination( + // (which is checked in _verifyVRFProof below.) + function _linearCombination( uint256 c, uint256[2] memory p1, uint256[2] memory cp1Witness, @@ -473,18 +459,18 @@ contract VRF { // solhint-disable-next-line custom-errors require((cp1Witness[0] % FIELD_SIZE) != (sp2Witness[0] % FIELD_SIZE), "points in sum must be distinct"); // solhint-disable-next-line custom-errors - require(ecmulVerify(p1, c, cp1Witness), "First mul check failed"); + require(_ecmulVerify(p1, c, cp1Witness), "First mul check failed"); // solhint-disable-next-line custom-errors - require(ecmulVerify(p2, s, sp2Witness), "Second mul check failed"); - return affineECAdd(cp1Witness, sp2Witness, zInv); + require(_ecmulVerify(p2, s, sp2Witness), "Second mul check failed"); + return _affineECAdd(cp1Witness, sp2Witness, zInv); } } - // Domain-separation tag for the hash taken in scalarFromCurvePoints. + // Domain-separation tag for the hash taken in _scalarFromCurvePoints. // Corresponds to scalarFromCurveHashPrefix in vrf.go uint256 internal constant SCALAR_FROM_CURVE_POINTS_HASH_PREFIX = 2; - // Pseudo-random number from inputs. Matches vrf.go/scalarFromCurvePoints, and + // Pseudo-random number from inputs. Matches vrf.go/_scalarFromCurvePoints, and // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.4.3 // The draft calls (in step 7, via the definition of string_to_int, in // https://datatracker.ietf.org/doc/html/rfc8017#section-4.2 ) for taking the @@ -495,8 +481,7 @@ contract VRF { // using the compressed representation of the points, if we collated the y // parities into a single bytes32. // https://www.pivotaltracker.com/story/show/171120588 - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function scalarFromCurvePoints( + function _scalarFromCurvePoints( uint256[2] memory hash, uint256[2] memory pk, uint256[2] memory gamma, @@ -508,15 +493,14 @@ contract VRF { // True if (gamma, c, s) is a correctly constructed randomness proof from pk // and seed. zInv must be the inverse of the third ordinate from - // projectiveECAdd applied to cGammaWitness and sHashWitness. Corresponds to + // _projectiveECAdd applied to cGammaWitness and sHashWitness. Corresponds to // section 5.3 of the IETF draft. // // TODO(alx): Since I'm only using pk in the ecrecover call, I could only pass // the x ordinate, and the parity of the y ordinate in the top bit of uWitness // (which I could make a uint256 without using any extra space.) Would save // about 2000 gas. https://www.pivotaltracker.com/story/show/170828567 - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function verifyVRFProof( + function _verifyVRFProof( uint256[2] memory pk, uint256[2] memory gamma, uint256 c, @@ -529,26 +513,26 @@ contract VRF { ) internal view { unchecked { // solhint-disable-next-line custom-errors - require(isOnCurve(pk), "public key is not on curve"); + require(_isOnCurve(pk), "public key is not on curve"); // solhint-disable-next-line custom-errors - require(isOnCurve(gamma), "gamma is not on curve"); + require(_isOnCurve(gamma), "gamma is not on curve"); // solhint-disable-next-line custom-errors - require(isOnCurve(cGammaWitness), "cGammaWitness is not on curve"); + require(_isOnCurve(cGammaWitness), "cGammaWitness is not on curve"); // solhint-disable-next-line custom-errors - require(isOnCurve(sHashWitness), "sHashWitness is not on curve"); + require(_isOnCurve(sHashWitness), "sHashWitness is not on curve"); // Step 5. of IETF draft section 5.3 (pk corresponds to 5.3's Y, and here // we use the address of u instead of u itself. Also, here we add the // terms instead of taking the difference, and in the proof construction in // vrf.GenerateProof, we correspondingly take the difference instead of // taking the sum as they do in step 7 of section 5.1.) // solhint-disable-next-line custom-errors - require(verifyLinearCombinationWithGenerator(c, pk, s, uWitness), "addr(c*pk+s*g)!=_uWitness"); + require(_verifyLinearCombinationWithGenerator(c, pk, s, uWitness), "addr(c*pk+s*g)!=_uWitness"); // Step 4. of IETF draft section 5.3 (pk corresponds to Y, seed to alpha_string) - uint256[2] memory hash = hashToCurve(pk, seed); + uint256[2] memory hash = _hashToCurve(pk, seed); // Step 6. of IETF draft section 5.3, but see note for step 5 about +/- terms - uint256[2] memory v = linearCombination(c, gamma, cGammaWitness, s, hash, sHashWitness, zInv); + uint256[2] memory v = _linearCombination(c, gamma, cGammaWitness, s, hash, sHashWitness, zInv); // Steps 7. and 8. of IETF draft section 5.3 - uint256 derivedC = scalarFromCurvePoints(hash, pk, gamma, uWitness, v); + uint256 derivedC = _scalarFromCurvePoints(hash, pk, gamma, uWitness, v); // solhint-disable-next-line custom-errors require(c == derivedC, "invalid proof"); } @@ -580,9 +564,8 @@ contract VRF { * @return output i.e., the random output implied by the proof * *************************************************************************** */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function randomValueFromVRFProof(Proof memory proof, uint256 seed) internal view returns (uint256 output) { - verifyVRFProof( + function _randomValueFromVRFProof(Proof memory proof, uint256 seed) internal view returns (uint256 output) { + _verifyVRFProof( proof.pk, proof.gamma, proof.c, diff --git a/contracts/src/v0.8/vrf/VRFCoordinatorV2.sol b/contracts/src/v0.8/vrf/VRFCoordinatorV2.sol index 994e3af7dcb..5150d263a8b 100644 --- a/contracts/src/v0.8/vrf/VRFCoordinatorV2.sol +++ b/contracts/src/v0.8/vrf/VRFCoordinatorV2.sol @@ -315,7 +315,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo if (s_subscriptionConfigs[subId].owner == address(0)) { revert InvalidSubscription(); } - cancelSubscriptionHelper(subId, s_subscriptionConfigs[subId].owner); + _cancelSubscriptionHelper(subId, s_subscriptionConfigs[subId].owner); } /** @@ -387,7 +387,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo // The consequence for users is that they can send requests // for invalid keyHashes which will simply not be fulfilled. uint64 nonce = currentNonce + 1; - (uint256 requestId, uint256 preSeed) = computeRequestId(keyHash, msg.sender, subId, nonce); + (uint256 requestId, uint256 preSeed) = _computeRequestId(keyHash, msg.sender, subId, nonce); s_requestCommitments[requestId] = keccak256( abi.encode(requestId, ChainSpecificUtil._getBlockNumber(), subId, callbackGasLimit, numWords, msg.sender) @@ -416,8 +416,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo return s_requestCommitments[requestId]; } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function computeRequestId( + function _computeRequestId( bytes32 keyHash, address sender, uint64 subId, @@ -431,8 +430,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { + function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow @@ -461,8 +459,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo return success; } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getRandomnessFromProof( + function _getRandomnessFromProof( Proof memory proof, RequestCommitment memory rc ) private view returns (bytes32 keyHash, uint256 requestId, uint256 randomness) { @@ -493,7 +490,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 + randomness = VRF._randomValueFromVRFProof(proof, actualSeed); // Reverts on failure } /* @@ -527,7 +524,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo */ function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) { uint256 startGas = gasleft(); - (bytes32 keyHash, uint256 requestId, uint256 randomness) = getRandomnessFromProof(proof, rc); + (bytes32 keyHash, uint256 requestId, uint256 randomness) = _getRandomnessFromProof(proof, rc); uint256[] memory randomWords = new uint256[](rc.numWords); for (uint256 i = 0; i < rc.numWords; i++) { @@ -541,10 +538,10 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo // Important to not let them exhaust the gas budget and avoid oracle payment. // Do not allow any non-view/non-pure coordinator functions to be called // during the consumers callback code via reentrancyLock. - // Note that callWithExactGas will revert if we do not have sufficient gas + // Note that _callWithExactGas will revert if we do not have sufficient gas // to give the callee their requested amount. s_config.reentrancyLock = true; - bool success = callWithExactGas(rc.callbackGasLimit, rc.sender, resp); + bool success = _callWithExactGas(rc.callbackGasLimit, rc.sender, resp); s_config.reentrancyLock = false; // Increment the req count for fee tier selection. @@ -557,7 +554,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo // We also add the flat link fee to the payment amount. // Its specified in millionths of link, if s_config.fulfillmentFlatFeeLinkPPM = 1 // 1 link / 1e6 = 1e18 juels / 1e6 = 1e12 juels. - uint96 payment = calculatePaymentAmount( + uint96 payment = _calculatePaymentAmount( startGas, s_config.gasAfterPaymentCalculation, getFeeTier(reqCount), @@ -574,15 +571,14 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo } // Get the amount of gas used for fulfillment - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmount( + function _calculatePaymentAmount( uint256 startGas, uint256 gasAfterPaymentCalculation, uint32 fulfillmentFlatFeeLinkPPM, uint256 weiPerUnitGas ) internal view returns (uint96) { int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); + weiPerUnitLink = _getFeedData(); if (weiPerUnitLink <= 0) { revert InvalidLinkWeiPrice(weiPerUnitLink); } @@ -598,8 +594,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo return uint96(paymentNoFee + fee); } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getFeedData() private view returns (int256) { + function _getFeedData() private view returns (int256) { uint32 stalenessSeconds = s_config.stalenessSeconds; bool staleFallback = stalenessSeconds > 0; uint256 timestamp; @@ -770,11 +765,10 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo if (pendingRequestExists(subId)) { revert PendingRequestExists(); } - cancelSubscriptionHelper(subId, to); + _cancelSubscriptionHelper(subId, to); } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function cancelSubscriptionHelper(uint64 subId, address to) private nonReentrant { + function _cancelSubscriptionHelper(uint64 subId, address to) private nonReentrant { SubscriptionConfig memory subConfig = s_subscriptionConfigs[subId]; Subscription memory sub = s_subscriptions[subId]; uint96 balance = sub.balance; @@ -801,7 +795,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo SubscriptionConfig memory subConfig = s_subscriptionConfigs[subId]; for (uint256 i = 0; i < subConfig.consumers.length; i++) { for (uint256 j = 0; j < s_provingKeyHashes.length; j++) { - (uint256 reqId, ) = computeRequestId( + (uint256 reqId, ) = _computeRequestId( s_provingKeyHashes[j], subConfig.consumers[i], subId, diff --git a/contracts/src/v0.8/vrf/VRFOwner.sol b/contracts/src/v0.8/vrf/VRFOwner.sol index 055308cac42..3b35eae8a47 100644 --- a/contracts/src/v0.8/vrf/VRFOwner.sol +++ b/contracts/src/v0.8/vrf/VRFOwner.sol @@ -194,8 +194,7 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver { * @param fallbackWeiPerUnitLink fallback eth/link price in the case of a stale feed * @param feeConfig fee tier configuration */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function setConfigPrivate( + function _setConfig( uint16 minimumRequestConfirmations, uint32 maxGasLimit, uint32 stalenessSeconds, @@ -236,8 +235,7 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver { * @dev when too many local variables are in the same scope. * @return Config struct containing all relevant configs from the VRF coordinator. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getConfigs() private view returns (Config memory) { + function _getConfigs() private view returns (Config memory) { ( uint16 minimumRequestConfirmations, uint32 maxGasLimit, @@ -286,15 +284,15 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver { VRFTypes.Proof memory proof, VRFTypes.RequestCommitment memory rc ) external validateAuthorizedSender { - uint256 requestId = requestIdFromProof(proof.pk, proof.seed); + uint256 requestId = _requestIdFromProof(proof.pk, proof.seed); // Get current configs to restore them to original values after - // calling setConfigPrivate. - Config memory cfg = getConfigs(); + // calling _setConfig. + Config memory cfg = _getConfigs(); - // call setConfigPrivate with the appropriate params in order to fulfill + // call _setConfig with the appropriate params in order to fulfill // an accidentally-underfunded request. - setConfigPrivate( + _setConfig( cfg.minimumRequestConfirmations, cfg.maxGasLimit, 1, // stalenessSeconds @@ -316,7 +314,7 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver { s_vrfCoordinator.fulfillRandomWords(proof, rc); // reset configuration back to old values. - setConfigPrivate( + _setConfig( cfg.minimumRequestConfirmations, cfg.maxGasLimit, cfg.stalenessSeconds, @@ -342,8 +340,7 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver { * @param proofSeed the proof seed * @dev Refer to VRFCoordinatorV2.getRandomnessFromProof for original implementation. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function requestIdFromProof(uint256[2] memory publicKey, uint256 proofSeed) private view returns (uint256) { + function _requestIdFromProof(uint256[2] memory publicKey, uint256 proofSeed) private view returns (uint256) { bytes32 keyHash = s_vrfCoordinator.hashOfKey(publicKey); uint256 requestId = uint256(keccak256(abi.encode(keyHash, proofSeed))); return requestId; diff --git a/contracts/src/v0.8/vrf/VRFV2Wrapper.sol b/contracts/src/v0.8/vrf/VRFV2Wrapper.sol index a041c62c3fe..805c8d76cb6 100644 --- a/contracts/src/v0.8/vrf/VRFV2Wrapper.sol +++ b/contracts/src/v0.8/vrf/VRFV2Wrapper.sol @@ -221,8 +221,8 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas function calculateRequestPrice( uint32 _callbackGasLimit ) external view override onlyConfiguredNotDisabled returns (uint256) { - int256 weiPerUnitLink = getFeedData(); - return calculateRequestPriceInternal(_callbackGasLimit, tx.gasprice, weiPerUnitLink); + int256 weiPerUnitLink = _getFeedData(); + return _calculateRequestPrice(_callbackGasLimit, tx.gasprice, weiPerUnitLink); } /** @@ -238,12 +238,11 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas uint32 _callbackGasLimit, uint256 _requestGasPriceWei ) external view override onlyConfiguredNotDisabled returns (uint256) { - int256 weiPerUnitLink = getFeedData(); - return calculateRequestPriceInternal(_callbackGasLimit, _requestGasPriceWei, weiPerUnitLink); + int256 weiPerUnitLink = _getFeedData(); + return _calculateRequestPrice(_callbackGasLimit, _requestGasPriceWei, weiPerUnitLink); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculateRequestPriceInternal( + function _calculateRequestPrice( uint256 _gas, uint256 _requestGasPrice, int256 _weiPerUnitLink @@ -286,9 +285,9 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas _data, (uint32, uint16, uint32) ); - uint32 eip150Overhead = getEIP150Overhead(callbackGasLimit); - int256 weiPerUnitLink = getFeedData(); - uint256 price = calculateRequestPriceInternal(callbackGasLimit, tx.gasprice, weiPerUnitLink); + uint32 eip150Overhead = _getEIP150Overhead(callbackGasLimit); + int256 weiPerUnitLink = _getFeedData(); + uint256 price = _calculateRequestPrice(callbackGasLimit, tx.gasprice, weiPerUnitLink); // solhint-disable-next-line custom-errors require(_amount >= price, "fee too low"); // solhint-disable-next-line custom-errors @@ -347,14 +346,13 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas VRFV2WrapperConsumerBase c; bytes memory resp = abi.encodeWithSelector(c.rawFulfillRandomWords.selector, _requestId, _randomWords); - bool success = callWithExactGas(callback.callbackGasLimit, callback.callbackAddress, resp); + bool success = _callWithExactGas(callback.callbackGasLimit, callback.callbackAddress, resp); if (!success) { emit WrapperFulfillmentFailed(_requestId, callback.callbackAddress); } } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getFeedData() private view returns (int256) { + function _getFeedData() private view returns (int256) { bool staleFallback = s_stalenessSeconds > 0; uint256 timestamp; int256 weiPerUnitLink; @@ -371,8 +369,7 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas /** * @dev Calculates extra amount of gas required for running an assembly call() post-EIP150. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getEIP150Overhead(uint32 gas) private pure returns (uint32) { + function _getEIP150Overhead(uint32 gas) private pure returns (uint32) { return gas / 63 + 1; } @@ -380,8 +377,7 @@ contract VRFV2Wrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsumerBas * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { + function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow diff --git a/contracts/src/v0.8/vrf/dev/BatchVRFCoordinatorV2Plus.sol b/contracts/src/v0.8/vrf/dev/BatchVRFCoordinatorV2Plus.sol index 34b5ff6f189..06c44d4dcd1 100644 --- a/contracts/src/v0.8/vrf/dev/BatchVRFCoordinatorV2Plus.sol +++ b/contracts/src/v0.8/vrf/dev/BatchVRFCoordinatorV2Plus.sol @@ -32,10 +32,10 @@ contract BatchVRFCoordinatorV2Plus { try COORDINATOR.fulfillRandomWords(proofs[i], rcs[i]) returns (uint96 /* payment */) { continue; } catch Error(string memory reason) { - uint256 requestId = getRequestIdFromProof(proofs[i]); + uint256 requestId = _getRequestIdFromProof(proofs[i]); emit ErrorReturned(requestId, reason); } catch (bytes memory lowLevelData) { - uint256 requestId = getRequestIdFromProof(proofs[i]); + uint256 requestId = _getRequestIdFromProof(proofs[i]); emit RawErrorReturned(requestId, lowLevelData); } } @@ -45,8 +45,7 @@ contract BatchVRFCoordinatorV2Plus { * @notice Returns the proving key hash associated with this public key. * @param publicKey the key to return the hash of. */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) { + function _hashOfKey(uint256[2] memory publicKey) internal pure returns (bytes32) { return keccak256(abi.encode(publicKey)); } @@ -54,9 +53,8 @@ contract BatchVRFCoordinatorV2Plus { * @notice Returns the request ID of the request associated with the given proof. * @param proof the VRF proof provided by the VRF oracle. */ - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) { - bytes32 keyHash = hashOfKey(proof.pk); + function _getRequestIdFromProof(VRFTypes.Proof memory proof) internal pure returns (uint256) { + bytes32 keyHash = _hashOfKey(proof.pk); return uint256(keccak256(abi.encode(keyHash, proof.seed))); } } diff --git a/contracts/src/v0.8/vrf/dev/SubscriptionAPI.sol b/contracts/src/v0.8/vrf/dev/SubscriptionAPI.sol index 478ff4cce4a..e4708bb1fcf 100644 --- a/contracts/src/v0.8/vrf/dev/SubscriptionAPI.sol +++ b/contracts/src/v0.8/vrf/dev/SubscriptionAPI.sol @@ -151,7 +151,7 @@ abstract contract SubscriptionAPI is ConfirmedOwner, IERC677Receiver, IVRFSubscr if (s_subscriptionConfigs[subId].owner == address(0)) { revert InvalidSubscription(); } - cancelSubscriptionHelper(subId, s_subscriptionConfigs[subId].owner); + _cancelSubscriptionHelper(subId, s_subscriptionConfigs[subId].owner); } /** @@ -392,8 +392,7 @@ abstract contract SubscriptionAPI is ConfirmedOwner, IERC677Receiver, IVRFSubscr emit SubscriptionConsumerAdded(subId, consumer); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function deleteSubscription(uint256 subId) internal returns (uint96 balance, uint96 nativeBalance) { + function _deleteSubscription(uint256 subId) internal returns (uint96 balance, uint96 nativeBalance) { SubscriptionConfig memory subConfig = s_subscriptionConfigs[subId]; Subscription memory sub = s_subscriptions[subId]; balance = sub.balance; @@ -411,9 +410,8 @@ abstract contract SubscriptionAPI is ConfirmedOwner, IERC677Receiver, IVRFSubscr return (balance, nativeBalance); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function cancelSubscriptionHelper(uint256 subId, address to) internal { - (uint96 balance, uint96 nativeBalance) = deleteSubscription(subId); + function _cancelSubscriptionHelper(uint256 subId, address to) internal { + (uint96 balance, uint96 nativeBalance) = _deleteSubscription(subId); // Only withdraw LINK if the token is active and there is a balance. if (address(LINK) != address(0) && balance != 0) { diff --git a/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol b/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol index 31a555f8ac7..e0e46fe67b7 100644 --- a/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol +++ b/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol @@ -269,7 +269,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { // The consequence for users is that they can send requests // for invalid keyHashes which will simply not be fulfilled. uint64 nonce = currentNonce + 1; - (uint256 requestId, uint256 preSeed) = computeRequestId(req.keyHash, msg.sender, req.subId, nonce); + (uint256 requestId, uint256 preSeed) = _computeRequestId(req.keyHash, msg.sender, req.subId, nonce); VRFV2PlusClient.ExtraArgsV1 memory extraArgs = _fromBytes(req.extraArgs); bytes memory extraArgsBytes = VRFV2PlusClient._argsToBytes(extraArgs); @@ -300,8 +300,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { return requestId; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function computeRequestId( + function _computeRequestId( bytes32 keyHash, address sender, uint256 subId, @@ -315,8 +314,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { + function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow @@ -351,8 +349,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { uint256 randomness; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function getRandomnessFromProof( + function _getRandomnessFromProof( Proof memory proof, RequestCommitment memory rc ) internal view returns (Output memory) { @@ -384,7 +381,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { // The seed actually used by the VRF machinery, mixing in the blockhash uint256 actualSeed = uint256(keccak256(abi.encodePacked(proof.seed, blockHash))); - uint256 randomness = VRF.randomValueFromVRFProof(proof, actualSeed); // Reverts on failure + uint256 randomness = VRF._randomValueFromVRFProof(proof, actualSeed); // Reverts on failure return Output(keyHash, requestId, randomness); } @@ -397,7 +394,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { */ function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) { uint256 startGas = gasleft(); - Output memory output = getRandomnessFromProof(proof, rc); + Output memory output = _getRandomnessFromProof(proof, rc); uint256[] memory randomWords = new uint256[](rc.numWords); for (uint256 i = 0; i < rc.numWords; i++) { @@ -411,10 +408,10 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { // Important to not let them exhaust the gas budget and avoid oracle payment. // Do not allow any non-view/non-pure coordinator functions to be called // during the consumers callback code via reentrancyLock. - // Note that callWithExactGas will revert if we do not have sufficient gas + // Note that _callWithExactGas will revert if we do not have sufficient gas // to give the callee their requested amount. s_config.reentrancyLock = true; - bool success = callWithExactGas(rc.callbackGasLimit, rc.sender, resp); + bool success = _callWithExactGas(rc.callbackGasLimit, rc.sender, resp); s_config.reentrancyLock = false; // Increment the req count for the subscription. @@ -427,7 +424,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { // We want to charge users exactly for how much gas they use in their callback. // The gasAfterPaymentCalculation is meant to cover these additional operations where we // decrement the subscription balance and increment the oracles withdrawable balance. - uint96 payment = calculatePaymentAmount( + uint96 payment = _calculatePaymentAmount( startGas, s_config.gasAfterPaymentCalculation, tx.gasprice, @@ -455,8 +452,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { } } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmount( + function _calculatePaymentAmount( uint256 startGas, uint256 gasAfterPaymentCalculation, uint256 weiPerUnitGas, @@ -464,7 +460,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { ) internal view returns (uint96) { if (nativePayment) { return - calculatePaymentAmountNative( + _calculatePaymentAmountNative( startGas, gasAfterPaymentCalculation, s_feeConfig.fulfillmentFlatFeeNativePPM, @@ -472,7 +468,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { ); } return - calculatePaymentAmountLink( + _calculatePaymentAmountLink( startGas, gasAfterPaymentCalculation, s_feeConfig.fulfillmentFlatFeeLinkPPM, @@ -480,8 +476,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { ); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmountNative( + function _calculatePaymentAmountNative( uint256 startGas, uint256 gasAfterPaymentCalculation, uint32 fulfillmentFlatFeePPM, @@ -498,15 +493,14 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { } // Get the amount of gas used for fulfillment - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmountLink( + function _calculatePaymentAmountLink( uint256 startGas, uint256 gasAfterPaymentCalculation, uint32 fulfillmentFlatFeeLinkPPM, uint256 weiPerUnitGas ) internal view returns (uint96) { int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); + weiPerUnitLink = _getFeedData(); if (weiPerUnitLink <= 0) { revert InvalidLinkWeiPrice(weiPerUnitLink); } @@ -522,8 +516,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { return uint96(paymentNoFee + fee); } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getFeedData() private view returns (int256) { + function _getFeedData() private view returns (int256) { uint32 stalenessSeconds = s_config.stalenessSeconds; bool staleFallback = stalenessSeconds > 0; uint256 timestamp; @@ -543,7 +536,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { SubscriptionConfig memory subConfig = s_subscriptionConfigs[subId]; for (uint256 i = 0; i < subConfig.consumers.length; i++) { for (uint256 j = 0; j < s_provingKeyHashes.length; j++) { - (uint256 reqId, ) = computeRequestId( + (uint256 reqId, ) = _computeRequestId( s_provingKeyHashes[j], subConfig.consumers[i], subId, @@ -591,7 +584,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { if (pendingRequestExists(subId)) { revert PendingRequestExists(); } - cancelSubscriptionHelper(subId, to); + _cancelSubscriptionHelper(subId, to); } /*************************************************************************** @@ -627,8 +620,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { uint96 nativeBalance; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function isTargetRegistered(address target) internal view returns (bool) { + function _isTargetRegistered(address target) internal view returns (bool) { for (uint256 i = 0; i < s_migrationTargets.length; i++) { if (s_migrationTargets[i] == target) { return true; @@ -638,7 +630,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { } function registerMigratableCoordinator(address target) external onlyOwner { - if (isTargetRegistered(target)) { + if (_isTargetRegistered(target)) { revert CoordinatorAlreadyRegistered(target); } s_migrationTargets.push(target); @@ -660,7 +652,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { } function migrate(uint256 subId, address newCoordinator) external nonReentrant { - if (!isTargetRegistered(newCoordinator)) { + if (!_isTargetRegistered(newCoordinator)) { revert CoordinatorNotRegistered(newCoordinator); } (uint96 balance, uint96 nativeBalance, , address owner, address[] memory consumers) = getSubscription(subId); @@ -678,7 +670,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { nativeBalance: nativeBalance }); bytes memory encodedData = abi.encode(migrationData); - deleteSubscription(subId); + _deleteSubscription(subId); IVRFCoordinatorV2PlusMigration(newCoordinator).onMigration{value: nativeBalance}(encodedData); // Only transfer LINK if the token is active and there is a balance. diff --git a/contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol b/contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol index 12557f73d2c..f6d5fec68d5 100644 --- a/contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol +++ b/contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol @@ -276,14 +276,14 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume function calculateRequestPrice( uint32 _callbackGasLimit ) external view override onlyConfiguredNotDisabled returns (uint256) { - int256 weiPerUnitLink = getFeedData(); - return calculateRequestPriceInternal(_callbackGasLimit, tx.gasprice, weiPerUnitLink); + int256 weiPerUnitLink = _getFeedData(); + return _calculateRequestPrice(_callbackGasLimit, tx.gasprice, weiPerUnitLink); } function calculateRequestPriceNative( uint32 _callbackGasLimit ) external view override onlyConfiguredNotDisabled returns (uint256) { - return calculateRequestPriceNativeInternal(_callbackGasLimit, tx.gasprice); + return _calculateRequestPriceNative(_callbackGasLimit, tx.gasprice); } /** @@ -299,19 +299,18 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume uint32 _callbackGasLimit, uint256 _requestGasPriceWei ) external view override onlyConfiguredNotDisabled returns (uint256) { - int256 weiPerUnitLink = getFeedData(); - return calculateRequestPriceInternal(_callbackGasLimit, _requestGasPriceWei, weiPerUnitLink); + int256 weiPerUnitLink = _getFeedData(); + return _calculateRequestPrice(_callbackGasLimit, _requestGasPriceWei, weiPerUnitLink); } function estimateRequestPriceNative( uint32 _callbackGasLimit, uint256 _requestGasPriceWei ) external view override onlyConfiguredNotDisabled returns (uint256) { - return calculateRequestPriceNativeInternal(_callbackGasLimit, _requestGasPriceWei); + return _calculateRequestPriceNative(_callbackGasLimit, _requestGasPriceWei); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculateRequestPriceNativeInternal(uint256 _gas, uint256 _requestGasPrice) internal view returns (uint256) { + function _calculateRequestPriceNative(uint256 _gas, uint256 _requestGasPrice) internal view returns (uint256) { // costWei is the base fee denominated in wei (native) // costWei takes into account the L1 posting costs of the VRF fulfillment // transaction, if we are on an L2. @@ -329,8 +328,7 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume return feeWithFlatFee; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculateRequestPriceInternal( + function _calculateRequestPrice( uint256 _gas, uint256 _requestGasPrice, int256 _weiPerUnitLink @@ -374,9 +372,9 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume (uint32, uint16, uint32, bytes) ); checkPaymentMode(extraArgs, true); - uint32 eip150Overhead = getEIP150Overhead(callbackGasLimit); - int256 weiPerUnitLink = getFeedData(); - uint256 price = calculateRequestPriceInternal(callbackGasLimit, tx.gasprice, weiPerUnitLink); + uint32 eip150Overhead = _getEIP150Overhead(callbackGasLimit); + int256 weiPerUnitLink = _getFeedData(); + uint256 price = _calculateRequestPrice(callbackGasLimit, tx.gasprice, weiPerUnitLink); // solhint-disable-next-line custom-errors require(_amount >= price, "fee too low"); // solhint-disable-next-line custom-errors @@ -430,8 +428,8 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume ) external payable override returns (uint256 requestId) { checkPaymentMode(extraArgs, false); - uint32 eip150Overhead = getEIP150Overhead(_callbackGasLimit); - uint256 price = calculateRequestPriceNativeInternal(_callbackGasLimit, tx.gasprice); + uint32 eip150Overhead = _getEIP150Overhead(_callbackGasLimit); + uint256 price = _calculateRequestPriceNative(_callbackGasLimit, tx.gasprice); // solhint-disable-next-line custom-errors require(msg.value >= price, "fee too low"); // solhint-disable-next-line custom-errors @@ -505,14 +503,13 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume VRFV2PlusWrapperConsumerBase c; bytes memory resp = abi.encodeWithSelector(c.rawFulfillRandomWords.selector, _requestId, _randomWords); - bool success = callWithExactGas(callback.callbackGasLimit, callback.callbackAddress, resp); + bool success = _callWithExactGas(callback.callbackGasLimit, callback.callbackAddress, resp); if (!success) { emit WrapperFulfillmentFailed(_requestId, callback.callbackAddress); } } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getFeedData() private view returns (int256) { + function _getFeedData() private view returns (int256) { bool staleFallback = s_stalenessSeconds > 0; uint256 timestamp; int256 weiPerUnitLink; @@ -529,8 +526,7 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume /** * @dev Calculates extra amount of gas required for running an assembly call() post-EIP150. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getEIP150Overhead(uint32 gas) private pure returns (uint32) { + function _getEIP150Overhead(uint32 gas) private pure returns (uint32) { return gas / 63 + 1; } @@ -538,8 +534,7 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { + function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow diff --git a/contracts/src/v0.8/vrf/dev/testhelpers/ExposedVRFCoordinatorV2_5.sol b/contracts/src/v0.8/vrf/dev/testhelpers/ExposedVRFCoordinatorV2_5.sol index f9c34b2b611..02cb15e38a4 100644 --- a/contracts/src/v0.8/vrf/dev/testhelpers/ExposedVRFCoordinatorV2_5.sol +++ b/contracts/src/v0.8/vrf/dev/testhelpers/ExposedVRFCoordinatorV2_5.sol @@ -16,18 +16,18 @@ contract ExposedVRFCoordinatorV2_5 is VRFCoordinatorV2_5 { uint256 subId, uint64 nonce ) external pure returns (uint256, uint256) { - return computeRequestId(keyHash, sender, subId, nonce); + return _computeRequestId(keyHash, sender, subId, nonce); } function isTargetRegisteredExternal(address target) external view returns (bool) { - return isTargetRegistered(target); + return _isTargetRegistered(target); } function getRandomnessFromProofExternal( Proof calldata proof, RequestCommitment calldata rc ) external view returns (Output memory) { - return getRandomnessFromProof(proof, rc); + return _getRandomnessFromProof(proof, rc); } function getActiveSubscriptionIdsLength() external view returns (uint256) { diff --git a/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2PlusUpgradedVersion.sol b/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2PlusUpgradedVersion.sol index b6c76e1c713..4837411955c 100644 --- a/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2PlusUpgradedVersion.sol +++ b/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2PlusUpgradedVersion.sol @@ -260,7 +260,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is // The consequence for users is that they can send requests // for invalid keyHashes which will simply not be fulfilled. uint64 nonce = currentNonce + 1; - (uint256 requestId, uint256 preSeed) = computeRequestId(req.keyHash, msg.sender, req.subId, nonce); + (uint256 requestId, uint256 preSeed) = _computeRequestId(req.keyHash, msg.sender, req.subId, nonce); VRFV2PlusClient.ExtraArgsV1 memory extraArgs = _fromBytes(req.extraArgs); bytes memory extraArgsBytes = VRFV2PlusClient._argsToBytes(extraArgs); @@ -291,8 +291,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is return requestId; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function computeRequestId( + function _computeRequestId( bytes32 keyHash, address sender, uint256 subId, @@ -306,8 +305,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is * @dev calls target address with exactly gasAmount gas and data as calldata * or reverts if at least gasAmount gas is not available. */ - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { + function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow @@ -342,8 +340,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is uint256 randomness; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function getRandomnessFromProof( + function _getRandomnessFromProof( Proof memory proof, RequestCommitment memory rc ) internal view returns (Output memory) { @@ -375,7 +372,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is // The seed actually used by the VRF machinery, mixing in the blockhash uint256 actualSeed = uint256(keccak256(abi.encodePacked(proof.seed, blockHash))); - uint256 randomness = VRF.randomValueFromVRFProof(proof, actualSeed); // Reverts on failure + uint256 randomness = VRF._randomValueFromVRFProof(proof, actualSeed); // Reverts on failure return Output(keyHash, requestId, randomness); } @@ -388,7 +385,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is */ function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) { uint256 startGas = gasleft(); - Output memory output = getRandomnessFromProof(proof, rc); + Output memory output = _getRandomnessFromProof(proof, rc); uint256[] memory randomWords = new uint256[](rc.numWords); for (uint256 i = 0; i < rc.numWords; i++) { @@ -402,10 +399,10 @@ contract VRFCoordinatorV2PlusUpgradedVersion is // Important to not let them exhaust the gas budget and avoid oracle payment. // Do not allow any non-view/non-pure coordinator functions to be called // during the consumers callback code via reentrancyLock. - // Note that callWithExactGas will revert if we do not have sufficient gas + // Note that _callWithExactGas will revert if we do not have sufficient gas // to give the callee their requested amount. s_config.reentrancyLock = true; - bool success = callWithExactGas(rc.callbackGasLimit, rc.sender, resp); + bool success = _callWithExactGas(rc.callbackGasLimit, rc.sender, resp); s_config.reentrancyLock = false; // Increment the req count for the subscription. @@ -418,7 +415,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is // We want to charge users exactly for how much gas they use in their callback. // The gasAfterPaymentCalculation is meant to cover these additional operations where we // decrement the subscription balance and increment the oracles withdrawable balance. - uint96 payment = calculatePaymentAmount( + uint96 payment = _calculatePaymentAmount( startGas, s_config.gasAfterPaymentCalculation, tx.gasprice, @@ -446,8 +443,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is } } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmount( + function _calculatePaymentAmount( uint256 startGas, uint256 gasAfterPaymentCalculation, uint256 weiPerUnitGas, @@ -455,7 +451,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is ) internal view returns (uint96) { if (nativePayment) { return - calculatePaymentAmountNative( + _calculatePaymentAmountNative( startGas, gasAfterPaymentCalculation, s_feeConfig.fulfillmentFlatFeeNativePPM, @@ -463,7 +459,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is ); } return - calculatePaymentAmountLink( + _calculatePaymentAmountLink( startGas, gasAfterPaymentCalculation, s_feeConfig.fulfillmentFlatFeeLinkPPM, @@ -471,8 +467,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is ); } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmountNative( + function _calculatePaymentAmountNative( uint256 startGas, uint256 gasAfterPaymentCalculation, uint32 fulfillmentFlatFeePPM, @@ -489,15 +484,14 @@ contract VRFCoordinatorV2PlusUpgradedVersion is } // Get the amount of gas used for fulfillment - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function calculatePaymentAmountLink( + function _calculatePaymentAmountLink( uint256 startGas, uint256 gasAfterPaymentCalculation, uint32 fulfillmentFlatFeeLinkPPM, uint256 weiPerUnitGas ) internal view returns (uint96) { int256 weiPerUnitLink; - weiPerUnitLink = getFeedData(); + weiPerUnitLink = _getFeedData(); if (weiPerUnitLink <= 0) { revert InvalidLinkWeiPrice(weiPerUnitLink); } @@ -513,8 +507,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is return uint96(paymentNoFee + fee); } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function getFeedData() private view returns (int256) { + function _getFeedData() private view returns (int256) { uint32 stalenessSeconds = s_config.stalenessSeconds; bool staleFallback = stalenessSeconds > 0; uint256 timestamp; @@ -540,7 +533,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is SubscriptionConfig memory subConfig = s_subscriptionConfigs[subId]; for (uint256 i = 0; i < subConfig.consumers.length; i++) { for (uint256 j = 0; j < s_provingKeyHashes.length; j++) { - (uint256 reqId, ) = computeRequestId( + (uint256 reqId, ) = _computeRequestId( s_provingKeyHashes[j], subConfig.consumers[i], subId, @@ -588,7 +581,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is if (pendingRequestExists(subId)) { revert PendingRequestExists(); } - cancelSubscriptionHelper(subId, to); + _cancelSubscriptionHelper(subId, to); } /*************************************************************************** @@ -621,8 +614,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is uint96 nativeBalance; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function isTargetRegistered(address target) internal view returns (bool) { + function _isTargetRegistered(address target) internal view returns (bool) { for (uint256 i = 0; i < s_migrationTargets.length; i++) { if (s_migrationTargets[i] == target) { return true; @@ -632,7 +624,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is } function registerMigratableCoordinator(address target) external onlyOwner { - if (isTargetRegistered(target)) { + if (_isTargetRegistered(target)) { revert CoordinatorAlreadyRegistered(target); } s_migrationTargets.push(target); @@ -640,7 +632,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is } function migrate(uint256 subId, address newCoordinator) external nonReentrant { - if (!isTargetRegistered(newCoordinator)) { + if (!_isTargetRegistered(newCoordinator)) { revert CoordinatorNotRegistered(newCoordinator); } (uint96 balance, uint96 nativeBalance, , address owner, address[] memory consumers) = getSubscription(subId); @@ -658,7 +650,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is nativeBalance: nativeBalance }); bytes memory encodedData = abi.encode(migrationData); - deleteSubscription(subId); + _deleteSubscription(subId); IVRFCoordinatorV2PlusMigration(newCoordinator).onMigration{value: nativeBalance}(encodedData); // Only transfer LINK if the token is active and there is a balance. diff --git a/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2Plus_V2Example.sol b/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2Plus_V2Example.sol index af49abbf6b5..0204be807f5 100644 --- a/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2Plus_V2Example.sol +++ b/contracts/src/v0.8/vrf/dev/testhelpers/VRFCoordinatorV2Plus_V2Example.sol @@ -135,11 +135,10 @@ contract VRFCoordinatorV2Plus_V2Example is IVRFCoordinatorV2PlusMigration { function requestRandomWords(VRFV2PlusClient.RandomWordsRequest calldata req) external returns (uint256 requestId) { Subscription memory sub = s_subscriptions[req.subId]; sub.reqCount = sub.reqCount + 1; - return handleRequest(msg.sender); + return _handleRequest(msg.sender); } - // solhint-disable-next-line chainlink-solidity/prefix-private-functions-with-underscore - function handleRequest(address requester) private returns (uint256) { + function _handleRequest(address requester) private returns (uint256) { s_requestId = s_requestId + 1; uint256 requestId = s_requestId; s_requestConsumerMapping[s_requestId] = requester; diff --git a/contracts/src/v0.8/vrf/dev/testhelpers/VRFV2PlusConsumerExample.sol b/contracts/src/v0.8/vrf/dev/testhelpers/VRFV2PlusConsumerExample.sol index 6898e101f82..2ef4e5c021f 100644 --- a/contracts/src/v0.8/vrf/dev/testhelpers/VRFV2PlusConsumerExample.sol +++ b/contracts/src/v0.8/vrf/dev/testhelpers/VRFV2PlusConsumerExample.sol @@ -34,8 +34,7 @@ contract VRFV2PlusConsumerExample is ConfirmedOwner, VRFConsumerBaseV2Plus { return resp.randomWords[idx]; } - // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore - function subscribe() internal returns (uint256) { + function _subscribe() internal returns (uint256) { if (s_subId == 0) { s_subId = s_vrfCoordinatorApiV1.createSubscription(); s_vrfCoordinatorApiV1.addConsumer(s_subId, address(this)); @@ -44,12 +43,12 @@ contract VRFV2PlusConsumerExample is ConfirmedOwner, VRFConsumerBaseV2Plus { } function createSubscriptionAndFundNative() external payable { - subscribe(); + _subscribe(); s_vrfCoordinatorApiV1.fundSubscriptionWithNative{value: msg.value}(s_subId); } function createSubscriptionAndFund(uint96 amount) external { - subscribe(); + _subscribe(); // Approve the link transfer. s_linkToken.transferAndCall(address(s_vrfCoordinator), amount, abi.encode(s_subId)); } diff --git a/contracts/src/v0.8/vrf/testhelpers/VRFTestHelper.sol b/contracts/src/v0.8/vrf/testhelpers/VRFTestHelper.sol index e3f9ee04824..bcead3f0c99 100644 --- a/contracts/src/v0.8/vrf/testhelpers/VRFTestHelper.sol +++ b/contracts/src/v0.8/vrf/testhelpers/VRFTestHelper.sol @@ -9,27 +9,27 @@ import {VRF} from "../VRF.sol"; */ contract VRFTestHelper is VRF { function bigModExp_(uint256 base, uint256 exponent) public view returns (uint256) { - return super.bigModExp(base, exponent); + return super._bigModExp(base, exponent); } function squareRoot_(uint256 x) public view returns (uint256) { - return super.squareRoot(x); + return super._squareRoot(x); } function ySquared_(uint256 x) public pure returns (uint256) { - return super.ySquared(x); + return super._ySquared(x); } function fieldHash_(bytes memory b) public pure returns (uint256) { - return super.fieldHash(b); + return super._fieldHash(b); } function hashToCurve_(uint256[2] memory pk, uint256 x) public view returns (uint256[2] memory) { - return super.hashToCurve(pk, x); + return super._hashToCurve(pk, x); } function ecmulVerify_(uint256[2] memory x, uint256 scalar, uint256[2] memory q) public pure returns (bool) { - return super.ecmulVerify(x, scalar, q); + return super._ecmulVerify(x, scalar, q); } function projectiveECAdd_( @@ -38,7 +38,7 @@ contract VRFTestHelper is VRF { uint256 qx, uint256 qy ) public pure returns (uint256, uint256, uint256) { - return super.projectiveECAdd(px, py, qx, qy); + return super._projectiveECAdd(px, py, qx, qy); } function affineECAdd_( @@ -46,7 +46,7 @@ contract VRFTestHelper is VRF { uint256[2] memory p2, uint256 invZ ) public pure returns (uint256[2] memory) { - return super.affineECAdd(p1, p2, invZ); + return super._affineECAdd(p1, p2, invZ); } function verifyLinearCombinationWithGenerator_( @@ -55,7 +55,7 @@ contract VRFTestHelper is VRF { uint256 s, address lcWitness ) public pure returns (bool) { - return super.verifyLinearCombinationWithGenerator(c, p, s, lcWitness); + return super._verifyLinearCombinationWithGenerator(c, p, s, lcWitness); } function linearCombination_( @@ -67,7 +67,7 @@ contract VRFTestHelper is VRF { uint256[2] memory sp2Witness, uint256 zInv ) public pure returns (uint256[2] memory) { - return super.linearCombination(c, p1, cp1Witness, s, p2, sp2Witness, zInv); + return super._linearCombination(c, p1, cp1Witness, s, p2, sp2Witness, zInv); } function scalarFromCurvePoints_( @@ -77,11 +77,11 @@ contract VRFTestHelper is VRF { address uWitness, uint256[2] memory v ) public pure returns (uint256) { - return super.scalarFromCurvePoints(hash, pk, gamma, uWitness, v); + return super._scalarFromCurvePoints(hash, pk, gamma, uWitness, v); } function isOnCurve_(uint256[2] memory p) public pure returns (bool) { - return super.isOnCurve(p); + return super._isOnCurve(p); } function verifyVRFProof_( @@ -95,10 +95,10 @@ contract VRFTestHelper is VRF { uint256[2] memory sHashWitness, uint256 zInv ) public view { - super.verifyVRFProof(pk, gamma, c, s, seed, uWitness, cGammaWitness, sHashWitness, zInv); + super._verifyVRFProof(pk, gamma, c, s, seed, uWitness, cGammaWitness, sHashWitness, zInv); } function randomValueFromVRFProof_(Proof memory proof, uint256 seed) public view returns (uint256 output) { - return super.randomValueFromVRFProof(proof, seed); + return super._randomValueFromVRFProof(proof, seed); } }