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

PoW HardFork #2866

Merged
merged 19 commits into from Jun 12, 2019

Conversation

Projects
None yet
3 participants
@tromp
Copy link
Contributor

commented May 30, 2019

Grin's first mainnet hardfork!

From well before launch, Grin planned to hardfork every 6 month during the first 2 years.
This is pretty much a necessity for any chain with an ASIC-resistant PoW, as an immutable PoW
falls to ASICs sooner or later. Grin's GPU oriented PoW, Cuckaroo29, is no exception.

The PoW tweak was introduced in the Grin Forum post at https://www.grin-forum.org/t/mid-july-pow-hardfork-cuckaroo29-cuckarood29.

The crucial change in this PR is in function global::create_pow_context:

    match chain_type {
            // Mainnet has Cuckaroo(d)29 for AR and Cuckatoo30+ for AF
+           ChainTypes::Mainnet if edge_bits == 29 && valid_header_version(height, HeaderVersion::new(2))
+                                            => new_cuckarood_ctx(edge_bits, proof_size),
            ChainTypes::Mainnet if edge_bits == 29 => new_cuckaroo_ctx(edge_bits, proof_size),
            ChainTypes::Mainnet => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),

            // Same for Floonet
+             ChainTypes::Floonet if edge_bits == 29 && valid_header_version(height, HeaderVersion::new(2))
+                                            => new_cuckarood_ctx(edge_bits, proof_size),
            ChainTypes::Floonet if edge_bits == 29 => new_cuckaroo_ctx(edge_bits, proof_size),
            ChainTypes::Floonet => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),

in combination with a change in consensus::valid_header_version
that requires version 2 at heights [HARD_FORK_INTERVAL, 2 * HARD_FORK_INTERVAL) on mainnet and at heights [FLOONET_FIRST_HARD_FORK, 2 * HARD_FORK_INTERVAL) on flooonet,

with all other changes just putting up the necessary scaffolding to make this work.

If all goes well, then the first block with header version 2, at height WEEK_HEIGHT * 52/2 =
60247*26 = 262080, will roll around on Jul 17, and will have to be solved by either good old Cuckatoo31+, or by the new Cuckarood29. We will be able to test this a few weeks prior on Floonet.

Any nodes that fail to upgrade will not be able to advance to height 262080, as the current consensus::valid_header_version will simply return false. So there cannot actually be any chain split.
One side will advance, and the other will remain stuck until they upgrade as well.

The major work left to be done is in grin-miner. We may initially only offer a CUDA miner there as the CPU mean miner is an exceedingly complex beast.

Show resolved Hide resolved core/src/pow/cuckarood.rs Outdated
Show resolved Hide resolved core/src/pow/cuckarood.rs

quentinlesceller added a commit to blockcypher/libgrin that referenced this pull request May 30, 2019

Show resolved Hide resolved core/src/global.rs Outdated
Show resolved Hide resolved core/src/global.rs
@quentinlesceller

This comment has been minimized.

Copy link
Member

commented Jun 3, 2019

@tromp Can you fix the merge conflict?

@tromp

This comment has been minimized.

Copy link
Contributor Author

commented Jun 3, 2019

Fixed conflict.

@tromp

This comment has been minimized.

Copy link
Contributor Author

commented Jun 5, 2019

NOTE that while the PoW hardfork happens 32 days earlier on Floonet, at height 216000, it will still have version 1 headers. To make Floonet have version 2 headers at 216000 would require making consensus::valid_header_version dependent on CHAIN_TYPE...

quentinlesceller added some commits Jun 5, 2019

quentinlesceller added some commits Jun 5, 2019

@yeastplume yeastplume added this to the 2.0.0 milestone Jun 6, 2019

@quentinlesceller quentinlesceller changed the base branch from master to milestone/2.0.0 Jun 6, 2019

tromp added some commits Jun 6, 2019

move floonet early hardforking behaviour from global::create_pow_cont…
…ext to consensus::valid_header_version
Show resolved Hide resolved core/src/consensus.rs Outdated
@tromp

This comment has been minimized.

Copy link
Contributor Author

commented Jun 7, 2019

ok; moved it forward by a half day

tromp added some commits Jun 11, 2019

@yeastplume

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

It would seem these tests are hanging in the current commit:

test hard_forks ... ok
test test_secondary_pow_scale ... ok
test test_secondary_pow_ratio ... test test_secondary_pow_ratio has been running for over 60 seconds
test adjustment_scenarios ... test adjustment_scenarios has been running for over 60 seconds
test next_target_adjustment ... test next_target_adjustment has been running for over 60 seconds

@tromp tromp changed the title [WIP] PoW HardFork PoW HardFork Jun 12, 2019

@yeastplume

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

Odd... I ran CI again and it passed this time, but on a second local run I get a different set of tests hanging. Something definitely inconsistent here:

test test_secondary_pow_scale ... ok
test test_secondary_pow_ratio ... test test_secondary_pow_ratio has been running for over 60 seconds
test hard_forks ... test hard_forks has been running for over 60 seconds
test adjustment_scenarios ... test adjustment_scenarios has been running for over 60 seconds
test next_target_adjustment ... test next_target_adjustment has been running for over 60 seconds

@yeastplume yeastplume merged commit 6429580 into mimblewimble:milestone/2.0.0 Jun 12, 2019

10 checks passed

mimblewimble.grin Build #20190611.5 succeeded
Details
mimblewimble.grin (linux api/util/store) linux api/util/store succeeded
Details
mimblewimble.grin (linux chain/core/keychain) linux chain/core/keychain succeeded
Details
mimblewimble.grin (linux pool/p2p/src) linux pool/p2p/src succeeded
Details
mimblewimble.grin (linux release) linux release succeeded
Details
mimblewimble.grin (linux servers) linux servers succeeded
Details
mimblewimble.grin (macos release) macos release succeeded
Details
mimblewimble.grin (macos test) macos test succeeded
Details
mimblewimble.grin (windows release) windows release succeeded
Details
mimblewimble.grin (windows test) windows test succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.