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

[PoS] Stake Modifier V2 #983

Merged
merged 38 commits into from
Aug 26, 2019

Conversation

random-zebra
Copy link

@random-zebra random-zebra commented Aug 14, 2019

This pull request defines a new 256-bit modifier for the proof of stake protocol, CBlockIndex::nStakeModifierV2.
It is computed at every block, by taking the hash of the modifier of previous block along with the coinstake input.
To meet the protocol, the PoS kernel must comprise the modifier of the previous block.

Enforcement height is set at 1214000 for testnet and 1967000 for mainnet.

This also includes upgrades to PROTOCOL_VERSION (to 70917) and to block version (to version 6) and disables 0-fee transactions.

Copy link

@CaveSpectre11 CaveSpectre11 left a comment

Choose a reason for hiding this comment

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

more in depth later; lunch break is over

src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
src/chain.h Show resolved Hide resolved
@Mrs-X
Copy link

Mrs-X commented Aug 14, 2019

On a first view looks good, even when

    // switch with old modifier on upgrade block
    if (pindexPrev->nStakeModifierV2 == uint256() && pindexPrev->nStakeModifier)

(in my opinion) is unnecessary hard to verify/understand (you have to lookup those assumptions in chain.h) instead of simply using the block height of the upgrade block.

Copy link

@Warrows Warrows left a comment

Choose a reason for hiding this comment

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

Looks okay.

@random-zebra random-zebra force-pushed the 2019_new_stakeModifier branch 2 times, most recently from 215f3c4 to 6106e53 Compare August 17, 2019 01:31
@furszy furszy added this to the 3.4.0 milestone Aug 23, 2019
random-zebra and others added 17 commits August 24, 2019 15:01
[Cleanup] Remove unused 'GetWeight()' function

[Cleanup] Remove unneeded variables
also there's no need to count mints and spends here
other redundancies.

[PoS][Refactor] CPivStake, caching data + removing redundant method
calls.

[PoS] Fix error in nSelectionIntervalStart integer division
…s nStakeMinAgeV2Modifier and nMaturityV2Modifier.
require it to be nStakeMinDepth deep instead of nStkaMinAge old.
[SQUASH] Fix nTimeTx bug in Stake()
the block under review.

[PoS] CheckProofOfStake, stop searching a block on disk when it's
absolutely not needed.
 * Not used variable nTargetTimespan in chainParams removed.
[SQUASH] Cleanup proof-of-stake debug log
[PoS] cleaning not used stakeTargetHit method + fixing bad nHeight in
the new compute modifier method.
furszy and others added 8 commits August 24, 2019 15:19
…ckIndex and not in the chainActive and look for it based on the next block hash and not based on height.

    * Contextual zPIV stake, invalid height contextual check, using tip instead of prev height + 1.
… the near future (4.0) and the code will be fully refactored soon.

          // This is just a quick inline towards that goal, the mempool by default will not accept them. Blocking
          // any subsequent network relay.

[SQUASH] Permitting free txes only in regtest.
conditional log output in kernel.cpp functions can use the global fDebug variable instead of their own.
Also add help description for new keys
@random-zebra random-zebra changed the title [WIP] - [PoS] Stake Modifier V2 [PoS] Stake Modifier V2 Aug 25, 2019
@random-zebra random-zebra added Block Generation Mining/Staking related issues Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes Protocol-Update Validation labels Aug 25, 2019
Fuzzbawls added a commit to Fuzzbawls/PIVX that referenced this pull request Aug 26, 2019
Built on top of PIVX-Project#983, this adds the enforcement logic for 70917 and also
updates the spork key.
Fuzzbawls added a commit to Fuzzbawls/PIVX that referenced this pull request Aug 26, 2019
Built on top of PIVX-Project#983, this adds the enforcement logic for 70917 and also
updates the spork key.
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK bf16514

Copy link

@Mrs-X Mrs-X left a comment

Choose a reason for hiding this comment

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

utACK bf16514

