-
Notifications
You must be signed in to change notification settings - Fork 88
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
Proposed snapshot should contain only seen transactions #904
Conversation
Transactions CostsSizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using
Script summary
Cost of Init Transaction
Cost of Commit TransactionThis is using ada-only outputs for better comparability.
Cost of CollectCom Transaction
Cost of Close Transaction
Cost of Contest Transaction
Cost of Abort TransactionSome variation because of random mixture of still initial and already committed outputs.
Cost of FanOut TransactionInvolves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Therefore, I think we should augment the protocol to (at least) require that txs in a snapshot have been previously seen in a ReqTx.
In the original protocol a ReqSn
was only ever requesting transactions to be snapshotted by id. We (over-)simplified this to have snapshot requests include the transactions directly. This is definitely a performance problem, but maybe you are on to something bigger here? The issue #728 would tackle this.
it's super easy for any node to front-run other nodes
How? Any node would apply the transaction once seen to their seen ledger and not agree with another transaction spending the same input, but differently. Or is this maybe a use case where the thing to be "raced on" is not represented as a UTxO being spent?
The problem I am seeing is not related to performance, only to the fact that a node can receive a snapshot containing arbitrary transactions, even ones it has not yet seen, as long of course as that snapshot makes sense with the latest known one. This makes it possible for a node to "front-run" another node by: 1/ receiving a Perhaps this is not a real problem? As explained in the PR's description this dawned on me while trying to think about how a node could propose "atomic" transaction sets and how to enforce that in the protocol. |
No, I think you are right and this is a real problem. Which makes #728 much more important! |
Imagine B want to be evil and sign snapshot with its own not submitted transaction instead of another legit one. Suppose it's B's turn to be the leader. I understand that the concern of this issue would be to prevent the following scenario to occur:
If we implement this issue, now A will only sign the snapshot if it has seen Tb before receive the snapshot. I can see the following scenario leading to the same result as before:
Are these scenario correct in the context of this issue or did I miss something? |
@pgrange You are right, this issue exposes only part of the problem of the lack of fairness in the Hydra consensus protocol. But a big difference with the previous situation is that if |
b92e7da
to
6c0f8f4
Compare
d43b5e8
to
86654d8
Compare
Test Results342 tests +7 336 ✔️ +7 27m 6s ⏱️ + 4m 1s Results for commit 2511d45. ± Comparison against base commit 14db869. This pull request removes 1 and adds 8 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a protocol change in the direction where we actually want to be (as also described in #728).
Not sure if it's worthwhile to stop half-way and not do the full switch into ReqSn
only holds txId. That would be more intuitive, I guess, as then the resolution from TxId -> Tx
is naturally implying the check we do here manually now.
I can approve this change, but would be more comfortable if we would have researchers also think about this (they proposed the only send TxId with lookup of TxId -> Tx in the past, so it should be fine as this is semantically the same though).
Requested change is about updating figure 10 in the spec accordingly.
After discussing this with @ch1bo it seems to make more sense to bite the bullet and implement the "proper" |
8283a9c
to
524724b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this was quick! This only requires updating the spec now IMO (more than the one section I commented)
0fb2c1e
to
f4debad
Compare
To prepare for #903 we want to be able to combine outcomes of type `Wait` and `NewState`. This commit allows for that and provide a more cohesive Outcome algebra.
This test is currently failing on purpose. The motivation for this work comes from the idea of packing multiple transactions in a ReqTx to guarantee the atomicity of a sequence of txs. Thinking about this feature, I realised that: 1. To enforce atomicity, we would need the snapshot to contain not only individual tx but actually the ReqTx, plus the proposed new UTxO set 2. Our current head logic says nothing about the txs part of a snapshot beyond that they should be applicable to the current ledger. 3. It's therefore impossible to implement the feature and more importantly it's super easy for any node to front-run other nodes: When it's your turn to make a snapshot, just look at the proposed txs pick and chose the one you wants, and add more applicable txs of your liking. In the context of a market, or an auction perhaps, this makes it trivial to cheat as far as I understand it. Therefore, I think we should augment the protocol to (at least) require that txs in a snapshot have been previously seen in a ReqTx.
1b5b763
to
2cfe136
Compare
We previously waited on the transactions in the snapshot to be applicable to the previous snapshot (confirmed UTxO), but as we now wait for all tx to have been seen, and seeing a tx implies it to be applicable to the latest seenUTxO which itself is a derivation from the previous snapshot, it should be an error to request a snapshot which does not apply cleanly on the previous snapshot.
2cfe136
to
62d2bd3
Compare
- When trying to apply a tx upon ReqTx, if the tx is not applicable and TTL has passed we are removing the transaction from the known hydra state.
The motivation for this work comes from the idea of packing multiple transactions in a ReqTx (see #900) to guarantee the atomicity of a sequence of txs. Thinking about this feature, I realised that:
Therefore, I initially thought we should augment the protocol to (at least) require that txs in a snapshot have been previously seen in a
ReqTx
. But this is in essence what #728 implies as this implies the only way to properly apply a transaction from theReqSn
propagating only TxId is to have seen it before and be able to resolve it.Therefore, the goal of this PR is to fix #728