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

[Refactor] Fix stake age checks for regtest #976

Merged

Conversation

random-zebra
Copy link

There is a bug occurring sometimes on regtest where a block is not accepted due to CheckStakeKernelHash() : min age violation.
This is because the min age requirement for RegTest was changed (in #812) inside Stake but not in CheckProofOfStake (the error indicates also the wrong function).

This fixes it and moves nStakeMinAge to chain params (instead of having it as rogue external variable) and sets it to 0 for RegTest (for consistency).
Also fixes the error messages in kernel.cpp.

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.

utACK. However it would be better to have at least two separate commits, one for real code changes and one for comments, indenting and formatting.
Also, I'm not a native speaker but as far as I know in English there is no space before a : character. So your changes regarding this matter seems to go in the wrong direction.

@CaveSpectre11
Copy link

CaveSpectre11 commented Aug 6, 2019

Also, I'm not a native speaker but as far as I know in English there is no space before a : character. So your changes regarding this matter seems to go in the wrong direction.

Personally I don't like the space between the function and :. Can't really judge what the standard format is in the code base since it's pretty much a tossup between the two (however taking a quick look at net.cpp is pretty funny; with CAddrDB::Write() and CBanDB::Write() having a different format for the same messages).

@random-zebra
Copy link
Author

Yes, there is no standard convention in the code for that (which is supposed to be just a separator, doesn't have to strictly follow the conventions of the English language for spacing around colons).

Anyway this PR is not about code styling. That can be addressed separately.
The reason for the edits in the log lines was only using __func__ instead of explicitely writing the name (often mistaking it due to cut and paste).

@CaveSpectre11
Copy link

Anyway this PR is not about code styling. That can be addressed separately.

Fair enough; especially after peeking at the code and seeing the topic is a can of worms :)

@furszy furszy self-requested a review August 6, 2019 17:13
furszy
furszy previously approved these changes Aug 6, 2019
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.

Overall looks good, great catch.

Two minor things that can be tackled in another PR without block this one.

  1. Would be nice to start moving away from the Params().something static calls and have a variable at the beginning of every method that use it, making easy any future BTC back port as they are moving away from that too.

  2. Would be good to have in ChainParams a isRegtest() method and stop doing the Params().NetworkID() != CbaseChainParams::REGTEST.

Side from that, utACK b67becf

- fix age check in CheckProofOfStake
- move nStakeMinAge to chain params
- fix error logs in kernel.cpp
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.

utACK 2eacdb7

@furszy
Copy link

furszy commented Aug 9, 2019

@PIVX-Project/core-developers check this one please, it's pretty straightforward and will clean the #936 commits list for a better review.

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 2eacdb7

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 2eacdb7

@random-zebra random-zebra merged commit 2eacdb7 into PIVX-Project:master Aug 14, 2019
random-zebra added a commit that referenced this pull request Aug 14, 2019
2eacdb7 [Refactor] Fix stake age checks for regtest (random-zebra)

Pull request description:

  There is a bug occurring sometimes on regtest where a block is not accepted due to `CheckStakeKernelHash() : min age violation`.
  This is because the min age requirement for RegTest was changed (in #812) inside `Stake` but not in `CheckProofOfStake` (the error indicates also the  wrong function).

  This fixes it and moves `nStakeMinAge` to chain params (instead of having it as rogue external variable) and sets it to `0` for RegTest (for consistency).
  Also fixes the error messages in kernel.cpp.

ACKs for top commit:
  furszy:
    utACK [2eacdb7](2eacdb7)
  Fuzzbawls:
    ACK 2eacdb7
  Warrows:
    ACK 2eacdb7

Tree-SHA512: e65d0298ad76ac2c3886507e9d4316d6c00591873f9fb3c59fe856be851d9c7a9ae3dcf9ea01cf7ccb726c4a5c0599dc80cfd427224c2c37d5e72197e79d0eba
@Fuzzbawls Fuzzbawls added the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Aug 16, 2019
@random-zebra random-zebra modified the milestones: 4.0.0, 3.4.0 Aug 25, 2019
@Fuzzbawls Fuzzbawls removed the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Aug 26, 2019
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.

None yet

5 participants