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

Improve TxInvalid notifications #990

Open
pgrange opened this issue Jul 20, 2023 · 1 comment
Open

Improve TxInvalid notifications #990

pgrange opened this issue Jul 20, 2023 · 1 comment
Labels
task Subtask of a bigger feature. ux Related to user experience

Comments

@pgrange
Copy link
Contributor

pgrange commented Jul 20, 2023

Why

There are two situations were a client could be notified of a TxInvalid:

  1. when the client ask its own node to post an invalid transaction;
  2. when the node receives some invalid transaction from another peer.

In the first case, the client sending an invalid transaction to its own node seems suspicious in the sense that the client has all the information it needs to build and post a valid transaction unless, of course, another transaction concurrently spent the UTxO it plans to spend. Today, we are trying to apply this transaction locally several times and we also broadcast this transaction to our peers, making them try to apply the transaction several times. This induce a performance cost and some noise in the peers network that will almost always end up with the transaction being rejected in the end. Instead, we could immediately reject the client transaction with TxInvalid and forget about it. It will be the client's responsibility to re-submit it later if, for some reason, it then becomes valid.

In the second case, we are notifying the client about an invalid transaction that this client never heard about before. We could improve developer experience by just not bothering the client with the transaction at all at that point in time, reducing noise here.

Also, with #904 and #988, we now keep the invalid transaction in allTxs in case it is, later, included in a snapshot. This makes sense to handle conflicting transactions with the arbitrage of the leader. That means that we can now send to the client an TxInvalid to the client for a transaction it never heard about before AND later include it as a valid one in a snapshot. Even worse in terms of noise.

What

  • Transactions submitted by "our" clients via NewTx are validated against localUTxO

    • if invalid, a TxInvalid output is sent to our clients (only)
    • if valid, the transaction is broadcast as a ReqTx
  • Transactions requested by peers via ReqTx are validated against localUTxO (as it is already the case)

    • if invalid, we drop the ReqTx, but do not send a client output
    • if valid, everything continues as before

How

  1. When the hydra-node receives an invalid transaction from a peer and it's TTL expires, it does no send TxInvalid or any other notification to its client anymore (but it keeps logging as of today).
  2. When the hydra-node receives an invalid transaction from its connected client, it rejects it immediately with TxInvalid and forgets about it. It does not propagate it to its peers.

Additional info

  • We had some form of validation on NewTx in the past Align HeadLogic: Not validate tx on NewTx #745

    • this should not be a reason against this item
    • back then, we validated against the last confirmed UTxO
      • not sure why, but maybe because the GetUTxO returned to clients, i.e. the visible UTxO in the head, was querying the latest confirmed snapshot UTxO
  • TBD: Should we change GetUTxO to return the localUTxO for a more consistent local view? Or both, the confirmed and local utxo?

@pgrange pgrange added the 💭 idea An idea or feature request label Jul 20, 2023
@ch1bo
Copy link
Member

ch1bo commented Jul 21, 2023

We had validation in place on NewTx handling in the past, but it was tricky with not "getting heads stuck" too often IIRC.

Just noticed: in the api reference we still document it that way https://github.com/input-output-hk/hydra/blob/ea46f1a32085a04ec43f9c2ce270db23912c722d/hydra-node/json-schemas/api.yaml#L198

@ch1bo ch1bo mentioned this issue Jul 21, 2023
7 tasks
@ch1bo ch1bo changed the title ImproveTxInvalid notifications Improve TxInvalid notifications Jul 25, 2023
@ch1bo ch1bo added ux Related to user experience task Subtask of a bigger feature. and removed 💭 idea An idea or feature request labels Jul 25, 2023
@ffakenz ffakenz self-assigned this Oct 10, 2023
@ffakenz ffakenz removed their assignment Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Subtask of a bigger feature. ux Related to user experience
Projects
None yet
Development

No branches or pull requests

3 participants