Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into devnet-0
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed May 23, 2024
2 parents 08f3ed4 + 39d24b4 commit 45bffde
Show file tree
Hide file tree
Showing 57 changed files with 213 additions and 165 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ indent_size = 4
[*.rs]
max_line_length = 100

[*.{yml,yaml}]
indent_size = 2

[*.md]
# double whitespace at end of line
# denotes a line break in Markdown
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ contact_links:
about: Please ask and answer questions here to keep the issue tracker clean.
- name: Security
url: mailto:[email protected]
about: Please report security vulnerabilities here.
about: Please report security vulnerabilities here.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ body:
label: Describe the feature
description: |
Please describe the feature and what it is aiming to solve, if relevant.
If the feature is for a crate, please include a proposed API surface.
validations:
required: true
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/assertoor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
id: services
run: |
export github_sha=${{ github.sha }}
export github_repository=${{ github.repository }}
export github_repository=${{ github.repository }}
cat etc/assertoor/assertoor-template.yaml | envsubst > etc/assertoor/assertoor.yaml
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
elif [ "$task_result" == "failure" ]; then
task_result="${RED}failure${NC}"
fi
echo -e " $(printf '%-4s' "$task_id")\t$task_status\t$task_result\t$(printf '%-50s' "$task_graph$task_name") \t$task_title"
done <<< $(echo "$tasks")
}
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
echo "$task_lines"
fi
if [ $failed_tests -gt 0 ]; then
if [ $failed_tests -gt 0 ]; then
final_test_result="failure"
break
fi
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
with:
name: "kurtosis-enclave-dump-${{ github.run_id }}"
path: ./temp/dump

