From 3913018118711b1a77536a3fe4b70b51e28a6f5e Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Mon, 20 May 2024 20:24:51 +0200 Subject: [PATCH] account for #4430 --- substrate/client/consensus/beefy/src/tests.rs | 7 ++++--- substrate/frame/merkle-mountain-range/src/mmr/mmr.rs | 2 +- substrate/primitives/consensus/beefy/src/lib.rs | 2 +- substrate/primitives/merkle-mountain-range/src/utils.rs | 8 +++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/substrate/client/consensus/beefy/src/tests.rs b/substrate/client/consensus/beefy/src/tests.rs index d2cf43b06c48..b96b390d1346 100644 --- a/substrate/client/consensus/beefy/src/tests.rs +++ b/substrate/client/consensus/beefy/src/tests.rs @@ -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}, @@ -362,8 +362,9 @@ sp_api::mock_impl_runtime_apis! { ) -> Result, 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![], }) } } diff --git a/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs b/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs index 71ae80e70650..5efc172d1e93 100644 --- a/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs +++ b/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs @@ -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}; diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index d5ce603f4d17..bc0e2048aef8 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -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::< diff --git a/substrate/primitives/merkle-mountain-range/src/utils.rs b/substrate/primitives/merkle-mountain-range/src/utils.rs index 604a7f43404a..f5dd6940a3f2 100644 --- a/substrate/primitives/merkle-mountain-range/src/utils.rs +++ b/substrate/primitives/merkle-mountain-range/src/utils.rs @@ -52,14 +52,12 @@ where H: Clone + Debug + PartialEq + Encode, M: mmr_lib::Merge, { - let p: mmr_lib::NodeMerkleProof = mmr_lib::NodeMerkleProof::::new( - mmr_size, - ancestry_proof.proof.items.into_iter().collect(), - ); + let p: mmr_lib::NodeMerkleProof = + mmr_lib::NodeMerkleProof::::new(mmr_size, ancestry_proof.items.into_iter().collect()); let ancestry_proof = mmr_lib::AncestryProof:: { prev_peaks: ancestry_proof.prev_peaks, - prev_size: ancestry_proof.prev_size, + prev_size: ancestry_proof.prev_leaf_count, proof: p, };