Hanchon
  • Home
  • BCH Testnet Environment
    • BCH Testnet Environment
    • BitcoinABC (bitcore patches)
    • Bitcore (insight + insight-api)
    • NOMP (mining pool)
    • CPU Miner
    • Fork the network
    • Run regtest
  • Bitprim
    • Introduction
    • Node versions
    • Requirements
    • Node installation
    • Run the node
    • Insight Installation
    • Run Insight (node + REST-API)
    • Query the insight api
  • Bitprim Node Configuration Files
    • Bitcoin Cash Testnet
    • Bitcoin Cash Mainnet
    • Bitcoin Core Testnet
    • Bitcoin Core Mainnet
    • Litecoin Testnet
    • Litecoin Mainnet
  • Bitprim Insight Configuration
    • Insight-API configuration file
  • Utils
    • Install Node Version Manager
    • Install Redis
Powered by GitBook
On this page
  • Introduction
  • Fork the network
  • First method:
  • Second method:
  • Block propagation
  1. BCH Testnet Environment

Fork the network

Ways to fork the testnet.

Introduction

Sometimes when we want to tests some tool we want to work in a private testnet to keep our tests isolated from the rest of the nodes.

Fork the network

First method:

If you are testing the node before a hard fork, setting a different activation time than the "official" testnets will create your own fork.

For the Nov 15th HardFork the current testnet is using the magneticanomalyactivationtime = 153500000 . So setting a different activation time before running the Initial Blockchain Download (IBD) will result in your node forking the network alone.

The rest of the nodes of the network will ban you for sending an invalid chain. Different activation times result in nodes with different consensus rules.

Second method:

In case you are not testing a hard fork you can simply let the IBD finish, look for the hash of the last block and invalidate it using ./bitcoin-abc/src/bitcoin-cli .

For example:

The last block is 1260770 and its hash is 000000000024bd340462fa737887b30131fa8da599f886ef8324dcc761cb9f4e . So calling invalidate block will set your current height at 1260769 and you'll be able to mine your own 1260770 block.

./bitcoin-abc/src/bitcoin-cli invalidateblock 000000000024bd340462fa737887b30131fa8da599f886ef8324dcc761cb9f4e

The parameter -conf=/path/to/bitcoin.conf can be used by the bitcoin-cli binary.

In case you need to follow the main chain, there is a method called reconsiderblock that will revalidate the block matching the hash that is passed as parameter.

For example:

Follow the testnet "official" chain after invalidating the block000000000024bd340462fa737887b30131fa8da599f886ef8324dcc761cb9f4e

./bitcoin-abc/src/bitcoin-cli reconsiderblock 000000000024bd340462fa737887b30131fa8da599f886ef8324dcc761cb9f4e

Block propagation

Using the default networking configuration will result in your node sending its blocks to the rest of the network, so it won't be a real private testnet.

There are a couple of configurations that can be changed in order to avoid connecting to other nodes. The configuration depends on what the user want to test.

For example,

  • connect = 0

  • nolisten = 1

  • maxconnections = 0

PreviousCPU MinerNextRun regtest

Last updated 6 years ago