Fuzzbawls added a commit that referenced this pull request Aug 26, 2019
bf16514 [Consensus] New modifier enforcement height changed for mainnet (random-zebra)
6b6ef32 Don't load old stake modifier from disk after changeover height (Fuzzbawls)
d085ed0 [Consensus] Fix old block version check (including v.6) (random-zebra)
b1416f5 [Tests] fix blocks/maturity fakestake_accepted (random-zebra)
c212587 [PoS] fix regtest nBlockStakeModifierlV2 and cbase maturity (random-zebra)
dddca50 Use better JSON key names in block coinstake output (Fuzzbawls)
2835111 Don't shadow global fDebug (Fuzzbawls)
85fa96e [Consensus] New modifier enforcement height set. (furszy)
a74f6cf [GUI] sendCoinsdialog, removing zero tx fee checkbox and label. (furszy)
6a33fff [Mempool] // As zero fee transactions are not going to be accepted in the near future (4.0) and the code will be fully refactored soon.           // This is just a quick inline towards that goal, the mempool by default will not accept them. Blocking           // any subsequent network relay. (furszy)
6c69cfe [PoS] * GetKernelStakeModifier, look for the next block in the mapBlockIndex and not in the chainActive and look for it based on the next block hash and not based on height.     * Contextual zPIV stake, invalid height contextual check, using tip instead of prev height + 1. (furszy)
d3db3e6 [PoS] Stake(): Add check for staked blocks in the future (random-zebra)
f8777c6 [Refactor] Add future block time drift to chainparams (random-zebra)
8c7522b [PoS] Compute old modifier, invalid integer division removal plus extra logging for the stake modifier height added. (furszy)
beaba47 [RPC] getblock, validate that PoS blocks to return the coin stake data. (furszy)
81446bb [PoS][RPC] getblock command, adding more information about the coin stake tx. (furszy)
820e08c [PoS][RPC][Refactor] GetHashProofOfStake and initStakeInput methods created, better method responsibility division from the CheckStakeKernelHash to be able to get the information for the getblock rpc command and possible future tests. (furszy)
4d5cc97 [Wallet] Staking, unreacheable code removed.. (furszy)
41ccf6b [PoS][Wallet] CreateCoinStake, if the block is from the future then start on a future time. (furszy)
ffb0dd5 [Trivial] logging, removing none required jump lines. (furszy)
843dc56 [PoS] Allign ComputeStakeModifier (v2) to nHeight logic (random-zebra)
4c24934 [PoS] read/write block index modifier based on height and not block version. (furszy)
6297e77 [Core] Introduce Blocks version 6 (random-zebra)
b8c59ae [PoS] CheckStakeKernelHash, was checking the previous block instead of the block under review. (furszy)
0d31ac2 [Wallet] HasMintableCoins, don't call GetAdjustedTime on every cycle of the loop. (furszy)
d94931f [Trivial] Add logs to CheckKernelHash (random-zebra)
eab9944 version bumped (furszy)
117f815 [PoS] New logic for stake input maturity (random-zebra)
d805952 [Wallet] SelectStakeCoins using block time and fix GetBlocksToMaturity (random-zebra)
01ed69a [PoS] Remove extra nTime check in Stake() (random-zebra)
74d85c2 [Refactor][PoS] Do not calculate the prevBlock medianTimePast on every cycle of the CreateCoinStake loop. (furszy)
a48a7a5 [Trivial] Compiler warning, uint_32 compared against int. (furszy)
e9c07d0 [Consensus] V2 modifier protocol change, two new fields in chainparams nStakeMinAgeV2Modifier and nMaturityV2Modifier. (furszy)
3b97fc0 [PoS] Cleaning GetStakeModifierSelectionInterval() constant method + other redundancies. (furszy)
3c1fd7a [PoS] Stake Modifier V2 (random-zebra)
f73a27f [Core] Do not check block if it's not the one needed (random-zebra)
1e4c864 [Cleanup] Clean error messages in CheckBlock (random-zebra)
401a986 [Consensus] Placeholder block height for modifier V2 enforcement (random-zebra)

Pull request description:

  This pull request defines a new 256-bits modifier for the proof of stake protocol, `CBlockIndex::nStakeModifierV2`.
  It is computed at every block, by taking the hash of the modifier of previous block along with the coinstake input.
  To meet the protocol, the PoS kernel must comprise the modifier of the previous block.

  Enforcement height is set at 1214000 for testnet and 1967000 for mainnet.

  This also includes upgrades to `PROTOCOL_VERSION` (to 70917) and to block version (to version 6) and disables 0-fee transactions.

ACKs for top commit:
  Fuzzbawls:
    ACK bf16514
  Mrs-X:
    utACK bf16514

Tree-SHA512: 02fdcf1515b0b5571ef6c6eb9bf61429841e51b7372de50990bb4b58704030ebe9cc869ff896f507731cfa3f6a90ada25a4f71800f863dfc05b222368cafbbf0
@Fuzzbawls Fuzzbawls merged commit bf16514 into PIVX-Project:master Aug 26, 2019
Fuzzbawls added a commit to Fuzzbawls/PIVX that referenced this pull request Aug 26, 2019
Built on top of PIVX-Project#983, this adds the enforcement logic for 70917 and also
updates the spork key.
Fuzzbawls added a commit that referenced this pull request Aug 26, 2019
… keys

ce8dccb [Net] Protocol update enforcement for 70917 and new spork keys (Fuzzbawls)

Pull request description:

  Built on top of #983, this adds the enforcement logic for 70917 and also
  updates the spork key.

Top commit has no ACKs.

Tree-SHA512: bde4ebea833acf746b838e354e8c5be55376ea4657e8b02874f958e6a43f4b5ae087051e7df0f76e455625558c56e7fb35bd9d01a3645b1dfc10bb14b48ad5ac
Copy link

@Warrows Warrows left a comment

Choose a reason for hiding this comment

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

ACK

src/kernel.cpp Show resolved Hide resolved
@Fuzzbawls Fuzzbawls removed the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Dec 8, 2019
CaveSpectre11 pushed a commit to CaveSpectre11/PIVX that referenced this pull request Dec 14, 2019
Built on top of PIVX-Project#983, this adds the enforcement logic for 70917 and also
updates the spork key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants