diff --git a/README.md b/README.md index 28fb9842..3ff7e1fa 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ java -jar pull-tests-f56eec3.jar By default parity connects to bitcoind-seednodes. Full list is [here](./pbtc/seednodes.rs). -Before starting synchronization, you must decide - which fork to follow - SegWit (`--segwit` flag), SegWit2x (`--segwit2x` flag) or Bitcoin Cash (`--bitcoin-cash` flag). On next start, passing the same flag is optional, as the database is already bound to selected fork and won't be synchronized using other verification rules. +Before starting synchronization, you must decide - which fork to follow - SegWit (`--segwit` flag) or Bitcoin Cash (`--bitcoin-cash` flag). On next start, passing the same flag is optional, as the database is already bound to selected fork and won't be synchronized using other verification rules. To start syncing the main network, just start the client, passing selected fork flag. For example: @@ -185,7 +185,6 @@ FLAGS: -q, --quiet Do not show any synchronization information in the console. --regtest Use a private network for regression tests. --segwit Enable SegWit verification rules. - --segwit2x Enable SegWit2x verification rules. --testnet Use the test network (Testnet3). -V, --version Prints version information diff --git a/network/src/consensus.rs b/network/src/consensus.rs index eb0792a4..5ff676e2 100644 --- a/network/src/consensus.rs +++ b/network/src/consensus.rs @@ -1,8 +1,6 @@ use hash::H256; use {Network, Magic, Deployment}; -/// First block of SegWit2x fork. -const SEGWIT2X_FORK_BLOCK: u32 = 494784; // https://segwit2x.github.io/segwit2x-announce.html /// First block of BitcoinCash fork. const BITCOIN_CASH_FORK_BLOCK: u32 = 478559; // https://blockchair.com/bitcoin-cash/block/478559 @@ -46,26 +44,11 @@ pub struct BitcoinCashConsensusParams { pub difficulty_adjustion_time: u32, } -#[derive(Debug, Clone)] -/// SegWit2x consensus parameters. -pub struct SegWit2xConsensusParams { - /// Initial SegWit2x hard fork height. - pub height: u32, -} - #[derive(Debug, Clone)] /// Concurrent consensus rule forks. pub enum ConsensusFork { /// No fork. NoFork, - /// SegWit2x (aka The New York Agreement). - /// `u32` is height of the first block, for which new consensus rules are applied. - /// Briefly: SegWit + blocks up to 2MB. - /// Technical specification: - /// Segregated Witness (Consensus layer) - https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki - /// Block size increase to 2MB - https://github.com/bitcoin/bips/blob/master/bip-0102.mediawiki - /// Readiness checklist - https://segwit2x.github.io/segwit2x-announce.html - SegWit2x(SegWit2xConsensusParams), /// Bitcoin Cash (aka UAHF). /// `u32` is height of the first block, for which new consensus rules are applied. /// Briefly: no SegWit + blocks up to 8MB + replay protection. @@ -85,7 +68,7 @@ impl ConsensusParams { bip65_height: 388381, // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0 bip66_height: 363725, // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931 segwit_deployment: match fork { - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) => Some(Deployment { + ConsensusFork::NoFork => Some(Deployment { name: "segwit", bit: 1, start_time: 1479168000, @@ -112,7 +95,7 @@ impl ConsensusParams { bip65_height: 581885, // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6 bip66_height: 330776, // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182 segwit_deployment: match fork { - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) => Some(Deployment { + ConsensusFork::NoFork => Some(Deployment { name: "segwit", bit: 1, start_time: 1462060800, @@ -139,7 +122,7 @@ impl ConsensusParams { bip65_height: 1351, bip66_height: 1251, // used only in rpc tests segwit_deployment: match fork { - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) => Some(Deployment { + ConsensusFork::NoFork => Some(Deployment { name: "segwit", bit: 1, start_time: 0, @@ -191,7 +174,6 @@ impl ConsensusFork { pub fn activation_height(&self) -> u32 { match *self { ConsensusFork::NoFork => 0, - ConsensusFork::SegWit2x(ref fork) => fork.height, ConsensusFork::BitcoinCash(ref fork) => fork.height, } } @@ -206,16 +188,14 @@ impl ConsensusFork { match *self { // size of first fork block must be larger than 1MB ConsensusFork::BitcoinCash(ref fork) if height == fork.height => 1_000_001, - ConsensusFork::SegWit2x(ref fork) if height == fork.height => 1_000_001, - ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) | ConsensusFork::SegWit2x(_) => 0, + ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) => 0, } } pub fn max_block_size(&self, height: u32) -> usize { match *self { - ConsensusFork::SegWit2x(ref fork) if height >= fork.height => 2_000_000, ConsensusFork::BitcoinCash(ref fork) if height >= fork.height => 8_000_000, - ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) | ConsensusFork::SegWit2x(_) => 1_000_000, + ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) => 1_000_000, } } @@ -224,9 +204,7 @@ impl ConsensusFork { // according to REQ-5: max_block_sigops = 20000 * ceil((max(blocksize_bytes, 1000000) / 1000000)) ConsensusFork::BitcoinCash(ref fork) if height >= fork.height => 20_000 * (1 + (block_size - 1) / 1_000_000), - ConsensusFork::SegWit2x(ref fork) if height >= fork.height => - 40_000, - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) | ConsensusFork::BitcoinCash(_) => 20_000, + ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) => 20_000, } } @@ -234,18 +212,14 @@ impl ConsensusFork { match *self { ConsensusFork::BitcoinCash(_) => self.max_block_sigops(height, block_size) * Self::witness_scale_factor(), - ConsensusFork::SegWit2x(ref fork) if height >= fork.height => - 160_000, - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) => + ConsensusFork::NoFork => 80_000, } } - pub fn max_block_weight(&self, height: u32) -> usize { + pub fn max_block_weight(&self, _height: u32) -> usize { match *self { - ConsensusFork::SegWit2x(ref fork) if height >= fork.height => - 8_000_000, - ConsensusFork::NoFork | ConsensusFork::SegWit2x(_) => + ConsensusFork::NoFork => 4_000_000, ConsensusFork::BitcoinCash(_) => unreachable!("BitcoinCash has no SegWit; weight is only checked with SegWit activated; qed"), @@ -262,14 +236,6 @@ impl Default for BitcoinCashConsensusParams { } } -impl Default for SegWit2xConsensusParams { - fn default() -> Self { - SegWit2xConsensusParams { - height: SEGWIT2X_FORK_BLOCK, - } - } -} - #[cfg(test)] mod tests { use super::super::Network; @@ -313,9 +279,6 @@ mod tests { #[test] fn test_consensus_fork_min_block_size() { assert_eq!(ConsensusFork::NoFork.min_block_size(0), 0); - let fork = ConsensusFork::SegWit2x(Default::default()); - assert_eq!(fork.min_block_size(0), 0); - assert_eq!(fork.min_block_size(fork.activation_height()), 1_000_001); let fork = ConsensusFork::BitcoinCash(Default::default()); assert_eq!(fork.min_block_size(0), 0); assert_eq!(fork.min_block_size(fork.activation_height()), 1_000_001); @@ -324,17 +287,12 @@ mod tests { #[test] fn test_consensus_fork_max_transaction_size() { assert_eq!(ConsensusFork::NoFork.max_transaction_size(), 1_000_000); - assert_eq!(ConsensusFork::SegWit2x(Default::default()).max_transaction_size(), 1_000_000); assert_eq!(ConsensusFork::BitcoinCash(Default::default()).max_transaction_size(), 1_000_000); } #[test] fn test_consensus_fork_max_block_sigops() { assert_eq!(ConsensusFork::NoFork.max_block_sigops(0, 1_000_000), 20_000); - let fork = ConsensusFork::SegWit2x(Default::default()); - assert_eq!(fork.max_block_sigops(0, 1_000_000), 20_000); - assert_eq!(fork.max_block_sigops(fork.activation_height(), 2_000_000), 40_000); - assert_eq!(fork.max_block_sigops(fork.activation_height() + 100, 3_000_000), 40_000); let fork = ConsensusFork::BitcoinCash(Default::default()); assert_eq!(fork.max_block_sigops(0, 1_000_000), 20_000); assert_eq!(fork.max_block_sigops(fork.activation_height(), 2_000_000), 40_000); diff --git a/network/src/lib.rs b/network/src/lib.rs index 55f09a3f..40c47655 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -10,6 +10,6 @@ mod network; pub use primitives::{hash, compact}; -pub use consensus::{ConsensusParams, ConsensusFork, BitcoinCashConsensusParams, SegWit2xConsensusParams}; +pub use consensus::{ConsensusParams, ConsensusFork, BitcoinCashConsensusParams}; pub use deployments::Deployment; pub use network::{Magic, Network}; diff --git a/pbtc/cli.yml b/pbtc/cli.yml index 4d62880f..99d293f5 100644 --- a/pbtc/cli.yml +++ b/pbtc/cli.yml @@ -12,9 +12,6 @@ args: - segwit: long: segwit help: Enable SegWit verification rules. - - segwit2x: - long: segwit2x - help: Enable SegWit2x verification rules. - bitcoin-cash: long: bitcoin-cash help: Use Bitcoin Cash verification rules. diff --git a/pbtc/config.rs b/pbtc/config.rs index 00e10e64..e15594a2 100644 --- a/pbtc/config.rs +++ b/pbtc/config.rs @@ -4,7 +4,7 @@ use db; use message::Services; use network::{Network, ConsensusParams, ConsensusFork}; use p2p::InternetProtocol; -use seednodes::{mainnet_seednodes, testnet_seednodes, segwit2x_seednodes, bitcoin_cash_seednodes, bitcoin_cash_testnet_seednodes}; +use seednodes::{mainnet_seednodes, testnet_seednodes, bitcoin_cash_seednodes, bitcoin_cash_testnet_seednodes}; use rpc_apis::ApiSet; use {USER_AGENT, REGTEST_USER_AGENT}; use primitives::hash::H256; @@ -73,7 +73,6 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { // to skip idiotic 30 seconds delay in test-scripts let user_agent_suffix = match consensus.fork { ConsensusFork::NoFork => "", - ConsensusFork::SegWit2x(_) => "/SegWit2x", ConsensusFork::BitcoinCash(_) => "/UAHF", }; let user_agent = match network { @@ -96,7 +95,7 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { None => None, }; - let mut seednodes: Vec = match matches.value_of("seednode") { + let seednodes: Vec = match matches.value_of("seednode") { Some(s) => vec![s.parse().map_err(|_| "Invalid seednode".to_owned())?], None => match (network, &consensus.fork) { (Network::Mainnet, &ConsensusFork::BitcoinCash(_)) => bitcoin_cash_seednodes().into_iter().map(Into::into).collect(), @@ -106,10 +105,6 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { (Network::Other(_), _) | (Network::Regtest, _) | (Network::Unitest, _) => Vec::new(), }, }; - match consensus.fork { - ConsensusFork::SegWit2x(_) => seednodes.extend(segwit2x_seednodes().into_iter().map(Into::into)), - _ => (), - } let only_net = match matches.value_of("only-net") { Some(s) => s.parse()?, @@ -126,7 +121,7 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { let services = Services::default().with_network(true); let services = match &consensus.fork { &ConsensusFork::BitcoinCash(_) => services.with_bitcoin_cash(true), - &ConsensusFork::NoFork | &ConsensusFork::SegWit2x(_) => services.with_witness(true), + &ConsensusFork::NoFork => services.with_witness(true), }; let verification_level = match matches.value_of("verification-level") { @@ -174,15 +169,14 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { fn parse_consensus_fork(db: &db::SharedStore, matches: &clap::ArgMatches) -> Result { let old_consensus_fork = db.consensus_fork()?; - let new_consensus_fork = match (matches.is_present("segwit"), matches.is_present("segwit2x"), matches.is_present("bitcoin-cash")) { - (false, false, false) => match &old_consensus_fork { + let new_consensus_fork = match (matches.is_present("segwit"), matches.is_present("bitcoin-cash")) { + (false, false) => match &old_consensus_fork { &Some(ref old_consensus_fork) => old_consensus_fork, - &None => return Err("You must select fork on first run: --segwit, --segwit2x, --bitcoin-cash".into()), + &None => return Err("You must select fork on first run: --segwit, --bitcoin-cash".into()), }, - (true, false, false) => "segwit", - (false, true, false) => "segwit2x", - (false, false, true) => "bitcoin-cash", - _ => return Err("You can only pass single fork argument: --segwit, --segwit2x, --bitcoin-cash".into()), + (true, false) => "segwit", + (false, true) => "bitcoin-cash", + _ => return Err("You can only pass single fork argument: --segwit, --bitcoin-cash".into()), }; match &old_consensus_fork { @@ -194,7 +188,6 @@ fn parse_consensus_fork(db: &db::SharedStore, matches: &clap::ArgMatches) -> Res Ok(match new_consensus_fork { "segwit" => ConsensusFork::NoFork, - "segwit2x" => ConsensusFork::SegWit2x(Default::default()), "bitcoin-cash" => ConsensusFork::BitcoinCash(Default::default()), _ => unreachable!("hardcoded above"), }) diff --git a/pbtc/seednodes.rs b/pbtc/seednodes.rs index 4730ff02..7b94bb3d 100644 --- a/pbtc/seednodes.rs +++ b/pbtc/seednodes.rs @@ -41,12 +41,3 @@ pub fn bitcoin_cash_testnet_seednodes() -> Vec<&'static str> { "testnet-seed.bitprim.org:18333", ] } - -pub fn segwit2x_seednodes() -> Vec<&'static str> { - vec![ - "seed.mainnet.b-pay.net:8333", - "seed.ob1.io:8333", - "seed.blockchain.info:8333", - "bitcoin.bloqseeds.net:8333", - ] -} diff --git a/verification/src/accept_block.rs b/verification/src/accept_block.rs index 501290ae..0c6d89d4 100644 --- a/verification/src/accept_block.rs +++ b/verification/src/accept_block.rs @@ -111,7 +111,6 @@ impl<'a> BlockSerializedSize<'a> { // before SegWit: it is main check for size // after SegWit: without witness data, block size should be <= 1_000_000 // after BitcoinCash fork: block size is increased to 8_000_000 - // after SegWit2x fork: without witness data, block size should be <= 2_000_000 if size < self.consensus.fork.min_block_size(self.height) || size > self.consensus.fork.max_block_size(self.height) { return Err(Error::Size(size)); @@ -164,7 +163,6 @@ impl<'a> BlockSigops<'a> { // before SegWit: 20_000 // after SegWit: cost of sigops is sigops * 4 and max cost is 80_000 => max sigops is still 20_000 // after BitcoinCash fork: 20_000 sigops for each full/partial 1_000_000 bytes of block - // after SegWit2x fork: cost of sigops is sigops * 4 and max cost is 160_000 => max sigops is 40_000 let size = self.block.size(); if sigops > self.consensus.fork.max_block_sigops(self.height, size) { return Err(Error::MaximumSigops); @@ -174,7 +172,6 @@ impl<'a> BlockSigops<'a> { // before SegWit: no witnesses => cost is sigops * 4 and max cost is 80_000 // after SegWit: it is main check for sigops // after BitcoinCash fork: no witnesses => cost is sigops * 4 and max cost depends on block size - // after SegWit2x: it is basic check for sigops, limits are increased if sigops_cost > self.consensus.fork.max_block_sigops_cost(self.height, size) { Err(Error::MaximumSigopsCost) } else { diff --git a/verification/src/accept_transaction.rs b/verification/src/accept_transaction.rs index 6422be60..c2fc48bc 100644 --- a/verification/src/accept_transaction.rs +++ b/verification/src/accept_transaction.rs @@ -313,7 +313,7 @@ impl<'a> TransactionEval<'a> { let verify_dersig = height >= params.bip66_height; let signature_version = match params.fork { ConsensusFork::BitcoinCash(ref fork) if height >= fork.height => SignatureVersion::ForkId, - ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) | ConsensusFork::SegWit2x(_) => SignatureVersion::Base, + ConsensusFork::NoFork | ConsensusFork::BitcoinCash(_) => SignatureVersion::Base, }; let verify_checksequence = deployments.csv();