nspcc-dev / neo-go

Go Node and SDK for the Neo blockchain
MIT License
123 stars 79 forks source link

Make the number of validators mutable during chain lifetime #2320

Closed roman-khimov closed 2 years ago

roman-khimov commented 2 years ago

Right now ValidatorsCount sets proper CN count for the whole network lifetime which is acceptable for most public networks, but doesn't fit well some of NeoFS scenarios (growing a network from one node to many of them). Therefore we need to make it possible to change it.

An obvious solution is just an extension of the configuration file, like ValidatorsCount: {height: number, height: number,...}, similar to Legacy's MaxTransactionsPerBlock or FreeGasLimit setting. Easy to implement, but it requires configuration file update on all nodes.

The other option is going through Policy or other special contract. Committee-signed transactions are always good, but it's a separate mechanism and it contradicts the scheme we have now, so maintaining this functionality (protocol extension) would be rather costly.

fyrchik commented 2 years ago

Things that should be taken into account:

  1. Real committee is updated once in a while (the performance optimization from af1651941). DBFT should probably see the updated view on validator number when the committee is updated. Otherwise reward calculations should be altered somehow (it is not obvious how).
  2. SecondsPerBlock should be altered too. As we could see in benchmarks it can heavily influence TPS when there are many validators.
roman-khimov commented 2 years ago
  1. It can be made a part of election process, delaying update for committee number of blocks is not a problem (still, it's easier to do that with configuration file).
  2. SecondsPerBlock just requires a configuration on all CNs, other nodes don't care much.
roman-khimov commented 2 years ago

It also affects these things:

The other thing to keep in mind is that we have a committee which technically can be of different size than CN list. Usually it's taken from the configuration file, but the number of keys there is not specified explicitly, so changing it requires additional configuration option as well.

Updating the number of validators via the configuration file solves almost all of these problems (except for getversion), while keeping it in the contract is not easy. Going through the contract we'll need to keep "excessive" standby validators nearby and we'll have to change some internal parameters on the go (without node restart). Legacy voting was somewhat more flexible wrt this issue.

Unless we completely drop the N3 voting ("private FS mode") we better extend the configuration file format and update configs on all nodes. This way it'll at least not require additional switches (of which we have many already) and the extension itself will be completely possible.