From 43120e93bc0ebd350434e14800f555979d5c9234 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Wed, 27 Sep 2023 18:46:40 +0200 Subject: [PATCH 1/2] chore: update comments and types address WP-N3 and WP-N4 --- contracts/GelatoVRFConsumerBase.sol | 16 ++++++++-------- contracts/MockVRFConsumerBase.sol | 4 ++-- .../VRFCoordinatorV2Adapter.sol | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/contracts/GelatoVRFConsumerBase.sol b/contracts/GelatoVRFConsumerBase.sol index c6a695e..e70a658 100644 --- a/contracts/GelatoVRFConsumerBase.sol +++ b/contracts/GelatoVRFConsumerBase.sol @@ -35,19 +35,17 @@ abstract contract GelatoVRFConsumerBase is GelatoVRFConsumer { } /// @notice User logic to handle the random value received. - /// @dev The seed is derived from the hash of the randomness - /// provided by the drand network and the request ID. - /// @param seed The derived seed. + /// @param randomness The random number generated by Gelato VRF. /// @param requestId The ID for the randomness request. /// @param extraData Additional data from the randomness request. function _fulfillRandomness( - bytes32 seed, + uint256 randomness, uint64 requestId, bytes memory extraData ) internal virtual; /// @notice Callback function used by Gelato VRF to return the random number. - /// The seed is derived by hashing the provided randomness with the request ID. + /// The randomness is derived by hashing the provided randomness with the request ID. /// @param randomness The random number generated by Gelato VRF. /// @param data Additional data provided by Gelato VRF, typically containing request details. function fulfillRandomness( @@ -59,11 +57,13 @@ abstract contract GelatoVRFConsumerBase is GelatoVRFConsumer { data, (uint64, bytes) ); - bytes32 seed = keccak256( - abi.encode(randomness, address(this), block.chainid, requestId) + randomness = uint( + keccak256( + abi.encode(randomness, address(this), block.chainid, requestId) + ) ); if (requestPending[requestId]) { - _fulfillRandomness(seed, requestId, extraData); + _fulfillRandomness(randomness, requestId, extraData); requestPending[requestId] = false; } } diff --git a/contracts/MockVRFConsumerBase.sol b/contracts/MockVRFConsumerBase.sol index f5bbdc4..10eb430 100644 --- a/contracts/MockVRFConsumerBase.sol +++ b/contracts/MockVRFConsumerBase.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.18; import {GelatoVRFConsumerBase} from "./GelatoVRFConsumerBase.sol"; contract MockVRFConsumerBase is GelatoVRFConsumerBase { - bytes32 public latestRandomness; + uint256 public latestRandomness; uint64 public latestRequestId; address private immutable _operatorAddr; @@ -21,7 +21,7 @@ contract MockVRFConsumerBase is GelatoVRFConsumerBase { } function _fulfillRandomness( - bytes32 randomness, + uint256 randomness, uint64 requestId, bytes memory ) internal override { diff --git a/contracts/chainlink_compatible/VRFCoordinatorV2Adapter.sol b/contracts/chainlink_compatible/VRFCoordinatorV2Adapter.sol index 60084a6..93add3c 100644 --- a/contracts/chainlink_compatible/VRFCoordinatorV2Adapter.sol +++ b/contracts/chainlink_compatible/VRFCoordinatorV2Adapter.sol @@ -89,10 +89,10 @@ contract VRFCoordinatorV2Adapter is } /// @notice Callback function used by Gelato VRF to return the random number. - /// @param seed The random number generated by Gelato VRF. + /// @param randomness The random number generated by Gelato VRF. /// @param data Additional data provided by Gelato VRF, typically containing request details. function _fulfillRandomness( - bytes32 seed, + uint256 randomness, uint64 requestId, bytes memory data ) internal override { @@ -102,7 +102,7 @@ contract VRFCoordinatorV2Adapter is ); uint[] memory words = new uint[](numWords); for (uint32 i = 0; i < numWords; i++) { - words[i] = uint(keccak256(abi.encode(seed, i))); + words[i] = uint(keccak256(abi.encode(randomness, i))); } consumer.rawFulfillRandomWords(requestId, words); } From 9f2fe050c9027724b82009da214c16c01513f5e8 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Wed, 27 Sep 2023 18:50:46 +0200 Subject: [PATCH 2/2] chore: missing error message address WP-N2 --- contracts/GelatoVRFConsumerBase.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/GelatoVRFConsumerBase.sol b/contracts/GelatoVRFConsumerBase.sol index e70a658..0112306 100644 --- a/contracts/GelatoVRFConsumerBase.sol +++ b/contracts/GelatoVRFConsumerBase.sol @@ -52,7 +52,7 @@ abstract contract GelatoVRFConsumerBase is GelatoVRFConsumer { uint256 randomness, bytes calldata data ) external { - require(msg.sender == _operator()); + require(msg.sender == _operator(), "only operator"); (uint64 requestId, bytes memory extraData) = abi.decode( data, (uint64, bytes)