chfast / ethash Goto Github PK
View Code? Open in Web Editor NEWC/C++ implementation of Ethash and ProgPoW – the Ethereum Proof of Work algorithms
License: Apache License 2.0
C/C++ implementation of Ethash and ProgPoW – the Ethereum Proof of Work algorithms
License: Apache License 2.0
Hi,
I am trying to understand ethash algo to make a cache and dag and pow to get the final golden nonce and hash.
I found some reference implementations in go language, but i am not familier with it.
is it possible to get a setp by step func or logic to get complete pow including dag generation logic and cache generation logic in python or c with actual blockheader or from block-explorer.
for mining here is so far i understand.
->pool will send a seed hash from which we need to determine block number.
-> from block number generate cache and dag
->pow(this i dont understand how it interacts with dag)
Mention ProgPoW in the description
The Init-Update-Final is common model for secure hash function. This useful e.g. in Ethereum networking.
See https://crypto.stackexchange.com/questions/52136/cryptographic-hasing-functions-init-update-final.
Huntered ethash in another Cmake project with cxx17 standard.
MSVC fails to compile due to warning (treated as error) C4211 triggered here https://github.com/chfast/ethash/blob/master/lib/ethash/builtins.h#L24-L37
openSUSE Tumbleweed, gcc 9.2.1
[ 39%] Building C object test/integration/compilation/CMakeFiles/test-compile-c90.dir/__/__/__/lib/ethash/keccak.c.o
cd /home/abuild/rpmbuild/BUILD/ethash-0.4.4/build/test/integration/compilation && /usr/bin/cc -I/home/abuild/rpmbuild/BUILD/ethash-0.4.4/include -fomit-frame-pointer -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=6 -g -DNDEBUG -O2 -g -DNDEBUG -pedantic -Werror -Wall -Wextra -Wconversion -Wsign-conversion -Wno-unknown-pragmas -fno-stack-protector -Wimplicit-fallthrough -mtune=generic -std=c90 -o CMakeFiles/test-compile-c90.dir/__/__/__/lib/ethash/keccak.c.o -c /home/abuild/rpmbuild/BUILD/ethash-0.4.4/lib/ethash/keccak.c
/home/abuild/rpmbuild/BUILD/ethash-0.4.4/lib/ethash/keccak.c: In function 'keccak':
/home/abuild/rpmbuild/BUILD/ethash-0.4.4/lib/ethash/keccak.c:89:5: error: integer constant is too large for 'long' type [-Werror=long-long]
89 | state[(block_size / word_size) - 1] ^= 0x8000000000000000;
| ^~~~~
cc1: all warnings being treated as errors
Can you provide some more detail on the commands needed to get the WASI build to compile? I installed the WASI SDK following the steps from the circle.yml
section on WASI and also just tried cmake -DTOOLCHAIN=wasm32-wasi
and it doesn't compile anything. I'm completely new to cmake and compiling anything to WASM and have spent a fair bit of time trying to understand how to do this but nothing seems to work.
I'm a little bit confused, does the ethereum/ethash project be deprecated?
When trying to install on python, I get this error:
Creating library build\temp.win32-3.9\Release\build\temp.win32-3.9\Release\_ethash.lib and object build\temp.win32-3.9\Release\build\temp.win32-3.9\Release\_ethash.exp
_ethash.obj : error LNK2001: unresolved external symbol _ethash_keccak512
_ethash.obj : error LNK2001: unresolved external symbol _ethash_hash
_ethash.obj : error LNK2001: unresolved external symbol _ethash_verify_against_boundary
_ethash.obj : error LNK2001: unresolved external symbol _ethash_keccak256
_ethash.obj : error LNK2001: unresolved external symbol _ethash_get_global_epoch_context
build\lib.win32-3.9\_ethash.pyd : fatal error LNK1120: 5 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x86\\link.exe' failed with exit code 1120
Could anyone help me out?
I've been trying to figure out which library to use for the Keccak algorithm. How is this different to https://github.com/ethereum/ethash? I thought that was the library being used by cpp-ethereum but it turns out it is this one instead?
Thanks for any info
I am studying "aleth" in "windows 10 pro" environment.
However, I am worried about the following error during the build.
"C:.hunter_Base\c4cfcc0\e941b8e\402d68a\Build\ethash\Source\lib\ethash\progpow.cpp"
Since this file(progpow.cpp) is only UTF-8 encoded, the following error occurs.
All other files are ANSI encoded.
Please correct this problem.
[hunter ** FATAL ERROR **] Build step failed (dir: C:/.hunter/_Base/c4cfcc0/e941b8e/402d68a/Build/ethash
[hunter ** FATAL ERROR **] [Directory:C:/.hunter/_Base/Download/Hunter/0.23.44/c4cfcc0/Unpacked/cmake/projects/ethash]
I want to make a Python package for verifying an ETC mining shares.
Tried to integrate ECIP-1099: https://ecips.ethereumclassic.org/ECIPs/ecip-1099
I looked at the repository which already tried to do this: https://github.com/etclabscore/cpp-etchash
My same attemp here: andrei-kondakov@2699d03
Etclabscore and my solution don't work on this case of real mining ETC share:
import unittest
import ethash
class TestEthash(unittest.TestCase):
epoch_number = 493 # (we used old epoch here: 493 like in ETH?, real is 246)
nonce = 0x4f29c0e5dc784d8b
header_hash = bytes.fromhex(
'32d6c83f7fc493aa224a8fcc3ac007e6113d28ed70717e7d5a7505d72d4bdd7f')
mix_hash = bytes.fromhex(
'b27518ae34f7e81c56a4dedb81df93c4d4301d90643678044b3445ded0b331ce')
final_hash = bytes.fromhex(
'000000016454ac15829b7d6158f4be151ba9a9aa42e905153c7c43f211decb9f')
def test_hash(self):
f, m = ethash.hash(self.epoch_number, self.header_hash, self.nonce)
print(f.hex()) # <- 8a678cdfc607962405f0f543b9a3a046072079d197b4e364be04f2cd175ab31f
print(m.hex()) # <- 3d93eb7ff453d852bf95e98e6c73ab92f64628a7c1e3f3b4110f80970a0af96d
self.assertEqual(m, self.mix_hash) # fail
self.assertEqual(f, self.final_hash) # fail
Whats wrong here? How to integrate ECIP-1099 correctly?
Thanks!
The search() function is not useful, because it does not return the mix and final hash. Extend result
type with nonce and return it from search()
.
I have try to build this repository, in win10.
cmake ..
cmake --build .
has several error or link errors.
So, I've tried following way , on ethminer builds.
cmake .. -G "Visual Studio 15 2017 Win64" -T v140
cmake --build . --config Release
will compile well for generate library.
CMake Error at CMakeLists.txt:229 (message):
Failed to determine the source files for the regular expression backend
-- Configuring incomplete, errors occurred!
See also "/home/IC/.hunter/_Base/18e57a4/c197bbe/5c48e6d/Build/benchmark/Build/benchmark-Release-prefix/src/benchmark-Release-build/CMakeFiles/CMakeOutput.log".
See also "/home/IC/.hunter/_Base/18e57a4/c197bbe/5c48e6d/Build/benchmark/Build/benchmark-Release-prefix/src/benchmark-Release-build/CMakeFiles/CMakeError.log".
gmake[2]: *** [benchmark-Release-prefix/src/benchmark-Release-stamp/benchmark-Release-configure] Error 1
gmake[1]: *** [CMakeFiles/benchmark-Release.dir/all] Error 2
gmake: *** [all] Error 2
[hunter ** FATAL ERROR **] Build step failed (dir: /home/IC/.hunter/_Base/18e57a4/c197bbe/5c48e6d/Build/benchmark
[hunter ** FATAL ERROR **] [Directory:/home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/projects/benchmark]
CMake Error at /home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/modules/hunter_error_page.cmake:12 (message):
Call Stack (most recent call first):
/home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/modules/hunter_fatal_error.cmake:20 (hunter_error_page)
/home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/modules/hunter_download.cmake:617 (hunter_fatal_error)
/home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/projects/benchmark/hunter.cmake:32 (hunter_download)
/home/IC/.hunter/_Base/Download/Hunter/0.23.224/18e57a4/Unpacked/cmake/modules/hunter_add_package.cmake:62 (include)
test/benchmarks/CMakeLists.txt:5 (hunter_add_package)
-- Configuring incomplete, errors occurred!
See also "/home/IC/ethash/test/chfast/ethash/build/CMakeFiles/CMakeOutput.log".
See also "/home/IC/ethash/test/chfast/ethash/build/CMakeFiles/CMakeError.log".
In build_light_cache() function, the address of variable `cache' changes in each loop
for (int i = 0; i < num_items; ++i)
{
const uint32_t index_limit = static_cast<uint32_t>(num_items);
// Fist index: 4 first bytes of the item as little-endian integer.
const uint32_t t = le::uint32(cache[i].word32s[0]);
const uint32_t v = t % index_limit;
// Second index.
const uint32_t w = static_cast<uint32_t>(num_items + (i - 1)) % index_limit;
cache[i] = keccak512(bitwise_xor(cache[v], cache[w]));
}
In particular, for i=0, cache[0] is the first element of array cache (as expected). However, for i=1, cache[0] is the second element of array cache, and for i=2, cache[0] is the third element of array cache, ...
By observing the address of cache, I found that the address of cache changes each time when arriving at
" const uint32_t t = le::uint32(cache[i].word32s[0]);".
As a result, the generated cache is different from that generated in go-ethereum.
hi all~
I have the following a problems.
https://github.com/ruslo/hunter/issues/1716
help me.
have a nice day~
When I link the libethash.a ,I get the following errors
/usr/bin/ld: //usr/local/lib/libethash.a(ethash.cpp.o): relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
//usr/local/lib/libethash.a: error adding symbols: Bad value
Actually method verify only returns true
if verification is success or false
otherwise.
Would be nice to have a return code instead to assert
A nice to have feature would be to have the computation of hash256 boundary from the difficulty value as specified in block header
In gexp we made these changes
expanse-org/go-expanse@5433a50
The idea is after a predetermined epoch switch from hashimoto to frankomoto.
Frankomoto and Hashimoto are similar except that instead of Keccak512 and Keccak256 it uses Sha512 and Sha512_256.
@chfast Hello!
I want to upload a new package version (0.9.0-alpha.0) on PyPi.
I made a fork of the repository with following changes: andrei-kondakov@633cdc7.
I renamed the package name to ethash2 in my fork and add myself as maintainer of this package. I did not change the author parameter, you are still listed there. Is it okay?
I want to use this package on ubuntu 20.04 later.
I'm creating a wheel on a Mac (m1) and got following error during upload to pypi:
(venv) andrei@m1 ethash % pip install twine
...
(venv) andrei@m1 ethash % python setup.py bdist_wheel
....
(venv) andrei@m1 ethash % twine upload -r testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
InvalidDistribution: Unknown distribution format: 'include'
Can u tell me how you published the package on PyPI?
Thank you!
The final hash verification is
final_hash <= 2^256 / difficulty
The current verify() API takes boundary = 2^256 / difficulty
instead of difficulty
. The boundary
is commonly used in mining for efficiency. However, for block hash verification this is not optimal because clients have to compute 2^256 / difficulty
inversion for every block hash.
We propose to add additional function which takes difficulty
argument directly: verify_against_difficulty()
.
Internally, we can perform much more efficient check:
final_hash * difficulty <= 2^256
This has been tested and the formula is also valid for difficulty 0 and 1.
We also propose to rename verify()
to verify_against_boundary()
to disambiguate.
And change verify_final_hash()
to verify_final_hash_against_difficulty()
as this function is suppose to be used for quick block hash verification.
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.