aionnetwork / aion_miner

aion miner
57 stars 25 forks source link

Documentation #7

Open Robinson-George opened 6 years ago

Robinson-George commented 6 years ago

Is this a good place to ask?:

Must NDIGITS be equal to (WK+1) ? What would happen if NDIGITS was another divisor of WN ?

Also, why are buckets needed at all, if in Rounds1, 2, 3 ...etc, all DIGITBITS are always XOR'ed anyway ? What would happen in Round0 if RESTBITS == DIGITBITS and BUCKBITS == 0 ?
...in other words, what would change in Round0 if there was only 1 bucket and (1<<DIGITBITS) number of slots ?

aion-Ross commented 6 years ago

Hey Robinson-George, thanks for the questions, some of them are algorithm dependent while others are implementation so I'll try to go through them one by one.

The W prefix is there in the code to avoid confusion with things such as loop variables; I'll just use N and K here.

Must NDIGITS be equal to (WK+1) ?

Yes - The Equihash algorithm states that N must be divisible by (K+1). NDIGITS just stores the K+1 value when calculating DIGITBITS N/(K+1).

What would happen if NDIGITS was another divisor of WN?

You could make NDIGITS another divisor or N and could still run Equihash but that would be for anotehr set of parameters which would not be compatible with the (210,9) parameters. For example you could build a system using (210,6) as 210 is divisible by 7. However, due to the changed parameters these systems PoW algorithms would not be compatible with each other,

Also, why are buckets needed at all, if in Rounds1, 2, 3 ...etc, all DIGITBITS are always XOR'ed anyway ? What would happen in Round0 if RESTBITS == DIGITBITS and BUCKBITS == 0 ? ...in other words, what would change in Round0 if there was only 1 bucket and (1<<DIGITBITS) number of slots ?

The buckets are used to sort hashes into candidates and save work in future rounds. If you stored all hashes in round 0 in a bucket with 1<<DIGITBITS slots, then in the next round you would have to compare every single pair (most failing to xor to 0 over DIGITBITS). By sorting the candidates we ensure we only continue processing hashes which have the potential to generate a solution.

However the bucket sort is an implementation detail, there are other implementations which don't necessarily sort hashes the same way. At the moment I don't believe there are any other 210,9 implementations out there but there are various implementations for 200,9 and 192,7.

BTW, if you're not sure if a question should be an issue here you can always post any questions up on the forum https://forum.aion.network/