From 03cab695938f8ec3ee864dccaa9208b2e233590a Mon Sep 17 00:00:00 2001 From: ursisterbtw Date: Sun, 17 Nov 2024 01:49:14 -0500 Subject: [PATCH] added some docker configuration, converting to config.yml args soon --- .gitignore | 6 +++++- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ README.md | 8 +++----- docker-compose.yml | 17 +++++++++++++++-- src/main.rs | 16 +++++++++++++++- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 60d0feb..22c6b02 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ run.py *.pyd *.def Cargo.lock -dockerfile ascii.gen cmd.md # Dirs @@ -24,5 +23,10 @@ app __pycache__ secrets data/ + +*.db +*.log +**/gen/*.json +.build-metrics.db # Temp Ignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0cfc546 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Use a more recent version of Rust +FROM rust:1.82 AS builder + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy the current directory contents into the container +COPY . . + +# Build the application +RUN cargo build --release + +# Use Ubuntu as the base image for the final stage +FROM ubuntu:22.04 + +# Install necessary runtime libraries +RUN apt-get update && \ + apt-get install -y \ + libssl3 \ + supervisor \ + && rm -rf /var/lib/apt/lists/* + +# Copy the binary and supervisor config +COPY --from=builder /usr/src/app/target/release/hash_hunter /usr/local/bin/hash_hunter +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Set the working directory +WORKDIR /usr/src/app + +# Create directory for persistent storage +RUN mkdir -p /usr/src/app/gen + +# Use supervisor to manage the process +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/README.md b/README.md index 1925547..c38bb1a 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,21 @@ # hash_hunter -hash_hunter is a simple Ethereum vanity address generator written in both Rust and Python. It is designed to be a proof of concept for generating Ethereum addresses with a specific prefix and suffix, as well as some other features. +`hash_hunter` is a simple Ethereum vanity address generator written in both Rust and Python. It is designed to be a proof of concept for generating Ethereum addresses with a specific prefix and suffix, as well as some other features. -🦀 main.rs 🦀 is designed to max out cpu, 🐍 main.py 🐍 is a little more considerate. +🦀 `main.rs` 🦀 is designed to max out cpu, 🐍 `main.py` 🐍 is a little more considerate. Setup finished, python/rust working as intended. If you're feeling froggy, I left some hints in /src that point towards a rather speedy Cython implementation ⏩ -Cuidado loco! +Be careful! ## Usage -```rust ```rust cargo run --release ``` -```rust ```rust cargo run --release -- --start-pattern 123 --end-pattern abc --min-zeros 5 ``` diff --git a/docker-compose.yml b/docker-compose.yml index f694cb8..54d3fa2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,20 @@ version: '3.8' services: hash_hunter: - build: . + image: hash_hunter:latest + build: + context: . volumes: - ./gen:/usr/src/app/gen - command: hash_hunter -p 69 -e 69696969 -c -s 100000 -m 100000000000 -i 10000 \ No newline at end of file + command: hash_hunter -p 69 -e 69696969 -c -s 100000 -m 100000000000 -i 10000 -y + restart: unless-stopped + deploy: + resources: + limits: + cpus: '7.5' + memory: 8G + healthcheck: + test: ["CMD", "supervisorctl", "status", "hash_hunter"] + interval: 30s + timeout: 10s + retries: 3 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8b423a8..a0224c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,10 @@ struct Args { // regex pattern to match in the address #[arg(short = 'r', long, default_value = "")] regex_pattern: String, + + // skip confirmation prompt for docker + #[arg(short = 'y', long, default_value_t = false)] + skip_confirmation: bool, } struct VanityResult { @@ -115,10 +119,16 @@ fn main() { let found = Arc::clone(&found); let progress_bar = Arc::clone(&progress_bar); std::thread::spawn(move || { + let mut last_attempts = 0u64; while !found.load(Ordering::Relaxed) { std::thread::sleep(Duration::from_millis(log_interval)); let attempts = total_attempts.get("attempts").map(|a| *a).unwrap_or(0); progress_bar.set_position(attempts); + + // Add rate calculation + let rate = (attempts - last_attempts) as f64 / (log_interval as f64 / 1000.0); + println!("Rate: {:.2} attempts/sec, Total: {}", rate, attempts); + last_attempts = attempts; } }); } @@ -385,7 +395,11 @@ fn to_checksum_address(address: &str) -> String { checksum_address } -fn confirm_start(_args: &Args) -> bool { +fn confirm_start(args: &Args) -> bool { + if args.skip_confirmation { + return true; + } + println!("\nAre you sure you want to start with these parameters? (y/n)"); print!(">>> "); io::stdout().flush().unwrap();