You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @title Random Number Generator using beacon chain random opcode
15
15
*/
16
-
contractBeaconRNGisRNG {
16
+
contractBeaconRNG {
17
+
18
+
uintpublic constant LOOKAHEAD =132; // Number of blocks that has to pass before obtaining the random number. 4 epochs + 4 slots, according to EIP-4399.
19
+
uintpublic constant ERROR =32; // Number of blocks after which the lookahead gets reset, so eligible blocks after lookahead don't go long distance, to avoid a possiblity for manipulation.
17
20
18
-
/**
19
-
* @dev Since we don't really need to incentivise requesting the beacon chain randomness,
20
-
* this is a stub implementation required for backwards compatibility with the
21
-
* RNG interface.
22
-
* @notice All the ETH sent here will be lost forever.
23
-
* @param _block Block the random number is linked to.
21
+
RNG public blockhashRNG; // Address of blockhashRNG to fall back on.
22
+
23
+
/** @dev Constructor.
24
+
* @param _blockhashRNG The blockhash RNG deployed contract address.
24
25
*/
25
-
function contribute(uint_block) publicpayable {}
26
+
constructor(RNG _blockhashRNG) public {
27
+
blockhashRNG = _blockhashRNG;
28
+
}
26
29
30
+
/**
31
+
* @dev Request a random number. It is not used by this contract and only exists for backward compatibility.
32
+
*/
33
+
function requestRN(uint/*_block*/) publicpure {}
27
34
28
-
/** @dev Return the random number from the PoS randomness beacon.
29
-
* @param _block Block the random number is linked to.
30
-
* @return RN Random Number. If the PoS upgrade defined by EIP-3675
31
-
* has not yet executed 0 instead.
35
+
/**
36
+
* @dev Get an uncorrelated random number.
37
+
* @param _block Block the random number is linked to.
38
+
* @return RN Random Number. If the number is not ready or has not been required 0 instead.
32
39
*/
33
-
function getRN(uint_block) publicreturns (uintRN) {
34
-
if (block.difficulty<=2**64)
35
-
return0;
36
-
returnblock.difficulty;
40
+
function getUncorrelatedRN(uint_block) publicreturns (uint) {
0 commit comments