Giter Site home page Giter Site logo

Comments (6)

mikekeke avatar mikekeke commented on July 28, 2024 3

After discussion session current plan is to enable bpi to use separate constant utxo as collateral in automatic manner, such that:

  • at start bpi should create separate collateral utxo containing Ada only from UTXOs available at user wallet address (address that refers to "own PubKeyHash")
  • at start bpi should try to find suitable utxo for collateral containing Ada only from UTXOs available at user wallet address (address that refers to "own PubKeyHash"), if there is none - create separate collateral UTXO
    • default amount of Ada for such UTXO will be 10 Ada, but can also be specified via bpi config
  • bpi tracks this collateral UTXO in memory excluding it from queries performed by contracts and balancing (if possible)
    • collateral UTXO should not be returned in Contract queries like utxosAt
    • collateral UTXO should not be used as input (unless there is no other choice)
  • if there is no way to secure collateral UTXO from being consumed (e.g. no more UTXO left for balancing) bpi should create new UTXO that could be used as collateral while balancing transaction; in this case some warning log message could be handy to make user aware of situation

from bot-plutus-interface.

GeorgeFlerovsky avatar GeorgeFlerovsky commented on July 28, 2024

I strongly prefer Solution 2.

from bot-plutus-interface.

mikekeke avatar mikekeke commented on July 28, 2024

There are two problems with this approach

There is one more issue found - case when Ada value of picked collateral is not enough for calculated fee:

Result: ExecutionResult {outcome = Left (ContractExecutionError "WalletContractError (OtherError \"ExitCode 1: Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (InsufficientCollateral (Coin 2000000) (Coin 5460195))))])\\n\")")

Link to source for InsufficientCollateral

from bot-plutus-interface.

GeorgeFlerovsky avatar GeorgeFlerovsky commented on July 28, 2024

So, balancing requires collateral to be selected, because balancing involves calculating the tx fee and thus the change output?

If that's the case, then I would suggest the following silly workaround:

  1. Select the largest utxo available and set it as the collateral input, for the purposes of balancing. (This minimizes the chance that balancing will fail due to insufficient collateral during fee calculation -- if that's possible)
  2. After balancing, replace the collateral input in the balanced transaction with the smallest utxo that is larger than the required collateral amount.

Assuming that replacing one collateral input for another in the transaction balanced transaction does not affect fees (I don't think it should), this should give you what you want, improving upon the "random collateral" selection rule.

--

Alternatively, if fee calculation during balancing does not check for collateral sufficiency/existence, then don't set collateral before balancing --- do balancing first and then set collateral to the smallest sufficient utxo.

from bot-plutus-interface.

TotallyNotChase avatar TotallyNotChase commented on July 28, 2024

Some more thoughts:-

I was looking into some plutip transactions case by case in an interactive environment and it dawned on me that the "No collateral" issue pops up primarily after a minting transaction where the minted token is paid to your wallet. The new tokens must be put within some ada utxo, but it looks like the balancing algo BPI uses is very eager to jumble up a lot of your existing "small ada change" utxos into one and then put the new tokens inside it.
So even if you start with a lot of small ada utxos in change, if your mint + pay to self transactions don't explicitly distribute ada, it might be jumbled up after a few transactions.

This can be solved by putting an explicit constraint that says "create this much ada only utxos as outputs" but the crux of the issue really seems like it lies on the balancing algo IMO. The contract endpoint needs to know how much ada a particular user has to do a "distribute ada" in a UX friendly manner, but that's not the contract's job! It should be the balancer's job.

from bot-plutus-interface.

mikekeke avatar mikekeke commented on July 28, 2024

Done in #124 and #133

from bot-plutus-interface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.