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

New BIP: Ordinal Numbers #1408

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
289 changes: 289 additions & 0 deletions bip-0000.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
<pre>
BIP: ?
Layer: Applications
Title: Ordinal Numbers
Author: Casey Rodarmor <casey@rodarmor.com>
Comments-Summary: No comments yet.
Comments-URI: https://github.com/casey/ord/discussions/126
casey marked this conversation as resolved.
Show resolved Hide resolved
Status: Draft
Type: Informational
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me which BIP type this draft would correspond to WRT BIP2. An Informational BIP does not propose a new feature. Nor does this seem to fit the criteria for a Standards Track BIP or a Process BIP.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a look at the three kinds of BIPS:

There are three kinds of BIP:

  • A Standards Track BIP describes any change that affects most or all Bitcoin implementations, such as a change to the network protocol, a change in block or transaction validity rules, or any change or addition that affects the interoperability of applications using Bitcoin. Standards Track BIPs consist of two parts, a design document and a reference implementation.

Ordinals does not affect most or all Bitcoin implementations, so it shoudn't be a Standards Track BIP.

  • 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. Informational BIPs do not necessarily represent a Bitcoin community consensus or recommendation, so users and implementors are free to ignore Informational BIPs or follow their advice.

Ordinals is essentially an application-level technology, so I think it fits into "guidelines or information", and doesn't propose a new feature, so I think it should be a Informational BIP. For example, see BIP-32, Hierarchical Deterministic Wallets. Anyone is free to use HD wallets, or not, similar to ordinals, so I think Informational BIP fits best.

  • A Process BIP describes a process surrounding Bitcoin, or proposes a change to (or an event in) a process. Process BIPs are like Standards Track BIPs but apply to areas other than the Bitcoin protocol itself. They may propose an implementation, but not to Bitcoin's codebase; they often require community consensus; unlike Informational BIPs, they are more than recommendations, and users are typically not free to ignore them. Examples include procedures, guidelines, changes to the decision-making process, and changes to the tools or environment used in Bitcoin development. Any meta-BIP is also considered a Process BIP.

Ordinals does not require consensus and users are free to ignore ordinals, so this shouldn't be a Process BIP.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've implemented a wallet and block explorer, with public instances on mainnet, signet, and testnet, and a wallet that uses sat control to ensure specific sats are transferred to specific outputs. Constructing such transactions is tricky, especially given the dust limit and doing proper fee estimation, but once you get the details right it works well, and the fact that such transactions are otherwise normal Bitcoin transactions means that existing bitcoin infrastructure can be leveraged.

defines a scheme for assigning serial numbers to sats

provide stable identifiers

Whereas BIP32 describes a design implemented in the Bitcoin reference client, these appear to clearly describe features, thus my own hesitation with respect to Informational. There has been discussion to update or improve BIP 2, and perhaps a clarification on BIP scope will be an aspect of that.

Created: 2022-02-02
License: CC0-1.0
</pre>

== Introduction ==

=== Abstract ===

This document defines a scheme for assigning serial numbers to sats.

=== Copyright ===

This work is placed in the public domain.

=== Motivation ===

Bitcoin has no notion of stable, public accounts or identities. Addresses are
single-use, and wallet accounts are private. Additionally, the use of addresses
or public keys as stable identifiers precludes transfer of ownership or key
rotation.

This proposal is motivated by the desire to provide stable identifiers that may
be used by Bitcoin applications.
casey marked this conversation as resolved.
Show resolved Hide resolved

== Description ==

=== Design ===

Every sat is serially numbered, starting at 0, in the order in which it is
mined. These numbers are termed "ordinal numbers", or "ordinals", as they are
ordinal numbers in the mathematical sense, giving the order of each sat in the
total supply. The word "ordinal" is nicely unambiguous, as it is not used
elsewhere in the Bitcoin protocol.

The ordinal numbers of sats in transaction inputs are transferred to output
sats in first-in-first-out order, according to the size and order of the
transactions inputs and outputs.
Comment on lines +44 to +46
Copy link

@ghost ghost Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like ordinals and inscriptions. However, the concept of assigning serial numbers to sats or transferring them based on size and order isnt a part of bitcoin protocol. So ordinals do not really require a BIP and could work at layer 2 or externally.

