skalenetwork / skaled

Running more than 20 production blockchains, SKALED is Ethereum-compatible, high performance C++ Proof-of-Stake client, tools and libraries. Uses SKALE consensus as a blockchain consensus core. Includes dynamic Oracle. Implements file storage and retrieval as an EVM extension.
https://skale.network
GNU General Public License v3.0
85 stars 40 forks source link

Skaled sign blocks with invalid keys during the node rotation and update procedure #1979

Open oleksandrSydorenkoJ opened 2 months ago

oleksandrSydorenkoJ commented 2 months ago

Describe the bug Skaled sign blocks with the actual node groups (latest) but checks the incoming blocks through the catchup with timestamp root. To avoid signing for the not actual keys set, you need to add checks into the skaled. If the timestamp of the latest group is null and rotation is in progress, check the finish_ts of the previous group. If the finish_ts of the previous group are bigger than the actual timestamp - use the earlier keys for a sign.

Preconditions Ative schain medium type 17 nodes with 1 ETH on the balance

Versions skalenetwork/schain:3.19.1

To Reproduce

  1. Run node exit on the node A
  2. wait for the DKG completed
  3. run skale node update on the staying node B
  4. check skaled logs

Expected behavior Config is regenerated during the update, Skaled uses valid keys from actual node_group to sign the blocks and continue mining blocks without any errors.

Actual state Skaled on updated node sign blocks with the new node group, when blocks should be sign with the previous node_group's keys

logs

from updated node

2024-09-05 14:44:23.774 [197:main] [error] 5848291:     !Caused by: CryptoManager:State check failed::res /home/s5/actions-runner-3/_work/skaled/skaled/libconsensus/crypto/CryptoManager.cpp:985     
olehnikolaiev commented 2 months ago

should be managed by skale-admin, not by skaled. skaled only signs blocks with the key that was passed to it.