Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/optional-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ jobs:

- name: Run cargo udeps
run: cargo +nightly udeps --workspace --tests --all-targets --release --exclude ef-tests

cargo-workspace-lints:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install cargo workspace lints
run: cargo install cargo-workspace-lints --locked

- name: Run cargo workspace lints
run: cargo workspace-lints
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ repository = "https://github.com/ReamLabs/ream"
rust-version = "1.88.0"
version = "0.1.0"

[workspace.lints.clippy]
let_and_return = "warn"
uninlined_format_args = "warn"
unnecessary_debug_formatting = "warn"
unwrap_used = "warn"
useless_let_if_seq = "warn"
wildcard_imports = "warn"

[workspace.dependencies]
actix-web = "4.10.2"
actix-web-lab = "0.24.1"
Expand Down
3 changes: 3 additions & 0 deletions bin/ream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ ream-storage.workspace = true
ream-sync.workspace = true
ream-validator-beacon.workspace = true
ream-validator-lean.workspace = true

[lints]
workspace = true
2 changes: 2 additions & 0 deletions .clippy.toml → clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
allow-mixed-uninlined-format-args = false

# This feature is in Rust nightly, as of v1.62. The line is added in anticipation.
# Once the feature stabilizes, remove the #[allow(clippy::unwrap_used)] lines in front of every `mod test`
allow-unwrap-in-tests = true
3 changes: 3 additions & 0 deletions crates/common/account_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ bip39.workspace = true
rand.workspace = true
rand_chacha.workspace = true
sha2.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/api_types/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ url.workspace = true
ream-bls.workspace = true
ream-consensus-beacon.workspace = true
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/api_types/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ actix-web.workspace = true
alloy-primitives.workspace = true
serde.workspace = true
thiserror.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/api_types/lean/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ ethereum_ssz.workspace = true
ethereum_ssz_derive.workspace = true
serde.workspace = true
serde_json.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/chain/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ ream-network-spec.workspace = true
ream-operation-pool.workspace = true
ream-p2p.workspace = true
ream-storage.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/chain/lean/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ ream-metrics.workspace = true
ream-network-spec.workspace = true
ream-storage.workspace = true
ream-sync.workspace = true

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/common/chain/lean/src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn create_lean_clock_interval() -> anyhow::Result<Interval> {
lean_network_spec().genesis_time,
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.expect("system time before UNIX EPOCH")
.as_secs()
))
})?;
Expand Down
3 changes: 3 additions & 0 deletions crates/common/checkpoint_sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ ream-consensus-misc.workspace = true
ream-fork-choice.workspace = true
ream-network-spec.workspace = true
ream-storage.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ ream-bls.workspace = true
ream-consensus-misc.workspace = true
ream-merkle.workspace = true
ream-network-spec.workspace = true

[lints]
workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ use crate::{
};

pub mod quoted_u8_var_list {
use super::*;
use super::{
Deserialize, Deserializer, Serialize, Serializer, ValidatorRegistryLimit, VariableList,
};

pub fn serialize<S>(
value: &VariableList<u8, ValidatorRegistryLimit>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ impl FromStr for KZGCommitment {
Ok(Self(kzg_commitment_bytes))
} else {
Err(format!(
"InvalidByteLength: got {}, expected {}",
"InvalidByteLength: got {}, expected {BYTES_PER_COMMITMENT}",
bytes.len(),
BYTES_PER_COMMITMENT
))
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/common/consensus/lean/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ tree_hash_derive.workspace = true
# Local dependencies
ream-consensus-misc.workspace = true
ream-metrics.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/consensus/misc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ tree_hash_derive.workspace = true

# ream dependencies
ream-bls.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/execution_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ tree_hash_derive.workspace = true
# ream dependencies
ream-consensus-beacon.workspace = true
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ anyhow.workspace = true
futures.workspace = true
tokio.workspace = true
tracing.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/fork_choice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ ream-network-spec.workspace = true
ream-operation-pool.workspace = true
ream-polynomial-commitments.workspace = true
ream-storage.workspace = true

[lints]
workspace = true
9 changes: 5 additions & 4 deletions crates/common/fork_choice/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ impl Store {
}

// Calculate proposer score if ``proposer_boost_root`` is set
let mut proposer_score: u64 = 0;
// Boost is applied if ``root`` is an ancestor of ``proposer_boost_root``
if self.get_ancestor(
let proposer_score = if self.get_ancestor(
self.db.proposer_boost_root_provider().get()?,
self.db
.beacon_block_provider()
Expand All @@ -415,8 +414,10 @@ impl Store {
.slot,
)? == root
{
proposer_score = self.get_proposer_score()?;
}
self.get_proposer_score()?
} else {
0
};

Ok(attestation_score + proposer_score)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/common/light_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ tree_hash_derive.workspace = true
# ream dependencies
ream-consensus-beacon.workspace = true
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ version.workspace = true
[dependencies]
lazy_static.workspace = true
prometheus_exporter.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/network_spec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ serde_yaml.workspace = true

# ream-dependencies
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ version.workspace = true
[build-dependencies]
vergen = { version = "9.0", features = ["build", "cargo", "emit_and_set", "rustc"] }
vergen-git2 = "1.0"

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/operation_pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ tree_hash.workspace = true
# ream dependencies
ream-consensus-beacon.workspace = true
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/polynomial_commitments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ tree_hash_derive.workspace = true
ream-bls.workspace = true
ream-consensus-beacon.workspace = true
ream-consensus-misc.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ version.workspace = true

[dependencies]
tokio.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/validator/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ ream-execution-engine.workspace = true
ream-executor.workspace = true
ream-keystore.workspace = true
ream-network-spec.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/common/validator/lean/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ ream-consensus-lean.workspace = true
ream-consensus-misc.workspace = true
ream-network-spec.workspace = true
ream-sync.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/crypto/bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ ssz_types.workspace = true
thiserror.workspace = true
tree_hash.workspace = true
tree_hash_derive.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/crypto/keystore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ uuid = { version = "1.0", features = ["v4", "serde"] }

# ream dependencies
ream-bls.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/crypto/merkle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ alloy-primitives.workspace = true
anyhow.workspace = true
ethereum_hashing.workspace = true
serde.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/crypto/post_quantum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ serde_json.workspace = true
thiserror.workspace = true
tree_hash.workspace = true
tree_hash_derive.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/networking/discv5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ tracing.workspace = true
# ream dependencies
ream-consensus-misc.workspace = true
ream-network-spec.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/networking/manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ ream-polynomial-commitments.workspace = true
ream-storage.workspace = true
ream-syncer.workspace = true
ream-validator-beacon.workspace = true

[lints]
workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub async fn validate_blob_sidecar(
Ok(expected_index) => {
if expected_index != header.proposer_index {
return Ok(ValidationResult::Reject(format!(
"Wrong proposer index: slot {}: expected {}, got {}",
header.slot, expected_index, header.proposer_index
"Wrong proposer index: slot {}: expected {expected_index}, got {}",
header.slot, header.proposer_index
)));
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/networking/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ ream-network-spec.workspace = true
ream-storage.workspace = true
ream-sync.workspace = true
ream-validator-beacon.workspace = true

[lints]
workspace = true
27 changes: 5 additions & 22 deletions crates/networking/p2p/src/gossipsub/beacon/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ impl std::fmt::Display for GossipTopic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"/{}/{}/{}/{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{}/{ENCODING_POSTFIX}",
self.fork.encode_hex(),
self.kind,
ENCODING_POSTFIX
)
}
}
Expand Down Expand Up @@ -126,42 +124,27 @@ impl From<GossipTopic> for TopicHash {
LightClientOptimisticUpdate => LIGHT_CLIENT_OPTIMISTIC_UPDATE_TOPIC,
BeaconAttestation(index) => {
return TopicHash::from_raw(format!(
"/{}/{}/{}{}{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{BEACON_ATTESTATION_PREFIX}{index}{ENCODING_POSTFIX}",
val.fork.encode_hex(),
BEACON_ATTESTATION_PREFIX,
index,
ENCODING_POSTFIX,
));
}
SyncCommittee(index) => {
return TopicHash::from_raw(format!(
"/{}/{}/{}{}{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{SYNC_COMMITTEE_PREFIX_TOPIC}{index}{ENCODING_POSTFIX}",
val.fork.encode_hex(),
SYNC_COMMITTEE_PREFIX_TOPIC,
index,
ENCODING_POSTFIX,
));
}
BlobSidecar(index) => {
return TopicHash::from_raw(format!(
"/{}/{}/{}{}{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{BLOB_SIDECAR_PREFIX_TOPIC}{index}{ENCODING_POSTFIX}",
val.fork.encode_hex(),
BLOB_SIDECAR_PREFIX_TOPIC,
index,
ENCODING_POSTFIX,
));
}
};

TopicHash::from_raw(format!(
"/{}/{}/{}{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{kind_str}{ENCODING_POSTFIX}",
val.fork.encode_hex(),
kind_str,
ENCODING_POSTFIX
))
}
}
Expand Down
9 changes: 2 additions & 7 deletions crates/networking/p2p/src/gossipsub/lean/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ impl std::fmt::Display for LeanGossipTopic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"/{}/{}/{}/{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{}/{ENCODING_POSTFIX}",
self.fork.encode_hex(),
self.kind,
ENCODING_POSTFIX
)
}
}
Expand All @@ -75,11 +73,8 @@ impl From<LeanGossipTopic> for TopicHash {
Vote => LEAN_VOTE_TOPIC,
};
TopicHash::from_raw(format!(
"/{}/{}/{}/{}",
TOPIC_PREFIX,
"/{TOPIC_PREFIX}/{}/{kind_str}/{ENCODING_POSTFIX}",
val.fork.encode_hex(),
kind_str,
ENCODING_POSTFIX
))
}
}
Expand Down
Loading