rgb-archive / spec

[OLD!] RGB Protocol specifications for Bitcoin-based digital assets
https://rgb-org.github.io/
147 stars 26 forks source link

Decide how to "sort" transactions in the same block #18

Closed afilini closed 6 years ago

afilini commented 6 years ago

This is necessary to make something similar to the "crowdsale" contract implemented in the proof of concept: this kind of contract "mints" new tokens whenever a transaction which sends some satoshis to a predetermined address is seen on the blockchain. This transaction itself is then used as the first node of the chain of proofs1.

We have to agree on a criteria to "sort" all of those transactions buying tokens, because when we reach the max supply of tokens, we need to agree on who is going to get the tokens and who is going to get the "refund". If multiple transactions are confirmed in the same block we don't really have a way to know which one "comes first".

This way of distributing tokens is pretty good at reducing space on the blockchain and making everything more "automatic". It's also very useful to increase privacy, since many chains of proof will be created instead of one, making it more difficult to analyze all the movements later down the chain.


1: Since the transaction NEEDS to have only two outputs (one which is paying some satoshis to the deposit address specified in the contract and the other which will receive all the tokens/change/refund), by showing that you paid some satoshis to this specific address you are actually proving that you own the tokens, as long as you can spend the second output of the transaction.

tiero commented 6 years ago

Not related to the actual issue, I will open another issue if not the right place for discussion.

I don't like to replicate the eth "gas war" in general for crowdsales.

Something like this: a personal cap for each contributor in the first 24h, If all people contribute the maximum available the sale will reach the hard cap (if exists) having a fair and equal distribution of tokens among contributors. After 24h, the personal cap will go away and whales can come in ahah

afilini commented 6 years ago

It's pretty hard to detect "the same contributor", because it's trivial to change your address in Bitcoin..

fedsten commented 6 years ago

Maybe I am missing something, but isn't the order that a miner gives to the transactions in the block sufficient for sorting purposes?

afilini commented 6 years ago

Yes, the order inside of a block could be a way. I was wondering if there was a better way, maybe by looking at fees directly (even though it would probably be the same as the "miner" order) or maybe by looking at something completely different..

fedsten commented 6 years ago

If the order has to be time-based, I don't see any other deterministic sorting solutions. A different approach could be for auction style crowdsales (which is not what is proposed in the contract example), where the ordering is based on the proposed price per token. However, I wouldn't incentivise the idea of on-chain auctions. Since they involve a lot of transaction replacement they should always be conducted over LN or other payment channel protocols.

In general, I believe that the standard crowdsale should have a time-base sorting using the miner tx order, alternative schemes (e.g. auctions, big contributors first, utxo consolidators first, proof of off-chain rank, etc) can be implemented later with other contracts.

afilini commented 6 years ago

I agree, I think we can close the issue now..