Delivery-date: Wed, 19 Mar 2025 02:04:42 -0700 Received: from mail-yw1-f184.google.com ([209.85.128.184]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tupLt-0000Ol-Kg for bitcoindev@gnusha.org; Wed, 19 Mar 2025 02:04:42 -0700 Received: by mail-yw1-f184.google.com with SMTP id 00721157ae682-6fec1d75f7asf77843317b3.0 for ; Wed, 19 Mar 2025 02:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1742375075; x=1742979875; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:sender:from :to:cc:subject:date:message-id:reply-to; bh=fPlj/wsJjE+LaFiRw2xNq+nFuwALGL3AzqFya5tZhPg=; b=VCWj3wEmOomzRa43JSc4Bvho9e8K7a/7JZTra+qiXrMSaLdXC3THnNzUU+7i8CElnp sOjJTSEBhsnvVW3cdKNvE0o71gpRvS/gRWmGdjb2Nmmb/SuUueD5VqFRemqbcmx/I2LP KiVCoAcCIUxy8k9PNP0c3G3ppQVFTMIuG57sfE+FYwJ6XYjwujlnH9alEAJQSAandmsI BRIoDYwWhnlKI6xkVzEUvoubSdC5tWrLLHu5wNN7pIrWgvKH2zw55c1O9chw0PQPnhBU sLIYbhL9SuRCJescZwDR//5osYPG43dihA9SYBD3kHqeRRmszsl8j98Ys6h4pE2oA9hR Rcbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742375075; x=1742979875; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=fPlj/wsJjE+LaFiRw2xNq+nFuwALGL3AzqFya5tZhPg=; b=XEvg+/ijTT5V4JT2suI0wNxfLPPyZNiVfD+eLC1Cf48ClX3WPAsM0JZyc5JGgM+SYL FvuHYHZBTVWdx/s8csuLmG1miR6NeQLoc56KVmxN3FtqZAyXhqEEXzBmq1ukzd62A1QN tv1Ock5ji9NuxbZIG9dsXJwOYhqBuMRX5EXU6VkuV8WhRBjRbNl1pHLJTpKeQKtbmGTh qZ3qtXjhySIwv8HyBW28+wR/GR1wAplbPzzJtXzwSCdUJkxgjKy3+kU5TPpwIS0HlKKz loJpjGhqr2mfwgUX+Ki33pkSs1tHwJv3pVkS4HnRVkQax9R/GstUv12n2/UeZHMJeX6X rdvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742375075; x=1742979875; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=fPlj/wsJjE+LaFiRw2xNq+nFuwALGL3AzqFya5tZhPg=; b=PKyZJxuSRoi75VxudwJaHgOZlzCPjP6VVnPXNPFH1KTEbY9i3PX3CU+P3SwT+HOVQc gSJUhOeGMVmPgl7NtYIIdoELwhgmaNbQFuU8TRP8HlatJPGuj8zsuuU+EN9Bzw53qXoL RC5E6/6CcD5XdApHtbNzyDMnIDSbCxrte1botxTrriMPR4gGOF3tty0cSn+IeNAWXg9z //NELcVg5ktc1VRlUGJGrstFLamhUerPaj/Kxbs4Unv4EtWlFuvCiAX8+0kqxVNxzLr/ 8XUFTE39EsEwothZHu2Q8Z2uUIthsRh1SFw3N0PLFAPPwPervm1q4QnflrMfsQvXorHY 8lfg== Sender: bitcoindev@googlegroups.com X-Forwarded-Encrypted: i=1; AJvYcCVjvhgkhMoe1+jw25xGBj6eO5KmIJw/3XVdnXpPclvoLREin/Pui9Xm7xtJSAa+R4uAGifZxEQ6uhMP@gnusha.org X-Gm-Message-State: AOJu0YxTLaoJWtxm4R0zvcay/4m+GVaDHFYZ+HutnXnGBsYImwu3XxRr VW4mm8ZHj1/r5VRaupDyH7uxdpL/M444IPC6yhk0B7GEx0HU/RyC X-Google-Smtp-Source: AGHT+IGtfhvIQWAROdYUp3wFiRurv8SdT/Wj8wVr1AgD7NH8hMzpP7bXS1cVqXURkGf9X9JQmJe4OQ== X-Received: by 2002:a05:6902:2303:b0:e63:7760:4842 with SMTP id 3f1490d57ef6-e667b44859cmr2182263276.47.1742375075523; Wed, 19 Mar 2025 02:04:35 -0700 (PDT) X-BeenThere: bitcoindev@googlegroups.com; h=ARLLPALLv1xAz44OL0cdbaMNMxW7nBt9Ok77sk6I6pSuo8JgLg== Received: by 2002:a25:7243:0:b0:e61:1c4c:6d6b with SMTP id 3f1490d57ef6-e66779a4dbals875315276.2.-pod-prod-02-us; Wed, 19 Mar 2025 02:04:32 -0700 (PDT) X-Received: by 2002:a05:690c:c14:b0:6fd:4473:5184 with SMTP id 00721157ae682-7009c161100mr26560427b3.35.1742375072008; Wed, 19 Mar 2025 02:04:32 -0700 (PDT) Received: by 2002:a05:690c:6a86:b0:6ef:590d:3213 with SMTP id 00721157ae682-7009ba67b03ms7b3; Wed, 19 Mar 2025 01:43:17 -0700 (PDT) X-Received: by 2002:a05:690c:4913:b0:6f9:525d:a096 with SMTP id 00721157ae682-7009bf4a40bmr25482587b3.3.1742373796383; Wed, 19 Mar 2025 01:43:16 -0700 (PDT) Date: Wed, 19 Mar 2025 01:43:16 -0700 (PDT) From: Garlo Nicon To: Bitcoin Development Mailing List Message-Id: <66e51750-56d3-4fc7-b55b-eb838c07adb4n@googlegroups.com> In-Reply-To: <688E575D-C370-4D7D-A6DB-11E0B56710B1@sprovoost.nl> References: <688E575D-C370-4D7D-A6DB-11E0B56710B1@sprovoost.nl> Subject: Re: [bitcoindev] Unbreaking testnet4 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_113040_143961308.1742373796070" X-Original-Sender: garlonicon@gmail.com Precedence: list Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com List-ID: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Score: -0.5 (/) ------=_Part_113040_143961308.1742373796070 Content-Type: multipart/alternative; boundary="----=_Part_113041_938972227.1742373796070" ------=_Part_113041_938972227.1742373796070 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It seems you are right. However, this rule is based on block timestamps,=20 which gives me another idea: what about simply invalidating a block, if the= =20 block time difference is bigger than 20 minutes? Because that's what ASIC= =20 miners would want to do anyway, to reorg a long chain of CPU-mined blocks:= =20 if the difficulty is 12345678, and you can see hundreds of blocks with=20 difficulty 1, then a single block with difficulty 12345678 will reorg all= =20 of these CPU-mined blocks in a single shot. By the way: if we are entering a hard-fork territory, and if testnet4 coins= =20 are traded, then what about switching to testnet5 with new rules instead? And also, in case of any forks, there is a question, how many miners will= =20 actually support new changes. Because in case of new timewarp rules, we saw= =20 hundreds of blocks being reorged, because some ASIC miners didn't upgrade= =20 their code: https://github.com/bitcoin/bitcoin/issues/30786 And even when mempool.space upgraded their code, a few weeks after that, I= =20 could still see some ASIC nodes in the wild, which were mining on the wrong= =20 branch, and with just a CPU, it was possible to fork them once every 2016= =20 blocks, for a few hundred blocks. =C5=9Broda, 19 marca 2025 o 08:59:26 UTC+1 Sjors Provoost napisa=C5=82(a): > > > > Op 19 mrt 2025, om 08:01 heeft Garlo Nicon het=20 > volgende geschreven: > >=20 > > > I propose to fix this by removing the difficulty reset rule from=20 > testnet4 through a flag day hard fork on 2026-01-01. > >=20 > > You can do that in a soft-fork way. Just rejecting blocks with=20 > difficulty=3D1, and requiring always a block with the true network=20 > difficulty, is a valid soft-fork. > > Unfortunately it's a hard-fork. > > > So, I assume if you change "fPowAllowMinDifficultyBlocks" from "true" t= o=20 > "false", when block time will be greater than unix time "1767225600", the= n=20 > you will get a valid soft-fork. > > > The fPowAllowMinDifficultyBlocks rule says that after 20 minutes the new= =20 > block MUST have difficulty 1. A block with the real difficulty will be=20 > rejected. > > This is because in general the block nBits value, which announces how muc= h=20 > work the block has, must have an exact value. It can't be higher. > > In validation.cpp we have this: > > if (block.nBits !=3D GetNextWorkRequired(pindexPrev, &block,=20 > consensusParams)) > return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER,=20 > "bad-diffbits", "incorrect proof of work"); > > Inside GetNextWorkRequired there is the testnet exception rule, which=20 > Antoine proposes to drop: > > if (params.fPowAllowMinDifficultyBlocks) { > // Special difficulty rule for testnet: > // If the new block's timestamp is more than 2* 10 minutes > // then allow mining of a min-difficulty block. > if (pblock->GetBlockTime() > pindexLast->GetBlockTime() +=20 > params.nPowTargetSpacing*2) > return nProofOfWorkLimit; > else > ... (same difficulty as last block, unless it's a retarget) > > The code comment is misleading, "allow" should be "require". > > - Sjors --=20 You received this message because you are subscribed to the Google Groups "= Bitcoin Development Mailing List" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoindev+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/= 66e51750-56d3-4fc7-b55b-eb838c07adb4n%40googlegroups.com. ------=_Part_113041_938972227.1742373796070 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It seems you are right. However, this rule is based on block timestamps, wh= ich gives me another idea: what about simply invalidating a block, if the b= lock time difference is bigger than 20 minutes? Because that's what ASIC mi= ners would want to do anyway, to reorg a long chain of CPU-mined blocks: if= the difficulty is 12345678, and you can see hundreds of blocks with diffic= ulty 1, then a single block with difficulty 12345678 will reorg all of thes= e CPU-mined blocks in a single shot.

By the way: if we are enter= ing a hard-fork territory, and if testnet4 coins are traded, then what abou= t switching to testnet5 with new rules instead?

And also, in cas= e of any forks, there is a question, how many miners will actually support = new changes. Because in case of new timewarp rules, we saw hundreds of bloc= ks being reorged, because some ASIC miners didn't upgrade their code: https= ://github.com/bitcoin/bitcoin/issues/30786

And even when mempool= .space upgraded their code, a few weeks after that, I could still see some = ASIC nodes in the wild, which were mining on the wrong branch, and with jus= t a CPU, it was possible to fork them once every 2016 blocks, for a few hun= dred blocks.

=C5=9Broda, 19 marca 2025 o=C2=A008:59:26 UTC+1 Sjors Provo= ost napisa=C5=82(a):


> Op 19 mrt 2025, om 08:01 heeft Garlo Nicon <garlo...@gmail.com> het volgende geschreven:
>=20
> > I propose to fix this by removing the difficulty reset rule f= rom testnet4 through a flag day hard fork on 2026-01-01.
>=20
> You can do that in a soft-fork way. Just rejecting blocks with dif= ficulty=3D1, and requiring always a block with the true network difficulty,= is a valid soft-fork.

Unfortunately it's a hard-fork.

> So, I assume if you change "fPowAllowMinDifficultyBlocks"= ; from "true" to "false", when block time will be great= er than unix time "1767225600", then you will get a valid soft-fo= rk.


The fPowAllowMinDifficultyBlocks rule says that after 20 minutes the ne= w block MUST have difficulty 1. A block with the real difficulty will be r= ejected.

This is because in general the block nBits value, which announces how m= uch work the block has, must have an exact value. It can't be higher.

In validation.cpp we have this:

if (block.nBits !=3D GetNextWorkRequired(pindexPrev, &block, consen= susParams))
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, &= quot;bad-diffbits", "incorrect proof of work");

Inside GetNextWorkRequired there is the testnet exception rule, which A= ntoine proposes to drop:

if (params.fPowAllowMinDifficultyBlocks) {
// Special difficulty rule for testnet:
// If the new block's timestamp is more than 2* 10 minutes
// then allow mining of a min-difficulty block.
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + = params.nPowTargetSpacing*2)
return nProofOfWorkLimit;
else
... (same difficulty as last block, unless it's a retarget)

The code comment is misleading, "allow" should be "requi= re".

- Sjors

--
You received this message because you are subscribed to the Google Groups &= quot;Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoind= ev/66e51750-56d3-4fc7-b55b-eb838c07adb4n%40googlegroups.com.
------=_Part_113041_938972227.1742373796070-- ------=_Part_113040_143961308.1742373796070--