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

CPS-0009? | Coin Selection Including Native Tokens #611

Merged
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions CPS-0009/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
CPS: 9
Title: Coin Selection Including Native Tokens
Status: Open
Category: Wallets
Authors:
- Hinson Wong <[email protected]>
- Tsz Wai Wu <[email protected]>
Proposed Solutions: []
Discussions:
- https://github.com/cardano-foundation/CIPs/issues/232
- https://github.com/cardano-foundation/CIPs/pull/611
Created: 2023-10-20
---

## Abstract

The introduction of native tokens in Cardano has introduced unique challenges related to coin selection and transaction efficiency. This Cardano Problem Statement (CPS) addresses the need for a specialized coin selection approach to optimize transactions involving native tokens while minimizing transaction size and complexity.

## Problem

The integration of native tokens in Cardano transactions has brought both opportunities and challenges. One of the significant challenges is associated with coin selection when dealing with native tokens.

### 1. Need for Efficient Coin Selection

Cardano transactions involving native tokens often require attaching a minUTxO value (lovelace) to the transaction. In scenarios where multiple tokens are associated with a single UTxO, selecting such UTxOs as inputs can lead to inefficient transactions. This inefficiency arises from the increased transaction size due to token information, potentially impacting the decentralized applications and network performance.
rphair marked this conversation as resolved.
Show resolved Hide resolved

### 2. Prioritizing Necessary Tokens
rphair marked this conversation as resolved.
Show resolved Hide resolved

To improve the efficiency of Cardano transactions, there is a need to prioritize the selection of necessary tokens while excluding unnecessary ones. This prioritization will help reduce the inflation of transaction sizes, making them more streamlined and cost-effective.

### 3. Streamlining the Selection Process

In addition to token prioritization, streamlining the selection process is crucial. Enhancements should be made to the selection algorithms to ensure that even in complex scenarios, the coin selection process remains efficient and doesn't compromise the user experience.

### 4. Compatibility with Serialization Libraries

The largest off-chain serialization library, cardano-serialization-lib, still follows a modified version of the CIP-2 standard, which was established in the pre-native token era. There's a need to ensure that the proposed coin selection approach remains compatible with existing serialization libraries, making it accessible to a wider range of developers and applications.

While CIP-2 certainly works well in an environment where native assets such as tokens and NFTs don't exist, it has been expanded upon differently by each serialization library, with their own custom solutions to select for tokens. It would be useful to once again have some standard for coin selection that is trusted by the community.

## Use Cases

### Native Token Transactions

Users and applications frequently engage in native token transactions, making efficient coin selection essential to minimize transaction costs and network congestion.

### DApps and DeFi

Decentralized applications and DeFi projects require efficient coin selection to maintain the performance and cost-effectiveness of their transactions.

### Example Implementation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is the place to add this block as we discussed in biweekly. Also if anyone knows the right link pointing to the implementation for cardano wallet please help to supplement!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this makes perfect sense because Example Implementations will always be closely related to, if not qualify as, Use Cases.

Copy link
Collaborator

@rphair rphair Nov 28, 2023

Choose a reason for hiding this comment

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

so far I think this list is:
👉 the dev version of cardano-wallet @nicolasayotte mentioned in today's meeting
👉 anything open source from what @siegfried mentioned in #611 (comment)
👉 cardano-utxo-wasm as per #611 (review)

Some real world use cases of the coin selection algorithm taking Native Token into account is listed below:
1. [UTxO utils of Cardano in WASM](https://www.npmjs.com/package/cardano-utxo-wasm)
2. Cardano Wallet (link to be supplied)
rphair marked this conversation as resolved.
Show resolved Hide resolved
3. [cardano-multiplatform-lib](https://github.com/dcSpark/cardano-multiplatform-lib)

### Network Scalability

Efficient coin selection contributes to network scalability by reducing the size and complexity of transactions, ensuring smooth and rapid processing.

## Goals

### Specialized Coin Selection Approach

The primary goal of this CPS is to establish a specialized coin selection approach for transactions involving native tokens in Cardano. This approach should prioritize necessary tokens, improve transaction efficiency, and minimize the impact of native token inclusion on transaction size.

### Streamlined Transactions

By optimizing coin selection, we aim to streamline Cardano transactions, reducing their size and complexity while preserving the integrity of native token operations.

### Cross-Compatibility

The proposed approach should remain compatible with existing off-chain serialization libraries and protocols, ensuring accessibility to a wide range of developers and projects.

### Improved Network Performance

Efficient coin selection contributes to overall network performance, making Cardano more scalable and reliable for users, DApps, and DeFi.

## Open Questions

### Implementation

1. How can we effectively implement and promote the specialized coin selection approach?
2. What changes, enhancements, or protocols need to be adopted within the Cardano ecosystem to achieve this?
3. Is there any community collective intelligence could gather for this area? Particularly, would engineers from Emurgo (who maintain the `cardano-serialization-lib`) and developer of `cardano-cardano-multiplatform-lib` got any form of insight to push forth the community progress?

### Developer Education

1. Is there any changes on application code itself with the improvement on coin selection algorithm?
2. If so, how can developers be educated and informed about the new coin selection approach to ensure its successful adoption and integration into their projects?

### Community Consensus

1. How can we gather and build consensus within the Cardano community regarding the proposed coin selection approach?
2. Do we need any support from academia with formal proof to impose the standard?
3. What methods can be employed to ensure widespread acceptance and adoption? Do we need endorsement from any of IOHK, CF or Emurgo?
4. If academic formal research is not needed for this consensus, how can we set the bar for acceptable algorithm? Would there be core committee making the decision?