Skip to content

[DISCUSSION] - BRC-95 Atomic BEEF vs BRC-62 BEEF  #80

Closed

Description

@dorzepowski

BRC ID

95

Discussion

It looks for me, that there may be a misunderstanding regarding BRC-62.

  1. While it’s not explicitly stated, the intent was that BEEF operates as a format for a single transaction.
    The Ordering subsection, of the BEEF specification, requires Kahn's Topological Sorting, which by definition applies to a single DAG.
    I would like @sirdeggen to confirm my understanding there.
    1. This suggests that the introduction of the "Atomic BEEF" might be unnecessary.
      Additionally, once sorting is applied, the final transaction naturally becomes the subject, removing the need for an extra field to specify it proposed in Atomic BEEF.
    2. Also It might be worth revisiting the specification to clarify these assumptions.
    3. Also consider whether this clarification affects assumptions made in other BRCs or in current implementations.
    4. It may also be necessary to introduce a new format or mechanism for handling merged lists of BEEFs. Since BEEF has been previously used in a way that implies merging multiple instances, such a format would help ensure that duplicates are removed from both the BUMP list and the transaction list. This approach would maintain the intended efficiency of the BEEF format by reducing redundancy and streamlining the overall process.

Activity

  1. tonesnotes commented on Dec 6, 2024

    @tonesnotes
    Contributor

    The BRC-62 (V1) BEEF spec was motivated to support the validity of a single transaction. But the serialization format trivially extends to support multiple new transactions, in which case it becomes a rather arbitrary requirement to say which one is "special". The sort order does require dependencies to appear before dependents, but it explicitly does not require that transactions must be no more than one generation from a BUMP. That is, from a "newness" perspective, a BEEFs purpose is to contain many transactions that are new.

    BRC-95 clarifies and makes explicit the originally assumed but not enforced use case of a BEEF in support of a single newest transaction. But in many use cases it makes a great deal of sense to aggregate and share sets of "new" transactions.

    Consider the ARC endpoint https://tapi.taal.com/arc/v1/tx to which a serialized BEEF may be posted:

    1. If I construct a BEEF with multiple new transactions, each with validity fully supported, how should ARC respond?
    2. What sense would it make to be required to create and send multiple BEEFs one at a time for each new transaction?

    A central point of Bitcoin is to support the validity of data encoded as transaction outputs. I believe the BEEF format can and should directly support this mission where it is viewed as a list of transactions and BUMP proof data which together allows for the validity of the data in those transaction outputs to be fully trusted.

    Applications and services should not be sending transactions, they should be sending BEEFs. Receive a BEEF, verify its validity, and all the transaction data it contains is good to go.

    The @bsv/sdk-ts Beef class implements the BEEF V1, V2 and Atomic specifications. It supports merging Beefs, raw transactions, and BUMPs. It implements validation and verification. This includes being able to filter down an arbitrary collection of BUMPs and transactions into an AtomicBEEF.

    Using the Beef class, here's a snapshot at the inner workings of a BEEF enabled wallet:

    1. The wallet maintains a Beef instance to hold recent transaction validity data.
    2. To build a transaction, existing outputs may be queried from back end services. These are returned with a supporting Beef which is merged into wallet Beef.
    3. New external inputs must be accompanied by a supporting Beef which is merged into wallet Beef.
    4. A full set of new inputs is sent to back end services with a supporting Beef to create and process as a new transaction.
    5. Broadcast to the network may be deferred until a batch of new transaction is completed and then broadcast.
    6. As new proofs a received, they are merged into wallet Beef.

    To understand the motivation for the V2 Beef extension specification, consider the exchange of Beefs between the local wallet and its back end services:

    1. Once the wallet receives valid transaction data from the backend it should never send the same data back, the server already knows its valid.
    2. Thus when constructing a new transaction with outputs from prior known by the server transactions, there must be an encoding for a transaction in a BEEF when the recipient is known to already possess the raw transaction and proof data.
    3. In this case, a fully V1 valid BEEF can be reduced by replacing full raw transactions with just their txids and a flag indicating that the recipient should recognize it. This is what V2 allows.
  2. tonesnotes commented on Dec 6, 2024

    @tonesnotes
    Contributor

    The BEEF V2 Spec is here: BEEF V2

  3. dorzepowski commented on Dec 10, 2024

    @dorzepowski
    ContributorAuthor

    Thank you for your response and for emphasizing the importance of Atomic BEEF. After revisiting the specifications and discussions, I’ve realized that you're referring to BEEF v2 (although in the Atomic BEEF specification BRC-62 is mentioned).

    I now understand that BEEF v2 introduces support for multiple transaction graphs. However, this has led me to reassess how BEEF, as originally defined, relates to Atomic BEEF and its motivations.

    From my perspective, the issue Atomic BEEF aims to address as described in the Motivation section does not seem to exist in the context of the original BEEF (BRC-62). The Motivation section suggests that BEEF can contain multiple unrelated transactions, but due to the required Kahn sorting, which enforces a valid topological order, BEEF inherently operates on a single Directed Acyclic Graph (DAG). Transactions that are not part of the same graph as the last transaction can validly be ignored by any tool parsing the BEEF into a class/structure.

    With regard to BEEF v2, while it introduces support for multiple transaction graphs, I believe this represents a significant departure from the single-transaction focus of the original BEEF. This divergence, while valuable for broader use cases, complicates the narrative that BEEF v2 is simply an iteration or extension of the original format. The reliance on Kahn’s sorting in BEEF makes it inherently unsuitable for multiple DAGs, as attempting to use it for such purposes could result in unpredictable behavior or ignored unrelated graphs.

    I fully recognize that you may have a different interpretation. To better understand your perspective, could you provide an example—ideally with a diagram or drawing (or ascii art) — demonstrating how multiple DAGs could be encoded in BEEF (BRC-62)? Furthermore, it would be helpful to see how Atomic BEEF specifically addresses issues that a correctly constructed BEEF (BRC-62) cannot resolve.

    Looking forward to your clarification.

  4. tonesnotes commented on Dec 10, 2024

    @tonesnotes
    Contributor

    There are two distinct points here that I'll respond to:

    1. BEEF V2 addresses data redundancy. Sending a BEEF to a party already aware of potentially large but still unmined transactions on which new transactions depend.
    2. The "multi-DAG" view of BEEF, which I'll call the "multiple-new-transactions" view of BEEF.

    Expanding on #2 first, "multiple-new-transactions".

    Even in the original single DAG view of BEEF, sending a BEEF with multiple new transactions to ARC's post BEEF endpoints currently works as it should: each new transaction (never broadcast before) gets processed into the chain. It would make no sense for a recipient to complain about an internal dependency transaction that they had not seen before but whose validity was fully supported by the BEEF.

    So even in the "only-one-newest" transaction case, single DAG, I argue it makes no sense to disallow multiple new transactions to be sent in a single BEEF.

    On to full "multiple-new-transactions", imagine we start with proven transaction A and create new transactions B and C, each of which consumes one output from A. Now I want to send B and C for processing. Am I going to create two BEEFs, each containing a full copy of A just to adhere to "AtomicBEEF"?? What I want to do is throw all three in a single BEEF with a BUMP that supports A and send the single BEEF to ARC for processing. And this works... Why would ARC ignore valid transactions for which it can easily prove validity?

    So, it seems to come down to sort order. As I see it, the critical requirement is that dependencies are serialized first: If B consumes outputs from A, then A must be serialized first. This requirement does not yield a unique sort order in the general case, but I see no reason for requiring one. The use of Kahn's algorithm seems like an example to me, not a requirement.

    Expanding on #1, BEEF V2

    When you start using BEEF to send transactions with validity data in any kind of a multi-step transaction data exchange process you should rapidly realize that V1 often requires you to return data to its source, because it is required to support the validity of yet unmined new work.

    You could serialize incomplete, unverifiable BEEFs and send that, expecting the recipient to realize they possess the missing data. This choice greatly expands the potential work to invalidate actually invalid BEEFs. BEEF validity would also depend on context: Do you possess an external validity store that has the missing data.

    BEEF V2 extends V1 by allowing transactions to be listed in the BEEF in two ways: full serialized raw transaction OR just it's 32 byte TXID. When determining the validity of a V2 BEEF, a transaction is valid either in the V1 sense OR if it is just a TXID. The recipient of a V2 BEEF can verify validity efficiently yielding an explicit list of TXIDs they are expected to already know are valid.

  5. tonesnotes commented on Dec 10, 2024

    @tonesnotes
    Contributor

    From BRC-62:

    We propose a binary format for sending Transactions between peers to allow Simple Payment Verification (SPV). The format is optimized for minimal bandwidth while maintaining data required to independently validate the transaction in full.

    "Transactions..." plural. Reading this to mean only the last transaction really matters or that they must all form a single DAG is greatly narrowing the obvious intent and utility of the specification.

    Order is important - we must ensure that we end with the tx being evaluated, and its inputs are above, and their inputs are above that. Khan's algorithm is a well known solution to the problem in Graph Theory. Running this on the transaction DAG subset is recommended for complex transaction chains where order is not clear. Example below to demonstrate with extraneous data removed for clarity.

    "Must ensure" that inputs appear as outputs before use as inputs...

    "DAG subset"..."recommended for complex transaction chains" The algorithm is explicitly not a requirement. DAG already allows for multiple new transactions B and C depending on A but not each other.

  6. tonesnotes commented on Dec 10, 2024

    @tonesnotes
    Contributor

    Transactions that are not part of the same graph as the last transaction can validly be ignored by any tool parsing the BEEF into a class/structure.

    But why would you want to?? If you are a transaction processor and someone sends you a BEEF containing multiple DAGs with validity support for each one, why would you not process all the new transactions?? If you are a business data processing service and someone sends you a BEEF with multiple DAGs, it either makes sense or doesn't based on service level context. It may certainly be beneficial.

    Only in the case where you must consider the BEEF as supporting a single transaction are you justified in ignoring unrelated data. This is the precise point of AtomicBEEF.

  7. dorzepowski commented on Dec 10, 2024

    @dorzepowski
    ContributorAuthor

    On to full "multiple-new-transactions", imagine we start with proven transaction A and create new transactions B and C, each of which consumes one output from A. Now I want to send B and C for processing.

    I understand your point and I didn't ever question the idea that we need some format for transferring, but to have a better view. I would like to ask you for an example how can I prepare with ts-sdk, Transaction so the toBEEF (BRC-62) will contain both B and C, because I would like to examine such a BEEF.

  8. dorzepowski commented on Dec 10, 2024

    @dorzepowski
    ContributorAuthor

    Thank you for your response and for elaborating on the purpose of AtomicBEEF.

    I’d like to better understand why introducing AtomicBEEF is necessary, given that BEEF v1, implemented with Kahn sorting, appears to solve the same problem without requiring additional metadata. From my involvement in preparing BEEF v1, it was designed as an extension to EF, which itself extends the RAW TX format. Our intention with BEEF was to create a format for a single transaction that provides all the information required for SPV validation in a compact, efficient structure.

    Rather than introducing a new AtomicBEEF format, wouldn’t it make sense to simply add a requirement to BEEF that the last transaction is the subject of the BEEF and that all included transactions must belong to the strict subtree of this transaction? Any unrelated transactions would then be ignored. This approach eliminates the need for adding a txid to the header of the format and aligns with the original design principles of BEEF.

    Regarding BEEF v2, I believe it could be more aptly named Aggregated BEEF to reflect its broader scope and differentiate it from the single-transaction focus of BEEF. Aggregated BEEF could use a different magic number while retaining most of the structure of BEEF, but without the single-DAG requirement (and with appropriate sorting rules). This approach preserves the understanding that has already been established in the BSV ecosystem around BEEF, while clearly delineating the new functionality.

    To illustrate the established understanding of BEEF as a single-transaction format, I’d like to point to the ts-sdk API, where the Transaction class has a method fromBEEF that returns a single transaction. This raises the question: if BEEF were intended to store or transfer multiple transactions, what would this method return in such cases?

    I hope this perspective contributes constructively to the discussion, and I look forward to further clarifications and insights.

  9. tonesnotes commented on Dec 10, 2024

    @tonesnotes
    Contributor

    I understand your point and I didn't ever question the idea that we need some format for transferring, but to have a better view. I would like to ask you for an example how can I prepare with ts-sdk, Transaction so the toBEEF (BRC-62) will contain both B and C, because I would like to examine such a BEEF.

    Certainly! The Beef class in ts-sdk supports all the formats. You could use something like the following:

    import { Beef } from '@bsv/ts-sdk'
    const beef = Beef.fromBinary(<BRC-62 BEEF of A>)
    const A = beef.findTxid(<txid of A>).Tx  // Transaction A
    const B = new Transaction() // add output 0 from A as input to B
    const C = new Transaction() // add output 1 from A as input to C
    beef.mergeTransaction(B)
    beef.mergeTransaction(C)
    const ok = await beef.verify(chainTracker)
    const beefABC: number[] = beef.toBinary()
    
  10. tonesnotes commented on Dec 10, 2024

    @tonesnotes
    Contributor

    Note that Beef.fromBinary() will read V1, V2, and AtomicBEEF serialized formats. You can force V1 format only. By default it serializes to V2 only if you use mergeTxidOnly(txid) or if you use fromBinary() on data containing txid only transactions.

  11. dorzepowski commented on Dec 12, 2024

    @dorzepowski
    ContributorAuthor

    Thank you for the example code! I will experiment with it to gain a better understanding.

    In the meantime, I’m still looking forward to your opinion or comment regarding my proposition to use BRC-62 BEEF instead of AtomicBEEF, as well as the suggestion to redefine BEEF V2 as a separate format—such as "Aggregated BEEF"—for handling a list of any transactions.

  12. locked and limited conversation to collaborators on Dec 15, 2024
  13. converted this issue into a discussion #84 on Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions