Silence known deprecation warnings (#2651)

* Silence known deprecation warnings

1. Prefixes known instances of usages of client.backend and client.import_lock with `#[allow(deprecated)]` to silence the warnings. 2. Remove file-global `#![allow(deprecated)]` used in these cases. Both to prevent us overlooking externally caused deprecation messages.

* fixing missing ;

* fix missing test cases

* move deprecated markers to make CI happy

* move deprecated markers to make CI happy

* attempt to fix the test

* bumping impl_version of node runtime

* Minor cleanup
This commit is contained in:
Benjamin Kampmann
2019-05-28 10:35:00 +02:00
committed by Tomasz Drwięga
parent b10ecd7931
commit 22d3043917
20 changed files with 95 additions and 38 deletions
@@ -399,6 +399,7 @@ pub(crate) fn ancestry<B, Block: BlockT<Hash=H256>, E, RA>(
if base == block { return Err(GrandpaError::NotDescendent) }
let tree_route_res = ::client::blockchain::tree_route(
#[allow(deprecated)]
client.backend().blockchain(),
BlockId::Hash(block),
BlockId::Hash(base),
@@ -521,6 +522,7 @@ where
current_round: HasVoted::Yes(local_id, Vote::Propose(propose)),
};
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?;
Ok(Some(set_state))
@@ -562,6 +564,7 @@ where
current_round: HasVoted::Yes(local_id, Vote::Prevote(propose.cloned(), prevote)),
};
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?;
Ok(Some(set_state))
@@ -601,6 +604,7 @@ where
current_round: HasVoted::Yes(local_id, Vote::Precommit(propose.clone(), prevote.clone(), precommit)),
};
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?;
Ok(Some(set_state))
@@ -644,6 +648,7 @@ where
current_round: HasVoted::No,
};
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?;
Ok(Some(set_state))
@@ -655,8 +660,10 @@ where
fn finalize_block(&self, hash: Block::Hash, number: NumberFor<Block>, round: u64, commit: Commit<Block>) -> Result<(), Self::Error> {
use client::blockchain::HeaderBackend;
let status = self.inner.backend().blockchain().info()?;
if number <= status.finalized_number && self.inner.backend().blockchain().hash(number)? == Some(hash) {
#[allow(deprecated)]
let blockchain = self.inner.backend().blockchain();
let status = blockchain.info()?;
if number <= status.finalized_number && blockchain.hash(number)? == Some(hash) {
// This can happen after a forced change (triggered by the finality tracker when finality is stalled), since
// the voter will be restarted at the median last finalized block, which can be lower than the local best
// finalized block.
@@ -974,6 +981,7 @@ where B: Backend<Block, Blake2Hasher>,
}
let tree_route = client::blockchain::tree_route(
#[allow(deprecated)]
client.backend().blockchain(),
BlockId::Hash(*hash),
BlockId::Hash(*base),
@@ -173,6 +173,7 @@ impl<B, E, Block, RA> network::FinalityProofProvider<Block> for FinalityProofPro
})?;
match request {
FinalityProofRequest::Original(request) => prove_finality::<_, _, GrandpaJustification<Block>>(
#[allow(deprecated)]
&*self.client.backend().blockchain(),
&*self.authority_provider,
request.authorities_set_id,
@@ -317,12 +317,15 @@ where
// for the canon block the new authority set should start
// with. we use the minimum between the median and the local
// best finalized block.
#[allow(deprecated)]
let best_finalized_number = self.inner.backend().blockchain().info()
.map_err(|e| ConsensusError::ClientImport(e.to_string()))?
.finalized_number;
let canon_number = best_finalized_number.min(median_last_finalized_number);
#[allow(deprecated)]
let canon_hash =
self.inner.backend().blockchain().header(BlockId::Number(canon_number))
.map_err(|e| ConsensusError::ClientImport(e.to_string()))?
@@ -396,6 +399,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, PRA, SC> BlockImport<Block>
// early exit if block already in chain, otherwise the check for
// authority changes will error when trying to re-import a change block
#[allow(deprecated)]
match self.inner.backend().blockchain().status(BlockId::Hash(hash)) {
Ok(blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain),
Ok(blockchain::BlockStatus::Unknown) => {},
@@ -72,6 +72,7 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
loop {
if current_hash == commit.target_hash { break; }
#[allow(deprecated)]
match client.backend().blockchain().header(BlockId::Hash(current_hash))? {
Some(current_header) => {
if *current_header.number() <= commit.target_number {
+5 -1
View File
@@ -52,7 +52,6 @@
//! or prune any signaled changes based on whether the signaling block is
//! included in the newly-finalized chain.
#![forbid(warnings)]
#![allow(deprecated)] // FIXME #2532: remove once the refactor is done https://github.com/paritytech/substrate/issues/2532
use futures::prelude::*;
use log::{debug, info, warn};
@@ -321,6 +320,7 @@ where
let genesis_hash = chain_info.chain.genesis_hash;
let persistent_data = aux_schema::load_persistent(
#[allow(deprecated)]
&**client.backend(),
genesis_hash,
<NumberFor<Block>>::zero(),
@@ -430,6 +430,7 @@ fn register_finality_tracker_inherent_data_provider<B, E, Block: BlockT<Hash=H25
if !inherent_data_providers.has_provider(&srml_finality_tracker::INHERENT_IDENTIFIER) {
inherent_data_providers
.register_provider(srml_finality_tracker::InherentDataProvider::new(move || {
#[allow(deprecated)]
match client.backend().blockchain().info() {
Err(e) => Err(std::borrow::Cow::Owned(e.to_string())),
Ok(info) => {
@@ -653,6 +654,7 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, X>(
current_round: HasVoted::No,
};
#[allow(deprecated)]
aux_schema::write_voter_set_state(&**client.backend(), &set_state)?;
let set_state: SharedVoterSetState<_> = set_state.into();
@@ -678,6 +680,8 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, X>(
env.update_voter_set_state(|voter_set_state| {
let completed_rounds = voter_set_state.completed_rounds();
let set_state = VoterSetState::Paused { completed_rounds };
#[allow(deprecated)]
aux_schema::write_voter_set_state(&**client.backend(), &set_state)?;
Ok(Some(set_state))
})?;
@@ -64,6 +64,7 @@ pub fn light_block_import<B, E, Block: BlockT<Hash=H256>, RA, PRA>(
PRA::Api: GrandpaApi<Block>,
{
let info = client.info()?;
#[allow(deprecated)]
let import_data = load_aux_import_data(info.chain.finalized_hash, &**client.backend(), api)?;
Ok(GrandpaLightBlockImport {
client,
@@ -291,6 +292,7 @@ fn do_import_finality_proof<B, E, Block: BlockT<Hash=H256>, RA, J>(
let authority_set_id = data.authority_set.set_id();
let authorities = data.authority_set.authorities();
let finality_effects = crate::finality_proof::check_finality_proof(
#[allow(deprecated)]
&*client.backend().blockchain(),
authority_set_id,
authorities,
@@ -314,6 +316,7 @@ fn do_import_finality_proof<B, E, Block: BlockT<Hash=H256>, RA, J>(
// try to import latest justification
let finalized_block_hash = finality_effects.block;
#[allow(deprecated)]
let finalized_block_number = client.backend().blockchain()
.expect_block_number_from_id(&BlockId::Hash(finality_effects.block))
.map_err(|e| ConsensusError::ClientImport(e.to_string()))?;
@@ -502,6 +505,7 @@ fn require_insert_aux<T: Encode, B, E, Block: BlockT<Hash=H256>, RA>(
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
{
#[allow(deprecated)]
let backend = &**client.backend();
let encoded = value.encode();
let update_res = Backend::insert_aux(backend, &[(key, &encoded[..])], &[]);
@@ -218,6 +218,7 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
let completed_rounds = set_state.read().completed_rounds();
let set_state = VoterSetState::Paused { completed_rounds };
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**client.backend(), &set_state)?;
set_state
@@ -238,6 +239,7 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
current_round: HasVoted::No,
};
#[allow(deprecated)]
crate::aux_schema::write_voter_set_state(&**client.backend(), &set_state)?;
set_state
@@ -119,6 +119,7 @@ impl TestNetFactory for GrandpaTestNet {
{
match client {
PeersClient::Full(ref client) => {
#[allow(deprecated)]
let select_chain = LongestChain::new(
client.backend().clone(),
client.import_lock().clone()
@@ -676,6 +677,7 @@ fn transition_3_voters_twice_1_full_observer() {
"Peer #{} failed to sync", i);
let set: AuthoritySet<Hash, BlockNumber> = crate::aux_schema::load_authorities(
#[allow(deprecated)]
&**full_client.backend()
).unwrap();
@@ -765,6 +767,7 @@ fn transition_3_voters_twice_1_full_observer() {
.map(move |()| {
let full_client = client.as_full().expect("only full clients are used in test");
let set: AuthoritySet<Hash, BlockNumber> = crate::aux_schema::load_authorities(
#[allow(deprecated)]
&**full_client.backend()
).unwrap();
@@ -1035,6 +1038,7 @@ fn force_change_to_new_set() {
let full_client = peer.client().as_full().expect("only full clients are used in test");
let set: AuthoritySet<Hash, BlockNumber> = crate::aux_schema::load_authorities(
#[allow(deprecated)]
&**full_client.backend()
).unwrap();
@@ -1288,6 +1292,7 @@ fn voter_persists_its_votes() {
assert_eq!(net.lock().peer(0).client().info().unwrap().chain.best_number, 40,
"Peer #{} failed to sync", 0);
#[allow(deprecated)]
let block_30_hash =
net.lock().peer(0).client().as_full().unwrap().backend().blockchain().hash(30).unwrap().unwrap();