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
Copy file name to clipboardExpand all lines: contracts/standard/rng/BeaconRNGFallback.sol
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
/**
2
-
* @authors: [@shalzz]
3
-
* @reviewers: [@jaybuidl*, @geaxed]
2
+
* @authors: [@shalzz, @unknownunknown1]
3
+
* @reviewers: [@jaybuidl*, @geaxed*]
4
4
* @auditors: []
5
5
* @bounties: []
6
6
* @deployments: []
@@ -18,6 +18,8 @@ contract BeaconRNGFallBack is RNG {
18
18
RNG public beaconRNG;
19
19
RNG public blockhashRNG;
20
20
21
+
uintpublic constant LOOKAHEAD =132; // Number of blocks that has to pass before obtaining the random number. 4 epochs + 4 slots, according to EIP-4399.
22
+
21
23
/** @dev Constructor.
22
24
* @param _beaconRNG The beacon chain RNG deployed contract address
23
25
* @param _blockhashRNG The blockhash RNG deployed contract address
@@ -65,6 +67,10 @@ contract BeaconRNGFallBack is RNG {
65
67
// fallback to blockhash RNG
66
68
if (RN ==0) {
67
69
RN = blockhashRNG.getRN(_block);
70
+
} elseif (block.number< _block + LOOKAHEAD) {
71
+
// Beacon chain returns the random number, but sufficient number of blocks hasn't been mined yet.
72
+
// In this case signal to the court that RN isn't ready.
0 commit comments