Skip to content

Commit 302d002

Browse files
authored
chore: bump rust toolchain version to 1.78.0 (#4284)
1 parent 8ad19d0 commit 302d002

File tree

17 files changed

+29
-260
lines changed

17 files changed

+29
-260
lines changed

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.77.0"
2+
channel = "1.78.0"
33
components = ["clippy", "llvm-tools-preview", "rustfmt"]

src/beacon/signatures/public_key_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl PublicKeyOnG2 {
99
}
1010

1111
pub fn verify(&self, message: impl AsRef<[u8]>, signature: &SignatureOnG1) -> bool {
12-
verify_messages_unchained(self, &[message.as_ref()], &[&signature])
12+
verify_messages_unchained(self, &[message.as_ref()], &[signature])
1313
}
1414

1515
pub fn verify_batch(&self, messages: &[&[u8]], signatures: &[&SignatureOnG1]) -> bool {

src/blocks/chain4u.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ impl<T> Chain4U<T> {
167167
inner: Default::default(),
168168
}
169169
}
170-
pub fn get<Q: ?Sized>(&self, ident: &Q) -> Option<RawBlockHeader>
170+
pub fn get<Q>(&self, ident: &Q) -> Option<RawBlockHeader>
171171
where
172172
String: Borrow<Q>,
173-
Q: Hash + Eq,
173+
Q: Hash + Eq + ?Sized,
174174
{
175175
self.inner.lock().ident2header.get(ident).cloned()
176176
}
@@ -395,15 +395,11 @@ impl<N, E, Ix> KeyedDiGraph<N, E, Ix> {
395395
{
396396
petgraph::algo::is_cyclic_directed(&self.graph)
397397
}
398-
fn neighbors_directed<Q: ?Sized>(
399-
&self,
400-
node: &Q,
401-
dir: petgraph::Direction,
402-
) -> impl Iterator<Item = &N>
398+
fn neighbors_directed<Q>(&self, node: &Q, dir: petgraph::Direction) -> impl Iterator<Item = &N>
403399
where
404400
Ix: petgraph::graph::IndexType,
405401
N: Borrow<Q> + Hash + Eq,
406-
Q: Hash + Eq,
402+
Q: Hash + Eq + ?Sized,
407403
{
408404
self.node2ix
409405
.get_by_left(node)

src/chain/weight.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
// Copyright 2019-2024 ChainSafe Systems
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

4-
use crate::blocks::Tipset;
5-
use fvm_ipld_blockstore::Blockstore;
6-
use num::BigInt;
7-
use std::sync::Arc;
8-
9-
pub type Weight = BigInt;
10-
11-
/// The `Scale` trait abstracts away the logic of assigning a weight to a chain,
12-
/// which can be consensus specific. For example it can depend on the stake and
13-
/// power of validators, or it can be as simple as the height of the blocks in
14-
/// a `Nakamoto` style consensus.
15-
pub trait Scale {
16-
/// Calculate the weight of a tipset.
17-
fn weight<DB>(db: &Arc<DB>, ts: &Tipset) -> Result<Weight, anyhow::Error>
18-
where
19-
DB: Blockstore;
20-
}
4+
pub type Weight = num::BigInt;

src/chain_sync/consensus.rs

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,8 @@
11
// Copyright 2019-2024 ChainSafe Systems
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

4-
use std::{
5-
borrow::Cow,
6-
fmt::{Debug, Display},
7-
sync::Arc,
8-
};
9-
10-
use crate::blocks::{Block, Tipset};
11-
use crate::chain::Scale;
12-
use crate::message::SignedMessage;
13-
use crate::message_pool::MessagePool;
14-
use crate::state_manager::StateManager;
15-
use async_trait::async_trait;
164
use futures::{stream::FuturesUnordered, StreamExt};
17-
use fvm_ipld_blockstore::Blockstore;
185
use nunny::Vec as NonEmpty;
19-
use tokio::task::JoinSet;
20-
21-
/// The `Consensus` trait encapsulates consensus specific rules of validation
22-
/// and block creation. Behind the scenes they can farm out the total ordering
23-
/// of transactions to an arbitrary consensus engine, but in the end they
24-
/// package the transactions into Filecoin compatible blocks.
25-
///
26-
/// Not all fields will be made use of, however, so the validation of these
27-
/// blocks at least partially have to be trusted to the `Consensus` component.
28-
///
29-
/// Common rules for message ordering will be followed, and can be validated
30-
/// outside by the host system during chain synchronization.
31-
#[async_trait]
32-
pub trait Consensus: Scale + Debug + Send + Sync + Unpin + 'static {
33-
type Error: Debug + Display + Send + Sync;
34-
35-
/// Perform block validation asynchronously and return all encountered
36-
/// errors if failed.
37-
///
38-
/// Being asynchronous gives the method a chance to construct a pipeline of
39-
/// validations, i.e. do some common ones before branching out.
40-
async fn validate_block<DB>(
41-
&self,
42-
state_manager: Arc<StateManager<DB>>,
43-
block: Arc<Block>,
44-
) -> Result<(), NonEmpty<Self::Error>>
45-
where
46-
DB: Blockstore + Sync + Send + 'static;
47-
}
486

497
/// Helper function to collect errors from async validations.
508
pub async fn collect_errs<E>(
@@ -63,93 +21,3 @@ pub async fn collect_errs<E>(
6321
Err(_) => Ok(()),
6422
}
6523
}
66-
67-
/// The `Proposer` trait expresses the ability to "mine", or in more general,
68-
/// to propose blocks to the network according to the rules of the consensus
69-
/// protocol.
70-
///
71-
/// It is separate from the `Consensus` trait because it is only expected to
72-
/// be called once, then left to run in the background and try to publish
73-
/// blocks to the network which may or may not be adopted.
74-
///
75-
/// It exists mostly as a way for us to describe what kind of dependencies
76-
/// mining processes are expected to take.
77-
#[async_trait]
78-
pub trait Proposer {
79-
/// Start proposing blocks in the background and never return, unless
80-
/// something went horribly wrong. Broadly, they should select messages
81-
/// from the `mempool`, come up with a total ordering for them, then create
82-
/// blocks and publish them to the network.
83-
///
84-
/// To establish total ordering, the proposer might have to communicate
85-
/// with other peers using custom P2P messages, however that is its own
86-
/// concern, the dependencies to implement a suitable network later must
87-
/// come from somewhere else, because they are not common across all
88-
/// consensus variants.
89-
///
90-
/// The method returns a vector of handles so that it can start unspecified
91-
/// number of background tasks, which can all be canceled by the main thread
92-
/// if the application needs to exit. The method is async so that it can
93-
/// use async operations to initialize itself, during which it might
94-
/// encounter some errors.
95-
async fn spawn<DB, MP>(
96-
self,
97-
// NOTE: We will need access to the `ChainStore` as well, or, ideally
98-
// a wrapper over it that only allows us to do what we need to, but
99-
// for example not reset the Genesis. But since the `StateManager`
100-
// already exposes the `ChainStore` as is, and this is how it's
101-
// accessed during validation for example, I think we can defer
102-
// these for later refactoring and just use the same pattern.
103-
state_manager: Arc<StateManager<DB>>,
104-
mpool: Arc<MP>,
105-
services: &mut JoinSet<anyhow::Result<()>>,
106-
) -> anyhow::Result<()>
107-
where
108-
DB: Blockstore + Sync + Send + 'static,
109-
MP: MessagePoolApi + Sync + Send + 'static;
110-
}
111-
112-
/// The `MessagePoolApi` is the window of consensus to the contents of the
113-
/// `MessagePool`.
114-
///
115-
/// It exists to narrow down the possible operations that a consensus engine can
116-
/// do with the `MessagePool` to only those that it should reasonably exercise,
117-
/// which are mostly read-only queries to get transactions which can be expected
118-
/// to be put in the next block, based on their account nonce values and the
119-
/// current state.
120-
///
121-
/// The `MessagePool` is still expected to monitor the chain growth and remove
122-
/// messages which were included in blocks on its own.
123-
pub trait MessagePoolApi {
124-
/// Select the set of suitable signed messages based on a tipset we are
125-
/// about to build the next block on.
126-
///
127-
/// The result is a `Cow` in case the source can avoid cloning messages and
128-
/// just return a reference. They will be sent to the data store for
129-
/// storage, but a reference is enough for that.
130-
fn select_signed<DB>(
131-
&self,
132-
state_manager: &StateManager<DB>,
133-
base: &Tipset,
134-
) -> anyhow::Result<Vec<Cow<SignedMessage>>>
135-
where
136-
DB: Blockstore;
137-
}
138-
139-
impl<P> MessagePoolApi for MessagePool<P>
140-
where
141-
P: crate::message_pool::Provider + Send + Sync + 'static,
142-
{
143-
fn select_signed<DB>(
144-
&self,
145-
_: &StateManager<DB>,
146-
base: &Tipset,
147-
) -> anyhow::Result<Vec<Cow<SignedMessage>>>
148-
where
149-
DB: Blockstore,
150-
{
151-
self.select_messages_for_block(base)
152-
.map_err(|e| e.into())
153-
.map(|v| v.into_iter().map(Cow::Owned).collect())
154-
}
155-
}

src/cli/humantoken.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ mod parse {
219219
}
220220

221221
/// Take a float from the front of `input`
222-
fn bigdecimal<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, BigDecimal, E>
222+
fn bigdecimal<'a, E>(input: &'a str) -> IResult<&str, BigDecimal, E>
223223
where
224-
E: FromExternalError<&'a str, ParseBigDecimalError>,
224+
E: ParseError<&'a str> + FromExternalError<&'a str, ParseBigDecimalError>,
225225
{
226226
map_res(recognize_float, str::parse)(input)
227227
}

src/cli/subcommands/mpool_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn compute_stats(
134134
let actor_sequence = *actor_sequences.get(&address).expect("get must succeed");
135135

136136
let mut curr_sequence = actor_sequence;
137-
while bucket.get(&curr_sequence).is_some() {
137+
while bucket.contains_key(&curr_sequence) {
138138
curr_sequence += 1;
139139
}
140140

src/cli_shared/cli/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl CliOpts {
194194
}
195195

196196
if let Some(addresses) = &self.p2p_listen_address {
197-
cfg.network.listening_multiaddrs = addresses.clone();
197+
cfg.network.listening_multiaddrs.clone_from(addresses);
198198
}
199199

200200
if self.import_snapshot.is_some() && self.import_chain.is_some() {

src/db/car/forest.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ pub const DEFAULT_FOREST_CAR_FRAME_SIZE: usize = 8000_usize.next_power_of_two();
8383
pub const DEFAULT_FOREST_CAR_COMPRESSION_LEVEL: u16 = zstd::DEFAULT_COMPRESSION_LEVEL as _;
8484
const ZSTD_SKIP_FRAME_LEN: u64 = 8;
8585

86-
pub trait ReaderGen<V>: Fn() -> io::Result<V> + Send + Sync + 'static {}
87-
impl<ReaderT, X: Fn() -> io::Result<ReaderT> + Send + Sync + 'static> ReaderGen<ReaderT> for X {}
88-
8986
pub struct ForestCar<ReaderT> {
9087
// Multiple `ForestCar` structures may share the same cache. The cache key is used to identify
9188
// the origin of a cached z-frame.

src/ipld/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
pub mod selector;
55
pub mod util;
66

7-
pub use libipld::Path;
87
pub use libipld_core::ipld::Ipld;
98
pub use util::*;
109

src/ipld/selector/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0, MIT
33

44
mod empty_map;
5-
mod walk;
65
use std::ops::SubAssign;
76

87
use indexmap::IndexMap;

src/ipld/selector/walk.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/message_pool/msgpool/msg_pool.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ use crate::message_pool::{
4040
errors::Error,
4141
head_change, metrics,
4242
msgpool::{
43-
recover_sig, republish_pending_messages, select_messages_for_block,
44-
BASE_FEE_LOWER_BOUND_FACTOR_CONSERVATIVE, RBF_DENOM, RBF_NUM,
43+
recover_sig, republish_pending_messages, BASE_FEE_LOWER_BOUND_FACTOR_CONSERVATIVE,
44+
RBF_DENOM, RBF_NUM,
4545
},
4646
provider::Provider,
4747
utils::get_base_fee_lower_bound,
@@ -139,7 +139,7 @@ impl MsgSet {
139139
if self.msgs.remove(&sequence).is_none() {
140140
if applied && sequence >= self.next_sequence {
141141
self.next_sequence = sequence + 1;
142-
while self.msgs.get(&self.next_sequence).is_some() {
142+
while self.msgs.contains_key(&self.next_sequence) {
143143
self.next_sequence += 1;
144144
}
145145
}
@@ -442,27 +442,6 @@ where
442442
self.config = cfg;
443443
Ok(())
444444
}
445-
446-
/// Select messages that can be included in a block built on a given base
447-
/// tipset.
448-
pub fn select_messages_for_block(&self, base: &Tipset) -> Result<Vec<SignedMessage>, Error> {
449-
// Take a snapshot of the pending messages.
450-
let pending: HashMap<Address, HashMap<u64, SignedMessage>> = {
451-
let pending = self.pending.read();
452-
pending
453-
.iter()
454-
.filter_map(|(actor, mset)| {
455-
if mset.msgs.is_empty() {
456-
None
457-
} else {
458-
Some((*actor, mset.msgs.clone()))
459-
}
460-
})
461-
.collect()
462-
};
463-
464-
select_messages_for_block(self.api.as_ref(), self.chain_config.as_ref(), base, pending)
465-
}
466445
}
467446

468447
impl<T> MessagePool<T>

src/message_pool/msgpool/provider.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ pub trait Provider {
4646
&self,
4747
h: &CachingBlockHeader,
4848
) -> Result<(Vec<Message>, Vec<SignedMessage>), Error>;
49-
/// Return all messages for a tipset
50-
fn messages_for_tipset(&self, h: &Tipset) -> Result<Vec<ChainMessage>, Error>;
5149
/// Return a tipset given the tipset keys from the `ChainStore`
5250
fn load_tipset(&self, tsk: &TipsetKey) -> Result<Arc<Tipset>, Error>;
5351
/// Computes the base fee
@@ -117,10 +115,6 @@ where
117115
crate::chain::block_messages(self.sm.blockstore(), h).map_err(|err| err.into())
118116
}
119117

120-
fn messages_for_tipset(&self, h: &Tipset) -> Result<Vec<ChainMessage>, Error> {
121-
Ok(self.sm.chain_store().messages_for_tipset(h)?)
122-
}
123-
124118
fn load_tipset(&self, tsk: &TipsetKey) -> Result<Arc<Tipset>, Error> {
125119
Ok(self
126120
.sm

src/message_pool/msgpool/test_provider.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,6 @@ impl Provider for TestApi {
188188
}
189189
}
190190

191-
fn messages_for_tipset(&self, h: &Tipset) -> Result<Vec<ChainMessage>, Error> {
192-
let (us, s) = self.messages_for_block(h.block_headers().first())?;
193-
let mut msgs = Vec::with_capacity(us.len() + s.len());
194-
195-
for msg in us {
196-
msgs.push(ChainMessage::Unsigned(msg));
197-
}
198-
for smsg in s {
199-
msgs.push(ChainMessage::Signed(smsg));
200-
}
201-
Ok(msgs)
202-
}
203-
204191
fn load_tipset(&self, tsk: &TipsetKey) -> Result<Arc<Tipset>, Error> {
205192
let inner = self.inner.lock();
206193
for ts in &inner.tipsets {

0 commit comments

Comments
 (0)