Skip to content

Commit

Permalink
chore: upgrade rust-toolchain (#5023)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Dec 2, 2024
1 parent d08dacf commit 98d181e
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 213 deletions.
295 changes: 153 additions & 142 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.82.0"
channel = "1.83.0"
components = ["clippy", "llvm-tools-preview", "rustfmt"]
4 changes: 2 additions & 2 deletions src/chain/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ where
let (publisher, _) = broadcast::channel(SINK_CAP);
let chain_index = Arc::new(ChainIndex::new(Arc::clone(&db)));

if !settings
if settings
.read_obj::<TipsetKey>(HEAD_KEY)?
.is_some_and(|tipset_keys| chain_index.load_tipset(&tipset_keys).is_ok())
.is_none_or(|tipset_keys| chain_index.load_tipset(&tipset_keys).is_err())
{
let tipset_keys = TipsetKey::from(nonempty![*genesis_block_header.cid()]);
settings.write_obj(HEAD_KEY, &tipset_keys)?;
Expand Down
2 changes: 1 addition & 1 deletion src/chain_sync/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl From<IpldAmtError> for TipsetValidationError {

pub struct TipsetValidator<'a>(pub &'a FullTipset);

impl<'a> TipsetValidator<'a> {
impl TipsetValidator<'_> {
pub fn validate<DB: Blockstore>(
&self,
chainstore: &ChainStore<DB>,
Expand Down
4 changes: 2 additions & 2 deletions src/cid_collections/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub struct OccupiedEntry<'a, V> {
inner: OccupiedEntryInner<'a, V>,
}

impl<'a, V> OccupiedEntry<'a, V> {
impl<V> OccupiedEntry<'_, V> {
/// Gets a reference to the value in the entry.
///
/// See also [`std::collections::hash_map::OccupiedEntry::get`].
Expand Down Expand Up @@ -316,7 +316,7 @@ pub struct Keys<'a, V> {
}

#[cfg(test)]
impl<'a, V> Iterator for Keys<'a, V> {
impl<V> Iterator for Keys<'_, V> {
type Item = Cid;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/humantoken.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mod parse {
}

/// Take an [si::Prefix] from the front of `input`
fn si_scale<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&str, si::Prefix, E> {
fn si_scale<'a, E: ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, si::Prefix, E> {
// Try the longest matches first, so we don't e.g match `a` instead of `atto`,
// leaving `tto`.

Expand All @@ -219,7 +219,7 @@ mod parse {
}

/// Take a float from the front of `input`
fn bigdecimal<'a, E>(input: &'a str) -> IResult<&str, BigDecimal, E>
fn bigdecimal<'a, E>(input: &'a str) -> IResult<&'a str, BigDecimal, E>
where
E: ParseError<&'a str> + FromExternalError<&'a str, ParseBigDecimalError>,
{
Expand Down
109 changes: 57 additions & 52 deletions src/cli_shared/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,63 @@ mod parse {
Ok(t)
}

#[test]
fn test_serialization() {
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_serialization() {
for (text, value) in [
(
"forest_snapshot_mainnet_2023-05-30_height_2905376.car.zst",
ParsedFilename::full("forest", "mainnet", 2023, 5, 30, 2905376, false),
),
(
"forest_snapshot_calibnet_2023-05-30_height_604419.car.zst",
ParsedFilename::full("forest", "calibnet", 2023, 5, 30, 604419, false),
),
(
"forest_snapshot_mainnet_2023-05-30_height_2905376.forest.car.zst",
ParsedFilename::full("forest", "mainnet", 2023, 5, 30, 2905376, true),
),
(
"forest_snapshot_calibnet_2023-05-30_height_604419.forest.car.zst",
ParsedFilename::full("forest", "calibnet", 2023, 5, 30, 604419, true),
),
(
"2905920_2023_05_30T22_00_00Z.car.zst",
ParsedFilename::short(2905920, 2023, 5, 30, 22, 0, 0),
),
(
"605520_2023_05_31T00_13_00Z.car.zst",
ParsedFilename::short(605520, 2023, 5, 31, 0, 13, 0),
),
(
"filecoin_snapshot_calibnet_2023-06-13_height_643680.car.zst",
ParsedFilename::full("filecoin", "calibnet", 2023, 6, 13, 643680, false),
),
(
"venus_snapshot_pineconenet_2045-01-01_height_2.car.zst",
ParsedFilename::full("venus", "pineconenet", 2045, 1, 1, 2, false),
),
(
"filecoin_snapshot_calibnet_2023-06-13_height_643680.forest.car.zst",
ParsedFilename::full("filecoin", "calibnet", 2023, 6, 13, 643680, true),
),
(
"venus_snapshot_pineconenet_2045-01-01_height_2.forest.car.zst",
ParsedFilename::full("venus", "pineconenet", 2045, 1, 1, 2, true),
),
] {
assert_eq!(
value,
ParsedFilename::parse_str(text).unwrap(),
"mismatch in deserialize"
);
assert_eq!(value.to_string(), text, "mismatch in serialize");
}
}

impl ParsedFilename<'static> {
/// # Panics
/// - If `ymd`/`hms` aren't valid
Expand Down Expand Up @@ -404,56 +459,6 @@ mod parse {
}
}
}

for (text, value) in [
(
"forest_snapshot_mainnet_2023-05-30_height_2905376.car.zst",
ParsedFilename::full("forest", "mainnet", 2023, 5, 30, 2905376, false),
),
(
"forest_snapshot_calibnet_2023-05-30_height_604419.car.zst",
ParsedFilename::full("forest", "calibnet", 2023, 5, 30, 604419, false),
),
(
"forest_snapshot_mainnet_2023-05-30_height_2905376.forest.car.zst",
ParsedFilename::full("forest", "mainnet", 2023, 5, 30, 2905376, true),
),
(
"forest_snapshot_calibnet_2023-05-30_height_604419.forest.car.zst",
ParsedFilename::full("forest", "calibnet", 2023, 5, 30, 604419, true),
),
(
"2905920_2023_05_30T22_00_00Z.car.zst",
ParsedFilename::short(2905920, 2023, 5, 30, 22, 0, 0),
),
(
"605520_2023_05_31T00_13_00Z.car.zst",
ParsedFilename::short(605520, 2023, 5, 31, 0, 13, 0),
),
(
"filecoin_snapshot_calibnet_2023-06-13_height_643680.car.zst",
ParsedFilename::full("filecoin", "calibnet", 2023, 6, 13, 643680, false),
),
(
"venus_snapshot_pineconenet_2045-01-01_height_2.car.zst",
ParsedFilename::full("venus", "pineconenet", 2045, 1, 1, 2, false),
),
(
"filecoin_snapshot_calibnet_2023-06-13_height_643680.forest.car.zst",
ParsedFilename::full("filecoin", "calibnet", 2023, 6, 13, 643680, true),
),
(
"venus_snapshot_pineconenet_2045-01-01_height_2.forest.car.zst",
ParsedFilename::full("venus", "pineconenet", 2045, 1, 1, 2, true),
),
] {
assert_eq!(
value,
ParsedFilename::parse_str(text).unwrap(),
"mismatch in deserialize"
);
assert_eq!(value.to_string(), text, "mismatch in serialize");
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/fil_cns/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@ fn to_fil_public_replica_infos(

/// Functionality for verification of seal, winning PoSt and window PoSt proofs.
/// Proof verification will be full validation by default.

///
/// Verifies winning proof of spacetime. These proofs are generated by the
/// miners that are elected to mine a new block to verify a sector. A failed
/// winning proof leads to a miner being slashed.

///
/// PoSt proof variants.
enum ProofType {
Winning,
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct HistogramTimer<'a> {
start: Instant,
}

impl<'a> Drop for HistogramTimer<'a> {
impl Drop for HistogramTimer<'_> {
fn drop(&mut self) {
let duration = Instant::now() - self.start;
self.histogram.observe(duration.as_secs_f64());
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ fn encode_filecoin_returns_as_abi(

/// Round to the next multiple of `EVM` word length.
fn round_up_word(value: usize) -> usize {
((value + (EVM_WORD_LENGTH - 1)) / EVM_WORD_LENGTH) * EVM_WORD_LENGTH
value.div_ceil(EVM_WORD_LENGTH) * EVM_WORD_LENGTH
}

/// Format two numbers followed by an arbitrary byte array as solidity ABI.
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/reflect/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> Parser<'a> {
names: &'a [&'a str],
calling_convention: ParamStructure,
n_required: usize,
) -> Result<Self, ParseError> {
) -> Result<Self, ParseError<'a>> {
let params = match (params, calling_convention) {
// ignore the calling convention if there are no arguments to parse
(None, _) => None,
Expand Down
2 changes: 1 addition & 1 deletion src/shim/actors/market/balance_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::*;
use fil_actor_interface::market::BalanceTable;
use fvm_ipld_blockstore::Blockstore;

impl<'bs, BS: Blockstore> BalanceTableExt for BalanceTable<'bs, BS> {
impl<BS: Blockstore> BalanceTableExt for BalanceTable<'_, BS> {
fn for_each<F>(&self, mut f: F) -> anyhow::Result<()>
where
F: FnMut(&Address, &TokenAmount) -> anyhow::Result<()>,
Expand Down
2 changes: 1 addition & 1 deletion src/shim/actors/miner/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use super::*;
use fil_actor_interface::miner::Partition;

impl<'a> PartitionExt for Partition<'a> {
impl PartitionExt for Partition<'_> {
fn terminated(&self) -> &BitField {
match self {
Partition::V8(dl) => &dl.terminated,
Expand Down
4 changes: 2 additions & 2 deletions src/state_manager/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn is_valid_for_sending(network_version: NetworkVersion, actor: &ActorState)

// Only allow such actors to send if their delegated address is in the EAM's
// namespace.
return if let Payload::Delegated(address) = actor
if let Payload::Delegated(address) = actor
.delegated_address
.as_ref()
.expect("unfallible")
Expand All @@ -155,7 +155,7 @@ pub fn is_valid_for_sending(network_version: NetworkVersion, actor: &ActorState)
address.namespace() == Address::ETHEREUM_ACCOUNT_MANAGER_ACTOR.id().unwrap()
} else {
false
};
}
}

/// Generates sector challenge indexes for use in winning PoSt verification.
Expand Down
4 changes: 2 additions & 2 deletions src/utils/encoding/cid_de_cbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct CidVec(Vec<Cid>);
/// This is much faster than constructing an [`ipld_core::ipld::Ipld`] tree and then performing the filtering.
struct FilterCids<'a>(&'a mut Vec<Cid>);

impl<'de, 'a> DeserializeSeed<'de> for FilterCids<'a> {
impl<'de> DeserializeSeed<'de> for FilterCids<'_> {
type Value = ();

fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
Expand All @@ -32,7 +32,7 @@ impl<'de, 'a> DeserializeSeed<'de> for FilterCids<'a> {
{
struct FilterCidsVisitor<'a>(&'a mut Vec<Cid>);

impl<'de, 'a> Visitor<'de> for FilterCidsVisitor<'a> {
impl<'de> Visitor<'de> for FilterCidsVisitor<'_> {
type Value = ();

fn expecting(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit 98d181e

Please sign in to comment.