witnet / witnet-rust

Open source Rust implementation of the Witnet decentralized oracle protocol, including full node and wallet backend 👁️🦀
https://docs.witnet.io
GNU General Public License v3.0
180 stars 56 forks source link

Move consolidation logic out of ChainManager #685

Open tmpolaczyk opened 5 years ago

tmpolaczyk commented 5 years ago

It would be nice to be able to easily test validations of multiple blocks in sequence. For example, verifying if one block creates outputs, the next one can spend them.

But for that we need a consolidate_block function, which is currently defined in ChainManager and depends on actix. So we need to move that logic to the witnet_data_structures or the witnet_validations crate, in order to be able to write more validations tests.

The actix dependency can be removed by either returning all the needed information (for example, the list of reveals which need to be broadcasted through the network) and handling it in the caller, or by exposing a callback API so we can execute arbitrary code at arbitrary points in the consolidation process. Maybe some things can be extracted as a separate function, for example sending the JSON-RPC block notifications should not interfere with the consolidation.

tmpolaczyk commented 3 years ago

This would be useful now to verify that any changes to validations do not affect old blocks from the mainnet. That's useful to verify that new nodes will be able to sync from the beginning.