matoking / nanolib Goto Github PK
View Code? Open in Web Editor NEWPython library for working with the NANO cryptocurrency protocol
License: Creative Commons Zero v1.0 Universal
Python library for working with the NANO cryptocurrency protocol
License: Creative Commons Zero v1.0 Universal
Would it be possible to add the ability to solve work via a request `{"action": "work_generate", "hash": "HASH", "difficulty": "123"}' to a user given [IP]:port ?
RPC documentation: https://github.com/nanocurrency/nano-node/wiki/RPC-protocol#work-generate
This would add the ability to use nanolib with external servers like https://github.com/nanocurrency/nano-work-server
Functions like mnemonic_from_seed
and seed_from_mnemonic
would be pretty cool :)
Maybe this can be useful:
https://github.com/numsu/nanocurrency-web-js/blob/1134d96e28baa4096bfa63e8ae44fe6985993df6/lib/bip39-mnemonic.ts#L73
Thanks for this library, we've been using it for our service DPoW.
A few suggestions:
difficulty
rather than threshold
in every work related RPC, perhaps it would be good to change the semantics before the next major version update. See https://docs.nano.org/commands/rpc-protocol/#work_generateI can obviously use my own two small functions to accomplish this, but since this librar is so complete I thought I'd make the suggestion.
When trying install the wallet via the pip install pippin-wallet
command I am continuing the receive the follow error when attempting to build the wheel for nanolib fatal error C1083: Cannot open include file: 'sched.h': No such file or directory
.
I've updated all the compilers and headers for C/C++ in Visual Studio 2017, but am still running into the error. I'm using Git Bash but have run into the same error on the command line as well.
Hi,
Solving work takes 60+ seconds for me. Any idea what could cause this?
I am also very confused as to how you get to these benchmarks:
This based on a Ryzen 1800X giving the following results:
# avx speed: 6185344 hashes/s (this is likely the fastest on Intel CPUs)
# sse4_1 speed: 6259267 hashes/s
# ssse3 speed: 6249287 hashes/s
# sse2 speed: 4635929 hashes/s
# ref speed: 4539306 hashes/s
This is significantly faster than what I get when I run your benchmark (python setup.py speed
):
BLAKE2b PoW (avx) DEFAULT speed: 1653567 hashes/s
BLAKE2b PoW (sse4_1) speed: 1685205 hashes/s
BLAKE2b PoW (ssse3) speed: 1542921 hashes/s
BLAKE2b PoW (sse2) speed: 1195275 hashes/s
BLAKE2b PoW (ref) speed: 1448130 hashes/s
Account generation rate: 674 accounts/s
Block sign rate: 444 blocks/s
Block verify rate: 380 blocks/s
Unless you're using all cores for that? your benchmark is only single core though?
This is my CPU spec:
vendor_id : AuthenticAMD
cpu family : 23
model : 113
model name : AMD Ryzen 9 3950X 16-Core Processor
stepping : 0
microcode : 0x8701021
cpu MHz : 2200.000
cache size : 512 KB
physical id : 0
siblings : 32
core id : 0
cpu cores : 16
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 16
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sme sev sev_es
bugs : sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass
bogomips : 6989.22
TLB size : 3072 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate cpb eff_freq_ro [13] [14]
I can run nault.cc locally and send transactions every second or faster. So why the PoW generation so slow in nanolib?
The Nano node has been recently updated to version 21 (protocol v18), which sets up an updated, higher base difficulty for blocks. The network upgrade to reject blocks below the current difficulty will be performed using epoch blocks. For full details, refer to the documentation page on network upgrades , and the work generation guide.
In order to support the change by default for any clients using nanolib, it would be necessary to update the base difficulty to fffffff800000000
here at some point.
The difficulty is already an optional value to solving work though, and solve_work
has to be called explicitly. This means the flexibility for users of this library is already there, which is great.
pynanocurrency is just confusing, because you see it installed as pynanocurrency, but you must import nanocurrency to use it
or nanolib, something shorter to make using it faster
I have error:
Traceback (most recent call last):
File "test.py", line 14, in <module>
balance=10000000000000000000000000
File "/usr/local/lib/python3.7/dist-packages/nanolib/blocks.py", line 245, in __init__
setattr(self, key, value)
File "/usr/local/lib/python3.7/dist-packages/nanolib/blocks.py", line 83, in wrapper
setter(self, new)
File "/usr/local/lib/python3.7/dist-packages/nanolib/blocks.py", line 103, in wrapper
setter(self, val)
File "/usr/local/lib/python3.7/dist-packages/nanolib/blocks.py", line 116, in wrapper
setter(self, val)
File "/usr/local/lib/python3.7/dist-packages/nanolib/blocks.py", line 739, in set_previous
validate_public_key(previous)
File "/usr/local/lib/python3.7/dist-packages/nanolib/accounts.py", line 85, in validate_public_key
if len(public_key) != 64 or not is_hex(public_key):
TypeError: object of type 'property' has no len()
I think some function could be changed (or aliased for retrocompatibily reasons), like:
generate_account_private_key
-> derive_private_key
generate_account_id
-> derive_address
I don't know the lib very deeply, but I believe there are some other similar cases.
First, when I open https://github.com/Matoking/nanolib there's no place on the page saying how to import nanolib. I would suggest to put a line saying something like:
"Installation: If you are using Linux, open terminal and type pip install nanolib"
I encountered some errors when trying to: pip install nanolib
It was necessary to type this commands first:
sudo apt install build-essential
So, we need a list of requirements in nanolib github. Also, there nothing on documentation saying how to install it properly, or what is required to install before installing Nanolib.
Collecting nanolib
Using cached https://files.pythonhosted.org/packages/db/a8/af0f8110b7a40c65e10d0e0c635fc4b338bd9cd7e07d5b50cbee41c00202/nanolib-0.4.2.tar.gz
Collecting ed25519-blake2b>=1.4 (from nanolib)
Using cached https://files.pythonhosted.org/packages/1d/f1/035bafb5b2ed5b379abd4bf26ebad6e9fed73e21756971cefe027bd55ec2/ed25519-blake2b-1.4.tar.gz
Collecting py-cpuinfo>=4 (from nanolib)
Using cached https://files.pythonhosted.org/packages/f6/f5/8e6e85ce2e9f6e05040cf0d4e26f43a4718bcc4bce988b433276d4b1a5c1/py-cpuinfo-7.0.0.tar.gz
Installing collected packages: ed25519-blake2b, py-cpuinfo, nanolib
Running setup.py install for ed25519-blake2b ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-bmrg6xzj/ed25519-blake2b/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-v42xaj_n-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/ed25519_blake2b
copying src/ed25519/_version.py -> build/lib.linux-x86_64-3.6/ed25519_blake2b
copying src/ed25519/test_ed25519.py -> build/lib.linux-x86_64-3.6/ed25519_blake2b
copying src/ed25519/init.py -> build/lib.linux-x86_64-3.6/ed25519_blake2b
copying src/ed25519/keys.py -> build/lib.linux-x86_64-3.6/ed25519_blake2b
UPDATING build/lib.linux-x86_64-3.6/ed25519_blake2b/_version.py
set build/lib.linux-x86_64-3.6/ed25519_blake2b/_version.py to '1.4'
running build_ext
building 'ed25519_blake2b._ed25519' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
creating build/temp.linux-x86_64-3.6/src/ed25519-glue
creating build/temp.linux-x86_64-3.6/src/ed25519-supercop-ref
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/ed25519-supercop-ref -I/usr/include/python3.6m -c src/ed25519-glue/ed25519module.c -o build/temp.linux-x86_64-3.6/src/ed25519-glue/ed25519module.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-bmrg6xzj/ed25519-blake2b/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-v42xaj_n-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-bmrg6xzj/ed25519-blake2b/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.