Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ephemeral Anchors #29001

Closed
wants to merge 30 commits into from
Closed

Conversation

instagibbs
Copy link
Member

@instagibbs instagibbs commented Dec 5, 2023

Depends on #28948 and #28984

Replaces #26403 to refresh the conversation.

BIP text here: https://github.com/instagibbs/bips/blob/ephemeral_anchor/bip-ephemeralanchors.mediawiki

Example usage:
https://github.com/instagibbs/bolts/commits/zero_fee_commitment
https://github.com/instagibbs/lightning/commits/commit_zero_fees

TODO:

  1. figure out what precisely to do in a reorg when ephemeral transactions are trying to enter the mempool(and write a test)
  2. restrict ephemeral anchor value to 0 (future relaxation possible with more work/motivation)
  3. rebased on top of master, add in trim ephemeral anchor tx functionality when they are at 0-fee package feerate

glozow and others added 17 commits December 5, 2023 05:04
At this point it's not expected that there are any such transactions,
except from reorgs.
…o use Txid

It's preferable to use type-safe transaction identifiers to avoid
confusing txid and wtxid. The next commit will add a reference to this
set; we use this opportunity to change it to Txid ahead of time instead
of adding new uses of uint256.
As long as they are otherwise paid for, i.e. through package CPFP.
If a v3 transaction loses its sponsor, we can evict them with no trouble
because it will not have other descendants or ancestors to make the
feerate assessment more complicated.
The behavior is not new, but this rule exits earlier than before.
Previously, a carve out could have been granted in PreChecks() but then
nullified in PackageMempoolChecks() when CheckPackageLimits() is called
with the default limits.
No change in behavior.

For single transaction acceptance, this is a simple refactor:
Workspace::m_all_conflicting         -> MemPoolAccept::m_all_conflicts
Workspace::m_conflicting_fees        -> MemPoolAccept::m_conflicting_fees
Workspace::m_conflicting_size        -> MemPoolAccept::m_conflicting_size
Workspace::m_replaced_transactions   -> MemPoolAccept::m_replaced_transactions

And local variables m_total_vsize and m_total_modified_fees are now
MemPoolAccept members so they can be accessed from PackageMempoolChecks.

We want these to be package-wide variables because
- Transactions could conflict with the same tx (just not the same
prevout), or their conflicts could share descendants.
- We want to compare conflicts with the package fee rather than
individual transaction fee.

We reset these MemPoolAccept-wide fields for each subpackage
evaluation to not cause state leaking, similar to temporary
coins.
…tible

Avoid accepting replacements that are not more incentive compatible to
mine.  For now, as a somewhat conservative estimate, require that the minimum
between the transaction's individual feerate and ancestor feerate is
higher than the individual feerates of directly conflicting transactions
and the ancestor feerates of all original transactions.

Note that a package/transaction's ancestor feerate is not perfectly
representative of its incentive compatibility; it may overestimate (some
subset of the ancestors could be included by itself if it has other
high-feerate descendants or are themselves higher feerate than this
package/transaction).

Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 5, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29093 (NOMERGE UFG Default permitbaremultisig=0 by ajtowns)
  • #29088 (tests: Don't depend on value of DEFAULT_PERMIT_BAREMULTISIG by ajtowns)
  • #29086 (refactor: Simply include CTxMemPool::Options in CTxMemPool directly rather than duplicating definition by luke-jr)
  • #29050 (Add OP_TXHASH and OP_CHECKTXHASHVERIFY opcodes by stevenroose)
  • #28984 (Cluster size 2 package rbf by instagibbs)
  • #28972 (test: Add and use option for tx-version in MiniWallet methods by maflcko)
  • #28960 (kernel: Remove dependency on CScheduler by TheCharlatan)
  • #28950 (RPC: Add maxfeerate and maxburnamount args to submitpackage by instagibbs)
  • #28948 (v3 transaction policy for anti-pinning by glozow)
  • #28886 (refactor: Replace sets of txiter with CTxMemPoolEntryRefs by TheCharlatan)
  • #28676 ([WIP] Cluster mempool implementation by sdaftuar)
  • #27432 (contrib: add tool to convert compact-serialized UTXO set to SQLite database by theStack)
  • #26840 (refactor: importpubkey, importprivkey, importaddress, importmulti, and importdescriptors rpc by KolbyML)
  • #26593 (tracing: Only prepare tracepoint arguments when actually tracing by 0xB10C)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

This will be used in following commits
as the flag for ephemeral anchors, allowing
dust values, but also requiring
the output to be spend in the same relay package.
Anchor outputs are not yet required
to be spent in same mempool package.
Either in the same relay package, or by transactions RBFing
the CPFP.
@ariard
Copy link
Member

ariard commented Dec 10, 2023

BIP text here: https://github.com/instagibbs/bips/blob/ephemeral_anchor/bip-ephemeralanchors.mediawiki

"Be 0-fee”

This is uncertain to me how this rule works with trimmed HTLCs on LN commitment transactions making their fees non-zero, even assuming anchor outputs where second-stage txn are signed with 0-feerate.

Beyond, I think it should add an information section at destination of use-cases developers discouraging the usage of anyone-can-spend ephemeral anchor. Otherwise a time-sensitive package can be tampered by third-parties entering into replacement cycling games, without being a direct off-chain counterparty to the target transaction traffic.

@instagibbs
Copy link
Member Author

@ariard I'd rather talk downstream details over here bitcoin/bips#1524

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@luke-jr
Copy link
Member

luke-jr commented Dec 16, 2023

BIP text here: https://github.com/instagibbs/bips/blob/ephemeral_anchor/bip-ephemeralanchors.mediawiki

Node policy is not a subject matter for standardization in itself. It's the transaction format that the BIP (if there is one) should focus on, not speculative behaviour of individual nodes.

@ariard
Copy link
Member

ariard commented Dec 21, 2023

@ariard I'd rather talk downstream details over here bitcoin/bips#1524

Thanks good to me - Answered strong conceptual issues there.

@da2ce7
Copy link

da2ce7 commented Dec 26, 2023

@luke-jr

BIP text here: https://github.com/instagibbs/bips/blob/ephemeral_anchor/bip-ephemeralanchors.mediawiki

Node policy is not a subject matter for standardization in itself. It's the transaction format that the BIP (if there is one) should focus on, not speculative behaviour of individual nodes.

This Proposed BIP brings a set of concepts that allows the community to communicate using a coherent language regarding what "Ephemeral Anchors" are. By defining this term in context of how it could work, the community can reason about them in a clear and coherent manner, (no matter if they individuality choose to use them in their node policy or not).

It is my opinion that such a BIP proposal is perfectly applicable and beneficial toward the community communication goals:

An Informational BIP describes a Bitcoin design issue, or provides general guidelines or information to the Bitcoin community, but does not propose a new feature. [...]

@instagibbs
Copy link
Member Author

I have another branch I'm going to likely pursue once 1p1c relay is further along: instagibbs@fe67ffd

With v3 + sibling eviction, it makes sense to me to first open up the feature with current supported scriptpubkeys for when the output is considered dust.

This allows people to pick anyone can spend or shared keyed anchors. It also means any outputs can be dust, as long as they get spent.

Future updates can include:

  1. OP_1 <0xfees> style scripts as in the current PR.
  2. relaxation from V3: I suspect the cluster mempool interface will make the logic much simpler to extending it to be arbitrary tx topologies. This could allow batched CPFP and more.

@instagibbs
Copy link
Member Author

closing this in favor of #30239

@instagibbs instagibbs closed this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants