Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 5766a6a

Browse files
committed
get things compiling
1 parent 0057a11 commit 5766a6a

File tree

2 files changed

+21
-15
lines changed
  • client

2 files changed

+21
-15
lines changed

client/consensus/common/src/lib.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
1616

17+
use codec::Decode;
1718
use polkadot_primitives::{Hash as PHash, PersistedValidationData};
1819

19-
use cumulus_primitives_core::ParaId;
20+
use cumulus_primitives_core::{relay_chain::OccupiedCoreAssumption, ParaId};
21+
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
2022

2123
use sc_client_api::Backend;
2224
use sc_consensus::{shared_data::SharedData, BlockImport, ImportResult};
@@ -224,9 +226,9 @@ pub struct PotentialParent<B: BlockT> {
224226
/// * the block number is within `max_depth` blocks of the included block
225227
pub async fn find_potential_parents<B: BlockT>(
226228
params: ParentSearchParams,
227-
client: &C,
229+
client: &impl sp_blockchain::Backend<B>,
228230
relay_client: &impl RelayChainInterface,
229-
) -> Result<Vec<B::Hash>, RelayChainError> {
231+
) -> Result<Vec<PotentialParent<B>>, RelayChainError> {
230232
// 1. Build up the ancestry record of the relay chain to compare against.
231233
let rp_ancestry = {
232234
let mut ancestry = Vec::with_capacity(params.ancestry_lookback + 1);
@@ -241,21 +243,21 @@ pub async fn find_potential_parents<B: BlockT>(
241243
current_rp = header.parent_hash().clone();
242244

243245
// don't iterate back into the genesis block.
244-
if header.number == 1u32.into() { break }
246+
if header.number == 1 { break }
245247
}
246248

247-
rp_ancestry
249+
ancestry
248250
};
249251

250252
let is_hash_in_ancestry = |hash| rp_ancestry.iter().any(|x| x.0 == hash);
251-
let is_root_in_ancestry = |root| rp.ancestry.iter().any(|x| x.1 == root);
253+
let is_root_in_ancestry = |root| rp_ancestry.iter().any(|x| x.1 == root);
252254

253255
// 2. Get the included and pending availability blocks.
254256
let included_header = relay_client.persisted_validation_data(
255257
params.relay_parent,
256258
params.para_id,
257259
OccupiedCoreAssumption::TimedOut,
258-
)?;
260+
).await?;
259261

260262
let included_header = match included_header {
261263
Some(pvd) => pvd.parent_head,
@@ -266,7 +268,7 @@ pub async fn find_potential_parents<B: BlockT>(
266268
params.relay_parent,
267269
params.para_id,
268270
OccupiedCoreAssumption::Included,
269-
)?.and_then(|x| if x.parent_head != included_header { Some(x.parent_head) } else { None });
271+
).await?.and_then(|x| if x.parent_head != included_header { Some(x.parent_head) } else { None });
270272

271273
let included_header = match B::Header::decode(&mut &included_header.0[..]).ok() {
272274
None => return Ok(Vec::new()),
@@ -277,7 +279,7 @@ pub async fn find_potential_parents<B: BlockT>(
277279
let included_hash = included_header.hash();
278280
let pending_hash = pending_header.as_ref().map(|hdr| hdr.hash());
279281

280-
let mut frontier = vec![PotentialParent {
282+
let mut frontier = vec![PotentialParent::<B> {
281283
hash: included_hash,
282284
header: included_header,
283285
depth: 0,
@@ -303,17 +305,21 @@ pub async fn find_potential_parents<B: BlockT>(
303305
.map_or(false, is_root_in_ancestry)
304306
};
305307

308+
let descends_from_pending = entry.descends_from_pending;
309+
let child_depth = entry.depth + 1;
310+
let hash = entry.hash;
311+
306312
if is_potential {
307313
potential_parents.push(entry);
308314
}
309315

310-
if !is_potential || entry.depth + 1 > max_depth { continue }
316+
if !is_potential || child_depth > params.max_depth { continue }
311317

312318
// push children onto search frontier.
313-
for child in client.children(entry.hash).ok().flatten().into_iter().flat_map(|c| c) {
319+
for child in client.children(hash).ok().into_iter().flat_map(|c| c) {
314320
if params.ignore_alternative_branches
315321
&& is_included
316-
&& pending_hash.map_or(false, |h| &child != h)
322+
&& pending_hash.map_or(false, |h| child != h)
317323
{ continue }
318324

319325
let header = match client.header(child) {
@@ -325,8 +331,8 @@ pub async fn find_potential_parents<B: BlockT>(
325331
frontier.push(PotentialParent {
326332
hash: child,
327333
header,
328-
depth: entry.depth + 1,
329-
descends_from_pending: is_pending || entry.descends_from_pending,
334+
depth: child_depth,
335+
descends_from_pending: is_pending || descends_from_pending,
330336
});
331337
}
332338
}

client/relay-chain-interface/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ where
264264
}
265265

266266
async fn header(&self, block_id: PHash) -> RelayChainResult<Option<PHeader>> {
267-
(**self).header().await
267+
(**self).header(block_id).await
268268
}
269269

270270
async fn is_major_syncing(&self) -> RelayChainResult<bool> {

0 commit comments

Comments
 (0)