Describe the bug
The BTCRelay incorrectly sets the main chain as the longest fork instead of that which has the most work. This means that an attacker with significant mining power could mine a chain with an invalid timestamp to lower the difficulty after each readjustment period. It is currently not economically feasible to exploit due to the required mining requirements.
Expected behavior
We should only reorg when the fork has more work than the current main chain, see how electrum does that here.
Additional context
The summa relay here only checks the chain work when reorging but it does not support reorgs over 2017 blocks.
Describe the bug
The BTCRelay incorrectly sets the main chain as the longest fork instead of that which has the most work. This means that an attacker with significant mining power could mine a chain with an invalid timestamp to lower the difficulty after each readjustment period. It is currently not economically feasible to exploit due to the required mining requirements.
Expected behavior
We should only reorg when the fork has more work than the current main chain, see how electrum does that here.
Additional context
The summa relay here only checks the chain work when reorging but it does not support reorgs over 2017 blocks.