Skip to content

Conversation

@random-zebra
Copy link

@random-zebra random-zebra commented Feb 20, 2020

Second part of

Split as individual PR for ease of review.

@random-zebra random-zebra added this to the 4.1.0 milestone Feb 20, 2020
@random-zebra random-zebra self-assigned this Feb 20, 2020
Fuzzbawls added a commit that referenced this pull request Feb 22, 2020
64465b7 [Refactor] Consensus: Stake Modifier V2 (random-zebra)
8083725 [Refactor] Consensus: TimeProtocolV2 parameters (random-zebra)
4d1c696 [Refactor] Consensus: nStakeMinAge, nStakeMinDepth, nFutureTimeDrift (random-zebra)
e69cee2 [Refactor] Consensus: restore nMaxMoneyOut as consensus param (random-zebra)
08a581d [Refactor] Consensus: fAllowMinDifficultyBlocks, fPowNoRetargeting (random-zebra)
ca6ea3c [Refactor] Consensus: nTargetTimespan, nTargetSpacing, nTimeSlotLength (random-zebra)
a281dee [Refactor] Consensus: remove unneeded getters. Rename BIP65Height (random-zebra)
284271c [Refactor] Consensus: bnProofOfWorkLimit / bnProofOfStakeLimit (v1-v2) (random-zebra)

Pull request description:

  This PR builds on
  - [x] #1328

  Populates the `consensus` struct with all relevant consensus parameters.
  Resets `nMaxMoneyOut` as chain param (with different value for TestNet).
  Cleans up several unneeded fields in ChainParams.

  EDIT: Current PR has been split in two. Second part is #1344

ACKs for top commit:
  furszy:
    good, utACK 64465b7.
  Fuzzbawls:
    utACK 64465b7

Tree-SHA512: d3e46bc8bb2ad9ee48abcbc4d4b1df2f59914360aaca72e93e19a5578248ecb95fd6a422477238e4736bc767d4e226f5b7f867174d96dcace73621946bf84df8
@random-zebra
Copy link
Author

Rebased after merge of #1341

@random-zebra
Copy link
Author

Rebased after merge of #1338

- nZerocoinStartHeight
- nBlockZerocoinV2
- nBlockEnforceSerialRange
- nBlockRecalculateAccumulators
- nBlockFirstFraudulent
- nBlockLastGoodCheckpoint (removed)
- nModifierUpdateBlock
- nFakeSerialBlockheightEnd
- nBlockEnforceInvalidUTXO
- nBlockDoubleAccumulated (removed)
- nPublicZCSpends
- nBlockEnforceNewMessageSignatures
- nBlockV7StartHeight (removed)
- nBlockLastAccumulatorCheckpoint
@random-zebra
Copy link
Author

Rebased after merging #1342

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.

