From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2773EC001E; Sat, 1 Jan 2022 20:04:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 050884039D; Sat, 1 Jan 2022 20:04:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -1.497 X-Spam-Level: X-Spam-Status: No, score=-1.497 tagged_above=-999 required=5 tests=[BAYES_50=0.8, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aczJk2xLNUO5; Sat, 1 Jan 2022 20:04:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0506240180; Sat, 1 Jan 2022 20:04:14 +0000 (UTC) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (authenticated bits=0) (User authenticated as jlrubin@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 201K4BBp021623 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Sat, 1 Jan 2022 15:04:12 -0500 Received: by mail-lf1-f45.google.com with SMTP id r4so23396598lfe.7; Sat, 01 Jan 2022 12:04:12 -0800 (PST) X-Gm-Message-State: AOAM53300+zGcVRGqioQYsE9UuZzedaOYhS6T7G7PCKp3mpC54xdK0TR 1HfRVbTA4AEHIiWFUyxtvyXESpbuWw2F3h61uwo= X-Google-Smtp-Source: ABdhPJwARmdcHPBju3W/i9gL9CCkQic7V5wDz5ZEXUvCLjQWUNI7vsDyxOpKiF2CXOSV8SCrWiOHQAqplbLzWSnohD4= X-Received: by 2002:a05:6512:33c9:: with SMTP id d9mr29906956lfg.516.1641067451100; Sat, 01 Jan 2022 12:04:11 -0800 (PST) MIME-Version: 1.0 From: Jeremy Date: Sat, 1 Jan 2022 12:04:00 -0800 X-Gmail-Original-Message-ID: Message-ID: To: Bitcoin development mailing list , lightning-dev Content-Type: multipart/alternative; boundary="00000000000079b39405d48acabd" Subject: [bitcoin-dev] [Pre-BIP] Fee Accounts X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Jan 2022 20:04:17 -0000 --00000000000079b39405d48acabd Content-Type: text/plain; charset="UTF-8" Happy new years devs, I figured I would share some thoughts for conceptual review that have been bouncing around my head as an opportunity to clean up the fee paying semantics in bitcoin "for good". The design space is very wide on the approach I'll share, so below is just a sketch of how it could work which I'm sure could be improved greatly. Transaction fees are an integral part of bitcoin. However, due to quirks of Bitcoin's transaction design, fees are a part of the transactions that they occur in. While this works in a "Bitcoin 1.0" world, where all transactions are simple on-chain transfers, real world use of Bitcoin requires support for things like Fee Bumping stuck transactions, DoS resistant Payment Channels, and other long lived Smart Contracts that can't predict future fee rates. Having the fees paid in band makes writing these contracts much more difficult as you can't merely express the logic you want for the transaction, but also the fees. Previously, I proposed a special type of transaction called a "Sponsor" which has some special consensus + mempool rules to allow arbitrarily appending fees to a transaction to bump it up in the mempool. As an alternative, we could establish an account system in Bitcoin as an "extension block". *Here's how it might work:* 1. Define a special anyone can spend output type that is a "fee account" (e.g. segwit V2). Such outputs have a redeeming key and an amount associated with them, but are overall anyone can spend. 2. All deposits to these outputs get stored in a separate UTXO database for fee accounts 3. Fee accounts can sign only two kinds of transaction: A: a fee amount and a TXID (or Outpoint?); B: a withdraw amount, a fee, and an address 4. These transactions are committed in an extension block merkle tree. While the actual signature must cover the TXID/Outpoint, the committed data need only cover the index in the block of the transaction. The public key for account lookup can be recovered from the message + signature. 5. In any block, any of the fee account deposits can be: released into fees if there is a corresponding tx; consolidated together to reduce the number of utxos (this can be just an OP_TRUE no metadata needed); or released into fees *and paid back* into the requested withdrawal key (encumbering a 100 block timeout). Signatures must be unique in a block. 6. Mempool logic is updated to allow attaching of account fee spends to transactions, the mempool can restrict that an account is not allowed more spend more than it's balance. *But aren't accounts "bad"?* Yes, accounts are bad. But these accounts are not bad, because any funds withdrawn from the fee extension are fundamentally locked for 100 blocks as a coinbase output, so there should be no issues with any series of reorgs. Further, since there is no "rich state" for these accounts, the state updates can always be applied in a conflict-free way in any order. *Improving the privacy of this design:* This design could likely be modified to implement something like Tornado.cash or something else so that the fee account paying can be unlinked from the transaction being paid for, improving privacy at the expense of being a bit more expensive. Other operations could be added to allow a trustless mixing to be done by miners automatically where groups of accounts with similar values are trustlessly split into a common denominator and change, and keys are derived via a verifiable stealth address like protocol (so fee balances can be discovered by tracing the updates posted). These updates could also be produced by individuals rather than miners, and miners could simply honor them with better privacy. While a miner generating an update would be able to deanonymize their mixes, if you have your account mixed several times by independent miners that could potentially add sufficient privacy. The LN can also be used with PTLCs to, in theory, have another individual paid to sponsor a transaction on your behalf only if they reveal a valid sig from their fee paying account, although under this model it's hard to ensure that the owner doesn't pay a fee and then 'cancel' by withdrawing the rest. However, this could be partly solved by using reputable fee accounts (reputation could be measured somewhat decentralized-ly by longevity of the account and transactions paid for historically). *Scalability* This design is fundamentally 'decent' for scalability because adding fees to a transaction does not require adding inputs or outputs and does not require tracking substantial amounts of new state. Paying someone else to pay for you via the LN also helps make this more efficient if the withdrawal issues can be fixed. *Lightning:* This type of design works really well for channels because the addition of fees to e.g. a channel state does not require any sort of pre-planning (e.g. anchors) or transaction flexibility (SIGHASH flags). This sort of design is naturally immune to pinning issues since you could offer to pay a fee for any TXID and the number of fee adding offers does not need to be restricted in the same way the descendant transactions would need to be. *Without a fork?* This type of design could be done as a federated network that bribes miners -- potentially even retroactively after a block is formed. That might be sufficient to prove the concept works before a consensus upgrade is deployed, but such an approach does mean there is a centralizing layer interfering with normal mining. Happy new year!! Jeremy -- @JeremyRubin --00000000000079b39405d48acabd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Happy new years devs,

I figured I would share some thoughts for conceptual review that have be= en bouncing around my head as an opportunity to clean up the fee paying sem= antics in bitcoin "for good". The design space is very wide on th= e approach I'll share, so below is just a sketch of how it could work w= hich I'm sure could be improved greatly.

Transaction fees are an = integral part of bitcoin.

<= div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif= ;font-size:small;color:#000000">However, due to quirks of Bitcoin's tra= nsaction design, fees are a part of the transactions that they occur in.

While this works in a "Bitcoin 1.0" world, where all transact= ions are simple on-chain transfers, real world use of Bitcoin requires supp= ort for things like Fee Bumping stuck transactions, DoS resistant Payment C= hannels, and other long lived Smart Contracts that can't predict future= fee rates. Having the fees paid in band makes writing these contracts much= more difficult as you can't merely express the logic you want for the = transaction, but also the fees.

<= /div>
Previously, I proposed a special type= of transaction called a "Sponsor" which has some special consens= us=C2=A0+ mempool rules to allow arbitrarily appending fees to a transactio= n to bump it up in the mempool.

<= /div>
As an alternative, we could establish= an account system in Bitcoin as an "extension block".

H= ere's how it might work:

=
1. Define a special anyone can spend= output type that is a "fee account" (e.g. segwit V2). Such outpu= ts have a redeeming key and an amount associated with them, but are overall= anyone can spend.
2. All deposits to= these outputs get stored in a separate UTXO database for fee accounts
3. Fee accounts can sign only two kinds o= f transaction: A: a fee amount and a TXID (or Outpoint?); B: a withdraw amo= unt, a fee, and an=C2=A0address
4. Th= ese transactions are committed in an extension block merkle tree. While the= actual signature must cover the TXID/Outpoint, the committed data need onl= y cover the index in the block of the transaction. The public key for accou= nt lookup can be recovered from the message=C2=A0+ signature.
5. In any block, any of the fee account deposits c= an be: released into fees if there is a corresponding tx; consolidated toge= ther to reduce the number of utxos (this can be just an OP_TRUE no metadata= needed); or released into fees *and paid back* into the requested withdraw= al key (encumbering a 100 block timeout). Signatures must be unique in a bl= ock.
6. Mempool logic is updated to a= llow attaching of account fee spends to transactions, the mempool can restr= ict that an account is not allowed more spend more than it's balance.

But aren't accounts "bad"?

Yes, accounts ar= e bad. But these accounts are not bad, because any funds withdrawn from the= fee extension are fundamentally locked for 100 blocks as a coinbase output= , so there should be no issues with any series of reorgs. Further, since th= ere is no "rich state" for these accounts, the state updates can = always be applied in a conflict-free way in any order.


Improving the privacy of this design:

This design could likely be modified to implement something like Torna= do.cash or something else so that the fee account paying can be unlinked fr= om the transaction being paid for, improving privacy at the expense of bein= g a bit more expensive.

Other operations could be added to allow a tr= ustless mixing to be done by miners automatically where groups of accounts = with similar values are trustlessly =C2=A0split into a common denominator a= nd change, and keys are derived via a verifiable stealth address like proto= col (so fee balances can be discovered by tracing the updates posted). Thes= e updates could also be produced by individuals rather than miners, and min= ers could simply honor them with better privacy. While a miner generating a= n update would be able to deanonymize their mixes, if you have your account= mixed several times by independent miners that could potentially add suffi= cient privacy.

The LN can also be used with PTLCs to, in theory, ha= ve another individual paid to sponsor a transaction on your behalf only if = they reveal a valid sig from their fee paying account, although under this = model it's hard to ensure that the owner doesn't pay a fee and then= 'cancel' by withdrawing the rest. However, this could be partly so= lved by using reputable fee accounts (reputation could be measured somewhat= decentralized-ly by longevity of the account and transactions paid for his= torically).

Scalability
=
This design is fundamenta= lly 'decent' for scalability because adding fees to a transaction d= oes not require adding inputs or outputs and does not require tracking subs= tantial amounts of new state.

Paying someone else to pay for you via = the LN also helps make this more efficient if the withdrawal issues can be = fixed.

Lightning:
This type of design works reall= y well for channels because the addition of fees to e.g. a channel state do= es not require any sort of pre-planning (e.g. anchors) or transaction flexi= bility (SIGHASH flags). This sort of design is naturally immune to pinning = issues since you could offer to pay a fee for any TXID and the number of fe= e adding offers does not need to be restricted in the same way the descenda= nt transactions would need to be.
<= br>
Without a fork?

This= type of design could be done as a federated network that bribes miners -- = potentially even retroactively after a block is formed. That might be suffi= cient to prove the concept works before a consensus upgrade is deployed, bu= t such an approach does mean there is a centralizing layer interfering with= normal mining.


Happy new= year!!

Jeremy

--00000000000079b39405d48acabd--