hardfork: remove IsSuperMajority soft fork check.
This commit is contained in:
parent
083c5ea8f5
commit
b0b8d333a5
@ -439,6 +439,7 @@ Chain.prototype.verify = co(function* verify(block, prev) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Chain.prototype.getDeployments = co(function* getDeployments(block, prev, ancestors) {
|
Chain.prototype.getDeployments = co(function* getDeployments(block, prev, ancestors) {
|
||||||
|
var height = prev.height + 1;
|
||||||
var state = new DeploymentState();
|
var state = new DeploymentState();
|
||||||
var active;
|
var active;
|
||||||
|
|
||||||
@ -458,42 +459,42 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev, ancest
|
|||||||
|
|
||||||
// Only allow version 2 blocks (coinbase height)
|
// Only allow version 2 blocks (coinbase height)
|
||||||
// once the majority of blocks are using it.
|
// once the majority of blocks are using it.
|
||||||
if (block.version < 2 && prev.isOutdated(2, ancestors))
|
if (block.version < 2 && height >= this.network.block.bip34height)
|
||||||
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
||||||
|
|
||||||
// Only allow version 3 blocks (sig validation)
|
// Only allow version 3 blocks (sig validation)
|
||||||
// once the majority of blocks are using it.
|
// once the majority of blocks are using it.
|
||||||
if (block.version < 3 && prev.isOutdated(3, ancestors))
|
if (block.version < 3 && height >= this.network.block.bip66height)
|
||||||
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
||||||
|
|
||||||
// Only allow version 4 blocks (checklocktimeverify)
|
// Only allow version 4 blocks (checklocktimeverify)
|
||||||
// once the majority of blocks are using it.
|
// once the majority of blocks are using it.
|
||||||
if (block.version < 4 && prev.isOutdated(4, ancestors))
|
if (block.version < 4 && height >= this.network.block.bip65height)
|
||||||
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
||||||
|
|
||||||
// Only allow version 5 blocks (bip141 - segnet3)
|
// Only allow version 5 blocks (bip141 - segnet3)
|
||||||
// once the majority of blocks are using it.
|
// once the majority of blocks are using it.
|
||||||
if (this.options.witness && this.network.oldWitness) {
|
if (this.options.witness && this.network.oldWitness) {
|
||||||
if (block.version < 5 && prev.isOutdated(5, ancestors))
|
if (block.version < 5 && height >= this.network.block.bip141height)
|
||||||
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
throw new VerifyError(block, 'obsolete', 'bad-version', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the height contained in the coinbase is correct.
|
// Make sure the height contained in the coinbase is correct.
|
||||||
if (block.version >= 2 && prev.isUpgraded(2, ancestors)) {
|
if (height >= this.network.block.bip34height) {
|
||||||
state.bip34 = true;
|
state.bip34 = true;
|
||||||
if (!this.state.hasBIP34())
|
if (!this.state.hasBIP34())
|
||||||
this.logger.warning('BIP34 has been activated.');
|
this.logger.warning('BIP34 has been activated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signature validation is now enforced (bip66)
|
// Signature validation is now enforced (bip66)
|
||||||
if (block.version >= 3 && prev.isUpgraded(3, ancestors)) {
|
if (height >= this.network.block.bip66height) {
|
||||||
state.flags |= constants.flags.VERIFY_DERSIG;
|
state.flags |= constants.flags.VERIFY_DERSIG;
|
||||||
if (!this.state.hasBIP66())
|
if (!this.state.hasBIP66())
|
||||||
this.logger.warning('BIP66 has been activated.');
|
this.logger.warning('BIP66 has been activated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECKLOCKTIMEVERIFY is now usable (bip65)
|
// CHECKLOCKTIMEVERIFY is now usable (bip65)
|
||||||
if (block.version >= 4 && prev.isUpgraded(4, ancestors)) {
|
if (height >= this.network.block.bip65height) {
|
||||||
state.flags |= constants.flags.VERIFY_CHECKLOCKTIMEVERIFY;
|
state.flags |= constants.flags.VERIFY_CHECKLOCKTIMEVERIFY;
|
||||||
if (!this.state.hasCLTV())
|
if (!this.state.hasCLTV())
|
||||||
this.logger.warning('BIP65 has been activated.');
|
this.logger.warning('BIP65 has been activated.');
|
||||||
@ -501,7 +502,7 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev, ancest
|
|||||||
|
|
||||||
// Segregrated witness is now usable (bip141 - segnet3)
|
// Segregrated witness is now usable (bip141 - segnet3)
|
||||||
if (this.options.witness && this.network.oldWitness) {
|
if (this.options.witness && this.network.oldWitness) {
|
||||||
if (block.version >= 5 && prev.isUpgraded(5, ancestors)) {
|
if (height >= this.network.block.bip141height) {
|
||||||
state.flags |= constants.flags.VERIFY_WITNESS;
|
state.flags |= constants.flags.VERIFY_WITNESS;
|
||||||
if (!this.state.hasWitness())
|
if (!this.state.hasWitness())
|
||||||
this.logger.warning('Segwit has been activated.');
|
this.logger.warning('Segwit has been activated.');
|
||||||
@ -525,13 +526,13 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev, ancest
|
|||||||
// Segregrated witness is now usable (bip141 - segnet4)
|
// Segregrated witness is now usable (bip141 - segnet4)
|
||||||
active = yield this.isActive(prev, 'witness');
|
active = yield this.isActive(prev, 'witness');
|
||||||
if (active) {
|
if (active) {
|
||||||
// BIP147
|
|
||||||
// state.flags |= constants.flags.VERIFY_NULLDUMMY;
|
|
||||||
if (this.options.witness) {
|
if (this.options.witness) {
|
||||||
state.flags |= constants.flags.VERIFY_WITNESS;
|
state.flags |= constants.flags.VERIFY_WITNESS;
|
||||||
if (!this.state.hasWitness())
|
if (!this.state.hasWitness())
|
||||||
this.logger.warning('Segwit has been activated.');
|
this.logger.warning('Segwit has been activated.');
|
||||||
}
|
}
|
||||||
|
// BIP147
|
||||||
|
state.flags |= constants.flags.VERIFY_NULLDUMMY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@ -163,13 +163,14 @@ ChainEntry.prototype.isGenesis = function isGenesis() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ChainEntry.prototype.getRetargetAncestors = function getRetargetAncestors() {
|
ChainEntry.prototype.getRetargetAncestors = function getRetargetAncestors() {
|
||||||
var majorityWindow = this.network.block.majorityWindow;
|
|
||||||
var medianTimespan = constants.block.MEDIAN_TIMESPAN;
|
var medianTimespan = constants.block.MEDIAN_TIMESPAN;
|
||||||
var powDiffInterval = this.network.pow.retargetInterval;
|
var retargetInterval = this.network.pow.retargetInterval;
|
||||||
var diffReset = this.network.pow.difficultyReset;
|
var diffReset = this.network.pow.difficultyReset;
|
||||||
var max = Math.max(majorityWindow, medianTimespan);
|
var max = medianTimespan;
|
||||||
if ((this.height + 1) % powDiffInterval === 0 || diffReset)
|
|
||||||
max = Math.max(max, powDiffInterval);
|
if ((this.height + 1) % retargetInterval === 0 || diffReset)
|
||||||
|
max = Math.max(max, retargetInterval);
|
||||||
|
|
||||||
return this.getAncestors(max);
|
return this.getAncestors(max);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,93 +331,6 @@ ChainEntry.prototype.getMedianTimeAsync = co(function* getMedianTimeAsync() {
|
|||||||
return this.getMedianTime(ancestors);
|
return this.getMedianTime(ancestors);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Check isSuperMajority against majorityRejectOutdated.
|
|
||||||
* @param {Number} version
|
|
||||||
* @param {ChainEntry[]} ancestors
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isOutdated = function isOutdated(version, ancestors) {
|
|
||||||
return this.isSuperMajority(version,
|
|
||||||
this.network.block.majorityRejectOutdated,
|
|
||||||
ancestors);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check {@link ChainEntry#isUpgraded asynchronously}.
|
|
||||||
* @param {Number} version
|
|
||||||
* @returns {Promise} - Returns Boolean.
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isOutdatedAsync = function isOutdatedAsync(version) {
|
|
||||||
return this.isSuperMajorityAsync(version,
|
|
||||||
this.network.block.majorityRejectOutdated);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check isSuperMajority against majorityEnforceUpgrade.
|
|
||||||
* @param {Number} version
|
|
||||||
* @param {ChainEntry[]} ancestors
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isUpgraded = function isUpgraded(version, ancestors) {
|
|
||||||
return this.isSuperMajority(version,
|
|
||||||
this.network.block.majorityEnforceUpgrade,
|
|
||||||
ancestors);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check {@link ChainEntry#isUpgraded} asynchronously.
|
|
||||||
* @param {Number} version
|
|
||||||
* @returns {Promise}
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isUpgradedAsync = function isUpgradedAsync(version) {
|
|
||||||
return this.isSuperMajorityAsync(version,
|
|
||||||
this.network.block.majorityEnforceUpgrade);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate found number of block versions within the majority window.
|
|
||||||
* @param {Number} version
|
|
||||||
* @param {Number} required
|
|
||||||
* @param {ChainEntry[]} ancestors
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isSuperMajority = function isSuperMajority(version, required, ancestors) {
|
|
||||||
var entry = this;
|
|
||||||
var found = 0;
|
|
||||||
var majorityWindow = this.network.block.majorityWindow;
|
|
||||||
var i;
|
|
||||||
|
|
||||||
for (i = 0; i < majorityWindow && found < required && entry; i++) {
|
|
||||||
if (entry.version >= version)
|
|
||||||
found++;
|
|
||||||
entry = ancestors[i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return found >= required;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate {@link ChainEntry#isSuperMajority asynchronously}.
|
|
||||||
* @param {Number} version
|
|
||||||
* @param {Number} required
|
|
||||||
* @returns {Promise} - Returns Boolean.
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ChainEntry.prototype.isSuperMajorityAsync = co(function* isSuperMajorityAsync(version, required) {
|
|
||||||
var majorityWindow = this.network.block.majorityWindow;
|
|
||||||
var ancestors = yield this.getAncestors(majorityWindow);
|
|
||||||
return this.isSuperMajority(version, required, ancestors);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether the entry is potentially
|
* Test whether the entry is potentially
|
||||||
* an ancestor of a checkpoint.
|
* an ancestor of a checkpoint.
|
||||||
|
|||||||
@ -228,26 +228,6 @@ main.pow = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
main.block = {
|
main.block = {
|
||||||
/**
|
|
||||||
* Required versions to upgrade (see {@link ChainEntry#IsUpgraded}).
|
|
||||||
*/
|
|
||||||
|
|
||||||
majorityEnforceUpgrade: 750,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required versions to consider block
|
|
||||||
* outdated (see {@link ChainEntry#IsOutdated}).
|
|
||||||
*/
|
|
||||||
|
|
||||||
majorityRejectOutdated: 950,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Majority window to check for upgraded and outdated
|
|
||||||
* blocks (see {@link ChainEntry#IsSuperMajority}).
|
|
||||||
*/
|
|
||||||
|
|
||||||
majorityWindow: 1000,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height at which bip34 was activated.
|
* Height at which bip34 was activated.
|
||||||
* Used for avoiding bip30 checks.
|
* Used for avoiding bip30 checks.
|
||||||
@ -543,9 +523,6 @@ testnet.pow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testnet.block = {
|
testnet.block = {
|
||||||
majorityEnforceUpgrade: 51,
|
|
||||||
majorityRejectOutdated: 75,
|
|
||||||
majorityWindow: 100,
|
|
||||||
bip34height: 21111,
|
bip34height: 21111,
|
||||||
bip34hash: 'f88ecd9912d00d3f5c2a8e0f50417d3e415c75b3abe584346da9b32300000000',
|
bip34hash: 'f88ecd9912d00d3f5c2a8e0f50417d3e415c75b3abe584346da9b32300000000',
|
||||||
bip65height: 581885,
|
bip65height: 581885,
|
||||||
@ -690,10 +667,7 @@ regtest.pow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
regtest.block = {
|
regtest.block = {
|
||||||
majorityEnforceUpgrade: 750,
|
bip34height: 100000000,
|
||||||
majorityRejectOutdated: 950,
|
|
||||||
majorityWindow: 1000,
|
|
||||||
bip34height: -1,
|
|
||||||
bip34hash: null,
|
bip34hash: null,
|
||||||
bip65height: 1351,
|
bip65height: 1351,
|
||||||
bip65hash: null,
|
bip65hash: null,
|
||||||
@ -834,9 +808,6 @@ segnet3.pow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
segnet3.block = {
|
segnet3.block = {
|
||||||
majorityEnforceUpgrade: 7,
|
|
||||||
majorityRejectOutdated: 9,
|
|
||||||
majorityWindow: 10,
|
|
||||||
bip34height: 8,
|
bip34height: 8,
|
||||||
bip34hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000',
|
bip34hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000',
|
||||||
bip65height: 8,
|
bip65height: 8,
|
||||||
@ -956,9 +927,6 @@ segnet4.pow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
segnet4.block = {
|
segnet4.block = {
|
||||||
majorityEnforceUpgrade: 7,
|
|
||||||
majorityRejectOutdated: 9,
|
|
||||||
majorityWindow: 10,
|
|
||||||
bip34height: 8,
|
bip34height: 8,
|
||||||
bip34hash: '6c48386dc7c460defabb5640e28b6510a5f238cdbe6756c2976a7e0913000000',
|
bip34hash: '6c48386dc7c460defabb5640e28b6510a5f238cdbe6756c2976a7e0913000000',
|
||||||
bip65height: 8,
|
bip65height: 8,
|
||||||
@ -1098,9 +1066,6 @@ simnet.pow = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
simnet.block = {
|
simnet.block = {
|
||||||
majorityEnforceUpgrade: 51,
|
|
||||||
majorityRejectOutdated: 75,
|
|
||||||
majorityWindow: 100,
|
|
||||||
bip34height: 0,
|
bip34height: 0,
|
||||||
bip34hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
|
bip34hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
|
||||||
bip65height: 0,
|
bip65height: 0,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user