-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bounty] Faster address generation #377
Comments
Also try |
Yes it is 50% faster Average time for an address 0.000350296974182 . Thanks ! Anyway to achieve further speed. Not sure what are the mathematical limits
|
The main operations in Not sure what your application is here, but it might suffice for you to operate & on or store public key hashes, which are 20 bytes blobs, and only convert to an address when it's time to show them to a human. If you're doing vanity key generation, you could convert the vanity key limits from base58 to hashes and simply ensure that the hash is in that range. |
Thanks our main function is to display balance / history of xpub like this so we need the bitcoin address. I was wondering if there is any c extension of python/hardware accelerated library that does faster base58 encoding |
@shivaenigma are you still interested in this? |
Yes of course ! It is possible to achieve a further speed this up ? Feel free to also mail me |
I hacked a bit on In the past couple years, I've become expert at writing python extensions in rust thanks to pyo3 so I have a small prototype that speeds up b58 encoding up by 5-10x here https://github.com/richardkiss/pycoin_rs It looks like you are doing key derivation as well, so there are quite a few steps in the pipe that could be improved. Have you done any profiling to see what the slowest part is? |
Take a look at
https://github.com/richardkiss/pycoin_rs/blob/main/tests/test_bip32_derivation.py
for an example on how to use the new wheel `pycoin_rs` to derive lots of
addresses quickly. It even uses multiple cores (releasing the GIL) if more
than 32 paths are included.
Lots of rough edges still, including no error handling (just panics, so you
can't really deploy in production without doing careful pre-screening of
parameters), but I'd love to hear feedback. I can get binary wheels on pypi
fairly easily.
Richard
…On Mon, Nov 28, 2022 at 3:07 AM shivaenigma ***@***.***> wrote:
Yes of course ! It is possible to achieve a further speed this up ? Feel
free to also mail me
—
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABJWHD7MWFTLGJWCEJIRLWKSG5DANCNFSM4YMMQWSQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, richard. I was following this thread, and try to derivate keys and addresses. I forked your repo, and then merged master into b58-optimization to solve bip_as_sting issue. then run b58 branch. I got the same amount of time compare to master branch, am I missing something? and using secp256k1 as pycoin native: my test script was the same with shivaenigma as below:
|
The change I made to the Try the api in the new
On my MacBook Air M2, it generates 100000 children in 0.85 s, and does the b58-encoding in another 0.05 s. Being able to use multithreading when python can't is a huge win. |
well done, I checked and compared pycoin_rs with pycoin master branch and it boosts the speed 15x faster.
The Result: But, it seems doesn't support python 2.7 as maturin package requires python > 3.7 |
Yes, it will never support 2.7. In fact, I'm considering dropping py2 support for pycoin too. |
Thank you Richard. I know rust is a fast programming language in performance, but I am just curious isn't C++ faster than rust? and what was your motivation choosing rust over C++? |
I've disliked C++ for quite some time now, and had fallen behind in following the language. I was not able to read modern idiomatic C++ very easily. A couple years ago, I started learning rust to port clvm from python to rust here https://github.com/Chia-Network/clvm_rs and my admiration for the language has only grown since then. It includes a build and module system, which are two things that prevent the C++ ecosystem from being usable. |
Currently we are getting average 0.000709s . Our code is on master branch commit 6a8b7c.
Is there anyway to further speed this up?
We need to generate thousand addresses in around 0.001-0.01s. Happy to sponsor the work required for this in BTC
The text was updated successfully, but these errors were encountered: