Skip to content

Commit

Permalink
A0-4341: Bump rust toolchain to 1.79 (#1867)
Browse files Browse the repository at this point in the history
# Description

Mostly bumps the toolchain, but this also resulted in the detection and
removal of some unused code. This PR also removes support for the
`try-runtime` subcommand from the node binary – it was deprecated and we
are using the external tool already anyway.

## Type of change

Toolchain bump and cleanup.

# Checklist:
  • Loading branch information
timorleph authored Dec 2, 2024
1 parent 79d7908 commit 9c2036b
Show file tree
Hide file tree
Showing 22 changed files with 1,012 additions and 1,012 deletions.
1,840 changes: 956 additions & 884 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/chain-bootstrapper/src/chain_spec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl BootstrapChainCmd {
.into(),
);
}
authorities = account_ids.clone();
authorities.clone_from(&account_ids);
} else if !authorities
.iter()
.all(|authority| account_ids.contains(authority))
Expand Down
7 changes: 0 additions & 7 deletions bin/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ substrate-frame-rpc-system = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }

aleph-runtime = { workspace = true, optional = true }
try-runtime-cli = { workspace = true, optional = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true }
Expand Down Expand Up @@ -96,12 +95,6 @@ rocksdb = [
"sc-client-db/rocksdb",
"sc-service/rocksdb",
]
try-runtime = [
"aleph-runtime-native",
"dep:try-runtime-cli",
"aleph-runtime?/try-runtime",
"try-runtime-cli?/try-runtime",
]
aleph-runtime-native = [
"dep:aleph-runtime"
]
Expand Down
2 changes: 1 addition & 1 deletion bin/node/src/aleph_node_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub trait AlephNodeApi<BE> {
#[method(name = "getBlockAuthor")]
fn block_author(&self, hash: BlockHash) -> RpcResult<Option<AccountId>>;

///
/// Whether the node is ready for operation.
#[method(name = "ready")]
fn ready(&self) -> RpcResult<bool>;

Expand Down
9 changes: 1 addition & 8 deletions bin/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl SubstrateCli for Cli {
}
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, ClapSubcommand)]
pub enum Subcommand {
/// Key management cli utilities
Expand All @@ -95,14 +96,6 @@ pub enum Subcommand {
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Try some command against runtime state. Note: `try-runtime` feature must be enabled.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,

/// The custom benchmark subcommand benchmarking runtime pallets.
#[cfg(feature = "runtime-benchmarks")]
#[clap(subcommand)]
Expand Down
14 changes: 3 additions & 11 deletions bin/node/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
//! This module declares an `AlephExecutor` which is either a
//! * `WasmExecutor`, for production and test build (when no local debugging is required)
//! * `NativeElseWasmExecutor` for `try-runtime`, `runtime-benchmarks` and local debugging builds
//! * `NativeElseWasmExecutor` for `runtime-benchmarks` and local debugging builds
use sc_service::Configuration;

#[cfg(not(any(
feature = "runtime-benchmarks",
feature = "aleph-native-runtime",
feature = "try-runtime"
)))]
#[cfg(not(any(feature = "runtime-benchmarks", feature = "aleph-native-runtime",)))]
pub mod aleph_executor {
use sc_executor::WasmExecutor;

Expand All @@ -22,11 +18,7 @@ pub mod aleph_executor {
}
}

#[cfg(any(
feature = "runtime-benchmarks",
feature = "aleph-native-runtime",
feature = "try-runtime"
))]
#[cfg(any(feature = "runtime-benchmarks", feature = "aleph-native-runtime",))]
pub mod aleph_executor {
use sc_executor::NativeElseWasmExecutor;

Expand Down
6 changes: 1 addition & 5 deletions bin/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ mod service;

pub use cli::{Cli, Subcommand};
pub use config::Validator as ConfigValidator;
#[cfg(any(
feature = "runtime-benchmarks",
feature = "aleph-native-runtime",
feature = "try-runtime"
))]
#[cfg(any(feature = "runtime-benchmarks", feature = "aleph-native-runtime"))]
pub use executor::aleph_executor::ExecutorDispatch;
pub use service::{new_authority, new_partial, ServiceComponents};
35 changes: 0 additions & 35 deletions bin/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,41 +78,6 @@ fn main() -> sc_cli::Result<()> {
Ok((cmd.run(client, backend, None), task_manager))
})
}
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use aleph_node::ExecutorDispatch;
use primitives::{Block, MILLISECS_PER_BLOCK};
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;

Ok((
// TODO
// warning: use of deprecated method `try_runtime_cli::TryRuntimeCmd::run`:
// Substrate's `try-runtime` subcommand has been migrated to a standalone CLI
// (https://github.com/paritytech/try-runtime-cli). It is no longer being
// maintained here and will be removed entirely some time after January 2024.
// Please remove this subcommand from your runtime and use the standalone CLI.
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>, _>(Some(timestamp_with_aura_info(
MILLISECS_PER_BLOCK,
))),
task_manager,
))
})
}
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \
You can enable it with `--features try-runtime`."
.into()),
#[cfg(feature = "runtime-benchmarks")]
Some(Subcommand::Benchmark(cmd)) => {
use aleph_node::ExecutorDispatch;
Expand Down
2 changes: 1 addition & 1 deletion bin/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ pub struct U256ToBalance;

impl Convert<sp_core::U256, Balance> for U256ToBalance {
fn convert(n: sp_core::U256) -> Balance {
n.try_into().unwrap_or(Balance::max_value())
n.try_into().unwrap_or(Balance::MAX)
}
}

Expand Down
2 changes: 1 addition & 1 deletion finality-aleph/src/abft/current/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn run_member<H, C, ADN, V>(
multikeychain: Keychain,
config: Config,
network: WrappedNetwork<H::Unverified, ADN>,
data_provider: impl current_aleph_bft::DataProvider<AlephData<H::Unverified>> + Send + 'static,
data_provider: impl current_aleph_bft::DataProvider<AlephData<H::Unverified>> + 'static,
ordered_data_interpreter: OrderedDataInterpreter<SubstrateChainInfoProvider<H, C>, H, V>,
backup: ABFTBackup,
) -> Task
Expand Down
2 changes: 1 addition & 1 deletion finality-aleph/src/abft/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn run_member<H, C, ADN, V>(
multikeychain: Keychain,
config: Config,
network: WrappedNetwork<H::Unverified, ADN>,
data_provider: impl legacy_aleph_bft::DataProvider<AlephData<H::Unverified>> + Send + 'static,
data_provider: impl legacy_aleph_bft::DataProvider<AlephData<H::Unverified>> + 'static,
ordered_data_interpreter: OrderedDataInterpreter<SubstrateChainInfoProvider<H, C>, H, V>,
backup: ABFTBackup,
) -> Task
Expand Down
7 changes: 1 addition & 6 deletions finality-aleph/src/abft/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ use std::{cmp::Ordering, fmt::Debug, hash::Hash as StdHash, marker::PhantomData,

use futures::{channel::oneshot, Future};
use network_clique::{SpawnHandleExt, SpawnHandleT};
use parity_scale_codec::{Codec, Decode, Encode};
use parity_scale_codec::{Decode, Encode};
use sc_service::SpawnTaskHandle;
use sp_runtime::traits::Hash as SpHash;

/// A convenience trait for gathering all of the desired hash characteristics.
pub trait Hash: AsRef<[u8]> + StdHash + Eq + Clone + Codec + Debug + Send + Sync {}

impl<T: AsRef<[u8]> + StdHash + Eq + Clone + Codec + Debug + Send + Sync> Hash for T {}

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Wrapper<H: SpHash> {
phantom: PhantomData<H>,
Expand Down
6 changes: 1 addition & 5 deletions finality-aleph/src/block/mock/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Finalizer<MockJustification> for Backend {
None => panic!("finalizing block without specified parent: {header:?}"),
};

if storage.blockchain.get(&parent_id).is_none() {
if !storage.blockchain.contains_key(&parent_id) {
panic!("finalizing block without imported parent: {header:?}")
}

Expand Down Expand Up @@ -352,10 +352,6 @@ impl ChainStatus<MockBlock, MockJustification> for Backend {
Ok(FinalizedByDescendant(block.header.clone()))
}

fn best_block(&self) -> Result<MockHeader, Self::Error> {
Err(Self::Error {})
}

fn top_finalized(&self) -> Result<MockJustification, Self::Error> {
let storage = self.inner.lock();
let id = storage
Expand Down
3 changes: 0 additions & 3 deletions finality-aleph/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ where
/// the request is above the top finalized.
fn finalized_at(&self, number: BlockNumber) -> Result<FinalizationStatus<J>, Self::Error>;

/// The header of the best block.
fn best_block(&self) -> Result<J::Header, Self::Error>;

/// The justification of the top finalized block.
fn top_finalized(&self) -> Result<J, Self::Error>;

Expand Down
11 changes: 0 additions & 11 deletions finality-aleph/src/block/substrate/chain_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ impl SubstrateChainStatus {
}
}

fn best_hash(&self) -> AlephHash {
self.info().best_hash
}

fn finalized_hash(&self) -> AlephHash {
self.info().finalized_hash
}
Expand Down Expand Up @@ -225,13 +221,6 @@ impl ChainStatus<Block, Justification> for SubstrateChainStatus {
}
}

fn best_block(&self) -> Result<AlephHeader, Self::Error> {
let best_hash = self.best_hash();

self.header_for_hash(best_hash)?
.ok_or(Error::MissingHash(best_hash))
}

fn top_finalized(&self) -> Result<Justification, Self::Error> {
let finalized_hash = self.finalized_hash();
let header = self
Expand Down
19 changes: 18 additions & 1 deletion finality-aleph/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::sync::Arc;
use std::{
fmt::{Display, Error as FmtError, Formatter},
sync::Arc,
};

use parity_scale_codec::{Decode, Encode};
use sc_keystore::{Keystore, LocalKeystore};
Expand All @@ -17,6 +20,20 @@ pub enum Error {
Keystore(KeystoreError),
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
use Error::*;
match self {
KeyMissing(auth_id) => {
write!(f, "no key for authority {auth_id:?}")
}
Keystore(err) => {
write!(f, "keystore error: {err}")
}
}
}
}

#[derive(PartialEq, Eq, Clone, Debug, Hash, Decode, Encode)]
pub struct Signature(AuthoritySignature);

Expand Down
20 changes: 0 additions & 20 deletions finality-aleph/src/network/mock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::sync::Arc;

use futures::channel::mpsc;
use sc_keystore::LocalKeystore;
use sp_keystore::Keystore as _;

Expand All @@ -10,25 +9,6 @@ use crate::{
AuthorityId, NodeIndex,
};

#[derive(Clone)]
pub struct Channel<T>(
pub mpsc::UnboundedSender<T>,
pub Arc<tokio::sync::Mutex<mpsc::UnboundedReceiver<T>>>,
);

impl<T> Channel<T> {
pub fn new() -> Self {
let (tx, rx) = mpsc::unbounded();
Channel(tx, Arc::new(tokio::sync::Mutex::new(rx)))
}
}

impl<T> Default for Channel<T> {
fn default() -> Self {
Self::new()
}
}

pub fn crypto_basics(
num_crypto_basics: usize,
) -> (Vec<(NodeIndex, AuthorityPen)>, AuthorityVerifier) {
Expand Down
21 changes: 20 additions & 1 deletion finality-aleph/src/network/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{io::Error as IoError, iter, net::ToSocketAddrs as _};
use std::{
fmt::{Display as FmtDisplay, Error as FmtError, Formatter},
io::Error as IoError,
iter,
net::ToSocketAddrs as _,
};

use derive_more::{AsRef, Display};
use log::info;
Expand Down Expand Up @@ -177,6 +182,20 @@ pub enum Error {
AddressingInformation(AddressingInformationError),
}

impl FmtDisplay for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
use Error::*;
match self {
Io(err) => {
write!(f, "IO error: {err}")
}
AddressingInformation(err) => {
write!(f, "problem with addressing information: {err:?}")
}
}
}
}

impl From<IoError> for Error {
fn from(e: IoError) -> Self {
Error::Io(e)
Expand Down
10 changes: 5 additions & 5 deletions pallets/aleph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod mock;
mod tests;

mod impls;
mod traits;
pub mod traits;

use frame_support::{
sp_runtime::BoundToRuntimeAppPublic,
Expand Down Expand Up @@ -378,19 +378,19 @@ pub mod pallet {
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
type Key = T::AuthorityId;

fn on_genesis_session<'a, I: 'a>(validators: I)
fn on_genesis_session<'a, I>(validators: I)
where
I: Iterator<Item = (&'a T::AccountId, T::AuthorityId)>,
I: 'a + Iterator<Item = (&'a T::AccountId, T::AuthorityId)>,
T::AccountId: 'a,
{
let (_, authorities): (Vec<_>, Vec<_>) = validators.unzip();
// it is guaranteed that the first validator set will also be used in the next session
Self::initialize_authorities(authorities.as_slice(), authorities.as_slice());
}

fn on_new_session<'a, I: 'a>(changed: bool, _: I, queued_validators: I)
fn on_new_session<'a, I>(changed: bool, _: I, queued_validators: I)
where
I: Iterator<Item = (&'a T::AccountId, T::AuthorityId)>,
I: 'a + Iterator<Item = (&'a T::AccountId, T::AuthorityId)>,
T::AccountId: 'a,
{
Self::update_emergency_finalizer();
Expand Down
2 changes: 0 additions & 2 deletions pallets/elections/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(test)]

use frame_election_provider_support::{
data_provider, DataProviderBounds, ElectionDataProvider, VoteWeight,
};
Expand Down
2 changes: 0 additions & 2 deletions pallets/elections/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(test)]

use frame_election_provider_support::{ElectionProvider, Support};
use primitives::CommitteeSeats;
use sp_core::bounded_vec;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.77.0"
channel = "1.79.0"
targets = [ "wasm32-unknown-unknown" ]
components = [ "rustfmt", "clippy", "rust-src" ]
profile = "minimal"
Expand Down

0 comments on commit 9c2036b

Please sign in to comment.