mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
BlockId removal: refactor: Finalizer (#12528)
* BlockId removal: refactor: Finalizer It changes the arguments of methods of `Finalizer` trait from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * minor corrections * failing test corrected * minor rework
This commit is contained in:
committed by
GitHub
parent
7aadc2aa3c
commit
749bcd1949
@@ -509,14 +509,10 @@ fn finalize_block_and_wait_for_beefy(
|
||||
let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone());
|
||||
|
||||
for block in finalize_targets {
|
||||
let finalize = BlockId::number(*block);
|
||||
peers.clone().for_each(|(index, _)| {
|
||||
net.lock()
|
||||
.peer(index)
|
||||
.client()
|
||||
.as_client()
|
||||
.finalize_block(finalize, None)
|
||||
.unwrap();
|
||||
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();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -604,9 +600,15 @@ fn lagging_validators() {
|
||||
);
|
||||
|
||||
// Alice finalizes #25, Bob lags behind
|
||||
let finalize = BlockId::number(25);
|
||||
let finalize = net
|
||||
.lock()
|
||||
.peer(0)
|
||||
.client()
|
||||
.as_client()
|
||||
.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);
|
||||
@@ -614,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]);
|
||||
@@ -628,8 +630,14 @@ fn lagging_validators() {
|
||||
|
||||
// Alice finalizes session-boundary mandatory block #60, Bob lags behind
|
||||
let (best_blocks, versioned_finality_proof) = get_beefy_streams(&mut net.lock(), peers.clone());
|
||||
let finalize = BlockId::number(60);
|
||||
net.lock().peer(0).client().as_client().finalize_block(finalize, None).unwrap();
|
||||
let finalize = net
|
||||
.lock()
|
||||
.peer(0)
|
||||
.client()
|
||||
.as_client()
|
||||
.expect_block_hash_from_id(&BlockId::number(60))
|
||||
.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);
|
||||
@@ -637,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]);
|
||||
@@ -681,24 +689,16 @@ fn correct_beefy_payload() {
|
||||
get_beefy_streams(&mut net.lock(), [(0, BeefyKeyring::Alice)].into_iter());
|
||||
|
||||
// now 2 good validators and 1 bad one are voting
|
||||
net.lock()
|
||||
let hashof11 = net
|
||||
.lock()
|
||||
.peer(0)
|
||||
.client()
|
||||
.as_client()
|
||||
.finalize_block(BlockId::number(11), None)
|
||||
.unwrap();
|
||||
net.lock()
|
||||
.peer(1)
|
||||
.client()
|
||||
.as_client()
|
||||
.finalize_block(BlockId::number(11), None)
|
||||
.unwrap();
|
||||
net.lock()
|
||||
.peer(3)
|
||||
.client()
|
||||
.as_client()
|
||||
.finalize_block(BlockId::number(11), None)
|
||||
.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();
|
||||
|
||||
// verify consensus is _not_ reached
|
||||
let timeout = Some(Duration::from_millis(250));
|
||||
@@ -708,12 +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(BlockId::number(11), 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]);
|
||||
@@ -923,12 +918,9 @@ fn on_demand_beefy_justification_sync() {
|
||||
|
||||
let (dave_best_blocks, _) =
|
||||
get_beefy_streams(&mut net.lock(), [(dave_index, BeefyKeyring::Dave)].into_iter());
|
||||
net.lock()
|
||||
.peer(dave_index)
|
||||
.client()
|
||||
.as_client()
|
||||
.finalize_block(BlockId::number(1), None)
|
||||
.unwrap();
|
||||
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();
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user