Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: BlackHatCoiner on July 14, 2020, 07:23:46 PM



Title: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 14, 2020, 07:23:46 PM
How can I enable this option on regtest? Right now if I want to mine 10000 blocks, I can do it within a minute. But I want to try being Satoshi. That mined the first blocks with 10 minutes difference on average.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 14, 2020, 08:57:43 PM
Just mine blocks at higher difficulty. For example you can make sure that first 32 bits are zeroes, then you will get exactly the same as in mainnet in 2009. Also, you can just run mainnet detached from the network and start mining on top of Genesis Block with mainnet difficulty.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 14, 2020, 09:13:44 PM
Just mine blocks at higher difficulty. For example you can make sure that first 32 bits are zeroes, then you will get exactly the same as in mainnet in 2009. Also, you can just run mainnet detached from the network and start mining on top of Genesis Block with mainnet difficulty.

And how exactly do I increase difficulty?


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: jackg on July 14, 2020, 09:19:40 PM
I think you can change the difficulty to be set on 10 minutes per block bere: https://bitcoin.stackexchange.com/questions/84433/mining-difficulty-is-not-changed-on-regtest

(note it's an average of 10 minutes - you might want to isolate the process to a single thread if you try this as your computer might go slow).


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 15, 2020, 06:08:01 AM
You don't have to change source code. If running regtest, you can just configure your miner to produce blocks with higher difficulty. If running mainnet detached from the network, you will get it by default, if your wallet is not synchronized and you will start from Genesis Block. So the easiest option is probably just running mainnet and making sure it will be detached from the network.

So, to begin with, you can just:
1) make sure there is no ".bitcoin" or similar directory, so you begin from Genesis Block, it is probably enough to just rename existing dir (if any)
2) run mainnet
3) disable network activity (click icon in bottom right corner)
4) start mining using "generatetoaddress"


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 15, 2020, 06:34:52 AM
You don't have to change source code. If running regtest, you can just configure your miner to produce blocks with higher difficulty. If running mainnet detached from the network, you will get it by default, if your wallet is not synchronized and you will start from Genesis Block. So the easiest option is probably just running mainnet and making sure it will be detached from the network.

So, to begin with, you can just:
1) make sure there is no ".bitcoin" or similar directory, so you begin from Genesis Block, it is probably enough to just rename existing dir (if any)
2) run mainnet
3) disable network activity (click icon in bottom right corner)
4) start mining using "generatetoaddress"

When I use that command:
Code:
generatetoaddress 1 "bc1q33hjxx9wfnantaze4xd3j4jnjeq0srhzmp563q"

I get the following error:
Code:
CreateNewBlock: TestBlockValidity failed: bad-fork-prior-to-checkpoint (code 67) (code -1)


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 15, 2020, 07:04:28 AM
You have to use legacy address (starting from one), because segwit is a soft-fork that was activated many, many blocks after the Genesis Block. You wanted to "try being Satoshi" and he used this coin many years before segwit was introduced.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 15, 2020, 07:09:36 AM
You have to use legacy address (starting from one), because segwit is a soft-fork that was activated many, many blocks after the Genesis Block. You wanted to "try being Satoshi" and he used this coin many years before segwit was introduced.

Code:
generatetoaddress 1 "3FFEdtxyXkLFHoL8Gn91aXTNrxevraKnEK"

returns:

