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

Incorrect output_index stored for return collaterals #101

Closed
jy14898 opened this issue Jan 6, 2023 · 6 comments
Closed

Incorrect output_index stored for return collaterals #101

jy14898 opened this issue Jan 6, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jy14898
Copy link

jy14898 commented Jan 6, 2023

What Git revision / release tag are you using?

v2.2.0

Describe what the problem is?

Submitting a transaction which will fail phase 2 validation, with the is_valid field of the transaction set to false to allow submission, results in the outputs of such a transaction being indexed the collateral return outputs of such a transaction being incorrectly indexed in the matches endpoint. This results in unspendable utxos being listed in wallets, for example

What should be the expected behavior?

When is_valid is set to false, outputs should not be listed. I have not checked, but additionally we should verify the behaviour of collateral, ie that it should be marked as spent and collateral return outputs be indexed.

If applicable, what are the logs from the server around the occurence of the problem?

@KtorZ
Copy link
Member

KtorZ commented Jan 6, 2023

Hi, do you have an example of such a scenario? Are you sure that the indexed outputs do not correspond to a collateral change output resulting from the collateral consumption?

@jy14898
Copy link
Author

jy14898 commented Jan 6, 2023

Hmm, I'll check. It's possible it could be collateral return, but I was having trouble spending these outputs via ogmios.

@jy14898
Copy link
Author

jy14898 commented Jan 6, 2023

I think it is a collateral return, but blockfrost vs kupo return different tx and output indexes:

https://cardano-preview.blockfrost.io/api/v0/addresses/addr_test1vr69f80dfrmrfp77xg55zqzwfc4lf5pk65fxtnue2m3ffrspkhx6a/utxos
[
  {
    "address": "addr_test1vr69f80dfrmrfp77xg55zqzwfc4lf5pk65fxtnue2m3ffrspkhx6a",
    "tx_hash": "a9bd09c6191167dcc4362b23264684f2bd596cbd2f196af5aea1715e8badb7af",
    "tx_index": 1,
    "output_index": 1,
    "amount": [
      {
        "unit": "lovelace",
        "quantity": "5000000"
      }
    ],
    "block": "0f868b414cb5549fd0fcb41c3ab616c33f9f47ae51ce8500c925a2561c699029",
    "data_hash": null,
    "inline_datum": null,
    "reference_script_hash": null
  }
]
https://KUPO_INSTANCE/matches/addr_test1vr69f80dfrmrfp77xg55zqzwfc4lf5pk65fxtnue2m3ffrspkhx6a?unspent
[
  {
    "transaction_index": 3,
    "transaction_id": "a9bd09c6191167dcc4362b23264684f2bd596cbd2f196af5aea1715e8badb7af",
    "output_index": 0,
    "address": "addr_test1vr69f80dfrmrfp77xg55zqzwfc4lf5pk65fxtnue2m3ffrspkhx6a",
    "value": {
      "coins": 5000000,
      "assets": {}
    },
    "datum_hash": null,
    "script_hash": null,
    "created_at": {
      "slot_no": 6356319,
      "header_hash": "0f868b414cb5549fd0fcb41c3ab616c33f9f47ae51ce8500c925a2561c699029"
    },
    "spent_at": null
  }
]

@jy14898
Copy link
Author

jy14898 commented Jan 6, 2023

I think blockfrost's tx_index is wrong here, so maybe ignore that.

@jy14898
Copy link
Author

jy14898 commented Jan 6, 2023

Also to confirm kupos output index is wrong:

$ cardano-cli query utxo --address addr_test1vr69f80dfrmrfp77xg55zqzwfc4lf5pk65fxtnue2m3ffrspkhx6a --testnet-magic 2
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
a9bd09c6191167dcc4362b23264684f2bd596cbd2f196af5aea1715e8badb7af     1        5000000 lovelace + TxOutDatumNone

@KtorZ
Copy link
Member

KtorZ commented Jan 7, 2023

Ho, I see. The index is off because collateral return aren't indexes from zero, but as if they were a continuation of the existing output set.

Thanks for catching that, will fix asap.

@KtorZ KtorZ changed the title Outputs of transactions which fail phase 2 validation are indexed Incorrect output_index stored for return collaterals Jan 8, 2023
@KtorZ KtorZ closed this as completed in 66641cb Jan 8, 2023
@KtorZ KtorZ added the bug Something isn't working label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants