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
3 changes: 2 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
toolchain:
- stable
- nightly
features:
- ""
steps:
Expand All @@ -32,6 +32,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
components: "rustfmt,clippy"

# https://github.com/swatinem/rust-cache
- name: Run Swatinem/rust-cache@v2
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ build: ## Build (debug version)
cargo build --features "$(FEATURES)"

.PHONY: docker-image-rbuilder
docker-image-rubilder: ## Build a rbuilder Docker image
docker-image-rbuilder: ## Build a rbuilder Docker image
docker build --platform linux/amd64 --target rbuilder-runtime --build-arg FEATURES="$(FEATURES)" . -t rbuilder

##@ Dev

.PHONY: lint
lint: ## Run the linters
cargo fmt -- --check
cargo clippy --features "$(FEATURES)" -- -D warnings
cargo clippy -p op-rbuilder --features "$(FEATURES)" -- -D warnings
cargo +nightly fmt -- --check
cargo +nightly clippy --features "$(FEATURES)" -- -D warnings
cargo +nightly clippy -p op-rbuilder --features "$(FEATURES)" -- -D warnings

.PHONY: test
test: ## Run the tests for rbuilder and op-rbuilder
Expand All @@ -50,10 +50,10 @@ lt: lint test ## Run "lint" and "test"

.PHONY: fmt
fmt: ## Format the code
cargo fmt
cargo fix --allow-staged
cargo clippy --features "$(FEATURES)" --fix --allow-staged
cargo clippy -p op-rbuilder --features "$(FEATURES)" --fix --allow-staged
cargo +nightly fmt
cargo +nightly fix --allow-staged
cargo +nightly clippy --features "$(FEATURES)" --fix --allow-staged
cargo +nightly clippy -p op-rbuilder --features "$(FEATURES)" --fix --allow-staged

.PHONY: bench
bench: ## Run benchmarks
Expand Down
44 changes: 23 additions & 21 deletions crates/op-rbuilder/src/generator.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
use futures_util::Future;
use futures_util::FutureExt;
use reth::providers::BlockReaderIdExt;
use reth::{providers::StateProviderFactory, tasks::TaskSpawner};
use reth_basic_payload_builder::HeaderForPayload;
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, PayloadConfig};
use reth_node_api::PayloadBuilderAttributes;
use reth_node_api::PayloadKind;
use reth_payload_builder::PayloadJobGenerator;
use reth_payload_builder::{KeepPayloadJobAlive, PayloadBuilderError, PayloadJob};
use futures_util::{Future, FutureExt};
use reth::{
providers::{BlockReaderIdExt, StateProviderFactory},
tasks::TaskSpawner,
};
use reth_basic_payload_builder::{BasicPayloadJobGeneratorConfig, HeaderForPayload, PayloadConfig};
use reth_node_api::{PayloadBuilderAttributes, PayloadKind};
use reth_payload_builder::{
KeepPayloadJobAlive, PayloadBuilderError, PayloadJob, PayloadJobGenerator,
};
use reth_payload_primitives::BuiltPayload;
use reth_primitives_traits::HeaderTy;
use reth_revm::cached::CachedReads;
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use tokio::sync::oneshot;
use tokio::sync::Notify;
use tokio::time::Duration;
use tokio::time::Sleep;
use std::{
sync::{Arc, Mutex},
time::{SystemTime, UNIX_EPOCH},
};
use tokio::{
sync::{oneshot, Notify},
time::{Duration, Sleep},
};
use tokio_util::sync::CancellationToken;
use tracing::info;

Expand Down Expand Up @@ -424,14 +425,15 @@ mod tests {
use reth::tasks::TokioTaskExecutor;
use reth_chain_state::ExecutedBlockWithTrieUpdates;
use reth_node_api::NodePrimitives;
use reth_optimism_payload_builder::payload::OpPayloadBuilderAttributes;
use reth_optimism_payload_builder::OpPayloadPrimitives;
use reth_optimism_payload_builder::{payload::OpPayloadBuilderAttributes, OpPayloadPrimitives};
use reth_optimism_primitives::OpPrimitives;
use reth_primitives::SealedBlock;
use reth_provider::test_utils::MockEthProvider;
use reth_testing_utils::generators::{random_block_range, BlockRangeParams};
use tokio::task;
use tokio::time::{sleep, Duration};
use tokio::{
task,
time::{sleep, Duration},
};

#[tokio::test]
async fn test_block_cell_wait_for_value() {
Expand Down
26 changes: 13 additions & 13 deletions crates/op-rbuilder/src/integration/mod.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
use alloy_consensus::TxEip1559;
use alloy_eips::BlockNumberOrTag;
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718};
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, BlockNumberOrTag};
use alloy_provider::{Identity, Provider, ProviderBuilder};
use op_alloy_consensus::OpTypedTransaction;
use op_alloy_network::Optimism;
use op_rbuilder::OpRbuilderConfig;
use op_reth::OpRethConfig;
use parking_lot::Mutex;
use std::cmp::max;
use std::collections::HashSet;
use std::future::Future;
use std::net::TcpListener;
use std::path::Path;
use std::sync::LazyLock;
use std::{
cmp::max,
collections::HashSet,
fs::{File, OpenOptions},
future::Future,
io,
io::prelude::*,
path::PathBuf,
net::TcpListener,
path::{Path, PathBuf},
process::{Child, Command},
sync::LazyLock,
time::{Duration, SystemTime},
};
use time::{format_description, OffsetDateTime};
use tokio::time::sleep;
use uuid::Uuid;