- name: Return test result
shell: bash
run: |
Expand Down Expand Up @@ -227,4 +227,3 @@ jobs:
exit 1 # fail action
fi
1 change: 0 additions & 1 deletion .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
script: |
const label_pr = require('./.github/scripts/label_pr.js')
await label_pr({github, context})
19 changes: 13 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ members = [
"crates/stages/",
"crates/stages-api",
"crates/static-file/",
"crates/static-file-types/",
"crates/storage/codecs/",
"crates/storage/codecs/derive/",
"crates/storage/db/",
Expand Down Expand Up @@ -105,7 +106,7 @@ rust.missing_debug_implementations = "warn"
rust.missing_docs = "warn"
rust.unreachable_pub = "warn"
rust.unused_must_use = "deny"
rust.rust_2018_idioms = "deny"
rust.rust_2018_idioms = { level = "deny", priority = -1 }
rustdoc.all = "warn"

[workspace.lints.clippy]
Expand Down Expand Up @@ -271,6 +272,7 @@ reth-rpc-layer = { path = "crates/rpc/rpc-layer" }
reth-stages = { path = "crates/stages" }
reth-stages-api = { path = "crates/stages-api" }
reth-static-file = { path = "crates/static-file" }
reth-static-file-types = { path = "crates/static-file-types" }
reth-tasks = { path = "crates/tasks" }
reth-tokio-util = { path = "crates/tokio-util" }
reth-tracing = { path = "crates/tracing" }
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ fix-lint-other-targets:
-- -D warnings

fix-lint:
make lint-reth && \
make lint-op-reth && \
make lint-other-targets && \
make fix-lint-reth && \
make fix-lint-op-reth && \
make fix-lint-other-targets && \
make fmt

.PHONY: rustdocs
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl Command {
let max_widths = table.column_max_content_widths();
let mut separator = Row::new();
for width in max_widths {
separator.add_cell(Cell::new(&"-".repeat(width as usize)));
separator.add_cell(Cell::new("-".repeat(width as usize)));
}
table.add_row(separator);

Expand Down
6 changes: 4 additions & 2 deletions bin/reth/src/commands/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use discv5::ListenConfig;
use reth_config::Config;
use reth_db::create_db;
use reth_interfaces::p2p::bodies::client::BodiesClient;
use reth_network::NetworkConfigBuilder;
use reth_primitives::{BlockHashOrNumber, ChainSpec};
use reth_provider::ProviderFactory;
use std::{
Expand Down Expand Up @@ -112,8 +113,9 @@ impl Command {
let rlpx_socket = (self.network.addr, self.network.port).into();
let boot_nodes = self.chain.bootnodes().unwrap_or_default();

let mut network_config_builder = config
.network_config(self.network.nat, None, p2p_secret_key)
let mut network_config_builder = NetworkConfigBuilder::new(p2p_secret_key)
.peer_config(config.peers_config_with_basic_nodes_from_file(None))
.external_ip_resolver(self.network.nat)
.chain_spec(self.chain.clone())
.disable_discv4_discovery_if(self.chain.chain.is_optimism())
.boot_nodes(boot_nodes.clone());
Expand Down
4 changes: 4 additions & 0 deletions book/run/private-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ First, in your home directory, create a file with the name `network_params.json`
"launch_additional_services": false
}
```

> [!TIP]
> If you would like to use a modified reth node, you can build an image locally with a custom tag. The tag can then be used in the `el_image` field in the `network_params.json` file.
### Step 2: Spin up your network

Next, run the following command from your command line:
Expand Down
5 changes: 0 additions & 5 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ workspace = true
[dependencies]
# reth
reth-network.workspace = true
reth-net-nat.workspace = true
reth-discv4.workspace = true
reth-primitives.workspace = true

# serde
serde.workspace = true
humantime-serde.workspace = true

# crypto
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }

# toml
confy.workspace = true

Expand Down
28 changes: 9 additions & 19 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Configuration files.
use reth_discv4::Discv4Config;
use reth_network::{NetworkConfigBuilder, PeersConfig, SessionsConfig};
use reth_network::{PeersConfig, SessionsConfig};
use reth_primitives::PruneModes;
use secp256k1::SecretKey;
use serde::{Deserialize, Deserializer, Serialize};
use std::{
ffi::OsStr,
Expand All @@ -30,25 +28,17 @@ pub struct Config {
}

impl Config {
/// Initializes network config from read data
pub fn network_config(
/// Returns the [PeersConfig] for the node.
///
/// If a peers file is provided, the basic nodes from the file are added to the configuration.
pub fn peers_config_with_basic_nodes_from_file(
&self,
nat_resolution_method: reth_net_nat::NatResolver,
peers_file: Option<PathBuf>,
secret_key: SecretKey,
) -> NetworkConfigBuilder {
let peer_config = self
.peers
peers_file: Option<&Path>,
) -> PeersConfig {
self.peers
.clone()
.with_basic_nodes_from_file(peers_file)
.unwrap_or_else(|_| self.peers.clone());

let discv4 =
Discv4Config::builder().external_ip_resolver(Some(nat_resolution_method)).clone();
NetworkConfigBuilder::new(secret_key)
.sessions_config(self.sessions.clone())
.peer_config(peer_config)
.discovery(discv4)
.unwrap_or_else(|_| self.peers.clone())
}

/// Save the configuration to toml file.
Expand Down
1 change: 1 addition & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod config;
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/beacon/src/engine/hooks/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ impl<DB: Database + 'static> PruneHook<DB> {

/// This will try to spawn the pruner if it is idle:
/// 1. Check if pruning is needed through [Pruner::is_pruning_needed].
/// 2.
/// 1. If pruning is needed, pass tip block number to the [Pruner::run] and spawn it in a
/// separate task. Set pruner state to [PrunerState::Running].
/// 2. If pruning is not needed, set pruner state back to [PrunerState::Idle].
///
/// 2.1. If pruning is needed, pass tip block number to the [Pruner::run] and spawn it in a
/// separate task. Set pruner state to [PrunerState::Running].
/// 2.2. If pruning is not needed, set pruner state back to [PrunerState::Idle].
///
/// If pruner is already running, do nothing.
fn try_spawn_pruner(&mut self, tip_block_number: BlockNumber) -> Option<EngineHookEvent> {
Expand Down
14 changes: 7 additions & 7 deletions crates/consensus/beacon/src/engine/hooks/static_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ impl<DB: Database + 'static> StaticFileHook<DB> {
/// 1. Check if producing static files is needed through
/// [StaticFileProducer::get_static_file_targets](reth_static_file::StaticFileProducerInner::get_static_file_targets)
/// and then [StaticFileTargets::any](reth_static_file::StaticFileTargets::any).
/// 2.
/// 1. If producing static files is needed, pass static file request to the
/// [StaticFileProducer::run](reth_static_file::StaticFileProducerInner::run) and spawn
/// it in a separate task. Set static file producer state to
/// [StaticFileProducerState::Running].
/// 2. If producing static files is not needed, set static file producer state back to
/// [StaticFileProducerState::Idle].
///
/// 2.1. If producing static files is needed, pass static file request to the
/// [StaticFileProducer::run](reth_static_file::StaticFileProducerInner::run) and
/// spawn it in a separate task. Set static file producer state to
/// [StaticFileProducerState::Running].
/// 2.2. If producing static files is not needed, set static file producer state back to
/// [StaticFileProducerState::Idle].
///
/// If static_file_producer is already running, do nothing.
fn try_spawn_static_file_producer(
Expand Down
10 changes: 5 additions & 5 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,13 @@ where
/// If validation fails, the response MUST contain the latest valid hash:
///
/// - The block hash of the ancestor of the invalid payload satisfying the following two
/// conditions:
/// conditions:
/// - It is fully validated and deemed VALID
/// - Any other ancestor of the invalid payload with a higher blockNumber is INVALID
/// - 0x0000000000000000000000000000000000000000000000000000000000000000 if the above
/// conditions are satisfied by a PoW block.
/// conditions are satisfied by a PoW block.
/// - null if client software cannot determine the ancestor of the invalid payload satisfying
/// the above conditions.
/// the above conditions.
fn latest_valid_hash_for_invalid_payload(
&mut self,
parent_hash: B256,
Expand Down Expand Up @@ -1103,8 +1103,8 @@ where
/// - invalid extra data
/// - invalid transactions
/// - incorrect hash
/// - the versioned hashes passed with the payload do not exactly match transaction
/// versioned hashes
/// - the versioned hashes passed with the payload do not exactly match transaction versioned
/// hashes
/// - the block does not contain blob transactions if it is pre-cancun
///
/// This validates the following engine API rule:
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/engine-primitives/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV3 {
let EthBuiltPayload { block, fees, sidecars, .. } = value;

ExecutionPayloadEnvelopeV3 {
execution_payload: block_to_payload_v3(block),
execution_payload: block_to_payload_v3(block).0,
block_value: fees,
// From the engine API spec:
//
Expand Down
2 changes: 1 addition & 1 deletion crates/exex/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub struct ExExManagerMetrics {
/// The manager is responsible for:
///
/// - Receiving relevant events from the rest of the node, and sending these to the execution
/// extensions
/// extensions
/// - Backpressure
/// - Error handling
/// - Monitoring
Expand Down
1 change: 1 addition & 0 deletions crates/interfaces/src/blockchain_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ pub enum BlockStatus {
/// This is required to:
/// - differentiate whether trie state updates should be cached.
/// - inform other
///
/// This is required because the state root check can only be performed if the targeted block can be
/// traced back to the canonical __head__.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
4 changes: 2 additions & 2 deletions crates/net/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ description = "Types shared across network code"
workspace = true

[dependencies]
# reth
reth-network-types.workspace = true
# ethereum
alloy-primitives.workspace = true

# async
pin-project.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/net/common/src/ban_list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Support for banning peers.
use reth_network_types::PeerId;
type PeerId = alloy_primitives::B512;

use std::{collections::HashMap, net::IpAddr, time::Instant};

/// Determines whether or not the IP is globally routable.
Expand Down
Loading

0 comments on commit 45bffde

Please sign in to comment.