Note: This repo is considered an official bitcoin repo for improvements. However, you can always maintain such docs outside this repo and could be used by other bitcoin projects if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIPs are not just about layer 1 protocols. As an example, BIPs 173/350 (bech32 and bech32m) define an address format that never touches the p2p layer at all. BIP32 describes a key derivation scheme that is not even visible on the blockchain or p2p layer.

Essentially, to get a BIP, you just need to post something on the mailing list and then post a well-formatted well-specified document here. It doesn't need to be something that anybody needs to use, or even something that anybody should use. I guess it needs to be sorta Bitcoin-related, but this meets that threshold :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This doc could be maintained outside the BIPs repo but if the author wants a BIP I don't see a reason to prevent this.

From BIP 2:

Reasons for rejecting BIPs include duplication of effort, disregard for formatting rules, being too unfocused or too broad, being technically unsound, not providing proper motivation or addressing backwards compatibility, or not in keeping with the Bitcoin philosophy. For a BIP to be accepted it must meet certain minimum criteria. It must be a clear and complete description of the proposed enhancement. The enhancement must represent a net improvement. The proposed implementation, if applicable, must be solid and must not complicate the protocol unduly.

The "must represent a net improvement" is a bit of a grey area but when unsure I think the BIP editors should lean towards giving the BIP number. If people want to use ordinals a specification on how to use ordinals (ideally using block space as efficiently as possible) seems like a net improvement to me.


If a transaction is mined with the same transaction ID as outputs currently in
the UTXO set, following the behavior of Bitcoin Core, the new transaction
outputs displace the older UTXO set entries, destroying the sats contained in
any unspent outputs of the first transaction. This rule is required to handle
the two pairs of mainnet transactions with duplicate transaction IDs, namely
the coinbase transactions of blocks 91812/91842, and 91722/91880, mined before
[https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki BIP-34] made
the creation of transactions with duplicate IDs impossible.

For the purposes of the assignment algorithm, the coinbase transaction is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph and next could use more clarification. If the input order is coinbase subsidy + inputs of fee-paying transactions, what is the result when a miner forgoes either the subsidy and/or fees? Which ordinals are "burned" those from the subsidy, or those from the fees paid? E.g., at time of writing, subsidy is 625,000,000 sats. If fees paid are another 10,000,000 and the miner erroneously accepts 322,500,000 does that burn effectively burn the ordinals of all the fees paid and part of the subsidy that should have been ?

considered to have an implicit input equal in size to the subsidy, followed by
an input for every fee-paying transaction in the block, in the order that those
transactions appear in the block. The implicit subsidy input carries the
block's newly created sats. The implicit fee inputs carry the sats that were
paid as fees in the block's transactions.

Underpaying the subsidy does not change the ordinal numbers of sats mined
in subsequent blocks. Ordinals depend only on how many sats could have been
mined, not how many actually were.

