nimiq / core-rs-albatross

Rust implementation of the Albatross protocol
https://nimiq.com
Other
160 stars 61 forks source link

Missing blocks are tried to be pushed when the state root can not be verfied yet. #2675

Closed viquezclaudio closed 3 months ago

viquezclaudio commented 3 months ago

In several instances of testnet runs, when full nodes are syncing the validity window, the following kind of log messages can be observed:

` Pushing block #121:MI:f023dca1a4 from missing blocks response Rejecting block block=121:MI:f023dca1a4 block_root=d14ec6d3cac4714955df120c178242a95cdbfa54d0211d959f4c871d3d0feff4 history_root=13349e54e46d47f9497705d158c328d5b1ec37dd447971ec10aa68b49672e948 reason="History root doesn't match real history root"

Rejecting block block=#121:MI:f023dca1a4 reason="bad state" error=Invalid block: Invalid history root error=nvalid history root]

`

This is because for this particular case,, we started the validity sync to sync up to macro block #120: Starting validity window synchronization process target_macro=120

But when we see a block higher than macro block #120 being announced and try to apply those, it fails because the history root cannot be verified yet.

Once the validity sync is complete, and the history root can be verified, everything works as expected.

However, this is misleading and can create potential errors during the state sync process since a failed push block error is returned from the blockchain.

A better strategy is to not push blocks until we can verify the history root.