Stop UASF enforcement if SegWit has IsLockedIn state.#512
Stop UASF enforcement if SegWit has IsLockedIn state.#512luke-jr merged 3 commits intobitcoin:masterfrom
Conversation
|
More importantly, there is this question to be answered 60d4b51#commitcomment-21581456 |
| 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 |
There was a problem hiding this comment.
This must be defined in the code example.
| 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 |
There was a problem hiding this comment.
Both timestamp and date are wrong;
| !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 |
There was a problem hiding this comment.
Day is wrong, it's Weds not Sun
No-need to calculate the GetMedianTimePast() value twice.
|
@shaolinfry sorry about that: that was embarrassing. 😳 |
Adjust start time to Aug 1st 2017 Fix code sample logic.
| 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 |
There was a problem hiding this comment.
You need to define this function since it does not exist in Bitcoin Core.
ae3e33a to
76d49fd
Compare
|
@dooglus comments please? |
|
|
||
| <pre> | ||
|
|
||
|
|
| == THRESHOLD_LOCKED_IN); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
one unnecessary blank line
| { | ||
| LOCK(cs_main); | ||
| return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) | ||
| == THRESHOLD_LOCKED_IN); |
There was a problem hiding this comment.
dont linebreak here please.
|
Sorry, away from computer now. I can fix in a couple of hours.
…Sent from my iPhone
On 4 Apr 2017, at 13:55, shaolinfry ***@***.***> wrote:
@shaolinfry requested changes on this pull request.
In bip-0148.mediawiki:
>
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
=== Reference implementation ===
<pre>
+
+
two unnecessary lines
In bip-0148.mediawiki:
>
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
=== Reference implementation ===
<pre>
+
+
+// Check if Segregated Witness is Locked In
+bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params)
+{
+ LOCK(cs_main);
+ return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache)
+ == THRESHOLD_LOCKED_IN);
+}
+
+
one unnecessary blank line
In bip-0148.mediawiki:
>
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
=== Reference implementation ===
<pre>
+
+
+// Check if Segregated Witness is Locked In
+bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params)
+{
+ LOCK(cs_main);
+ return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache)
+ == THRESHOLD_LOCKED_IN);
dont linebreak here please.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@da2ce7 If you merge this it'll update this PR with the requested changes: https://github.com/da2ce7/bips/pull/2/files |
|
@afk11 thankyou, I have included your commit. |
| // 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 |
| 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. |
There was a problem hiding this comment.
Should be "This BIP will be active between..."
|
Bitcoin Branch that implements BIP 148 as described by this pull request. |
|
@shaolinfry, can you please re-review this pull request? |
| (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)) { |
There was a problem hiding this comment.
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 :)
|
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. |
|
@mkwia do you suggest defining a temporary boolean for clearer code? |
luke-jr
left a comment
There was a problem hiding this comment.
(Code review should really be done on a code project rather than the BIP change itself.)
| (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)) { |
Includes basic refactor.
No-need to calculate the GetMedianTimePast() value twice.