-
Notifications
You must be signed in to change notification settings - Fork 102
Randomise partition assignment to equally-full deadlines #432
Comments
I talked with @whyrusleeping about this and he says it's a "nice to have". I'll look into it if there's nothing else of higher priority. I'll look into #266. |
I'm debating between two options.
The random offset is nice because it's really simple, and easy to test. However, we could still end up with "runs" of deadlines with partitions. Draft PR: #1054. The permutation is nice and random, but doing it requires:
I'm currently going with "stingy use of entropy", but it's a bit nasty. TL;DR: we (theoretically) need
This takes 225 bits (because I'm not stingy enough to try to use fractional bits). The question is, is this worth it? Here's the proposed code for this "stingy" permutation algorithm: func deadlinePermutation(randomness abi.Randomness) [WPoStPeriodDeadlines]int {
var deadlines [WPoStPeriodDeadlines]int
for i := range deadlines {
deadlines[i] = i
}
randBits := uint(randomness[0])
randomness = randomness[1:]
remaining := 8
for i := uint(0); i < uint(len(deadlines)-1); i++ {
reqBits := bits.Len(uint(len(deadlines)) - i - 1)
rand := uint(0)
if remaining < reqBits {
rand = randBits << (reqBits - remaining)
randBits = uint(randomness[0])
randomness = randomness[1:]
reqBits -= remaining
remaining = 8
}
remaining -= reqBits
rand = randBits & ^((^uint(0)) << reqBits)
randBits >>= reqBits
j := rand + i
deadlines[i], deadlines[j] = deadlines[j], deadlines[i]
}
return deadlines
} |
This commit randomizes deadline assignment by starting to open new partitions fixes #432
This commit randomizes deadline assignment by starting deadline assignment at a random offset. fixes #432
(I can probably also implement the above with |
I talked about this with @nicola, and it's not important for security so we're going to drop it. |
@anorth would you like me to leave this open as a future improvement? |
Thanks! I'll re-open and move this to our "later" pipeline so we have your snippet above easily to hand if we decide to do this. I concur it's not important in the near term. |
Randomise the assignment of a partition to a new deadline among equally-full candidates. This randomisation should be seeded from chain randomness. We're seeking a really simple pseudo-random shuffle here, it's not first order security-critical. A Fiestel network may work, but is probably way overkill. A simple seeded PRNG that we can implement directly is probably sufficient.
The text was updated successfully, but these errors were encountered: