Skip to content

Stop UASF enforcement if SegWit has IsLockedIn state.#512

Merged
luke-jr merged 3 commits intobitcoin:masterfrom
da2ce7:bip148
Apr 6, 2017
Merged

Stop UASF enforcement if SegWit has IsLockedIn state.#512
luke-jr merged 3 commits intobitcoin:masterfrom
da2ce7:bip148

Conversation

@da2ce7
Copy link
Copy Markdown
Contributor

@da2ce7 da2ce7 commented Apr 4, 2017

Includes basic refactor.

No-need to calculate the GetMedianTimePast() value twice.

@shaolinfry
Copy link
Copy Markdown
Contributor

More importantly, there is this question to be answered 60d4b51#commitcomment-21581456

@da2ce7 da2ce7 changed the title Refactor Code-Example with Better Formatting Stop UASF enforcement if SegWit has IsLockedIn state. Apr 4, 2017
Comment thread bip-0148.mediawiki
int64_t nMedianTimePast = pindex->GetMedianTimePast();
if ( (nMedianTimePast >= 1506816000) && // Sun Oct 1 00:00:00 UTC 2017
(nMedianTimePast <= 1510704000) && // Sun Nov 15 00:00:00 UTC 2017
(!IsWitnessLockedIn(pindex->pprev, chainparams.GetConsensus()) && // Segwit is not locked in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This must be defined in the code example.

Comment thread bip-0148.mediawiki Outdated
pindex->GetMedianTimePast() <= 1510704000 && // Wed 15 Nov 2017 00:00:00 UTC
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus()))
int64_t nMedianTimePast = pindex->GetMedianTimePast();
if ( (nMedianTimePast >= 1506816000) && // Sun Oct 1 00:00:00 UTC 2017
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both timestamp and date are wrong;

Comment thread bip-0148.mediawiki Outdated
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus()))
int64_t nMedianTimePast = pindex->GetMedianTimePast();
if ( (nMedianTimePast >= 1506816000) && // Sun Oct 1 00:00:00 UTC 2017
(nMedianTimePast <= 1510704000) && // Sun Nov 15 00:00:00 UTC 2017
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Day is wrong, it's Weds not Sun

No-need to calculate the GetMedianTimePast() value twice.
@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 4, 2017

@shaolinfry sorry about that: that was embarrassing. 😳

shaolinfry referenced this pull request Apr 4, 2017
Adjust start time to Aug 1st 2017
Fix code sample logic.
Comment thread bip-0148.mediawiki
int64_t nMedianTimePast = pindex->GetMedianTimePast();
if ( (nMedianTimePast >= 1501545600) && // Tue 01 Aug 2017 00:00:00 UTC
(nMedianTimePast <= 1510704000) && // Wed 15 Nov 2017 00:00:00 UTC
(!IsWitnessLockedIn(pindex->pprev, chainparams.GetConsensus()) && // Segwit is not locked in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to define this function since it does not exist in Bitcoin Core.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@da2ce7 da2ce7 force-pushed the bip148 branch 2 times, most recently from ae3e33a to 76d49fd Compare April 4, 2017 11:20
@shaolinfry
Copy link
Copy Markdown
Contributor

@dooglus comments please?

Comment thread bip-0148.mediawiki Outdated

<pre>


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

two unnecessary lines

Comment thread bip-0148.mediawiki Outdated
== THRESHOLD_LOCKED_IN);
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one unnecessary blank line

Comment thread bip-0148.mediawiki Outdated
{
LOCK(cs_main);
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache)
== THRESHOLD_LOCKED_IN);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dont linebreak here please.

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 4, 2017 via email

@afk11
Copy link
Copy Markdown
Contributor

afk11 commented Apr 4, 2017

@da2ce7 If you merge this it'll update this PR with the requested changes: https://github.com/da2ce7/bips/pull/2/files

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 4, 2017

@afk11 thankyou, I have included your commit.

Comment thread bip-0148.mediawiki Outdated
// versionbits topbit and segwit flag must be set.
if ((pindex->nVersion & VERSIONBITS_TOP_MASK) != VERSIONBITS_TOP_BITS ||
(pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) {
bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS; // BIP9 bit set
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove the inaccurate comment.

Comment thread bip-0148.mediawiki Outdated
All times are specified according to median past time.

This BIP will be activate between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not activated before epoch time 1501545600. This BIP will cease to be active when the existing segwit deployment activates.
This BIP will be activate between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not locked-in or activated before epoch time 1501545600. This BIP will cease to be active when segwit is locked-in.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be "This BIP will be active between..."

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 4, 2017

@afk11 I have squashed your commit.
@mkwia thank you, I have corrected the phasing.
@luke-jr thank you, I have removed the inaccurate comment.

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 4, 2017

Bitcoin Branch that implements BIP 148 as described by this pull request.
https://github.com/da2ce7/bitcoin/tree/bip148

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 6, 2017

@shaolinfry, can you please re-review this pull request?

Comment thread bip-0148.mediawiki
(pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) {
bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS;
bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0;
if (!(fVersionBits && fSegbit)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought I had commented here but seems I didn't press the button :)
So while it is bikeshedding, I dislike this formatting, and prefer the previous notation but that is just my personal taste. So long as the logic works :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO this way is cleaner.

@shaolinfry
Copy link
Copy Markdown
Contributor

I need other's to peer review ACK this first, because when I give mine, it will get merged. I'm reasonably confident this is ok now, but peers please.

@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Apr 6, 2017

@mkwia do you suggest defining a temporary boolean for clearer code?

Copy link
Copy Markdown
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

(Code review should really be done on a code project rather than the BIP change itself.)

Comment thread bip-0148.mediawiki
(pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) {
bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS;
bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0;
if (!(fVersionBits && fSegbit)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO this way is cleaner.

@luke-jr luke-jr merged commit 1f6888e into bitcoin:master Apr 6, 2017
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.

5 participants