Skip to content

Commit

Permalink
Merge pull request bcoin-org#88 from nodar-chkuaselidze/remove-monolith
Browse files Browse the repository at this point in the history
consensus: remove monolith deployment
  • Loading branch information
tuxcanfly authored Oct 12, 2018
2 parents 28cf1ef + 5e3ce3e commit 2ff751b
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 239 deletions.
31 changes: 1 addition & 30 deletions lib/blockchain/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,10 @@ class Chain extends AsyncEmitter {
if (block.getSize() > state.maxBlockSize()) {
throw new VerifyError(block,
'invalid',
'bad-blk-weight',
'bad-blk-length',
100);
}

// If Monolith is not activated yet, we want to limit the max
// generated block size to 8MB
if (!state.hasMonolith()) {
if (block.getSize() > 8 * consensus.MAX_BLOCK_SIZE) {
throw new VerifyError(block,
'invalid',
'bad-blk-length',
100);
}
}

return state;
}

Expand Down Expand Up @@ -518,12 +507,6 @@ class Chain extends AsyncEmitter {
state.flags |= Script.flags.VERIFY_NULLFAIL;
}

const mtp = await this.getMedianTime(prev);
// Monolith is now enabled.
if (mtp >= consensus.MONOLITH_TIME) {
state.flags |= Script.flags.VERIFY_MONOLITH_OPCODES;
}

// CHECKSEQUENCEVERIFY and median time
// past locktimes are now usable (bip9 & bip113).
if (await this.isActive(prev, deployments.csv)) {
Expand Down Expand Up @@ -567,9 +550,6 @@ class Chain extends AsyncEmitter {
if (!this.state.hasDAA() && state.hasDAA())
this.logger.warning('DAA has been activated.');

if (!this.state.hasMonolith() && state.hasMonolith())
this.logger.warning('Monolith has been activated.');

this.state = state;
}

Expand Down Expand Up @@ -2924,15 +2904,6 @@ class DeploymentState {
return (this.flags & Script.flags.VERIFY_CHECKSEQUENCEVERIFY) !== 0;
}

/**
* Test whether monolith is active.
* @returns {Boolean}
*/

hasMonolith() {
return (this.flags & Script.flags.VERIFY_MONOLITH_OPCODES) !== 0;
}

/**
* Test whether DAA is active.
* @returns {Boolean}
Expand Down
8 changes: 0 additions & 8 deletions lib/protocol/consensus.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ exports.NULL_HASH =
exports.ANTI_REPLAY_COMMITMENT =
'Bitcoin: A Peer-to-Peer Electronic Cash System';

/**
* Monolith start time.
* @const {Number}
* @default
*/

exports.MONOLITH_TIME = 1526400000;

/**
* Convert a compact number to a big number.
* Used for `block.bits` -> `target` conversion.
Expand Down
6 changes: 2 additions & 4 deletions lib/script/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ exports.flags = {
VERIFY_NULLFAIL: 1 << 14,
VERIFY_COMPRESSED_PUBKEYTYPE: 1 << 15,
VERIFY_SIGHASH_FORKID: 1 << 16,
VERIFY_REPLAY_PROTECTION: 1 << 17,
VERIFY_MONOLITH_OPCODES: 1 << 18
VERIFY_REPLAY_PROTECTION: 1 << 17
};

/**
Expand Down Expand Up @@ -378,8 +377,7 @@ exports.flags.STANDARD_VERIFY_FLAGS = 0
| exports.flags.VERIFY_CHECKSEQUENCEVERIFY
| exports.flags.VERIFY_LOW_S
| exports.flags.VERIFY_COMPRESSED_PUBKEYTYPE
| exports.flags.VERIFY_SIGHASH_FORKID
| exports.flags.VERIFY_MONOLITH_OPCODES;
| exports.flags.VERIFY_SIGHASH_FORKID;

/**
* Standard flags without mandatory bits.
Expand Down
14 changes: 1 addition & 13 deletions lib/script/opcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,8 @@ class Opcode {
case opcodes.OP_LSHIFT:
case opcodes.OP_RSHIFT:
return true;

case opcodes.OP_CAT:
case opcodes.OP_SPLIT:
case opcodes.OP_AND:
case opcodes.OP_OR:
case opcodes.OP_XOR:
case opcodes.OP_NUM2BIN:
case opcodes.OP_BIN2NUM:
case opcodes.OP_DIV:
case opcodes.OP_MOD:
// Opcodes that have been reenabled.
if (!(flags & common.flags.VERIFY_MONOLITH_OPCODES))
return true;
}

return false;
}

Expand Down
Loading

0 comments on commit 2ff751b

Please sign in to comment.