Skip to content

Commit 8ee3850

Browse files
committed
rename found_flag
1 parent b127d3c commit 8ee3850

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

kernel/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub unsafe fn find_vanity_private_key(
3737
vanity_prefix_len: usize,
3838
rng_seed: u64,
3939
// output
40-
found_flag_slice_ptr: *mut cuda_std::atomic::AtomicF32,
40+
found_matches_slice_ptr: *mut cuda_std::atomic::AtomicF32,
4141
found_private_key_ptr: *mut u8,
4242
found_public_key_ptr: *mut u8,
4343
found_bs58_encoded_public_key_ptr: *mut u8,
@@ -76,22 +76,22 @@ pub unsafe fn find_vanity_private_key(
7676

7777
// if match, copy found match to host
7878
if matches {
79-
let found_flag_slice = unsafe { core::slice::from_raw_parts_mut(found_flag_slice_ptr, 1) };
79+
let found_matches_slice = unsafe { core::slice::from_raw_parts_mut(found_matches_slice_ptr, 1) };
8080
let found_private_key = unsafe { core::slice::from_raw_parts_mut(found_private_key_ptr, 32) };
8181
let found_public_key = unsafe { core::slice::from_raw_parts_mut(found_public_key_ptr, 32) };
8282
let found_bs58_encoded_public_key = unsafe { core::slice::from_raw_parts_mut(found_bs58_encoded_public_key_ptr, 64) };
8383
let found_thread_idx_slice = unsafe { core::slice::from_raw_parts_mut(found_thread_idx_slice_ptr, 1) };
84-
let found_flag = &mut found_flag_slice[0];
84+
let found_matches = &mut found_matches_slice[0];
8585

8686
// if first find, copy results to host
87-
if found_flag.load(core::sync::atomic::Ordering::SeqCst) == 0.0 {
87+
if found_matches.load(core::sync::atomic::Ordering::SeqCst) == 0.0 {
8888
found_private_key.copy_from_slice(&private_key[0..32]);
8989
found_public_key.copy_from_slice(&public_key_bytes[0..32]);
9090
found_bs58_encoded_public_key.copy_from_slice(&bs58_encoded_public_key[0..64]);
9191
found_thread_idx_slice[0] = thread_idx as u32;
9292
}
9393

94-
found_flag.fetch_add(1.0, core::sync::atomic::Ordering::SeqCst);
94+
found_matches.fetch_add(1.0, core::sync::atomic::Ordering::SeqCst);
9595
cuda_std::atomic::mid::device_thread_fence(core::sync::atomic::Ordering::SeqCst);
9696
}
9797
}

scripts/vast.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PORT=13360
44
HOST=ssh4.vast.ai
55
USER=root
66

7+
ssh -p $PORT $USER@$HOST
8+
79
# generate key
810
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST <<'EOF'
911
if [[ ! -f ~/.ssh/id_rsa ]]
@@ -68,5 +70,5 @@ EOF
6870
# run
6971
ssh -o StrictHostKeyChecking=no -p $PORT $USER@$HOST <<'EOF'
7072
pushd ed25519-vanity-rs
71-
./target/release/ed25519_vanity aa 16384 256
73+
./target/release/ed25519_vanity aa 8192 256
7274
EOF

src/main.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ fn device_main(
5252
loop {
5353
let rng_seed: u64 = rng.r#gen::<u64>();
5454

55-
let mut found_flag_slice = [0.0f32; 1];
55+
let mut found_matches_slice = [0.0f32; 1];
5656
let mut found_private_key = [0u8; 32];
5757
let mut found_public_key = [0u8; 32];
5858
let mut found_bs58_encoded_public_key = [0u8; 64];
5959
let mut found_thread_idx_slice = [0u32; 1];
6060

6161
let vanity_prefix_dev = vanity_prefix_bytes.as_dbuf()?;
62-
let found_flag_slice_dev = found_flag_slice.as_dbuf()?;
62+
let found_matches_slice_dev = found_matches_slice.as_dbuf()?;
6363
let found_private_key_dev = found_private_key.as_dbuf()?;
6464
let found_public_key_dev = found_public_key.as_dbuf()?;
6565
let found_bs58_encoded_public_key_dev = found_bs58_encoded_public_key.as_dbuf()?;
@@ -73,7 +73,7 @@ fn device_main(
7373
vanity_prefix_dev.as_device_ptr(),
7474
vanity_prefix_len,
7575
rng_seed,
76-
found_flag_slice_dev.as_device_ptr(),
76+
found_matches_slice_dev.as_device_ptr(),
7777
found_private_key_dev.as_device_ptr(),
7878
found_public_key_dev.as_device_ptr(),
7979
found_bs58_encoded_public_key_dev.as_device_ptr(),
@@ -88,30 +88,28 @@ fn device_main(
8888
global_stats.add_launch(operations_per_launch);
8989

9090
// Check if we found a match
91-
found_flag_slice_dev.copy_to(&mut found_flag_slice)?;
91+
found_matches_slice_dev.copy_to(&mut found_matches_slice)?;
9292

93-
if found_flag_slice[0] != 0.0 {
93+
let found_matches = found_matches_slice[0];
94+
if found_matches != 0.0 {
9495
// We found a match! Copy results back to host
9596
found_private_key_dev.copy_to(&mut found_private_key)?;
9697
found_public_key_dev.copy_to(&mut found_public_key)?;
9798
found_bs58_encoded_public_key_dev.copy_to(&mut found_bs58_encoded_public_key)?;
9899
found_thread_idx_slice_dev.copy_to(&mut found_thread_idx_slice)?;
99100

100-
global_stats.add_matches(found_flag_slice[0] as usize);
101+
global_stats.add_matches(found_matches as usize);
101102

102103
// Format results
103104
let found_thread_idx = found_thread_idx_slice[0];
104105
let wallet_formatted_result = hex::encode([found_private_key, found_public_key].concat());
105-
let public_key_string = String::from_utf8(found_bs58_encoded_public_key.to_vec()).unwrap();
106+
let encoded_public_key_string = String::from_utf8(found_bs58_encoded_public_key.to_vec()).unwrap();
107+
println!("[{ordinal}] First match: seed = {rng_seed} thread_idx = {found_thread_idx} encoded_public_key = {encoded_public_key_string} wallet = {wallet_formatted_result}");
106108

107109
// Print stats using global counters
108110
global_stats.print_stats(
109111
ordinal,
110-
found_flag_slice[0],
111-
&public_key_string,
112-
&wallet_formatted_result,
113-
rng_seed,
114-
found_thread_idx
112+
found_matches,
115113
);
116114
}
117115
}

src/stats.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl GlobalStats {
2929
self.matches_found.fetch_add(matches, Ordering::Relaxed);
3030
}
3131

32-
pub fn print_stats(&self, device_id: usize, matches_this_launch: f32, public_key: &str, wallet: &str, seed: u64, thread_idx: u32) {
32+
pub fn print_stats(&self, device_id: usize, matches_this_launch: f32) {
3333
let launches = self.launches.load(Ordering::Relaxed);
3434
let matches = self.matches_found.load(Ordering::Relaxed);
3535
let operations = self.total_operations.load(Ordering::Relaxed);
@@ -41,7 +41,6 @@ impl GlobalStats {
4141
let matches_per_second = matches as f64 / elapsed_seconds;
4242

4343
println!("[{device_id}] Found {matches_this_launch} matches this launch");
44-
println!("[{device_id}] First match: seed = {seed} thread_idx = {thread_idx} public_key = {public_key} wallet = {wallet}");
4544
println!("[{device_id}] GLOBAL STATS: Found {matches} matches in {elapsed_seconds:.2}s ({matches_per_second:.6} matches/sec, {launches_per_second:.2} launches/sec, {operations_per_second:.2}M ops/sec) with {launches} total launches, {operations} total operations");
4645
}
4746
}

0 commit comments

Comments
 (0)