=== Specification ===
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specification in BIPs is (as far as I understand) usually given in plain English with well-defined notation where necessary, not in code (reference implementation can be included in the BIP's corresponding folder). This is (again, as far as I understand) not a hard requirement for merging, just something to consider.


Sats are numbered and transferred with the following algorithm:
casey marked this conversation as resolved.
Show resolved Hide resolved

<source lang="python">
casey marked this conversation as resolved.
Show resolved Hide resolved
casey marked this conversation as resolved.
Show resolved Hide resolved
# subsidy of block at given height
def subsidy(height):
return 50 * 100_000_000 >> height // 210_000

# first ordinal of subsidy of block at given height
def first_ordinal(height):
start = 0
for height in range(height):
start += subsidy(height)
return start

# assign ordinals in given block
def assign_ordinals(block):
first = first_ordinal(block.height)
last = first + subsidy(block.height)
coinbase_ordinals = list(range(first, last))

for transaction in block.transactions[1:]:
ordinals = []
for input in transaction.inputs:
ordinals.extend(input.ordinals)

for output in transaction.outputs:
output.ordinals = ordinals[:output.value]
del ordinals[:output.value]

coinbase_ordinals.extend(ordinals)

for output in block.transaction[0].outputs:
output.ordinals = coinbase_ordinals[:output.value]
del coinbase_ordinals[:output.value]
Comment on lines +101 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion of the spec means that when a miner underpays the subsidy, the first sat destroyed is the last sat from the fee of the last transaction. While it would complicate the spec slightly, there are 2 alternatives I think worth considering:

  1. fees go first, then subsidy
  2. compute lost_sats = len(fee_ordinals)+subsidy(block.height)-sum(outs) and then before appending fee ordinals do coinbase_ordinals = coinbase_ordinals[:-lost_sats]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite facilitating non-fungible behavior, there is nothing in this that inhibits treating the sats as fully-fungible which means that the value of a single 'fee sat' is the same as the value of a single 'subsidy sat'. Given that, the priority should be on the single large range from the subsidy as that is the simpler range to track/store/lookup whereas the fee will be made, typically, of many small ranges.

</source>

A miner may underpay the block reward, in which case
<code>coinbase_ordinals</code> will not be empty when
<code>assign_ordinals</code> returns. These sats are lost and not assigned to
any output of the coinbase transaction.

=== Terminology and Notation ===

A satpoint may be used to indicate the location of a sat within an output. A
satpoint consists of an outpoint, i.e., a transaction ID and output index, with
the addition of the offset of the ordinal within that output. For example, if
the sat in question is at offset 6 in the first output of a transaction, its
satpoint is:

<code>680df1e4d43016571e504b0b142ee43c5c0b83398a97bdcfd94ea6f287322d22:0:6</code>

== Discussion ==

=== Rationale ===

Ordinal numbers are designed to be orthogonal to other aspects of the Bitcoin
protocol, and can thus be used in conjunction with other layer one and layer
applications, even ones that were not designed with ordinal numbers in mind.

Ordinal sats can be secured using current and future script types. They can be
held by single-signature wallets, multi-signature wallets, time-locked, and
height-locked in all the usual ways.

By assigning ordinal numbers to all sats without the need for an explicit
creation step, the anonymity set of ordinal number users is maximized.
casey marked this conversation as resolved.
Show resolved Hide resolved

Since a sat has an output that contains it, and an output has a public key that
casey marked this conversation as resolved.
Show resolved Hide resolved
controls it, the owner of a sat can respond to challenges by signing messages
using the address associated with the controlling UTXO. Additionally, a sat can
change hands, or its private key can be rotated without a change of ownership,
by transferring it to a new output.

Ordinals require no changes to blocks, transactions, or network protocols, and
can thus be immediately adopted, or ignored, without impacting existing users.

Ordinals do not have an explicit on-chain footprint. However, a valid objection
is that adoption of ordinals will increase demand for outputs, and thus
casey marked this conversation as resolved.
Show resolved Hide resolved
increase the size of the UTXO set that full nodes must track. See the
objections section below.

The ordinal number scheme is extremely simple. The specification above is 15
lines of code.
casey marked this conversation as resolved.
Show resolved Hide resolved

Ordinals are fairly assigned. They are not premined, and are assigned
proportionally to existing bitcoin holders.
casey marked this conversation as resolved.
Show resolved Hide resolved

Ordinals are as granular as possible, as bitcoin is not capable of tracking
ownership of sub-sat values.
casey marked this conversation as resolved.
Show resolved Hide resolved

=== Transfer and the Dust Limit ===

Any single-sat transfer can be accomplished in a single transaction, but the
resulting transaction may contain outputs below the dust limit, and thus be
non-standard and difficult to get included in a block. Consider a scenario
where Alice owns an output containing the range of sats [0,10], the current
dust limit is 5 sats, and Alice wishes to send send sat 4 and 6 to Bob, but
retain ordinal 5. Alice could construct a transaction with three outputs of
size 5, 1, and 5, containing sats [0,4], 5, and [6,10], respectively. The
second output is under the dust limit, and so such a transaction would be
non-standard.

This transfer, and indeed any transfer, can be accomplished by breaking the
transfer into multiple transactions, with each transaction performing one or
more splits and merging in padding outputs as needed.

To wit, Alice could perform the desired transfer in two transactions. The first
transaction would send sats [0,4] to Bob, and return as change sat [5,10] to
Alice. The second transaction would take as inputs an output of at least 4
sats, the change input, and an additional input of at least one sat; and create
an output of size 5 to Bob's address, and the remainder as a change output.
Both transactions avoid creating any non-standard outputs, but still accomplish
the same desired transfer of sats.

=== Objections ===

''Privacy: Ordinal numbers are public and thus reduce user privacy.''

The applications using ordinal numbers required them to be public, and reduce
the privacy of only those users that decide to use them.

''Fungibility: Ordinal numbers reduce the fungibility of Bitcoin, as ordinals
received in a transaction may carry with them some public history.''

As anyone can send anyone else any sats, any reasonable person will assume that
a new owner of a particular sat cannot be understood to be the old owner, or
have any particular relationship with the old owner.
casey marked this conversation as resolved.
Show resolved Hide resolved
casey marked this conversation as resolved.
Show resolved Hide resolved

''Congestion: Adoption of ordinal numbers will increase the demand for
transactions, and drive up fees.''

Since Bitcoin requires the development of a robust fee market, this is a strong
positive of the proposal.
casey marked this conversation as resolved.
Show resolved Hide resolved

''UTXO set bloat: Adoption of ordinal numbers will increase the demand for
entries in the UTXO set, and thus increase the size of the UTXO set, which all
full nodes are required to track.''

The dust limit, which makes outputs with small values difficult to create,
should encourage users to create non-dust outputs, and to clean them up once
they no longer have use for the sats that they contain.
casey marked this conversation as resolved.
Show resolved Hide resolved
casey marked this conversation as resolved.
Show resolved Hide resolved

=== Security ===

The public key associated with a sat may change. This requires actively
casey marked this conversation as resolved.
Show resolved Hide resolved
following the blockchain to keep up with key changes, and requires care
compared to a system where public keys are static. However, a system with
static public keys suffers from an inability for keys to be rotated or accounts
to change hands.

Ordinal-aware software must avoid losing valuable sats by unintentionally
relinquishing them in a transaction, either to a non-controlled output or by
using them as fees.
casey marked this conversation as resolved.
Show resolved Hide resolved

=== Privacy considerations ===

Ordinals are opt-in, and should not impact the privacy of existing users.

Ordinals are themselves public, however, this is required by the fact that many
of the applications that they are intended to enable require public
identifiers.

Ordinal aware software should never mix sats which might have some publicly
visible data associated with their ordinals with sats intended for use in
payments or savings, since this would associate that publicly visible data with
casey marked this conversation as resolved.
Show resolved Hide resolved
the users otherwise pseudonymous wallet outputs.

=== Fungibility considerations ===

Since any sat can be sent to any address at any time, sat that are transferred,
casey marked this conversation as resolved.
Show resolved Hide resolved
even those with some public history, should be considered to be fungible with
other sats with no such history.

=== Backward compatibility ===

Ordinal numbers are fully backwards compatible and require no changes to the
bitcoin network.

=== Drawbacks ===

==== Large Index Size ====

Indexes supporting fast queries related to ordinals are slow to build and
consume large amounts of space.

As of January, 2023, an O(1) index that maps UTXOs to the ordinals that they
contain is 100 GiB. The same index including spent outputs is 10 TiB.
casey marked this conversation as resolved.
Show resolved Hide resolved

An O(1) index supporting the opposite mapping, that of individual ordinals to
the UTXO that contains them, is likely to be intractable. However, an O(n)
index where n is the number of times an ordinal has changed hands, is fast and
practical.

==== Large Location Proofs ====

A proof can be constructed that demonstrates that a particular sat is contained
in a particular output, however the proofs are large. Such a proof consists of:

* Block headers
* A Merkle path to the coinbase transaction that created the sat
* The coinbase transaction that created the sat
* And for every spend of that sat:
** The spend transaction
** The transactions that created the inputs before the input that was spent, to determine the values of the preceding inputs, to determine the position of the sat
** And, if the sat was used as fees, all prior transaction in the block in which it was spent, and the coinbase transaction, to determine the location of the sat in the outputs.
casey marked this conversation as resolved.
Show resolved Hide resolved

== Reference implementation ==

This document and an implementation of an index that tracks the position of
sats in the main chain are maintained [https://github.com/casey/ord here].
casey marked this conversation as resolved.
Show resolved Hide resolved

== References ==

A variation of this scheme was independently invented a decade ago by jl2012
[https://bitcointalk.org/index.php?topic=117224.0 on the Bitcoin Forum].

For other colored coin proposals see [https://en.bitcoin.it/wiki/Colored_Coins
the Bitcoin Wiki entry].

For aliases, an implementation of short on-chain identifiers, see
[https://github.com/bitcoin/bips/blob/master/bip-0015.mediawiki BIP 15].