Skip to content

Commit

Permalink
better field names
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Jan 14, 2025
1 parent b1e2563 commit bb938c3
Show file tree
Hide file tree
Showing 352 changed files with 2,285 additions and 2,262 deletions.
4 changes: 2 additions & 2 deletions bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
match get_single_header(&client, BlockHashOrNumber::Number(block)).await {
Ok(tip_header) => {
info!(target: "reth::cli", ?block, "Successfully fetched block");
return Ok(tip_header.hash())
return Ok(tip_header.hash());
}
Err(error) => {
error!(target: "reth::cli", ?block, %error, "Failed to fetch the block. Retrying...");
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
provider.get_stage_checkpoint(StageId::Finish)?.map(|ch| ch.block_number);
if latest_block_number.unwrap_or_default() >= self.to {
info!(target: "reth::cli", latest = latest_block_number, "Nothing to run");
return Ok(())
return Ok(());
}

ctx.task_executor.spawn_critical(
Expand Down
6 changes: 3 additions & 3 deletions bin/reth/src/commands/debug_cmd/in_memory_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {

if in_memory_state_root == block.state_root {
info!(target: "reth::cli", state_root = ?in_memory_state_root, "Computed in-memory state root matches");
return Ok(())
return Ok(());
}

let provider_rw = provider_factory.database_provider_rw()?;
Expand Down Expand Up @@ -210,8 +210,8 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
match (in_mem_updates_iter.next(), incremental_updates_iter.next()) {
(Some(in_mem), Some(incr)) => {
similar_asserts::assert_eq!(in_mem.0, incr.0, "Nibbles don't match");
if in_mem.1 != incr.1 &&
in_mem.0.len() > self.skip_node_depth.unwrap_or_default()
if in_mem.1 != incr.1
&& in_mem.0.len() > self.skip_node_depth.unwrap_or_default()
{
in_mem_mismatched.push(in_mem);
incremental_mismatched.push(incr);
Expand Down
20 changes: 10 additions & 10 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {

if incremental_result.is_ok() {
debug!(target: "reth::cli", block_number, "Successfully computed incremental root");
continue
continue;
}

warn!(target: "reth::cli", block_number, "Incremental calculation failed, retrying from scratch");
Expand Down Expand Up @@ -241,14 +241,14 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
let mut clean_account_mismatched = Vec::new();
let mut incremental_account_trie_iter = incremental_account_trie.into_iter().peekable();
let mut clean_account_trie_iter = clean_account_trie.into_iter().peekable();
while incremental_account_trie_iter.peek().is_some() ||
clean_account_trie_iter.peek().is_some()
while incremental_account_trie_iter.peek().is_some()
|| clean_account_trie_iter.peek().is_some()
{
match (incremental_account_trie_iter.next(), clean_account_trie_iter.next()) {
(Some(incremental), Some(clean)) => {
similar_asserts::assert_eq!(incremental.0, clean.0, "Nibbles don't match");
if incremental.1 != clean.1 &&
clean.0 .0.len() > self.skip_node_depth.unwrap_or_default()
if incremental.1 != clean.1
&& clean.0 .0.len() > self.skip_node_depth.unwrap_or_default()
{
incremental_account_mismatched.push(incremental);
clean_account_mismatched.push(clean);
Expand All @@ -270,16 +270,16 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
let mut first_mismatched_storage = None;
let mut incremental_storage_trie_iter = incremental_storage_trie.into_iter().peekable();
let mut clean_storage_trie_iter = clean_storage_trie.into_iter().peekable();
while incremental_storage_trie_iter.peek().is_some() ||
clean_storage_trie_iter.peek().is_some()
while incremental_storage_trie_iter.peek().is_some()
|| clean_storage_trie_iter.peek().is_some()
{
match (incremental_storage_trie_iter.next(), clean_storage_trie_iter.next()) {
(Some(incremental), Some(clean)) => {
if incremental != clean &&
clean.1.nibbles.len() > self.skip_node_depth.unwrap_or_default()
if incremental != clean
&& clean.1.nibbles.len() > self.skip_node_depth.unwrap_or_default()
{
first_mismatched_storage = Some((incremental, clean));
break
break;
}
}
(Some(incremental), None) => {
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/chain_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
self.inner.safe_block.send_if_modified(|current_header| {
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
let _ = current_header.replace(header);
return true
return true;
}

false
Expand All @@ -134,7 +134,7 @@ where
self.inner.finalized_block.send_if_modified(|current_header| {
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
let _ = current_header.replace(header);
return true
return true;
}

false
Expand Down
6 changes: 3 additions & 3 deletions crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
{
if self.inner.in_memory_state.blocks.read().get(&persisted_num_hash.hash).is_none() {
// do nothing
return
return;
}
}

Expand Down Expand Up @@ -554,7 +554,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
.iter()
.find(|tx| tx.trie_hash() == hash)
{
return Some(tx.clone())
return Some(tx.clone());
}
}
None
Expand Down Expand Up @@ -588,7 +588,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
timestamp: block_state.block_ref().block.timestamp(),
excess_blob_gas: block_state.block_ref().block.excess_blob_gas(),
};
return Some((tx.clone(), meta))
return Some((tx.clone(), meta));
}
}
None
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ impl<N: NodePrimitives> Stream for CanonStateNotificationStream<N> {
Some(Ok(notification)) => Poll::Ready(Some(notification)),
Some(Err(err)) => {
debug!(%err, "canonical state notification stream lagging behind");
continue
continue;
}
None => Poll::Ready(None),
}
};
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
.into_trie_account(EMPTY_ROOT_HASH),
)])),
// use the number as the timestamp so it is monotonically increasing
timestamp: number +
EthereumHardfork::Cancun.activation_timestamp(self.chain_spec.chain).unwrap(),
timestamp: number
+ EthereumHardfork::Cancun.activation_timestamp(self.chain_spec.chain).unwrap(),
withdrawals_root: Some(calculate_withdrawals_root(&[])),
blob_gas_used: Some(0),
excess_blob_gas: Some(0),
Expand Down
16 changes: 8 additions & 8 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl ChainSpec {
// given timestamp.
for (fork, params) in bf_params.iter().rev() {
if self.hardforks.is_fork_active_at_timestamp(fork.clone(), timestamp) {
return *params
return *params;
}
}

Expand All @@ -404,7 +404,7 @@ impl ChainSpec {
// given timestamp.
for (fork, params) in bf_params.iter().rev() {
if self.hardforks.is_fork_active_at_block(fork.clone(), block_number) {
return *params
return *params;
}
}

Expand Down Expand Up @@ -489,8 +489,8 @@ impl ChainSpec {
// We filter out TTD-based forks w/o a pre-known block since those do not show up in the
// fork filter.
Some(match condition {
ForkCondition::Block(block) |
ForkCondition::TTD { fork_block: Some(block), .. } => ForkFilterKey::Block(block),
ForkCondition::Block(block)
| ForkCondition::TTD { fork_block: Some(block), .. } => ForkFilterKey::Block(block),
ForkCondition::Timestamp(time) => ForkFilterKey::Time(time),
_ => return None,
})
Expand All @@ -517,8 +517,8 @@ impl ChainSpec {
for (_, cond) in self.hardforks.forks_iter() {
// handle block based forks and the sepolia merge netsplit block edge case (TTD
// ForkCondition with Some(block))
if let ForkCondition::Block(block) |
ForkCondition::TTD { fork_block: Some(block), .. } = cond
if let ForkCondition::Block(block)
| ForkCondition::TTD { fork_block: Some(block), .. } = cond
{
if cond.active_at_head(head) {
// skip duplicated hardforks: hardforks enabled at genesis block
Expand All @@ -529,7 +529,7 @@ impl ChainSpec {
} else {
// we can return here because this block fork is not active, so we set the
// `next` value
return ForkId { hash: forkhash, next: block }
return ForkId { hash: forkhash, next: block };
}
}
}
Expand All @@ -552,7 +552,7 @@ impl ChainSpec {
// can safely return here because we have already handled all block forks and
// have handled all active timestamp forks, and set the next value to the
// timestamp that is known but not active yet
return ForkId { hash: forkhash, next: timestamp }
return ForkId { hash: forkhash, next: timestamp };
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/cli/src/chainspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn parse_genesis(s: &str) -> eyre::Result<alloy_genesis::Genesis> {
if s.contains('{') {
s.to_string()
} else {
return Err(io_err.into()) // assume invalid path
return Err(io_err.into()); // assume invalid path
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
{
if factory.db_ref().is_read_only()? {
warn!(target: "reth::cli", ?unwind_target, "Inconsistent storage. Restart node to heal.");
return Ok(factory)
return Ok(factory);
}

// Highly unlikely to happen, and given its destructive nature, it's better to panic
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/db/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<N: ProviderNodeTypes> TableViewer<(u64, Duration)> for ChecksumViewer<'_, N

total = index + 1;
if total >= limit {
break
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/db/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ where
) {
// do not bother comparing if the key is already in the discrepancies map
if self.discrepancies.contains_key(&key) {
return
return;
}

// do not bother comparing if the key is already in the extra elements map
if self.extra_elements.contains_key(&key) {
return
return;
}

match (first, second) {
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/db/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Command {
.as_ref()
.map(|search| {
if let Some(search) = search.strip_prefix("0x") {
return hex::decode(search).unwrap()
return hex::decode(search).unwrap();
}
search.as_bytes().to_vec()
})
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>

if !input.trim().eq_ignore_ascii_case("y") {
println!("Database drop aborted!");
return Ok(())
return Ok(());
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/cli/commands/src/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ impl Command {
.add_cell(Cell::new(human_bytes(segment_config_size as f64)));
}
row.add_cell(Cell::new(human_bytes(
(segment_data_size +
segment_index_size +
segment_offsets_size +
segment_config_size) as f64,
(segment_data_size
+ segment_index_size
+ segment_offsets_size
+ segment_config_size) as f64,
)));
table.add_row(row);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/db/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ where
}
}

return Ok(false)
return Ok(false);
}

match event {
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> ImportComm
let total_imported_blocks = provider.tx_ref().entries::<tables::HeaderNumbers>()?;
let total_imported_txns = provider.tx_ref().entries::<tables::TransactionHashNumbers>()?;

if total_decoded_blocks != total_imported_blocks ||
total_decoded_txns != total_imported_txns
if total_decoded_blocks != total_imported_blocks
|| total_decoded_txns != total_imported_txns
{
error!(target: "reth::cli",
total_decoded_blocks,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/hashing_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn dry_run<N: ProviderNodeTypes>(
checkpoint: Some(StageCheckpoint::new(from)),
};
if stage.execute(&provider, input)?.done {
break
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn dry_run<N: ProviderNodeTypes>(
checkpoint: Some(StageCheckpoint::new(from)),
};
if stage.execute(&provider, input)?.done {
break
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where
checkpoint: Some(StageCheckpoint::new(from)),
};
if stage.execute(&provider, input)?.done {
break
break;
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/cli/commands/src/stage/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
config.stages.bodies.downloader_max_buffered_blocks_size_bytes,
)
.with_concurrent_requests_range(
config.stages.bodies.downloader_min_concurrent_requests..=
config.stages.bodies.downloader_max_concurrent_requests,
config.stages.bodies.downloader_min_concurrent_requests
..=config.stages.bodies.downloader_max_concurrent_requests,
)
.build(fetch_client, consensus.clone(), provider_factory.clone()),
);
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>
}

if done {
break
break;
}
}
info!(target: "reth::cli", stage = %self.stage, time = ?start.elapsed(), "Finished stage");
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/test_vectors/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ where
tries += 1;
bytes.extend(std::iter::repeat(0u8).take(256));
} else {
return Err(err)?
return Err(err)?;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/test_vectors/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
let key: T::Key = strat_keys.new_tree(runner).map_err(|e| eyre::eyre!("{e}"))?.current();

if !seen_keys.insert(key.clone()) {
continue
continue;
}

let mut values: Vec<T::Value> =
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/util/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ pub enum SocketAddressParsingError {
/// An error is returned if the value is empty.
pub fn parse_socket_address(value: &str) -> eyre::Result<SocketAddr, SocketAddressParsingError> {
if value.is_empty() {
return Err(SocketAddressParsingError::Empty)
return Err(SocketAddressParsingError::Empty);
}

if let Some(port) = value.strip_prefix(':').or_else(|| value.strip_prefix("localhost:")) {
let port: u16 = port.parse()?;
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port))
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port));
}
if let Ok(port) = value.parse() {
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port))
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port));
}
value
.to_socket_addrs()?
Expand Down
Loading

0 comments on commit bb938c3

Please sign in to comment.