neo-project / neo-modules

MIT License
60 stars 100 forks source link

fix: selfish mining #832

Closed Jim8y closed 11 months ago

Jim8y commented 11 months ago

https://github.com/neo-project/neo/issues/2918

Prevents:

Jim8y commented 11 months ago

The problem here is that malicious nodes can start the consensus early when they become the primary, speeding up the consensus and thus generating more blocks and mining more GAS. We did not check a thing that is similar to mining difficulty. As v17 has mentioned here https://github.com/neo-project/neo/issues/2918, this is not an emergency fix, it is totally OK, it you think consensus nodes should be allowed to speed up the consensus maliciously.

I use 10000 just because i need a time window to konw what is the average block time in the past 10000 blocks, if they are shoter than the default consensus time, then the current consensus round would wait longer to slow down the consensus.

Jim8y commented 11 months ago

Create a new method IsValidTimestamp(previous, current) with UT?

would be challenging to have 10000 blocks UT, LOL, lets find out.

cschuchardt88 commented 11 months ago

One way, is to use NeoSystem in memory, than you could sleep thread until height is 10k. Should download on network and should be quick.

Jim8y commented 11 months ago

Kinda fun when i set it to 10000, not anymore.