<oembed><type>rich</type><version>1.0</version><title>lisa neigut [ARCHIVE] wrote</title><author_name>lisa neigut [ARCHIVE] (npub1sp…s64t2)</author_name><author_url>https://yabu.me/npub1sprhp66c693av0c0n9had046hcdcckp2th25fnmphwstc5e4wg9qxs64t2</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2020-02-10&#xA;📝 Original message:&#xA;&gt; But if you impose the blockheight - 6 in the Lightning protocol level,&#xA;and Lightning succeeds (meaning a substantial fraction of blockchain&#xA;transactions are Lightning opens)...&#xA;&gt;  --- then transactions with `nLockTime` equal to the block they are&#xA;included in minus 5 will be more common than others, and would be a&#xA;reliable indicator that the transaction is a Lightning channel funding&#xA;attempt.&#xA;&#xA;Ah good point. This can be mitigated by setting the acceptable range up to&#xA;100 then, matching the behavior of bitcoind.&#xA;&lt;https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L2507-L2544&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;On Thu, Feb 6, 2020 at 6:23 PM ZmnSCPxj &lt;ZmnSCPxj at protonmail.com&gt; wrote:&#xA;&#xA;&gt; Good morning lisa,&#xA;&gt;&#xA;&gt; &gt; &gt; I am unsure what is the purpose of this minus 6.&#xA;&gt; &gt;&#xA;&gt; &gt; The original motivation was to keep the funding transaction from being&#xA;&gt; rejected from the mempool in the case of a re-org, but as you pointed out,&#xA;&gt; the &#39;next block&#39; is always at -par or ahead of the current chain tip, so&#xA;&gt; I&#39;m not sure this accomplishes this goal.  I&#39;m not sure how bitcoind&#xA;&gt; handles the mempool in the case of the &#39;best block&#39; moving to another tip,&#xA;&gt; the goal of setting it to -6 is to avoid the funding transaction being&#xA;&gt; evicted.&#xA;&gt;&#xA;&gt; My understanding is that it rewinds the abandoned tip, putting the&#xA;&gt; transactions in those blocks back into its local mempool (which may lead to&#xA;&gt; evictions if the mempool gets full), all the way to the branch-off point,&#xA;&gt; then it re-adds blocks back to the new tip (which can lead to removals from&#xA;&gt; the mempool, if transactions in the block spend the same UTXOs (or *are*&#xA;&gt; the same transactions) as transactions in the mempool).&#xA;&gt; The main effect is that there could be suddenly higher fee pressure for&#xA;&gt; the transactions in the reorged-away blocks (because of possible mempool&#xA;&gt; congestion if the longer chainsplit has fewer transactions per block), but&#xA;&gt; that is why the dual-funding protocol has RBF built-in right?&#xA;&gt;&#xA;&gt; Setting blockheight - 6 also increases the incentive of potential&#xA;&gt; deliberate reorgers to actually perform a reorg attack, because the&#xA;&gt; transaction you just added is valid for earlier blocks that the reorger&#xA;&gt; wants to rewrite.&#xA;&gt; This is a bad thing, because you want your funding txout to be confirmed,&#xA;&gt; not have parts of global hashpower contemplating reorgs and delaying your&#xA;&gt; confirmations even more.&#xA;&gt;&#xA;&gt;&#xA;&gt; &gt;&#xA;&gt; &gt; In practice, setting the locktime back a few blocks makes the funding&#xA;&gt; transaction eligible for inclusion in any of the previous six blocks, so in&#xA;&gt; case of a reorg there&#39;s a higher probability it will have been included in&#xA;&gt; the reorganization. In other words, it enables fee-sniping for up to 6&#xA;&gt; blocks in the hopes that any &#39;eligible&#39; re-org includes the funding&#xA;&gt; transaction (the short channel id will change, but otherwise the channel&#xA;&gt; open will be the same).&#xA;&gt; &gt;&#xA;&gt; &gt; On second thought, this doesn&#39;t seem like something that we should&#xA;&gt; include at the protocol level; if a peer wanted to &#39;allow fee-sniping for&#xA;&gt; up to X blocks&#39;, then they&#39;d simply relay the &#34;blocktip&#34; that they&#39;re using&#xA;&gt; for the nLocktime to be at the depth they&#39;d desire. Though it might be&#xA;&gt; worth imposing a limit as to how far back in the past a peer can allow&#xA;&gt; fee-sniping for... no more than 6 blocks from our current tip seems&#xA;&gt; reasonable. (This would then limit the &#39;acceptable range&#39; for an offset of&#xA;&gt; an initiator to 5, as your peer may be off from your tip by one.)&#xA;&gt; &gt;&#xA;&gt; &gt; On that note, I believe bitcoind fuzzes the nLocktime value to obfuscate&#xA;&gt; exactly what blockheight the outgoing transaction was composed / broadcast&#xA;&gt; at, which is probably something we should encourage in lightning&#xA;&gt; implementations as well.&#xA;&gt;&#xA;&gt; But if you impose the blockheight - 6 in the Lightning protocol level, and&#xA;&gt; Lightning succeeds (meaning a substantial fraction of blockchain&#xA;&gt; transactions are Lightning opens) --- then transactions with `nLockTime`&#xA;&gt; equal to the block they are included in minus 5 will be more common than&#xA;&gt; others, and would be a reliable indicator that the transaction is a&#xA;&gt; Lightning channel funding attempt.&#xA;&gt; The fuzzing may not be big enough to cover that, as there is a 10% chance&#xA;&gt; to fuzz and about 1% subsequent chance (total 0.1% chance) that Bitcoin ore&#xA;&gt; will put a transaction at blockheight - 6 (as opposed to the 99 other&#xA;&gt; possibilities: blockheight - 0 to blockheight - 99 inclusive).&#xA;&gt; So once more than 0.1% of onchain transactions are Lightning&#xA;&gt; dual-fundings, an analyst has &gt; 50% chance of correctly betting that a&#xA;&gt; blockheight - 5 transaction (yes, - 5, because a transaction can typically&#xA;&gt; be added only on the next block) is a Lightning funding.&#xA;&gt;&#xA;&gt;&#xA;&gt; You are better off with blockheight, possibly with SPV-header-chain-proofs&#xA;&gt; if one side or the other thinks the blockheight has changed since one side&#xA;&gt; or the other proposed it.&#xA;&gt;&#xA;&gt;&#xA;&gt; Regards,&#xA;&gt; ZmnSCPxj&#xA;&gt;&#xA;&gt; &gt;&#xA;&gt; &gt; On Wed, Feb 5, 2020 at 8:25 PM ZmnSCPxj &lt;ZmnSCPxj at protonmail.com&gt; wrote:&#xA;&gt; &gt;&#xA;&gt; &gt; &gt; Good morning niftynei,&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; Rusty had some suggestions about how to improve the protocol&#xA;&gt; messages for this, namely adding a serial_id to the inputs and outputs,&#xA;&gt; which can then be reused for deletions.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; The serial id can then also be used as the ordering heuristic for&#xA;&gt; transaction inputs during construction (replacing current usage of BIP69).&#xA;&gt; Inputs can be shared amongst peers by flipping the bottom bit of the&#xA;&gt; serial_id before relaying them to another peer (as your own).&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; What happens if the initiator deliberately provides serial IDs 0x1,&#xA;&gt; 0x3, .... while the acceptor naively provides serial IDs from&#xA;&gt; `/dev/urandom`?&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Then the balance of probability is that the initiator inputs and&#xA;&gt; outputs are sorted before the acceptor.&#xA;&gt; &gt; &gt; Now, this is probably not an issue, since the initiator and acceptor&#xA;&gt; both know which inputs and outputs are theirs and not theirs, so they could&#xA;&gt; just reveal this information to anyone, so an actor providing such lousy&#xA;&gt; serial IDs is just hurting its own privacy relative to blockchain analysts,&#xA;&gt; so probably will not happen in practice.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; My initial reaction was to propose adding a secret-sharing round where&#xA;&gt; the resulting key is XORed to each serial ID before sorting by the XORed&#xA;&gt; serial ID, but this might be too overweight, and again the initiator is&#xA;&gt; only hurting its own privacy, and the two participants already know whose&#xA;&gt; money is whose anyway....&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; See below for details.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; 1. type:   440 `tx_add_input`&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; 2. data:&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`32*byte`:`channel_identifier`]&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt;         * [`32*byte`:``serial_id`]&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; Add a serial id.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; Each input addition must have a unique serial id.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; No addition may have a repeated id number.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; The initiator&#39;s serial id&#39;s must be odd. The non-initiator&#39;s serial&#xA;&gt; id&#39;s must be even.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; Serial ids are used as sorting heuristic for input ordering in final&#xA;&gt; transaction, replaces BIP69&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u64`:`sats`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`sha256`:`prevtx_txid`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u32`:`prevtx_vout`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u16`:`prevtx_scriptpubkey_len`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u16`:`max_witness_len`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u16`:`scriptlen`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`scriptlen*byte`:`script`]&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; Removes the signal_rbf; everything will be flagged as RBF eligible.&#xA;&gt; (This makes verifying RBF eligibility during a RBF round simpler.)&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Yes. Ish.&#xA;&gt; &gt; &gt; RBF and privacy do not work well together unfortunately.&#xA;&gt; &gt; &gt; This is still initiator-pays, right?&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; 1. subtype: `witness_element`&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; 2. data:&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`u16`:`len`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt;     * [`len*byte`:`witness`]&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; ## General Notes&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; - All output scripts must be standard&#xA;&gt; &gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; &gt; - nLocktime is always set to 0x00000000&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; - If a blockheight to be used as nLocktime is communicated in the&#xA;&gt; initiation step, is set to blockheight-6; otherwise set to zero-&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; I am unsure what is the purpose of this minus 6.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; If you fear blockheight disagreements, this is probably a good time to&#xA;&gt; introduce block headers.&#xA;&gt; &gt; &gt; So for example if the acceptor thinks the initiator blockheight is too&#xA;&gt; high, it could challenge the initiator to give block headers from its known&#xA;&gt; blockheight to the initiator blockheight.&#xA;&gt; &gt; &gt; If the acceptor thinks the initiator blockheight is too low, it could&#xA;&gt; provide block headers itself as proof.&#xA;&gt; &gt; &gt; This could be limited so that gross differences in blockheight are&#xA;&gt; outright rejected by the acceptor (it could `error` the temporary channel&#xA;&gt; ID rather than accept it).&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; This is SPV, but neither side is actually making or accepting a&#xA;&gt; payment *yet*, just synchronizing clocks, so maybe not as bad as normal SPV.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Massive chain reorgs cannot reduce blockheight, only increase it (else&#xA;&gt; the reorg attempt fails in the first place) so there must still exist at&#xA;&gt; least one chain(split) with the highest known blockheight already given a&#xA;&gt; proof-of-header-chain, and all you really need is some mining activity on&#xA;&gt; top of *one* split that confirms your funding transaction.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; If it is not because of blockheight disagreements or massive chain&#xA;&gt; reorgs, what is the purpose of `blockheight - 6`?&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; - Serial ids should be chosen at random&#xA;&gt; &gt; &gt; &gt; - For multiparty constructions, the initiator MUST flip the bottom&#xA;&gt; bit of any received inputs before relaying them to a peer.&#xA;&gt; &gt; &gt; &gt;&#xA;&gt; &gt; &gt; &gt; - Collisions of serial ids between peers is a protocol error&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; I suppose we should define collision to mean &#34;equal in all bits except&#xA;&gt; the lowest bit&#34;.&#xA;&gt; &gt; &gt;&#xA;&gt; &gt; &gt; Regards,&#xA;&gt; &gt; &gt; ZmnSCPxj&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200210/26f95449/attachment-0001.html&gt;</html></oembed>