LNP-BP / LNPBPs

LNP/BP standards for bitcoin layer 2 & 3 protocols
https://standards.lnp-bp.org
202 stars 36 forks source link

Standard RGB interfaces v1 RC1 #154

Closed dr-orlovsky closed 1 year ago

dr-orlovsky commented 1 year ago

This updates all standard RGB interfaces to v0.10 requirements and capabilities, finalizing them as an initial standard for asset issuance.

All future versions will be additive, encoded as a part of the interface name in form of "RGB20rev1" etc.

Summary of the changes:

cryptoquick commented 1 year ago

So, one thing that still bothers me is the inability to specify a IDs for owner, creator, and parent. I realize assetOwner here is with reference to a UTXO, but that's highly ephemeral. With an accounts-based system, the account address is often used as a proxy for DID, but Bitcoin discourages address reuse, and so we'll need to rely on something like RGB22 for attribution, since we can't rely on on-chain ownership records, either. And attribution is very, very necessary for proving the value of an NFT. Things like provenance are useful, and so is proving a body of work is presented by a specific artist.

Some definitions:

If implemented, they'd be pointers to an RGB ID (could be any other asset, including RGB22, RGB21, etc), and it'd be really useful if some of these fields could be optionally mutable (as indicated) against either the same UTXO that owns the asset, or a separate UTXO that can be spent in exclusion. This would allow the UDA to be dynamic, and an on-chain record of DID association could be updated with each transfer, ideally within the same state transition as the transfer consignment, and not as a separate on-chain commitment.

In addition, for Carbonado, it'd be very helpful if we could include a public key alongside the hash. This allows us to change relays should infrastructure change and the node carrying the hash is no longer available. This also helps us verify the signature of the file, and nodes generally namespace their files by pubkey, and encrypt files on-disk in a way that can only be decoded if the public key is specified. And most importantly, the blake3 hash is a keyed hash, for privacy, and so a public key is needed to verify the data once it's been retrieved. The keys we use are 33-byte compressed secp256k1 pubkeys. If we didn't have pubkeys, we'd need to build additional infrastructure to support keyless lookups.

Do all these things make sense?

dr-orlovsky commented 1 year ago

@cryptoquick @zoedberg @crisdut I put the changes we discussed during our dev call today - and commented some things which you need to be aware of.

dr-orlovsky commented 1 year ago

@crisdut can you pls also provide your full name and surname such that I can add you to the author list?

crisdut commented 1 year ago

@crisdut can you pls also provide your full name and surname such that I can add you to the author list?

Sure. The full name is Armando Dutra

zoedberg commented 1 year ago

@dr-orlovsky Sorry for reporting this only now but last time I completely forgot. Shouldn't we have a timestamp field for contracts? In v0.9 this was contract metadata.

dr-orlovsky commented 1 year ago

@zoedberg yep, good point!

However, an alternative might be that we can have a dedicated interface for reporting genesis timestamp (potentially also using OTS) for all schemata, including fungibles, NFTs etc.

What do you think? I had the similar idea for the issuer identity which may be a dedicated interface.

zoedberg commented 1 year ago

@zoedberg yep, good point!

However, an alternative might be that we can have a dedicated interface for reporting genesis timestamp (potentially also using OTS) for all schemata, including fungibles, NFTs etc.

What do you think? I had the similar idea for the issuer identity which may be a dedicated interface.

Not sure what do you mean, could you please explain more in detail how this interface should work? Sounds a bit complex and I'm not sure we should add more complexity just for the timestamp, but I'm probably missing what's the advantage of the solution you're proposing

dr-orlovsky commented 1 year ago

Answering @zoedberg

Not sure what do you mean, could you please explain more in detail how this interface should work?

Interfaces are composable, meaning that a contract may implement multiple interfaces. This leaves one question which approach is better to use: normal computer science (like in rust), where we use "atomic interfaces" for a bits of composable functionality - or "ethereum"-like where we put in a single interface everything what is needed for a holistic user case.

For instance, we may see the following atomic contract ABIs:

If each piece of the ABIs will be made an interface, a contract can select a set of interfaces to implement - and wallets will have more freedom in presenting unknown types of the contracts in the UI.

What I tend to think is that we need a third approach: interfaces should be atomic, but large-level interfaces like RGB20 etc should provide the whole set of functionality, meaning that a wallet must be able to decompose a high-level interface into interface atoms.

I.e., in binary form (and in consignment) there will be just one/very few high-level interfaces and implementation for a contract (let's say for fungibles it will be RGB20). However, for developers and wallets we will provide an ability to do the following:

interface NamedContract
   global name: String

interface RGB20 implements NamedContract

and wallets may test a contract on supporting these ABI atoms:

   let iface = stock.contract_iface(contract_id);
   if iface.supports(NamedContract::id()) {
      // present contract name in the UI
   }
dr-orlovsky commented 1 year ago

@zoedberg ok, I think the "complex interface" approach (like we currently have with RGB20) is correct - and the other two should not be used.

Rationale: a contract may expose both NFT and a token (even several of them) and they all may have different names. Thus, accessing them through a single "atomic ABI" is invalid.

dr-orlovsky commented 1 year ago

@zoedberg added timestamps to all interfaces in https://github.com/LNP-BP/LNPBPs/pull/154/commits/bdc4f926be012bed341deeb61d08f1af42445ffc

dr-orlovsky commented 1 year ago

Merging this - we already have many rounds of discussion here and all amendments seems to be fulfilled. If something is missed - feel free to open an issue or do another PR.