use crate::tester::{BlockGenerator, EngineApi};
use crate::tx_signer::Signer;
use crate::{
tester::{BlockGenerator, EngineApi},
tx_signer::Signer,
};

/// Default JWT token for testing purposes
pub const DEFAULT_JWT_TOKEN: &str =
Expand Down Expand Up @@ -92,7 +92,7 @@ pub async fn poll_logs(

impl ServiceInstance {
pub fn new(name: String, test_dir: PathBuf) -> Self {
let log_path = test_dir.join(format!("{}.log", name));
let log_path = test_dir.join(format!("{name}.log"));
Self {
process: None,
log_path,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl IntegrationFramework {

let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_dir.push("../../integration_logs");
test_dir.push(format!("{}_{}", date_format, test_name));
test_dir.push(format!("{date_format}_{test_name}"));

std::fs::create_dir_all(&test_dir).map_err(|_| IntegrationError::SetupError)?;

Expand Down
3 changes: 1 addition & 2 deletions crates/op-rbuilder/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use clap::Parser;
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
use reth_optimism_node::node::OpAddOnsBuilder;
use reth_optimism_node::OpNode;
use reth_optimism_node::{node::OpAddOnsBuilder, OpNode};

#[cfg(feature = "flashblocks")]
use payload_builder::CustomOpPayloadBuilder;
Expand Down
5 changes: 4 additions & 1 deletion crates/op-rbuilder/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use reth_metrics::{metrics::Counter, metrics::Histogram, Metrics};
use reth_metrics::{
metrics::{Counter, Histogram},
Metrics,
};

/// op-rbuilder metrics
#[derive(Metrics, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn main() -> eyre::Result<()> {
generator.init().await?;

let block_hash = generator.deposit(address, amount).await?;
println!("Deposit transaction included in block: {}", block_hash);
println!("Deposit transaction included in block: {block_hash}");
Ok(())
}
}
Expand Down
17 changes: 7 additions & 10 deletions crates/op-rbuilder/src/tester/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl EngineApi {

pub fn new_with_port(port: u16) -> Result<Self, Box<dyn std::error::Error>> {
Self::builder()
.with_url(&format!("http://localhost:{}", port))
.with_url(&format!("http://localhost:{port}"))
.build()
}

Expand Down Expand Up @@ -179,13 +179,13 @@ pub async fn generate_genesis(output: Option<String>) -> eyre::Result<()> {
let timestamp = chrono::Utc::now().timestamp();
if let Some(config) = genesis.as_object_mut() {
// Assuming timestamp is at the root level - adjust path as needed
config["timestamp"] = Value::String(format!("0x{:x}", timestamp));
config["timestamp"] = Value::String(format!("0x{timestamp:x}"));
}

// Write the result to the output file
if let Some(output) = output {
std::fs::write(&output, serde_json::to_string_pretty(&genesis)?)?;
println!("Generated genesis file at: {}", output);
println!("Generated genesis file at: {output}");
} else {
println!("{}", serde_json::to_string_pretty(&genesis)?);
}
Expand Down Expand Up @@ -241,10 +241,7 @@ impl BlockGenerator {

// Initialize flashblocks service
if let Some(flashblocks_endpoint) = &self.flashblocks_endpoint {
println!(
"Initializing flashblocks service at {}",
flashblocks_endpoint
);
println!("Initializing flashblocks service at {flashblocks_endpoint}");

self.flashblocks_service = Some(Flashblocks::run(
flashblocks_endpoint.to_string(),
Expand Down Expand Up @@ -273,7 +270,7 @@ impl BlockGenerator {
let mut latest_hash = latest_validation_block.header.hash;

for i in (latest_validation_block.header.number + 1)..=latest_block.header.number {
println!("syncing block {}", i);
println!("syncing block {i}");

let block = self
.engine_api
Expand Down Expand Up @@ -512,7 +509,7 @@ pub async fn run_system(
block_time_secs: u64,
flashblocks_endpoint: Option<String>,
) -> eyre::Result<()> {
println!("Validation: {}", validation);
println!("Validation: {validation}");

let engine_api = EngineApi::new("http://localhost:4444").unwrap();
let validation_api = if validation {
Expand All @@ -535,6 +532,6 @@ pub async fn run_system(
loop {
println!("Generating new block...");
let block_hash = generator.generate_block().await?;
println!("Generated block: {}", block_hash);
println!("Generated block: {block_hash}");
}
}
Loading