Skip to content
Open
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
33 changes: 10 additions & 23 deletions Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ cl_command_queue Dispatcher::Device::createQueue(cl_context & clContext, cl_devi
#endif

#ifdef CL_VERSION_2_0
const cl_command_queue ret = clCreateCommandQueueWithProperties(clContext, clDeviceId, &p, NULL);
const cl_queue_properties props[] = { CL_QUEUE_PROPERTIES, p, 0 };
const cl_command_queue ret = clCreateCommandQueueWithProperties(clContext, clDeviceId, p ? props : NULL, NULL);
#else
const cl_command_queue ret = clCreateCommandQueue(clContext, clDeviceId, p, NULL);
#endif
Expand Down Expand Up @@ -185,9 +186,7 @@ Dispatcher::Device::Device(Dispatcher & parent, cl_context & clContext, cl_progr
m_clQueue(createQueue(clContext, clDeviceId) ),
m_kernelInit( createKernel(clProgram, "profanity_init") ),
m_kernelInverse(createKernel(clProgram, "profanity_inverse")),
m_kernelIterate(createKernel(clProgram, "profanity_iterate")),
m_kernelTransform( mode.transformKernel() == "" ? NULL : createKernel(clProgram, mode.transformKernel())),
m_kernelScore(createKernel(clProgram, mode.kernel)),
m_kernelIterate(createKernel(clProgram, mode.kernel)),
m_memPrecomp(clContext, m_clQueue, CL_MEM_READ_ONLY | CL_MEM_HOST_WRITE_ONLY, sizeof(g_precomp), g_precomp),
m_memPointsDeltaX(clContext, m_clQueue, CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS, size, true),
m_memInversedNegativeDoubleGy(clContext, m_clQueue, CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS, size, true),
Expand Down Expand Up @@ -322,23 +321,16 @@ void Dispatcher::initBegin(Device & d) {
d.m_memPointsDeltaX.setKernelArg(d.m_kernelInverse, 0);
d.m_memInversedNegativeDoubleGy.setKernelArg(d.m_kernelInverse, 1);

// Kernel arguments - profanity_iterate
// Kernel arguments - profanity_iterate_score_*
d.m_memPointsDeltaX.setKernelArg(d.m_kernelIterate, 0);
d.m_memInversedNegativeDoubleGy.setKernelArg(d.m_kernelIterate, 1);
d.m_memPrevLambda.setKernelArg(d.m_kernelIterate, 2);
d.m_memResult.setKernelArg(d.m_kernelIterate, 3);
d.m_memData1.setKernelArg(d.m_kernelIterate, 4);
d.m_memData2.setKernelArg(d.m_kernelIterate, 5);

// Kernel arguments - profanity_transform_*
if(d.m_kernelTransform) {
d.m_memInversedNegativeDoubleGy.setKernelArg(d.m_kernelTransform, 0);
}

// Kernel arguments - profanity_score_*
d.m_memInversedNegativeDoubleGy.setKernelArg(d.m_kernelScore, 0);
d.m_memResult.setKernelArg(d.m_kernelScore, 1);
d.m_memData1.setKernelArg(d.m_kernelScore, 2);
d.m_memData2.setKernelArg(d.m_kernelScore, 3);

CLMemory<cl_uchar>::setKernelArg(d.m_kernelScore, 4, d.m_clScoreMax); // Updated in handleResult()
CLMemory<cl_uchar>::setKernelArg(d.m_kernelIterate, 6, d.m_clScoreMax); // Updated in handleResult()
CLMemory<cl_uchar>::setKernelArg(d.m_kernelIterate, 7, (cl_uchar) (m_mode.target == CONTRACT ? 1 : 0));

// Seed device
initContinue(d);
Expand Down Expand Up @@ -433,11 +425,6 @@ void Dispatcher::dispatch(Device & d) {
enqueueKernelDevice(d, d.m_kernelIterate, m_size);
#endif

if (d.m_kernelTransform) {
enqueueKernelDevice(d, d.m_kernelTransform, m_size);
}

enqueueKernelDevice(d, d.m_kernelScore, m_size);
clFlush(d.m_clQueue);

#ifdef PROFANITY_DEBUG
Expand Down Expand Up @@ -487,7 +474,7 @@ void Dispatcher::handleResult(Device & d) {

if (r.found > 0 && i >= d.m_clScoreMax) {
d.m_clScoreMax = i;
CLMemory<cl_uchar>::setKernelArg(d.m_kernelScore, 4, d.m_clScoreMax);
CLMemory<cl_uchar>::setKernelArg(d.m_kernelIterate, 6, d.m_clScoreMax);

std::lock_guard<std::mutex> lock(m_mutex);
if (i >= m_clScoreMax) {
Expand Down
2 changes: 0 additions & 2 deletions Dispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class Dispatcher {
cl_kernel m_kernelInit;
cl_kernel m_kernelInverse;
cl_kernel m_kernelIterate;
cl_kernel m_kernelTransform;
cl_kernel m_kernelScore;

CLMemory<point> m_memPrecomp;
CLMemory<mp_number> m_memPointsDeltaX;
Expand Down
29 changes: 9 additions & 20 deletions Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Mode::Mode() : score(0) {
Mode Mode::benchmark() {
Mode r;
r.name = "benchmark";
r.kernel = "profanity_score_benchmark";
r.kernel = "profanity_iterate_score_benchmark";
return r;
}

Expand Down Expand Up @@ -40,7 +40,7 @@ static std::string::size_type hexValue(char c) {
Mode Mode::matching(const std::string strHex) {
Mode r;
r.name = "matching";
r.kernel = "profanity_score_matching";
r.kernel = "profanity_iterate_score_matching";

if (strHex.size() > 40) {
throw std::runtime_error("hex mask must be at most 40 characters, got " + std::to_string(strHex.size()));
Expand Down Expand Up @@ -73,23 +73,23 @@ Mode Mode::matching(const std::string strHex) {
Mode Mode::exact(const std::string strHex) {
Mode r = matching(strHex);
r.name = "exact";
r.kernel = "profanity_exact_match";
r.kernel = "profanity_iterate_exact_match";
return r;
}

Mode Mode::leading(const char charLeading) {

Mode r;
r.name = "leading";
r.kernel = "profanity_score_leading";
r.kernel = "profanity_iterate_score_leading";
r.data1[0] = static_cast<cl_uchar>(hexValue(charLeading));
return r;
}

Mode Mode::range(const cl_uchar min, const cl_uchar max) {
Mode r;
r.name = "range";
r.kernel = "profanity_score_range";
r.kernel = "profanity_iterate_score_range";
r.data1[0] = min;
r.data2[0] = max;
return r;
Expand All @@ -98,7 +98,7 @@ Mode Mode::range(const cl_uchar min, const cl_uchar max) {
Mode Mode::zeroBytes() {
Mode r;
r.name = "zeroBytes";
r.kernel = "profanity_score_zerobytes";
r.kernel = "profanity_iterate_score_zerobytes";
return r;
}

Expand All @@ -114,17 +114,6 @@ Mode Mode::numbers() {
return r;
}

std::string Mode::transformKernel() const {
switch (this->target) {
case ADDRESS:
return "";
case CONTRACT:
return "profanity_transform_contract";
default:
throw "No kernel for target";
}
}

std::string Mode::transformName() const {
switch (this->target) {
case ADDRESS:
Expand All @@ -139,7 +128,7 @@ std::string Mode::transformName() const {
Mode Mode::leadingRange(const cl_uchar min, const cl_uchar max) {
Mode r;
r.name = "leadingrange";
r.kernel = "profanity_score_leadingrange";
r.kernel = "profanity_iterate_score_leadingrange";
r.data1[0] = min;
r.data2[0] = max;
return r;
Expand All @@ -148,13 +137,13 @@ Mode Mode::leadingRange(const cl_uchar min, const cl_uchar max) {
Mode Mode::mirror() {
Mode r;
r.name = "mirror";
r.kernel = "profanity_score_mirror";
r.kernel = "profanity_iterate_score_mirror";
return r;
}

Mode Mode::doubles() {
Mode r;
r.name = "doubles";
r.kernel = "profanity_score_doubles";
r.kernel = "profanity_iterate_score_doubles";
return r;
}
2 changes: 0 additions & 2 deletions Mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Mode {
std::string kernel;

HashTarget target;
// kernel transform fn name
std::string transformKernel() const;
// Address, Contract, ...
std::string transformName() const;

Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This project "profanity2" was forked from the original project and modified to g

Project "profanity2" is not generating key anymore, instead it adjusts user-provided public key until desired vanity address will be discovered. Users provide seed public key in form of 128-symbol hex string with `-z` parameter flag. Resulting private key should be used to be added to seed private key to achieve final private key of the desired vanity address (private keys are just 256-bit numbers). Running "profanity2" can even be outsourced to someone completely unreliable - it is still safe by design.

Note: when upgrading to a new version of profanity2, delete the `cache-opencl.*` files (or pass `--no-cache`) once so the OpenCL program is rebuilt with the new kernel.

## Getting public key for mandatory `-z` parameter

Generate private key and public key via openssl in terminal (remove prefix "04" from public key):
Expand Down Expand Up @@ -252,9 +254,6 @@ reported), and a very short mask can produce more matches per GPU round than the
buffer holds — the program prints a warning with the number of dropped matches if that
happens.

Note: if you have run an older version of profanity2 before, delete the `cache-opencl.*`
files (or pass `--no-cache`) once so the OpenCL program is rebuilt with the new kernel.

### Character classes anywhere (`--zeros`, `--letters`, `--numbers`)

Score on the total amount of matching characters anywhere in the address:
Expand Down Expand Up @@ -324,16 +323,17 @@ zeroth transaction** of the found account instead of the account address itself:
```

### Benchmarks - Current version
|Model|Clock Speed|Memory Speed|Modified straps|Speed|Time to match eight characters
|:-:|:-:|:-:|:-:|:-:|:-:|
|GTX 1070 OC|1950|4450|NO|179.0 MH/s| ~24s
|GTX 1070|1750|4000|NO|163.0 MH/s| ~26s
|RX 480|1328|2000|YES|120.0 MH/s| ~36s
|RTX 4090|-|-|-|1096 MH/s| ~3s
|Apple Silicon M1<br/>(8-core GPU)|-|-|-|45.0 MH/s| ~97s
|Apple Silicon M1 Max<br/>(32-core GPU)|-|-|-|172.0 MH/s| ~25s
|Apple Silicon M3 Pro<br/>(18-core GPU)|-|-|-|97 MH/s| ~45s
|Apple Silicon M4 Max<br/>(40-core GPU)|-|-|-|350 MH/s| ~12s
|Model|Clock Speed|Memory Speed|Speed|Time to match eight characters
|:-:|:-:|:-:|:-:|:-:|
|GTX 1070|1750|4000|225 MH/s| ~19s
|RTX 4090|2550|10500|1361 MH/s| ~3s
|RX 480|1328|4000|120 MH/s| ~36s
|RX 7900 XTX|2500|10000|592 MH/s| ~7s
|Apple Silicon M1<br/>(8-core GPU)|1278|4266|60 MH/s| ~72s
|Apple Silicon M1 Max<br/>(32-core GPU)|1296|6400|229 MH/s| ~19s
|Apple Silicon M2<br/>(10-core GPU)|1398|6400|75 MH/s| ~57s
|Apple Silicon M3 Pro<br/>(18-core GPU)|1398|6400|129 MH/s| ~33s
|Apple Silicon M4 Max<br/>(40-core GPU)|1800|8533|467 MH/s| ~9s

# License

Expand Down
4 changes: 2 additions & 2 deletions SpeedSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ double SpeedSample::getSpeed() const {

void SpeedSample::sample(const double V) {
const timepoint newTime = now();
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(newTime - m_lastTime).count();
m_lSpeeds.push_back((1000 * V) / delta);
auto delta = std::chrono::duration_cast<std::chrono::microseconds>(newTime - m_lastTime).count();
m_lSpeeds.push_back((1000000.0 * V) / delta);
m_lastTime = newTime;
if (m_lSpeeds.size() > m_length) {
m_lSpeeds.pop_front();
Expand Down
Loading