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

someUTxO does not actually update envUsedSomeUTxOs in GYTxMonadNode #318

Open
TotallyNotChase opened this issue Jul 3, 2024 · 3 comments

Comments

@TotallyNotChase
Copy link
Contributor

Describe the bug
If we look at the current someUTxO implementation for GYTxMonadNode:

someUTxO lang = do
    addrs           <- ownAddresses
    utxosToConsider <- availableUTxOs
    case lang of
      PlutusV2 ->
        case someTxOutRef utxosToConsider  of
            Just (oref, _) -> return oref
            Nothing        -> throwError . GYQueryUTxOException $ GYNoUtxosAtAddress addrs
      PlutusV1 ->
        case find utxoTranslatableToV1 $ utxosToList utxosToConsider of
          Just u  -> return $ utxoRef u
          Nothing -> throwError . GYQueryUTxOException $ GYNoUtxosAtAddress addrs  -- TODO: Better error message here?

We notice that the returned UTxO isn't actually removed from envUsedSomeUTxO. This seems problematic since the point of envUsedSomeUTxO is to track previously yielded someUTxOs so they aren't returned repeatedly.

As it currently stands, the field envUsedSomeUTxO is actually useless.

Expected behavior

envUsedSomeUTxO should be updated accordingly.

Additional context

Has this always been like this? I thought it used to work.

@TotallyNotChase
Copy link
Contributor Author

Tangentially related but the framework should use availableUTxOs wherever possible to obtain own utxos, instead of querying the own addresses.

@TotallyNotChase
Copy link
Contributor Author

Also, someUTxO impl for GYTxMonadNode should really be replaced with the randomTxOutRef from GYUTxO

@sourabhxyz
Copy link
Member

As it currently stands, the field envUsedSomeUTxO is actually useless.

That is true, I think it never served any meaningful purpose and was just there in case we wanted to give it some meaning.

We notice that the returned UTxO isn't actually removed from envUsedSomeUTxO. This seems problematic since the point of envUsedSomeUTxO is to track previously yielded someUTxOs so they aren't returned repeatedly.

I think you meant that it is not added to envUsedSomeUTxOs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants