From c12756b5d527c3ee0621e5c1433ef3822df62245 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Sun, 27 Oct 2024 11:27:54 +0900 Subject: [PATCH 1/3] add linter target Signed-off-by: Jun Kimura --- Makefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e57624..5dcb847 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,16 @@ +######## Lint ######## + +.PHONY: lint-tools +lint-tools: + rustup component add rustfmt clippy + cargo install cargo-machete + +.PHONY: fmt +fmt: + @cargo fmt --all $(CARGO_FMT_OPT) + .PHONY: lint lint: - @cargo fmt --all -- --check + @$(MAKE) CARGO_FMT_OPT=--check fmt + @cargo clippy --locked --tests $(CARGO_TARGET) -- -D warnings + @cargo machete From d7ea368a9f57d1fd3763d216a0584a91a3784f7c Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Sun, 27 Oct 2024 11:45:04 +0900 Subject: [PATCH 2/3] fix lint warnings Signed-off-by: Jun Kimura --- crates/consensus/src/bellatrix.rs | 4 +-- crates/consensus/src/bls.rs | 8 ++---- crates/consensus/src/capella.rs | 4 +-- crates/consensus/src/compute.rs | 8 +++--- crates/consensus/src/deneb.rs | 4 +-- crates/consensus/src/lib.rs | 1 + crates/consensus/src/merkle.rs | 2 +- crates/light-client-cli/Cargo.toml | 4 --- crates/light-client-cli/bin/main.rs | 2 +- crates/light-client-cli/src/chain.rs | 27 +++++++++++-------- crates/light-client-cli/src/cli.rs | 2 +- crates/light-client-cli/src/client.rs | 10 +++---- crates/light-client-cli/src/context.rs | 1 + crates/light-client-cli/src/lib.rs | 1 + crates/light-client-cli/src/state.rs | 2 +- crates/light-client-verifier/Cargo.toml | 1 - crates/light-client-verifier/src/consensus.rs | 18 ++++++------- crates/light-client-verifier/src/context.rs | 3 ++- crates/light-client-verifier/src/execution.rs | 19 +++++++------ crates/light-client-verifier/src/lib.rs | 1 + crates/light-client-verifier/src/state.rs | 1 + crates/light-client-verifier/src/updates.rs | 2 +- .../src/updates/bellatrix.rs | 12 ++++----- .../src/updates/capella.rs | 8 +++--- .../src/updates/deneb.rs | 8 +++--- crates/lodestar-rpc/Cargo.toml | 3 --- 26 files changed, 78 insertions(+), 78 deletions(-) diff --git a/crates/consensus/src/bellatrix.rs b/crates/consensus/src/bellatrix.rs index 2b8908b..c8681ba 100644 --- a/crates/consensus/src/bellatrix.rs +++ b/crates/consensus/src/bellatrix.rs @@ -317,7 +317,7 @@ pub fn gen_execution_payload_proof< branch.copy_from_slice( tree.proof(&[BLOCK_BODY_EXECUTION_PAYLOAD_LEAF_INDEX]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect::>() .as_slice(), @@ -357,7 +357,7 @@ pub fn gen_execution_payload_field_proof< branch.copy_from_slice( tree.proof(&[leaf_index]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect::>() .as_slice(), diff --git a/crates/consensus/src/bls.rs b/crates/consensus/src/bls.rs index afb70c3..a6106ca 100644 --- a/crates/consensus/src/bls.rs +++ b/crates/consensus/src/bls.rs @@ -80,9 +80,7 @@ pub struct PublicKeyBytesDef( impl From for PublicKeyBytes { fn from(value: PublicKeyBytesDef) -> Self { - Self(Vector::::from_iter( - value.0.into_iter(), - )) + Self(Vector::::from_iter(value.0)) } } @@ -186,9 +184,7 @@ pub struct SignatureBytesDef( impl From for SignatureBytes { fn from(value: SignatureBytesDef) -> Self { - Self(Vector::::from_iter( - value.0.into_iter(), - )) + Self(Vector::::from_iter(value.0)) } } diff --git a/crates/consensus/src/capella.rs b/crates/consensus/src/capella.rs index 04e547b..f0ac4ae 100644 --- a/crates/consensus/src/capella.rs +++ b/crates/consensus/src/capella.rs @@ -360,7 +360,7 @@ pub fn gen_execution_payload_proof< branch.copy_from_slice( tree.proof(&[BLOCK_BODY_EXECUTION_PAYLOAD_LEAF_INDEX]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect::>() .as_slice(), @@ -400,7 +400,7 @@ pub fn gen_execution_payload_field_proof< branch.copy_from_slice( tree.proof(&[leaf_index]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect::>() .as_slice(), diff --git a/crates/consensus/src/compute.rs b/crates/consensus/src/compute.rs index 8dc4764..8bbd59a 100644 --- a/crates/consensus/src/compute.rs +++ b/crates/consensus/src/compute.rs @@ -52,10 +52,10 @@ pub fn compute_fork_data_root( current_version: Version, genesis_validators_root: Root, ) -> Result { - Ok(hash_tree_root(ForkData { + hash_tree_root(ForkData { current_version, genesis_validators_root, - })?) + }) } /// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_domain @@ -77,10 +77,10 @@ pub fn compute_domain( /// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#compute_signing_root pub fn compute_signing_root(header: BeaconBlockHeader, domain: Domain) -> Result { - Ok(hash_tree_root(SigningData { + hash_tree_root(SigningData { object_root: hash_tree_root(header)?, domain, - })?) + }) } /// hash_tree_root returns the hash tree root of the object diff --git a/crates/consensus/src/deneb.rs b/crates/consensus/src/deneb.rs index 6ce8bcf..830a231 100644 --- a/crates/consensus/src/deneb.rs +++ b/crates/consensus/src/deneb.rs @@ -377,7 +377,7 @@ pub fn gen_execution_payload_proof< H256(tree.root().unwrap()), tree.proof(&[9]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect(), )) @@ -431,7 +431,7 @@ pub fn gen_execution_payload_field_proof< branch.copy_from_slice( tree.proof(&[leaf_index]) .proof_hashes() - .into_iter() + .iter() .map(|h| H256::from_slice(h)) .collect::>() .as_slice(), diff --git a/crates/consensus/src/lib.rs b/crates/consensus/src/lib.rs index cdbf1c3..4cfad12 100644 --- a/crates/consensus/src/lib.rs +++ b/crates/consensus/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(all(not(test), not(feature = "std")), no_std)] +#![allow(clippy::result_large_err)] extern crate alloc; #[allow(unused_imports)] diff --git a/crates/consensus/src/merkle.rs b/crates/consensus/src/merkle.rs index 189f110..f45d026 100644 --- a/crates/consensus/src/merkle.rs +++ b/crates/consensus/src/merkle.rs @@ -23,7 +23,7 @@ pub fn is_valid_merkle_branch( )); } let index = 2u64.pow(depth) + leaf_index; - let mut value = leaf.clone(); + let mut value = leaf; for (i, b) in branch.iter().enumerate() { if let Some(v) = 2u64.checked_pow(i as u32) { if index / v % 2 == 1 { diff --git a/crates/light-client-cli/Cargo.toml b/crates/light-client-cli/Cargo.toml index fb5b771..f7562dc 100644 --- a/crates/light-client-cli/Cargo.toml +++ b/crates/light-client-cli/Cargo.toml @@ -18,10 +18,6 @@ dirs = "4.0" env_logger = { version = "0.10.0" } tokio = { version = "1.24.1", default-features = false, features = ["rt-multi-thread", "macros"] } -ssz-rs = { git = "https://github.com/bluele/ssz_rs", branch = "serde-no-std", default-features = false, features = ["serde"] } -ssz-rs-derive = { git = "https://github.com/bluele/ssz_rs", branch = "serde-no-std", default-features = false } -rs_merkle = { git = "https://github.com/antouhou/rs-merkle", rev = "8ffa623ce70a3659ae73619397b813887cd8d1c9" } - ethereum-consensus = { path = "../consensus" } ethereum-light-client-verifier = { path = "../light-client-verifier" } lodestar-rpc = { path = "../lodestar-rpc" } diff --git a/crates/light-client-cli/bin/main.rs b/crates/light-client-cli/bin/main.rs index 76ee7b4..5801da3 100644 --- a/crates/light-client-cli/bin/main.rs +++ b/crates/light-client-cli/bin/main.rs @@ -6,5 +6,5 @@ async fn main() -> anyhow::Result<()> { env_logger::init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), ); - Ok(Cli::parse().run().await?) + Cli::parse().run().await } diff --git a/crates/light-client-cli/src/chain.rs b/crates/light-client-cli/src/chain.rs index 94bcf0f..298795b 100644 --- a/crates/light-client-cli/src/chain.rs +++ b/crates/light-client-cli/src/chain.rs @@ -5,6 +5,7 @@ use ethereum_consensus::{ }; use ethereum_light_client_verifier::updates::deneb::LightClientBootstrapInfo; use lodestar_rpc::client::RPCClient; +use std::str::FromStr; type Result = core::result::Result; @@ -60,24 +61,28 @@ pub enum Network { } impl Network { - pub fn from_str(s: &str) -> Result { + pub fn config(&self) -> Config { + match self { + Network::Minimal => config::minimal::get_config(), + Network::Mainnet => config::mainnet::get_config(), + Network::Goerli => config::goerli::get_config(), + Network::Sepolia => config::sepolia::get_config(), + } + } +} + +impl FromStr for Network { + type Err = Error; + + fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "minimal" => Ok(Network::Minimal), "mainnet" => Ok(Network::Mainnet), "goerli" => Ok(Network::Goerli), "sepolia" => Ok(Network::Sepolia), s => Err(Error::Other { - description: format!("unknown network: {}", s).into(), + description: format!("unknown network: {}", s), }), } } - - pub fn config(&self) -> Config { - match self { - Network::Minimal => config::minimal::get_config(), - Network::Mainnet => config::mainnet::get_config(), - Network::Goerli => config::goerli::get_config(), - Network::Sepolia => config::sepolia::get_config(), - } - } } diff --git a/crates/light-client-cli/src/cli.rs b/crates/light-client-cli/src/cli.rs index 5ec66e8..5d8e23b 100644 --- a/crates/light-client-cli/src/cli.rs +++ b/crates/light-client-cli/src/cli.rs @@ -1,6 +1,6 @@ use anyhow::Result; use clap::Parser; -use std::path::PathBuf; +use std::{path::PathBuf, str::FromStr}; use crate::{ chain::Network, diff --git a/crates/light-client-cli/src/client.rs b/crates/light-client-cli/src/client.rs index 2d4868f..a32980f 100644 --- a/crates/light-client-cli/src/client.rs +++ b/crates/light-client-cli/src/client.rs @@ -77,7 +77,7 @@ impl< } pub async fn init_with_bootstrap(&self, trusted_block_root: Option) -> Result<()> { - let bootstrap = self.chain.get_bootstrap(trusted_block_root.clone()).await?; + let bootstrap = self.chain.get_bootstrap(trusted_block_root).await?; self.verifier .validate_boostrap(&bootstrap, trusted_block_root)?; @@ -257,7 +257,7 @@ impl< info!("updates: finalized header not found"); return Ok(None); } - Err(e) => return Err(e.into()), + Err(e) => return Err(e), }; info!( @@ -307,7 +307,7 @@ impl< fn build_verification_context(&self) -> impl ChainContext + ConsensusVerificationContext { LightClientContext::new_with_config( self.ctx.config.clone(), - self.genesis_validators_root.clone(), + self.genesis_validators_root, self.genesis_time, self.trust_level.clone(), SystemTime::now() @@ -375,8 +375,8 @@ impl PartialEq for Target { impl PartialOrd for Target { fn partial_cmp(&self, other: &Updated) -> Option { match self { - Target::Slot(v) => v.partial_cmp(&other.0.into()), - Target::BlockNumber(v) => v.partial_cmp(&other.1.into()), + Target::Slot(v) => v.partial_cmp(&other.0), + Target::BlockNumber(v) => v.partial_cmp(&other.1), Target::None => Some(core::cmp::Ordering::Less), Target::Infinity => Some(core::cmp::Ordering::Greater), } diff --git a/crates/light-client-cli/src/context.rs b/crates/light-client-cli/src/context.rs index 7736e62..27d48ad 100644 --- a/crates/light-client-cli/src/context.rs +++ b/crates/light-client-cli/src/context.rs @@ -6,6 +6,7 @@ use ethereum_consensus::config::Config; use ethereum_consensus::context::ChainContext; use ethereum_consensus::deneb::LightClientBootstrap; use log::*; +use std::str::FromStr; #[derive(Debug)] pub struct Context< diff --git a/crates/light-client-cli/src/lib.rs b/crates/light-client-cli/src/lib.rs index deaa179..67d18ab 100644 --- a/crates/light-client-cli/src/lib.rs +++ b/crates/light-client-cli/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::result_large_err)] pub mod chain; pub mod cli; pub mod client; diff --git a/crates/light-client-cli/src/state.rs b/crates/light-client-cli/src/state.rs index 3b58536..5bdc61c 100644 --- a/crates/light-client-cli/src/state.rs +++ b/crates/light-client-cli/src/state.rs @@ -75,7 +75,7 @@ pub struct ExecutionUpdateInfo { impl ExecutionUpdate for ExecutionUpdateInfo { fn state_root(&self) -> H256 { - self.state_root.clone() + self.state_root } fn state_root_branch(&self) -> Vec { diff --git a/crates/light-client-verifier/Cargo.toml b/crates/light-client-verifier/Cargo.toml index d5fdb05..9b1f662 100644 --- a/crates/light-client-verifier/Cargo.toml +++ b/crates/light-client-verifier/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } displaydoc = { version = "0.2", default-features = false } -log = { version = "0.4.17", default-features = false } ethereum-consensus = { path = "../consensus", default-features = false } trie-db = { version= "0.24.0", default-features = false } diff --git a/crates/light-client-verifier/src/consensus.rs b/crates/light-client-verifier/src/consensus.rs index e78998f..0da9912 100644 --- a/crates/light-client-verifier/src/consensus.rs +++ b/crates/light-client-verifier/src/consensus.rs @@ -54,7 +54,7 @@ impl< &bootstrap.current_sync_committee_branch(), CURRENT_SYNC_COMMITTEE_DEPTH as u32, CURRENT_SYNC_COMMITTEE_SUBTREE_INDEX, - bootstrap.beacon_header().state_root.clone(), + bootstrap.beacon_header().state_root, ) .map_err(Error::InvalidCurrentSyncCommitteeMerkleBranch)?; Ok(()) @@ -112,7 +112,7 @@ impl< &update.state_root_branch(), EXECUTION_PAYLOAD_TREE_DEPTH as u32, EXECUTION_PAYLOAD_STATE_ROOT_LEAF_INDEX as u64, - trusted_execution_root.clone(), + trusted_execution_root, ) .map_err(Error::InvalidExecutionStateRootMerkleBranch)?; @@ -282,6 +282,7 @@ pub fn verify_sync_committee_attestation< } /// validate_light_client_update validates a light client update +/// /// NOTE: we can skip the validation of the attested header's execution payload here because we do not reference it in the light client protocol pub fn validate_light_client_update< const SYNC_COMMITTEE_SIZE: usize, @@ -339,7 +340,7 @@ pub fn validate_light_client_update< &consensus_update.finalized_beacon_header_branch(), FINALIZED_ROOT_DEPTH as u32, FINALIZED_ROOT_SUBTREE_INDEX, - consensus_update.attested_beacon_header().state_root.clone(), + consensus_update.attested_beacon_header().state_root, ) .map_err(Error::InvalidFinalizedBeaconHeaderMerkleBranch)?; @@ -369,8 +370,7 @@ pub fn validate_light_client_update< return Err(Error::InconsistentNextSyncCommittee( store_next_sync_committee.aggregate_pubkey.clone(), update_next_sync_committee.aggregate_pubkey.clone(), - ) - .into()); + )); } } is_valid_merkle_branch( @@ -378,13 +378,11 @@ pub fn validate_light_client_update< &consensus_update.next_sync_committee_branch().unwrap(), NEXT_SYNC_COMMITTEE_DEPTH as u32, NEXT_SYNC_COMMITTEE_SUBTREE_INDEX, - consensus_update.attested_beacon_header().state_root.clone(), + consensus_update.attested_beacon_header().state_root, ) .map_err(Error::InvalidNextSyncCommitteeMerkleBranch)?; - } else { - if let Some(branch) = consensus_update.next_sync_committee_branch() { - return Err(Error::NonEmptyNextSyncCommittee(branch.to_vec())); - } + } else if let Some(branch) = consensus_update.next_sync_committee_branch() { + return Err(Error::NonEmptyNextSyncCommittee(branch.to_vec())); } Ok(()) diff --git a/crates/light-client-verifier/src/context.rs b/crates/light-client-verifier/src/context.rs index 980bf14..f73c9a5 100644 --- a/crates/light-client-verifier/src/context.rs +++ b/crates/light-client-verifier/src/context.rs @@ -51,6 +51,7 @@ pub struct LightClientContext { } impl LightClientContext { + #[allow(clippy::too_many_arguments)] pub fn new( fork_parameters: ForkParameters, seconds_per_slot: U64, @@ -101,7 +102,7 @@ impl LightClientContext { impl ConsensusVerificationContext for LightClientContext { fn genesis_validators_root(&self) -> Root { - self.genesis_validators_root.clone() + self.genesis_validators_root } fn min_sync_committee_participants(&self) -> usize { diff --git a/crates/light-client-verifier/src/execution.rs b/crates/light-client-verifier/src/execution.rs index 7eb6550..4c7fd3e 100644 --- a/crates/light-client-verifier/src/execution.rs +++ b/crates/light-client-verifier/src/execution.rs @@ -52,10 +52,10 @@ impl ExecutionVerifier { key: &[u8], proof: Vec>, ) -> Result<(), Error> { - if let Some(_) = self.verify(root, key, proof)? { - Err(Error::ExecutionValueExist) - } else { + if self.verify(root, key, proof)?.is_none() { Ok(()) + } else { + Err(Error::ExecutionValueExist) } } @@ -66,7 +66,7 @@ impl ExecutionVerifier { address: &Address, proof: Vec>, ) -> Result, Error> { - if let Some(value) = self.verify(root, &address.0.as_slice(), proof)? { + if let Some(value) = self.verify(root, address.0.as_slice(), proof)? { Ok(Some(Account::from_rlp_bytes(&value)?)) } else { Ok(None) @@ -146,8 +146,7 @@ mod tests { .unwrap(); let address = Address(hex!("12496c9aa0e6754c897ca88c1d53fea9b19b8aff")); - let verifier = ExecutionVerifier::default(); - let res = verifier.verify_account(root.clone(), &address, proof.clone()); + let res = ExecutionVerifier.verify_account(root, &address, proof.clone()); assert!(res.is_ok()); let acc = res.unwrap(); assert!(acc.is_some()); @@ -156,8 +155,12 @@ mod tests { hex!("2988BB89D212527A6054FEC481672B5CDD01BDF7287129442E82BB7569A412F9") ); - let res = - verifier.verify_account_storage_root(root, &address, proof, acc.unwrap().storage_root); + let res = ExecutionVerifier.verify_account_storage_root( + root, + &address, + proof, + acc.unwrap().storage_root, + ); assert!(res.is_ok()); assert!(res.unwrap()); } diff --git a/crates/light-client-verifier/src/lib.rs b/crates/light-client-verifier/src/lib.rs index 4fe4139..966c371 100644 --- a/crates/light-client-verifier/src/lib.rs +++ b/crates/light-client-verifier/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::result_large_err)] extern crate alloc; #[allow(unused_imports)] diff --git a/crates/light-client-verifier/src/state.rs b/crates/light-client-verifier/src/state.rs index 3f52daa..d95cf03 100644 --- a/crates/light-client-verifier/src/state.rs +++ b/crates/light-client-verifier/src/state.rs @@ -14,6 +14,7 @@ pub trait LightClientStoreReader { } /// Returns the new current and next sync committees based on the state and the consensus update. +/// /// If the current sync committee should be updated, the new current sync committee is returned. /// If the next sync committee should be updated, the new next sync committee is returned. /// ref. https://github.com/ethereum/consensus-specs/blob/087e7378b44f327cdad4549304fc308613b780c3/specs/altair/light-client/sync-protocol.md#apply_light_client_update diff --git a/crates/light-client-verifier/src/updates.rs b/crates/light-client-verifier/src/updates.rs index ff1e635..a1334ee 100644 --- a/crates/light-client-verifier/src/updates.rs +++ b/crates/light-client-verifier/src/updates.rs @@ -48,7 +48,7 @@ pub trait ConsensusUpdate: &self.finalized_execution_branch(), EXECUTION_PAYLOAD_DEPTH as u32, BLOCK_BODY_EXECUTION_PAYLOAD_LEAF_INDEX as u64, - self.finalized_beacon_header().body_root.clone(), + self.finalized_beacon_header().body_root, ) .map_err(Error::InvalidFinalizedExecutionPayload) } diff --git a/crates/light-client-verifier/src/updates/bellatrix.rs b/crates/light-client-verifier/src/updates/bellatrix.rs index bcc4e89..7cfe62c 100644 --- a/crates/light-client-verifier/src/updates/bellatrix.rs +++ b/crates/light-client-verifier/src/updates/bellatrix.rs @@ -26,7 +26,7 @@ impl LightClientBootstrap &self.0.current_sync_committee } fn current_sync_committee_branch(&self) -> [H256; CURRENT_SYNC_COMMITTEE_DEPTH] { - self.0.current_sync_committee_branch.clone() + self.0.current_sync_committee_branch } } @@ -53,19 +53,19 @@ impl ConsensusUpdate self.light_client_update .next_sync_committee .as_ref() - .map(|c| c.1.clone()) + .map(|c| c.1) } fn finalized_beacon_header(&self) -> &BeaconBlockHeader { &self.light_client_update.finalized_header.0 } fn finalized_beacon_header_branch(&self) -> [H256; FINALIZED_ROOT_DEPTH] { - self.light_client_update.finalized_header.1.clone() + self.light_client_update.finalized_header.1 } fn finalized_execution_root(&self) -> H256 { - self.finalized_execution_root.clone() + self.finalized_execution_root } fn finalized_execution_branch(&self) -> [H256; EXECUTION_PAYLOAD_DEPTH] { - self.finalized_execution_branch.clone() + self.finalized_execution_branch } fn sync_aggregate(&self) -> &SyncAggregate { &self.light_client_update.sync_aggregate @@ -85,7 +85,7 @@ pub struct ExecutionUpdateInfo { impl ExecutionUpdate for ExecutionUpdateInfo { fn state_root(&self) -> H256 { - self.state_root.clone() + self.state_root } fn state_root_branch(&self) -> Vec { diff --git a/crates/light-client-verifier/src/updates/capella.rs b/crates/light-client-verifier/src/updates/capella.rs index 4b68cc6..e147583 100644 --- a/crates/light-client-verifier/src/updates/capella.rs +++ b/crates/light-client-verifier/src/updates/capella.rs @@ -60,7 +60,7 @@ impl< &self.0.current_sync_committee } fn current_sync_committee_branch(&self) -> [H256; CURRENT_SYNC_COMMITTEE_DEPTH] { - self.0.current_sync_committee_branch.clone() + self.0.current_sync_committee_branch } } @@ -99,13 +99,13 @@ impl< self.next_sync_committee.as_ref().map(|c| &c.0) } fn next_sync_committee_branch(&self) -> Option<[H256; NEXT_SYNC_COMMITTEE_DEPTH]> { - self.next_sync_committee.as_ref().map(|c| c.1.clone()) + self.next_sync_committee.as_ref().map(|c| c.1) } fn finalized_beacon_header(&self) -> &BeaconBlockHeader { &self.finalized_header.beacon } fn finalized_beacon_header_branch(&self) -> [H256; FINALIZED_ROOT_DEPTH] { - self.finality_branch.clone() + self.finality_branch } fn finalized_execution_root(&self) -> H256 { hash_tree_root(self.finalized_header.execution.clone()) @@ -114,7 +114,7 @@ impl< .into() } fn finalized_execution_branch(&self) -> [H256; EXECUTION_PAYLOAD_DEPTH] { - self.finalized_header.execution_branch.clone() + self.finalized_header.execution_branch } fn sync_aggregate(&self) -> &SyncAggregate { &self.sync_aggregate diff --git a/crates/light-client-verifier/src/updates/deneb.rs b/crates/light-client-verifier/src/updates/deneb.rs index b7ae598..33e200c 100644 --- a/crates/light-client-verifier/src/updates/deneb.rs +++ b/crates/light-client-verifier/src/updates/deneb.rs @@ -58,7 +58,7 @@ impl< &self.0.current_sync_committee } fn current_sync_committee_branch(&self) -> [H256; CURRENT_SYNC_COMMITTEE_DEPTH] { - self.0.current_sync_committee_branch.clone() + self.0.current_sync_committee_branch } } @@ -97,13 +97,13 @@ impl< self.next_sync_committee.as_ref().map(|c| &c.0) } fn next_sync_committee_branch(&self) -> Option<[H256; NEXT_SYNC_COMMITTEE_DEPTH]> { - self.next_sync_committee.as_ref().map(|c| c.1.clone()) + self.next_sync_committee.as_ref().map(|c| c.1) } fn finalized_beacon_header(&self) -> &BeaconBlockHeader { &self.finalized_header.beacon } fn finalized_beacon_header_branch(&self) -> [H256; FINALIZED_ROOT_DEPTH] { - self.finality_branch.clone() + self.finality_branch } fn finalized_execution_root(&self) -> H256 { hash_tree_root(self.finalized_header.execution.clone()) @@ -112,7 +112,7 @@ impl< .into() } fn finalized_execution_branch(&self) -> [H256; EXECUTION_PAYLOAD_DEPTH] { - self.finalized_header.execution_branch.clone() + self.finalized_header.execution_branch } fn sync_aggregate(&self) -> &SyncAggregate { &self.sync_aggregate diff --git a/crates/lodestar-rpc/Cargo.toml b/crates/lodestar-rpc/Cargo.toml index f18ba37..2387814 100644 --- a/crates/lodestar-rpc/Cargo.toml +++ b/crates/lodestar-rpc/Cargo.toml @@ -7,13 +7,10 @@ edition = "2021" serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } serde_json = "1.0.91" log = { version = "0.4.17", default-features = false } -hex = { version = "0.4.3", default-features = false, features = ["alloc", "serde"] } displaydoc = { version = "0.2", default-features = false } reqwest = { version = "0.11.13", features = ["json"] } -tokio = { version = "1.24.1", default-features = false, features = ["rt-multi-thread", "macros"] } ethereum-consensus = { path = "../consensus" } -ethereum-light-client-verifier = { path = "../light-client-verifier" } [features] default = [] From fb87029df7931f306ae3c6d69bedef079a11fb84 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Sun, 27 Oct 2024 12:34:46 +0900 Subject: [PATCH 3/3] fix CI settings Signed-off-by: Jun Kimura --- .github/workflows/no-std.yaml | 10 ++++------ .github/workflows/test.yml | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/no-std.yaml b/.github/workflows/no-std.yaml index f2e0c34..83f3251 100644 --- a/.github/workflows/no-std.yaml +++ b/.github/workflows/no-std.yaml @@ -21,11 +21,10 @@ jobs: name: Check no_std panic conflict runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable - override: true - run: | cd ci/no-std-check make check-panic-conflict @@ -34,12 +33,11 @@ jobs: name: Check no_std substrate support runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: nightly target: wasm32-unknown-unknown - override: true - run: | cd ci/no-std-check make check-substrate diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17c7e74..c736db9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,10 +20,9 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - run: make lint + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 - run: cargo test - - run: cargo build --bin ethlc + - run: cargo build + - run: make lint-tools lint