Skip to content

keyfinder --in fails with "invalid argument" if more than 16 addresses are loaded (MAX_TARGETS_CONSTANT_MEM limitation)Β #461

@toxxy

Description

@toxxy

🐞 Bug description

When using the --in option to load addresses from a file, keyfinder fails with the error:

[Info] Error: invalid argument

This happens consistently when the input file contains more than 16 Bitcoin addresses, even if all of them are valid and previously tested individually.


πŸ” Root Cause

After inspecting the source code, we found the following line in CudaHashLookup.cu:

#define MAX_TARGETS_CONSTANT_MEM 16

And later:

if (targets.size() <= MAX_TARGETS_CONSTANT_MEM) {
    return setTargetConstantMemory(targets);
} else {
    return setTargetBloomFilter(targets);
}

The logic is supposed to switch to a bloom filter automatically when more than 16 targets are provided. However, this transition silently fails and returns invalid argument.


βœ… Reproduction steps

  1. Create a file named addresses.txt with 17 valid Base58 Bitcoin addresses.

  2. Run:

    keyfinder --in addresses.txt
  3. Observe the error:

    [Info] Error: invalid argument
    
  4. Reduce the file to 16 addresses β†’ it works fine.


πŸ’‘ Expected behavior

  • keyfinder should properly fall back to bloom filter mode.
  • If any error occurs in that transition, it should print a clear message or fallback safely.
  • Ideally, it should log something like:
    [Warning] Input exceeds 16 constant memory targets; switching to bloom filter.
    

πŸ§ͺ Environment

  • OS: Linux (Ubuntu 22.04)
  • CUDA version: 12.0
  • GPU: NVIDIA RTX 2000 Ada
  • Build: Compiled from latest master using make BUILD_CUDA=1

πŸ› οΈ Workaround

By adding logging to the bloom filter logic, I verified that it does work correctly if the allocation and transfer succeed. After recompiling with minor logging fixes, it correctly loaded and processed over 100,000 addresses using the bloom filter mechanism.


❀️ Suggestion

I can submit a PR to improve the error messaging and add a note in the README for this hidden limitation.

Let me know if that would be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions