Skip to content

Commit

Permalink
fix inherent data tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devdanco committed Jan 5, 2023
1 parent d81f776 commit 52ed01a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions client/basic-authorship-ver/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,6 @@ where
let (tx, rx) = oneshot::channel();
let spawn_handle = self.spawn_handle.clone();

if let Ok(None) = inherent_data
.get_data::<sp_core::ShufflingSeed>(&sp_ver::RANDOM_SEED_INHERENT_IDENTIFIER)
{
sp_ver::RandomSeedInherentDataProvider(Default::default())
.provide_inherent_data(&mut inherent_data);
}

spawn_handle.spawn_blocking(
"basic-authorship-proposer",
None,
Expand Down Expand Up @@ -425,10 +418,19 @@ where
) -> Result<Proposal<Block, backend::TransactionFor<B, Block>, PR::Proof>, sp_blockchain::Error>
{
let propose_with_start = time::Instant::now();
let mut inherent_data = inherent_data.clone();

let mut block_builder =
self.client.new_block_at(&self.parent_id, inherent_digests, PR::ENABLED)?;


if let Ok(None) = inherent_data
.get_data::<sp_core::ShufflingSeed>(&sp_ver::RANDOM_SEED_INHERENT_IDENTIFIER)
{
sp_ver::RandomSeedInherentDataProvider(Default::default())
.provide_inherent_data(&mut inherent_data).await.unwrap();
}

let create_inherents_start = time::Instant::now();
let (seed, inherents) = block_builder.create_inherents(inherent_data.clone())?;
let create_inherents_end = time::Instant::now();
Expand Down Expand Up @@ -789,6 +791,7 @@ mod tests {

// when
let deadline = time::Duration::from_secs(3);

let block =
block_on(proposer.propose(Default::default(), Default::default(), deadline, None))
.map(|r| r.block)
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
let claim = self.claim_slot(&slot_info.chain_head, slot, &aux_data).await?;

let key = self.get_key(&claim);
inject_inherents(keystore, &key, &mut slot_info).await.ok();
inject_inherents(keystore, &key, &mut slot_info).await.ok()?;

if self.should_backoff(slot, &slot_info.chain_head) {
return None
Expand Down

0 comments on commit 52ed01a

Please sign in to comment.