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
Redesign of Tx/TxInBlock #2379
Redesign of Tx/TxInBlock #2379
Conversation
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.
This looks good to me. I'll integrate against it today on my branch and report back.
In one of the commit messages:
Drop 'TxInBlock' and use Core.Tx family.
Since
Tx
will now be what is submitted by the wallet/node, ...
Is there a typo in that sentence fragment? It reads like "now that X is true" but X already was true. I was expecting something like "now that Tx
(ie what the wallet/node submits) contains the same data as TxInBlock
, ...`
-- Conditions to define the rule in this Era | ||
HasField "_d" (Core.PParams era) UnitInterval, | ||
HasField "_maxBlockExUnits" (Core.PParams era) ExUnits, | ||
Era era, -- supplies WellFormed HasField, and Crypto constraints | ||
Era.TxSeq era ~ Alonzo.TxSeq era, | ||
Era.TxInBlock era ~ Alonzo.ValidatedTx era, | ||
Core.Tx era ~ Alonzo.ValidatedTx era, |
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 we discussed this on a call, but I'll risk repeating my opinion. ValidatedTx
seems like a misnomer. EG Core.Tx
is the type of a transaction that we just deserialized from the network; we haven't had a chancee to validate it beyond "does it deserialize".
On the other hand, it does carry a flag, so at least someone is claiming to have validated it.
No particular action requested, just pointing out an awkwardness/opportunity for confusion.
Edit: looking ahead, I see that we'll indirectly have Validated Alonzo.ValidatedTx
in the new mempool API, eg.
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.
Yes, sorry, the thing I forgot to do in this branch was rename ValidatedTx
, I agree that it's now a bad name!
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 have a branch on which the non-testing code compiles against this PR's branch. I'm requesting changes based on a couple discovered requirements re the Validated
newtype.
shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/API/Mempool.hs
Show resolved
Hide resolved
b3d337d
to
0b8fae3
Compare
shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/API/Mempool.hs
Show resolved
Hide resolved
8dff99f
to
a6ab504
Compare
@nfrisby Is this ok for you now? |
I think so. I'll be able to confirm that today. |
trustMe :: Bool -> Core.Tx A -> ValidatedTx A | ||
trustMe v (Core.Tx b w a) = ValidatedTx b w (IsValidating v) a | ||
trustMe :: Bool -> ValidatedTx A -> ValidatedTx A | ||
trustMe iv' (ValidatedTx b w _ m) = ValidatedTx b w (IsValidating iv') m |
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 you do not need this function anymore, the tests can just stamp the correct IsValidating
field directly.
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.
From my end, I think this looks great! It's a nice simplification.
OK, I have my downstream PR working with this PR right now, except for one last hurdle. One of my tests isn't compiling, and I think the fix would be to change the type of (There is already an Edit: if the module hierarchy makes this awkward (is |
The theme behind this change is that consensus (and the node, and components above this) will regard an Alonzo Tx to be the full Tx, including the `IsValidating` tag. Where previously we exposed the unvarnished `Tx` and kept the `TxInBlock` as a ledger-internal detail, we will now be doing the opposite - exposing the full `TxInBlock`.
Since `Tx` will now be what is submitted by the wallet/node, there is no need for a separate `TxInBlock` concept. Instead, `Tx` becomes a type family (since it _will_ vary between eras) and everything is defined in those terms. As part of this, we alter the `SupportsSegWit` type class to reflect now the isomorphism between `TxSeq` and `Seq Tx`.
This serialisation is only for use when transmitting Tx from node to node, or wallet to node.
Previously, we used the Tx/TxInBlock distinction to also embody the fact that a Tx had been validated, and hence future applications of that Tx could skip a certain number of checks, an important performance concern. Now we lack this distinction (which in any case was somewhat a conflation of concerns), so we introduce the `Validated` newtype to reflect this, and rewrite the Mempool API to reflect this.
We will drop this when downstream projects are updated.
Most of this is trivial. We modify `EraGen` to include a `constructTx`, which creates a transaction from its constituent parts.
Approximately, for the 'TranslateEra' instance.
Edit: Nevermind, I hadn't noticed that the Plutus source-repo dep needed to be updated. All clear now. |
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.
This now works for me. Thanks! Approved.
The only failures I'm now seeing are the result of the new serialization of Alonzo txs, totally expected.
This comes out of discussions with the consensus team. Rather than sending basic Shelley transactions around and computing the
IsValidating
field at the node level, we instead require consumers to compute their ownIsValidating
field. This is then verified as usual, and the node is required to verify this. Depending on the configuration, the node may choose to do different things with the transaction if the flag is set incorrectly.This may be reviewed commit by commit; they should all stand alone.