Skip to content

Commit

Permalink
account for paritytech#4430
Browse files Browse the repository at this point in the history
  • Loading branch information
Lederstrumpf committed May 20, 2024
1 parent 9deeef3 commit 3913018
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
7 changes: 4 additions & 3 deletions substrate/client/consensus/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use sp_consensus_beefy::{
};
use sp_core::H256;
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
use sp_mmr_primitives::{AncestryProof, Error as MmrError, LeafIndex, MmrApi, NodeProof};
use sp_mmr_primitives::{AncestryProof, Error as MmrError, LeafIndex, MmrApi};
use sp_runtime::{
codec::{Decode, Encode},
traits::{Header as HeaderT, NumberFor},
Expand Down Expand Up @@ -362,8 +362,9 @@ sp_api::mock_impl_runtime_apis! {
) -> Result<AncestryProof<MmrRootHash>, MmrError> {
Ok(AncestryProof {
prev_peaks: vec![],
prev_size: 0,
proof: NodeProof { leaf_indices: vec![], leaf_count: 0, items: vec![] },
prev_leaf_count: 0,
leaf_count: 0,
items: vec![],
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/merkle-mountain-range/src/mmr/mmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
storage::{OffchainStorage, RuntimeStorage, Storage},
Hasher, Node, NodeOf,
},
primitives::{self, Error, LeafIndex, NodeIndex},
primitives::{self, Error, NodeIndex},
Config, HashOf, HashingOf,
};
use sp_mmr_primitives::{mmr_lib, mmr_lib::MMRStoreReadOps, utils::NodesUtils, LeafIndex};
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/consensus/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ where
// this can be inferred from the leaf_count / mmr_size of the prev_root:
// we've converted the commitment.block_number to an mmr size and now
// compare with the value in the ancestry proof
if expected_mmr_size != ancestry_proof.prev_size {
if expected_mmr_size != ancestry_proof.prev_leaf_count {
return false
}
if sp_mmr_primitives::utils::verify_ancestry_proof::<
Expand Down
8 changes: 3 additions & 5 deletions substrate/primitives/merkle-mountain-range/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ where
H: Clone + Debug + PartialEq + Encode,
M: mmr_lib::Merge<Item = H>,
{
let p: mmr_lib::NodeMerkleProof<H, _> = mmr_lib::NodeMerkleProof::<H, M>::new(
mmr_size,
ancestry_proof.proof.items.into_iter().collect(),
);
let p: mmr_lib::NodeMerkleProof<H, _> =
mmr_lib::NodeMerkleProof::<H, M>::new(mmr_size, ancestry_proof.items.into_iter().collect());

let ancestry_proof = mmr_lib::AncestryProof::<H, _> {
prev_peaks: ancestry_proof.prev_peaks,
prev_size: ancestry_proof.prev_size,
prev_size: ancestry_proof.prev_leaf_count,
proof: p,
};

Expand Down

0 comments on commit 3913018

Please sign in to comment.