qtumproject / qips

Qtum Improvement Proposals
9 stars 2 forks source link

QIP-4: Add address-local data store with authentication (brainstorming) #4

Open Earlz opened 6 years ago

Earlz commented 6 years ago

Abstract

Right now, if you have a cryptokitty contract, all state for all users must be present in the contract's state at all times. This is the normal for smart contract platforms today. In order to transfer a kitty from user A to user B, user A would call the contract and the contract would basically change a flag to say "this kitty belongs to B now, not A".

This large global state concept is a big problem for many off-chain scaling solutions, including Plasma. This also has an impact on potential future on-chain scaling solutions like sharding. If a contract must be placed in a single shard, or constantly communicate with other shards it will not be ideal.

This proposal is to add a new type of data storage for x86 contracts (retrofitting this in the EVM is not trivial). This storage will be namespaced per sending address and per contract. So, if you have sender A and contract X, that storage space would effectively be exclusive to A:X. Sender A is not capable of modifying data in A:X without logic in X allowing it, and contract X is not capable of modifying data, without the sender (and thus being given authorization) is A.

This effectively allows A to prove ownership of an asset to X solely by having some data in this special storage area. A really interesting use case is that it could be possible for a precompiled contract or some other special function to be constructed that allows A:X state to be moved to B:X state without executing contract X. This would be ideal for ERC20 contracts or crypto kitties. It is especially suitable for any non-fungible asset though.

There's a lot of problems still being figured out for this, but thus far it seems like Qtum's UTXO model could offer a substantial advantage if some kind of metadata could be attached to UTXOs.