BlockId removal: &Hash to Hash (#12626)

It changes &Block::Hash argument to Block::Hash.

This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)
This commit is contained in:
Michal Kucharczyk
2022-11-07 22:42:16 +01:00
committed by GitHub
parent 7c4bfc9749
commit 1ed70004e7
49 changed files with 428 additions and 441 deletions
+13 -13
View File
@@ -512,7 +512,7 @@ fn finalize_block_and_wait_for_beefy(
peers.clone().for_each(|(index, _)| {
let client = net.lock().peer(index).client().as_client();
let finalize = client.expect_block_hash_from_id(&BlockId::number(*block)).unwrap();
client.finalize_block(&finalize, None).unwrap();
client.finalize_block(finalize, None).unwrap();
})
}
@@ -608,7 +608,7 @@ fn lagging_validators() {
.expect_block_hash_from_id(&BlockId::number(25))
.unwrap();
let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone());
net.lock().peer(0).client().as_client().finalize_block(&finalize, None).unwrap();
net.lock().peer(0).client().as_client().finalize_block(finalize, None).unwrap();
// verify nothing gets finalized by BEEFY
let timeout = Some(Duration::from_millis(250));
streams_empty_after_timeout(best_blocks, &net, &mut runtime, timeout);
@@ -616,7 +616,7 @@ fn lagging_validators() {
// Bob catches up and also finalizes #25
let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone());
net.lock().peer(1).client().as_client().finalize_block(&finalize, None).unwrap();
net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap();
// expected beefy finalizes block #17 from diff-power-of-two
wait_for_best_beefy_blocks(best_blocks, &net, &mut runtime, &[23, 24, 25]);
wait_for_beefy_signed_commitments(versioned_finality_proof, &net, &mut runtime, &[23, 24, 25]);
@@ -637,7 +637,7 @@ fn lagging_validators() {
.as_client()
.expect_block_hash_from_id(&BlockId::number(60))
.unwrap();
net.lock().peer(0).client().as_client().finalize_block(&finalize, None).unwrap();
net.lock().peer(0).client().as_client().finalize_block(finalize, None).unwrap();
// verify nothing gets finalized by BEEFY
let timeout = Some(Duration::from_millis(250));
streams_empty_after_timeout(best_blocks, &net, &mut runtime, timeout);
@@ -645,7 +645,7 @@ fn lagging_validators() {
// Bob catches up and also finalizes #60 (and should have buffered Alice's vote on #60)
let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers);
net.lock().peer(1).client().as_client().finalize_block(&finalize, None).unwrap();
net.lock().peer(1).client().as_client().finalize_block(finalize, None).unwrap();
// verify beefy skips intermediary votes, and successfully finalizes mandatory block #60
wait_for_best_beefy_blocks(best_blocks, &net, &mut runtime, &[60]);
wait_for_beefy_signed_commitments(versioned_finality_proof, &net, &mut runtime, &[60]);
@@ -696,9 +696,9 @@ fn correct_beefy_payload() {
.as_client()
.expect_block_hash_from_id(&BlockId::number(11))
.unwrap();
net.lock().peer(0).client().as_client().finalize_block(&hashof11, None).unwrap();
net.lock().peer(1).client().as_client().finalize_block(&hashof11, None).unwrap();
net.lock().peer(3).client().as_client().finalize_block(&hashof11, None).unwrap();
net.lock().peer(0).client().as_client().finalize_block(hashof11, None).unwrap();
net.lock().peer(1).client().as_client().finalize_block(hashof11, None).unwrap();
net.lock().peer(3).client().as_client().finalize_block(hashof11, None).unwrap();
// verify consensus is _not_ reached
let timeout = Some(Duration::from_millis(250));
@@ -708,7 +708,7 @@ fn correct_beefy_payload() {
// 3rd good validator catches up and votes as well
let (best_blocks, versioned_finality_proof) =
get_beefy_streams(&mut net.lock(), [(0, BeefyKeyring::Alice)].into_iter());
net.lock().peer(2).client().as_client().finalize_block(&hashof11, None).unwrap();
net.lock().peer(2).client().as_client().finalize_block(hashof11, None).unwrap();
// verify consensus is reached
wait_for_best_beefy_blocks(best_blocks, &net, &mut runtime, &[11]);
@@ -760,7 +760,7 @@ fn beefy_importing_blocks() {
// none in backend,
assert_eq!(
full_client
.justifications(&hashof1)
.justifications(hashof1)
.unwrap()
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
None
@@ -799,7 +799,7 @@ fn beefy_importing_blocks() {
// still not in backend (worker is responsible for appending to backend),
assert_eq!(
full_client
.justifications(&hashof2)
.justifications(hashof2)
.unwrap()
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
None
@@ -843,7 +843,7 @@ fn beefy_importing_blocks() {
// none in backend,
assert_eq!(
full_client
.justifications(&hashof3)
.justifications(hashof3)
.unwrap()
.and_then(|j| j.get(BEEFY_ENGINE_ID).cloned()),
None
@@ -941,7 +941,7 @@ fn on_demand_beefy_justification_sync() {
get_beefy_streams(&mut net.lock(), [(dave_index, BeefyKeyring::Dave)].into_iter());
let client = net.lock().peer(dave_index).client().as_client();
let hashof1 = client.expect_block_hash_from_id(&BlockId::number(1)).unwrap();
client.finalize_block(&hashof1, None).unwrap();
client.finalize_block(hashof1, None).unwrap();
// Give Dave task some cpu cycles to process the finality notification,
run_for(Duration::from_millis(100), &net, &mut runtime);
// freshly spun up Dave now needs to listen for gossip to figure out the state of his peers.