Right now the security is not optimized as it could be, since someone can dominate one mining algorithm and reorg the chain only with one algorithm, and making it useless to have multiple algorithms to mine.
To solve this each block should determine the next block’s mining algorithm randomly, so that one actor that dominates one algorithm can’t reorg the chain by himself
No not quite, this opens you up to a whole other level of issues.
How the PoW with the multi algorthim works is via target time.
And here is the big kicker, each algorithm targets a block time of 8 mins, meaning the difficulty is adjusted so that on avg we mine a block every 8 minutes for each algorithm. BUT the Tari block time is 2 mins, not 8. This leads to on avg in a period of 8 mins, each algorthim is chosen once.
When you calculate the difficulty, you only look at your algorithm blocks and calculate the time it took to mine them.
So for example:
Lets say Sha3 is very strong, they have a new miner, and they are now getting a block every 2 minutes, while the diffulty is ramping up. This means the diffulty will go up as long as a sha3 block is not more than 8 minutes since the last sha3 block. And for every sha3 block mined, the other algorthimgs dont get a block, so their diffulty goes down, making them easier to mine.
Great points, but, how fast does the difficult adjustment kick in? Is it block by block depending on the time the previous block with that algo was mined? Because an entity could mine with one algo 80 blocks in a row in secret and release them all at once, that would wipe the defense mechanism you wrote about the other algos getting easier
Or not even to do a reorg attack, but a selfish miner could mine a few blocks with one algo and release them all at once
Let me address this in two parts:
1:
Yes its block by block.
So for example we have {Algo(Timestamp seconds)}:
Sha3(100) → RXT(120) → Sha3(150) → RxT(200)
So after block 2 gets mined, the time fed into the difficulty algorithm is:
Assuming now time = 121
Sha3 → 121 - 100
RxT → 121 - 120
After block 3 gets mined, and time is now = 151
Sha3 → 151 -150
RxT → 151-120
2: Selfish mine is difficult due to the way we calculate total pow.
We keep all difficulties seperate, and use a form of geometric mean to compare them.
So given two tips.
tip A:
Sha3: 1000_000
c29: 29
Tip B:
Sha3: 900_000
c29 50
Which is higher?
Its difficult as c29 difficulty is measured in 10’s and sha in millions.
But if you calculate the geometric mean, it compares them and you can see which one has the highest rate of change.
In this case we have
TipA: sqrt(1000_000^2 * 29 ^2) = 29_000_000
TipB: sqrt(900_000^2 * 50 ^2) = 45_000_000
and this is because tip b has c29 difficulty increase of almost 100% where as tip a only increased Sha3 by 10 %
So for a selfish chain to win, you want to mine more pow percentage wise increase than the other 3 algos combined. Which is hard to do.
We have a proposal to harden this somewhat, but its going to be a hardfork, but still something thats worth considering
But a bad actor could mine 80 blocks with one algo in a row of 8 minutes each in secret and then mine 10 more very quickly and then release them all at once
With this attack is much easier to attack the chain that if it had one algo, because you can concentrate all the resources in one algo making it much cheaper since the efforts to protect the chain are divided in 4 algos
Or what am I missing?
Edit: I see that only mining with one algo every eight minutes you would be much behind from the real chain so this doesn’t make sense