Commit e253c7f2491316708e41cf944a3fb2c48386a9f4 results in testnet halting sync at block 201 due to the invalid nBits (referenced in #915). The changes here only take mainnet into consideration so need to add the testnet values back.

Suggested patch:

Index: src/chainparams.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/chainparams.cpp	(revision 4d721223520870d03e44cd1df256f4fe76daa700)
+++ src/chainparams.cpp	(date 1582681779760)
@@ -197,8 +197,8 @@
         consensus.height_ZC_RecalcAccumulators = 908000;
 
         // validation by-pass
-        consensus.blk_259201_nTime = 1471401614;    // Skip nBit validation of Block 259201 per PR #915
-        consensus.blk_259201_nBits = 0x1c056dac;    // Skip nBit validation of Block 259201 per PR #915
+        consensus.nPivxBadBlockTime = 1471401614;    // Skip nBit validation of Block 259201 per PR #915
+        consensus.nPivxBadBlockBits = 0x1c056dac;    // Skip nBit validation of Block 259201 per PR #915
 
         // Zerocoin-related params
         consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784"
@@ -319,6 +319,10 @@
         consensus.height_start_ZC_SerialsV2 = 444020;
         consensus.height_ZC_RecalcAccumulators = 999999999;
 
+        // validation by-pass
+        consensus.nPivxBadBlockTime = 1489001494; // Skip nBit validation of Block 201 per PR #915
+        consensus.nPivxBadBlockBits = 0x1e0a20bd; // Skip nBit validation of Block 201 per PR #915
+
         // Zerocoin-related params
         consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784"
                 "4069182906412495150821892985591491761845028084891200728449926873928072877767359714183472702618963750149718246911"
Index: src/consensus/params.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/consensus/params.h	(revision 4d721223520870d03e44cd1df256f4fe76daa700)
+++ src/consensus/params.h	(date 1582681711334)
@@ -69,8 +69,8 @@
     int height_ZC_RecalcAccumulators;
 
     // validation by-pass
-    int64_t blk_259201_nTime;
-    unsigned int blk_259201_nBits;
+    int64_t nPivxBadBlockTime;
+    unsigned int nPivxBadBlockBits;
 
 
     int64_t TargetTimespan(const bool fV2 = true) const { return fV2 ? nTargetTimespanV2 : nTargetTimespan; }
Index: src/main.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main.cpp	(revision 4d721223520870d03e44cd1df256f4fe76daa700)
+++ src/main.cpp	(date 1582681711329)
@@ -3854,8 +3854,8 @@
     if (block.nBits != nBitsRequired) {
         // Pivx Specific reference to the block with the wrong threshold was used.
         const Consensus::Params& consensus = Params().GetConsensus();
-        if ((block.nTime == (uint32_t) consensus.blk_259201_nTime) &&
-                (block.nBits == (uint32_t) consensus.blk_259201_nTime)) {
+        if ((block.nTime == (uint32_t) consensus.nPivxBadBlockTime) &&
+                (block.nBits == (uint32_t) consensus.nPivxBadBlockBits)) {
             // accept PIVX block minted with incorrect proof of work threshold
             return true;
         }

@random-zebra
Copy link
Author

random-zebra commented Feb 26, 2020

@Fuzzbawls good catch. Fixed in 98494ab

- zerocoinModulus
- nMaxZerocoinSpendsPerTransaction
- nMaxZerocoinPublicSpendsPerTransaction
- nMinZerocoinMintFee
- nMintRequiredConfirmations
- nRequiredAccumulation (removed)
- nDefaultSecurityLevel (removed)
- nZerocoinHeaderVersion (removed)
- nZerocoinRequiredStakeDepth
- nZerocoinStartTime
- nMasternodeCountDrift
- nBudgetCycleBlocks
- nProposalEstablishmentTime
- nBudget_Fee_Confirmations
- nStartMasternodePayments (removed)
- strObfuscationPoolDummyAddress
- nPoolMaxTransactions
+ spork keys handling
- nPivxBadBlockTime / nPivxBadBlocknBits
- nInvalidAmountFiltered (moved outside chain params)
- nMinColdStakingAmount (moved outside chain params)
- fHeadersFirstSyncingActive (removed)
- fTestnetToBeDeprecatedFieldRPC (removed)
- fSkipProofOfWorkCheck (removed - use IsRegTestNet)
- fRequireStandard (removed - use IsRegTestNet)
- fDefaultConsistencyChecks (removed - use IsRegTestNet)
- fMiningRequiresPeers (removed - use IsRegTestNet)
- nMaxReorganizationDepth (moved outside chain params)
- nEnforce[/nReject/nToCheck]BlockUpgradeMajority
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 92221b1

Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

not syncing on mainnet, needs #1359 for the bug introduced in #1341 but code wise looks good.

utACK 92221b1.

@furszy furszy merged commit e4041b1 into PIVX-Project:master Feb 28, 2020
@random-zebra random-zebra deleted the 2020_consensus_part2 branch September 24, 2020 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants