Skip to content
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

Change PoW to Equihash #15

Merged
merged 21 commits into from
Oct 19, 2017
Merged

Change PoW to Equihash #15

merged 21 commits into from
Oct 19, 2017

Conversation

h4x3rotab
Copy link
Member

@h4x3rotab h4x3rotab commented Sep 20, 2017

This ongoing PR changes the PoW to Equihash. The implementation of Equihash is taken from Zcash project.

It will include the following modifications:

  • Link sodium for Equihash library
  • Extend block header to include Equihash solution
    • Embed Equihash related consensus parameters
    • Introduce a new block version
    • Add Equihash solution field to block header
    • Legacy node serialization compatibility
    • Be Zcash miner compatible
  • Change PoW after fork height
    • Add PoW functions
    • Introduce Equihash block validation for the hard fork
    • Fix mining RPCs
  • Fix rest RPCs
  • Tests
    • Unittest everywhere
    • Regression test
  • Fix compact block

Tested:
make (macOS 10.12.5, Xcode 8.3.3)
Protocol version: 70016 (BTG_HARD_FORK_VERSION)
Version bits: 0x60000000
- Add two new fields: nHeight, nSolution (for Equihash)
- Calculate block hash in new block format after the hard fork.
- Serialize block in legacy format when talking to Bitcoin node.

Tested:
unittest
@h4x3rotab
Copy link
Member Author

Compact block is broken by new block format. Seems we have to fix it.

Tested:
./autogen.sh && make
- Initialize sodium on startup
- Add Equihash validation logic
- Fix missing htole32 problem in mingw build.
@sennevb
Copy link

sennevb commented Oct 4, 2017

Watching this one closely, interested to add this coin to the pool on launch..

@daira
Copy link

daira commented Oct 5, 2017

(Zcash developer here.)

Zcash will also need to add compact blocks. We haven't thought about it much yet but our ticket for that is https://github.com/zcash/zcash/issues/2316 . Let's cooperate on a spec.

- Serialize in different formats based on the net protocol version.
- Remove the version bit 0x40000000.
- Support legacy block format for RPCs: getblock, getblockheader, getblocktemplate, submitblock.
- Temporarily disable SEND_CMPT.

Tested:
unit tests
Intended broken testes:
- p2p-compactblocks.py
- rest.py

Tested:
reg tests.
src/net.h Outdated
@@ -833,6 +830,8 @@ class CNode
std::string GetAddrName() const;
//! Sets the addrName only if it was not previously set
void MaybeSetAddrName(const std::string& addrNameIn);

bool IsLeacyBlockHeader(int version) { return version < BTG_HARD_FORK_VERSION; };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in function name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

- Add fields to block header for Zcash compatibility
- Extend the nonce from `uint32_t` to `uint256`
- Add 'nonceUint32' for backward compatibility:
  - RPC: 'getblockheader', 'getblock'
  - Rest: '/rest/headers', '/rest/block'

Tested:
./src/test/test_bitcoin
./test/functional/test_runner.py
(all passed except intended failures: p2p-compactblocks.py, rest.py)
@antonifigueiredo
Copy link

Boa tarde, qual a previsão de Exchange terá o BTG? (BITCOINGOLD)?

Also add a test to ensure Zcash compability.

Tested:
./src/test/test_bitcoin --run_test=btg_tests
Tested:
./src/test/test_bitcoin --run_test=sanity_tests
Tested:
./src/test/test_bitcoin --run_test=equihash_tests
- RPC
  - generate
  - generatetoaddress
  - getblocktemplate
- Add regtest `btg-hardfork.py`

Tested:
./src/test/test_bitcoin
./test/functional/test_runner.py
@h4x3rotab
Copy link
Member Author

It's time to do mining tests. No way to do it in a regular regression test as there's no existing Equihash solver in Python.

@peter-bonanni
Copy link

@h4x3rotab

https://github.com/str4d/zcash-pow

Isn't this an Equihash python solver?

@oliverw
Copy link

oliverw commented Oct 18, 2017

@h4x3rotab Is the daemon ready for pool integration now?

@h4x3rotab
Copy link
Member Author

h4x3rotab commented Oct 19, 2017

This change should be further tested but for now let's merge it to the staging tree. I will create another issue to track the process of PoW changes & tests.

Will submit after it passes TravisCI check.

@h4x3rotab h4x3rotab merged commit 2f5fe4c into BTCGPU:master Oct 19, 2017
@h4x3rotab h4x3rotab changed the title [WIP] Change PoW to Equihash Change PoW to Equihash Oct 19, 2017
h4x3rotab pushed a commit to h4x3rotab/BTCGPU that referenced this pull request May 6, 2018
64052c76c5 Merge BTCGPU#15: Add filename to corruption errors
135ed0fb4e Add filename to corruption errors

git-subtree-dir: src/leveldb
git-subtree-split: 64052c76c567cff3dad32d1db0ef969d97b5882f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants