Skip to content

Commit 707cd7f

Browse files
bweickBrian Weickmann
andauthored
Added some comments re: sequence size in ScaledEntropyCallback. (#19)
Co-authored-by: Brian Weickmann <[email protected]>
1 parent 236ca07 commit 707cd7f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

contracts/ScaledEntropyProvider.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ contract ScaledEntropyProvider is Ownable, IScaledEntropyProvider, IEntropyConsu
106106
/**
107107
* @notice Requests scaled random numbers from Pyth Network with callback delivery
108108
* @dev Submits entropy request to Pyth Network and stores callback details for async delivery.
109-
* The callback will receive scaled random numbers according to the specified requests.
109+
* The callback will receive scaled random numbers according to the specified requests. Developer
110+
* needs to ensure that the range is not too large to be able to build an array of the appropriate
111+
* size in memory in order to avoid out of gas errors during Fisher-Yates sampling.
110112
* IMPORTANT: The callback address is automatically set to msg.sender (the calling contract).
111113
* @param _gasLimit Gas limit for the entropy callback execution
112114
* @param _requests Array of SetRequest structs defining random number requirements

contracts/lib/FisherYatesWithRejection.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ library FisherYatesRejection {
2222
* 2. Using Fisher-Yates shuffle with rejection sampling to avoid modulo bias
2323
* 3. Selecting the first 'count' numbers from the shuffled pool
2424
* The rejection sampling ensures uniform distribution by rejecting random values
25-
* that would create bias when reduced to the required range.
25+
* that would create bias when reduced to the required range. Developer needs to ensure
26+
* that the range is not too large to be able to build an array of the appropriate size
27+
* in memory.
2628
* @param minRange Minimum value in the selection range (inclusive)
2729
* @param maxRange Maximum value in the selection range (inclusive)
2830
* @param count Number of unique values to select

0 commit comments

Comments
 (0)