Skip to content

Commit

Permalink
fix: computation of vn mmr (#4772)
Browse files Browse the repository at this point in the history
Description
---
Fix the VNs mmr. The output vector was in random order that resulted in the mmr being kind of random as well.
So the miner and base node had different order of VNs and the blocks were invalidated. More VNs = less probability of passing.

How Has This Been Tested?
---
I manually registered 27 VNs and mined 100 blocks.
  • Loading branch information
Cifko authored Oct 11, 2022
1 parent 4060935 commit 64002e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base_layer/core/src/chain_storage/blockchain_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,8 @@ pub fn calculate_mmr_roots<T: BlockchainBackend>(db: &T, block: &Block) -> Resul

output_mmr.compress();

let validator_nodes = db.fetch_active_validator_nodes(metadata.height_of_longest_chain() + 1)?;
let mut validator_nodes = db.fetch_active_validator_nodes(metadata.height_of_longest_chain() + 1)?;
validator_nodes.sort();
let vn_mmr = ValidatorNodeMmr::new(validator_nodes.iter().map(|vn| vn.1.to_vec()).collect());

let mmr_roots = MmrRoots {
Expand Down

0 comments on commit 64002e9

Please sign in to comment.