Code:
CreateNewBlock: TestBlockValidity failed: bad-fork-prior-to-checkpoint (code 67) (code -1)


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 15, 2020, 07:22:57 AM
Ok, I will demonstrate it step-by-step:
Code:
$ getnewaddress "" "legacy"
1Y83rK42gC2KHctMmzkaqB9BgZiyYZYH9
$ dumpprivkey 1Y83rK42gC2KHctMmzkaqB9BgZiyYZYH9
L2rirSQXXu3fy77BPr1gEen1SgoNuKUu89cGvEoysrPaYZyyK67f
$ generatetoaddress 1 "1Y83rK42gC2KHctMmzkaqB9BgZiyYZYH9" 1000000000
[
  "0000000056d13c49bc63b0d4a121496419d74e27a5ea0986611df1dcad787150"
]
$ getblock 0000000056d13c49bc63b0d4a121496419d74e27a5ea0986611df1dcad787150
{
  "hash": "0000000056d13c49bc63b0d4a121496419d74e27a5ea0986611df1dcad787150",
  "confirmations": 1,
  "strippedsize": 216,
  "size": 216,
  "weight": 864,
  "height": 1,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "a2f6aa713a1cf5d7ca6bd97e214e04b65abbac11fe06594de5d32371aaba5685",
  "tx": [
    "a2f6aa713a1cf5d7ca6bd97e214e04b65abbac11fe06594de5d32371aaba5685"
  ],
  "time": 1594797319,
  "mediantime": 1594797319,
  "nonce": 5153686,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000200020002",
  "nTx": 1,
  "previousblockhash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
}
$ gettransaction a2f6aa713a1cf5d7ca6bd97e214e04b65abbac11fe06594de5d32371aaba5685
{
  "amount": 0.00000000,
  "confirmations": 1,
  "generated": true,
  "blockhash": "0000000056d13c49bc63b0d4a121496419d74e27a5ea0986611df1dcad787150",
  "blockheight": 1,
  "blockindex": 0,
  "blocktime": 1594797319,
  "txid": "a2f6aa713a1cf5d7ca6bd97e214e04b65abbac11fe06594de5d32371aaba5685",
  "walletconflicts": [
  ],
  "time": 1594797319,
  "timereceived": 1594797324,
  "bip125-replaceable": "no",
  "details": [
    {
      "address": "1Y83rK42gC2KHctMmzkaqB9BgZiyYZYH9",
      "category": "immature",
      "amount": 50.00000000,
      "label": "",
      "vout": 0
    }
  ],
  "hex": "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a010000001976a91405e2c775de292850af856a685308c5de0f39d3cf88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000"
}

Edit:
Quote
Code:
generatetoaddress 1 "3FFEdtxyXkLFHoL8Gn91aXTNrxevraKnEK"
It is not legacy address. Legacy address should start with one, not three!


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 15, 2020, 07:27:01 AM
I did every single step you said. It still returns me the bad-fork-prior-to-checkpoint error on generatetoaddress.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 15, 2020, 07:43:43 AM
1. Do you have network activity disabled? (click icon in bottom right corner if it is enabled)
2. What client version do you have? I am using Bitcoin Core version v0.20.0.
3. Do you have any blocks after the Genesis Block? Command "getblockcount" should give you zero. If it is bigger than that, you have to recreate bitcoin directory or invalidate previous blocks using "invalidateblock" command.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: BlackHatCoiner on July 15, 2020, 07:52:12 AM
1. Do you have network activity disabled? (click icon in bottom right corner if it is enabled)
2. What client version do you have? I am using Bitcoin Core version v0.20.0.
3. Do you have any blocks after the Genesis Block? Command "getblockcount" should give you zero. If it is bigger than that, you have to recreate bitcoin directory or invalidate previous blocks using "invalidateblock" command.

1. I have network activity disabled.
2. I use v0.19.2, does it matter?
3. getblockcount gives me 0.


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: vjudeu on July 15, 2020, 08:34:12 AM
I cannot see Bitcoin Core 0.19.2, after Bitcoin Core 0.19.1 there is Bitcoin Core 0.20.0. Are you getting your client from https://github.com/bitcoin/bitcoin/releases (https://github.com/bitcoin/bitcoin/releases)?


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: HCP on July 15, 2020, 09:38:35 AM
As far as I'm aware, there was no 0.19.2... they went straight from 0.19.1 to 0.20.0.

As for the error... does your Bitcoin Core instance currently have transactions that you're created using your SegWit address(es)? ??? If so, that might be screwing things up...


Title: Re: Regnet - Don't blocks get mined every 10 minutes?
Post by: caymanguy on July 19, 2020, 09:44:10 AM
I cannot see Bitcoin Core 0.19.2, after Bitcoin Core 0.19.1 there is Bitcoin Core 0.20.0. Are you getting your client from https://github.com/bitcoin/bitcoin/releases (https://github.com/bitcoin/bitcoin/releases)?
previous versions of the client may not correctly display blocks installed and saved in the new version.