Skip to content

Commit

Permalink
added some docker configuration, converting to config.yml args soon
Browse files Browse the repository at this point in the history
  • Loading branch information
ursisterbtw committed Nov 17, 2024
1 parent 9b58a2a commit 03cab69
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ run.py
*.pyd
*.def
Cargo.lock
dockerfile
ascii.gen
cmd.md
# Dirs
Expand All @@ -24,5 +23,10 @@ app
__pycache__
secrets
data/

*.db
*.log
**/gen/*.json
.build-metrics.db
# Temp Ignore

34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
Expand Down
17 changes: 15 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
});
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 03cab69

Please sign in to comment.