mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
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:
committed by
GitHub
parent
7c4bfc9749
commit
1ed70004e7
+1
-1
@@ -153,7 +153,7 @@ where
|
||||
self.client.block_hash(request.payload.begin).map_err(Error::Client)?
|
||||
{
|
||||
self.client
|
||||
.justifications(&hash)
|
||||
.justifications(hash)
|
||||
.map_err(Error::Client)?
|
||||
.and_then(|justifs| justifs.get(BEEFY_ENGINE_ID).cloned())
|
||||
// No BEEFY justification present.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -511,7 +511,7 @@ where
|
||||
.expect("forwards closure result; the closure always returns Ok; qed.");
|
||||
|
||||
self.backend
|
||||
.append_justification(&hash, (BEEFY_ENGINE_ID, finality_proof.encode()))
|
||||
.append_justification(hash, (BEEFY_ENGINE_ID, finality_proof.encode()))
|
||||
}) {
|
||||
error!(target: "beefy", "🥩 Error {:?} on appending justification: {:?}", e, finality_proof);
|
||||
}
|
||||
@@ -709,7 +709,7 @@ where
|
||||
// a BEEFY justification, or at this session's boundary; voter will resume from there.
|
||||
loop {
|
||||
if let Some(true) = blockchain
|
||||
.justifications(&header.hash())
|
||||
.justifications(header.hash())
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|justifs| justifs.get(BEEFY_ENGINE_ID).is_some())
|
||||
@@ -1375,8 +1375,8 @@ pub(crate) mod tests {
|
||||
// finalize 1 and 2 without justifications
|
||||
let hashof1 = backend.blockchain().expect_block_hash_from_id(&BlockId::Number(1)).unwrap();
|
||||
let hashof2 = backend.blockchain().expect_block_hash_from_id(&BlockId::Number(2)).unwrap();
|
||||
backend.finalize_block(&hashof1, None).unwrap();
|
||||
backend.finalize_block(&hashof2, None).unwrap();
|
||||
backend.finalize_block(hashof1, None).unwrap();
|
||||
backend.finalize_block(hashof2, None).unwrap();
|
||||
|
||||
let justif = create_finality_proof(2);
|
||||
// create new session at block #2
|
||||
@@ -1401,7 +1401,7 @@ pub(crate) mod tests {
|
||||
}));
|
||||
|
||||
// check BEEFY justifications are also appended to backend
|
||||
let justifs = backend.blockchain().justifications(&hashof2).unwrap().unwrap();
|
||||
let justifs = backend.blockchain().justifications(hashof2).unwrap().unwrap();
|
||||
assert!(justifs.get(BEEFY_ENGINE_ID).is_some())
|
||||
}
|
||||
|
||||
@@ -1512,7 +1512,7 @@ pub(crate) mod tests {
|
||||
// finalize 13 without justifications
|
||||
let hashof13 =
|
||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(13)).unwrap();
|
||||
net.peer(0).client().as_client().finalize_block(&hashof13, None).unwrap();
|
||||
net.peer(0).client().as_client().finalize_block(hashof13, None).unwrap();
|
||||
|
||||
// Test initialization at session boundary.
|
||||
{
|
||||
@@ -1551,7 +1551,7 @@ pub(crate) mod tests {
|
||||
let hashof10 =
|
||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(10)).unwrap();
|
||||
backend
|
||||
.append_justification(&hashof10, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.append_justification(hashof10, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.unwrap();
|
||||
|
||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 10
|
||||
@@ -1587,7 +1587,7 @@ pub(crate) mod tests {
|
||||
let hashof12 =
|
||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(12)).unwrap();
|
||||
backend
|
||||
.append_justification(&hashof12, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.append_justification(hashof12, (BEEFY_ENGINE_ID, justif.encode()))
|
||||
.unwrap();
|
||||
|
||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 12
|
||||
|
||||
Reference in New Issue
Block a user