Subject: Re: [bitcoindev] Re: Unbreaking testnet4

From: pithosian <[email-masked]>
Date: Mon, 12 May 2025 20:19:16 +0000 (UTC)

> Not only that. It may also invalidate timelocked signatures, which
> would be made around "halving".

Good point. I was thinking about just hacking at the UTXO set as it
conceptually seemed to make the change very localized, but timelocks
probably(?) rule the whole approach out.

The freely-spendable amount would be:

amount/2^(targetHeight/halvingBlocks-utxoHeight/halvingBlocks)

Or the bitshift equivalent, where targetHeight is the current height,
or in the case of timelocks, the locked height, but longer
timestamp-based timelocks can't be reasoned about very well with any
'degrading coin' behaviour, and even your presigned, height locked
transaction might not get be confirmed before the next epoch if the
timelock approaches it.

Doesn't modifying spendability have the same problem? When presigning
your timelocked transaction, you need to be aware of the amount you can
actually spend come expiry of the timelock up-front, however the coin
degrades.

It also breaks lightning channels, I think.

On Mon, 12 May 2025 18:18:09 +0000 (UTC)
Saint Wenhao <[email-masked]> wrote:

> > Updating the entire UTXO set all at once would be pretty expensive,
> 
> Not only that. It may also invalidate timelocked signatures, which
> would be made around "halving". So, if you would sign something, when
> block height will be set to 209,990, and timelock it into 20 blocks,
> then at block height 210,010, it would be invalid, because of
> incorrect amount.
> 
> Which means, that stored UTXO amounts should be probably left
> untouched, but rather spendability of the coins should be affected.
> So: if someone received 50 tBTC, then that person should be able to
> freely move 25 tBTC anywhere, but 25 tBTC can be enforced to go
> directly into transaction fees (and so on, and so forth, so later it
> would be splitted into 12.5 spendable tBTC, and 37.5 tBTC fees).
> 
> And then, that kind of fees can be claimed directly by miners, or can
> be simply burned, by just not claiming it, if you want to permanently
> throw it away from the UTXO set, without leaving any trace.
> 
> pon., 12 maj 2025 o 15:50 pithosian <[email-masked]>
> napisał(a):
> 
> > Another option is to invert the halving logic on testnet (to what
> > some newbies occasionally think the halving is on mainnet); don't
> > halve the subsidy, half the existing supply.
> >
> > Fix the subsidy:
> > validation.cpp
> >   CAmount GetBlockSubsidy(int nHeight, const Consensus::Params&
> >   consensusParams) { if (consensusParams.fixedSubsidy != 0) {
> >       return consensusParams.fixedSubsidy;
> >     }
> >
> > Then as the last step of processing a block, after its txs have been
> > applied to chainstate, check if it's a halving block and, if it is
> > (and some consensus flag is set), halve the value of all existing
> > UTXOs.
> >
> > The result is:
> > 1. We'd never exceed a 21m coins.
> > 2. We'd disincentivise hoarding.
> > 3. We'd ensure permanent liquidity on testnet.
> >
> > Updating the entire UTXO set all at once would be pretty expensive,
> > though, and over enough halvings you'd have a bunch of zero value
> > UTXOs we may or may not be able to clean up.
> >
> > On Mon, 12 May 2025 11:03:23 +0000 (UTC)
> > Anthony Towns <[email-masked]> wrote:
> >
> > > > > Hard fork in an ultramassive premine, as large as possible but
> > > > > what stays with existing value overflow logic. (so maybe an
> > > > > additional 21 million testnet btc?).
> > >
> > > The existing logic gives errors if:
> > >
> > >   * a single input of a tx (ie a coin in the utxo set), or the
> > > sum of inputs to a txn, is outside the range 0-21M
> > > (bad-txns-inputvalues-outofrange)
> > >
> > >   * a single output of a tx is outside the range 0-21M
> > >     (bad-txns-vout-negative or bad-txns-vout-toolarge)
> > >
> > >   * the sum of the outputs of a single tx is outside the range
> > > 0-21M (bad-txns-txouttotal-toolarge)
> > >
> > >   * the fee paid by a single tx is outside the range 0-21M
> > >     (bad-txns-fee-outofrange)
> > >
> > >   * a block's fees go outside the range 0-21M
> > >     (bad-txns-accumulated-fee-outofrange)
> > >
> > > Keeping the total supply under 21M seems nicer than having txs
> > > that spend real utxos be able to hit these errors (eg, by
> > > combining the premine utxo at 21M with a coinbase reward of 50
> > > and hitting bad-txns-inputvalues-outofrange).
> > >
> > > That's pretty easy to achieve: just have the initial premine be
> > > half the supply (eg), and also cut the halvening time in half (so
> > > 10.5M premine, 105,000 blocks in a halving). Or you could have
> > > halvenings every 6 months (26250 blocks), and have an 18.375M
> > > premine, or whatever.
> > >
> > > You could also consider premining (almost) the entire supply, and
> > > have the block reward be entirely fees (almost) immediately after
> > > that, but I think there's value in making it possible to obtain
> > > coins for testing in a permissionless, anonymous and relatively
> > > low-latency manner, for which PoW is great. Might also be
> > > annoying for empty blocks to pay a reward of exactly 0, so if
> > > miners included their address in the coinbase tx like normal,
> > > they'd be creating a 0 valued utxo, and probably never spend it.
> > >
> > > I had a quick poke at what code to allow for chains with premines
> > > might look like here:
> > >
> > >   https://github.com/ajtowns/bitcoin/commits/202505-premine/
> > >
> > > About 11 lines of code to implement the logic.
> > >
> > > If this approach made the testnet difficulty reset logic obsolete
> > > (ie, a testnet with just PoW and a premine turns out to work
> > > fine), that would drop 14 lines of code for the
> > > fPowAllowMinDifficultyBlocks and enforce_BIP94 logic. Presumably
> > > a PoW-only testnet could also have its min-difficulty bumped from
> > > 1 to 65536 or more, since it seems like a single Bitaxe can still
> > > maintain the chain at that difficulty.
> > >
> > > The idea of this approach is that when establishing a premined
> > > testnet, you would:
> > >
> > >  a) first define the chain, with a new genesis, etc; then set
> > >     nSubsidyHalvingInterval=105000 and premine=10'500'000*COIN or
> > > similar, but leave premine_block_hash=0
> > >
> > >  b) build the node software, and mine block 1 to the premine
> > > address.
> > >
> > >  c) set premine_block_hash to block 1's hash. publish the code
> > > with the genesis block and block 1 hash, so that the public can
> > > mine as of block 2.
> > >
> > >  d) once 100 blocks have been mined, split the premine up amongst
> > >     devs, faucets, wallet maintainers, user groups, a managed
> > > endowment for future testers, whatever.
> > >
> > > On Fri, May 09, 2025 at 03:07:48PM +0200, Garlo Nicon wrote:
> > > > Why hard-forking anything? The starting difficulty is set to 1,
> > > > and it raises to 4 almost instantly, when testnet creators are
> > > > mining the first coins. Which means, that difficulty 1 is
> > > > ridiculously easy to work with, when you have any ASICs. If you
> > > > combine it with the idea of fake timestamps,
> > >
> > > It's not the number of blocks, but the cumulative work that
> > > matters, so to have a soft reset of testnet3 or testnet4 you'd
> > > need to apply more hashing for the new chain than the existing
> > > chains have already received. That's a fair amount of "wasted"
> > > hash: I think mining a more-work chain than testnet4 would
> > > require about the same amount of hash that it would take to mine
> > > ~13 mainnet blocks at the current difficulty, so you'd be giving
> > > up about $4M USD in mainnet block rewards to do it.
> > >
> > > In any event, a hard fork is "necessary", as otherwise whenever it
> > > takes 20 minutes or more to find a block, old clients will expect
> > > a lower difficulty than new clients do, so the two wouldn't be
> > > compatible with each other. You could do various things to work
> > > around that, but that's a lot of coding time that could be better
> > > spent on improving things relevant to mainnet, and if you're
> > > resetting the chain anyway, there's not much advantage to it.
> > >
> > > > then you can produce a really long initial chain, which will
> > > > start in 2009, and up to 2025, it will produce almost the same
> > > > amount of blocks as mainnet.
> > >
> > > A soft fork of testnet3 would start 3rd Feb 2011 (leading to about
> > > 750k blocks vs mainnet's ~900k), and a soft fork of testnet4 would
> > > start at 4th May 2024 (leading to about 54k blocks). (These are
> > > the timestamps of the respective genesis blocks)
> > >
> > > A disadvantage of doing a premine that way is that users of the
> > > chain need to download and validate thousands of blocks and deal
> > > with an equal number of utxos just to establish the premine;
> > > doing that in a single block with a single utxo (or one utxo for
> > > each recipient of the premine) is quite a bit more efficient.
> > >
> > > > Which means, that instead of "premine", you can use
> > > > "ninja-mine", and achieve pretty much the same end result.
> > >
> > > I think in general usage "premine" covers both those approaches
> > > -- any time the creator(s) of a chain gets the opportunity to
> > > claim/distribute coins prior to the general public being able to
> > > mint new coins by mining blocks, that's a premine.
> > >
> > > Cheers,
> > > aj
> > >
> >
> > --
> > 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 email to [email-masked].
> > To view this discussion visit
> > https://groups.google.com/d/msgid/bitcoindev/20250512120531.1AC1F7C0557%40smtp.postman.i2p
> > .
> >

-- 
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 email to [email-masked].
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/20250512201916.3818A7C1190%40smtp.postman.i2p.