Update to Rust 1.59 and 2021 edition (#3038)

## Proposed Changes

Lots of lint updates related to `flat_map`, `unwrap_or_else` and string patterns. I did a little more creative refactoring in the op pool, but otherwise followed Clippy's suggestions.

## Additional Info

We need this PR to unblock CI.
This commit is contained in:
Michael Sproul 2022-02-25 00:10:17 +00:00
parent c1df5d29cb
commit 5e1f8a8480
115 changed files with 173 additions and 188 deletions

View File

@ -2,7 +2,7 @@
name = "account_manager"
version = "0.3.5"
authors = ["Paul Hauner <paul@paulhauner.com>", "Luke Anderson <luke@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
bls = { path = "../crypto/bls" }

View File

@ -2,7 +2,7 @@
name = "beacon_node"
version = "2.1.3"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com"]
edition = "2018"
edition = "2021"
[lib]
name = "beacon_node"

View File

@ -2,7 +2,7 @@
name = "beacon_chain"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com>"]
edition = "2018"
edition = "2021"
autotests = false # using a single test binary compiles faster
[features]

View File

@ -2289,7 +2289,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.position(|(_root, block)| {
block.slot().epoch(T::EthSpec::slots_per_epoch()) > start_epoch
})
.unwrap_or_else(|| filtered_chain_segment.len());
.unwrap_or(filtered_chain_segment.len());
// Split off the first section blocks that are all either within the current epoch of
// the first block. These blocks can all be signature-verified with the same

View File

@ -421,10 +421,7 @@ impl<T: AggregateMap> NaiveAggregationPool<T> {
/// Iterate all items in all slots of `self`.
pub fn iter(&self) -> impl Iterator<Item = &T::Value> {
self.maps
.iter()
.map(|(_slot, map)| map.get_map().iter().map(|(_key, value)| value))
.flatten()
self.maps.values().flat_map(|map| map.get_map().values())
}
/// Removes any items with a slot lower than `current_slot` and bars any future

View File

@ -635,7 +635,7 @@ pub fn verify_sync_committee_message<T: BeaconChainTypes>(
let pubkey = pubkey_cache
.get_pubkey_from_pubkey_bytes(pubkey_bytes)
.map(Cow::Borrowed)
.ok_or_else(|| Error::UnknownValidatorPubkey(*pubkey_bytes))?;
.ok_or(Error::UnknownValidatorPubkey(*pubkey_bytes))?;
let next_slot_epoch = (sync_message.get_slot() + 1).epoch(T::EthSpec::slots_per_epoch());
let fork = chain.spec.fork_at_epoch(next_slot_epoch);

View File

@ -198,14 +198,11 @@ impl MonitoredValidator {
/// as the value recorded by the validator monitor ignores skip slots.
fn min_inclusion_distance(&self, epoch: &Epoch) -> Option<u64> {
let summaries = self.summaries.read();
summaries
.get(epoch)
.map(|summary| {
summary
.attestation_min_block_inclusion_distance
.map(Into::into)
})
.flatten()
summaries.get(epoch).and_then(|summary| {
summary
.attestation_min_block_inclusion_distance
.map(Into::into)
})
}
/// Maps `func` across the `self.summaries`.

View File

@ -175,9 +175,7 @@ impl<T: BeaconChainTypes> ValidatorPubkeyCache<T> {
/// Get the `PublicKey` for a validator with `PublicKeyBytes`.
pub fn get_pubkey_from_pubkey_bytes(&self, pubkey: &PublicKeyBytes) -> Option<&PublicKey> {
self.get_index(pubkey)
.map(|index| self.get(index))
.flatten()
self.get_index(pubkey).and_then(|index| self.get(index))
}
/// Get the public key (in bytes form) for a validator with index `i`.

View File

@ -179,7 +179,7 @@ fn aggregated_gossip_verification() {
get_valid_sync_contribution(&harness, RelativeSyncCommittee::Current);
macro_rules! assert_invalid {
($desc: tt, $attn_getter: expr, $($error: pat) |+ $( if $guard: expr )?) => {
($desc: tt, $attn_getter: expr, $($error: pat_param) |+ $( if $guard: expr )?) => {
assert!(
matches!(
harness
@ -505,7 +505,7 @@ fn unaggregated_gossip_verification() {
get_valid_sync_committee_message(&harness, current_slot, RelativeSyncCommittee::Current);
macro_rules! assert_invalid {
($desc: tt, $attn_getter: expr, $subnet_getter: expr, $($error: pat) |+ $( if $guard: expr )?) => {
($desc: tt, $attn_getter: expr, $subnet_getter: expr, $($error: pat_param) |+ $( if $guard: expr )?) => {
assert!(
matches!(
harness

View File

@ -2,7 +2,7 @@
name = "client"
version = "0.2.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
toml = "0.5.6"

View File

@ -2,7 +2,7 @@
name = "eth1"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
eth1_test_rig = { path = "../../testing/eth1_test_rig" }

View File

@ -449,7 +449,7 @@ fn response_result_or_error(response: &str) -> Result<Value, RpcError> {
let json = serde_json::from_str::<Value>(response)
.map_err(|e| RpcError::InvalidJson(e.to_string()))?;
if let Some(error) = json.get("error").map(|e| e.get("message")).flatten() {
if let Some(error) = json.get("error").and_then(|e| e.get("message")) {
let error = error.to_string();
if error.contains(EIP155_ERROR_STR) {
Err(RpcError::Eip155Error)

View File

@ -1,7 +1,7 @@
[package]
name = "execution_layer"
version = "0.1.0"
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "genesis"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
eth1_test_rig = { path = "../../testing/eth1_test_rig" }

View File

@ -2,7 +2,7 @@
name = "http_api"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
autotests = false # using a single test binary compiles faster
[dependencies]

View File

@ -2,7 +2,7 @@
name = "http_metrics"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "lighthouse_network"
version = "0.2.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
discv5 = { version = "0.1.0-beta.13", features = ["libp2p"] }

View File

@ -458,7 +458,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
GossipKind::Attestation(subnet_id) => {
if let Some(v) = metrics::get_int_gauge(
&metrics::FAILED_ATTESTATION_PUBLISHES_PER_SUBNET,
&[&subnet_id.to_string()],
&[subnet_id.as_ref()],
) {
v.inc()
};

View File

@ -2,7 +2,7 @@
name = "network"
version = "0.2.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
sloggers = { version = "2.1.1", features = ["json"] }

View File

@ -2,7 +2,7 @@
name = "operation_pool"
version = "0.2.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
derivative = "2.1.1"

View File

@ -560,9 +560,8 @@ impl<T: EthSpec> OperationPool<T> {
pub fn get_all_attestations(&self) -> Vec<Attestation<T>> {
self.attestations
.read()
.iter()
.map(|(_, attns)| attns.iter().cloned())
.flatten()
.values()
.flat_map(|attns| attns.iter().cloned())
.collect()
}
@ -575,10 +574,10 @@ impl<T: EthSpec> OperationPool<T> {
{
self.attestations
.read()
.iter()
.map(|(_, attns)| attns.iter().cloned())
.flatten()
.filter(filter)
.values()
.flat_map(|attns| attns.iter())
.filter(|attn| filter(*attn))
.cloned()
.collect()
}

View File

@ -97,20 +97,19 @@ impl<T: EthSpec> PersistedOperationPool<T> {
/// Reconstruct an `OperationPool`. Sets `sync_contributions` to its `Default` if `self` matches
/// `PersistedOperationPool::Base`.
pub fn into_operation_pool(self) -> Result<OperationPool<T>, OpPoolError> {
let attestations = RwLock::new(self.attestations().to_vec().into_iter().collect());
let attester_slashings =
RwLock::new(self.attester_slashings().to_vec().into_iter().collect());
let attestations = RwLock::new(self.attestations().iter().cloned().collect());
let attester_slashings = RwLock::new(self.attester_slashings().iter().cloned().collect());
let proposer_slashings = RwLock::new(
self.proposer_slashings()
.to_vec()
.into_iter()
.iter()
.cloned()
.map(|slashing| (slashing.signed_header_1.message.proposer_index, slashing))
.collect(),
);
let voluntary_exits = RwLock::new(
self.voluntary_exits()
.to_vec()
.into_iter()
.iter()
.cloned()
.map(|exit| (exit.message.validator_index, exit))
.collect(),
);
@ -125,7 +124,7 @@ impl<T: EthSpec> PersistedOperationPool<T> {
},
PersistedOperationPool::Altair(_) => {
let sync_contributions =
RwLock::new(self.sync_contributions()?.to_vec().into_iter().collect());
RwLock::new(self.sync_contributions()?.iter().cloned().collect());
OperationPool {
attestations,

View File

@ -705,13 +705,15 @@ pub fn set_network_config(
// Appending enr-port to the dns hostname to appease `to_socket_addrs()` parsing.
// Since enr-update is disabled with a dns address, not setting the enr-udp-port
// will make the node undiscoverable.
if let Some(enr_udp_port) = config.enr_udp_port.or_else(|| {
if use_listening_port_as_enr_port_by_default {
Some(config.discovery_port)
} else {
None
}
}) {
if let Some(enr_udp_port) =
config
.enr_udp_port
.or(if use_listening_port_as_enr_port_by_default {
Some(config.discovery_port)
} else {
None
})
{
addr.push_str(&format!(":{}", enr_udp_port));
} else {
return Err(

View File

@ -2,7 +2,7 @@
name = "store"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -762,7 +762,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
let partial_state_bytes = self
.cold_db
.get_bytes(DBColumn::BeaconState.into(), state_root.as_bytes())?
.ok_or_else(|| HotColdDBError::MissingRestorePoint(*state_root))?;
.ok_or(HotColdDBError::MissingRestorePoint(*state_root))?;
let mut partial_state: PartialBeaconState<E> =
PartialBeaconState::from_ssz_bytes(&partial_state_bytes, &self.spec)?;

View File

@ -2,7 +2,7 @@
name = "timer"
version = "0.2.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
beacon_chain = { path = "../beacon_chain" }

View File

@ -2,7 +2,7 @@
name = "boot_node"
version = "2.1.3"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
beacon_node = { path = "../beacon_node" }

View File

@ -2,7 +2,7 @@
name = "account_utils"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "clap_utils"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -31,7 +31,7 @@ pub fn get_eth2_network_config(cli_args: &ArgMatches) -> Result<Eth2NetworkConfi
if let Some(string) = parse_optional::<String>(cli_args, "terminal-total-difficulty-override")?
{
let stripped = string.replace(",", "");
let stripped = string.replace(',', "");
let terminal_total_difficulty = Uint256::from_dec_str(&stripped).map_err(|e| {
format!(
"Could not parse --terminal-total-difficulty-override as decimal value: {:?}",

View File

@ -2,7 +2,7 @@
name = "compare_fields"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
compare_fields_derive = { path = "../compare_fields_derive" }

View File

@ -2,7 +2,7 @@
name = "compare_fields_derive"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[lib]
proc-macro = true

View File

@ -8,7 +8,7 @@ use syn::{parse_macro_input, DeriveInput};
fn is_slice(field: &syn::Field) -> bool {
field.attrs.iter().any(|attr| {
attr.path.is_ident("compare_fields")
&& attr.tokens.to_string().replace(" ", "") == "(as_slice)"
&& attr.tokens.to_string().replace(' ', "") == "(as_slice)"
})
}

View File

@ -2,7 +2,7 @@
name = "deposit_contract"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
build = "build.rs"

View File

@ -2,7 +2,7 @@
name = "directory"
version = "0.1.0"
authors = ["pawan <pawandhananjay@gmail.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "eth2"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "eth2_config"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dependencies]
types = { path = "../../consensus/types" }

View File

@ -2,7 +2,7 @@
name = "eth2_interop_keypairs"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "eth2_network_config"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
build = "build.rs"

View File

@ -2,7 +2,7 @@
name = "eth2_wallet_manager"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "fallback"
version = "0.1.0"
authors = ["blacktemplar <blacktemplar@a1.net>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "filesystem"
version = "0.1.0"
authors = ["Mark Mackey <mark@sigmaprime.io>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "hashset_delay"
version = "0.2.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
futures = "0.3.7"

View File

@ -2,7 +2,7 @@
name = "lighthouse_metrics"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "lighthouse_version"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "lockfile"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
fs2 = "0.4.3"

View File

@ -2,7 +2,7 @@
name = "logging"
version = "0.2.0"
authors = ["blacktemplar <blacktemplar@a1.net>"]
edition = "2018"
edition = "2021"
[features]
test_logger = [] # Print log output to stderr when running tests instead of dropping it

View File

@ -3,13 +3,11 @@ use std::process::Command;
use std::process::Output;
fn run_cmd(cmd_line: &str) -> Result<Output, std::io::Error> {
let output;
if cfg!(target_os = "windows") {
output = Command::new(r#"cmd"#).args(["/C", cmd_line]).output();
Command::new(r#"cmd"#).args(["/C", cmd_line]).output()
} else {
output = Command::new(r#"sh"#).args(["-c", cmd_line]).output();
Command::new(r#"sh"#).args(["-c", cmd_line]).output()
}
output
}
#[test]

View File

@ -2,7 +2,7 @@
name = "lru_cache"
version = "0.1.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
fnv = "1.0.7"

View File

@ -2,7 +2,7 @@
name = "malloc_utils"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "monitoring_api"
version = "0.1.0"
authors = ["pawan <pawandhananjay@gmail.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "sensitive_url"
version = "0.1.0"
authors = ["Mac L <mjladson@pm.me>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "slot_clock"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dependencies]
types = { path = "../../consensus/types" }

View File

@ -2,7 +2,7 @@
name = "target_check"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
static_assertions = "1.1.0"

View File

@ -2,7 +2,7 @@
name = "task_executor"
version = "0.1.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
tokio = { version = "1.14.0", features = ["rt"] }

View File

@ -2,7 +2,7 @@
name = "test_random_derive"
version = "0.2.0"
authors = ["thojest <thojest@gmail.com>"]
edition = "2018"
edition = "2021"
description = "Procedural derive macros for implementation of TestRandom trait"
[lib]

View File

@ -10,7 +10,7 @@ use syn::{parse_macro_input, DeriveInput};
/// The field attribute is: `#[test_random(default)]`
fn should_use_default(field: &syn::Field) -> bool {
field.attrs.iter().any(|attr| {
attr.path.is_ident("test_random") && attr.tokens.to_string().replace(" ", "") == "(default)"
attr.path.is_ident("test_random") && attr.tokens.to_string().replace(' ', "") == "(default)"
})
}

View File

@ -2,7 +2,7 @@
name = "validator_dir"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[features]
insecure_keys = []

View File

@ -2,7 +2,7 @@
name = "warp_utils"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "cached_tree_hash"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
ethereum-types = "0.12.1"

View File

@ -127,7 +127,7 @@ impl<T: Encode + Decode> CacheArena<T> {
.offsets
.get(alloc_id + 1)
.copied()
.unwrap_or_else(|| self.backing.len());
.unwrap_or(self.backing.len());
Ok(end - start)
}
@ -168,7 +168,7 @@ impl<T: Encode + Decode> CacheArena<T> {
.offsets
.get(alloc_id + 1)
.copied()
.unwrap_or_else(|| self.backing.len());
.unwrap_or(self.backing.len());
Ok(start..end)
}

View File

@ -2,7 +2,7 @@
name = "fork_choice"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -219,7 +219,7 @@ fn dequeue_attestations(
queued_attestations
.iter()
.position(|a| a.slot >= current_slot)
.unwrap_or_else(|| queued_attestations.len()),
.unwrap_or(queued_attestations.len()),
);
std::mem::replace(queued_attestations, remaining)

View File

@ -613,7 +613,7 @@ fn justified_balances() {
}
macro_rules! assert_invalid_block {
($err: tt, $($error: pat) |+ $( if $guard: expr )?) => {
($err: tt, $($error: pat_param) |+ $( if $guard: expr )?) => {
assert!(
matches!(
$err,
@ -719,7 +719,7 @@ fn invalid_block_finalized_descendant() {
}
macro_rules! assert_invalid_attestation {
($err: tt, $($error: pat) |+ $( if $guard: expr )?) => {
($err: tt, $($error: pat_param) |+ $( if $guard: expr )?) => {
assert!(
matches!(
$err,

View File

@ -2,7 +2,7 @@
name = "int_to_bytes"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dependencies]
bytes = "1.0.1"

View File

@ -2,7 +2,7 @@
name = "merkle_proof"
version = "0.2.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
ethereum-types = "0.12.1"

View File

@ -2,7 +2,7 @@
name = "proto_array"
version = "0.2.0"
authors = ["Paul Hauner <paul@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[[bin]]
name = "proto_array"

View File

@ -313,7 +313,7 @@ impl ProtoArray {
.indices
.get(justified_root)
.copied()
.ok_or_else(|| Error::JustifiedNodeUnknown(*justified_root))?;
.ok_or(Error::JustifiedNodeUnknown(*justified_root))?;
let justified_node = self
.nodes

View File

@ -2,7 +2,7 @@
name = "safe_arith"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "eth2_serde_utils"
version = "0.1.1"
authors = ["Paul Hauner <paul@paulhauner.com", "Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
description = "Serialization and deserialization utilities useful for JSON representations of Ethereum 2.0 types."
license = "Apache-2.0"

View File

@ -51,7 +51,7 @@ where
let raw = hex::encode(num.to_be_bytes());
let trimmed = raw.trim_start_matches('0');
let hex = if trimmed.is_empty() { "0" } else { &trimmed };
let hex = if trimmed.is_empty() { "0" } else { trimmed };
serializer.serialize_str(&format!("0x{}", &hex))
}

View File

@ -2,7 +2,7 @@
name = "eth2_ssz"
version = "0.4.1"
authors = ["Paul Hauner <paul@sigmaprime.io>"]
edition = "2018"
edition = "2021"
description = "SimpleSerialize (SSZ) as used in Ethereum 2.0"
license = "Apache-2.0"

View File

@ -187,12 +187,13 @@ impl<'a> SszDecoderBuilder<'a> {
let start = self.items_index;
self.items_index += ssz_fixed_len;
let slice = self.bytes.get(start..self.items_index).ok_or_else(|| {
DecodeError::InvalidByteLength {
len: self.bytes.len(),
expected: self.items_index,
}
})?;
let slice =
self.bytes
.get(start..self.items_index)
.ok_or(DecodeError::InvalidByteLength {
len: self.bytes.len(),
expected: self.items_index,
})?;
self.items.push(slice);
} else {
@ -347,12 +348,12 @@ pub fn split_union_bytes(bytes: &[u8]) -> Result<(UnionSelector, &[u8]), DecodeE
/// Reads a `BYTES_PER_LENGTH_OFFSET`-byte length from `bytes`, where `bytes.len() >=
/// BYTES_PER_LENGTH_OFFSET`.
pub fn read_offset(bytes: &[u8]) -> Result<usize, DecodeError> {
decode_offset(bytes.get(0..BYTES_PER_LENGTH_OFFSET).ok_or_else(|| {
decode_offset(bytes.get(0..BYTES_PER_LENGTH_OFFSET).ok_or(
DecodeError::InvalidLengthPrefix {
len: bytes.len(),
expected: BYTES_PER_LENGTH_OFFSET,
}
})?)
},
)?)
}
/// Decode bytes as a little-endian usize, returning an `Err` if `bytes.len() !=

View File

@ -2,7 +2,7 @@
name = "eth2_ssz_derive"
version = "0.3.0"
authors = ["Paul Hauner <paul@sigmaprime.io>"]
edition = "2018"
edition = "2021"
description = "Procedural derive macros to accompany the eth2_ssz crate."
license = "Apache-2.0"

View File

@ -2,7 +2,7 @@
name = "eth2_ssz_types"
version = "0.2.2"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
description = "Provides types with unique properties required for SSZ serialization and Merklization."
license = "Apache-2.0"

View File

@ -2,7 +2,7 @@
name = "state_processing"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>", "Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dev-dependencies]
env_logger = "0.9.0"

View File

@ -3,7 +3,7 @@
not(test),
deny(
clippy::integer_arithmetic,
clippy::disallowed_method,
clippy::disallowed_methods,
clippy::indexing_slicing,
clippy::unwrap_used,
clippy::expect_used,

View File

@ -177,7 +177,7 @@ where
Ok(SignatureSet::single_pubkey(
block.body().randao_reveal(),
get_pubkey(proposer_index).ok_or_else(|| Error::ValidatorUnknown(proposer_index as u64))?,
get_pubkey(proposer_index).ok_or(Error::ValidatorUnknown(proposer_index as u64))?,
message,
))
}
@ -199,15 +199,13 @@ where
block_header_signature_set(
state,
&proposer_slashing.signed_header_1,
get_pubkey(proposer_index)
.ok_or_else(|| Error::ValidatorUnknown(proposer_index as u64))?,
get_pubkey(proposer_index).ok_or(Error::ValidatorUnknown(proposer_index as u64))?,
spec,
),
block_header_signature_set(
state,
&proposer_slashing.signed_header_2,
get_pubkey(proposer_index)
.ok_or_else(|| Error::ValidatorUnknown(proposer_index as u64))?,
get_pubkey(proposer_index).ok_or(Error::ValidatorUnknown(proposer_index as u64))?,
spec,
),
))
@ -363,7 +361,7 @@ where
Ok(SignatureSet::single_pubkey(
&signed_exit.signature,
get_pubkey(proposer_index).ok_or_else(|| Error::ValidatorUnknown(proposer_index as u64))?,
get_pubkey(proposer_index).ok_or(Error::ValidatorUnknown(proposer_index as u64))?,
message,
))
}
@ -521,7 +519,7 @@ where
{
let mut pubkeys = Vec::with_capacity(T::SyncSubcommitteeSize::to_usize());
for pubkey in pubkey_bytes {
pubkeys.push(get_pubkey(pubkey).ok_or_else(|| Error::ValidatorPubkeyUnknown(*pubkey))?);
pubkeys.push(get_pubkey(pubkey).ok_or(Error::ValidatorPubkeyUnknown(*pubkey))?);
}
let domain = spec.get_domain(epoch, Domain::SyncCommittee, fork, genesis_validators_root);

View File

@ -4,7 +4,6 @@ use crate::per_epoch_processing::{
Delta, Error,
};
use safe_arith::SafeArith;
use std::array::IntoIter as ArrayIter;
use types::{BeaconState, ChainSpec, EthSpec};
/// Combination of several deltas for different components of an attestation reward.
@ -30,13 +29,13 @@ impl AttestationDelta {
inactivity_penalty_delta,
} = self;
let mut result = Delta::default();
for delta in ArrayIter::new([
for delta in [
source_delta,
target_delta,
head_delta,
inclusion_delay_delta,
inactivity_penalty_delta,
]) {
] {
result.combine(delta)?;
}
Ok(result)

View File

@ -2,7 +2,7 @@
name = "swap_or_not_shuffle"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[[bench]]
name = "benches"

View File

@ -2,7 +2,7 @@
name = "tree_hash"
version = "0.4.1"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "Efficient Merkle-hashing as used in Ethereum 2.0"

View File

@ -376,8 +376,8 @@ mod test {
fn compare_with_reference(leaves: &[Hash256], depth: usize) {
let reference_bytes = leaves
.iter()
.map(|hash| hash.as_bytes().to_vec())
.flatten()
.flat_map(|hash| hash.as_bytes())
.copied()
.collect::<Vec<_>>();
let reference_root = merkleize_padded(&reference_bytes, 1 << (depth - 1));

View File

@ -2,7 +2,7 @@
name = "tree_hash_derive"
version = "0.4.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
description = "Procedural derive macros to accompany the tree_hash crate."
license = "Apache-2.0"

View File

@ -109,7 +109,7 @@ fn cached_tree_hash_attr_metas(attrs: &[Attribute]) -> Vec<Meta> {
fn should_skip_hashing(field: &syn::Field) -> bool {
field.attrs.iter().any(|attr| {
attr.path.is_ident("tree_hash")
&& attr.tokens.to_string().replace(" ", "") == "(skip_hashing)"
&& attr.tokens.to_string().replace(' ', "") == "(skip_hashing)"
})
}

View File

@ -2,7 +2,7 @@
name = "types"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com>"]
edition = "2018"
edition = "2021"
[[bench]]
name = "benches"

View File

@ -1,5 +1,5 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::disallowed_method)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::indexing_slicing)]
use super::Error;

View File

@ -7,7 +7,7 @@
not(test),
deny(
clippy::integer_arithmetic,
clippy::disallowed_method,
clippy::disallowed_methods,
clippy::indexing_slicing
)
)]

View File

@ -2,7 +2,7 @@
name = "bls"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dependencies]
eth2_ssz = "0.4.1"

View File

@ -2,7 +2,7 @@
name = "eth2_hashing"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "Hashing primitives used in Ethereum 2.0"

View File

@ -2,7 +2,7 @@
name = "eth2_key_derivation"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -148,8 +148,7 @@ fn parent_sk_to_lamport_pk(ikm: &[u8], index: u32) -> ZeroizeHash {
lamports
.iter()
.map(LamportSecretKey::iter_chunks)
.flatten()
.flat_map(LamportSecretKey::iter_chunks)
.enumerate()
.for_each(|(i, chunk)| {
let mut hasher = Sha256::new();

View File

@ -2,7 +2,7 @@
name = "eth2_keystore"
version = "0.1.0"
authors = ["Pawan Dhananjay <pawan@sigmaprime.io", "Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@
name = "eth2_wallet"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -3,7 +3,7 @@ name = "lcli"
description = "Lighthouse CLI (modeled after zcli)"
version = "2.1.3"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[features]
portable = ["bls/supranational-portable"]

View File

@ -74,9 +74,9 @@ async fn get_block_attestations_set<'a, T: EthSpec>(
.graffiti()
.as_utf8_lossy()
// Remove commas and apostropes from graffiti to ensure correct CSV format.
.replace(",", "")
.replace("\"", "")
.replace("'", ""),
.replace(',', "")
.replace('"', "")
.replace('\'', ""),
};
let attestations = block.message().body().attestations();

View File

@ -2,7 +2,7 @@
name = "lighthouse"
version = "2.1.3"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
edition = "2021"
autotests = false
[features]

View File

@ -2,7 +2,7 @@
name = "environment"
version = "0.1.2"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[dependencies]
tokio = { version = "1.14.0", features = ["macros", "rt", "rt-multi-thread", "signal" ] }

View File

@ -2,7 +2,7 @@
name = "slasher"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
bincode = "1.3.1"

View File

@ -2,7 +2,7 @@
name = "slasher_service"
version = "0.1.0"
authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
edition = "2021"
[dependencies]
beacon_chain = { path = "../../beacon_node/beacon_chain" }

View File

@ -2,7 +2,7 @@
name = "ef_tests"
version = "0.2.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
edition = "2021"
[features]
# `ef_tests` feature must be enabled to actually run the tests

Some files were not shown because too many files have changed in this diff Show More